Alistair Leslie-Hughes : msado15: Implement _Connection Get/Put Provider.

Alexandre Julliard julliard at winehq.org
Thu Oct 8 15:20:05 CDT 2020


Module: wine
Branch: master
Commit: 2262e048270061eb148453d3d25bd3b1282ef9f0
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2262e048270061eb148453d3d25bd3b1282ef9f0

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Thu Oct  8 14:00:35 2020 +0200

msado15: Implement _Connection Get/Put Provider.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msado15/connection.c    | 26 ++++++++++++++++++++++----
 dlls/msado15/tests/msado15.c | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 5 deletions(-)

diff --git a/dlls/msado15/connection.c b/dlls/msado15/connection.c
index 5d8f78f53e..499f8b2256 100644
--- a/dlls/msado15/connection.c
+++ b/dlls/msado15/connection.c
@@ -53,6 +53,7 @@ struct connection
     ObjectStateEnum           state;
     LONG                      timeout;
     WCHAR                    *datasource;
+    WCHAR                    *provider;
     struct connection_point   cp_connev;
 };
 
@@ -96,6 +97,7 @@ static ULONG WINAPI connection_Release( _Connection *iface )
                 IUnknown_Release( connection->cp_connev.sinks[i] );
         }
         heap_free( connection->cp_connev.sinks );
+        heap_free( connection->provider );
         heap_free( connection->datasource );
         heap_free( connection );
     }
@@ -346,14 +348,29 @@ static HRESULT WINAPI connection_put_Mode( _Connection *iface, ConnectModeEnum m
 
 static HRESULT WINAPI connection_get_Provider( _Connection *iface, BSTR *str )
 {
-    FIXME( "%p, %p\n", iface, str );
-    return E_NOTIMPL;
+    struct connection *connection = impl_from_Connection( iface );
+    BSTR provider = NULL;
+
+    TRACE( "%p, %p\n", iface, str );
+
+    if (connection->provider && !(provider = SysAllocString( connection->provider ))) return E_OUTOFMEMORY;
+    *str = provider;
+    return S_OK;
 }
 
 static HRESULT WINAPI connection_put_Provider( _Connection *iface, BSTR str )
 {
-    FIXME( "%p, %s\n", iface, debugstr_w(str) );
-    return E_NOTIMPL;
+    struct connection *connection = impl_from_Connection( iface );
+    WCHAR *provider = NULL;
+
+    TRACE( "%p, %s\n", iface, debugstr_w(str) );
+
+    if (!str) return MAKE_ADO_HRESULT(adErrInvalidArgument);
+
+    if (!(provider = strdupW( str ))) return E_OUTOFMEMORY;
+    heap_free( connection->provider );
+    connection->provider = provider;
+    return S_OK;
 }
 
 static HRESULT WINAPI connection_get_State( _Connection *iface, LONG *state )
@@ -646,6 +663,7 @@ HRESULT Connection_create( void **obj )
     connection->state = adStateClosed;
     connection->timeout = 30;
     connection->datasource = NULL;
+    connection->provider = SysAllocString(L"MSDASQL");
 
     connection->cp_connev.conn = connection;
     connection->cp_connev.riid = &DIID_ConnectionEvents;
diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c
index 1629fe15be..bedca96368 100644
--- a/dlls/msado15/tests/msado15.c
+++ b/dlls/msado15/tests/msado15.c
@@ -718,15 +718,50 @@ if (0)   /* Crashes on windows */
     ok(hr == S_OK, "Failed to get state, hr 0x%08x\n", hr);
     ok(timeout == 300, "Unexpected timeout value %d\n", timeout);
 
+    /* Default */
     str = (BSTR)0xdeadbeef;
-    hr = _Connection_get_ConnectionString(connection, &str);
+    hr = _Connection_get_Provider(connection, &str);
+    ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
+    ok(!wcscmp(str, L"MSDASQL"), "wrong string %s\n", wine_dbgstr_w(str));
+    SysFreeString(str);
+
+    str = SysAllocString(L"MSDASQL.1");
+    hr = _Connection_put_Provider(connection, str);
+    ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
+    SysFreeString(str);
+
+    str = (BSTR)0xdeadbeef;
+    hr = _Connection_get_Provider(connection, &str);
+    ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
+    ok(!wcscmp(str, L"MSDASQL.1"), "wrong string %s\n", wine_dbgstr_w(str));
+
+    /* Restore default */
+    str = SysAllocString(L"MSDASQL");
+    hr = _Connection_put_Provider(connection, str);
     ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
+    SysFreeString(str);
+
+    hr = _Connection_put_Provider(connection, NULL);
+    ok(hr == MAKE_ADO_HRESULT(adErrInvalidArgument), "got 0x%08x\n", hr);
+    SysFreeString(str);
+
+    str = (BSTR)0xdeadbeef;
+    hr = _Connection_get_ConnectionString(connection, &str);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
     ok(str == NULL, "got %p\n", str);
 
     str = SysAllocString(L"Provider=MSDASQL.1;Persist Security Info=False;Data Source=wine_test");
     hr = _Connection_put_ConnectionString(connection, str);
     ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
 
+    /* Show put_ConnectionString effects Provider */
+    str3 = (BSTR)0xdeadbeef;
+    hr = _Connection_get_Provider(connection, &str3);
+    ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
+    ok(str3 != NULL, "Expected value got NULL\n");
+    todo_wine ok(!wcscmp(str3, L"MSDASQL.1"), "wrong string %s\n", wine_dbgstr_w(str3));
+    SysFreeString(str3);
+
 if (0) /* Crashes on windows */
 {
     hr = _Connection_get_ConnectionString(connection, NULL);




More information about the wine-cvs mailing list