1ca8020a09df08fdc685dc8961e23b52157260b4
[reactos.git] / dll / win32 / wuapi / searcher.c
1 /*
2 * IUpdateSearcher implementation
3 *
4 * Copyright 2008 Hans Leidekker
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #define COBJMACROS
22
23 #include "config.h"
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "wuapi.h"
31 #include "wuapi_private.h"
32
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
36
37 typedef struct _update_searcher
38 {
39 IUpdateSearcher IUpdateSearcher_iface;
40 LONG refs;
41 } update_searcher;
42
43 static inline update_searcher *impl_from_IUpdateSearcher( IUpdateSearcher *iface )
44 {
45 return CONTAINING_RECORD(iface, update_searcher, IUpdateSearcher_iface);
46 }
47
48 static ULONG WINAPI update_searcher_AddRef(
49 IUpdateSearcher *iface )
50 {
51 update_searcher *update_searcher = impl_from_IUpdateSearcher( iface );
52 return InterlockedIncrement( &update_searcher->refs );
53 }
54
55 static ULONG WINAPI update_searcher_Release(
56 IUpdateSearcher *iface )
57 {
58 update_searcher *update_searcher = impl_from_IUpdateSearcher( iface );
59 LONG refs = InterlockedDecrement( &update_searcher->refs );
60 if (!refs)
61 {
62 TRACE("destroying %p\n", update_searcher);
63 HeapFree( GetProcessHeap(), 0, update_searcher );
64 }
65 return refs;
66 }
67
68 static HRESULT WINAPI update_searcher_QueryInterface(
69 IUpdateSearcher *iface,
70 REFIID riid,
71 void **ppvObject )
72 {
73 update_searcher *This = impl_from_IUpdateSearcher( iface );
74
75 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
76
77 if ( IsEqualGUID( riid, &IID_IUpdateSearcher ) ||
78 IsEqualGUID( riid, &IID_IDispatch ) ||
79 IsEqualGUID( riid, &IID_IUnknown ) )
80 {
81 *ppvObject = iface;
82 }
83 else
84 {
85 FIXME("interface %s not implemented\n", debugstr_guid(riid));
86 return E_NOINTERFACE;
87 }
88 IUpdateSearcher_AddRef( iface );
89 return S_OK;
90 }
91
92 static HRESULT WINAPI update_searcher_GetTypeInfoCount(
93 IUpdateSearcher *iface,
94 UINT *pctinfo )
95 {
96 FIXME("\n");
97 return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI update_searcher_GetTypeInfo(
101 IUpdateSearcher *iface,
102 UINT iTInfo,
103 LCID lcid,
104 ITypeInfo **ppTInfo )
105 {
106 FIXME("\n");
107 return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI update_searcher_GetIDsOfNames(
111 IUpdateSearcher *iface,
112 REFIID riid,
113 LPOLESTR *rgszNames,
114 UINT cNames,
115 LCID lcid,
116 DISPID *rgDispId )
117 {
118 FIXME("\n");
119 return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI update_searcher_Invoke(
123 IUpdateSearcher *iface,
124 DISPID dispIdMember,
125 REFIID riid,
126 LCID lcid,
127 WORD wFlags,
128 DISPPARAMS *pDispParams,
129 VARIANT *pVarResult,
130 EXCEPINFO *pExcepInfo,
131 UINT *puArgErr )
132 {
133 FIXME("\n");
134 return E_NOTIMPL;
135 }
136
137 static HRESULT WINAPI update_searcher_get_CanAutomaticallyUpgradeService(
138 IUpdateSearcher *This,
139 VARIANT_BOOL *retval )
140 {
141 FIXME("\n");
142 return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI update_searcher_put_CanAutomaticallyUpgradeService(
146 IUpdateSearcher *This,
147 VARIANT_BOOL value )
148 {
149 FIXME("%p, %d\n", This, value);
150 return S_OK;
151 }
152
153 static HRESULT WINAPI update_searcher_get_ClientApplicationID(
154 IUpdateSearcher *This,
155 BSTR *retval )
156 {
157 FIXME("\n");
158 return E_NOTIMPL;
159 }
160
161 static HRESULT WINAPI update_searcher_put_ClientApplicationID(
162 IUpdateSearcher *This,
163 BSTR value )
164 {
165 FIXME("%p, %s\n", This, debugstr_w(value));
166 return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI update_searcher_get_IncludePotentiallySupersededUpdates(
170 IUpdateSearcher *This,
171 VARIANT_BOOL *retval )
172 {
173 FIXME("\n");
174 return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI update_searcher_put_IncludePotentiallySupersededUpdates(
178 IUpdateSearcher *This,
179 VARIANT_BOOL value )
180 {
181 FIXME("\n");
182 return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI update_searcher_get_ServerSelection(
186 IUpdateSearcher *This,
187 ServerSelection *retval )
188 {
189 FIXME("\n");
190 return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI update_searcher_put_ServerSelection(
194 IUpdateSearcher *This,
195 ServerSelection value )
196 {
197 FIXME("\n");
198 return E_NOTIMPL;
199 }
200
201 static HRESULT WINAPI update_searcher_BeginSearch(
202 IUpdateSearcher *This,
203 BSTR criteria,
204 IUnknown *onCompleted,
205 VARIANT state,
206 ISearchJob **retval )
207 {
208 FIXME("\n");
209 return E_NOTIMPL;
210 }
211
212 static HRESULT WINAPI update_searcher_EndSearch(
213 IUpdateSearcher *This,
214 ISearchJob *searchJob,
215 ISearchResult **retval )
216 {
217 FIXME("\n");
218 return E_NOTIMPL;
219 }
220
221 static HRESULT WINAPI update_searcher_EscapeString(
222 IUpdateSearcher *This,
223 BSTR unescaped,
224 BSTR *retval )
225 {
226 FIXME("\n");
227 return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI update_searcher_QueryHistory(
231 IUpdateSearcher *This,
232 LONG startIndex,
233 LONG count,
234 IUpdateHistoryEntryCollection **retval )
235 {
236 FIXME("\n");
237 return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI update_searcher_Search(
241 IUpdateSearcher *This,
242 BSTR criteria,
243 ISearchResult **retval )
244 {
245 FIXME("\n");
246 return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI update_searcher_get_Online(
250 IUpdateSearcher *This,
251 VARIANT_BOOL *retval )
252 {
253 FIXME("\n");
254 return E_NOTIMPL;
255 }
256
257 static HRESULT WINAPI update_searcher_put_Online(
258 IUpdateSearcher *This,
259 VARIANT_BOOL value )
260 {
261 FIXME("\n");
262 return E_NOTIMPL;
263 }
264
265 static HRESULT WINAPI update_searcher_GetTotalHistoryCount(
266 IUpdateSearcher *This,
267 LONG *retval )
268 {
269 FIXME("\n");
270 return E_NOTIMPL;
271 }
272
273 static HRESULT WINAPI update_searcher_get_ServiceID(
274 IUpdateSearcher *This,
275 BSTR *retval )
276 {
277 FIXME("\n");
278 return E_NOTIMPL;
279 }
280
281 static HRESULT WINAPI update_searcher_put_ServiceID(
282 IUpdateSearcher *This,
283 BSTR value )
284 {
285 FIXME("\n");
286 return E_NOTIMPL;
287 }
288
289 static const struct IUpdateSearcherVtbl update_searcher_vtbl =
290 {
291 update_searcher_QueryInterface,
292 update_searcher_AddRef,
293 update_searcher_Release,
294 update_searcher_GetTypeInfoCount,
295 update_searcher_GetTypeInfo,
296 update_searcher_GetIDsOfNames,
297 update_searcher_Invoke,
298 update_searcher_get_CanAutomaticallyUpgradeService,
299 update_searcher_put_CanAutomaticallyUpgradeService,
300 update_searcher_get_ClientApplicationID,
301 update_searcher_put_ClientApplicationID,
302 update_searcher_get_IncludePotentiallySupersededUpdates,
303 update_searcher_put_IncludePotentiallySupersededUpdates,
304 update_searcher_get_ServerSelection,
305 update_searcher_put_ServerSelection,
306 update_searcher_BeginSearch,
307 update_searcher_EndSearch,
308 update_searcher_EscapeString,
309 update_searcher_QueryHistory,
310 update_searcher_Search,
311 update_searcher_get_Online,
312 update_searcher_put_Online,
313 update_searcher_GetTotalHistoryCount,
314 update_searcher_get_ServiceID,
315 update_searcher_put_ServiceID
316 };
317
318 HRESULT UpdateSearcher_create( LPVOID *ppObj )
319 {
320 update_searcher *searcher;
321
322 TRACE("(%p)\n", ppObj);
323
324 searcher = HeapAlloc( GetProcessHeap(), 0, sizeof(*searcher) );
325 if (!searcher) return E_OUTOFMEMORY;
326
327 searcher->IUpdateSearcher_iface.lpVtbl = &update_searcher_vtbl;
328 searcher->refs = 1;
329
330 *ppObj = &searcher->IUpdateSearcher_iface;
331
332 TRACE("returning iface %p\n", *ppObj);
333 return S_OK;
334 }