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
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
;
41 static inline struct enum_class_object
*impl_from_IEnumWbemClassObject(
42 IEnumWbemClassObject
*iface
)
44 return CONTAINING_RECORD(iface
, struct enum_class_object
, IEnumWbemClassObject_iface
);
47 static ULONG WINAPI
enum_class_object_AddRef(
48 IEnumWbemClassObject
*iface
)
50 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
51 return InterlockedIncrement( &ec
->refs
);
54 static ULONG WINAPI
enum_class_object_Release(
55 IEnumWbemClassObject
*iface
)
57 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
58 LONG refs
= InterlockedDecrement( &ec
->refs
);
61 TRACE("destroying %p\n", ec
);
62 free_query( ec
->query
);
68 static HRESULT WINAPI
enum_class_object_QueryInterface(
69 IEnumWbemClassObject
*iface
,
73 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
75 TRACE("%p, %s, %p\n", ec
, debugstr_guid( riid
), ppvObject
);
77 if ( IsEqualGUID( riid
, &IID_IEnumWbemClassObject
) ||
78 IsEqualGUID( riid
, &IID_IUnknown
) )
84 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
87 IEnumWbemClassObject_AddRef( iface
);
91 static HRESULT WINAPI
enum_class_object_Reset(
92 IEnumWbemClassObject
*iface
)
94 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
95 struct view
*view
= ec
->query
->view
;
100 return WBEM_S_NO_ERROR
;
103 static HRESULT WINAPI
enum_class_object_Next(
104 IEnumWbemClassObject
*iface
,
107 IWbemClassObject
**apObjects
,
110 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
111 struct view
*view
= ec
->query
->view
;
114 TRACE("%p, %d, %u, %p, %p\n", iface
, lTimeout
, uCount
, apObjects
, puReturned
);
116 if (!uCount
) return WBEM_S_FALSE
;
117 if (!apObjects
|| !puReturned
) return WBEM_E_INVALID_PARAMETER
;
118 if (lTimeout
!= WBEM_INFINITE
) FIXME("timeout not supported\n");
121 if (view
->index
+ uCount
> view
->count
) return WBEM_S_FALSE
;
123 hr
= WbemClassObject_create( NULL
, iface
, view
->index
, (void **)apObjects
);
124 if (hr
!= S_OK
) return hr
;
128 if (view
->index
== view
->count
) return WBEM_S_FALSE
;
129 if (uCount
> 1) return WBEM_S_TIMEDOUT
;
130 return WBEM_S_NO_ERROR
;
133 static HRESULT WINAPI
enum_class_object_NextAsync(
134 IEnumWbemClassObject
*iface
,
136 IWbemObjectSink
*pSink
)
138 FIXME("%p, %u, %p\n", iface
, uCount
, pSink
);
142 static HRESULT WINAPI
enum_class_object_Clone(
143 IEnumWbemClassObject
*iface
,
144 IEnumWbemClassObject
**ppEnum
)
146 FIXME("%p, %p\n", iface
, ppEnum
);
150 static HRESULT WINAPI
enum_class_object_Skip(
151 IEnumWbemClassObject
*iface
,
155 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
156 struct view
*view
= ec
->query
->view
;
158 TRACE("%p, %d, %u\n", iface
, lTimeout
, nCount
);
160 if (lTimeout
!= WBEM_INFINITE
) FIXME("timeout not supported\n");
162 if (view
->index
+ nCount
>= view
->count
)
164 view
->index
= view
->count
- 1;
167 view
->index
+= nCount
;
168 return WBEM_S_NO_ERROR
;
171 static const IEnumWbemClassObjectVtbl enum_class_object_vtbl
=
173 enum_class_object_QueryInterface
,
174 enum_class_object_AddRef
,
175 enum_class_object_Release
,
176 enum_class_object_Reset
,
177 enum_class_object_Next
,
178 enum_class_object_NextAsync
,
179 enum_class_object_Clone
,
180 enum_class_object_Skip
183 HRESULT
EnumWbemClassObject_create(
184 IUnknown
*pUnkOuter
, struct query
*query
, LPVOID
*ppObj
)
186 struct enum_class_object
*ec
;
188 TRACE("%p, %p\n", pUnkOuter
, ppObj
);
190 ec
= heap_alloc( sizeof(*ec
) );
191 if (!ec
) return E_OUTOFMEMORY
;
193 ec
->IEnumWbemClassObject_iface
.lpVtbl
= &enum_class_object_vtbl
;
197 *ppObj
= &ec
->IEnumWbemClassObject_iface
;
199 TRACE("returning iface %p\n", *ppObj
);
205 IWbemClassObject IWbemClassObject_iface
;
207 IEnumWbemClassObject
*iter
;
211 static inline struct class_object
*impl_from_IWbemClassObject(
212 IWbemClassObject
*iface
)
214 return CONTAINING_RECORD(iface
, struct class_object
, IWbemClassObject_iface
);
217 static ULONG WINAPI
class_object_AddRef(
218 IWbemClassObject
*iface
)
220 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
221 return InterlockedIncrement( &co
->refs
);
224 static ULONG WINAPI
class_object_Release(
225 IWbemClassObject
*iface
)
227 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
228 LONG refs
= InterlockedDecrement( &co
->refs
);
231 TRACE("destroying %p\n", co
);
232 if (co
->iter
) IEnumWbemClassObject_Release( co
->iter
);
238 static HRESULT WINAPI
class_object_QueryInterface(
239 IWbemClassObject
*iface
,
243 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
245 TRACE("%p, %s, %p\n", co
, debugstr_guid( riid
), ppvObject
);
247 if ( IsEqualGUID( riid
, &IID_IWbemClassObject
) ||
248 IsEqualGUID( riid
, &IID_IUnknown
) )
254 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
255 return E_NOINTERFACE
;
257 IWbemClassObject_AddRef( iface
);
261 static HRESULT WINAPI
class_object_GetQualifierSet(
262 IWbemClassObject
*iface
,
263 IWbemQualifierSet
**ppQualSet
)
265 FIXME("%p, %p\n", iface
, ppQualSet
);
269 static HRESULT WINAPI
class_object_Get(
270 IWbemClassObject
*iface
,
277 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
278 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
279 struct view
*view
= ec
->query
->view
;
281 TRACE("%p, %s, %08x, %p, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, pVal
, pType
, plFlavor
);
285 FIXME("flavor parameter not supported\n");
288 return get_propval( view
, co
->index
, wszName
, pVal
, pType
);
291 static HRESULT WINAPI
class_object_Put(
292 IWbemClassObject
*iface
,
298 FIXME("%p, %s, %08x, %p, %u\n", iface
, debugstr_w(wszName
), lFlags
, pVal
, Type
);
302 static HRESULT WINAPI
class_object_Delete(
303 IWbemClassObject
*iface
,
306 FIXME("%p, %s\n", iface
, debugstr_w(wszName
));
310 static HRESULT WINAPI
class_object_GetNames(
311 IWbemClassObject
*iface
,
312 LPCWSTR wszQualifierName
,
314 VARIANT
*pQualifierVal
,
317 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
318 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
320 TRACE("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszQualifierName
), lFlags
, pQualifierVal
, pNames
);
322 if (wszQualifierName
|| pQualifierVal
)
324 FIXME("qualifier not supported\n");
327 if (lFlags
!= WBEM_FLAG_ALWAYS
)
329 FIXME("flags %08x not supported\n", lFlags
);
332 return get_properties( ec
->query
->view
, pNames
);
335 static HRESULT WINAPI
class_object_BeginEnumeration(
336 IWbemClassObject
*iface
,
339 FIXME("%p, %08x\n", iface
, lEnumFlags
);
343 static HRESULT WINAPI
class_object_Next(
344 IWbemClassObject
*iface
,
351 FIXME("%p, %08x, %p, %p, %p, %p\n", iface
, lFlags
, strName
, pVal
, pType
, plFlavor
);
355 static HRESULT WINAPI
class_object_EndEnumeration(
356 IWbemClassObject
*iface
)
358 FIXME("%p\n", iface
);
362 static HRESULT WINAPI
class_object_GetPropertyQualifierSet(
363 IWbemClassObject
*iface
,
365 IWbemQualifierSet
**ppQualSet
)
367 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszProperty
), ppQualSet
);
371 static HRESULT WINAPI
class_object_Clone(
372 IWbemClassObject
*iface
,
373 IWbemClassObject
**ppCopy
)
375 FIXME("%p, %p\n", iface
, ppCopy
);
379 static HRESULT WINAPI
class_object_GetObjectText(
380 IWbemClassObject
*iface
,
382 BSTR
*pstrObjectText
)
384 FIXME("%p, %08x, %p\n", iface
, lFlags
, pstrObjectText
);
388 static HRESULT WINAPI
class_object_SpawnDerivedClass(
389 IWbemClassObject
*iface
,
391 IWbemClassObject
**ppNewClass
)
393 FIXME("%p, %08x, %p\n", iface
, lFlags
, ppNewClass
);
397 static HRESULT WINAPI
class_object_SpawnInstance(
398 IWbemClassObject
*iface
,
400 IWbemClassObject
**ppNewInstance
)
402 FIXME("%p, %08x, %p\n", iface
, lFlags
, ppNewInstance
);
406 static HRESULT WINAPI
class_object_CompareTo(
407 IWbemClassObject
*iface
,
409 IWbemClassObject
*pCompareTo
)
411 FIXME("%p, %08x, %p\n", iface
, lFlags
, pCompareTo
);
415 static HRESULT WINAPI
class_object_GetPropertyOrigin(
416 IWbemClassObject
*iface
,
418 BSTR
*pstrClassName
)
420 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszName
), pstrClassName
);
424 static HRESULT WINAPI
class_object_InheritsFrom(
425 IWbemClassObject
*iface
,
426 LPCWSTR strAncestor
)
428 FIXME("%p, %s\n", iface
, debugstr_w(strAncestor
));
432 static HRESULT WINAPI
class_object_GetMethod(
433 IWbemClassObject
*iface
,
436 IWbemClassObject
**ppInSignature
,
437 IWbemClassObject
**ppOutSignature
)
439 FIXME("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, ppInSignature
, ppOutSignature
);
443 static HRESULT WINAPI
class_object_PutMethod(
444 IWbemClassObject
*iface
,
447 IWbemClassObject
*pInSignature
,
448 IWbemClassObject
*pOutSignature
)
450 FIXME("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, pInSignature
, pOutSignature
);
454 static HRESULT WINAPI
class_object_DeleteMethod(
455 IWbemClassObject
*iface
,
458 FIXME("%p, %s\n", iface
, debugstr_w(wszName
));
462 static HRESULT WINAPI
class_object_BeginMethodEnumeration(
463 IWbemClassObject
*iface
,
466 FIXME("%p, %08x\n", iface
, lEnumFlags
);
470 static HRESULT WINAPI
class_object_NextMethod(
471 IWbemClassObject
*iface
,
474 IWbemClassObject
**ppInSignature
,
475 IWbemClassObject
**ppOutSignature
)
477 FIXME("%p, %08x, %p, %p, %p\n", iface
, lFlags
, pstrName
, ppInSignature
, ppOutSignature
);
481 static HRESULT WINAPI
class_object_EndMethodEnumeration(
482 IWbemClassObject
*iface
)
484 FIXME("%p\n", iface
);
488 static HRESULT WINAPI
class_object_GetMethodQualifierSet(
489 IWbemClassObject
*iface
,
491 IWbemQualifierSet
**ppQualSet
)
493 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszMethod
), ppQualSet
);
497 static HRESULT WINAPI
class_object_GetMethodOrigin(
498 IWbemClassObject
*iface
,
499 LPCWSTR wszMethodName
,
502 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszMethodName
), pstrClassName
);
506 static const IWbemClassObjectVtbl class_object_vtbl
=
508 class_object_QueryInterface
,
510 class_object_Release
,
511 class_object_GetQualifierSet
,
515 class_object_GetNames
,
516 class_object_BeginEnumeration
,
518 class_object_EndEnumeration
,
519 class_object_GetPropertyQualifierSet
,
521 class_object_GetObjectText
,
522 class_object_SpawnDerivedClass
,
523 class_object_SpawnInstance
,
524 class_object_CompareTo
,
525 class_object_GetPropertyOrigin
,
526 class_object_InheritsFrom
,
527 class_object_GetMethod
,
528 class_object_PutMethod
,
529 class_object_DeleteMethod
,
530 class_object_BeginMethodEnumeration
,
531 class_object_NextMethod
,
532 class_object_EndMethodEnumeration
,
533 class_object_GetMethodQualifierSet
,
534 class_object_GetMethodOrigin
537 HRESULT
WbemClassObject_create(
538 IUnknown
*pUnkOuter
, IEnumWbemClassObject
*iter
, UINT index
, LPVOID
*ppObj
)
540 struct class_object
*co
;
542 TRACE("%p, %p\n", pUnkOuter
, ppObj
);
544 co
= heap_alloc( sizeof(*co
) );
545 if (!co
) return E_OUTOFMEMORY
;
547 co
->IWbemClassObject_iface
.lpVtbl
= &class_object_vtbl
;
551 if (iter
) IEnumWbemClassObject_AddRef( iter
);
553 *ppObj
= &co
->IWbemClassObject_iface
;
555 TRACE("returning iface %p\n", *ppObj
);