msado15: Implement _Connection Open.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2020-10-21 11:47:14 +02:00 committed by Alexandre Julliard
parent 45295c5e07
commit 57e30f27cb
3 changed files with 54 additions and 7 deletions

View File

@ -1,5 +1,5 @@
MODULE = msado15.dll MODULE = msado15.dll
IMPORTS = oleaut32 IMPORTS = oleaut32 ole32
EXTRADLLFLAGS = -mno-cygwin EXTRADLLFLAGS = -mno-cygwin

View File

@ -23,6 +23,7 @@
#include "initguid.h" #include "initguid.h"
#include "ocidl.h" #include "ocidl.h"
#include "objbase.h" #include "objbase.h"
#include "msdasc.h"
#include "olectl.h" #include "olectl.h"
#include "msado15_backcompat.h" #include "msado15_backcompat.h"
@ -56,6 +57,7 @@ struct connection
WCHAR *provider; WCHAR *provider;
ConnectModeEnum mode; ConnectModeEnum mode;
CursorLocationEnum location; CursorLocationEnum location;
IUnknown *session;
struct connection_point cp_connev; struct connection_point cp_connev;
}; };
@ -98,6 +100,7 @@ static ULONG WINAPI connection_Release( _Connection *iface )
if (connection->cp_connev.sinks[i]) if (connection->cp_connev.sinks[i])
IUnknown_Release( connection->cp_connev.sinks[i] ); IUnknown_Release( connection->cp_connev.sinks[i] );
} }
if (connection->session) IUnknown_Release( connection->session );
heap_free( connection->cp_connev.sinks ); heap_free( connection->cp_connev.sinks );
heap_free( connection->provider ); heap_free( connection->provider );
heap_free( connection->datasource ); heap_free( connection->datasource );
@ -240,6 +243,12 @@ static HRESULT WINAPI connection_Close( _Connection *iface )
if (connection->state == adStateClosed) return MAKE_ADO_HRESULT( adErrObjectClosed ); if (connection->state == adStateClosed) return MAKE_ADO_HRESULT( adErrObjectClosed );
if (connection->session)
{
IUnknown_Release( connection->session );
connection->session = NULL;
}
connection->state = adStateClosed; connection->state = adStateClosed;
return S_OK; return S_OK;
} }
@ -273,13 +282,50 @@ static HRESULT WINAPI connection_Open( _Connection *iface, BSTR connect_str, BST
LONG options ) LONG options )
{ {
struct connection *connection = impl_from_Connection( iface ); struct connection *connection = impl_from_Connection( iface );
FIXME( "%p, %s, %s, %p, %08x\n", iface, debugstr_w(connect_str), debugstr_w(userid), IDBProperties *props;
password, options ); IDBInitialize *dbinit = NULL;
IDataInitialize *datainit;
IDBCreateSession *session = NULL;
HRESULT hr;
TRACE( "%p, %s, %s, %p, %08x\n", iface, debugstr_w(connect_str), debugstr_w(userid), password, options );
if (connection->state == adStateOpen) return MAKE_ADO_HRESULT( adErrObjectOpen ); if (connection->state == adStateOpen) return MAKE_ADO_HRESULT( adErrObjectOpen );
if (!connect_str) return E_FAIL;
connection->state = adStateOpen; if ((hr = CoCreateInstance( &CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, &IID_IDataInitialize,
return S_OK; (void **)&datainit )) != S_OK) return hr;
if ((hr = IDataInitialize_GetDataSource( datainit, NULL, CLSCTX_INPROC_SERVER, connect_str, &IID_IDBInitialize,
(IUnknown **)&dbinit )) != S_OK) goto done;
if ((hr = IDBInitialize_QueryInterface( dbinit, &IID_IDBProperties, (void **)&props )) != S_OK) goto done;
/* TODO - Update username/password if required. */
if ((userid && *userid) || (password && *password))
FIXME("Username/password parameters currently not supported\n");
if ((hr = IDBInitialize_Initialize( dbinit )) != S_OK) goto done;
if ((hr = IDBInitialize_QueryInterface( dbinit, &IID_IDBCreateSession, (void **)&session )) != S_OK) goto done;
if ((hr = IDBCreateSession_CreateSession( session, NULL, &IID_IUnknown, &connection->session )) == S_OK)
{
connection->state = adStateOpen;
}
IDBCreateSession_Release( session );
done:
if (hr != S_OK && connection->session)
{
IUnknown_Release( connection->session );
connection->session = NULL;
}
if (dbinit)
{
IDBInitialize_Uninitialize( dbinit );
IDBInitialize_Release( dbinit );
}
IDataInitialize_Release( datainit );
TRACE("ret 0x%08x\n", hr);
return hr;
} }
static HRESULT WINAPI connection_get_Errors( _Connection *iface, Errors **obj ) static HRESULT WINAPI connection_get_Errors( _Connection *iface, Errors **obj )
@ -688,6 +734,7 @@ HRESULT Connection_create( void **obj )
} }
connection->mode = adModeUnknown; connection->mode = adModeUnknown;
connection->location = adUseServer; connection->location = adUseServer;
connection->session = NULL;
connection->cp_connev.conn = connection; connection->cp_connev.conn = connection;
connection->cp_connev.riid = &DIID_ConnectionEvents; connection->cp_connev.riid = &DIID_ConnectionEvents;

View File

@ -808,12 +808,12 @@ if (0) /* Crashes on windows */
ok(!wcscmp(str, str2), "wrong string %s\n", wine_dbgstr_w(str2)); ok(!wcscmp(str, str2), "wrong string %s\n", wine_dbgstr_w(str2));
hr = _Connection_Open(connection, NULL, NULL, NULL, 0); hr = _Connection_Open(connection, NULL, NULL, NULL, 0);
todo_wine ok(hr == E_FAIL, "Failed, hr 0x%08x\n", hr); ok(hr == E_FAIL, "Failed, hr 0x%08x\n", hr);
/* Open adds trailing ; if it's missing */ /* Open adds trailing ; if it's missing */
str3 = SysAllocString(L"Provider=MSDASQL.1;Persist Security Info=False;Data Source=wine_test;"); str3 = SysAllocString(L"Provider=MSDASQL.1;Persist Security Info=False;Data Source=wine_test;");
hr = _Connection_Open(connection, NULL, NULL, NULL, adConnectUnspecified); hr = _Connection_Open(connection, NULL, NULL, NULL, adConnectUnspecified);
todo_wine ok(hr == E_FAIL, "Failed, hr 0x%08x\n", hr); ok(hr == E_FAIL, "Failed, hr 0x%08x\n", hr);
str2 = NULL; str2 = NULL;
hr = _Connection_get_ConnectionString(connection, &str2); hr = _Connection_get_ConnectionString(connection, &str2);