mstask: Implement GetTargetComputer.
[wine] / dlls / scrrun / dictionary.c
1 /*
2  * Copyright (C) 2012 Alistair Leslie-Hughes
3  *
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.
8  *
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.
13  *
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
17  */
18 #define COBJMACROS
19
20 #include "config.h"
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "ole2.h"
26 #include "dispex.h"
27 #include "scrrun.h"
28 #include "scrrun_private.h"
29
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
33
34 typedef struct
35 {
36     IDictionary IDictionary_iface;
37
38     LONG ref;
39 } dictionary;
40
41 static inline dictionary *impl_from_IDictionary(IDictionary *iface)
42 {
43     return CONTAINING_RECORD(iface, dictionary, IDictionary_iface);
44 }
45
46 static HRESULT WINAPI dictionary_QueryInterface(IDictionary *iface, REFIID riid, void **obj)
47 {
48     dictionary *This = impl_from_IDictionary(iface);
49     TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
50
51     *obj = NULL;
52
53     if(IsEqualIID(riid, &IID_IUnknown) ||
54        IsEqualIID(riid, &IID_IDispatch) ||
55        IsEqualIID(riid, &IID_IDictionary))
56     {
57         *obj = &This->IDictionary_iface;
58     }
59     else if ( IsEqualGUID( riid, &IID_IDispatchEx ))
60     {
61         TRACE("Interface IDispatchEx not supported - returning NULL\n");
62         *obj = NULL;
63         return E_NOINTERFACE;
64     }
65     else if ( IsEqualGUID( riid, &IID_IObjectWithSite ))
66     {
67         TRACE("Interface IObjectWithSite not supported - returning NULL\n");
68         *obj = NULL;
69         return E_NOINTERFACE;
70     }
71     else
72     {
73         WARN("interface %s not implemented\n", debugstr_guid(riid));
74         return E_NOINTERFACE;
75     }
76
77     IDictionary_AddRef(iface);
78     return S_OK;
79 }
80
81 static ULONG WINAPI dictionary_AddRef(IDictionary *iface)
82 {
83     dictionary *This = impl_from_IDictionary(iface);
84     TRACE("(%p)\n", This);
85
86     return InterlockedIncrement(&This->ref);
87 }
88
89 static ULONG WINAPI dictionary_Release(IDictionary *iface)
90 {
91     dictionary *This = impl_from_IDictionary(iface);
92     LONG ref;
93
94     TRACE("(%p)\n", This);
95
96     ref = InterlockedDecrement(&This->ref);
97     if(ref == 0)
98     {
99         HeapFree(GetProcessHeap(), 0, This);
100     }
101
102     return ref;
103 }
104
105 static HRESULT WINAPI dictionary_GetTypeInfoCount(IDictionary *iface, UINT *pctinfo)
106 {
107     dictionary *This = impl_from_IDictionary(iface);
108
109     TRACE("(%p)->()\n", This);
110
111     *pctinfo = 1;
112     return S_OK;
113 }
114
115 static HRESULT WINAPI dictionary_GetTypeInfo(IDictionary *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
116 {
117     dictionary *This = impl_from_IDictionary(iface);
118
119     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
120     return get_typeinfo(IDictionary_tid, ppTInfo);
121 }
122
123 static HRESULT WINAPI dictionary_GetIDsOfNames(IDictionary *iface, REFIID riid, LPOLESTR *rgszNames,
124                 UINT cNames, LCID lcid, DISPID *rgDispId)
125 {
126     dictionary *This = impl_from_IDictionary(iface);
127     ITypeInfo *typeinfo;
128     HRESULT hr;
129
130     TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
131
132     hr = get_typeinfo(IDictionary_tid, &typeinfo);
133     if(SUCCEEDED(hr))
134     {
135         hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
136         ITypeInfo_Release(typeinfo);
137     }
138
139     return hr;
140 }
141
142 static HRESULT WINAPI dictionary_Invoke(IDictionary *iface, DISPID dispIdMember, REFIID riid,
143                 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
144                 EXCEPINFO *pExcepInfo, UINT *puArgErr)
145 {
146     dictionary *This = impl_from_IDictionary(iface);
147     ITypeInfo *typeinfo;
148     HRESULT hr;
149
150     TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
151            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
152
153     hr = get_typeinfo(IDictionary_tid, &typeinfo);
154     if(SUCCEEDED(hr))
155     {
156         hr = ITypeInfo_Invoke(typeinfo, &This->IDictionary_iface, dispIdMember, wFlags,
157                 pDispParams, pVarResult, pExcepInfo, puArgErr);
158         ITypeInfo_Release(typeinfo);
159     }
160
161     return hr;
162 }
163
164 static HRESULT WINAPI dictionary_putref_Item(IDictionary *iface, VARIANT *Key, VARIANT *pRetItem)
165 {
166     dictionary *This = impl_from_IDictionary(iface);
167
168     FIXME("(%p)->(%p %p)\n", This, Key, pRetItem);
169
170     return E_NOTIMPL;
171 }
172
173 static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *Key, VARIANT *pRetItem)
174 {
175     dictionary *This = impl_from_IDictionary(iface);
176
177     FIXME("(%p)->(%p %p)\n", This, Key, pRetItem);
178
179     return E_NOTIMPL;
180 }
181
182 static HRESULT WINAPI dictionary_get_Item(IDictionary *iface, VARIANT *Key, VARIANT *pRetItem)
183 {
184     dictionary *This = impl_from_IDictionary(iface);
185
186     FIXME("(%p)->(%p %p)\n", This, Key, pRetItem );
187
188     return E_NOTIMPL;
189 }
190
191 static HRESULT WINAPI dictionary_Add(IDictionary *iface, VARIANT *Key, VARIANT *Item)
192 {
193     dictionary *This = impl_from_IDictionary(iface);
194
195     FIXME("(%p)->(%p %p)\n", This, Key, Item);
196
197     return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI dictionary_get_Count(IDictionary *iface, LONG *pCount)
201 {
202     dictionary *This = impl_from_IDictionary(iface);
203
204     FIXME("(%p)->(%p)\n", This, pCount);
205
206     *pCount = 0;
207
208     return S_OK;
209 }
210
211 static HRESULT WINAPI dictionary_Exists(IDictionary *iface, VARIANT *Key, VARIANT_BOOL *pExists)
212 {
213     dictionary *This = impl_from_IDictionary(iface);
214
215     FIXME("(%p)->(%p %p)\n", This, Key, pExists);
216
217     return E_NOTIMPL;
218 }
219
220 static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *pItemsArray)
221 {
222     dictionary *This = impl_from_IDictionary(iface);
223
224     FIXME("(%p)->(%p)\n", This, pItemsArray);
225
226     return E_NOTIMPL;
227 }
228
229 static HRESULT WINAPI dictionary_put_Key(IDictionary *iface, VARIANT *Key, VARIANT *rhs)
230 {
231     dictionary *This = impl_from_IDictionary(iface);
232
233     FIXME("(%p)->(%p %p)\n", This, Key, rhs);
234
235     return E_NOTIMPL;
236 }
237
238 static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *pKeysArray)
239 {
240     dictionary *This = impl_from_IDictionary(iface);
241
242     FIXME("(%p)->(%p)\n", This, pKeysArray);
243
244     return E_NOTIMPL;
245 }
246
247 static HRESULT WINAPI dictionary_Remove(IDictionary *iface, VARIANT *Key)
248 {
249     dictionary *This = impl_from_IDictionary(iface);
250
251     FIXME("(%p)->(%p)\n", This, Key);
252
253     return E_NOTIMPL;
254 }
255
256 static HRESULT WINAPI dictionary_RemoveAll(IDictionary *iface)
257 {
258     dictionary *This = impl_from_IDictionary(iface);
259
260     FIXME("(%p)->()\n", This);
261
262     return E_NOTIMPL;
263 }
264
265 static HRESULT WINAPI dictionary_put_CompareMode(IDictionary *iface, CompareMethod pcomp)
266 {
267     dictionary *This = impl_from_IDictionary(iface);
268
269     FIXME("(%p)->()\n", This);
270
271     return E_NOTIMPL;
272 }
273
274 static HRESULT WINAPI dictionary_get_CompareMode(IDictionary *iface, CompareMethod *pcomp)
275 {
276     dictionary *This = impl_from_IDictionary(iface);
277
278     FIXME("(%p)->(%p)\n", This, pcomp);
279
280     return E_NOTIMPL;
281 }
282
283 static HRESULT WINAPI dictionary__NewEnum(IDictionary *iface, IUnknown **ppunk)
284 {
285     dictionary *This = impl_from_IDictionary(iface);
286
287     FIXME("(%p)->(%p)\n", This, ppunk);
288
289     return E_NOTIMPL;
290 }
291
292 static HRESULT WINAPI dictionary_get_HashVal(IDictionary *iface, VARIANT *Key, VARIANT *HashVal)
293 {
294     dictionary *This = impl_from_IDictionary(iface);
295
296     FIXME("(%p)->(%p %p)\n", This, Key, HashVal);
297
298     return E_NOTIMPL;
299 }
300
301
302 static const struct IDictionaryVtbl dictionary_vtbl =
303 {
304     dictionary_QueryInterface,
305     dictionary_AddRef,
306     dictionary_Release,
307     dictionary_GetTypeInfoCount,
308     dictionary_GetTypeInfo,
309     dictionary_GetIDsOfNames,
310     dictionary_Invoke,
311     dictionary_putref_Item,
312     dictionary_put_Item,
313     dictionary_get_Item,
314     dictionary_Add,
315     dictionary_get_Count,
316     dictionary_Exists,
317     dictionary_Items,
318     dictionary_put_Key,
319     dictionary_Keys,
320     dictionary_Remove,
321     dictionary_RemoveAll,
322     dictionary_put_CompareMode,
323     dictionary_get_CompareMode,
324     dictionary__NewEnum,
325     dictionary_get_HashVal
326 };
327
328 HRESULT WINAPI Dictionary_CreateInstance(IClassFactory *factory,IUnknown *outer,REFIID riid, void **obj)
329 {
330     dictionary *This;
331
332     TRACE("(%p)\n", obj);
333
334     *obj = NULL;
335
336     This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
337     if(!This) return E_OUTOFMEMORY;
338
339     This->IDictionary_iface.lpVtbl = &dictionary_vtbl;
340     This->ref = 1;
341
342     *obj = &This->IDictionary_iface;
343
344     return S_OK;
345 }