Hans Leidekker : wmiutils: Implement IWbemPath::SetClassName.

Alexandre Julliard julliard at winehq.org
Thu Jan 17 14:48:50 CST 2013


Module: wine
Branch: master
Commit: ae6468c9a9d9fbd9b51296bb4edfece8d8632255
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ae6468c9a9d9fbd9b51296bb4edfece8d8632255

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Thu Jan 17 15:29:12 2013 +0100

wmiutils: Implement IWbemPath::SetClassName.

---

 dlls/wmiutils/path.c       |   24 +++++++++++++++++++-----
 dlls/wmiutils/tests/path.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c
index e706372..6e63e26 100644
--- a/dlls/wmiutils/path.c
+++ b/dlls/wmiutils/path.c
@@ -447,18 +447,21 @@ static HRESULT WINAPI path_SetServer(
     static const ULONGLONG flags =
         WBEMPATH_INFO_PATH_HAD_SERVER | WBEMPATH_INFO_V1_COMPLIANT |
         WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT;
+    WCHAR *server;
 
     TRACE("%p, %s\n", iface, debugstr_w(name));
 
-    heap_free( path->server );
     if (name)
     {
-        if (!(path->server = strdupW( name ))) return WBEM_E_OUT_OF_MEMORY;
+        if (!(server = strdupW( name ))) return WBEM_E_OUT_OF_MEMORY;
+        heap_free( path->server );
+        path->server = server;
         path->len_server = strlenW( path->server );
         path->flags |= flags;
     }
     else
     {
+        heap_free( path->server );
         path->server = NULL;
         path->len_server = 0;
         path->flags &= ~flags;
@@ -593,10 +596,21 @@ static HRESULT WINAPI path_RemoveAllScopes(
 
 static HRESULT WINAPI path_SetClassName(
     IWbemPath *iface,
-    LPCWSTR Name)
+    LPCWSTR name)
 {
-    FIXME("%p, %s\n", iface, debugstr_w(Name));
-    return E_NOTIMPL;
+    struct path *path = impl_from_IWbemPath( iface );
+    WCHAR *class;
+
+    TRACE("%p, %s\n", iface, debugstr_w(name));
+
+    if (!name) return WBEM_E_INVALID_PARAMETER;
+
+    if (!(class = strdupW( name ))) return WBEM_E_OUT_OF_MEMORY;
+    heap_free( path->class );
+    path->class = class;
+    path->len_class = strlenW( path->class );
+    path->flags |= WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT;
+    return S_OK;
 }
 
 static HRESULT WINAPI path_GetClassName(
diff --git a/dlls/wmiutils/tests/path.c b/dlls/wmiutils/tests/path.c
index 947defa..e21593d 100644
--- a/dlls/wmiutils/tests/path.c
+++ b/dlls/wmiutils/tests/path.c
@@ -324,6 +324,44 @@ static void test_IWbemPath_GetClassName(void)
     IWbemPath_Release( path );
 }
 
+static void test_IWbemPath_SetClassName(void)
+{
+    static const WCHAR classW[] = {'c','l','a','s','s',0};
+    static const WCHAR emptyW[] = {0};
+    IWbemPath *path;
+    WCHAR buf[16];
+    ULONG len;
+    ULONGLONG flags;
+    HRESULT hr;
+
+    if (!(path = create_path())) return;
+
+    hr = IWbemPath_SetClassName( path, NULL );
+    ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
+
+    hr = IWbemPath_SetClassName( path, emptyW );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = IWbemPath_SetClassName( path, classW );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    buf[0] = 0;
+    len = sizeof(buf) / sizeof(buf[0]);
+    hr = IWbemPath_GetClassName( path, &len, buf );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
+
+    flags = 0;
+    hr = IWbemPath_GetInfo( path, 0, &flags );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_CLASS_REF |
+                  WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
+                  WBEMPATH_INFO_CIM_COMPLIANT),
+        "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
+
+    IWbemPath_Release( path );
+}
+
 static void test_IWbemPath_GetServer(void)
 {
     static const WCHAR dotW[] = {'.',0};
@@ -438,6 +476,7 @@ static void test_IWbemPath_GetInfo(void)
 static void test_IWbemPath_SetServer(void)
 {
     static const WCHAR serverW[] = {'s','e','r','v','e','r',0};
+    static const WCHAR emptyW[] = {0};
     IWbemPath *path;
     WCHAR buf[16];
     ULONG len;
@@ -453,6 +492,9 @@ static void test_IWbemPath_SetServer(void)
     hr = IWbemPath_GetServer( path, &len, buf );
     ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
 
+    hr = IWbemPath_SetServer( path, emptyW );
+    ok( hr == S_OK, "got %08x\n", hr );
+
     hr = IWbemPath_SetServer( path, serverW );
     ok( hr == S_OK, "got %08x\n", hr );
 
@@ -493,6 +535,7 @@ START_TEST (path)
     test_IWbemPath_SetText();
     test_IWbemPath_GetText();
     test_IWbemPath_GetClassName();
+    test_IWbemPath_SetClassName();
     test_IWbemPath_GetServer();
     test_IWbemPath_GetInfo();
     test_IWbemPath_SetServer();




More information about the wine-cvs mailing list