Hans Leidekker : wbemprox: Add support for enumerating class properties.

Alexandre Julliard julliard at winehq.org
Mon Jul 30 14:18:52 CDT 2012


Module: wine
Branch: master
Commit: 348e5d85fa5fac43dcbd228ca431ad949167285f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=348e5d85fa5fac43dcbd228ca431ad949167285f

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Mon Jul 30 15:05:09 2012 +0200

wbemprox: Add support for enumerating class properties.

---

 dlls/wbemprox/class.c            |   39 ++++++++++++++++++++++++++++++++-----
 dlls/wbemprox/table.c            |   18 +++++++++++++++++
 dlls/wbemprox/wbemprox_private.h |    1 +
 3 files changed, 52 insertions(+), 6 deletions(-)

diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c
index e9f1f13..030aed5 100644
--- a/dlls/wbemprox/class.c
+++ b/dlls/wbemprox/class.c
@@ -220,6 +220,7 @@ struct class_object
     IEnumWbemClassObject *iter;
     UINT index;
     UINT index_method;
+    UINT index_property;
 };
 
 static inline struct class_object *impl_from_IWbemClassObject(
@@ -351,8 +352,14 @@ static HRESULT WINAPI class_object_BeginEnumeration(
     IWbemClassObject *iface,
     LONG lEnumFlags )
 {
-    FIXME("%p, %08x\n", iface, lEnumFlags);
-    return E_NOTIMPL;
+    struct class_object *co = impl_from_IWbemClassObject( iface );
+
+    TRACE("%p, %08x\n", iface, lEnumFlags);
+
+    if (lEnumFlags) FIXME("flags 0x%08x not supported\n", lEnumFlags);
+
+    co->index_property = 0;
+    return S_OK;
 }
 
 static HRESULT WINAPI class_object_Next(
@@ -363,15 +370,34 @@ static HRESULT WINAPI class_object_Next(
     CIMTYPE *pType,
     LONG *plFlavor )
 {
-    FIXME("%p, %08x, %p, %p, %p, %p\n", iface, lFlags, strName, 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;
+    const WCHAR *property;
+    HRESULT hr;
+
+    TRACE("%p, %08x, %p, %p, %p, %p\n", iface, lFlags, strName, pVal, pType, plFlavor);
+
+    if (!(property = get_property_name( co->name, co->index_property ))) return WBEM_S_NO_MORE_DATA;
+    if (!(*strName = SysAllocString( property ))) return E_OUTOFMEMORY;
+    if ((hr = get_propval( view, co->index, property, pVal, pType, plFlavor ) != S_OK))
+    {
+        SysFreeString( *strName );
+        return hr;
+    }
+    co->index_property++;
+    return S_OK;
 }
 
 static HRESULT WINAPI class_object_EndEnumeration(
     IWbemClassObject *iface )
 {
-    FIXME("%p\n", iface);
-    return E_NOTIMPL;
+    struct class_object *co = impl_from_IWbemClassObject( iface );
+
+    TRACE("%p\n", iface);
+
+    co->index_property = 0;
+    return S_OK;
 }
 
 static HRESULT WINAPI class_object_GetPropertyQualifierSet(
@@ -773,6 +799,7 @@ HRESULT create_class_object(
     co->iter           = iter;
     co->index          = index;
     co->index_method   = 0;
+    co->index_property = 0;
     if (iter) IEnumWbemClassObject_AddRef( iter );
 
     *obj = &co->IWbemClassObject_iface;
diff --git a/dlls/wbemprox/table.c b/dlls/wbemprox/table.c
index 231c27d..6b584ff 100644
--- a/dlls/wbemprox/table.c
+++ b/dlls/wbemprox/table.c
@@ -349,3 +349,21 @@ const WCHAR *get_method_name( const WCHAR *class, UINT index )
     }
     return NULL;
 }
+
+const WCHAR *get_property_name( const WCHAR *class, UINT index )
+{
+    struct table *table;
+    UINT i, count = 0;
+
+    if (!(table = get_table( class ))) return NULL;
+
+    for (i = 0; i < table->num_cols; i++)
+    {
+        if (!(table->columns[i].type & COL_FLAG_METHOD))
+        {
+            if (index == count) return table->columns[i].name;
+            count++;
+        }
+    }
+    return NULL;
+}
diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h
index f6aa2b8..69b04e7 100644
--- a/dlls/wbemprox/wbemprox_private.h
+++ b/dlls/wbemprox/wbemprox_private.h
@@ -152,6 +152,7 @@ HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYP
 HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN;
 HRESULT get_object( const WCHAR *, IWbemClassObject ** ) DECLSPEC_HIDDEN;
 const WCHAR *get_method_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
+const WCHAR *get_property_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
 
 HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
 HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list