From 44cc7bef76f3aff0d4dc993cb2176e90b9e87e5c Mon Sep 17 00:00:00 2001 From: Gijs Vermeulen Date: Sun, 7 Jun 2020 15:51:20 +0200 Subject: [PATCH] msado15: Improve _Connection_Open/Close stubs. Signed-off-by: Gijs Vermeulen Signed-off-by: Alexandre Julliard --- dlls/msado15/connection.c | 17 ++++++++++++++--- dlls/msado15/tests/msado15.c | 27 ++++++++++++++++++++++++++- include/msado15_backcompat.idl | 6 ++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/dlls/msado15/connection.c b/dlls/msado15/connection.c index b9474e1b78e..35202d14aaa 100644 --- a/dlls/msado15/connection.c +++ b/dlls/msado15/connection.c @@ -221,8 +221,14 @@ static HRESULT WINAPI connection_get_Version( _Connection *iface, BSTR *str ) static HRESULT WINAPI connection_Close( _Connection *iface ) { - FIXME( "%p\n", iface ); - return E_NOTIMPL; + struct connection *connection = impl_from_Connection( iface ); + + TRACE( "%p\n", connection ); + + if (connection->state == adStateClosed) return MAKE_ADO_HRESULT( adErrObjectClosed ); + + connection->state = adStateClosed; + return S_OK; } static HRESULT WINAPI connection_Execute( _Connection *iface, BSTR command, VARIANT *records_affected, @@ -253,9 +259,14 @@ static HRESULT WINAPI connection_RollbackTrans( _Connection *iface ) static HRESULT WINAPI connection_Open( _Connection *iface, BSTR connect_str, BSTR userid, BSTR password, LONG options ) { + struct connection *connection = impl_from_Connection( iface ); FIXME( "%p, %s, %s, %p, %08x\n", iface, debugstr_w(connect_str), debugstr_w(userid), password, options ); - return E_NOTIMPL; + + if (connection->state == adStateOpen) return MAKE_ADO_HRESULT( adErrObjectOpen ); + + connection->state = adStateOpen; + return S_OK; } static HRESULT WINAPI connection_get_Errors( _Connection *iface, Errors **obj ) diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index 1d457a703dd..59c00948c86 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -674,7 +674,7 @@ static void test_Connection(void) ISupportErrorInfo *errorinfo; IConnectionPointContainer *pointcontainer; LONG state, timeout; - BSTR str, str2; + BSTR str, str2, str3; hr = CoCreateInstance(&CLSID_Connection, NULL, CLSCTX_INPROC_SERVER, &IID__Connection, (void**)&connection); ok( hr == S_OK, "got %08x\n", hr ); @@ -702,6 +702,9 @@ if (0) /* Crashes on windows */ ok(hr == S_OK, "Failed to get state, hr 0x%08x\n", hr); ok(state == adStateClosed, "Unexpected state value 0x%08x\n", state); + hr = _Connection_Close(connection); + ok(hr == MAKE_ADO_HRESULT(adErrObjectClosed), "got %08x\n", hr); + timeout = 0; hr = _Connection_get_CommandTimeout(connection, &timeout); ok(hr == S_OK, "Failed to get state, hr 0x%08x\n", hr); @@ -734,8 +737,30 @@ if (0) /* Crashes on windows */ hr = _Connection_get_ConnectionString(connection, &str2); ok(hr == S_OK, "Failed, hr 0x%08x\n", hr); ok(!wcscmp(str, str2), "wrong string %s\n", wine_dbgstr_w(str2)); + + hr = _Connection_Open(connection, NULL, NULL, NULL, 0); + todo_wine ok(hr == E_FAIL, "Failed, hr 0x%08x\n", hr); + + /* Open adds trailing ; if it's missing */ + str3 = SysAllocString(L"Provider=MSDASQL.1;Persist Security Info=False;Data Source=wine_test;"); + hr = _Connection_Open(connection, NULL, NULL, NULL, adConnectUnspecified); + todo_wine ok(hr == E_FAIL, "Failed, hr 0x%08x\n", hr); + + str2 = NULL; + hr = _Connection_get_ConnectionString(connection, &str2); + ok(hr == S_OK, "Failed, hr 0x%08x\n", hr); + todo_wine ok(!wcscmp(str3, str2) || broken(!wcscmp(str, str2)) /* XP */, "wrong string %s\n", wine_dbgstr_w(str2)); + + hr = _Connection_Open(connection, str, NULL, NULL, adConnectUnspecified); + todo_wine ok(hr == E_FAIL, "Failed, hr 0x%08x\n", hr); SysFreeString(str); + + str2 = NULL; + hr = _Connection_get_ConnectionString(connection, &str2); + ok(hr == S_OK, "Failed, hr 0x%08x\n", hr); + todo_wine ok(!wcscmp(str3, str2) || broken(!wcscmp(str, str2)) /* XP */, "wrong string %s\n", wine_dbgstr_w(str2)); SysFreeString(str2); + SysFreeString(str3); hr = _Connection_put_ConnectionString(connection, NULL); ok(hr == S_OK, "Failed, hr 0x%08x\n", hr); diff --git a/include/msado15_backcompat.idl b/include/msado15_backcompat.idl index 68fda6ab210..5ea9f51c1f4 100644 --- a/include/msado15_backcompat.idl +++ b/include/msado15_backcompat.idl @@ -512,6 +512,12 @@ typedef [uuid(00000531-0000-0010-8000-00aa006d2ea4)] enum EventReasonEnum adRsnMoveLast = 15 } EventReasonEnum; +typedef [uuid(00000541-0000-0010-8000-00aa006d2ea4)] enum ConnectOptionEnum +{ + adConnectUnspecified = -1, + adAsyncConnect = 0x10 +} ConnectOptionEnum; + [ uuid(00000503-0000-0010-8000-00aa006d2ea4), odl,