From 92e99866282925e07cda24de3e28a7aa4f17cf74 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Mon, 18 Jun 2012 09:31:29 +0200 Subject: [PATCH] wbemprox: Implement IWbemClassObject::Get. --- dlls/wbemprox/Makefile.in | 2 +- dlls/wbemprox/class.c | 14 +++++++++-- dlls/wbemprox/query.c | 42 ++++++++++++++++++++++++++++++++ dlls/wbemprox/wbemprox_private.h | 2 ++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/dlls/wbemprox/Makefile.in b/dlls/wbemprox/Makefile.in index 3a4d9f3b61c..f973c2f8edd 100644 --- a/dlls/wbemprox/Makefile.in +++ b/dlls/wbemprox/Makefile.in @@ -1,5 +1,5 @@ MODULE = wbemprox.dll -IMPORTS = ole32 advapi32 +IMPORTS = oleaut32 ole32 advapi32 C_SRCS = \ builtin.c \ diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c index b31dcbb569d..a1fbb709363 100644 --- a/dlls/wbemprox/class.c +++ b/dlls/wbemprox/class.c @@ -274,8 +274,18 @@ static HRESULT WINAPI class_object_Get( CIMTYPE *pType, LONG *plFlavor ) { - FIXME("%p, %s, %08x, %p, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, pType, plFlavor); - return E_NOTIMPL; + struct class_object *co = impl_from_IWbemClassObject( iface ); + struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter ); + struct view *view = ec->query->view; + + TRACE("%p, %s, %08x, %p, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, pType, plFlavor); + + if (plFlavor) + { + FIXME("flavor parameter not supported\n"); + *plFlavor = 0; + } + return get_propval( view, co->index, wszName, pVal, pType ); } static HRESULT WINAPI class_object_Put( diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c index 701d6567bfb..7b228aea505 100644 --- a/dlls/wbemprox/query.c +++ b/dlls/wbemprox/query.c @@ -347,3 +347,45 @@ done: if (hr != S_OK) free_query( query ); return hr; } + +static BOOL is_selected_prop( const struct view *view, const WCHAR *name ) +{ + const struct property *prop = view->proplist; + + if (!prop) return TRUE; + while (prop) + { + if (!strcmpiW( prop->name, name )) return TRUE; + prop = prop->next; + } + return FALSE; +} + +HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VARIANT *ret, CIMTYPE *type ) +{ + HRESULT hr; + UINT column, row = view->result[index]; + INT_PTR val; + + if (!is_selected_prop( view, name )) return WBEM_E_NOT_FOUND; + + hr = get_column_index( view->table, name, &column ); + if (hr != S_OK) return WBEM_E_NOT_FOUND; + + hr = get_value( view->table, row, column, &val ); + if (hr != S_OK) return hr; + + switch (view->table->columns[column].type) + { + case CIM_STRING: + case CIM_DATETIME: + V_VT( ret ) = VT_BSTR; + V_BSTR( ret ) = SysAllocString( (const WCHAR *)val ); + break; + default: + ERR("unhandled column type %u\n", view->table->columns[column].type); + return WBEM_E_FAILED; + } + if (type) *type = view->table->columns[column].type; + return S_OK; +} diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h index 3b4af0db822..1e3ca0c855c 100644 --- a/dlls/wbemprox/wbemprox_private.h +++ b/dlls/wbemprox/wbemprox_private.h @@ -111,6 +111,8 @@ HRESULT create_view( const struct property *, const WCHAR *, const struct expr * struct view ** ) DECLSPEC_HIDDEN; void destroy_view( struct view * ) DECLSPEC_HIDDEN; struct table *get_table( const WCHAR * ) DECLSPEC_HIDDEN; +HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *, + CIMTYPE * ) DECLSPEC_HIDDEN; HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN; HRESULT WbemServices_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;