wbemprox: Implement IWbemClassObject::Put.

This commit is contained in:
Hans Leidekker 2012-07-25 13:12:10 +02:00 committed by Alexandre Julliard
parent b41c71e3ab
commit 53d1cc1ed6
4 changed files with 113 additions and 2 deletions

View file

@ -300,8 +300,13 @@ static HRESULT WINAPI class_object_Put(
VARIANT *pVal,
CIMTYPE Type )
{
FIXME("%p, %s, %08x, %p, %u\n", iface, debugstr_w(wszName), lFlags, pVal, Type);
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, %u\n", iface, debugstr_w(wszName), lFlags, pVal, Type);
return put_propval( view, co->index, wszName, pVal, Type );
}
static HRESULT WINAPI class_object_Delete(

View file

@ -641,6 +641,67 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR
return S_OK;
}
static HRESULT variant_to_longlong( VARIANT *var, LONGLONG *val, CIMTYPE *type )
{
if (!var)
{
*val = 0;
return S_OK;
}
switch (V_VT( var ))
{
case VT_BSTR:
*val = (INT_PTR)SysAllocString( V_BSTR( var ) );
if (!*val) return E_OUTOFMEMORY;
*type = CIM_STRING;
break;
case VT_I2:
*val = V_I2( var );
*type = CIM_SINT16;
break;
case VT_UI2:
*val = V_UI2( var );
*type = CIM_UINT16;
break;
case VT_I4:
*val = V_I4( var );
*type = CIM_SINT32;
break;
case VT_UI4:
*val = V_UI4( var );
*type = CIM_UINT32;
break;
case VT_NULL:
*val = 0;
break;
default:
ERR("unhandled type %u\n", V_VT( var ));
return WBEM_E_FAILED;
}
return S_OK;
}
HRESULT put_propval( const struct view *view, UINT index, const WCHAR *name, VARIANT *var, CIMTYPE type )
{
HRESULT hr;
UINT column, row = view->result[index];
LONGLONG val;
hr = get_column_index( view->table, name, &column );
if (hr != S_OK)
{
FIXME("no support for creating new properties\n");
return WBEM_E_FAILED;
}
if (is_method( view->table, column ) || !(view->table->columns[column].type & COL_FLAG_DYNAMIC))
return WBEM_E_FAILED;
hr = variant_to_longlong( var, &val, &type );
if (hr != S_OK) return hr;
return set_value( view->table, row, column, val, type );
}
HRESULT get_properties( const struct view *view, SAFEARRAY **props )
{
SAFEARRAY *sa;

View file

@ -180,6 +180,49 @@ BSTR get_value_bstr( const struct table *table, UINT row, UINT column )
return NULL;
}
HRESULT set_value( const struct table *table, UINT row, UINT column, LONGLONG val,
CIMTYPE type )
{
UINT col_offset, row_size;
BYTE *ptr;
if ((table->columns[column].type & COL_TYPE_MASK) != type) return WBEM_E_TYPE_MISMATCH;
col_offset = get_column_offset( table, column );
row_size = get_row_size( table );
ptr = table->data + row * row_size + col_offset;
switch (table->columns[column].type & COL_TYPE_MASK)
{
case CIM_DATETIME:
case CIM_STRING:
*(WCHAR **)ptr = (WCHAR *)(INT_PTR)val;
break;
case CIM_SINT16:
*(INT16 *)ptr = val;
break;
case CIM_UINT16:
*(UINT16 *)ptr = val;
break;
case CIM_SINT32:
*(INT32 *)ptr = val;
break;
case CIM_UINT32:
*(UINT32 *)ptr = val;
break;
case CIM_SINT64:
*(INT64 *)ptr = val;
break;
case CIM_UINT64:
*(UINT64 *)ptr = val;
break;
default:
FIXME("unhandled column type %u\n", type);
return WBEM_E_FAILED;
}
return S_OK;
}
static void clear_table( struct table *table )
{
UINT i, j, type;

View file

@ -137,8 +137,10 @@ void free_table( struct table * ) DECLSPEC_HIDDEN;
HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC_HIDDEN;
HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN;
BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
HRESULT set_value( const struct table *, UINT, UINT, LONGLONG, CIMTYPE ) DECLSPEC_HIDDEN;
HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
CIMTYPE *, LONG * ) 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 WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;