Sync with trunk r62754.
[reactos.git] / dll / win32 / wuapi / installer.c
1 /*
2 * IUpdateInstaller 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_installer
24 {
25 IUpdateInstaller IUpdateInstaller_iface;
26 LONG refs;
27 } update_installer;
28
29 static inline update_installer *impl_from_IUpdateInstaller( IUpdateInstaller *iface )
30 {
31 return CONTAINING_RECORD(iface, update_installer, IUpdateInstaller_iface);
32 }
33
34 static ULONG WINAPI update_installer_AddRef(
35 IUpdateInstaller *iface )
36 {
37 update_installer *update_installer = impl_from_IUpdateInstaller( iface );
38 return InterlockedIncrement( &update_installer->refs );
39 }
40
41 static ULONG WINAPI update_installer_Release(
42 IUpdateInstaller *iface )
43 {
44 update_installer *update_installer = impl_from_IUpdateInstaller( iface );
45 LONG refs = InterlockedDecrement( &update_installer->refs );
46 if (!refs)
47 {
48 TRACE("destroying %p\n", update_installer);
49 HeapFree( GetProcessHeap(), 0, update_installer );
50 }
51 return refs;
52 }
53
54 static HRESULT WINAPI update_installer_QueryInterface(
55 IUpdateInstaller *iface,
56 REFIID riid,
57 void **ppvObject )
58 {
59 update_installer *This = impl_from_IUpdateInstaller( iface );
60
61 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
62
63 if ( IsEqualGUID( riid, &IID_IUpdateInstaller ) ||
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 IUpdateInstaller_AddRef( iface );
75 return S_OK;
76 }
77
78 static HRESULT WINAPI update_installer_GetTypeInfoCount(
79 IUpdateInstaller *iface,
80 UINT *pctinfo )
81 {
82 FIXME("\n");
83 return E_NOTIMPL;
84 }
85
86 static HRESULT WINAPI update_installer_GetTypeInfo(
87 IUpdateInstaller *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_installer_GetIDsOfNames(
97 IUpdateInstaller *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_installer_Invoke(
109 IUpdateInstaller *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_installer_get_ClientApplicationID(
124 IUpdateInstaller *This,
125 BSTR *retval )
126 {
127 FIXME("\n");
128 return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI update_installer_put_ClientApplicationID(
132 IUpdateInstaller *This,
133 BSTR value )
134 {
135 FIXME("%p, %s\n", This, debugstr_w(value));
136 return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI update_installer_get_IsForced(
140 IUpdateInstaller *This,
141 VARIANT_BOOL *retval )
142 {
143 FIXME("\n");
144 return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI update_installer_put_IsForced(
148 IUpdateInstaller *This,
149 VARIANT_BOOL value )
150 {
151 FIXME("\n");
152 return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI update_installer_get_ParentHwnd(
156 IUpdateInstaller *This,
157 HWND *retval )
158 {
159 FIXME("\n");
160 return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI update_installer_put_ParentHwnd(
164 IUpdateInstaller *This,
165 HWND value )
166 {
167 FIXME("\n");
168 return E_NOTIMPL;
169 }
170
171 static HRESULT WINAPI update_installer_put_ParentWindow(
172 IUpdateInstaller *This,
173 IUnknown *value )
174 {
175 FIXME("\n");
176 return E_NOTIMPL;
177 }
178
179 static HRESULT WINAPI update_installer_get_ParentWindow(
180 IUpdateInstaller *This,
181 IUnknown **retval )
182 {
183 FIXME("\n");
184 return E_NOTIMPL;
185 }
186
187 static HRESULT WINAPI update_installer_get_Updates(
188 IUpdateInstaller *This,
189 IUpdateCollection **retval )
190 {
191 FIXME("\n");
192 return E_NOTIMPL;
193 }
194
195 static HRESULT WINAPI update_installer_put_Updates(
196 IUpdateInstaller *This,
197 IUpdateCollection *value )
198 {
199 FIXME("\n");
200 return E_NOTIMPL;
201 }
202
203 static HRESULT WINAPI update_installer_BeginInstall(
204 IUpdateInstaller *This,
205 IUnknown *onProgressChanged,
206 IUnknown *onCompleted,
207 VARIANT state,
208 IInstallationJob **retval )
209 {
210 FIXME("\n");
211 return E_NOTIMPL;
212 }
213
214 static HRESULT WINAPI update_installer_BeginUninstall(
215 IUpdateInstaller *This,
216 IUnknown *onProgressChanged,
217 IUnknown *onCompleted,
218 VARIANT state,
219 IInstallationJob **retval )
220 {
221 FIXME("\n");
222 return E_NOTIMPL;
223 }
224
225 static HRESULT WINAPI update_installer_EndInstall(
226 IUpdateInstaller *This,
227 IInstallationJob *value,
228 IInstallationResult **retval )
229 {
230 FIXME("\n");
231 return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI update_installer_EndUninstall(
235 IUpdateInstaller *This,
236 IInstallationJob *value,
237 IInstallationResult **retval )
238 {
239 FIXME("\n");
240 return E_NOTIMPL;
241 }
242
243 static HRESULT WINAPI update_installer_Install(
244 IUpdateInstaller *This,
245 IInstallationResult **retval )
246 {
247 FIXME("\n");
248 return E_NOTIMPL;
249 }
250
251 static HRESULT WINAPI update_installer_RunWizard(
252 IUpdateInstaller *This,
253 BSTR dialogTitle,
254 IInstallationResult **retval )
255 {
256 FIXME("\n");
257 return E_NOTIMPL;
258 }
259
260 static HRESULT WINAPI update_installer_get_IsBusy(
261 IUpdateInstaller *This,
262 VARIANT_BOOL *retval )
263 {
264 FIXME("\n");
265 return E_NOTIMPL;
266 }
267
268 static HRESULT WINAPI update_installer_Uninstall(
269 IUpdateInstaller *This,
270 IInstallationResult **retval )
271 {
272 FIXME("\n");
273 return E_NOTIMPL;
274 }
275
276 static HRESULT WINAPI update_installer_get_AllowSourcePrompts(
277 IUpdateInstaller *This,
278 VARIANT_BOOL *retval )
279 {
280 FIXME("\n");
281 return E_NOTIMPL;
282 }
283
284 static HRESULT WINAPI update_installer_put_AllowSourcePrompts(
285 IUpdateInstaller *This,
286 VARIANT_BOOL value )
287 {
288 FIXME("\n");
289 return E_NOTIMPL;
290 }
291
292 static HRESULT WINAPI update_installer_get_RebootRequiredBeforeInstallation(
293 IUpdateInstaller *This,
294 VARIANT_BOOL *retval )
295 {
296 FIXME("\n");
297 return E_NOTIMPL;
298 }
299
300 static const struct IUpdateInstallerVtbl update_installer_vtbl =
301 {
302 update_installer_QueryInterface,
303 update_installer_AddRef,
304 update_installer_Release,
305 update_installer_GetTypeInfoCount,
306 update_installer_GetTypeInfo,
307 update_installer_GetIDsOfNames,
308 update_installer_Invoke,
309 update_installer_get_ClientApplicationID,
310 update_installer_put_ClientApplicationID,
311 update_installer_get_IsForced,
312 update_installer_put_IsForced,
313 update_installer_get_ParentHwnd,
314 update_installer_put_ParentHwnd,
315 update_installer_put_ParentWindow,
316 update_installer_get_ParentWindow,
317 update_installer_get_Updates,
318 update_installer_put_Updates,
319 update_installer_BeginInstall,
320 update_installer_BeginUninstall,
321 update_installer_EndInstall,
322 update_installer_EndUninstall,
323 update_installer_Install,
324 update_installer_RunWizard,
325 update_installer_get_IsBusy,
326 update_installer_Uninstall,
327 update_installer_get_AllowSourcePrompts,
328 update_installer_put_AllowSourcePrompts,
329 update_installer_get_RebootRequiredBeforeInstallation
330 };
331
332 HRESULT UpdateInstaller_create( IUnknown *pUnkOuter, LPVOID *ppObj )
333 {
334 update_installer *installer;
335
336 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
337
338 installer = HeapAlloc( GetProcessHeap(), 0, sizeof(*installer) );
339 if (!installer) return E_OUTOFMEMORY;
340
341 installer->IUpdateInstaller_iface.lpVtbl = &update_installer_vtbl;
342 installer->refs = 1;
343
344 *ppObj = &installer->IUpdateInstaller_iface;
345
346 TRACE("returning iface %p\n", *ppObj);
347 return S_OK;
348 }