From 47e9ffa773a0c96e2ac64005f9d9b50f152442e2 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 15 Jan 2013 11:26:48 +0100 Subject: [PATCH] wmiutils: Implement IWbemPath::GetInfo. --- dlls/wmiutils/path.c | 56 ++++++++++++++++++++++++++++++---------- dlls/wmiutils/tests/path.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++ include/wmiutils.idl | 22 ++++++++++++++++ 3 files changed, 128 insertions(+), 14 deletions(-) diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c index abdf0a5567b..f02c9c67a48 100644 --- a/dlls/wmiutils/path.c +++ b/dlls/wmiutils/path.c @@ -35,16 +35,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(wmiutils); struct path { IWbemPath IWbemPath_iface; - LONG refs; - WCHAR *text; - int len_text; - WCHAR *server; - int len_server; - WCHAR **namespaces; - int *len_namespaces; - int num_namespaces; - WCHAR *class; - int len_class; + LONG refs; + WCHAR *text; + int len_text; + WCHAR *server; + int len_server; + WCHAR **namespaces; + int *len_namespaces; + int num_namespaces; + WCHAR *class; + int len_class; + ULONGLONG flags; }; static void init_path( struct path *path ) @@ -58,6 +59,7 @@ static void init_path( struct path *path ) path->num_namespaces = 0; path->class = NULL; path->len_class = 0; + path->flags = 0; } static void clear_path( struct path *path ) @@ -136,6 +138,7 @@ static HRESULT parse_text( struct path *path, ULONG mode, const WCHAR *text ) memcpy( path->server, p, len * sizeof(WCHAR) ); path->server[len] = 0; path->len_server = len; + path->flags |= WBEMPATH_INFO_PATH_HAD_SERVER; } p = q; while (*q && *q != ':') @@ -180,6 +183,7 @@ static HRESULT parse_text( struct path *path, ULONG mode, const WCHAR *text ) done: if (hr != S_OK) clear_path( path ); + else path->flags |= WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_V2_COMPLIANT; return hr; } @@ -197,6 +201,7 @@ static HRESULT WINAPI path_SetText( if (!uMode || !pszPath) return WBEM_E_INVALID_PARAMETER; clear_path( path ); + if (!pszPath[0]) return S_OK; if ((hr = parse_text( path, uMode, pszPath )) != S_OK) return hr; len = strlenW( pszPath ); @@ -404,11 +409,34 @@ static HRESULT WINAPI path_GetText( static HRESULT WINAPI path_GetInfo( IWbemPath *iface, - ULONG uRequestedInfo, - ULONGLONG *puResponse) + ULONG info, + ULONGLONG *response) { - FIXME("%p, %d, %p\n", iface, uRequestedInfo, puResponse); - return E_NOTIMPL; + struct path *path = impl_from_IWbemPath( iface ); + + TRACE("%p, %u, %p\n", iface, info, response); + + if (info || !response) return WBEM_E_INVALID_PARAMETER; + + FIXME("some flags are not implemented\n"); + + *response = path->flags; + if (!path->server || (path->len_server == 1 && path->server[0] == '.')) + *response |= WBEMPATH_INFO_ANON_LOCAL_MACHINE; + else + *response |= WBEMPATH_INFO_HAS_MACHINE_NAME; + + if (!path->class) + *response |= WBEMPATH_INFO_SERVER_NAMESPACE_ONLY; + else + { + *response |= WBEMPATH_INFO_HAS_SUBSCOPES; + if (path->text && strchrW( path->text, '=' )) /* FIXME */ + *response |= WBEMPATH_INFO_IS_INST_REF; + else + *response |= WBEMPATH_INFO_IS_CLASS_REF; + } + return S_OK; } static HRESULT WINAPI path_SetServer( diff --git a/dlls/wmiutils/tests/path.c b/dlls/wmiutils/tests/path.c index 2d435f0faa1..3367690a00f 100644 --- a/dlls/wmiutils/tests/path.c +++ b/dlls/wmiutils/tests/path.c @@ -370,6 +370,69 @@ static void test_IWbemPath_GetServer(void) IWbemPath_Release( path ); } +static void test_IWbemPath_GetInfo(void) +{ + IWbemPath *path; + HRESULT hr; + ULONGLONG resp; + + if (!(path = create_path())) return; + + hr = IWbemPath_GetInfo( path, 0, NULL ); + ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr ); + + hr = IWbemPath_GetInfo( path, 1, NULL ); + ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr ); + + resp = 0xdeadbeef; + hr = IWbemPath_GetInfo( path, 0, &resp ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY), + "got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp ); + + hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = IWbemPath_GetInfo( path, 0, NULL ); + ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr ); + + hr = IWbemPath_GetInfo( path, 1, NULL ); + ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr ); + + resp = 0xdeadbeef; + hr = IWbemPath_GetInfo( path, 0, &resp ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF | + WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT | + WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER), + "got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp ); + + IWbemPath_Release( path ); + if (!(path = create_path())) return; + + hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path12 ); + ok( hr == S_OK, "got %08x\n", hr ); + + resp = 0xdeadbeef; + hr = IWbemPath_GetInfo( path, 0, &resp ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( resp == (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)(resp >> 32), (unsigned long)resp ); + + hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path1 ); + ok( hr == S_OK, "got %08x\n", hr ); + + resp = 0xdeadbeef; + hr = IWbemPath_GetInfo( path, 0, &resp ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY), + "got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp ); + + IWbemPath_Release( path ); +} + START_TEST (path) { CoInitialize( NULL ); @@ -378,6 +441,7 @@ START_TEST (path) test_IWbemPath_GetText(); test_IWbemPath_GetClassName(); test_IWbemPath_GetServer(); + test_IWbemPath_GetInfo(); CoUninitialize(); } diff --git a/include/wmiutils.idl b/include/wmiutils.idl index 82f64d14455..fa790c83460 100644 --- a/include/wmiutils.idl +++ b/include/wmiutils.idl @@ -21,6 +21,28 @@ import "oaidl.idl"; interface IWbemPath; interface IWbemPathKeyList; +typedef [v1_enum] enum tag_WBEM_PATH_STATUS_FLAG +{ + WBEMPATH_INFO_ANON_LOCAL_MACHINE = 0x1, + WBEMPATH_INFO_HAS_MACHINE_NAME = 0x2, + WBEMPATH_INFO_IS_CLASS_REF = 0x4, + WBEMPATH_INFO_IS_INST_REF = 0x8, + WBEMPATH_INFO_HAS_SUBSCOPES = 0x10, + WBEMPATH_INFO_IS_COMPOUND = 0x20, + WBEMPATH_INFO_HAS_V2_REF_PATHS = 0x40, + WBEMPATH_INFO_HAS_IMPLIED_KEY = 0x80, + WBEMPATH_INFO_CONTAINS_SINGLETON = 0x100, + WBEMPATH_INFO_V1_COMPLIANT = 0x200, + WBEMPATH_INFO_V2_COMPLIANT = 0x400, + WBEMPATH_INFO_CIM_COMPLIANT = 0x800, + WBEMPATH_INFO_IS_SINGLETON = 0x1000, + WBEMPATH_INFO_IS_PARENT = 0x2000, + WBEMPATH_INFO_SERVER_NAMESPACE_ONLY = 0x4000, + WBEMPATH_INFO_NATIVE_PATH = 0x8000, + WBEMPATH_INFO_WMI_PATH = 0x10000, + WBEMPATH_INFO_PATH_HAD_SERVER = 0x20000 +} tag_WBEM_PATH_STATUS_FLAG; + typedef [v1_enum] enum tag_WBEM_PATH_CREATE_FLAG { WBEMPATH_CREATE_ACCEPT_RELATIVE = 0x1, -- 2.11.4.GIT