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

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


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

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

wbemprox: Add support for enumerating class methods.

---

 dlls/wbemprox/class.c            |   55 ++++++++++++++++++++++++++++++++-----
 dlls/wbemprox/table.c            |   18 ++++++++++++
 dlls/wbemprox/wbemprox_private.h |    1 +
 3 files changed, 66 insertions(+), 8 deletions(-)

diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c
index 74e1c71..e9f1f13 100644
--- a/dlls/wbemprox/class.c
+++ b/dlls/wbemprox/class.c
@@ -219,6 +219,7 @@ struct class_object
     WCHAR *name;
     IEnumWbemClassObject *iter;
     UINT index;
+    UINT index_method;
 };
 
 static inline struct class_object *impl_from_IWbemClassObject(
@@ -643,8 +644,19 @@ static HRESULT WINAPI class_object_BeginMethodEnumeration(
     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);
+
+    if (co->iter)
+    {
+        WARN("not allowed on instance\n");
+        return WBEM_E_ILLEGAL_OPERATION;
+    }
+    co->index_method = 0;
+    return S_OK;
 }
 
 static HRESULT WINAPI class_object_NextMethod(
@@ -654,15 +666,41 @@ static HRESULT WINAPI class_object_NextMethod(
     IWbemClassObject **ppInSignature,
     IWbemClassObject **ppOutSignature)
 {
-    FIXME("%p, %08x, %p, %p, %p\n", iface, lFlags, pstrName, ppInSignature, ppOutSignature);
-    return E_NOTIMPL;
+    struct class_object *co = impl_from_IWbemClassObject( iface );
+    const WCHAR *method;
+    HRESULT hr;
+
+    TRACE("%p, %08x, %p, %p, %p\n", iface, lFlags, pstrName, ppInSignature, ppOutSignature);
+
+    if (!(method = get_method_name( co->name, co->index_method ))) return WBEM_S_NO_MORE_DATA;
+
+    hr = create_signature( co->name, method, PARAM_IN, ppInSignature );
+    if (hr != S_OK) return hr;
+
+    hr = create_signature( co->name, method, PARAM_OUT, ppOutSignature );
+    if (hr != S_OK) IWbemClassObject_Release( *ppInSignature );
+    else
+    {
+        if (!(*pstrName = SysAllocString( method )))
+        {
+            IWbemClassObject_Release( *ppInSignature );
+            IWbemClassObject_Release( *ppOutSignature );
+            return E_OUTOFMEMORY;
+        }
+        co->index_method++;
+    }
+    return hr;
 }
 
 static HRESULT WINAPI class_object_EndMethodEnumeration(
     IWbemClassObject *iface )
 {
-    FIXME("%p\n", iface);
-    return E_NOTIMPL;
+    struct class_object *co = impl_from_IWbemClassObject( iface );
+
+    TRACE("%p\n", iface);
+
+    co->index_method = 0;
+    return S_OK;
 }
 
 static HRESULT WINAPI class_object_GetMethodQualifierSet(
@@ -732,8 +770,9 @@ HRESULT create_class_object(
         heap_free( co );
         return E_OUTOFMEMORY;
     }
-    co->iter  = iter;
-    co->index = index;
+    co->iter           = iter;
+    co->index          = index;
+    co->index_method   = 0;
     if (iter) IEnumWbemClassObject_AddRef( iter );
 
     *obj = &co->IWbemClassObject_iface;
diff --git a/dlls/wbemprox/table.c b/dlls/wbemprox/table.c
index 5b6f4b4..231c27d 100644
--- a/dlls/wbemprox/table.c
+++ b/dlls/wbemprox/table.c
@@ -331,3 +331,21 @@ BOOL add_table( struct table *table )
     list_add_tail( table_list, &table->entry );
     return TRUE;
 }
+
+const WCHAR *get_method_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 34a3384..f6aa2b8 100644
--- a/dlls/wbemprox/wbemprox_private.h
+++ b/dlls/wbemprox/wbemprox_private.h
@@ -151,6 +151,7 @@ HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
 HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
 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;
 
 HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
 HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list