[1/5] wbemprox: Implement IWbemServices::OpenNamespace.

Hans Leidekker hans at codeweavers.com
Tue Jun 26 09:01:43 CDT 2012


---
 dlls/wbemprox/services.c         |   17 +++++++++++++----
 dlls/wbemprox/wbemlocator.c      |    2 +-
 dlls/wbemprox/wbemprox_private.h |    2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/dlls/wbemprox/services.c b/dlls/wbemprox/services.c
index e33ff36..b4bc8fb 100644
--- a/dlls/wbemprox/services.c
+++ b/dlls/wbemprox/services.c
@@ -201,8 +201,17 @@ static HRESULT WINAPI wbem_services_OpenNamespace(
     IWbemServices **ppWorkingNamespace,
     IWbemCallResult **ppResult )
 {
-    FIXME("\n");
-    return WBEM_E_FAILED;
+    static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
+    static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0};
+    struct wbem_services *ws = impl_from_IWbemServices( iface );
+
+    TRACE("%p, %s, 0x%08x, %p, %p, %p\n", iface, debugstr_w(strNamespace), lFlags,
+          pCtx, ppWorkingNamespace, ppResult);
+
+    if ((strcmpiW( strNamespace, cimv2W ) && strcmpiW( strNamespace, defaultW )) || ws->namespace)
+        return WBEM_E_INVALID_NAMESPACE;
+
+    return WbemServices_create( NULL, cimv2W, (void **)ppWorkingNamespace );
 }
 
 static HRESULT WINAPI wbem_services_CancelAsyncCall(
@@ -488,7 +497,7 @@ static const IWbemServicesVtbl wbem_services_vtbl =
     wbem_services_ExecMethodAsync
 };
 
-HRESULT WbemServices_create( IUnknown *pUnkOuter, WCHAR *namespace, LPVOID *ppObj )
+HRESULT WbemServices_create( IUnknown *pUnkOuter, const WCHAR *namespace, LPVOID *ppObj )
 {
     struct wbem_services *ws;
 
@@ -499,7 +508,7 @@ HRESULT WbemServices_create( IUnknown *pUnkOuter, WCHAR *namespace, LPVOID *ppOb
 
     ws->IWbemServices_iface.lpVtbl = &wbem_services_vtbl;
     ws->refs = 1;
-    ws->namespace = namespace;
+    ws->namespace = heap_strdupW( namespace );
 
     *ppObj = &ws->IWbemServices_iface;
 
diff --git a/dlls/wbemprox/wbemlocator.c b/dlls/wbemprox/wbemlocator.c
index 87a4d01..0034983 100644
--- a/dlls/wbemprox/wbemlocator.c
+++ b/dlls/wbemprox/wbemlocator.c
@@ -192,10 +192,10 @@ static HRESULT WINAPI wbem_locator_ConnectServer(
         FIXME("unsupported flags\n");
 
     hr = WbemServices_create( NULL, namespace, (void **)ppNamespace );
+    heap_free( namespace );
     if (SUCCEEDED( hr ))
         return WBEM_NO_ERROR;
 
-    heap_free( namespace );
     return WBEM_E_FAILED;
 }
 
diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h
index d0cdb76..9273744 100644
--- a/dlls/wbemprox/wbemprox_private.h
+++ b/dlls/wbemprox/wbemprox_private.h
@@ -121,7 +121,7 @@ HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
 HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN;
 
 HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
-HRESULT WbemServices_create(IUnknown *, WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
+HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
 HRESULT WbemClassObject_create(IUnknown *, IEnumWbemClassObject *, UINT, LPVOID *) DECLSPEC_HIDDEN;
 HRESULT EnumWbemClassObject_create(IUnknown *, struct query *, LPVOID *) DECLSPEC_HIDDEN;
 
-- 
1.7.10







More information about the wine-patches mailing list