Alistair Leslie-Hughes : msado15: Implement _Connection get/put ConnectionString.
Alexandre Julliard
julliard at winehq.org
Tue Nov 10 13:46:21 CST 2020
Module: wine
Branch: stable
Commit: 8b6ec48f33e649cc5eb023963cc81f1a60b7dc60
URL: https://source.winehq.org/git/wine.git/?a=commit;h=8b6ec48f33e649cc5eb023963cc81f1a60b7dc60
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Tue Jan 28 11:36:03 2020 +0100
msado15: Implement _Connection get/put ConnectionString.
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>
(cherry picked from commit 765fc5cb319b199d1bd9fe145111ea5951c86696)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/msado15/connection.c | 24 ++++++++++++++++++++----
dlls/msado15/tests/msado15.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/dlls/msado15/connection.c b/dlls/msado15/connection.c
index 73b225628c2..2f0aa0c8dfc 100644
--- a/dlls/msado15/connection.c
+++ b/dlls/msado15/connection.c
@@ -37,6 +37,7 @@ struct connection
LONG refs;
ObjectStateEnum state;
LONG timeout;
+ WCHAR *datasource;
};
static inline struct connection *impl_from_Connection( _Connection *iface )
@@ -62,6 +63,7 @@ static ULONG WINAPI connection_Release( _Connection *iface )
if (!refs)
{
TRACE( "destroying %p\n", connection );
+ heap_free( connection->datasource );
heap_free( connection );
}
return refs;
@@ -125,14 +127,27 @@ static HRESULT WINAPI connection_get_Properties( _Connection *iface, Properties
static HRESULT WINAPI connection_get_ConnectionString( _Connection *iface, BSTR *str )
{
- FIXME( "%p, %p\n", iface, str );
- return E_NOTIMPL;
+ struct connection *connection = impl_from_Connection( iface );
+ BSTR source = NULL;
+
+ TRACE( "%p, %p\n", connection, str );
+
+ if (connection->datasource && !(source = SysAllocString( connection->datasource ))) return E_OUTOFMEMORY;
+ *str = source;
+ return S_OK;
}
static HRESULT WINAPI connection_put_ConnectionString( _Connection *iface, BSTR str )
{
- FIXME( "%p, %s\n", iface, debugstr_w(str) );
- return E_NOTIMPL;
+ struct connection *connection = impl_from_Connection( iface );
+ WCHAR *source = NULL;
+
+ TRACE( "%p, %s\n", connection, debugstr_w( !wcsstr( str, L"Password" ) ? L"<hidden>" : str ) );
+
+ if (str && !(source = strdupW( str ))) return E_OUTOFMEMORY;
+ heap_free( connection->datasource );
+ connection->datasource = source;
+ return S_OK;
}
static HRESULT WINAPI connection_get_CommandTimeout( _Connection *iface, LONG *timeout )
@@ -392,6 +407,7 @@ HRESULT Connection_create( void **obj )
connection->refs = 1;
connection->state = adStateClosed;
connection->timeout = 30;
+ connection->datasource = NULL;
*obj = &connection->Connection_iface;
TRACE( "returning iface %p\n", *obj );
diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c
index dd37dbf5a69..ca07b4c2ae0 100644
--- a/dlls/msado15/tests/msado15.c
+++ b/dlls/msado15/tests/msado15.c
@@ -661,6 +661,7 @@ static void test_Connection(void)
IRunnableObject *runtime;
ISupportErrorInfo *errorinfo;
LONG state, timeout;
+ BSTR str, str2;
hr = CoCreateInstance(&CLSID_Connection, NULL, CLSCTX_INPROC_SERVER, &IID__Connection, (void**)&connection);
ok( hr == S_OK, "got %08x\n", hr );
@@ -696,6 +697,35 @@ 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);
+ str = (BSTR)0xdeadbeef;
+ hr = _Connection_get_ConnectionString(connection, &str);
+ ok(hr == S_OK, "Failed, hr 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);
+
+if (0) /* Crashes on windows */
+{
+ hr = _Connection_get_ConnectionString(connection, NULL);
+ ok(hr == E_POINTER, "Failed, hr 0x%08x\n", hr);
+}
+
+ str2 = NULL;
+ 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));
+ SysFreeString(str);
+ SysFreeString(str2);
+
+ hr = _Connection_put_ConnectionString(connection, NULL);
+ ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
+
+ str = (BSTR)0xdeadbeef;
+ hr = _Connection_get_ConnectionString(connection, &str);
+ ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
+ ok(str == NULL, "got %p\n", str);
_Connection_Release(connection);
}
More information about the wine-cvs
mailing list