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