Commit 34bd6a9c authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemprox: Map CIM_UINT16 and CIM_UINT32 to VT_I4 by default.

parent 58572fc9
......@@ -227,7 +227,6 @@ static struct record *create_record( struct table *table )
for (i = 0; i < table->num_cols; i++)
{
record->fields[i].type = table->columns[i].type;
record->fields[i].vartype = table->columns[i].vartype;
record->fields[i].u.ival = 0;
}
record->count = table->num_cols;
......@@ -347,13 +346,13 @@ static HRESULT WINAPI class_object_GetQualifierSet(
static HRESULT record_get_value( const struct record *record, UINT index, VARIANT *var, CIMTYPE *type )
{
VARTYPE vartype = record->fields[index].vartype;
VARTYPE vartype = to_vartype( record->fields[index].type & CIM_TYPE_MASK );
if (type) *type = record->fields[index].type;
if (record->fields[index].type & CIM_FLAG_ARRAY)
{
V_VT( var ) = vartype ? vartype : to_vartype( record->fields[index].type & CIM_TYPE_MASK ) | VT_ARRAY;
V_VT( var ) = vartype | VT_ARRAY;
V_ARRAY( var ) = to_safearray( record->fields[index].u.aval, record->fields[index].type & CIM_TYPE_MASK );
return S_OK;
}
......@@ -362,15 +361,12 @@ static HRESULT record_get_value( const struct record *record, UINT index, VARIAN
case CIM_STRING:
case CIM_DATETIME:
case CIM_REFERENCE:
if (!vartype) vartype = VT_BSTR;
V_BSTR( var ) = SysAllocString( record->fields[index].u.sval );
break;
case CIM_SINT32:
if (!vartype) vartype = VT_I4;
V_I4( var ) = record->fields[index].u.ival;
break;
case CIM_UINT32:
if (!vartype) vartype = VT_UI4;
V_UI4( var ) = record->fields[index].u.ival;
break;
default:
......@@ -735,7 +731,6 @@ static HRESULT create_signature_columns_and_data( IEnumWbemClassObject *iter, UI
{
static const WCHAR parameterW[] = {'P','a','r','a','m','e','t','e','r',0};
static const WCHAR typeW[] = {'T','y','p','e',0};
static const WCHAR varianttypeW[] = {'V','a','r','i','a','n','t','T','y','p','e',0};
static const WCHAR defaultvalueW[] = {'D','e','f','a','u','l','t','V','a','l','u','e',0};
struct column *columns;
BYTE *row;
......@@ -764,10 +759,6 @@ static HRESULT create_signature_columns_and_data( IEnumWbemClassObject *iter, UI
if (hr != S_OK) goto error;
columns[i].type = V_UI4( &val );
hr = IWbemClassObject_Get( param, varianttypeW, 0, &val, NULL, NULL );
if (hr != S_OK) goto error;
columns[i].vartype = V_UI4( &val );
hr = IWbemClassObject_Get( param, defaultvalueW, 0, &val, NULL, NULL );
if (hr != S_OK) goto error;
if (V_UI4( &val )) set_default_value( columns[i].type, V_UI4( &val ), row + offset );
......
......@@ -1025,18 +1025,25 @@ VARTYPE to_vartype( CIMTYPE type )
{
switch (type)
{
case CIM_BOOLEAN: return VT_BOOL;
case CIM_BOOLEAN: return VT_BOOL;
case CIM_STRING:
case CIM_REFERENCE:
case CIM_DATETIME: return VT_BSTR;
case CIM_SINT8: return VT_I1;
case CIM_UINT8: return VT_UI1;
case CIM_SINT16: return VT_I2;
case CIM_UINT16: return VT_UI2;
case CIM_SINT32: return VT_I4;
case CIM_UINT32: return VT_UI4;
case CIM_SINT64: return VT_I8;
case CIM_UINT64: return VT_UI8;
case CIM_DATETIME: return VT_BSTR;
case CIM_SINT8: return VT_I1;
case CIM_UINT8: return VT_UI1;
case CIM_SINT16: return VT_I2;
case CIM_UINT16:
case CIM_SINT32:
case CIM_UINT32: return VT_I4;
case CIM_SINT64: return VT_I8;
case CIM_UINT64: return VT_UI8;
case CIM_REAL32: return VT_R4;
default:
ERR("unhandled type %u\n", type);
break;
......@@ -1044,10 +1051,10 @@ VARTYPE to_vartype( CIMTYPE type )
return 0;
}
SAFEARRAY *to_safearray( const struct array *array, CIMTYPE type )
SAFEARRAY *to_safearray( const struct array *array, CIMTYPE basetype )
{
SAFEARRAY *ret;
VARTYPE vartype = to_vartype( type );
VARTYPE vartype = to_vartype( basetype );
LONG i;
if (!array || !(ret = SafeArrayCreateVector( vartype, 0, array->count ))) return NULL;
......@@ -1187,23 +1194,20 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR
if (!ret) return S_OK;
vartype = table->columns[column].vartype;
vartype = to_vartype( table->columns[column].type & CIM_TYPE_MASK );
if (table->columns[column].type & CIM_FLAG_ARRAY)
{
CIMTYPE basetype = table->columns[column].type & CIM_TYPE_MASK;
val_ptr = to_safearray( (const struct array *)(INT_PTR)val, basetype );
if (!val_ptr) vartype = VT_NULL;
else if (!vartype) vartype = to_vartype( basetype ) | VT_ARRAY;
else vartype |= VT_ARRAY;
set_variant( vartype, val, val_ptr, ret );
return S_OK;
}
switch (table->columns[column].type & COL_TYPE_MASK)
{
case CIM_BOOLEAN:
if (!vartype) vartype = VT_BOOL;
break;
case CIM_STRING:
case CIM_REFERENCE:
case CIM_DATETIME:
......@@ -1215,24 +1219,6 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR
else
vartype = VT_NULL;
break;
case CIM_SINT8:
if (!vartype) vartype = VT_I1;
break;
case CIM_UINT8:
if (!vartype) vartype = VT_UI1;
break;
case CIM_SINT16:
if (!vartype) vartype = VT_I2;
break;
case CIM_UINT16:
if (!vartype) vartype = VT_UI2;
break;
case CIM_SINT32:
if (!vartype) vartype = VT_I4;
break;
case CIM_UINT32:
if (!vartype) vartype = VT_UI4;
break;
case CIM_SINT64:
vartype = VT_BSTR;
val_ptr = get_value_bstr( table, row, column );
......@@ -1241,8 +1227,14 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR
vartype = VT_BSTR;
val_ptr = get_value_bstr( table, row, column );
break;
case CIM_BOOLEAN:
case CIM_SINT8:
case CIM_UINT8:
case CIM_SINT16:
case CIM_UINT16:
case CIM_SINT32:
case CIM_UINT32:
case CIM_REAL32:
if (!vartype) vartype = VT_R4;
break;
default:
ERR("unhandled column type %u\n", table->columns[column].type);
......
......@@ -216,17 +216,50 @@ static void test_associators( IWbemServices *services )
}
}
static void _check_property( ULONG line, IWbemClassObject *obj, const WCHAR *prop, VARTYPE vartype, CIMTYPE cimtype )
{
CIMTYPE type = 0xdeadbeef;
VARIANT val;
HRESULT hr;
VariantInit( &val );
hr = IWbemClassObject_Get( obj, prop, 0, &val, &type, NULL );
ok( hr == S_OK, "%u: failed to get description %08x\n", line, hr );
ok( V_VT( &val ) == vartype, "%u: unexpected variant type 0x%x\n", line, V_VT(&val) );
ok( type == cimtype, "%u: unexpected type 0x%x\n", line, type );
switch (V_VT(&val))
{
case VT_BSTR:
trace( "%s: %s\n", wine_dbgstr_w(prop), wine_dbgstr_w(V_BSTR(&val)) );
break;
case VT_I2:
trace( "%s: %d\n", wine_dbgstr_w(prop), V_I2(&val) );
break;
case VT_I4:
trace( "%s: %d\n", wine_dbgstr_w(prop), V_I4(&val) );
break;
case VT_R4:
trace( "%s: %f\n", wine_dbgstr_w(prop), V_R4(&val) );
break;
default:
break;
}
VariantClear( &val );
}
#define check_property(a,b,c,d) _check_property(__LINE__,a,b,c,d)
static void test_Win32_Service( IWbemServices *services )
{
static const WCHAR returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
static const WCHAR pauseserviceW[] = {'P','a','u','s','e','S','e','r','v','i','c','e',0};
static const WCHAR processidW[] = {'P','r','o','c','e','s','s','I','D',0};
static const WCHAR resumeserviceW[] = {'R','e','s','u','m','e','S','e','r','v','i','c','e',0};
static const WCHAR returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
static const WCHAR serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e','.',
'N','a','m','e','=','"','S','p','o','o','l','e','r','"',0};
static const WCHAR startserviceW[] = {'S','t','a','r','t','S','e','r','v','i','c','e',0};
static const WCHAR stopserviceW[] = {'S','t','o','p','S','e','r','v','i','c','e',0};
static const WCHAR stateW[] = {'S','t','a','t','e',0};
static const WCHAR stoppedW[] = {'S','t','o','p','p','e','d',0};
static const WCHAR serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e','.',
'N','a','m','e','=','"','S','p','o','o','l','e','r','"',0};
static const WCHAR stopserviceW[] = {'S','t','o','p','S','e','r','v','i','c','e',0};
static const WCHAR emptyW[] = {0};
BSTR class = SysAllocString( serviceW ), empty = SysAllocString( emptyW ), method;
IWbemClassObject *service, *out;
......@@ -240,6 +273,8 @@ static void test_Win32_Service( IWbemServices *services )
win_skip( "Win32_Service not available\n" );
goto out;
}
check_property( service, processidW, VT_I4, CIM_UINT32 );
type = 0xdeadbeef;
VariantInit( &state );
hr = IWbemClassObject_Get( service, stateW, 0, &state, &type, NULL );
......@@ -317,38 +352,6 @@ out:
SysFreeString( class );
}
static void _check_property( ULONG line, IWbemClassObject *obj, const WCHAR *prop, VARTYPE vartype, CIMTYPE cimtype )
{
CIMTYPE type = 0xdeadbeef;
VARIANT val;
HRESULT hr;
VariantInit( &val );
hr = IWbemClassObject_Get( obj, prop, 0, &val, &type, NULL );
ok( hr == S_OK, "%u: failed to get description %08x\n", line, hr );
ok( V_VT( &val ) == vartype, "%u: unexpected variant type 0x%x\n", line, V_VT(&val) );
ok( type == cimtype, "%u: unexpected type 0x%x\n", line, type );
switch (V_VT(&val))
{
case VT_BSTR:
trace( "%s: %s\n", wine_dbgstr_w(prop), wine_dbgstr_w(V_BSTR(&val)) );
break;
case VT_I2:
trace( "%s: %d\n", wine_dbgstr_w(prop), V_I2(&val) );
break;
case VT_I4:
trace( "%s: %d\n", wine_dbgstr_w(prop), V_I4(&val) );
break;
case VT_R4:
trace( "%s: %f\n", wine_dbgstr_w(prop), V_R4(&val) );
break;
default:
break;
}
VariantClear( &val );
}
#define check_property(a,b,c,d) _check_property(__LINE__,a,b,c,d)
static void test_Win32_Bios( IWbemServices *services )
{
static const WCHAR queryW[] =
......@@ -1414,6 +1417,8 @@ static void test_Win32_Processor( IWbemServices *services )
{'A','r','c','h','i','t','e','c','t','u','r','e',0};
static const WCHAR captionW[] =
{'C','a','p','t','i','o','n',0};
static const WCHAR cpustatusW[] =
{'C','p','u','S','t','a','t','u','s',0};
static const WCHAR familyW[] =
{'F','a','m','i','l','y',0};
static const WCHAR levelW[] =
......@@ -1451,8 +1456,9 @@ static void test_Win32_Processor( IWbemServices *services )
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
if (hr != S_OK) break;
check_property( obj, captionW, VT_BSTR, CIM_STRING );
check_property( obj, architectureW, VT_I4, CIM_UINT16 );
check_property( obj, captionW, VT_BSTR, CIM_STRING );
check_property( obj, cpustatusW, VT_I4, CIM_UINT16 );
check_property( obj, familyW, VT_I4, CIM_UINT16 );
check_property( obj, levelW, VT_I4, CIM_UINT16 );
check_property( obj, manufacturerW, VT_BSTR, CIM_STRING );
......@@ -1493,6 +1499,8 @@ static void test_Win32_Processor( IWbemServices *services )
static void test_Win32_VideoController( IWbemServices *services )
{
static const WCHAR availabilityW[] =
{'A','v','a','i','l','a','b','i','l','i','t','y',0};
static const WCHAR configmanagererrorcodeW[] =
{'C','o','n','f','i','g','M','a','n','a','g','e','r','E','r','r','o','r','C','o','d','e',0};
static const WCHAR driverdateW[] =
......@@ -1524,6 +1532,7 @@ static void test_Win32_VideoController( IWbemServices *services )
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
if (hr != S_OK) break;
check_property( obj, availabilityW, VT_I4, CIM_UINT16 );
check_property( obj, configmanagererrorcodeW, VT_I4, CIM_UINT32 );
check_property( obj, driverdateW, VT_BSTR, CIM_DATETIME );
......@@ -1547,8 +1556,12 @@ static void test_Win32_VideoController( IWbemServices *services )
static void test_Win32_Printer( IWbemServices *services )
{
static const WCHAR attributesW[] =
{'A','t','t','r','i','b','u','t','e','s',0};
static const WCHAR deviceidW[] =
{'D','e','v','i','c','e','I','d',0};
static const WCHAR horizontalresolutionW[] =
{'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
static const WCHAR locationW[] =
{'L','o','c','a','t','i','o','n',0};
static const WCHAR portnameW[] =
......@@ -1576,7 +1589,9 @@ static void test_Win32_Printer( IWbemServices *services )
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
if (hr != S_OK) break;
check_property( obj, attributesW, VT_I4, CIM_UINT32 );
check_property( obj, deviceidW, VT_BSTR, CIM_STRING );
check_property( obj, horizontalresolutionW, VT_I4, CIM_UINT32 );
type = 0xdeadbeef;
memset( &val, 0, sizeof(val) );
......
......@@ -89,7 +89,6 @@ struct column
{
const WCHAR *name;
UINT type;
VARTYPE vartype; /* 0 for default mapping */
};
enum fill_status
......@@ -132,7 +131,6 @@ struct array
struct field
{
UINT type;
VARTYPE vartype; /* 0 for default mapping */
union
{
LONGLONG ival;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment