From 090f2c60072475ad8f974a33c89ce029cdbe459b Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 28 Jun 2024 20:57:30 +1000 Subject: [PATCH] msado15: Implement _Command::get_Parameters. --- dlls/msado15/command.c | 165 ++++++++++++++++++++++++++++++++- dlls/msado15/main.c | 1 + dlls/msado15/msado15_private.h | 1 + dlls/msado15/tests/msado15.c | 13 +++ 4 files changed, 178 insertions(+), 2 deletions(-) diff --git a/dlls/msado15/command.c b/dlls/msado15/command.c index 762a13c8776..de5dcc0233e 100644 --- a/dlls/msado15/command.c +++ b/dlls/msado15/command.c @@ -33,6 +33,7 @@ struct command { _Command Command_iface; ADOCommandConstruction ADOCommandConstruction_iface; + Parameters Parameters_iface; LONG ref; CommandTypeEnum type; BSTR text; @@ -49,6 +50,156 @@ static inline struct command *impl_from_ADOCommandConstruction( ADOCommandConstr return CONTAINING_RECORD( iface, struct command, ADOCommandConstruction_iface ); } +static inline struct command *impl_from_Parameters( Parameters *iface ) +{ + return CONTAINING_RECORD( iface, struct command, Parameters_iface ); +} + +static HRESULT WINAPI parameters_QueryInterface(Parameters *iface, REFIID riid, void **obj) +{ + TRACE( "%p, %s, %p\n", iface, debugstr_guid(riid), obj ); + + *obj = NULL; + + if (IsEqualIID(riid, &IID_IUnknown) || + IsEqualIID(riid, &IID_IDispatch) || + IsEqualIID(riid, &IID__Collection) || + IsEqualIID(riid, &IID__DynaCollection) || + IsEqualIID(riid, &IID_Parameters)) + { + *obj = iface; + } + else + { + FIXME( "interface %s not implemented\n", debugstr_guid(riid) ); + return E_NOINTERFACE; + } + + Parameters_AddRef( iface ); + return S_OK; +} + +static ULONG WINAPI parameters_AddRef(Parameters *iface) +{ + struct command *command = impl_from_Parameters( iface ); + return _Command_AddRef(&command->Command_iface); +} + +static ULONG WINAPI parameters_Release(Parameters *iface) +{ + struct command *command = impl_from_Parameters( iface ); + return _Command_Release(&command->Command_iface); +} + +static HRESULT WINAPI parameters_GetTypeInfoCount(Parameters *iface, UINT *count) +{ + struct command *command = impl_from_Parameters( iface ); + TRACE( "%p, %p\n", command, count ); + *count = 1; + return S_OK; +} + +static HRESULT WINAPI parameters_GetTypeInfo(Parameters *iface, UINT index, LCID lcid, ITypeInfo **info) +{ + struct command *command = impl_from_Parameters( iface ); + TRACE( "%p, %u, %lu, %p\n", command, index, lcid, info ); + return get_typeinfo(Parameters_tid, info); +} + +static HRESULT WINAPI parameters_GetIDsOfNames(Parameters *iface, REFIID riid, LPOLESTR *names, UINT count, + LCID lcid, DISPID *dispid) +{ + struct command *command = impl_from_Parameters( iface ); + HRESULT hr; + ITypeInfo *typeinfo; + + TRACE( "%p, %s, %p, %u, %lu, %p\n", command, debugstr_guid(riid), names, count, lcid, dispid ); + + hr = get_typeinfo(Parameters_tid, &typeinfo); + if(SUCCEEDED(hr)) + { + hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, dispid); + ITypeInfo_Release(typeinfo); + } + + return hr; +} + +static HRESULT WINAPI parameters_Invoke(Parameters *iface, DISPID member, REFIID riid, LCID lcid, WORD flags, + DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep_info, UINT *arg_err) +{ + struct command *command = impl_from_Parameters( iface ); + HRESULT hr; + ITypeInfo *typeinfo; + + TRACE( "%p, %ld, %s, %ld, %d, %p, %p, %p, %p\n", command, member, debugstr_guid(riid), lcid, flags, params, + result, excep_info, arg_err ); + + hr = get_typeinfo(Parameters_tid, &typeinfo); + if(SUCCEEDED(hr)) + { + hr = ITypeInfo_Invoke(typeinfo, &command->Parameters_iface, member, flags, params, + result, excep_info, arg_err); + ITypeInfo_Release(typeinfo); + } + + return hr; +} + +static HRESULT WINAPI parameters_get_Count(Parameters *iface, LONG *count) +{ + FIXME( "%p, %p\n", iface, count); + *count = 0; + return S_OK; +} + +static HRESULT WINAPI parameters__NewEnum(Parameters *iface, IUnknown **object) +{ + FIXME( "%p, %p\n", iface, object); + return E_NOTIMPL; +} + +static HRESULT WINAPI parameters_Refresh(Parameters *iface) +{ + FIXME( "%p\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI parameters_Append(Parameters *iface, IDispatch *object) +{ + FIXME( "%p, %p\n", iface, object); + return E_NOTIMPL; +} + +static HRESULT WINAPI parameters_Delete(Parameters *iface, VARIANT index) +{ + FIXME( "%p, %s\n", iface, debugstr_variant(&index)); + return E_NOTIMPL; +} + +static HRESULT WINAPI parameters_get_Item(Parameters *iface, VARIANT index, _Parameter **object) +{ + FIXME( "%p, %s, %p\n", iface, debugstr_variant(&index), object); + return E_NOTIMPL; +} + +static const struct ParametersVtbl parameters_vtbl = +{ + parameters_QueryInterface, + parameters_AddRef, + parameters_Release, + parameters_GetTypeInfoCount, + parameters_GetTypeInfo, + parameters_GetIDsOfNames, + parameters_Invoke, + parameters_get_Count, + parameters__NewEnum, + parameters_Refresh, + parameters_Append, + parameters_Delete, + parameters_get_Item +}; + static HRESULT WINAPI command_QueryInterface( _Command *iface, REFIID riid, void **obj ) { struct command *command = impl_from_Command( iface ); @@ -253,8 +404,17 @@ static HRESULT WINAPI command_CreateParameter( _Command *iface, BSTR name, DataT static HRESULT WINAPI command_get_Parameters( _Command *iface, Parameters **parameters ) { - FIXME( "%p, %p\n", iface, parameters ); - return E_NOTIMPL; + struct command *command = impl_from_Command( iface ); + + TRACE( "%p, %p\n", iface, parameters ); + + if (!parameters) + return E_INVALIDARG; + + *parameters = &command->Parameters_iface; + Parameters_AddRef(*parameters); + + return S_OK; } static HRESULT WINAPI command_put_CommandType( _Command *iface, CommandTypeEnum type ) @@ -446,6 +606,7 @@ HRESULT Command_create( void **obj ) if (!(command = malloc( sizeof(*command) ))) return E_OUTOFMEMORY; command->Command_iface.lpVtbl = &command_vtbl; command->ADOCommandConstruction_iface.lpVtbl = &construct_vtbl; + command->Parameters_iface.lpVtbl = ¶meters_vtbl; command->type = adCmdUnknown; command->text = NULL; command->connection = NULL; diff --git a/dlls/msado15/main.c b/dlls/msado15/main.c index 2d2f220c06f..2e2e5a83250 100644 --- a/dlls/msado15/main.c +++ b/dlls/msado15/main.c @@ -145,6 +145,7 @@ static REFIID tid_ids[] = { &IID__Connection, &IID_Field, &IID_Fields, + &IID_Parameters, &IID_Properties, &IID_Property, &IID__Recordset, diff --git a/dlls/msado15/msado15_private.h b/dlls/msado15/msado15_private.h index f8a515a596f..797354e7dc0 100644 --- a/dlls/msado15/msado15_private.h +++ b/dlls/msado15/msado15_private.h @@ -32,6 +32,7 @@ typedef enum tid_t { Connection_tid, Field_tid, Fields_tid, + Parameters_tid, Properties_tid, Property_tid, Recordset_tid, diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index 8826fb5b0e8..4b46848cbe7 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -1332,6 +1332,7 @@ static void test_Command(void) BSTR cmd_text = (BSTR)"test"; _Connection *connection; ADOCommandConstruction *adocommand; + Parameters *parameters, *parameters2; hr = CoCreateInstance( &CLSID_Command, NULL, CLSCTX_INPROC_SERVER, &IID__Command, (void **)&command ); ok( hr == S_OK, "got %08lx\n", hr ); @@ -1352,6 +1353,9 @@ static void test_Command(void) ok( hr == S_OK, "got %08lx\n", hr ); ADOCommandConstruction_Release( adocommand ); + hr = _Command_QueryInterface( command, &IID_Parameters, (void **)¶meters ); + ok( hr == E_NOINTERFACE, "got %08lx\n", hr ); + hr = _Command_get_CommandType( command, &cmd_type ); ok( hr == S_OK, "got %08lx\n", hr ); ok( cmd_type == adCmdUnknown, "got %08x\n", cmd_type ); @@ -1397,6 +1401,15 @@ static void test_Command(void) hr = _Command_putref_ActiveConnection( command, NULL ); ok( hr == S_OK, "got %08lx\n", hr ); + hr = _Command_get_Parameters( command, ¶meters ); + ok( hr == S_OK, "got %08lx\n", hr ); + + hr = _Command_get_Parameters( command, ¶meters2 ); + ok( hr == S_OK, "got %08lx\n", hr ); + ok( parameters == parameters2, "got %08lx\n", hr ); + Parameters_Release(parameters); + Parameters_Release(parameters2); + _Command_Release( command ); }