Commit 2262e048 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

msado15: Implement _Connection Get/Put Provider.

parent d136c755
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment