wined3d: Ignore set_priority calls on non-managed resources.
[wine.git] / dlls / wbemdisp / locator.c
blobe95b673c6af6b1f1dcd0afe3dcfaee19bac1db52
1 /*
2 * Copyright 2013 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 "wbemdisp.h"
29 #include "wine/debug.h"
30 #include "wine/unicode.h"
31 #include "wbemdisp_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp);
35 struct locator
37 ISWbemLocator ISWbemLocator_iface;
38 LONG refs;
41 static inline struct locator *impl_from_ISWbemLocator( ISWbemLocator *iface )
43 return CONTAINING_RECORD( iface, struct locator, ISWbemLocator_iface );
46 static ULONG WINAPI locator_AddRef(
47 ISWbemLocator *iface )
49 struct locator *locator = impl_from_ISWbemLocator( iface );
50 return InterlockedIncrement( &locator->refs );
53 static ULONG WINAPI locator_Release(
54 ISWbemLocator *iface )
56 struct locator *locator = impl_from_ISWbemLocator( iface );
57 LONG refs = InterlockedDecrement( &locator->refs );
58 if (!refs)
60 TRACE( "destroying %p\n", locator );
61 heap_free( locator );
63 return refs;
66 static HRESULT WINAPI locator_QueryInterface(
67 ISWbemLocator *iface,
68 REFIID riid,
69 void **ppvObject )
71 struct locator *locator = impl_from_ISWbemLocator( iface );
73 TRACE( "%p, %s, %p\n", locator, debugstr_guid( riid ), ppvObject );
75 if (IsEqualGUID( riid, &IID_ISWbemLocator ) ||
76 IsEqualGUID( riid, &IID_IDispatch ) ||
77 IsEqualGUID( riid, &IID_IUnknown ))
79 *ppvObject = iface;
81 else
83 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
84 return E_NOINTERFACE;
86 ISWbemLocator_AddRef( iface );
87 return S_OK;
90 static HRESULT WINAPI locator_GetTypeInfoCount(
91 ISWbemLocator *iface,
92 UINT *count )
94 struct locator *locator = impl_from_ISWbemLocator( iface );
96 TRACE( "%p, %p\n", locator, count );
97 *count = 1;
98 return S_OK;
101 enum type_id
103 ISWbemLocator_tid,
104 last_tid
107 static ITypeLib *wbemdisp_typelib;
108 static ITypeInfo *wbemdisp_typeinfo[last_tid];
110 static REFIID wbemdisp_tid_id[] =
112 &IID_ISWbemLocator
115 static HRESULT get_typeinfo( enum type_id tid, ITypeInfo **ret )
117 HRESULT hr;
119 if (!wbemdisp_typelib)
121 ITypeLib *typelib;
123 hr = LoadRegTypeLib( &LIBID_WbemScripting, 1, 2, LOCALE_SYSTEM_DEFAULT, &typelib );
124 if (FAILED( hr ))
126 ERR( "LoadRegTypeLib failed: %08x\n", hr );
127 return hr;
129 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib, typelib, NULL ))
130 ITypeLib_Release( typelib );
132 if (!wbemdisp_typeinfo[tid])
134 ITypeInfo *typeinfo;
136 hr = ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib, wbemdisp_tid_id[tid], &typeinfo );
137 if (FAILED( hr ))
139 ERR( "GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(wbemdisp_tid_id[tid]), hr );
140 return hr;
142 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo + tid), typeinfo, NULL ))
143 ITypeInfo_Release( typeinfo );
145 *ret = wbemdisp_typeinfo[tid];
146 return S_OK;
149 static HRESULT WINAPI locator_GetTypeInfo(
150 ISWbemLocator *iface,
151 UINT index,
152 LCID lcid,
153 ITypeInfo **info )
155 struct locator *locator = impl_from_ISWbemLocator( iface );
156 TRACE( "%p, %u, %u, %p\n", locator, index, lcid, info );
158 return get_typeinfo( ISWbemLocator_tid, info );
161 static HRESULT WINAPI locator_GetIDsOfNames(
162 ISWbemLocator *iface,
163 REFIID riid,
164 LPOLESTR *names,
165 UINT count,
166 LCID lcid,
167 DISPID *dispid )
169 struct locator *locator = impl_from_ISWbemLocator( iface );
170 ITypeInfo *typeinfo;
171 HRESULT hr;
173 TRACE( "%p, %s, %p, %u, %u, %p\n", locator, debugstr_guid(riid), names, count, lcid, dispid );
175 if (!names || !count || !dispid) return E_INVALIDARG;
177 hr = get_typeinfo( ISWbemLocator_tid, &typeinfo );
178 if (SUCCEEDED(hr))
180 hr = ITypeInfo_GetIDsOfNames( typeinfo, names, count, dispid );
181 ITypeInfo_Release( typeinfo );
183 return hr;
186 static HRESULT WINAPI locator_Invoke(
187 ISWbemLocator *iface,
188 DISPID member,
189 REFIID riid,
190 LCID lcid,
191 WORD flags,
192 DISPPARAMS *params,
193 VARIANT *result,
194 EXCEPINFO *excep_info,
195 UINT *arg_err )
197 struct locator *locator = impl_from_ISWbemLocator( iface );
198 ITypeInfo *typeinfo;
199 HRESULT hr;
201 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", locator, member, debugstr_guid(riid),
202 lcid, flags, params, result, excep_info, arg_err );
204 hr = get_typeinfo( ISWbemLocator_tid, &typeinfo );
205 if (SUCCEEDED(hr))
207 hr = ITypeInfo_Invoke( typeinfo, &locator->ISWbemLocator_iface, member, flags,
208 params, result, excep_info, arg_err );
209 ITypeInfo_Release( typeinfo );
211 return hr;
214 static HRESULT WINAPI locator_ConnectServer(
215 ISWbemLocator *iface,
216 BSTR strServer,
217 BSTR strNamespace,
218 BSTR strUser,
219 BSTR strPassword,
220 BSTR strLocale,
221 BSTR strAuthority,
222 LONG iSecurityFlags,
223 IDispatch *objWbemNamedValueSet,
224 ISWbemServices **objWbemServices )
226 FIXME( "%p, %s, %s, %s, %p, %s, %s, 0x%08x, %p, %p\n", iface, debugstr_w(strServer),
227 debugstr_w(strNamespace), debugstr_w(strUser), strPassword, debugstr_w(strLocale),
228 debugstr_w(strAuthority), iSecurityFlags, objWbemNamedValueSet, objWbemServices );
229 return E_NOTIMPL;
232 static HRESULT WINAPI locator_get_Security_(
233 ISWbemLocator *iface,
234 ISWbemSecurity **objWbemSecurity )
236 FIXME( "%p, %p\n", iface, objWbemSecurity );
237 return E_NOTIMPL;
240 static const ISWbemLocatorVtbl locator_vtbl =
242 locator_QueryInterface,
243 locator_AddRef,
244 locator_Release,
245 locator_GetTypeInfoCount,
246 locator_GetTypeInfo,
247 locator_GetIDsOfNames,
248 locator_Invoke,
249 locator_ConnectServer,
250 locator_get_Security_
253 HRESULT SWbemLocator_create( void **obj )
255 struct locator *locator;
257 TRACE( "%p\n", obj );
259 if (!(locator = heap_alloc( sizeof(*locator) ))) return E_OUTOFMEMORY;
260 locator->ISWbemLocator_iface.lpVtbl = &locator_vtbl;
261 locator->refs = 1;
263 *obj = &locator->ISWbemLocator_iface;
264 TRACE( "returning iface %p\n", *obj );
265 return S_OK;