wbemprox: Implement GetValue()/SetValue() for context object.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
83cd24bb41
commit
377853dc51
|
@ -955,12 +955,33 @@ HRESULT WbemServices_create( const WCHAR *namespace, LPVOID *ppObj )
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
struct wbem_context_value
|
||||
{
|
||||
struct list entry;
|
||||
WCHAR *name;
|
||||
VARIANT value;
|
||||
};
|
||||
|
||||
struct wbem_context
|
||||
{
|
||||
IWbemContext IWbemContext_iface;
|
||||
LONG refs;
|
||||
struct list values;
|
||||
};
|
||||
|
||||
static void wbem_context_delete_values(struct wbem_context *context)
|
||||
{
|
||||
struct wbem_context_value *value, *next;
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(value, next, &context->values, struct wbem_context_value, entry)
|
||||
{
|
||||
list_remove( &value->entry );
|
||||
VariantClear( &value->value );
|
||||
heap_free( value->name );
|
||||
heap_free( value );
|
||||
}
|
||||
}
|
||||
|
||||
static struct wbem_context *impl_from_IWbemContext( IWbemContext *iface )
|
||||
{
|
||||
return CONTAINING_RECORD( iface, struct wbem_context, IWbemContext_iface );
|
||||
|
@ -1004,6 +1025,7 @@ static ULONG WINAPI wbem_context_Release(
|
|||
if (!refs)
|
||||
{
|
||||
TRACE("destroying %p\n", context);
|
||||
wbem_context_delete_values( context );
|
||||
heap_free( context );
|
||||
}
|
||||
return refs;
|
||||
|
@ -1056,26 +1078,78 @@ static HRESULT WINAPI wbem_context_EndEnumeration(
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static struct wbem_context_value *wbem_context_get_value( struct wbem_context *context, const WCHAR *name )
|
||||
{
|
||||
struct wbem_context_value *value;
|
||||
|
||||
LIST_FOR_EACH_ENTRY( value, &context->values, struct wbem_context_value, entry )
|
||||
{
|
||||
if (!lstrcmpiW( value->name, name )) return value;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI wbem_context_SetValue(
|
||||
IWbemContext *iface,
|
||||
LPCWSTR name,
|
||||
LONG flags,
|
||||
VARIANT *value )
|
||||
VARIANT *var )
|
||||
{
|
||||
FIXME("%p, %s, %#x, %p\n", iface, debugstr_w(name), flags, value);
|
||||
struct wbem_context *context = impl_from_IWbemContext( iface );
|
||||
struct wbem_context_value *value;
|
||||
HRESULT hr;
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p, %s, %#x, %s\n", iface, debugstr_w(name), flags, debugstr_variant(var));
|
||||
|
||||
if (!name || !var)
|
||||
return WBEM_E_INVALID_PARAMETER;
|
||||
|
||||
if ((value = wbem_context_get_value( context, name )))
|
||||
{
|
||||
VariantClear( &value->value );
|
||||
hr = VariantCopy( &value->value, var );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(value = heap_alloc_zero( sizeof(*value) ))) return E_OUTOFMEMORY;
|
||||
if (!(value->name = heap_strdupW( name )))
|
||||
{
|
||||
heap_free( value );
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
if (FAILED(hr = VariantCopy( &value->value, var )))
|
||||
{
|
||||
heap_free( value->name );
|
||||
heap_free( value );
|
||||
return hr;
|
||||
}
|
||||
|
||||
list_add_tail( &context->values, &value->entry );
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI wbem_context_GetValue(
|
||||
IWbemContext *iface,
|
||||
LPCWSTR name,
|
||||
LONG flags,
|
||||
VARIANT *value )
|
||||
VARIANT *var )
|
||||
{
|
||||
FIXME("%p, %s, %#x, %p\n", iface, debugstr_w(name), flags, value);
|
||||
struct wbem_context *context = impl_from_IWbemContext( iface );
|
||||
struct wbem_context_value *value;
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p, %s, %#x, %p\n", iface, debugstr_w(name), flags, var);
|
||||
|
||||
if (!name || !var)
|
||||
return WBEM_E_INVALID_PARAMETER;
|
||||
|
||||
if (!(value = wbem_context_get_value( context, name )))
|
||||
return WBEM_E_NOT_FOUND;
|
||||
|
||||
V_VT(var) = VT_EMPTY;
|
||||
return VariantCopy( var, &value->value );
|
||||
}
|
||||
|
||||
static HRESULT WINAPI wbem_context_DeleteValue(
|
||||
|
@ -1123,6 +1197,7 @@ HRESULT WbemContext_create( void **obj )
|
|||
|
||||
context->IWbemContext_iface.lpVtbl = &wbem_context_vtbl;
|
||||
context->refs = 1;
|
||||
list_init(&context->values);
|
||||
|
||||
*obj = &context->IWbemContext_iface;
|
||||
|
||||
|
|
|
@ -152,11 +152,74 @@ static void test_IWbemLocator(void)
|
|||
static void test_IWbemContext(void)
|
||||
{
|
||||
IWbemContext *context;
|
||||
VARIANT var;
|
||||
HRESULT hr;
|
||||
BSTR str;
|
||||
|
||||
hr = CoCreateInstance( &CLSID_WbemContext, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemContext, (void **)&context );
|
||||
ok(hr == S_OK, "Failed to create context object, hr %#x.\n", hr);
|
||||
|
||||
hr = IWbemContext_SetValue(context, L"name", 0, NULL);
|
||||
ok(hr == WBEM_E_INVALID_PARAMETER, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
V_VT(&var) = VT_I4;
|
||||
V_I4(&var) = 12;
|
||||
hr = IWbemContext_SetValue(context, NULL, 0, &var);
|
||||
ok(hr == WBEM_E_INVALID_PARAMETER, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IWbemContext_SetValue(context, L"name", 0, &var);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IWbemContext_GetValue(context, NULL, 0, &var);
|
||||
ok(hr == WBEM_E_INVALID_PARAMETER, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IWbemContext_GetValue(context, L"name", 0, NULL);
|
||||
ok(hr == WBEM_E_INVALID_PARAMETER, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IWbemContext_GetValue(context, L"noname", 0, &var);
|
||||
ok(hr == WBEM_E_NOT_FOUND, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
V_VT(&var) = VT_EMPTY;
|
||||
hr = IWbemContext_GetValue(context, L"NAME", 0, &var);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(V_VT(&var) == VT_I4, "Unexpected value type.\n");
|
||||
|
||||
V_VT(&var) = VT_I4;
|
||||
V_I4(&var) = 13;
|
||||
hr = IWbemContext_SetValue(context, L"name2", 0, &var);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IWbemContext_Next(context, 0, &str, &var);
|
||||
todo_wine
|
||||
ok(hr == WBEM_E_UNEXPECTED, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IWbemContext_BeginEnumeration(context, 0);
|
||||
todo_wine
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
str = NULL;
|
||||
hr = IWbemContext_Next(context, 0, &str, &var);
|
||||
todo_wine {
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(!lstrcmpW(str, L"name"), "Unexpected name %s.\n", wine_dbgstr_w(str));
|
||||
SysFreeString(str);
|
||||
}
|
||||
hr = IWbemContext_EndEnumeration(context);
|
||||
todo_wine
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
/* Overwrite */
|
||||
V_VT(&var) = VT_I4;
|
||||
V_I4(&var) = 14;
|
||||
hr = IWbemContext_SetValue(context, L"name", 0, &var);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
V_VT(&var) = VT_EMPTY;
|
||||
hr = IWbemContext_GetValue(context, L"name", 0, &var);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(V_VT(&var) == VT_I4, "Unexpected value type.\n");
|
||||
ok(V_I4(&var) == 14, "Unexpected value.\n");
|
||||
|
||||
IWbemContext_Release( context );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue