wmiutils: Implement IWbemPath::SetText and IWbemPath::GetText.
[wine.git] / dlls / wmiutils / path.c
blobb8c0f3ec3c394c966102e07f011db6835779762e
1 /*
2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include "config.h"
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ole2.h"
27 #include "wbemcli.h"
28 #include "wmiutils.h"
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
32 #include "wmiutils_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(wmiutils);
36 struct path
38 IWbemPath IWbemPath_iface;
39 LONG refs;
40 WCHAR *text;
41 int len;
44 static inline struct path *impl_from_IWbemPath( IWbemPath *iface )
46 return CONTAINING_RECORD(iface, struct path, IWbemPath_iface);
49 static ULONG WINAPI path_AddRef(
50 IWbemPath *iface )
52 struct path *path = impl_from_IWbemPath( iface );
53 return InterlockedIncrement( &path->refs );
56 static ULONG WINAPI path_Release(
57 IWbemPath *iface )
59 struct path *path = impl_from_IWbemPath( iface );
60 LONG refs = InterlockedDecrement( &path->refs );
61 if (!refs)
63 TRACE("destroying %p\n", path);
64 HeapFree( GetProcessHeap(), 0, path->text );
65 HeapFree( GetProcessHeap(), 0, path );
67 return refs;
70 static HRESULT WINAPI path_QueryInterface(
71 IWbemPath *iface,
72 REFIID riid,
73 void **ppvObject )
75 struct path *path = impl_from_IWbemPath( iface );
77 TRACE("%p, %s, %p\n", path, debugstr_guid( riid ), ppvObject );
79 if ( IsEqualGUID( riid, &IID_IWbemPath ) ||
80 IsEqualGUID( riid, &IID_IUnknown ) )
82 *ppvObject = iface;
84 else
86 FIXME("interface %s not implemented\n", debugstr_guid(riid));
87 return E_NOINTERFACE;
89 IWbemPath_AddRef( iface );
90 return S_OK;
93 static HRESULT WINAPI path_SetText(
94 IWbemPath *iface,
95 ULONG uMode,
96 LPCWSTR pszPath)
98 struct path *path = impl_from_IWbemPath( iface );
99 int len;
101 TRACE("%p, %u, %s\n", iface, uMode, debugstr_w(pszPath));
103 if (uMode) FIXME("igoring mode %u\n", uMode);
105 len = strlenW( pszPath );
106 if (!(path->text = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) )))
107 return E_OUTOFMEMORY;
109 strcpyW( path->text, pszPath );
110 path->len = len;
111 return S_OK;
114 static HRESULT WINAPI path_GetText(
115 IWbemPath *iface,
116 LONG lFlags,
117 ULONG *puBufferLength,
118 LPWSTR pszText)
120 struct path *path = impl_from_IWbemPath( iface );
122 TRACE("%p, 0x%x, %p, %p\n", iface, lFlags, puBufferLength, pszText);
124 if (lFlags != WBEMPATH_GET_ORIGINAL)
126 FIXME("flags 0x%x not supported\n", lFlags);
127 return WBEM_E_INVALID_PARAMETER;
129 if (*puBufferLength < path->len + 1)
131 *puBufferLength = path->len + 1;
132 return S_OK;
134 if (pszText) strcpyW( pszText, path->text );
135 *puBufferLength = path->len + 1;
136 return S_OK;
139 static HRESULT WINAPI path_GetInfo(
140 IWbemPath *iface,
141 ULONG uRequestedInfo,
142 ULONGLONG *puResponse)
144 FIXME("%p, %d, %p\n", iface, uRequestedInfo, puResponse);
145 return E_NOTIMPL;
148 static HRESULT WINAPI path_SetServer(
149 IWbemPath *iface,
150 LPCWSTR Name)
152 FIXME("%p, %s\n", iface, debugstr_w(Name));
153 return E_NOTIMPL;
156 static HRESULT WINAPI path_GetServer(
157 IWbemPath *iface,
158 ULONG *puNameBufLength,
159 LPWSTR pName)
161 FIXME("%p, %p, %p\n", iface, puNameBufLength, pName);
162 return E_NOTIMPL;
165 static HRESULT WINAPI path_GetNamespaceCount(
166 IWbemPath *iface,
167 ULONG *puCount)
169 FIXME("%p, %p\n", iface, puCount);
170 return E_NOTIMPL;
173 static HRESULT WINAPI path_SetNamespaceAt(
174 IWbemPath *iface,
175 ULONG uIndex,
176 LPCWSTR pszName)
178 FIXME("%p, %u, %s\n", iface, uIndex, debugstr_w(pszName));
179 return E_NOTIMPL;
182 static HRESULT WINAPI path_GetNamespaceAt(
183 IWbemPath *iface,
184 ULONG uIndex,
185 ULONG *puNameBufLength,
186 LPWSTR pName)
188 FIXME("%p, %u, %p, %p\n", iface, uIndex, puNameBufLength, pName);
189 return E_NOTIMPL;
192 static HRESULT WINAPI path_RemoveNamespaceAt(
193 IWbemPath *iface,
194 ULONG uIndex)
196 FIXME("%p, %u\n", iface, uIndex);
197 return E_NOTIMPL;
200 static HRESULT WINAPI path_RemoveAllNamespaces(
201 IWbemPath *iface)
203 FIXME("%p\n", iface);
204 return E_NOTIMPL;
207 static HRESULT WINAPI path_GetScopeCount(
208 IWbemPath *iface,
209 ULONG *puCount)
211 FIXME("%p, %p\n", iface, puCount);
212 return E_NOTIMPL;
215 static HRESULT WINAPI path_SetScope(
216 IWbemPath *iface,
217 ULONG uIndex,
218 LPWSTR pszClass)
220 FIXME("%p, %u, %s\n", iface, uIndex, debugstr_w(pszClass));
221 return E_NOTIMPL;
224 static HRESULT WINAPI path_SetScopeFromText(
225 IWbemPath *iface,
226 ULONG uIndex,
227 LPWSTR pszText)
229 FIXME("%p, %u, %s\n", iface, uIndex, debugstr_w(pszText));
230 return E_NOTIMPL;
233 static HRESULT WINAPI path_GetScope(
234 IWbemPath *iface,
235 ULONG uIndex,
236 ULONG *puClassNameBufSize,
237 LPWSTR pszClass,
238 IWbemPathKeyList **pKeyList)
240 FIXME("%p, %u, %p, %p, %p\n", iface, uIndex, puClassNameBufSize, pszClass, pKeyList);
241 return E_NOTIMPL;
244 static HRESULT WINAPI path_GetScopeAsText(
245 IWbemPath *iface,
246 ULONG uIndex,
247 ULONG *puTextBufSize,
248 LPWSTR pszText)
250 FIXME("%p, %u, %p, %p\n", iface, uIndex, puTextBufSize, pszText);
251 return E_NOTIMPL;
254 static HRESULT WINAPI path_RemoveScope(
255 IWbemPath *iface,
256 ULONG uIndex)
258 FIXME("%p, %u\n", iface, uIndex);
259 return E_NOTIMPL;
262 static HRESULT WINAPI path_RemoveAllScopes(
263 IWbemPath *iface)
265 FIXME("%p\n", iface);
266 return E_NOTIMPL;
269 static HRESULT WINAPI path_SetClassName(
270 IWbemPath *iface,
271 LPCWSTR Name)
273 FIXME("%p, %s\n", iface, debugstr_w(Name));
274 return E_NOTIMPL;
277 static HRESULT WINAPI path_GetClassName(
278 IWbemPath *iface,
279 ULONG *puBufferLength,
280 LPWSTR pszName)
282 FIXME("%p,%p, %p\n", iface, puBufferLength, pszName);
283 return E_NOTIMPL;
286 static HRESULT WINAPI path_GetKeyList(
287 IWbemPath *iface,
288 IWbemPathKeyList **pOut)
290 FIXME("%p, %p\n", iface, pOut);
291 return E_NOTIMPL;
294 static HRESULT WINAPI path_CreateClassPart(
295 IWbemPath *iface,
296 LONG lFlags,
297 LPCWSTR Name)
299 FIXME("%p, 0x%x, %s\n", iface, lFlags, debugstr_w(Name));
300 return E_NOTIMPL;
303 static HRESULT WINAPI path_DeleteClassPart(
304 IWbemPath *iface,
305 LONG lFlags)
307 FIXME("%p, 0x%x\n", iface, lFlags);
308 return E_NOTIMPL;
311 static BOOL WINAPI path_IsRelative(
312 IWbemPath *iface,
313 LPWSTR wszMachine,
314 LPWSTR wszNamespace)
316 FIXME("%p, %s, %s\n", iface, debugstr_w(wszMachine), debugstr_w(wszNamespace));
317 return E_NOTIMPL;
320 static BOOL WINAPI path_IsRelativeOrChild(
321 IWbemPath *iface,
322 LPWSTR wszMachine,
323 LPWSTR wszNamespace,
324 LONG lFlags)
326 FIXME("%p, %s, %s, 0x%x\n", iface, debugstr_w(wszMachine), debugstr_w(wszNamespace), lFlags);
327 return E_NOTIMPL;
330 static BOOL WINAPI path_IsLocal(
331 IWbemPath *iface,
332 LPCWSTR wszMachine)
334 FIXME("%p, %s\n", iface, debugstr_w(wszMachine));
335 return E_NOTIMPL;
338 static BOOL WINAPI path_IsSameClassName(
339 IWbemPath *iface,
340 LPCWSTR wszClass)
342 FIXME("%p, %s\n", iface, debugstr_w(wszClass));
343 return E_NOTIMPL;
346 static const struct IWbemPathVtbl path_vtbl =
348 path_QueryInterface,
349 path_AddRef,
350 path_Release,
351 path_SetText,
352 path_GetText,
353 path_GetInfo,
354 path_SetServer,
355 path_GetServer,
356 path_GetNamespaceCount,
357 path_SetNamespaceAt,
358 path_GetNamespaceAt,
359 path_RemoveNamespaceAt,
360 path_RemoveAllNamespaces,
361 path_GetScopeCount,
362 path_SetScope,
363 path_SetScopeFromText,
364 path_GetScope,
365 path_GetScopeAsText,
366 path_RemoveScope,
367 path_RemoveAllScopes,
368 path_SetClassName,
369 path_GetClassName,
370 path_GetKeyList,
371 path_CreateClassPart,
372 path_DeleteClassPart,
373 path_IsRelative,
374 path_IsRelativeOrChild,
375 path_IsLocal,
376 path_IsSameClassName
379 HRESULT WbemPath_create( IUnknown *pUnkOuter, LPVOID *ppObj )
381 struct path *path;
383 TRACE("%p, %p\n", pUnkOuter, ppObj);
385 if (!(path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) ))) return E_OUTOFMEMORY;
387 path->IWbemPath_iface.lpVtbl = &path_vtbl;
388 path->refs = 1;
390 *ppObj = &path->IWbemPath_iface;
392 TRACE("returning iface %p\n", *ppObj);
393 return S_OK;