Commit 4963da25 authored by Aaro Altonen's avatar Aaro Altonen Committed by Alexandre Julliard

msado15: Implement _Command get/put CommandText.

parent f1e7d5bb
......@@ -31,9 +31,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msado15);
struct command
{
_Command Command_iface;
LONG ref;
CommandTypeEnum type;
_Command Command_iface;
LONG ref;
CommandTypeEnum type;
BSTR text;
};
static inline struct command *impl_from_Command( _Command *iface )
......@@ -79,6 +80,7 @@ static ULONG WINAPI command_Release( _Command *iface )
if (!ref)
{
TRACE( "destroying %p\n", command );
heap_free( command->text );
heap_free( command );
}
return ref;
......@@ -137,14 +139,27 @@ static HRESULT WINAPI command_put_ActiveConnection( _Command *iface, VARIANT con
static HRESULT WINAPI command_get_CommandText( _Command *iface, BSTR *text )
{
FIXME( "%p, %p\n", iface, text );
return E_NOTIMPL;
struct command *command = impl_from_Command( iface );
BSTR cmd_text = NULL;
TRACE( "%p, %p\n", command, text );
if (command->text && !(cmd_text = SysAllocString( command->text ))) return E_OUTOFMEMORY;
*text = cmd_text;
return S_OK;
}
static HRESULT WINAPI command_put_CommandText( _Command *iface, BSTR text )
{
FIXME( "%p, %s\n", iface, debugstr_w(text) );
return E_NOTIMPL;
struct command *command = impl_from_Command( iface );
WCHAR *source = NULL;
TRACE( "%p, %s\n", command, debugstr_w( text ) );
if (text && !(source = strdupW( text ))) return E_OUTOFMEMORY;
heap_free( command->text );
command->text = source;
return S_OK;
}
static HRESULT WINAPI command_get_CommandTimeout( _Command *iface, LONG *timeout )
......@@ -327,6 +342,7 @@ HRESULT Command_create( void **obj )
if (!(command = heap_alloc( sizeof(*command) ))) return E_OUTOFMEMORY;
command->Command_iface.lpVtbl = &command_vtbl;
command->type = adCmdUnknown;
command->text = NULL;
command->ref = 1;
*obj = &command->Command_iface;
......
......@@ -743,6 +743,7 @@ static void test_Command(void)
Command15 *command15;
Command25 *command25;
CommandTypeEnum cmd_type = adCmdUnspecified;
BSTR cmd_text = (BSTR)"test";
hr = CoCreateInstance( &CLSID_Command, NULL, CLSCTX_INPROC_SERVER, &IID__Command, (void **)&command );
ok( hr == S_OK, "got %08x\n", hr );
......@@ -771,6 +772,31 @@ static void test_Command(void)
hr = _Command_put_CommandType( command, 0xdeadbeef );
ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08x\n", hr );
hr = _Command_get_CommandText( command, &cmd_text );
ok( hr == S_OK, "got %08x\n", hr );
ok( !cmd_text, "got %s\n", wine_dbgstr_w( cmd_text ));
hr = _Command_put_CommandText( command, NULL );
ok( hr == S_OK, "got %08x\n", hr );
cmd_text = SysAllocString( L"" );
hr = _Command_put_CommandText( command, cmd_text );
ok( hr == S_OK, "got %08x\n", hr );
SysFreeString( cmd_text );
hr = _Command_get_CommandText( command, &cmd_text );
ok( hr == S_OK, "got %08x\n", hr );
ok( cmd_text && !*cmd_text, "got %p\n", cmd_text );
cmd_text = SysAllocString( L"test" );
hr = _Command_put_CommandText( command, cmd_text );
ok( hr == S_OK, "got %08x\n", hr );
SysFreeString( cmd_text );
hr = _Command_get_CommandText( command, &cmd_text );
ok( hr == S_OK, "got %08x\n", hr );
ok( !wcscmp( L"test", cmd_text ), "got %p\n", wine_dbgstr_w( cmd_text ) );
_Command_Release( command );
}
......
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