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
29 #include "wine/debug.h"
30 #include "wine/unicode.h"
31 #include "wbemdisp_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp
);
37 ISWbemLocator ISWbemLocator_iface
;
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
);
60 TRACE( "destroying %p\n", locator
);
66 static HRESULT WINAPI
locator_QueryInterface(
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
))
83 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
86 ISWbemLocator_AddRef( iface
);
90 static HRESULT WINAPI
locator_GetTypeInfoCount(
94 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
96 TRACE( "%p, %p\n", locator
, count
);
107 static ITypeLib
*wbemdisp_typelib
;
108 static ITypeInfo
*wbemdisp_typeinfo
[last_tid
];
110 static REFIID wbemdisp_tid_id
[] =
115 static HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
119 if (!wbemdisp_typelib
)
123 hr
= LoadRegTypeLib( &LIBID_WbemScripting
, 1, 2, LOCALE_SYSTEM_DEFAULT
, &typelib
);
126 ERR( "LoadRegTypeLib failed: %08x\n", hr
);
129 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib
, typelib
, NULL
))
130 ITypeLib_Release( typelib
);
132 if (!wbemdisp_typeinfo
[tid
])
136 hr
= ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib
, wbemdisp_tid_id
[tid
], &typeinfo
);
139 ERR( "GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(wbemdisp_tid_id
[tid
]), hr
);
142 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo
+ tid
), typeinfo
, NULL
))
143 ITypeInfo_Release( typeinfo
);
145 *ret
= wbemdisp_typeinfo
[tid
];
149 static HRESULT WINAPI
locator_GetTypeInfo(
150 ISWbemLocator
*iface
,
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
,
169 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
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
);
180 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
181 ITypeInfo_Release( typeinfo
);
186 static HRESULT WINAPI
locator_Invoke(
187 ISWbemLocator
*iface
,
194 EXCEPINFO
*excep_info
,
197 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
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
);
207 hr
= ITypeInfo_Invoke( typeinfo
, &locator
->ISWbemLocator_iface
, member
, flags
,
208 params
, result
, excep_info
, arg_err
);
209 ITypeInfo_Release( typeinfo
);
214 static HRESULT WINAPI
locator_ConnectServer(
215 ISWbemLocator
*iface
,
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
);
232 static HRESULT WINAPI
locator_get_Security_(
233 ISWbemLocator
*iface
,
234 ISWbemSecurity
**objWbemSecurity
)
236 FIXME( "%p, %p\n", iface
, objWbemSecurity
);
240 static const ISWbemLocatorVtbl locator_vtbl
=
242 locator_QueryInterface
,
245 locator_GetTypeInfoCount
,
247 locator_GetIDsOfNames
,
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
;
263 *obj
= &locator
->ISWbemLocator_iface
;
264 TRACE( "returning iface %p\n", *obj
);