[PATCH 2/2] msado15: Implement _Command get/putref ActiveConnection

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Fri Oct 9 02:57:15 CDT 2020


Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/msado15/command.c       | 20 ++++++++++++++++----
 dlls/msado15/tests/msado15.c |  9 +++++++++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/dlls/msado15/command.c b/dlls/msado15/command.c
index eb7b3a035eb..d19108a1a25 100644
--- a/dlls/msado15/command.c
+++ b/dlls/msado15/command.c
@@ -35,6 +35,7 @@ struct command
     LONG             ref;
     CommandTypeEnum  type;
     BSTR             text;
+    _Connection     *connection;
 };
 
 static inline struct command *impl_from_Command( _Command *iface )
@@ -80,6 +81,7 @@ static ULONG WINAPI command_Release( _Command *iface )
     if (!ref)
     {
         TRACE( "destroying %p\n", command );
+        if (command->connection) _Connection_Release(command->connection);
         heap_free( command->text );
         heap_free( command );
     }
@@ -121,14 +123,23 @@ static HRESULT WINAPI command_get_Properties( _Command *iface, Properties **prop
 
 static HRESULT WINAPI command_get_ActiveConnection( _Command *iface, _Connection **connection )
 {
-    FIXME( "%p, %p\n", iface, connection );
-    return E_NOTIMPL;
+    struct command *command = impl_from_Command( iface );
+    TRACE( "%p, %p\n", iface, connection );
+
+    *connection = command->connection;
+    if (command->connection) _Connection_AddRef(command->connection);
+    return S_OK;
 }
 
 static HRESULT WINAPI command_putref_ActiveConnection( _Command *iface, _Connection *connection )
 {
-    FIXME( "%p, %p\n", iface, connection );
-    return E_NOTIMPL;
+    struct command *command = impl_from_Command( iface );
+    TRACE( "%p, %p\n", iface, connection );
+
+    if (command->connection) _Connection_Release(command->connection);
+    command->connection = connection;
+    if (command->connection) _Connection_AddRef(command->connection);
+    return S_OK;
 }
 
 static HRESULT WINAPI command_put_ActiveConnection( _Command *iface, VARIANT connection )
@@ -343,6 +354,7 @@ HRESULT Command_create( void **obj )
     command->Command_iface.lpVtbl = &command_vtbl;
     command->type = adCmdUnknown;
     command->text = NULL;
+    command->connection = NULL;
     command->ref = 1;
 
     *obj = &command->Command_iface;
diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c
index efcee58c561..378c2eb918c 100644
--- a/dlls/msado15/tests/msado15.c
+++ b/dlls/msado15/tests/msado15.c
@@ -850,6 +850,7 @@ static void test_Command(void)
     Command25 *command25;
     CommandTypeEnum cmd_type = adCmdUnspecified;
     BSTR cmd_text = (BSTR)"test";
+    _Connection *connection;
 
     hr = CoCreateInstance( &CLSID_Command, NULL, CLSCTX_INPROC_SERVER, &IID__Command, (void **)&command );
     ok( hr == S_OK, "got %08x\n", hr );
@@ -903,6 +904,14 @@ static void test_Command(void)
     ok( hr == S_OK, "got %08x\n", hr );
     ok( !wcscmp( L"test", cmd_text ), "got %p\n", wine_dbgstr_w( cmd_text ) );
 
+    connection = (_Connection*)0xdeadbeef;
+    hr = _Command_get_ActiveConnection( command,  &connection );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( connection == NULL, "got %p\n", connection );
+
+    hr = _Command_putref_ActiveConnection( command,  NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
     _Command_Release( command );
 }
 
-- 
2.28.0




More information about the wine-devel mailing list