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
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
32 #include "wbemprox_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
36 struct client_security
38 IClientSecurity IClientSecurity_iface;
41 static inline struct client_security *impl_from_IClientSecurity( IClientSecurity *iface )
43 return CONTAINING_RECORD( iface, struct client_security, IClientSecurity_iface );
46 static HRESULT WINAPI client_security_QueryInterface(
47 IClientSecurity *iface,
51 struct client_security *cs = impl_from_IClientSecurity( iface );
53 TRACE("%p %s %p\n", cs, debugstr_guid( riid ), ppvObject );
55 if ( IsEqualGUID( riid, &IID_IClientSecurity ) ||
56 IsEqualGUID( riid, &IID_IUnknown ) )
62 FIXME("interface %s not implemented\n", debugstr_guid(riid));
65 IClientSecurity_AddRef( iface );
69 static ULONG WINAPI client_security_AddRef(
70 IClientSecurity *iface )
76 static ULONG WINAPI client_security_Release(
77 IClientSecurity *iface )
83 static HRESULT WINAPI client_security_QueryBlanket(
84 IClientSecurity *iface,
88 OLECHAR **pServerPrincName,
92 DWORD *pCapabilities )
98 static HRESULT WINAPI client_security_SetBlanket(
99 IClientSecurity *iface,
103 OLECHAR *pServerPrincName,
109 FIXME("%p, %p, %u, %u, %s, %u, %u, %p, 0x%08x\n", iface, pProxy, AuthnSvc, AuthzSvc,
110 debugstr_w(pServerPrincName), AuthnLevel, ImpLevel, pAuthInfo, Capabilities);
111 return WBEM_NO_ERROR;
114 static HRESULT WINAPI client_security_CopyProxy(
115 IClientSecurity *iface,
120 return WBEM_E_FAILED;
123 static const IClientSecurityVtbl client_security_vtbl =
125 client_security_QueryInterface,
126 client_security_AddRef,
127 client_security_Release,
128 client_security_QueryBlanket,
129 client_security_SetBlanket,
130 client_security_CopyProxy
133 IClientSecurity client_security = { &client_security_vtbl };
137 IWbemServices IWbemServices_iface;
142 static inline struct wbem_services *impl_from_IWbemServices( IWbemServices *iface )
144 return CONTAINING_RECORD( iface, struct wbem_services, IWbemServices_iface );
147 static ULONG WINAPI wbem_services_AddRef(
148 IWbemServices *iface )
150 struct wbem_services *ws = impl_from_IWbemServices( iface );
151 return InterlockedIncrement( &ws->refs );
154 static ULONG WINAPI wbem_services_Release(
155 IWbemServices *iface )
157 struct wbem_services *ws = impl_from_IWbemServices( iface );
158 LONG refs = InterlockedDecrement( &ws->refs );
161 TRACE("destroying %p\n", ws);
162 heap_free( ws->namespace );
168 static HRESULT WINAPI wbem_services_QueryInterface(
169 IWbemServices *iface,
173 struct wbem_services *ws = impl_from_IWbemServices( iface );
175 TRACE("%p %s %p\n", ws, debugstr_guid( riid ), ppvObject );
177 if ( IsEqualGUID( riid, &IID_IWbemServices ) ||
178 IsEqualGUID( riid, &IID_IUnknown ) )
182 else if ( IsEqualGUID( riid, &IID_IClientSecurity ) )
184 *ppvObject = &client_security;
189 FIXME("interface %s not implemented\n", debugstr_guid(riid));
190 return E_NOINTERFACE;
192 IWbemServices_AddRef( iface );
196 static HRESULT WINAPI wbem_services_OpenNamespace(
197 IWbemServices *iface,
198 const BSTR strNamespace,
201 IWbemServices **ppWorkingNamespace,
202 IWbemCallResult **ppResult )
204 static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
205 static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0};
206 struct wbem_services *ws = impl_from_IWbemServices( iface );
208 TRACE("%p, %s, 0x%08x, %p, %p, %p\n", iface, debugstr_w(strNamespace), lFlags,
209 pCtx, ppWorkingNamespace, ppResult);
211 if ((strcmpiW( strNamespace, cimv2W ) && strcmpiW( strNamespace, defaultW )) || ws->namespace)
212 return WBEM_E_INVALID_NAMESPACE;
214 return WbemServices_create( NULL, cimv2W, (void **)ppWorkingNamespace );
217 static HRESULT WINAPI wbem_services_CancelAsyncCall(
218 IWbemServices *iface,
219 IWbemObjectSink *pSink )
222 return WBEM_E_FAILED;
225 static HRESULT WINAPI wbem_services_QueryObjectSink(
226 IWbemServices *iface,
228 IWbemObjectSink **ppResponseHandler )
231 return WBEM_E_FAILED;
234 static HRESULT WINAPI wbem_services_GetObject(
235 IWbemServices *iface,
236 const BSTR strObjectPath,
239 IWbemClassObject **ppObject,
240 IWbemCallResult **ppCallResult )
242 static const WCHAR selectW[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',0};
243 IEnumWbemClassObject *iter;
247 TRACE("%p, %s, 0x%08x, %p, %p, %p\n", iface, debugstr_w(strObjectPath), lFlags,
248 pCtx, ppObject, ppCallResult);
250 if (lFlags) FIXME("unsupported flags 0x%08x\n", lFlags);
252 /* FIXME: parse path */
254 if (!(query = heap_alloc( strlenW( strObjectPath ) * sizeof(WCHAR) + sizeof(selectW) )))
255 return E_OUTOFMEMORY;
256 strcpyW( query, selectW );
257 strcatW( query, strObjectPath );
259 hr = exec_query( query, &iter );
261 if (hr != S_OK) return hr;
263 hr = WbemClassObject_create( NULL, iter, 0, (void **)ppObject );
264 IEnumWbemClassObject_Release( iter );
268 static HRESULT WINAPI wbem_services_GetObjectAsync(
269 IWbemServices *iface,
270 const BSTR strObjectPath,
273 IWbemObjectSink *pResponseHandler )
276 return WBEM_E_FAILED;
279 static HRESULT WINAPI wbem_services_PutClass(
280 IWbemServices *iface,
281 IWbemClassObject *pObject,
284 IWbemCallResult **ppCallResult )
287 return WBEM_E_FAILED;
290 static HRESULT WINAPI wbem_services_PutClassAsync(
291 IWbemServices *iface,
292 IWbemClassObject *pObject,
295 IWbemObjectSink *pResponseHandler )
298 return WBEM_E_FAILED;
301 static HRESULT WINAPI wbem_services_DeleteClass(
302 IWbemServices *iface,
306 IWbemCallResult **ppCallResult )
309 return WBEM_E_FAILED;
312 static HRESULT WINAPI wbem_services_DeleteClassAsync(
313 IWbemServices *iface,
317 IWbemObjectSink *pResponseHandler )
320 return WBEM_E_FAILED;
323 static HRESULT WINAPI wbem_services_CreateClassEnum(
324 IWbemServices *iface,
325 const BSTR strSuperclass,
328 IEnumWbemClassObject **ppEnum )
331 return WBEM_E_FAILED;
334 static HRESULT WINAPI wbem_services_CreateClassEnumAsync(
335 IWbemServices *iface,
336 const BSTR strSuperclass,
339 IWbemObjectSink *pResponseHandler )
342 return WBEM_E_FAILED;
345 static HRESULT WINAPI wbem_services_PutInstance(
346 IWbemServices *iface,
347 IWbemClassObject *pInst,
350 IWbemCallResult **ppCallResult )
353 return WBEM_E_FAILED;
356 static HRESULT WINAPI wbem_services_PutInstanceAsync(
357 IWbemServices *iface,
358 IWbemClassObject *pInst,
361 IWbemObjectSink *pResponseHandler )
364 return WBEM_E_FAILED;
367 static HRESULT WINAPI wbem_services_DeleteInstance(
368 IWbemServices *iface,
369 const BSTR strObjectPath,
372 IWbemCallResult **ppCallResult )
375 return WBEM_E_FAILED;
378 static HRESULT WINAPI wbem_services_DeleteInstanceAsync(
379 IWbemServices *iface,
380 const BSTR strObjectPath,
383 IWbemObjectSink *pResponseHandler )
386 return WBEM_E_FAILED;
389 static HRESULT WINAPI wbem_services_CreateInstanceEnum(
390 IWbemServices *iface,
394 IEnumWbemClassObject **ppEnum )
396 static const WCHAR selectW[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',0};
400 TRACE("%p, %s, 0%08x, %p, %p\n", iface, debugstr_w(strClass), lFlags, pCtx, ppEnum);
402 if (lFlags) FIXME("unsupported flags 0x%08x\n", lFlags);
404 if (!(query = heap_alloc( strlenW( strClass ) * sizeof(WCHAR) + sizeof(selectW) )))
405 return E_OUTOFMEMORY;
406 strcpyW( query, selectW );
407 strcatW( query, strClass );
409 hr = exec_query( query, ppEnum );
414 static HRESULT WINAPI wbem_services_CreateInstanceEnumAsync(
415 IWbemServices *iface,
416 const BSTR strFilter,
419 IWbemObjectSink *pResponseHandler )
422 return WBEM_E_FAILED;
425 static HRESULT WINAPI wbem_services_ExecQuery(
426 IWbemServices *iface,
427 const BSTR strQueryLanguage,
431 IEnumWbemClassObject **ppEnum )
433 static const WCHAR wqlW[] = {'W','Q','L',0};
435 TRACE("%p, %s, %s, 0x%08x, %p, %p\n", iface, debugstr_w(strQueryLanguage),
436 debugstr_w(strQuery), lFlags, pCtx, ppEnum);
438 if (!strQueryLanguage || !strQuery) return WBEM_E_INVALID_PARAMETER;
439 if (strcmpiW( strQueryLanguage, wqlW )) return WBEM_E_INVALID_QUERY_TYPE;
440 return exec_query( strQuery, ppEnum );
443 static HRESULT WINAPI wbem_services_ExecQueryAsync(
444 IWbemServices *iface,
445 const BSTR strQueryLanguage,
449 IWbemObjectSink *pResponseHandler )
452 return WBEM_E_FAILED;
455 static HRESULT WINAPI wbem_services_ExecNotificationQuery(
456 IWbemServices *iface,
457 const BSTR strQueryLanguage,
461 IEnumWbemClassObject **ppEnum )
464 return WBEM_E_FAILED;
467 static HRESULT WINAPI wbem_services_ExecNotificationQueryAsync(
468 IWbemServices *iface,
469 const BSTR strQueryLanguage,
473 IWbemObjectSink *pResponseHandler )
476 return WBEM_E_FAILED;
479 static HRESULT WINAPI wbem_services_ExecMethod(
480 IWbemServices *iface,
481 const BSTR strObjectPath,
482 const BSTR strMethodName,
485 IWbemClassObject *pInParams,
486 IWbemClassObject **ppOutParams,
487 IWbemCallResult **ppCallResult )
490 return WBEM_E_FAILED;
493 static HRESULT WINAPI wbem_services_ExecMethodAsync(
494 IWbemServices *iface,
495 const BSTR strObjectPath,
496 const BSTR strMethodName,
499 IWbemClassObject *pInParams,
500 IWbemObjectSink *pResponseHandler )
503 return WBEM_E_FAILED;
506 static const IWbemServicesVtbl wbem_services_vtbl =
508 wbem_services_QueryInterface,
509 wbem_services_AddRef,
510 wbem_services_Release,
511 wbem_services_OpenNamespace,
512 wbem_services_CancelAsyncCall,
513 wbem_services_QueryObjectSink,
514 wbem_services_GetObject,
515 wbem_services_GetObjectAsync,
516 wbem_services_PutClass,
517 wbem_services_PutClassAsync,
518 wbem_services_DeleteClass,
519 wbem_services_DeleteClassAsync,
520 wbem_services_CreateClassEnum,
521 wbem_services_CreateClassEnumAsync,
522 wbem_services_PutInstance,
523 wbem_services_PutInstanceAsync,
524 wbem_services_DeleteInstance,
525 wbem_services_DeleteInstanceAsync,
526 wbem_services_CreateInstanceEnum,
527 wbem_services_CreateInstanceEnumAsync,
528 wbem_services_ExecQuery,
529 wbem_services_ExecQueryAsync,
530 wbem_services_ExecNotificationQuery,
531 wbem_services_ExecNotificationQueryAsync,
532 wbem_services_ExecMethod,
533 wbem_services_ExecMethodAsync
536 HRESULT WbemServices_create( IUnknown *pUnkOuter, const WCHAR *namespace, LPVOID *ppObj )
538 struct wbem_services *ws;
540 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
542 ws = heap_alloc( sizeof(*ws) );
543 if (!ws) return E_OUTOFMEMORY;
545 ws->IWbemServices_iface.lpVtbl = &wbem_services_vtbl;
547 ws->namespace = heap_strdupW( namespace );
549 *ppObj = &ws->IWbemServices_iface;
551 TRACE("returning iface %p\n", *ppObj);