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 (!view->count) return WBEM_S_FALSE;
172 if (nCount > view->count - ec->index)
174 ec->index = view->count - 1;
178 return WBEM_S_NO_ERROR;
181 static const IEnumWbemClassObjectVtbl enum_class_object_vtbl =
183 enum_class_object_QueryInterface,
184 enum_class_object_AddRef,
185 enum_class_object_Release,
186 enum_class_object_Reset,
187 enum_class_object_Next,
188 enum_class_object_NextAsync,
189 enum_class_object_Clone,
190 enum_class_object_Skip
193 HRESULT EnumWbemClassObject_create(
194 IUnknown *pUnkOuter, struct query *query, LPVOID *ppObj )
196 struct enum_class_object *ec;
198 TRACE("%p, %p\n", pUnkOuter, ppObj);
200 ec = heap_alloc( sizeof(*ec) );
201 if (!ec) return E_OUTOFMEMORY;
203 ec->IEnumWbemClassObject_iface.lpVtbl = &enum_class_object_vtbl;
206 addref_query( query );
209 *ppObj = &ec->IEnumWbemClassObject_iface;
211 TRACE("returning iface %p\n", *ppObj);
217 IWbemClassObject IWbemClassObject_iface;
219 IEnumWbemClassObject *iter;
223 static inline struct class_object *impl_from_IWbemClassObject(
224 IWbemClassObject *iface )
226 return CONTAINING_RECORD(iface, struct class_object, IWbemClassObject_iface);
229 static ULONG WINAPI class_object_AddRef(
230 IWbemClassObject *iface )
232 struct class_object *co = impl_from_IWbemClassObject( iface );
233 return InterlockedIncrement( &co->refs );
236 static ULONG WINAPI class_object_Release(
237 IWbemClassObject *iface )
239 struct class_object *co = impl_from_IWbemClassObject( iface );
240 LONG refs = InterlockedDecrement( &co->refs );
243 TRACE("destroying %p\n", co);
244 if (co->iter) IEnumWbemClassObject_Release( co->iter );
250 static HRESULT WINAPI class_object_QueryInterface(
251 IWbemClassObject *iface,
255 struct class_object *co = impl_from_IWbemClassObject( iface );
257 TRACE("%p, %s, %p\n", co, debugstr_guid( riid ), ppvObject );
259 if ( IsEqualGUID( riid, &IID_IWbemClassObject ) ||
260 IsEqualGUID( riid, &IID_IUnknown ) )
266 FIXME("interface %s not implemented\n", debugstr_guid(riid));
267 return E_NOINTERFACE;
269 IWbemClassObject_AddRef( iface );
273 static HRESULT WINAPI class_object_GetQualifierSet(
274 IWbemClassObject *iface,
275 IWbemQualifierSet **ppQualSet )
277 FIXME("%p, %p\n", iface, ppQualSet);
281 static HRESULT WINAPI class_object_Get(
282 IWbemClassObject *iface,
289 struct class_object *co = impl_from_IWbemClassObject( iface );
290 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
291 struct view *view = ec->query->view;
293 TRACE("%p, %s, %08x, %p, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, pType, plFlavor);
295 return get_propval( view, co->index, wszName, pVal, pType, plFlavor );
298 static HRESULT WINAPI class_object_Put(
299 IWbemClassObject *iface,
305 struct class_object *co = impl_from_IWbemClassObject( iface );
306 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
307 struct view *view = ec->query->view;
309 TRACE("%p, %s, %08x, %p, %u\n", iface, debugstr_w(wszName), lFlags, pVal, Type);
311 return put_propval( view, co->index, wszName, pVal, Type );
314 static HRESULT WINAPI class_object_Delete(
315 IWbemClassObject *iface,
318 FIXME("%p, %s\n", iface, debugstr_w(wszName));
322 static HRESULT WINAPI class_object_GetNames(
323 IWbemClassObject *iface,
324 LPCWSTR wszQualifierName,
326 VARIANT *pQualifierVal,
329 struct class_object *co = impl_from_IWbemClassObject( iface );
330 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
332 TRACE("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszQualifierName), lFlags, pQualifierVal, pNames);
334 if (wszQualifierName || pQualifierVal)
336 FIXME("qualifier not supported\n");
339 if (lFlags != WBEM_FLAG_ALWAYS)
341 FIXME("flags %08x not supported\n", lFlags);
344 return get_properties( ec->query->view, pNames );
347 static HRESULT WINAPI class_object_BeginEnumeration(
348 IWbemClassObject *iface,
351 FIXME("%p, %08x\n", iface, lEnumFlags);
355 static HRESULT WINAPI class_object_Next(
356 IWbemClassObject *iface,
363 FIXME("%p, %08x, %p, %p, %p, %p\n", iface, lFlags, strName, pVal, pType, plFlavor);
367 static HRESULT WINAPI class_object_EndEnumeration(
368 IWbemClassObject *iface )
370 FIXME("%p\n", iface);
374 static HRESULT WINAPI class_object_GetPropertyQualifierSet(
375 IWbemClassObject *iface,
377 IWbemQualifierSet **ppQualSet )
379 FIXME("%p, %s, %p\n", iface, debugstr_w(wszProperty), ppQualSet);
383 static HRESULT WINAPI class_object_Clone(
384 IWbemClassObject *iface,
385 IWbemClassObject **ppCopy )
387 FIXME("%p, %p\n", iface, ppCopy);
391 static HRESULT WINAPI class_object_GetObjectText(
392 IWbemClassObject *iface,
394 BSTR *pstrObjectText )
396 FIXME("%p, %08x, %p\n", iface, lFlags, pstrObjectText);
400 static HRESULT WINAPI class_object_SpawnDerivedClass(
401 IWbemClassObject *iface,
403 IWbemClassObject **ppNewClass )
405 FIXME("%p, %08x, %p\n", iface, lFlags, ppNewClass);
409 static HRESULT WINAPI class_object_SpawnInstance(
410 IWbemClassObject *iface,
412 IWbemClassObject **ppNewInstance )
414 FIXME("%p, %08x, %p\n", iface, lFlags, ppNewInstance);
418 static HRESULT WINAPI class_object_CompareTo(
419 IWbemClassObject *iface,
421 IWbemClassObject *pCompareTo )
423 FIXME("%p, %08x, %p\n", iface, lFlags, pCompareTo);
427 static HRESULT WINAPI class_object_GetPropertyOrigin(
428 IWbemClassObject *iface,
430 BSTR *pstrClassName )
432 FIXME("%p, %s, %p\n", iface, debugstr_w(wszName), pstrClassName);
436 static HRESULT WINAPI class_object_InheritsFrom(
437 IWbemClassObject *iface,
438 LPCWSTR strAncestor )
440 FIXME("%p, %s\n", iface, debugstr_w(strAncestor));
444 static HRESULT WINAPI class_object_GetMethod(
445 IWbemClassObject *iface,
448 IWbemClassObject **ppInSignature,
449 IWbemClassObject **ppOutSignature )
451 FIXME("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, ppInSignature, ppOutSignature);
455 static HRESULT WINAPI class_object_PutMethod(
456 IWbemClassObject *iface,
459 IWbemClassObject *pInSignature,
460 IWbemClassObject *pOutSignature )
462 FIXME("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, pInSignature, pOutSignature);
466 static HRESULT WINAPI class_object_DeleteMethod(
467 IWbemClassObject *iface,
470 FIXME("%p, %s\n", iface, debugstr_w(wszName));
474 static HRESULT WINAPI class_object_BeginMethodEnumeration(
475 IWbemClassObject *iface,
478 FIXME("%p, %08x\n", iface, lEnumFlags);
482 static HRESULT WINAPI class_object_NextMethod(
483 IWbemClassObject *iface,
486 IWbemClassObject **ppInSignature,
487 IWbemClassObject **ppOutSignature)
489 FIXME("%p, %08x, %p, %p, %p\n", iface, lFlags, pstrName, ppInSignature, ppOutSignature);
493 static HRESULT WINAPI class_object_EndMethodEnumeration(
494 IWbemClassObject *iface )
496 FIXME("%p\n", iface);
500 static HRESULT WINAPI class_object_GetMethodQualifierSet(
501 IWbemClassObject *iface,
503 IWbemQualifierSet **ppQualSet)
505 FIXME("%p, %s, %p\n", iface, debugstr_w(wszMethod), ppQualSet);
509 static HRESULT WINAPI class_object_GetMethodOrigin(
510 IWbemClassObject *iface,
511 LPCWSTR wszMethodName,
514 FIXME("%p, %s, %p\n", iface, debugstr_w(wszMethodName), pstrClassName);
518 static const IWbemClassObjectVtbl class_object_vtbl =
520 class_object_QueryInterface,
522 class_object_Release,
523 class_object_GetQualifierSet,
527 class_object_GetNames,
528 class_object_BeginEnumeration,
530 class_object_EndEnumeration,
531 class_object_GetPropertyQualifierSet,
533 class_object_GetObjectText,
534 class_object_SpawnDerivedClass,
535 class_object_SpawnInstance,
536 class_object_CompareTo,
537 class_object_GetPropertyOrigin,
538 class_object_InheritsFrom,
539 class_object_GetMethod,
540 class_object_PutMethod,
541 class_object_DeleteMethod,
542 class_object_BeginMethodEnumeration,
543 class_object_NextMethod,
544 class_object_EndMethodEnumeration,
545 class_object_GetMethodQualifierSet,
546 class_object_GetMethodOrigin
549 HRESULT WbemClassObject_create(
550 IUnknown *pUnkOuter, IEnumWbemClassObject *iter, UINT index, LPVOID *ppObj )
552 struct class_object *co;
554 TRACE("%p, %p\n", pUnkOuter, ppObj);
556 co = heap_alloc( sizeof(*co) );
557 if (!co) return E_OUTOFMEMORY;
559 co->IWbemClassObject_iface.lpVtbl = &class_object_vtbl;
563 if (iter) IEnumWbemClassObject_AddRef( iter );
565 *ppObj = &co->IWbemClassObject_iface;
567 TRACE("returning iface %p\n", *ppObj);