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
;
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
);
62 TRACE("destroying %p\n", ec
);
63 release_query( ec
->query
);
69 static HRESULT WINAPI
enum_class_object_QueryInterface(
70 IEnumWbemClassObject
*iface
,
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
) )
83 else if ( IsEqualGUID( riid
, &IID_IClientSecurity
) )
85 *ppvObject
= &client_security
;
90 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
93 IEnumWbemClassObject_AddRef( iface
);
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
);
105 return WBEM_S_NO_ERROR
;
108 static HRESULT WINAPI
enum_class_object_Next(
109 IEnumWbemClassObject
*iface
,
112 IWbemClassObject
**apObjects
,
115 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
116 struct view
*view
= ec
->query
->view
;
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");
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
;
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
,
141 IWbemObjectSink
*pSink
)
143 FIXME("%p, %u, %p\n", iface
, uCount
, pSink
);
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
,
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;
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
;
204 addref_query( query
);
207 *ppObj
= &ec
->IEnumWbemClassObject_iface
;
209 TRACE("returning iface %p\n", *ppObj
);
215 IWbemClassObject IWbemClassObject_iface
;
217 IEnumWbemClassObject
*iter
;
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
);
241 TRACE("destroying %p\n", co
);
242 if (co
->iter
) IEnumWbemClassObject_Release( co
->iter
);
248 static HRESULT WINAPI
class_object_QueryInterface(
249 IWbemClassObject
*iface
,
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
) )
264 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
265 return E_NOINTERFACE
;
267 IWbemClassObject_AddRef( iface
);
271 static HRESULT WINAPI
class_object_GetQualifierSet(
272 IWbemClassObject
*iface
,
273 IWbemQualifierSet
**ppQualSet
)
275 FIXME("%p, %p\n", iface
, ppQualSet
);
279 static HRESULT WINAPI
class_object_Get(
280 IWbemClassObject
*iface
,
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
,
303 FIXME("%p, %s, %08x, %p, %u\n", iface
, debugstr_w(wszName
), lFlags
, pVal
, Type
);
307 static HRESULT WINAPI
class_object_Delete(
308 IWbemClassObject
*iface
,
311 FIXME("%p, %s\n", iface
, debugstr_w(wszName
));
315 static HRESULT WINAPI
class_object_GetNames(
316 IWbemClassObject
*iface
,
317 LPCWSTR wszQualifierName
,
319 VARIANT
*pQualifierVal
,
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");
332 if (lFlags
!= WBEM_FLAG_ALWAYS
)
334 FIXME("flags %08x not supported\n", lFlags
);
337 return get_properties( ec
->query
->view
, pNames
);
340 static HRESULT WINAPI
class_object_BeginEnumeration(
341 IWbemClassObject
*iface
,
344 FIXME("%p, %08x\n", iface
, lEnumFlags
);
348 static HRESULT WINAPI
class_object_Next(
349 IWbemClassObject
*iface
,
356 FIXME("%p, %08x, %p, %p, %p, %p\n", iface
, lFlags
, strName
, pVal
, pType
, plFlavor
);
360 static HRESULT WINAPI
class_object_EndEnumeration(
361 IWbemClassObject
*iface
)
363 FIXME("%p\n", iface
);
367 static HRESULT WINAPI
class_object_GetPropertyQualifierSet(
368 IWbemClassObject
*iface
,
370 IWbemQualifierSet
**ppQualSet
)
372 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszProperty
), ppQualSet
);
376 static HRESULT WINAPI
class_object_Clone(
377 IWbemClassObject
*iface
,
378 IWbemClassObject
**ppCopy
)
380 FIXME("%p, %p\n", iface
, ppCopy
);
384 static HRESULT WINAPI
class_object_GetObjectText(
385 IWbemClassObject
*iface
,
387 BSTR
*pstrObjectText
)
389 FIXME("%p, %08x, %p\n", iface
, lFlags
, pstrObjectText
);
393 static HRESULT WINAPI
class_object_SpawnDerivedClass(
394 IWbemClassObject
*iface
,
396 IWbemClassObject
**ppNewClass
)
398 FIXME("%p, %08x, %p\n", iface
, lFlags
, ppNewClass
);
402 static HRESULT WINAPI
class_object_SpawnInstance(
403 IWbemClassObject
*iface
,
405 IWbemClassObject
**ppNewInstance
)
407 FIXME("%p, %08x, %p\n", iface
, lFlags
, ppNewInstance
);
411 static HRESULT WINAPI
class_object_CompareTo(
412 IWbemClassObject
*iface
,
414 IWbemClassObject
*pCompareTo
)
416 FIXME("%p, %08x, %p\n", iface
, lFlags
, pCompareTo
);
420 static HRESULT WINAPI
class_object_GetPropertyOrigin(
421 IWbemClassObject
*iface
,
423 BSTR
*pstrClassName
)
425 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszName
), pstrClassName
);
429 static HRESULT WINAPI
class_object_InheritsFrom(
430 IWbemClassObject
*iface
,
431 LPCWSTR strAncestor
)
433 FIXME("%p, %s\n", iface
, debugstr_w(strAncestor
));
437 static HRESULT WINAPI
class_object_GetMethod(
438 IWbemClassObject
*iface
,
441 IWbemClassObject
**ppInSignature
,
442 IWbemClassObject
**ppOutSignature
)
444 FIXME("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, ppInSignature
, ppOutSignature
);
448 static HRESULT WINAPI
class_object_PutMethod(
449 IWbemClassObject
*iface
,
452 IWbemClassObject
*pInSignature
,
453 IWbemClassObject
*pOutSignature
)
455 FIXME("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, pInSignature
, pOutSignature
);
459 static HRESULT WINAPI
class_object_DeleteMethod(
460 IWbemClassObject
*iface
,
463 FIXME("%p, %s\n", iface
, debugstr_w(wszName
));
467 static HRESULT WINAPI
class_object_BeginMethodEnumeration(
468 IWbemClassObject
*iface
,
471 FIXME("%p, %08x\n", iface
, lEnumFlags
);
475 static HRESULT WINAPI
class_object_NextMethod(
476 IWbemClassObject
*iface
,
479 IWbemClassObject
**ppInSignature
,
480 IWbemClassObject
**ppOutSignature
)
482 FIXME("%p, %08x, %p, %p, %p\n", iface
, lFlags
, pstrName
, ppInSignature
, ppOutSignature
);
486 static HRESULT WINAPI
class_object_EndMethodEnumeration(
487 IWbemClassObject
*iface
)
489 FIXME("%p\n", iface
);
493 static HRESULT WINAPI
class_object_GetMethodQualifierSet(
494 IWbemClassObject
*iface
,
496 IWbemQualifierSet
**ppQualSet
)
498 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszMethod
), ppQualSet
);
502 static HRESULT WINAPI
class_object_GetMethodOrigin(
503 IWbemClassObject
*iface
,
504 LPCWSTR wszMethodName
,
507 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszMethodName
), pstrClassName
);
511 static const IWbemClassObjectVtbl class_object_vtbl
=
513 class_object_QueryInterface
,
515 class_object_Release
,
516 class_object_GetQualifierSet
,
520 class_object_GetNames
,
521 class_object_BeginEnumeration
,
523 class_object_EndEnumeration
,
524 class_object_GetPropertyQualifierSet
,
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
;
556 if (iter
) IEnumWbemClassObject_AddRef( iter
);
558 *ppObj
= &co
->IWbemClassObject_iface
;
560 TRACE("returning iface %p\n", *ppObj
);