Hans Leidekker : wbemprox: Implement IWbemClassObject::Put.
Alexandre Julliard
julliard at winehq.org
Wed Jul 25 16:06:53 CDT 2012
Module: wine
Branch: master
Commit: 53d1cc1ed63ea0bf376ccd4e2d1c372dc7f8bd48
URL: http://source.winehq.org/git/wine.git/?a=commit;h=53d1cc1ed63ea0bf376ccd4e2d1c372dc7f8bd48
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Jul 25 13:12:10 2012 +0200
wbemprox: Implement IWbemClassObject::Put.
---
dlls/wbemprox/class.c | 9 ++++-
dlls/wbemprox/query.c | 61 ++++++++++++++++++++++++++++++++++++++
dlls/wbemprox/table.c | 43 ++++++++++++++++++++++++++
dlls/wbemprox/wbemprox_private.h | 2 +
4 files changed, 113 insertions(+), 2 deletions(-)
diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c
index ff729f2..5bd9c1c 100644
--- a/dlls/wbemprox/class.c
+++ b/dlls/wbemprox/class.c
@@ -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(
diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c
index 74b48e4..15423d9 100644
--- a/dlls/wbemprox/query.c
+++ b/dlls/wbemprox/query.c
@@ -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;
diff --git a/dlls/wbemprox/table.c b/dlls/wbemprox/table.c
index c3757d5..5e79de5 100644
--- a/dlls/wbemprox/table.c
+++ b/dlls/wbemprox/table.c
@@ -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;
diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h
index 5f095c6..14c97b2 100644
--- a/dlls/wbemprox/wbemprox_private.h
+++ b/dlls/wbemprox/wbemprox_private.h
@@ -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;
More information about the wine-cvs
mailing list