wbemprox: Add support for enumerating class methods.

This commit is contained in:
Hans Leidekker 2012-07-30 15:04:49 +02:00 committed by Alexandre Julliard
parent 12caddb4be
commit a26b5dc09a
3 changed files with 66 additions and 8 deletions

View File

@ -219,6 +219,7 @@ struct class_object
WCHAR *name; WCHAR *name;
IEnumWbemClassObject *iter; IEnumWbemClassObject *iter;
UINT index; UINT index;
UINT index_method;
}; };
static inline struct class_object *impl_from_IWbemClassObject( static inline struct class_object *impl_from_IWbemClassObject(
@ -643,8 +644,19 @@ static HRESULT WINAPI class_object_BeginMethodEnumeration(
IWbemClassObject *iface, IWbemClassObject *iface,
LONG lEnumFlags) LONG lEnumFlags)
{ {
FIXME("%p, %08x\n", iface, lEnumFlags); struct class_object *co = impl_from_IWbemClassObject( iface );
return E_NOTIMPL;
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( static HRESULT WINAPI class_object_NextMethod(
@ -654,15 +666,41 @@ static HRESULT WINAPI class_object_NextMethod(
IWbemClassObject **ppInSignature, IWbemClassObject **ppInSignature,
IWbemClassObject **ppOutSignature) IWbemClassObject **ppOutSignature)
{ {
FIXME("%p, %08x, %p, %p, %p\n", iface, lFlags, pstrName, ppInSignature, ppOutSignature); struct class_object *co = impl_from_IWbemClassObject( iface );
return E_NOTIMPL; 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( static HRESULT WINAPI class_object_EndMethodEnumeration(
IWbemClassObject *iface ) IWbemClassObject *iface )
{ {
FIXME("%p\n", iface); struct class_object *co = impl_from_IWbemClassObject( iface );
return E_NOTIMPL;
TRACE("%p\n", iface);
co->index_method = 0;
return S_OK;
} }
static HRESULT WINAPI class_object_GetMethodQualifierSet( static HRESULT WINAPI class_object_GetMethodQualifierSet(
@ -732,8 +770,9 @@ HRESULT create_class_object(
heap_free( co ); heap_free( co );
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
co->iter = iter; co->iter = iter;
co->index = index; co->index = index;
co->index_method = 0;
if (iter) IEnumWbemClassObject_AddRef( iter ); if (iter) IEnumWbemClassObject_AddRef( iter );
*obj = &co->IWbemClassObject_iface; *obj = &co->IWbemClassObject_iface;

View File

@ -331,3 +331,21 @@ BOOL add_table( struct table *table )
list_add_tail( table_list, &table->entry ); list_add_tail( table_list, &table->entry );
return TRUE; 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;
}

View File

@ -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 put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN; HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN;
HRESULT get_object( const WCHAR *, IWbemClassObject ** ) 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 WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN; HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;