wbemdisp: Use pointer moniker instead of custom moniker implementation.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2cefc54fed
commit
05dd821238
|
@ -36,248 +36,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp);
|
||||||
|
|
||||||
static HINSTANCE instance;
|
static HINSTANCE instance;
|
||||||
|
|
||||||
struct moniker
|
|
||||||
{
|
|
||||||
IMoniker IMoniker_iface;
|
|
||||||
LONG refs;
|
|
||||||
IUnknown *obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline struct moniker *impl_from_IMoniker(
|
|
||||||
IMoniker *iface )
|
|
||||||
{
|
|
||||||
return CONTAINING_RECORD( iface, struct moniker, IMoniker_iface );
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG WINAPI moniker_AddRef(
|
|
||||||
IMoniker *iface )
|
|
||||||
{
|
|
||||||
struct moniker *moniker = impl_from_IMoniker( iface );
|
|
||||||
return InterlockedIncrement( &moniker->refs );
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG WINAPI moniker_Release(
|
|
||||||
IMoniker *iface )
|
|
||||||
{
|
|
||||||
struct moniker *moniker = impl_from_IMoniker( iface );
|
|
||||||
LONG refs = InterlockedDecrement( &moniker->refs );
|
|
||||||
if (!refs)
|
|
||||||
{
|
|
||||||
TRACE( "destroying %p\n", moniker );
|
|
||||||
IUnknown_Release( moniker->obj );
|
|
||||||
heap_free( moniker );
|
|
||||||
}
|
|
||||||
return refs;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_QueryInterface(
|
|
||||||
IMoniker *iface, REFIID riid, void **ppvObject )
|
|
||||||
{
|
|
||||||
struct moniker *moniker = impl_from_IMoniker( iface );
|
|
||||||
|
|
||||||
TRACE( "%p, %s, %p\n", moniker, debugstr_guid( riid ), ppvObject );
|
|
||||||
|
|
||||||
if (IsEqualGUID( riid, &IID_IMoniker ) ||
|
|
||||||
IsEqualGUID( riid, &IID_IUnknown ))
|
|
||||||
{
|
|
||||||
*ppvObject = iface;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
|
|
||||||
return E_NOINTERFACE;
|
|
||||||
}
|
|
||||||
IMoniker_AddRef( iface );
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_GetClassID(
|
|
||||||
IMoniker *iface, CLSID *pClassID )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_IsDirty(
|
|
||||||
IMoniker *iface )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_Load(
|
|
||||||
IMoniker *iface, IStream *pStm )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_Save(
|
|
||||||
IMoniker *iface, IStream *pStm, BOOL fClearDirty )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_GetSizeMax(
|
|
||||||
IMoniker *iface, ULARGE_INTEGER *pcbSize )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_BindToObject(
|
|
||||||
IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riidResult, void **ppvResult )
|
|
||||||
{
|
|
||||||
struct moniker *moniker = impl_from_IMoniker( iface );
|
|
||||||
|
|
||||||
TRACE( "%p, %p, %p, %s, %p\n", iface, pbc, pmkToLeft, debugstr_guid(riidResult), ppvResult );
|
|
||||||
return IUnknown_QueryInterface( moniker->obj, riidResult, ppvResult );
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_BindToStorage(
|
|
||||||
IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riid, void **ppvObj )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_Reduce(
|
|
||||||
IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_ComposeWith(
|
|
||||||
IMoniker *iface, IMoniker *pmkRight, BOOL fOnlyIfNotGeneric, IMoniker **ppmkComposite )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_Enum(
|
|
||||||
IMoniker *iface, BOOL fForward, IEnumMoniker **ppenumMoniker )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_IsEqual(
|
|
||||||
IMoniker *iface, IMoniker *pmkOtherMoniker )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_Hash(
|
|
||||||
IMoniker *iface, DWORD *pdwHash )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_IsRunning(
|
|
||||||
IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_GetTimeOfLastChange(
|
|
||||||
IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, FILETIME *pFileTime )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_Inverse(
|
|
||||||
IMoniker *iface, IMoniker **ppmk )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_CommonPrefixWith(
|
|
||||||
IMoniker *iface, IMoniker *pmkOther, IMoniker **ppmkPrefix )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_RelativePathTo(
|
|
||||||
IMoniker *iface, IMoniker *pmkOther, IMoniker **ppmkRelPath )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_GetDisplayName(
|
|
||||||
IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_ParseDisplayName(
|
|
||||||
IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten,
|
|
||||||
IMoniker **ppmkOut )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI moniker_IsSystemMoniker(
|
|
||||||
IMoniker *iface, DWORD *pdwMksys )
|
|
||||||
{
|
|
||||||
FIXME( "\n" );
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const IMonikerVtbl moniker_vtbl =
|
|
||||||
{
|
|
||||||
moniker_QueryInterface,
|
|
||||||
moniker_AddRef,
|
|
||||||
moniker_Release,
|
|
||||||
moniker_GetClassID,
|
|
||||||
moniker_IsDirty,
|
|
||||||
moniker_Load,
|
|
||||||
moniker_Save,
|
|
||||||
moniker_GetSizeMax,
|
|
||||||
moniker_BindToObject,
|
|
||||||
moniker_BindToStorage,
|
|
||||||
moniker_Reduce,
|
|
||||||
moniker_ComposeWith,
|
|
||||||
moniker_Enum,
|
|
||||||
moniker_IsEqual,
|
|
||||||
moniker_Hash,
|
|
||||||
moniker_IsRunning,
|
|
||||||
moniker_GetTimeOfLastChange,
|
|
||||||
moniker_Inverse,
|
|
||||||
moniker_CommonPrefixWith,
|
|
||||||
moniker_RelativePathTo,
|
|
||||||
moniker_GetDisplayName,
|
|
||||||
moniker_ParseDisplayName,
|
|
||||||
moniker_IsSystemMoniker
|
|
||||||
};
|
|
||||||
|
|
||||||
static HRESULT Moniker_create( IUnknown *unk, IMoniker **obj )
|
|
||||||
{
|
|
||||||
struct moniker *moniker;
|
|
||||||
|
|
||||||
TRACE( "%p, %p\n", unk, obj );
|
|
||||||
|
|
||||||
if (!(moniker = heap_alloc( sizeof(*moniker) ))) return E_OUTOFMEMORY;
|
|
||||||
moniker->IMoniker_iface.lpVtbl = &moniker_vtbl;
|
|
||||||
moniker->refs = 1;
|
|
||||||
moniker->obj = unk;
|
|
||||||
IUnknown_AddRef( moniker->obj );
|
|
||||||
|
|
||||||
*obj = &moniker->IMoniker_iface;
|
|
||||||
TRACE( "returning iface %p\n", *obj );
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI WinMGMTS_QueryInterface(IParseDisplayName *iface, REFIID riid, void **ppv)
|
static HRESULT WINAPI WinMGMTS_QueryInterface(IParseDisplayName *iface, REFIID riid, void **ppv)
|
||||||
{
|
{
|
||||||
if(IsEqualGUID(riid, &IID_IUnknown)) {
|
if(IsEqualGUID(riid, &IID_IUnknown)) {
|
||||||
|
@ -401,12 +159,12 @@ static HRESULT WINAPI WinMGMTS_ParseDisplayName(IParseDisplayName *iface, IBindC
|
||||||
hr = ISWbemLocator_ConnectServer( locator, server, namespace, NULL, NULL, NULL, NULL, 0, NULL, &services );
|
hr = ISWbemLocator_ConnectServer( locator, server, namespace, NULL, NULL, NULL, NULL, 0, NULL, &services );
|
||||||
if (hr != S_OK) goto done;
|
if (hr != S_OK) goto done;
|
||||||
|
|
||||||
if (!relative || !*relative) Moniker_create( (IUnknown *)services, ppmkOut );
|
if (!relative || !*relative) CreatePointerMoniker( (IUnknown *)services, ppmkOut );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hr = ISWbemServices_Get( services, relative, 0, NULL, &obj );
|
hr = ISWbemServices_Get( services, relative, 0, NULL, &obj );
|
||||||
if (hr != S_OK) goto done;
|
if (hr != S_OK) goto done;
|
||||||
hr = Moniker_create( (IUnknown *)obj, ppmkOut );
|
hr = CreatePointerMoniker( (IUnknown *)obj, ppmkOut );
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
DEFINE_GUID(CLSID_WINMGMTS,0x172bddf8,0xceea,0x11d1,0x8b,0x05,0x00,0x60,0x08,0x06,0xd9,0xb6);
|
DEFINE_GUID(CLSID_WINMGMTS,0x172bddf8,0xceea,0x11d1,0x8b,0x05,0x00,0x60,0x08,0x06,0xd9,0xb6);
|
||||||
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
||||||
|
DEFINE_OLEGUID(CLSID_PointerMoniker,0x306,0,0);
|
||||||
|
|
||||||
static const LCID english = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
|
static const LCID english = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ static void test_ParseDisplayName(void)
|
||||||
BSTR str;
|
BSTR str;
|
||||||
ULONG i, eaten, count;
|
ULONG i, eaten, count;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
CLSID clsid;
|
||||||
|
|
||||||
hr = CoCreateInstance( &CLSID_WINMGMTS, NULL, CLSCTX_INPROC_SERVER, &IID_IParseDisplayName, (void **)&displayname );
|
hr = CoCreateInstance( &CLSID_WINMGMTS, NULL, CLSCTX_INPROC_SERVER, &IID_IParseDisplayName, (void **)&displayname );
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
|
@ -95,6 +97,10 @@ static void test_ParseDisplayName(void)
|
||||||
ok( eaten == tests[i].eaten, "%u: got %u\n", i, eaten );
|
ok( eaten == tests[i].eaten, "%u: got %u\n", i, eaten );
|
||||||
if (moniker)
|
if (moniker)
|
||||||
{
|
{
|
||||||
|
hr = IMoniker_GetClassID( moniker, &clsid );
|
||||||
|
ok( hr == S_OK, "%u: got %x\n", i, hr );
|
||||||
|
ok( IsEqualCLSID( &clsid, &CLSID_PointerMoniker ), "%u: got %s\n", i, wine_dbgstr_guid( &clsid ) );
|
||||||
|
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
hr = IMoniker_BindToObject( moniker, ctx, NULL, tests[i].iid, (void **)&obj );
|
hr = IMoniker_BindToObject( moniker, ctx, NULL, tests[i].iid, (void **)&obj );
|
||||||
ok( hr == S_OK, "%u: got %x\n", i, hr );
|
ok( hr == S_OK, "%u: got %x\n", i, hr );
|
||||||
|
@ -114,6 +120,10 @@ static void test_ParseDisplayName(void)
|
||||||
{
|
{
|
||||||
ISWbemServices *services = NULL;
|
ISWbemServices *services = NULL;
|
||||||
|
|
||||||
|
hr = IMoniker_GetClassID( moniker, &clsid );
|
||||||
|
ok( hr == S_OK, "%u: got %x\n", i, hr );
|
||||||
|
ok( IsEqualCLSID( &clsid, &CLSID_PointerMoniker ), "got %s\n", wine_dbgstr_guid( &clsid ) );
|
||||||
|
|
||||||
hr = IMoniker_BindToObject( moniker, ctx, NULL, &IID_IUnknown, (void **)&services );
|
hr = IMoniker_BindToObject( moniker, ctx, NULL, &IID_IUnknown, (void **)&services );
|
||||||
ok( hr == S_OK, "got %x\n", hr );
|
ok( hr == S_OK, "got %x\n", hr );
|
||||||
if (services)
|
if (services)
|
||||||
|
@ -259,6 +269,11 @@ static void test_ParseDisplayName(void)
|
||||||
if (moniker)
|
if (moniker)
|
||||||
{
|
{
|
||||||
ISWbemObject *sobj = NULL;
|
ISWbemObject *sobj = NULL;
|
||||||
|
|
||||||
|
hr = IMoniker_GetClassID( moniker, &clsid );
|
||||||
|
ok( hr == S_OK, "%u: got %x\n", i, hr );
|
||||||
|
ok( IsEqualCLSID( &clsid, &CLSID_PointerMoniker ), "got %s\n", wine_dbgstr_guid( &clsid ) );
|
||||||
|
|
||||||
hr = IMoniker_BindToObject( moniker, ctx, NULL, &IID_ISWbemObject, (void **)&sobj );
|
hr = IMoniker_BindToObject( moniker, ctx, NULL, &IID_ISWbemObject, (void **)&sobj );
|
||||||
ok( hr == S_OK, "got %x\n",hr );
|
ok( hr == S_OK, "got %x\n",hr );
|
||||||
if (sobj)
|
if (sobj)
|
||||||
|
|
Loading…
Reference in New Issue