xref: /reactos/dll/win32/wuapi/installer.c (revision 19b18ce2)
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 #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_installer
38 {
39     IUpdateInstaller IUpdateInstaller_iface;
40     LONG refs;
41 } update_installer;
42 
43 static inline update_installer *impl_from_IUpdateInstaller( IUpdateInstaller *iface )
44 {
45     return CONTAINING_RECORD(iface, update_installer, IUpdateInstaller_iface);
46 }
47 
48 static ULONG WINAPI update_installer_AddRef(
49     IUpdateInstaller *iface )
50 {
51     update_installer *update_installer = impl_from_IUpdateInstaller( iface );
52     return InterlockedIncrement( &update_installer->refs );
53 }
54 
55 static ULONG WINAPI update_installer_Release(
56     IUpdateInstaller *iface )
57 {
58     update_installer *update_installer = impl_from_IUpdateInstaller( iface );
59     LONG refs = InterlockedDecrement( &update_installer->refs );
60     if (!refs)
61     {
62         TRACE("destroying %p\n", update_installer);
63         HeapFree( GetProcessHeap(), 0, update_installer );
64     }
65     return refs;
66 }
67 
68 static HRESULT WINAPI update_installer_QueryInterface(
69     IUpdateInstaller *iface,
70     REFIID riid,
71     void **ppvObject )
72 {
73     update_installer *This = impl_from_IUpdateInstaller( iface );
74 
75     TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
76 
77     if ( IsEqualGUID( riid, &IID_IUpdateInstaller ) ||
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     IUpdateInstaller_AddRef( iface );
89     return S_OK;
90 }
91 
92 static HRESULT WINAPI update_installer_GetTypeInfoCount(
93     IUpdateInstaller *iface,
94     UINT *pctinfo )
95 {
96     FIXME("\n");
97     return E_NOTIMPL;
98 }
99 
100 static HRESULT WINAPI update_installer_GetTypeInfo(
101     IUpdateInstaller *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_installer_GetIDsOfNames(
111     IUpdateInstaller *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_installer_Invoke(
123     IUpdateInstaller *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_installer_get_ClientApplicationID(
138     IUpdateInstaller *This,
139     BSTR *retval )
140 {
141     FIXME("\n");
142     return E_NOTIMPL;
143 }
144 
145 static HRESULT WINAPI update_installer_put_ClientApplicationID(
146     IUpdateInstaller *This,
147     BSTR value )
148 {
149     FIXME("%p, %s\n", This, debugstr_w(value));
150     return E_NOTIMPL;
151 }
152 
153 static HRESULT WINAPI update_installer_get_IsForced(
154     IUpdateInstaller *This,
155     VARIANT_BOOL *retval )
156 {
157     FIXME("\n");
158     return E_NOTIMPL;
159 }
160 
161 static HRESULT WINAPI update_installer_put_IsForced(
162     IUpdateInstaller *This,
163     VARIANT_BOOL value )
164 {
165     FIXME("\n");
166     return E_NOTIMPL;
167 }
168 
169 static HRESULT WINAPI update_installer_get_ParentHwnd(
170     IUpdateInstaller *This,
171     HWND *retval )
172 {
173     FIXME("\n");
174     return E_NOTIMPL;
175 }
176 
177 static HRESULT WINAPI update_installer_put_ParentHwnd(
178     IUpdateInstaller *This,
179     HWND value )
180 {
181     FIXME("\n");
182     return E_NOTIMPL;
183 }
184 
185 static HRESULT WINAPI update_installer_put_ParentWindow(
186     IUpdateInstaller *This,
187     IUnknown *value )
188 {
189     FIXME("\n");
190     return E_NOTIMPL;
191 }
192 
193 static HRESULT WINAPI update_installer_get_ParentWindow(
194     IUpdateInstaller *This,
195     IUnknown **retval )
196 {
197     FIXME("\n");
198     return E_NOTIMPL;
199 }
200 
201 static HRESULT WINAPI update_installer_get_Updates(
202     IUpdateInstaller *This,
203     IUpdateCollection **retval )
204 {
205     FIXME("\n");
206     return E_NOTIMPL;
207 }
208 
209 static HRESULT WINAPI update_installer_put_Updates(
210     IUpdateInstaller *This,
211     IUpdateCollection *value )
212 {
213     FIXME("\n");
214     return E_NOTIMPL;
215 }
216 
217 static HRESULT WINAPI update_installer_BeginInstall(
218     IUpdateInstaller *This,
219     IUnknown *onProgressChanged,
220     IUnknown *onCompleted,
221     VARIANT state,
222     IInstallationJob **retval )
223 {
224     FIXME("\n");
225     return E_NOTIMPL;
226 }
227 
228 static HRESULT WINAPI update_installer_BeginUninstall(
229     IUpdateInstaller *This,
230     IUnknown *onProgressChanged,
231     IUnknown *onCompleted,
232     VARIANT state,
233     IInstallationJob **retval )
234 {
235     FIXME("\n");
236     return E_NOTIMPL;
237 }
238 
239 static HRESULT WINAPI update_installer_EndInstall(
240     IUpdateInstaller *This,
241     IInstallationJob *value,
242     IInstallationResult **retval )
243 {
244     FIXME("\n");
245     return E_NOTIMPL;
246 }
247 
248 static HRESULT WINAPI update_installer_EndUninstall(
249     IUpdateInstaller *This,
250     IInstallationJob *value,
251     IInstallationResult **retval )
252 {
253     FIXME("\n");
254     return E_NOTIMPL;
255 }
256 
257 static HRESULT WINAPI update_installer_Install(
258     IUpdateInstaller *This,
259     IInstallationResult **retval )
260 {
261     FIXME("\n");
262     return E_NOTIMPL;
263 }
264 
265 static HRESULT WINAPI update_installer_RunWizard(
266     IUpdateInstaller *This,
267     BSTR dialogTitle,
268     IInstallationResult **retval )
269 {
270     FIXME("\n");
271     return E_NOTIMPL;
272 }
273 
274 static HRESULT WINAPI update_installer_get_IsBusy(
275     IUpdateInstaller *This,
276     VARIANT_BOOL *retval )
277 {
278     FIXME("\n");
279     return E_NOTIMPL;
280 }
281 
282 static HRESULT WINAPI update_installer_Uninstall(
283     IUpdateInstaller *This,
284     IInstallationResult **retval )
285 {
286     FIXME("\n");
287     return E_NOTIMPL;
288 }
289 
290 static HRESULT WINAPI update_installer_get_AllowSourcePrompts(
291     IUpdateInstaller *This,
292     VARIANT_BOOL *retval )
293 {
294     FIXME("\n");
295     return E_NOTIMPL;
296 }
297 
298 static HRESULT WINAPI update_installer_put_AllowSourcePrompts(
299     IUpdateInstaller *This,
300     VARIANT_BOOL value )
301 {
302     FIXME("\n");
303     return E_NOTIMPL;
304 }
305 
306 static HRESULT WINAPI update_installer_get_RebootRequiredBeforeInstallation(
307     IUpdateInstaller *This,
308     VARIANT_BOOL *retval )
309 {
310     FIXME("\n");
311     return E_NOTIMPL;
312 }
313 
314 static const struct IUpdateInstallerVtbl update_installer_vtbl =
315 {
316     update_installer_QueryInterface,
317     update_installer_AddRef,
318     update_installer_Release,
319     update_installer_GetTypeInfoCount,
320     update_installer_GetTypeInfo,
321     update_installer_GetIDsOfNames,
322     update_installer_Invoke,
323     update_installer_get_ClientApplicationID,
324     update_installer_put_ClientApplicationID,
325     update_installer_get_IsForced,
326     update_installer_put_IsForced,
327     update_installer_get_ParentHwnd,
328     update_installer_put_ParentHwnd,
329     update_installer_put_ParentWindow,
330     update_installer_get_ParentWindow,
331     update_installer_get_Updates,
332     update_installer_put_Updates,
333     update_installer_BeginInstall,
334     update_installer_BeginUninstall,
335     update_installer_EndInstall,
336     update_installer_EndUninstall,
337     update_installer_Install,
338     update_installer_RunWizard,
339     update_installer_get_IsBusy,
340     update_installer_Uninstall,
341     update_installer_get_AllowSourcePrompts,
342     update_installer_put_AllowSourcePrompts,
343     update_installer_get_RebootRequiredBeforeInstallation
344 };
345 
346 HRESULT UpdateInstaller_create( LPVOID *ppObj )
347 {
348     update_installer *installer;
349 
350     TRACE("(%p)\n", ppObj);
351 
352     installer = HeapAlloc( GetProcessHeap(), 0, sizeof(*installer) );
353     if (!installer) return E_OUTOFMEMORY;
354 
355     installer->IUpdateInstaller_iface.lpVtbl = &update_installer_vtbl;
356     installer->refs = 1;
357 
358     *ppObj = &installer->IUpdateInstaller_iface;
359 
360     TRACE("returning iface %p\n", *ppObj);
361     return S_OK;
362 }
363