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 #include "wbemdisp_private.h"
26 ISWbemLocator ISWbemLocator_iface
;
30 static inline struct locator
*impl_from_ISWbemLocator( ISWbemLocator
*iface
)
32 return CONTAINING_RECORD( iface
, struct locator
, ISWbemLocator_iface
);
35 static ULONG WINAPI
locator_AddRef(
36 ISWbemLocator
*iface
)
38 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
39 return InterlockedIncrement( &locator
->refs
);
42 static ULONG WINAPI
locator_Release(
43 ISWbemLocator
*iface
)
45 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
46 LONG refs
= InterlockedDecrement( &locator
->refs
);
49 TRACE( "destroying %p\n", locator
);
55 static HRESULT WINAPI
locator_QueryInterface(
60 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
62 TRACE( "%p, %s, %p\n", locator
, debugstr_guid( riid
), ppvObject
);
64 if (IsEqualGUID( riid
, &IID_ISWbemLocator
) ||
65 IsEqualGUID( riid
, &IID_IDispatch
) ||
66 IsEqualGUID( riid
, &IID_IUnknown
))
72 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
75 ISWbemLocator_AddRef( iface
);
79 static HRESULT WINAPI
locator_GetTypeInfoCount(
83 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
85 TRACE( "%p, %p\n", locator
, count
);
96 static ITypeLib
*wbemdisp_typelib
;
97 static ITypeInfo
*wbemdisp_typeinfo
[last_tid
];
99 static REFIID wbemdisp_tid_id
[] =
104 static HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
108 if (!wbemdisp_typelib
)
112 hr
= LoadRegTypeLib( &LIBID_WbemScripting
, 1, 2, LOCALE_SYSTEM_DEFAULT
, &typelib
);
115 ERR( "LoadRegTypeLib failed: %08x\n", hr
);
118 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib
, typelib
, NULL
))
119 ITypeLib_Release( typelib
);
121 if (!wbemdisp_typeinfo
[tid
])
125 hr
= ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib
, wbemdisp_tid_id
[tid
], &typeinfo
);
128 ERR( "GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(wbemdisp_tid_id
[tid
]), hr
);
131 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo
+ tid
), typeinfo
, NULL
))
132 ITypeInfo_Release( typeinfo
);
134 *ret
= wbemdisp_typeinfo
[tid
];
138 static HRESULT WINAPI
locator_GetTypeInfo(
139 ISWbemLocator
*iface
,
144 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
145 TRACE( "%p, %u, %u, %p\n", locator
, index
, lcid
, info
);
147 return get_typeinfo( ISWbemLocator_tid
, info
);
150 static HRESULT WINAPI
locator_GetIDsOfNames(
151 ISWbemLocator
*iface
,
158 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
162 TRACE( "%p, %s, %p, %u, %u, %p\n", locator
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
164 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
166 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
169 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
170 ITypeInfo_Release( typeinfo
);
175 static HRESULT WINAPI
locator_Invoke(
176 ISWbemLocator
*iface
,
183 EXCEPINFO
*excep_info
,
186 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
190 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", locator
, member
, debugstr_guid(riid
),
191 lcid
, flags
, params
, result
, excep_info
, arg_err
);
193 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
196 hr
= ITypeInfo_Invoke( typeinfo
, &locator
->ISWbemLocator_iface
, member
, flags
,
197 params
, result
, excep_info
, arg_err
);
198 ITypeInfo_Release( typeinfo
);
203 static HRESULT WINAPI
locator_ConnectServer(
204 ISWbemLocator
*iface
,
212 IDispatch
*objWbemNamedValueSet
,
213 ISWbemServices
**objWbemServices
)
215 FIXME( "%p, %s, %s, %s, %p, %s, %s, 0x%08x, %p, %p\n", iface
, debugstr_w(strServer
),
216 debugstr_w(strNamespace
), debugstr_w(strUser
), strPassword
, debugstr_w(strLocale
),
217 debugstr_w(strAuthority
), iSecurityFlags
, objWbemNamedValueSet
, objWbemServices
);
221 static HRESULT WINAPI
locator_get_Security_(
222 ISWbemLocator
*iface
,
223 ISWbemSecurity
**objWbemSecurity
)
225 FIXME( "%p, %p\n", iface
, objWbemSecurity
);
229 static const ISWbemLocatorVtbl locator_vtbl
=
231 locator_QueryInterface
,
234 locator_GetTypeInfoCount
,
236 locator_GetIDsOfNames
,
238 locator_ConnectServer
,
239 locator_get_Security_
242 HRESULT
SWbemLocator_create( void **obj
)
244 struct locator
*locator
;
246 TRACE( "%p\n", obj
);
248 if (!(locator
= heap_alloc( sizeof(*locator
) ))) return E_OUTOFMEMORY
;
249 locator
->ISWbemLocator_iface
.lpVtbl
= &locator_vtbl
;
252 *obj
= &locator
->ISWbemLocator_iface
;
253 TRACE( "returning iface %p\n", *obj
);