Synchronize with trunk r58606.
[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 WIN32_NO_STATUS
22 #define _INC_WINDOWS
23
24 #define COBJMACROS
25
26 #include <config.h>
27 #include <stdarg.h>
28
29 #include <windef.h>
30 #include <winbase.h>
31 //#include "winuser.h"
32 #include <ole2.h>
33 #include <wuapi.h>
34
35 #include <wine/debug.h>
36
37 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
38
39 typedef struct _update_searcher
40 {
41 IUpdateSearcher IUpdateSearcher_iface;
42 LONG refs;
43 } update_searcher;
44
45 static inline update_searcher *impl_from_IUpdateSearcher( IUpdateSearcher *iface )
46 {
47 return CONTAINING_RECORD(iface, update_searcher, IUpdateSearcher_iface);
48 }
49
50 static ULONG WINAPI update_searcher_AddRef(
51 IUpdateSearcher *iface )
52 {
53 update_searcher *update_searcher = impl_from_IUpdateSearcher( iface );
54 return InterlockedIncrement( &update_searcher->refs );
55 }
56
57 static ULONG WINAPI update_searcher_Release(
58 IUpdateSearcher *iface )
59 {
60 update_searcher *update_searcher = impl_from_IUpdateSearcher( iface );
61 LONG refs = InterlockedDecrement( &update_searcher->refs );
62 if (!refs)
63 {
64 TRACE("destroying %p\n", update_searcher);
65 HeapFree( GetProcessHeap(), 0, update_searcher );
66 }
67 return refs;
68 }
69
70 static HRESULT WINAPI update_searcher_QueryInterface(
71 IUpdateSearcher *iface,
72 REFIID riid,
73 void **ppvObject )
74 {
75 update_searcher *This = impl_from_IUpdateSearcher( iface );
76
77 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
78
79 if ( IsEqualGUID( riid, &IID_IUpdateSearcher ) ||
80 IsEqualGUID( riid, &IID_IDispatch ) ||
81 IsEqualGUID( riid, &IID_IUnknown ) )
82 {
83 *ppvObject = iface;
84 }
85 else
86 {
87 FIXME("interface %s not implemented\n", debugstr_guid(riid));
88 return E_NOINTERFACE;
89 }
90 IUpdateSearcher_AddRef( iface );
91 return S_OK;
92 }
93
94 static HRESULT WINAPI update_searcher_GetTypeInfoCount(
95 IUpdateSearcher *iface,
96 UINT *pctinfo )
97 {
98 FIXME("\n");
99 return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI update_searcher_GetTypeInfo(
103 IUpdateSearcher *iface,
104 UINT iTInfo,
105 LCID lcid,
106 ITypeInfo **ppTInfo )
107 {
108 FIXME("\n");
109 return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI update_searcher_GetIDsOfNames(
113 IUpdateSearcher *iface,
114 REFIID riid,
115 LPOLESTR *rgszNames,
116 UINT cNames,
117 LCID lcid,
118 DISPID *rgDispId )
119 {
120 FIXME("\n");
121 return E_NOTIMPL;
122 }
123
124 static HRESULT WINAPI update_searcher_Invoke(
125 IUpdateSearcher *iface,
126 DISPID dispIdMember,
127 REFIID riid,
128 LCID lcid,
129 WORD wFlags,
130 DISPPARAMS *pDispParams,
131 VARIANT *pVarResult,
132 EXCEPINFO *pExcepInfo,
133 UINT *puArgErr )
134 {
135 FIXME("\n");
136 return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI update_searcher_get_CanAutomaticallyUpgradeService(
140 IUpdateSearcher *This,
141 VARIANT_BOOL *retval )
142 {
143 FIXME("\n");
144 return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI update_searcher_put_CanAutomaticallyUpgradeService(
148 IUpdateSearcher *This,
149 VARIANT_BOOL value )
150 {
151 FIXME("%p, %d\n", This, value);
152 return S_OK;
153 }
154
155 static HRESULT WINAPI update_searcher_get_ClientApplicationID(
156 IUpdateSearcher *This,
157 BSTR *retval )
158 {
159 FIXME("\n");
160 return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI update_searcher_put_ClientApplicationID(
164 IUpdateSearcher *This,
165 BSTR value )
166 {
167 FIXME("%p, %s\n", This, debugstr_w(value));
168 return E_NOTIMPL;
169 }
170
171 static HRESULT WINAPI update_searcher_get_IncludePotentiallySupersededUpdates(
172 IUpdateSearcher *This,
173 VARIANT_BOOL *retval )
174 {
175 FIXME("\n");
176 return E_NOTIMPL;
177 }
178
179 static HRESULT WINAPI update_searcher_put_IncludePotentiallySupersededUpdates(
180 IUpdateSearcher *This,
181 VARIANT_BOOL value )
182 {
183 FIXME("\n");
184 return E_NOTIMPL;
185 }
186
187 static HRESULT WINAPI update_searcher_get_ServerSelection(
188 IUpdateSearcher *This,
189 ServerSelection *retval )
190 {
191 FIXME("\n");
192 return E_NOTIMPL;
193 }
194
195 static HRESULT WINAPI update_searcher_put_ServerSelection(
196 IUpdateSearcher *This,
197 ServerSelection value )
198 {
199 FIXME("\n");
200 return E_NOTIMPL;
201 }
202
203 static HRESULT WINAPI update_searcher_BeginSearch(
204 IUpdateSearcher *This,
205 BSTR criteria,
206 IUnknown *onCompleted,
207 VARIANT state,
208 ISearchJob **retval )
209 {
210 FIXME("\n");
211 return E_NOTIMPL;
212 }
213
214 static HRESULT WINAPI update_searcher_EndSearch(
215 IUpdateSearcher *This,
216 ISearchJob *searchJob,
217 ISearchResult **retval )
218 {
219 FIXME("\n");
220 return E_NOTIMPL;
221 }
222
223 static HRESULT WINAPI update_searcher_EscapeString(
224 IUpdateSearcher *This,
225 BSTR unescaped,
226 BSTR *retval )
227 {
228 FIXME("\n");
229 return E_NOTIMPL;
230 }
231
232 static HRESULT WINAPI update_searcher_QueryHistory(
233 IUpdateSearcher *This,
234 LONG startIndex,
235 LONG count,
236 IUpdateHistoryEntryCollection **retval )
237 {
238 FIXME("\n");
239 return E_NOTIMPL;
240 }
241
242 static HRESULT WINAPI update_searcher_Search(
243 IUpdateSearcher *This,
244 BSTR criteria,
245 ISearchResult **retval )
246 {
247 FIXME("\n");
248 return E_NOTIMPL;
249 }
250
251 static HRESULT WINAPI update_searcher_get_Online(
252 IUpdateSearcher *This,
253 VARIANT_BOOL *retval )
254 {
255 FIXME("\n");
256 return E_NOTIMPL;
257 }
258
259 static HRESULT WINAPI update_searcher_put_Online(
260 IUpdateSearcher *This,
261 VARIANT_BOOL value )
262 {
263 FIXME("\n");
264 return E_NOTIMPL;
265 }
266
267 static HRESULT WINAPI update_searcher_GetTotalHistoryCount(
268 IUpdateSearcher *This,
269 LONG *retval )
270 {
271 FIXME("\n");
272 return E_NOTIMPL;
273 }
274
275 static HRESULT WINAPI update_searcher_get_ServiceID(
276 IUpdateSearcher *This,
277 BSTR *retval )
278 {
279 FIXME("\n");
280 return E_NOTIMPL;
281 }
282
283 static HRESULT WINAPI update_searcher_put_ServiceID(
284 IUpdateSearcher *This,
285 BSTR value )
286 {
287 FIXME("\n");
288 return E_NOTIMPL;
289 }
290
291 static const struct IUpdateSearcherVtbl update_searcher_vtbl =
292 {
293 update_searcher_QueryInterface,
294 update_searcher_AddRef,
295 update_searcher_Release,
296 update_searcher_GetTypeInfoCount,
297 update_searcher_GetTypeInfo,
298 update_searcher_GetIDsOfNames,
299 update_searcher_Invoke,
300 update_searcher_get_CanAutomaticallyUpgradeService,
301 update_searcher_put_CanAutomaticallyUpgradeService,
302 update_searcher_get_ClientApplicationID,
303 update_searcher_put_ClientApplicationID,
304 update_searcher_get_IncludePotentiallySupersededUpdates,
305 update_searcher_put_IncludePotentiallySupersededUpdates,
306 update_searcher_get_ServerSelection,
307 update_searcher_put_ServerSelection,
308 update_searcher_BeginSearch,
309 update_searcher_EndSearch,
310 update_searcher_EscapeString,
311 update_searcher_QueryHistory,
312 update_searcher_Search,
313 update_searcher_get_Online,
314 update_searcher_put_Online,
315 update_searcher_GetTotalHistoryCount,
316 update_searcher_get_ServiceID,
317 update_searcher_put_ServiceID
318 };
319
320 HRESULT UpdateSearcher_create( IUnknown *pUnkOuter, LPVOID *ppObj )
321 {
322 update_searcher *searcher;
323
324 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
325
326 searcher = HeapAlloc( GetProcessHeap(), 0, sizeof(*searcher) );
327 if (!searcher) return E_OUTOFMEMORY;
328
329 searcher->IUpdateSearcher_iface.lpVtbl = &update_searcher_vtbl;
330 searcher->refs = 1;
331
332 *ppObj = &searcher->IUpdateSearcher_iface;
333
334 TRACE("returning iface %p\n", *ppObj);
335 return S_OK;
336 }