dwrite: Added initial stub.
[wine/multimedia.git] / dlls / wbemprox / class.c
blobff729f2c07de94598a31fbf59cc9ef6abbb2439c
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 "objbase.h"
27 #include "wbemcli.h"
29 #include "wine/debug.h"
30 #include "wbemprox_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
34 struct enum_class_object
36 IEnumWbemClassObject IEnumWbemClassObject_iface;
37 LONG refs;
38 struct query *query;
39 UINT index;
42 static inline struct enum_class_object *impl_from_IEnumWbemClassObject(
43 IEnumWbemClassObject *iface )
45 return CONTAINING_RECORD(iface, struct enum_class_object, IEnumWbemClassObject_iface);
48 static ULONG WINAPI enum_class_object_AddRef(
49 IEnumWbemClassObject *iface )
51 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
52 return InterlockedIncrement( &ec->refs );
55 static ULONG WINAPI enum_class_object_Release(
56 IEnumWbemClassObject *iface )
58 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
59 LONG refs = InterlockedDecrement( &ec->refs );
60 if (!refs)
62 TRACE("destroying %p\n", ec);
63 release_query( ec->query );
64 heap_free( ec );
66 return refs;
69 static HRESULT WINAPI enum_class_object_QueryInterface(
70 IEnumWbemClassObject *iface,
71 REFIID riid,
72 void **ppvObject )
74 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
76 TRACE("%p, %s, %p\n", ec, debugstr_guid( riid ), ppvObject );
78 if ( IsEqualGUID( riid, &IID_IEnumWbemClassObject ) ||
79 IsEqualGUID( riid, &IID_IUnknown ) )
81 *ppvObject = ec;
83 else if ( IsEqualGUID( riid, &IID_IClientSecurity ) )
85 *ppvObject = &client_security;
86 return S_OK;
88 else
90 FIXME("interface %s not implemented\n", debugstr_guid(riid));
91 return E_NOINTERFACE;
93 IEnumWbemClassObject_AddRef( iface );
94 return S_OK;
97 static HRESULT WINAPI enum_class_object_Reset(
98 IEnumWbemClassObject *iface )
100 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
102 TRACE("%p\n", iface);
104 ec->index = 0;
105 return WBEM_S_NO_ERROR;
108 static HRESULT WINAPI enum_class_object_Next(
109 IEnumWbemClassObject *iface,
110 LONG lTimeout,
111 ULONG uCount,
112 IWbemClassObject **apObjects,
113 ULONG *puReturned )
115 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
116 struct view *view = ec->query->view;
117 HRESULT hr;
119 TRACE("%p, %d, %u, %p, %p\n", iface, lTimeout, uCount, apObjects, puReturned);
121 if (!uCount) return WBEM_S_FALSE;
122 if (!apObjects || !puReturned) return WBEM_E_INVALID_PARAMETER;
123 if (lTimeout != WBEM_INFINITE) FIXME("timeout not supported\n");
125 *puReturned = 0;
126 if (ec->index + uCount > view->count) return WBEM_S_FALSE;
128 hr = WbemClassObject_create( NULL, iface, ec->index, (void **)apObjects );
129 if (hr != S_OK) return hr;
131 ec->index++;
132 *puReturned = 1;
133 if (ec->index == view->count) return WBEM_S_FALSE;
134 if (uCount > 1) return WBEM_S_TIMEDOUT;
135 return WBEM_S_NO_ERROR;
138 static HRESULT WINAPI enum_class_object_NextAsync(
139 IEnumWbemClassObject *iface,
140 ULONG uCount,
141 IWbemObjectSink *pSink )
143 FIXME("%p, %u, %p\n", iface, uCount, pSink);
144 return E_NOTIMPL;
147 static HRESULT WINAPI enum_class_object_Clone(
148 IEnumWbemClassObject *iface,
149 IEnumWbemClassObject **ppEnum )
151 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
153 TRACE("%p, %p\n", iface, ppEnum);
155 return EnumWbemClassObject_create( NULL, ec->query, (void **)ppEnum );
158 static HRESULT WINAPI enum_class_object_Skip(
159 IEnumWbemClassObject *iface,
160 LONG lTimeout,
161 ULONG nCount )
163 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
164 struct view *view = ec->query->view;
166 TRACE("%p, %d, %u\n", iface, lTimeout, nCount);
168 if (lTimeout != WBEM_INFINITE) FIXME("timeout not supported\n");
170 if (ec->index + nCount >= view->count)
172 ec->index = view->count - 1;
173 return WBEM_S_FALSE;
175 ec->index += nCount;
176 return WBEM_S_NO_ERROR;
179 static const IEnumWbemClassObjectVtbl enum_class_object_vtbl =
181 enum_class_object_QueryInterface,
182 enum_class_object_AddRef,
183 enum_class_object_Release,
184 enum_class_object_Reset,
185 enum_class_object_Next,
186 enum_class_object_NextAsync,
187 enum_class_object_Clone,
188 enum_class_object_Skip
191 HRESULT EnumWbemClassObject_create(
192 IUnknown *pUnkOuter, struct query *query, LPVOID *ppObj )
194 struct enum_class_object *ec;
196 TRACE("%p, %p\n", pUnkOuter, ppObj);
198 ec = heap_alloc( sizeof(*ec) );
199 if (!ec) return E_OUTOFMEMORY;
201 ec->IEnumWbemClassObject_iface.lpVtbl = &enum_class_object_vtbl;
202 ec->refs = 1;
203 ec->query = query;
204 addref_query( query );
205 ec->index = 0;
207 *ppObj = &ec->IEnumWbemClassObject_iface;
209 TRACE("returning iface %p\n", *ppObj);
210 return S_OK;
213 struct class_object
215 IWbemClassObject IWbemClassObject_iface;
216 LONG refs;
217 IEnumWbemClassObject *iter;
218 UINT index;
221 static inline struct class_object *impl_from_IWbemClassObject(
222 IWbemClassObject *iface )
224 return CONTAINING_RECORD(iface, struct class_object, IWbemClassObject_iface);
227 static ULONG WINAPI class_object_AddRef(
228 IWbemClassObject *iface )
230 struct class_object *co = impl_from_IWbemClassObject( iface );
231 return InterlockedIncrement( &co->refs );
234 static ULONG WINAPI class_object_Release(
235 IWbemClassObject *iface )
237 struct class_object *co = impl_from_IWbemClassObject( iface );
238 LONG refs = InterlockedDecrement( &co->refs );
239 if (!refs)
241 TRACE("destroying %p\n", co);
242 if (co->iter) IEnumWbemClassObject_Release( co->iter );
243 heap_free( co );
245 return refs;
248 static HRESULT WINAPI class_object_QueryInterface(
249 IWbemClassObject *iface,
250 REFIID riid,
251 void **ppvObject )
253 struct class_object *co = impl_from_IWbemClassObject( iface );
255 TRACE("%p, %s, %p\n", co, debugstr_guid( riid ), ppvObject );
257 if ( IsEqualGUID( riid, &IID_IWbemClassObject ) ||
258 IsEqualGUID( riid, &IID_IUnknown ) )
260 *ppvObject = co;
262 else
264 FIXME("interface %s not implemented\n", debugstr_guid(riid));
265 return E_NOINTERFACE;
267 IWbemClassObject_AddRef( iface );
268 return S_OK;
271 static HRESULT WINAPI class_object_GetQualifierSet(
272 IWbemClassObject *iface,
273 IWbemQualifierSet **ppQualSet )
275 FIXME("%p, %p\n", iface, ppQualSet);
276 return E_NOTIMPL;
279 static HRESULT WINAPI class_object_Get(
280 IWbemClassObject *iface,
281 LPCWSTR wszName,
282 LONG lFlags,
283 VARIANT *pVal,
284 CIMTYPE *pType,
285 LONG *plFlavor )
287 struct class_object *co = impl_from_IWbemClassObject( iface );
288 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
289 struct view *view = ec->query->view;
291 TRACE("%p, %s, %08x, %p, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, pType, plFlavor);
293 return get_propval( view, co->index, wszName, pVal, pType, plFlavor );
296 static HRESULT WINAPI class_object_Put(
297 IWbemClassObject *iface,
298 LPCWSTR wszName,
299 LONG lFlags,
300 VARIANT *pVal,
301 CIMTYPE Type )
303 FIXME("%p, %s, %08x, %p, %u\n", iface, debugstr_w(wszName), lFlags, pVal, Type);
304 return E_NOTIMPL;
307 static HRESULT WINAPI class_object_Delete(
308 IWbemClassObject *iface,
309 LPCWSTR wszName )
311 FIXME("%p, %s\n", iface, debugstr_w(wszName));
312 return E_NOTIMPL;
315 static HRESULT WINAPI class_object_GetNames(
316 IWbemClassObject *iface,
317 LPCWSTR wszQualifierName,
318 LONG lFlags,
319 VARIANT *pQualifierVal,
320 SAFEARRAY **pNames )
322 struct class_object *co = impl_from_IWbemClassObject( iface );
323 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
325 TRACE("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszQualifierName), lFlags, pQualifierVal, pNames);
327 if (wszQualifierName || pQualifierVal)
329 FIXME("qualifier not supported\n");
330 return E_NOTIMPL;
332 if (lFlags != WBEM_FLAG_ALWAYS)
334 FIXME("flags %08x not supported\n", lFlags);
335 return E_NOTIMPL;
337 return get_properties( ec->query->view, pNames );
340 static HRESULT WINAPI class_object_BeginEnumeration(
341 IWbemClassObject *iface,
342 LONG lEnumFlags )
344 FIXME("%p, %08x\n", iface, lEnumFlags);
345 return E_NOTIMPL;
348 static HRESULT WINAPI class_object_Next(
349 IWbemClassObject *iface,
350 LONG lFlags,
351 BSTR *strName,
352 VARIANT *pVal,
353 CIMTYPE *pType,
354 LONG *plFlavor )
356 FIXME("%p, %08x, %p, %p, %p, %p\n", iface, lFlags, strName, pVal, pType, plFlavor);
357 return E_NOTIMPL;
360 static HRESULT WINAPI class_object_EndEnumeration(
361 IWbemClassObject *iface )
363 FIXME("%p\n", iface);
364 return E_NOTIMPL;
367 static HRESULT WINAPI class_object_GetPropertyQualifierSet(
368 IWbemClassObject *iface,
369 LPCWSTR wszProperty,
370 IWbemQualifierSet **ppQualSet )
372 FIXME("%p, %s, %p\n", iface, debugstr_w(wszProperty), ppQualSet);
373 return E_NOTIMPL;
376 static HRESULT WINAPI class_object_Clone(
377 IWbemClassObject *iface,
378 IWbemClassObject **ppCopy )
380 FIXME("%p, %p\n", iface, ppCopy);
381 return E_NOTIMPL;
384 static HRESULT WINAPI class_object_GetObjectText(
385 IWbemClassObject *iface,
386 LONG lFlags,
387 BSTR *pstrObjectText )
389 FIXME("%p, %08x, %p\n", iface, lFlags, pstrObjectText);
390 return E_NOTIMPL;
393 static HRESULT WINAPI class_object_SpawnDerivedClass(
394 IWbemClassObject *iface,
395 LONG lFlags,
396 IWbemClassObject **ppNewClass )
398 FIXME("%p, %08x, %p\n", iface, lFlags, ppNewClass);
399 return E_NOTIMPL;
402 static HRESULT WINAPI class_object_SpawnInstance(
403 IWbemClassObject *iface,
404 LONG lFlags,
405 IWbemClassObject **ppNewInstance )
407 FIXME("%p, %08x, %p\n", iface, lFlags, ppNewInstance);
408 return E_NOTIMPL;
411 static HRESULT WINAPI class_object_CompareTo(
412 IWbemClassObject *iface,
413 LONG lFlags,
414 IWbemClassObject *pCompareTo )
416 FIXME("%p, %08x, %p\n", iface, lFlags, pCompareTo);
417 return E_NOTIMPL;
420 static HRESULT WINAPI class_object_GetPropertyOrigin(
421 IWbemClassObject *iface,
422 LPCWSTR wszName,
423 BSTR *pstrClassName )
425 FIXME("%p, %s, %p\n", iface, debugstr_w(wszName), pstrClassName);
426 return E_NOTIMPL;
429 static HRESULT WINAPI class_object_InheritsFrom(
430 IWbemClassObject *iface,
431 LPCWSTR strAncestor )
433 FIXME("%p, %s\n", iface, debugstr_w(strAncestor));
434 return E_NOTIMPL;
437 static HRESULT WINAPI class_object_GetMethod(
438 IWbemClassObject *iface,
439 LPCWSTR wszName,
440 LONG lFlags,
441 IWbemClassObject **ppInSignature,
442 IWbemClassObject **ppOutSignature )
444 FIXME("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, ppInSignature, ppOutSignature);
445 return E_NOTIMPL;
448 static HRESULT WINAPI class_object_PutMethod(
449 IWbemClassObject *iface,
450 LPCWSTR wszName,
451 LONG lFlags,
452 IWbemClassObject *pInSignature,
453 IWbemClassObject *pOutSignature )
455 FIXME("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, pInSignature, pOutSignature);
456 return E_NOTIMPL;
459 static HRESULT WINAPI class_object_DeleteMethod(
460 IWbemClassObject *iface,
461 LPCWSTR wszName )
463 FIXME("%p, %s\n", iface, debugstr_w(wszName));
464 return E_NOTIMPL;
467 static HRESULT WINAPI class_object_BeginMethodEnumeration(
468 IWbemClassObject *iface,
469 LONG lEnumFlags)
471 FIXME("%p, %08x\n", iface, lEnumFlags);
472 return E_NOTIMPL;
475 static HRESULT WINAPI class_object_NextMethod(
476 IWbemClassObject *iface,
477 LONG lFlags,
478 BSTR *pstrName,
479 IWbemClassObject **ppInSignature,
480 IWbemClassObject **ppOutSignature)
482 FIXME("%p, %08x, %p, %p, %p\n", iface, lFlags, pstrName, ppInSignature, ppOutSignature);
483 return E_NOTIMPL;
486 static HRESULT WINAPI class_object_EndMethodEnumeration(
487 IWbemClassObject *iface )
489 FIXME("%p\n", iface);
490 return E_NOTIMPL;
493 static HRESULT WINAPI class_object_GetMethodQualifierSet(
494 IWbemClassObject *iface,
495 LPCWSTR wszMethod,
496 IWbemQualifierSet **ppQualSet)
498 FIXME("%p, %s, %p\n", iface, debugstr_w(wszMethod), ppQualSet);
499 return E_NOTIMPL;
502 static HRESULT WINAPI class_object_GetMethodOrigin(
503 IWbemClassObject *iface,
504 LPCWSTR wszMethodName,
505 BSTR *pstrClassName)
507 FIXME("%p, %s, %p\n", iface, debugstr_w(wszMethodName), pstrClassName);
508 return E_NOTIMPL;
511 static const IWbemClassObjectVtbl class_object_vtbl =
513 class_object_QueryInterface,
514 class_object_AddRef,
515 class_object_Release,
516 class_object_GetQualifierSet,
517 class_object_Get,
518 class_object_Put,
519 class_object_Delete,
520 class_object_GetNames,
521 class_object_BeginEnumeration,
522 class_object_Next,
523 class_object_EndEnumeration,
524 class_object_GetPropertyQualifierSet,
525 class_object_Clone,
526 class_object_GetObjectText,
527 class_object_SpawnDerivedClass,
528 class_object_SpawnInstance,
529 class_object_CompareTo,
530 class_object_GetPropertyOrigin,
531 class_object_InheritsFrom,
532 class_object_GetMethod,
533 class_object_PutMethod,
534 class_object_DeleteMethod,
535 class_object_BeginMethodEnumeration,
536 class_object_NextMethod,
537 class_object_EndMethodEnumeration,
538 class_object_GetMethodQualifierSet,
539 class_object_GetMethodOrigin
542 HRESULT WbemClassObject_create(
543 IUnknown *pUnkOuter, IEnumWbemClassObject *iter, UINT index, LPVOID *ppObj )
545 struct class_object *co;
547 TRACE("%p, %p\n", pUnkOuter, ppObj);
549 co = heap_alloc( sizeof(*co) );
550 if (!co) return E_OUTOFMEMORY;
552 co->IWbemClassObject_iface.lpVtbl = &class_object_vtbl;
553 co->refs = 1;
554 co->iter = iter;
555 co->index = index;
556 if (iter) IEnumWbemClassObject_AddRef( iter );
558 *ppObj = &co->IWbemClassObject_iface;
560 TRACE("returning iface %p\n", *ppObj);
561 return S_OK;