2013-01-22 16:28:36 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Hans Leidekker for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "wbemcli.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wbemprox_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
|
|
|
|
|
|
|
|
struct qualifier_set
|
|
|
|
{
|
|
|
|
IWbemQualifierSet IWbemQualifierSet_iface;
|
|
|
|
LONG refs;
|
2021-09-13 16:13:27 +02:00
|
|
|
enum wbm_namespace ns;
|
2013-01-25 17:34:00 +01:00
|
|
|
WCHAR *class;
|
|
|
|
WCHAR *member;
|
2013-01-22 16:28:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct qualifier_set *impl_from_IWbemQualifierSet(
|
|
|
|
IWbemQualifierSet *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct qualifier_set, IWbemQualifierSet_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI qualifier_set_AddRef(
|
|
|
|
IWbemQualifierSet *iface )
|
|
|
|
{
|
|
|
|
struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
|
|
|
|
return InterlockedIncrement( &set->refs );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI qualifier_set_Release(
|
|
|
|
IWbemQualifierSet *iface )
|
|
|
|
{
|
|
|
|
struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
|
|
|
|
LONG refs = InterlockedDecrement( &set->refs );
|
|
|
|
if (!refs)
|
|
|
|
{
|
|
|
|
TRACE("destroying %p\n", set);
|
2022-01-31 14:49:43 +01:00
|
|
|
free( set->class );
|
|
|
|
free( set->member );
|
|
|
|
free( set );
|
2013-01-22 16:28:36 +01:00
|
|
|
}
|
|
|
|
return refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI qualifier_set_QueryInterface(
|
|
|
|
IWbemQualifierSet *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject )
|
|
|
|
{
|
|
|
|
struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
|
|
|
|
|
|
|
|
TRACE("%p, %s, %p\n", set, debugstr_guid( riid ), ppvObject );
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IWbemQualifierSet ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IUnknown ) )
|
|
|
|
{
|
|
|
|
*ppvObject = set;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
IWbemQualifierSet_AddRef( iface );
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-13 16:13:27 +02:00
|
|
|
static HRESULT create_qualifier_enum( enum wbm_namespace ns, const WCHAR *class, const WCHAR *member,
|
|
|
|
const WCHAR *name, IEnumWbemClassObject **iter )
|
2013-01-25 17:34:00 +01:00
|
|
|
{
|
2020-04-20 10:38:10 +02:00
|
|
|
static const WCHAR fmtW[] = L"SELECT * FROM __QUALIFIERS WHERE Class='%s' AND Member='%s' AND Name='%s'";
|
|
|
|
static const WCHAR fmt2W[] = L"SELECT * FROM __QUALIFIERS WHERE Class='%s' AND Member='%s'";
|
|
|
|
static const WCHAR fmt3W[] = L"SELECT * FROM __QUALIFIERS WHERE Class='%s'";
|
2013-01-25 17:34:00 +01:00
|
|
|
WCHAR *query;
|
|
|
|
HRESULT hr;
|
|
|
|
int len;
|
|
|
|
|
2019-08-28 14:14:29 +02:00
|
|
|
if (member && name)
|
|
|
|
{
|
|
|
|
len = lstrlenW( class ) + lstrlenW( member ) + lstrlenW( name ) + ARRAY_SIZE(fmtW);
|
2022-01-31 14:49:43 +01:00
|
|
|
if (!(query = malloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
|
2019-08-28 14:14:29 +02:00
|
|
|
swprintf( query, len, fmtW, class, member, name );
|
|
|
|
}
|
|
|
|
else if (member)
|
|
|
|
{
|
|
|
|
len = lstrlenW( class ) + lstrlenW( member ) + ARRAY_SIZE(fmt2W);
|
2022-01-31 14:49:43 +01:00
|
|
|
if (!(query = malloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
|
2019-08-28 14:14:29 +02:00
|
|
|
swprintf( query, len, fmt2W, class, member );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len = lstrlenW( class ) + ARRAY_SIZE(fmt3W);
|
2022-01-31 14:49:43 +01:00
|
|
|
if (!(query = malloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
|
2019-08-28 14:14:29 +02:00
|
|
|
swprintf( query, len, fmt3W, class );
|
|
|
|
}
|
2013-01-25 17:34:00 +01:00
|
|
|
|
2021-09-13 16:13:27 +02:00
|
|
|
hr = exec_query( ns, query, iter );
|
2022-01-31 14:49:43 +01:00
|
|
|
free( query );
|
2013-01-25 17:34:00 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2021-09-13 16:13:27 +02:00
|
|
|
static HRESULT get_qualifier_value( enum wbm_namespace ns, const WCHAR *class, const WCHAR *member, const WCHAR *name,
|
2013-01-25 17:34:00 +01:00
|
|
|
VARIANT *val, LONG *flavor )
|
|
|
|
{
|
|
|
|
IEnumWbemClassObject *iter;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2021-09-13 16:13:27 +02:00
|
|
|
hr = create_qualifier_enum( ns, class, member, name, &iter );
|
2013-01-25 17:34:00 +01:00
|
|
|
if (FAILED( hr )) return hr;
|
|
|
|
|
2021-09-13 16:13:27 +02:00
|
|
|
hr = create_class_object( ns, NULL, iter, 0, NULL, &obj );
|
2013-01-25 17:34:00 +01:00
|
|
|
IEnumWbemClassObject_Release( iter );
|
|
|
|
if (FAILED( hr )) return hr;
|
|
|
|
|
|
|
|
if (flavor)
|
|
|
|
{
|
2020-04-20 10:38:10 +02:00
|
|
|
hr = IWbemClassObject_Get( obj, L"Flavor", 0, &var, NULL, NULL );
|
2013-01-25 17:34:00 +01:00
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
*flavor = V_I4( &var );
|
|
|
|
}
|
2020-04-20 10:38:10 +02:00
|
|
|
hr = IWbemClassObject_Get( obj, L"Type", 0, &var, NULL, NULL );
|
2013-01-25 17:34:00 +01:00
|
|
|
if (hr != S_OK) goto done;
|
|
|
|
switch (V_UI4( &var ))
|
|
|
|
{
|
|
|
|
case CIM_STRING:
|
2020-04-20 10:38:10 +02:00
|
|
|
hr = IWbemClassObject_Get( obj, L"StringValue", 0, val, NULL, NULL );
|
2013-01-25 17:34:00 +01:00
|
|
|
break;
|
|
|
|
case CIM_SINT32:
|
2020-04-20 10:38:10 +02:00
|
|
|
hr = IWbemClassObject_Get( obj, L"IntegerValue", 0, val, NULL, NULL );
|
2013-01-25 17:34:00 +01:00
|
|
|
break;
|
2019-08-28 14:14:27 +02:00
|
|
|
case CIM_BOOLEAN:
|
2020-04-20 10:38:10 +02:00
|
|
|
hr = IWbemClassObject_Get( obj, L"BoolValue", 0, val, NULL, NULL );
|
2019-08-28 14:14:27 +02:00
|
|
|
break;
|
2013-01-25 17:34:00 +01:00
|
|
|
default:
|
2022-02-14 12:14:58 +01:00
|
|
|
ERR( "unhandled type %lu\n", V_UI4( &var ) );
|
2013-01-25 17:34:00 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2013-01-22 16:28:36 +01:00
|
|
|
static HRESULT WINAPI qualifier_set_Get(
|
|
|
|
IWbemQualifierSet *iface,
|
|
|
|
LPCWSTR wszName,
|
|
|
|
LONG lFlags,
|
|
|
|
VARIANT *pVal,
|
|
|
|
LONG *plFlavor )
|
|
|
|
{
|
2013-01-25 17:34:00 +01:00
|
|
|
struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
|
|
|
|
|
2022-02-14 12:14:58 +01:00
|
|
|
TRACE( "%p, %s, %#lx, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, plFlavor );
|
2019-08-28 14:14:29 +02:00
|
|
|
if (lFlags)
|
|
|
|
{
|
2022-02-14 12:14:58 +01:00
|
|
|
FIXME( "flags %#lx not supported\n", lFlags );
|
2019-08-28 14:14:29 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2021-09-13 16:13:27 +02:00
|
|
|
return get_qualifier_value( set->ns, set->class, set->member, wszName, pVal, plFlavor );
|
2013-01-22 16:28:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI qualifier_set_Put(
|
|
|
|
IWbemQualifierSet *iface,
|
|
|
|
LPCWSTR wszName,
|
|
|
|
VARIANT *pVal,
|
|
|
|
LONG lFlavor )
|
|
|
|
{
|
2022-02-14 12:14:58 +01:00
|
|
|
FIXME( "%p, %s, %p, %ld\n", iface, debugstr_w(wszName), pVal, lFlavor );
|
2013-01-22 16:28:36 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI qualifier_set_Delete(
|
|
|
|
IWbemQualifierSet *iface,
|
|
|
|
LPCWSTR wszName )
|
|
|
|
{
|
|
|
|
FIXME("%p, %s\n", iface, debugstr_w(wszName));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI qualifier_set_GetNames(
|
|
|
|
IWbemQualifierSet *iface,
|
|
|
|
LONG lFlags,
|
|
|
|
SAFEARRAY **pNames )
|
|
|
|
{
|
2019-08-28 14:14:29 +02:00
|
|
|
struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
|
|
|
|
IEnumWbemClassObject *iter;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-14 12:14:58 +01:00
|
|
|
TRACE( "%p, %#lx, %p\n", iface, lFlags, pNames );
|
2019-08-28 14:14:29 +02:00
|
|
|
if (lFlags)
|
|
|
|
{
|
2022-02-14 12:14:58 +01:00
|
|
|
FIXME( "flags %#lx not supported\n", lFlags );
|
2019-08-28 14:14:29 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2021-09-13 16:13:27 +02:00
|
|
|
hr = create_qualifier_enum( set->ns, set->class, set->member, NULL, &iter );
|
2019-08-28 14:14:29 +02:00
|
|
|
if (FAILED( hr )) return hr;
|
|
|
|
|
2021-09-13 16:13:27 +02:00
|
|
|
hr = create_class_object( set->ns, NULL, iter, 0, NULL, &obj );
|
2019-08-28 14:14:29 +02:00
|
|
|
IEnumWbemClassObject_Release( iter );
|
|
|
|
if (FAILED( hr )) return hr;
|
|
|
|
|
|
|
|
hr = IWbemClassObject_GetNames( obj, NULL, 0, NULL, pNames );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
return hr;
|
2013-01-22 16:28:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI qualifier_set_BeginEnumeration(
|
|
|
|
IWbemQualifierSet *iface,
|
|
|
|
LONG lFlags )
|
|
|
|
{
|
2022-02-14 12:14:58 +01:00
|
|
|
FIXME( "%p, %#lx\n", iface, lFlags );
|
2013-01-22 16:28:36 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI qualifier_set_Next(
|
|
|
|
IWbemQualifierSet *iface,
|
|
|
|
LONG lFlags,
|
|
|
|
BSTR *pstrName,
|
|
|
|
VARIANT *pVal,
|
|
|
|
LONG *plFlavor )
|
|
|
|
{
|
2022-02-14 12:14:58 +01:00
|
|
|
FIXME( "%p, %#lx, %p, %p, %p\n", iface, lFlags, pstrName, pVal, plFlavor );
|
2013-01-22 16:28:36 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI qualifier_set_EndEnumeration(
|
|
|
|
IWbemQualifierSet *iface )
|
|
|
|
{
|
|
|
|
FIXME("%p\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IWbemQualifierSetVtbl qualifier_set_vtbl =
|
|
|
|
{
|
|
|
|
qualifier_set_QueryInterface,
|
|
|
|
qualifier_set_AddRef,
|
|
|
|
qualifier_set_Release,
|
|
|
|
qualifier_set_Get,
|
|
|
|
qualifier_set_Put,
|
|
|
|
qualifier_set_Delete,
|
|
|
|
qualifier_set_GetNames,
|
|
|
|
qualifier_set_BeginEnumeration,
|
|
|
|
qualifier_set_Next,
|
|
|
|
qualifier_set_EndEnumeration
|
|
|
|
};
|
|
|
|
|
2021-09-13 16:13:27 +02:00
|
|
|
HRESULT WbemQualifierSet_create( enum wbm_namespace ns, const WCHAR *class, const WCHAR *member, LPVOID *ppObj )
|
2013-01-22 16:28:36 +01:00
|
|
|
{
|
|
|
|
struct qualifier_set *set;
|
|
|
|
|
2013-12-30 10:21:36 +01:00
|
|
|
TRACE("%p\n", ppObj);
|
2013-01-22 16:28:36 +01:00
|
|
|
|
2022-01-31 14:49:43 +01:00
|
|
|
if (!(set = malloc( sizeof(*set) ))) return E_OUTOFMEMORY;
|
2013-01-22 16:28:36 +01:00
|
|
|
|
|
|
|
set->IWbemQualifierSet_iface.lpVtbl = &qualifier_set_vtbl;
|
2013-01-25 17:34:00 +01:00
|
|
|
if (!(set->class = heap_strdupW( class )))
|
|
|
|
{
|
2022-01-31 14:49:43 +01:00
|
|
|
free( set );
|
2013-01-25 17:34:00 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
if (!member) set->member = NULL;
|
|
|
|
else if (!(set->member = heap_strdupW( member )))
|
|
|
|
{
|
2022-01-31 14:49:43 +01:00
|
|
|
free( set->class );
|
|
|
|
free( set );
|
2013-01-25 17:34:00 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2021-09-13 16:13:27 +02:00
|
|
|
set->ns = ns;
|
2013-01-22 16:28:36 +01:00
|
|
|
set->refs = 1;
|
|
|
|
|
|
|
|
*ppObj = &set->IWbemQualifierSet_iface;
|
|
|
|
|
|
|
|
TRACE("returning iface %p\n", *ppObj);
|
|
|
|
return S_OK;
|
|
|
|
}
|