msvcp90: Added num_put<char>::put(double) implementation.
[wine] / dlls / wbemprox / services.c
1 /*
2  * Copyright 2012 Hans Leidekker for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #define COBJMACROS
20
21 #include "config.h"
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "initguid.h"
27 #include "objbase.h"
28 #include "wbemcli.h"
29
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
32 #include "wbemprox_private.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
35
36 struct client_security
37 {
38     IClientSecurity IClientSecurity_iface;
39 };
40
41 static inline struct client_security *impl_from_IClientSecurity( IClientSecurity *iface )
42 {
43     return CONTAINING_RECORD( iface, struct client_security, IClientSecurity_iface );
44 }
45
46 static HRESULT WINAPI client_security_QueryInterface(
47     IClientSecurity *iface,
48     REFIID riid,
49     void **ppvObject )
50 {
51     struct client_security *cs = impl_from_IClientSecurity( iface );
52
53     TRACE("%p %s %p\n", cs, debugstr_guid( riid ), ppvObject );
54
55     if ( IsEqualGUID( riid, &IID_IClientSecurity ) ||
56          IsEqualGUID( riid, &IID_IUnknown ) )
57     {
58         *ppvObject = cs;
59     }
60     else
61     {
62         FIXME("interface %s not implemented\n", debugstr_guid(riid));
63         return E_NOINTERFACE;
64     }
65     IClientSecurity_AddRef( iface );
66     return S_OK;
67 }
68
69 static ULONG WINAPI client_security_AddRef(
70     IClientSecurity *iface )
71 {
72     FIXME("%p\n", iface);
73     return 2;
74 }
75
76 static ULONG WINAPI client_security_Release(
77     IClientSecurity *iface )
78 {
79     FIXME("%p\n", iface);
80     return 1;
81 }
82
83 static HRESULT WINAPI client_security_QueryBlanket(
84     IClientSecurity *iface,
85     IUnknown *pProxy,
86     DWORD *pAuthnSvc,
87     DWORD *pAuthzSvc,
88     OLECHAR **pServerPrincName,
89     DWORD *pAuthnLevel,
90     DWORD *pImpLevel,
91     void **pAuthInfo,
92     DWORD *pCapabilities )
93 {
94     FIXME("\n");
95     return WBEM_E_FAILED;
96 }
97
98 static HRESULT WINAPI client_security_SetBlanket(
99     IClientSecurity *iface,
100     IUnknown *pProxy,
101     DWORD AuthnSvc,
102     DWORD AuthzSvc,
103     OLECHAR *pServerPrincName,
104     DWORD AuthnLevel,
105     DWORD ImpLevel,
106     void *pAuthInfo,
107     DWORD Capabilities )
108 {
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;
112 }
113
114 static HRESULT WINAPI client_security_CopyProxy(
115     IClientSecurity *iface,
116     IUnknown *pProxy,
117     IUnknown **ppCopy )
118 {
119     FIXME("\n");
120     return WBEM_E_FAILED;
121 }
122
123 static const IClientSecurityVtbl client_security_vtbl =
124 {
125     client_security_QueryInterface,
126     client_security_AddRef,
127     client_security_Release,
128     client_security_QueryBlanket,
129     client_security_SetBlanket,
130     client_security_CopyProxy
131 };
132
133 static IClientSecurity client_security = { &client_security_vtbl };
134
135 struct wbem_services
136 {
137     IWbemServices IWbemServices_iface;
138     LONG refs;
139 };
140
141 static inline struct wbem_services *impl_from_IWbemServices( IWbemServices *iface )
142 {
143     return CONTAINING_RECORD( iface, struct wbem_services, IWbemServices_iface );
144 }
145
146 static ULONG WINAPI wbem_services_AddRef(
147     IWbemServices *iface )
148 {
149     struct wbem_services *ws = impl_from_IWbemServices( iface );
150     return InterlockedIncrement( &ws->refs );
151 }
152
153 static ULONG WINAPI wbem_services_Release(
154     IWbemServices *iface )
155 {
156     struct wbem_services *ws = impl_from_IWbemServices( iface );
157     LONG refs = InterlockedDecrement( &ws->refs );
158     if (!refs)
159     {
160         TRACE("destroying %p\n", ws);
161         heap_free( ws );
162     }
163     return refs;
164 }
165
166 static HRESULT WINAPI wbem_services_QueryInterface(
167     IWbemServices *iface,
168     REFIID riid,
169     void **ppvObject )
170 {
171     struct wbem_services *ws = impl_from_IWbemServices( iface );
172
173     TRACE("%p %s %p\n", ws, debugstr_guid( riid ), ppvObject );
174
175     if ( IsEqualGUID( riid, &IID_IWbemServices ) ||
176          IsEqualGUID( riid, &IID_IUnknown ) )
177     {
178         *ppvObject = ws;
179     }
180     else if ( IsEqualGUID( riid, &IID_IClientSecurity ) )
181     {
182         *ppvObject = &client_security;
183         return S_OK;
184     }
185     else
186     {
187         FIXME("interface %s not implemented\n", debugstr_guid(riid));
188         return E_NOINTERFACE;
189     }
190     IWbemServices_AddRef( iface );
191     return S_OK;
192 }
193
194 static HRESULT WINAPI wbem_services_OpenNamespace(
195     IWbemServices *iface,
196     const BSTR strNamespace,
197     LONG lFlags,
198     IWbemContext *pCtx,
199     IWbemServices **ppWorkingNamespace,
200     IWbemCallResult **ppResult )
201 {
202     FIXME("\n");
203     return WBEM_E_FAILED;
204 }
205
206 static HRESULT WINAPI wbem_services_CancelAsyncCall(
207     IWbemServices *iface,
208     IWbemObjectSink *pSink )
209 {
210     FIXME("\n");
211     return WBEM_E_FAILED;
212 }
213
214 static HRESULT WINAPI wbem_services_QueryObjectSink(
215     IWbemServices *iface,
216     LONG lFlags,
217     IWbemObjectSink **ppResponseHandler )
218 {
219     FIXME("\n");
220     return WBEM_E_FAILED;
221 }
222
223 static HRESULT WINAPI wbem_services_GetObject(
224     IWbemServices *iface,
225     const BSTR strObjectPath,
226     LONG lFlags,
227     IWbemContext *pCtx,
228     IWbemClassObject **ppObject,
229     IWbemCallResult **ppCallResult )
230 {
231     FIXME("\n");
232     return WBEM_E_FAILED;
233 }
234
235 static HRESULT WINAPI wbem_services_GetObjectAsync(
236     IWbemServices *iface,
237     const BSTR strObjectPath,
238     LONG lFlags,
239     IWbemContext *pCtx,
240     IWbemObjectSink *pResponseHandler )
241 {
242     FIXME("\n");
243     return WBEM_E_FAILED;
244 }
245
246 static HRESULT WINAPI wbem_services_PutClass(
247     IWbemServices *iface,
248     IWbemClassObject *pObject,
249     LONG lFlags,
250     IWbemContext *pCtx,
251     IWbemCallResult **ppCallResult )
252 {
253     FIXME("\n");
254     return WBEM_E_FAILED;
255 }
256
257 static HRESULT WINAPI wbem_services_PutClassAsync(
258     IWbemServices *iface,
259     IWbemClassObject *pObject,
260     LONG lFlags,
261     IWbemContext *pCtx,
262     IWbemObjectSink *pResponseHandler )
263 {
264     FIXME("\n");
265     return WBEM_E_FAILED;
266 }
267
268 static HRESULT WINAPI wbem_services_DeleteClass(
269     IWbemServices *iface,
270     const BSTR strClass,
271     LONG lFlags,
272     IWbemContext *pCtx,
273     IWbemCallResult **ppCallResult )
274 {
275     FIXME("\n");
276     return WBEM_E_FAILED;
277 }
278
279 static HRESULT WINAPI wbem_services_DeleteClassAsync(
280     IWbemServices *iface,
281     const BSTR strClass,
282     LONG lFlags,
283     IWbemContext *pCtx,
284     IWbemObjectSink *pResponseHandler )
285 {
286     FIXME("\n");
287     return WBEM_E_FAILED;
288 }
289
290 static HRESULT WINAPI wbem_services_CreateClassEnum(
291     IWbemServices *iface,
292     const BSTR strSuperclass,
293     LONG lFlags,
294     IWbemContext *pCtx,
295     IEnumWbemClassObject **ppEnum )
296 {
297     FIXME("\n");
298     return WBEM_E_FAILED;
299 }
300
301 static HRESULT WINAPI wbem_services_CreateClassEnumAsync(
302     IWbemServices *iface,
303     const BSTR strSuperclass,
304     LONG lFlags,
305     IWbemContext *pCtx,
306     IWbemObjectSink *pResponseHandler )
307 {
308     FIXME("\n");
309     return WBEM_E_FAILED;
310 }
311
312 static HRESULT WINAPI wbem_services_PutInstance(
313     IWbemServices *iface,
314     IWbemClassObject *pInst,
315     LONG lFlags,
316     IWbemContext *pCtx,
317     IWbemCallResult **ppCallResult )
318 {
319     FIXME("\n");
320     return WBEM_E_FAILED;
321 }
322
323 static HRESULT WINAPI wbem_services_PutInstanceAsync(
324     IWbemServices *iface,
325     IWbemClassObject *pInst,
326     LONG lFlags,
327     IWbemContext *pCtx,
328     IWbemObjectSink *pResponseHandler )
329 {
330     FIXME("\n");
331     return WBEM_E_FAILED;
332 }
333
334 static HRESULT WINAPI wbem_services_DeleteInstance(
335     IWbemServices *iface,
336     const BSTR strObjectPath,
337     LONG lFlags,
338     IWbemContext *pCtx,
339     IWbemCallResult **ppCallResult )
340 {
341     FIXME("\n");
342     return WBEM_E_FAILED;
343 }
344
345 static HRESULT WINAPI wbem_services_DeleteInstanceAsync(
346     IWbemServices *iface,
347     const BSTR strObjectPath,
348     LONG lFlags,
349     IWbemContext *pCtx,
350     IWbemObjectSink *pResponseHandler )
351 {
352     FIXME("\n");
353     return WBEM_E_FAILED;
354 }
355
356 static HRESULT WINAPI wbem_services_CreateInstanceEnum(
357     IWbemServices *iface,
358     const BSTR strFilter,
359     LONG lFlags,
360     IWbemContext *pCtx,
361     IEnumWbemClassObject **ppEnum )
362 {
363     FIXME("\n");
364     return WBEM_E_FAILED;
365 }
366
367 static HRESULT WINAPI wbem_services_CreateInstanceEnumAsync(
368     IWbemServices *iface,
369     const BSTR strFilter,
370     LONG lFlags,
371     IWbemContext *pCtx,
372     IWbemObjectSink *pResponseHandler )
373 {
374     FIXME("\n");
375     return WBEM_E_FAILED;
376 }
377
378 static HRESULT WINAPI wbem_services_ExecQuery(
379     IWbemServices *iface,
380     const BSTR strQueryLanguage,
381     const BSTR strQuery,
382     LONG lFlags,
383     IWbemContext *pCtx,
384     IEnumWbemClassObject **ppEnum )
385 {
386     static const WCHAR wqlW[] = {'W','Q','L',0};
387
388     TRACE("%p, %s, %s, 0x%08x, %p, %p\n", iface, debugstr_w(strQueryLanguage),
389           debugstr_w(strQuery), lFlags, pCtx, ppEnum);
390
391     if (!strQueryLanguage || !strQuery) return WBEM_E_INVALID_PARAMETER;
392     if (strcmpiW( strQueryLanguage, wqlW )) return WBEM_E_INVALID_QUERY_TYPE;
393     return exec_query( strQuery, ppEnum );
394 }
395
396 static HRESULT WINAPI wbem_services_ExecQueryAsync(
397     IWbemServices *iface,
398     const BSTR strQueryLanguage,
399     const BSTR strQuery,
400     LONG lFlags,
401     IWbemContext *pCtx,
402     IWbemObjectSink *pResponseHandler )
403 {
404     FIXME("\n");
405     return WBEM_E_FAILED;
406 }
407
408 static HRESULT WINAPI wbem_services_ExecNotificationQuery(
409     IWbemServices *iface,
410     const BSTR strQueryLanguage,
411     const BSTR strQuery,
412     LONG lFlags,
413     IWbemContext *pCtx,
414     IEnumWbemClassObject **ppEnum )
415 {
416     FIXME("\n");
417     return WBEM_E_FAILED;
418 }
419
420 static HRESULT WINAPI wbem_services_ExecNotificationQueryAsync(
421     IWbemServices *iface,
422     const BSTR strQueryLanguage,
423     const BSTR strQuery,
424     LONG lFlags,
425     IWbemContext *pCtx,
426     IWbemObjectSink *pResponseHandler )
427 {
428     FIXME("\n");
429     return WBEM_E_FAILED;
430 }
431
432 static HRESULT WINAPI wbem_services_ExecMethod(
433     IWbemServices *iface,
434     const BSTR strObjectPath,
435     const BSTR strMethodName,
436     LONG lFlags,
437     IWbemContext *pCtx,
438     IWbemClassObject *pInParams,
439     IWbemClassObject **ppOutParams,
440     IWbemCallResult **ppCallResult )
441 {
442     FIXME("\n");
443     return WBEM_E_FAILED;
444 }
445
446 static HRESULT WINAPI wbem_services_ExecMethodAsync(
447     IWbemServices *iface,
448     const BSTR strObjectPath,
449     const BSTR strMethodName,
450     LONG lFlags,
451     IWbemContext *pCtx,
452     IWbemClassObject *pInParams,
453     IWbemObjectSink *pResponseHandler )
454 {
455     FIXME("\n");
456     return WBEM_E_FAILED;
457 }
458
459 static const IWbemServicesVtbl wbem_services_vtbl =
460 {
461     wbem_services_QueryInterface,
462     wbem_services_AddRef,
463     wbem_services_Release,
464     wbem_services_OpenNamespace,
465     wbem_services_CancelAsyncCall,
466     wbem_services_QueryObjectSink,
467     wbem_services_GetObject,
468     wbem_services_GetObjectAsync,
469     wbem_services_PutClass,
470     wbem_services_PutClassAsync,
471     wbem_services_DeleteClass,
472     wbem_services_DeleteClassAsync,
473     wbem_services_CreateClassEnum,
474     wbem_services_CreateClassEnumAsync,
475     wbem_services_PutInstance,
476     wbem_services_PutInstanceAsync,
477     wbem_services_DeleteInstance,
478     wbem_services_DeleteInstanceAsync,
479     wbem_services_CreateInstanceEnum,
480     wbem_services_CreateInstanceEnumAsync,
481     wbem_services_ExecQuery,
482     wbem_services_ExecQueryAsync,
483     wbem_services_ExecNotificationQuery,
484     wbem_services_ExecNotificationQueryAsync,
485     wbem_services_ExecMethod,
486     wbem_services_ExecMethodAsync
487 };
488
489 HRESULT WbemServices_create( IUnknown *pUnkOuter, LPVOID *ppObj )
490 {
491     struct wbem_services *ws;
492
493     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
494
495     ws = heap_alloc( sizeof(*ws) );
496     if (!ws) return E_OUTOFMEMORY;
497
498     ws->IWbemServices_iface.lpVtbl = &wbem_services_vtbl;
499     ws->refs = 1;
500
501     *ppObj = &ws->IWbemServices_iface;
502
503     TRACE("returning iface %p\n", *ppObj);
504     return S_OK;
505 }