[PATCH 0/3] MR9895: msado15: Improve adoconstruct_WrapDSOandSession implementation.
From: Piotr Caban <piotr@codeweavers.com> --- dlls/msado15/recordset.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c index c760cbabbd2..aec94e08032 100644 --- a/dlls/msado15/recordset.c +++ b/dlls/msado15/recordset.c @@ -1866,6 +1866,8 @@ static HRESULT WINAPI recordset_putref_ActiveConnection( _Recordset *iface, IDis static HRESULT WINAPI recordset_put_ActiveConnection( _Recordset *iface, VARIANT connection ) { struct recordset *recordset = impl_from_Recordset( iface ); + ADOConnectionConstruction15 *construct; + IUnknown *session; _Connection *conn; LONG state; HRESULT hr; @@ -1893,6 +1895,19 @@ static HRESULT WINAPI recordset_put_ActiveConnection( _Recordset *iface, VARIANT hr = _Connection_get_State( conn, &state ); if (SUCCEEDED(hr) && state != adStateOpen) hr = MAKE_ADO_HRESULT( adErrInvalidConnection ); + if (SUCCEEDED(hr)) + hr = _Connection_QueryInterface(conn, &IID_ADOConnectionConstruction15, (void**)&construct); + if (SUCCEEDED(hr)) + { + hr = ADOConnectionConstruction15_get_Session(construct, &session); + ADOConnectionConstruction15_Release(construct); + } + if (SUCCEEDED(hr)) + { + if (!session) hr = MAKE_ADO_HRESULT( adErrInvalidConnection ); + else IUnknown_Release(session); + } + if (FAILED(hr)) { _Connection_Release( conn ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9895
From: Piotr Caban <piotr@codeweavers.com> --- dlls/msado15/connection.c | 62 +++++++++++++++++++++--------------- dlls/msado15/tests/msado15.c | 8 +++++ 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/dlls/msado15/connection.c b/dlls/msado15/connection.c index df8571f978e..76438daa31f 100644 --- a/dlls/msado15/connection.c +++ b/dlls/msado15/connection.c @@ -969,32 +969,44 @@ static HRESULT WINAPI adoconstruct_WrapDSOandSession(ADOConnectionConstruction15 TRACE("%p, %p, %p\n", connection, dso, session); - hr = IUnknown_QueryInterface( dso, &IID_IDBProperties, (void **)&props ); - if (FAILED(hr)) return hr; - propset.guidPropertySet = DBPROPSET_DBINIT; - propset.cProperties = ARRAY_SIZE(prop); - propset.rgProperties = prop; - memset(prop, 0, sizeof(prop)); - prop[0].dwPropertyID = DBPROP_INIT_TIMEOUT; - prop[0].dwOptions = DBPROPOPTIONS_OPTIONAL; - V_VT(&prop[0].vValue) = VT_I4; - V_I4(&prop[0].vValue) = connection->conn_timeout; - prop[1].dwPropertyID = DBPROP_INIT_OLEDBSERVICES; - prop[1].dwOptions = DBPROPOPTIONS_REQUIRED; - V_VT(&prop[1].vValue) = VT_I4; - V_I4(&prop[1].vValue) = DBPROPVAL_OS_ENABLEALL; - if (connection->location != adUseClient) - V_I4(&prop[1].vValue) &= ~DBPROPVAL_OS_CLIENTCURSOR; - hr = IDBProperties_SetProperties( props, 1, &propset ); - IDBProperties_Release( props ); - if (FAILED(hr)) FIXME("SetProperties failed: %lx\n", hr); - - hr = IUnknown_QueryInterface( dso, &IID_IDBInitialize, (void **)&dbinit ); - if (FAILED(hr)) return hr; + if (dso) + { + if (connection->dso) return E_ACCESSDENIED; + + hr = IUnknown_QueryInterface( dso, &IID_IDBProperties, (void **)&props ); + if (FAILED(hr)) return hr; + propset.guidPropertySet = DBPROPSET_DBINIT; + propset.cProperties = ARRAY_SIZE(prop); + propset.rgProperties = prop; + memset(prop, 0, sizeof(prop)); + prop[0].dwPropertyID = DBPROP_INIT_TIMEOUT; + prop[0].dwOptions = DBPROPOPTIONS_OPTIONAL; + V_VT(&prop[0].vValue) = VT_I4; + V_I4(&prop[0].vValue) = connection->conn_timeout; + prop[1].dwPropertyID = DBPROP_INIT_OLEDBSERVICES; + prop[1].dwOptions = DBPROPOPTIONS_REQUIRED; + V_VT(&prop[1].vValue) = VT_I4; + V_I4(&prop[1].vValue) = DBPROPVAL_OS_ENABLEALL; + if (connection->location != adUseClient) + V_I4(&prop[1].vValue) &= ~DBPROPVAL_OS_CLIENTCURSOR; + hr = IDBProperties_SetProperties( props, 1, &propset ); + IDBProperties_Release( props ); + if (FAILED(hr)) FIXME("SetProperties failed: %lx\n", hr); + + hr = IUnknown_QueryInterface( dso, &IID_IDBInitialize, (void **)&dbinit ); + if (FAILED(hr)) return hr; + + connection->dso = dbinit; + } + + if (session) + { + if (connection->session) + IUnknown_Release(connection->session); + connection->session = session; + IUnknown_AddRef( session ); + } - connection->dso = dbinit; - connection->session = session; - IUnknown_AddRef( session ); connection->state = adStateOpen; return S_OK; } diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index 03424b9e929..3b5faec7eb7 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -3574,6 +3574,13 @@ static void test_ADOConnectionConstruction(void) hr = _Connection_QueryInterface(conn, &IID_ADOConnectionConstruction15, (void **)&conn_constr); ok(hr == S_OK, "got %08lx\n", hr); + + hr = ADOConnectionConstruction15_WrapDSOandSession(conn_constr, NULL, NULL); + ok(hr == S_OK, "got %08lx\n", hr); + hr = _Connection_get_State(conn, &state); + ok(hr == S_OK, "got %08lx\n", hr); + ok(state == adStateOpen, "state = %ld\n", state); + SET_EXPECT(open_rowset_QI_ISessionProperties); SET_EXPECT(open_rowset_QI_IBindResource); SET_EXPECT(open_rowset_QI_ICreateRow); @@ -3587,6 +3594,7 @@ static void test_ADOConnectionConstruction(void) todo_wine CHECK_CALLED(open_rowset_QI_ICreateRow); todo_wine CHECK_CALLED(dbprops_GetProperties); CHECK_CALLED(dbprops_SetProperties); + ADOConnectionConstruction15_Release(conn_constr); hr = _Connection_get_State(conn, &state); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9895
From: Piotr Caban <piotr@codeweavers.com> --- dlls/msado15/connection.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/dlls/msado15/connection.c b/dlls/msado15/connection.c index 76438daa31f..8de669c55a4 100644 --- a/dlls/msado15/connection.c +++ b/dlls/msado15/connection.c @@ -24,6 +24,7 @@ #include "initguid.h" #include "ocidl.h" #include "objbase.h" +#include "oledberr.h" #include "msdasc.h" #include "olectl.h" #include "msado15_backcompat.h" @@ -964,6 +965,7 @@ static HRESULT WINAPI adoconstruct_WrapDSOandSession(ADOConnectionConstruction15 IDBInitialize *dbinit; IDBProperties *props; DBPROPSET propset; + BOOL err = FALSE; DBPROP prop[2]; HRESULT hr; @@ -991,7 +993,28 @@ static HRESULT WINAPI adoconstruct_WrapDSOandSession(ADOConnectionConstruction15 V_I4(&prop[1].vValue) &= ~DBPROPVAL_OS_CLIENTCURSOR; hr = IDBProperties_SetProperties( props, 1, &propset ); IDBProperties_Release( props ); - if (FAILED(hr)) FIXME("SetProperties failed: %lx\n", hr); + if (hr == DB_E_ERRORSOCCURRED || hr == DB_S_ERRORSOCCURRED) + { + DBPROPIDSET propidset; + DBPROPSET *propset; + DBPROPID id[1]; + ULONG count; + + err = TRUE; + + propidset.rgPropertyIDs = id; + propidset.cPropertyIDs = ARRAY_SIZE(id); + propidset.guidPropertySet = DBPROPSET_DBINIT; + id[0] = DBPROP_INIT_TIMEOUT; + hr = IDBProperties_GetProperties( props, 1, &propidset, &count, &propset ); + if (SUCCEEDED(hr)) + { + connection->conn_timeout = V_I4( &propset[0].rgProperties[0].vValue ); + CoTaskMemFree( propset[0].rgProperties ); + CoTaskMemFree( propset ); + } + } + else if (FAILED(hr)) return hr; hr = IUnknown_QueryInterface( dso, &IID_IDBInitialize, (void **)&dbinit ); if (FAILED(hr)) return hr; @@ -1008,7 +1031,7 @@ static HRESULT WINAPI adoconstruct_WrapDSOandSession(ADOConnectionConstruction15 } connection->state = adStateOpen; - return S_OK; + return err ? DB_S_ERRORSOCCURRED : S_OK; } struct ADOConnectionConstruction15Vtbl ado_construct_vtbl = -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9895
participants (2)
-
Piotr Caban -
Piotr Caban (@piotr)