Commit 301cc6ae authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemdisp: Forward SWbemLocator::ConnectServer to IWbemLocator::ConnectServer.

parent cbb2b35e
MODULE = wbemdisp.dll MODULE = wbemdisp.dll
IMPORTS = oleaut32 IMPORTS = oleaut32 ole32
C_SRCS = \ C_SRCS = \
locator.c \ locator.c \
......
...@@ -23,12 +23,15 @@ ...@@ -23,12 +23,15 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "initguid.h"
#include "objbase.h" #include "objbase.h"
#include "wbemcli.h"
#include "wbemdisp.h" #include "wbemdisp.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wbemdisp_private.h" #include "wbemdisp_private.h"
#include "wbemdisp_classes.h"
WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp); WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp);
...@@ -87,6 +90,7 @@ struct services ...@@ -87,6 +90,7 @@ struct services
{ {
ISWbemServices ISWbemServices_iface; ISWbemServices ISWbemServices_iface;
LONG refs; LONG refs;
IWbemServices *services;
}; };
static inline struct services *impl_from_ISWbemServices( static inline struct services *impl_from_ISWbemServices(
...@@ -110,6 +114,7 @@ static ULONG WINAPI services_Release( ...@@ -110,6 +114,7 @@ static ULONG WINAPI services_Release(
if (!refs) if (!refs)
{ {
TRACE( "destroying %p\n", services ); TRACE( "destroying %p\n", services );
IWbemServices_Release( services->services );
heap_free( services ); heap_free( services );
} }
return refs; return refs;
...@@ -494,15 +499,17 @@ static const ISWbemServicesVtbl services_vtbl = ...@@ -494,15 +499,17 @@ static const ISWbemServicesVtbl services_vtbl =
services_get_Security_ services_get_Security_
}; };
static HRESULT SWbemServices_create( ISWbemServices **obj ) static HRESULT SWbemServices_create( IWbemServices *wbem_services, ISWbemServices **obj )
{ {
struct services *services; struct services *services;
TRACE( "%p\n", obj ); TRACE( "%p, %p\n", obj, wbem_services );
if (!(services = heap_alloc( sizeof(*services) ))) return E_OUTOFMEMORY; if (!(services = heap_alloc( sizeof(*services) ))) return E_OUTOFMEMORY;
services->ISWbemServices_iface.lpVtbl = &services_vtbl; services->ISWbemServices_iface.lpVtbl = &services_vtbl;
services->refs = 1; services->refs = 1;
services->services = wbem_services;
IWbemServices_AddRef( services->services );
*obj = &services->ISWbemServices_iface; *obj = &services->ISWbemServices_iface;
TRACE( "returning iface %p\n", *obj ); TRACE( "returning iface %p\n", *obj );
...@@ -513,6 +520,7 @@ struct locator ...@@ -513,6 +520,7 @@ struct locator
{ {
ISWbemLocator ISWbemLocator_iface; ISWbemLocator ISWbemLocator_iface;
LONG refs; LONG refs;
IWbemLocator *locator;
}; };
static inline struct locator *impl_from_ISWbemLocator( ISWbemLocator *iface ) static inline struct locator *impl_from_ISWbemLocator( ISWbemLocator *iface )
...@@ -535,6 +543,7 @@ static ULONG WINAPI locator_Release( ...@@ -535,6 +543,7 @@ static ULONG WINAPI locator_Release(
if (!refs) if (!refs)
{ {
TRACE( "destroying %p\n", locator ); TRACE( "destroying %p\n", locator );
IWbemLocator_Release( locator->locator );
heap_free( locator ); heap_free( locator );
} }
return refs; return refs;
...@@ -640,6 +649,31 @@ static HRESULT WINAPI locator_Invoke( ...@@ -640,6 +649,31 @@ static HRESULT WINAPI locator_Invoke(
return hr; return hr;
} }
static BSTR build_resource_string( BSTR server, BSTR namespace )
{
static const WCHAR defaultW[] = {'r','o','o','t','\\','d','e','f','a','u','l','t',0};
ULONG len, len_server = 0, len_namespace = 0;
BSTR ret;
if (server && *server) len_server = strlenW( server );
else len_server = 1;
if (namespace && *namespace) len_namespace = strlenW( namespace );
else len_namespace = sizeof(defaultW) / sizeof(defaultW[0]) - 1;
if (!(ret = SysAllocStringLen( NULL, 2 + len_server + 1 + len_namespace ))) return NULL;
ret[0] = ret[1] = '\\';
if (server && *server) strcpyW( ret + 2, server );
else ret[2] = '.';
len = len_server + 2;
ret[len++] = '\\';
if (namespace && *namespace) strcpyW( ret + len, namespace );
else strcpyW( ret + len, defaultW );
return ret;
}
static HRESULT WINAPI locator_ConnectServer( static HRESULT WINAPI locator_ConnectServer(
ISWbemLocator *iface, ISWbemLocator *iface,
BSTR strServer, BSTR strServer,
...@@ -652,10 +686,33 @@ static HRESULT WINAPI locator_ConnectServer( ...@@ -652,10 +686,33 @@ static HRESULT WINAPI locator_ConnectServer(
IDispatch *objWbemNamedValueSet, IDispatch *objWbemNamedValueSet,
ISWbemServices **objWbemServices ) ISWbemServices **objWbemServices )
{ {
FIXME( "%p, %s, %s, %s, %p, %s, %s, 0x%08x, %p, %p\n", iface, debugstr_w(strServer), struct locator *locator = impl_from_ISWbemLocator( iface );
IWbemServices *services;
BSTR resource;
HRESULT hr;
TRACE( "%p, %s, %s, %s, %p, %s, %s, 0x%08x, %p, %p\n", iface, debugstr_w(strServer),
debugstr_w(strNamespace), debugstr_w(strUser), strPassword, debugstr_w(strLocale), debugstr_w(strNamespace), debugstr_w(strUser), strPassword, debugstr_w(strLocale),
debugstr_w(strAuthority), iSecurityFlags, objWbemNamedValueSet, objWbemServices ); debugstr_w(strAuthority), iSecurityFlags, objWbemNamedValueSet, objWbemServices );
return SWbemServices_create( objWbemServices );
if (objWbemNamedValueSet) FIXME( "context not supported\n" );
if (!locator->locator)
{
hr = CoCreateInstance( &CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator,
(void **)&locator->locator );
if (hr != S_OK) return hr;
}
if (!(resource = build_resource_string( strServer, strNamespace ))) return E_OUTOFMEMORY;
hr = IWbemLocator_ConnectServer( locator->locator, resource, strUser, strPassword, strLocale,
iSecurityFlags, strAuthority, NULL, &services );
SysFreeString( resource );
if (hr != S_OK) return hr;
hr = SWbemServices_create( services, objWbemServices );
IWbemServices_Release( services );
return hr;
} }
static HRESULT WINAPI locator_get_Security_( static HRESULT WINAPI locator_get_Security_(
...@@ -688,6 +745,7 @@ HRESULT SWbemLocator_create( void **obj ) ...@@ -688,6 +745,7 @@ HRESULT SWbemLocator_create( void **obj )
if (!(locator = heap_alloc( sizeof(*locator) ))) return E_OUTOFMEMORY; if (!(locator = heap_alloc( sizeof(*locator) ))) return E_OUTOFMEMORY;
locator->ISWbemLocator_iface.lpVtbl = &locator_vtbl; locator->ISWbemLocator_iface.lpVtbl = &locator_vtbl;
locator->refs = 1; locator->refs = 1;
locator->locator = NULL;
*obj = &locator->ISWbemLocator_iface; *obj = &locator->ISWbemLocator_iface;
TRACE( "returning iface %p\n", *obj ); TRACE( "returning iface %p\n", *obj );
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "initguid.h"
#include "objbase.h" #include "objbase.h"
#include "wbemdisp.h" #include "wbemdisp.h"
#include "rpcproxy.h" #include "rpcproxy.h"
......
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