Sync with trunk (r47116), hopefully without breaking anything.
[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 #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
32 #include "wine/debug.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
35
36 typedef struct _update_installer
37 {
38 const struct IUpdateInstallerVtbl *vtbl;
39 LONG refs;
40 } update_installer;
41
42 static inline update_installer *impl_from_IUpdateInstaller( IUpdateInstaller *iface )
43 {
44 return (update_installer *)((char *)iface - FIELD_OFFSET( update_installer, vtbl ));
45 }
46
47 static ULONG WINAPI update_installer_AddRef(
48 IUpdateInstaller *iface )
49 {
50 update_installer *update_installer = impl_from_IUpdateInstaller( iface );
51 return InterlockedIncrement( &update_installer->refs );
52 }
53
54 static ULONG WINAPI update_installer_Release(
55 IUpdateInstaller *iface )
56 {
57 update_installer *update_installer = impl_from_IUpdateInstaller( iface );
58 LONG refs = InterlockedDecrement( &update_installer->refs );
59 if (!refs)
60 {
61 TRACE("destroying %p\n", update_installer);
62 HeapFree( GetProcessHeap(), 0, update_installer );
63 }
64 return refs;
65 }
66
67 static HRESULT WINAPI update_installer_QueryInterface(
68 IUpdateInstaller *iface,
69 REFIID riid,
70 void **ppvObject )
71 {
72 update_installer *This = impl_from_IUpdateInstaller( iface );
73
74 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
75
76 if ( IsEqualGUID( riid, &IID_IUpdateInstaller ) ||
77 IsEqualGUID( riid, &IID_IDispatch ) ||
78 IsEqualGUID( riid, &IID_IUnknown ) )
79 {
80 *ppvObject = iface;
81 }
82 else
83 {
84 FIXME("interface %s not implemented\n", debugstr_guid(riid));
85 return E_NOINTERFACE;
86 }
87 IUpdateInstaller_AddRef( iface );
88 return S_OK;
89 }
90
91 static HRESULT WINAPI update_installer_GetTypeInfoCount(
92 IUpdateInstaller *iface,
93 UINT *pctinfo )
94 {
95 FIXME("\n");
96 return E_NOTIMPL;
97 }
98
99 static HRESULT WINAPI update_installer_GetTypeInfo(
100 IUpdateInstaller *iface,
101 UINT iTInfo,
102 LCID lcid,
103 ITypeInfo **ppTInfo )
104 {
105 FIXME("\n");
106 return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI update_installer_GetIDsOfNames(
110 IUpdateInstaller *iface,
111 REFIID riid,
112 LPOLESTR *rgszNames,
113 UINT cNames,
114 LCID lcid,
115 DISPID *rgDispId )
116 {
117 FIXME("\n");
118 return E_NOTIMPL;
119 }
120
121 static HRESULT WINAPI update_installer_Invoke(
122 IUpdateInstaller *iface,
123 DISPID dispIdMember,
124 REFIID riid,
125 LCID lcid,
126 WORD wFlags,
127 DISPPARAMS *pDispParams,
128 VARIANT *pVarResult,
129 EXCEPINFO *pExcepInfo,
130 UINT *puArgErr )
131 {
132 FIXME("\n");
133 return E_NOTIMPL;
134 }
135
136 static HRESULT WINAPI update_installer_get_ClientApplicationID(
137 IUpdateInstaller *This,
138 BSTR *retval )
139 {
140 FIXME("\n");
141 return E_NOTIMPL;
142 }
143
144 static HRESULT WINAPI update_installer_put_ClientApplicationID(
145 IUpdateInstaller *This,
146 BSTR value )
147 {
148 FIXME("%p, %s\n", This, debugstr_w(value));
149 return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI update_installer_get_IsForced(
153 IUpdateInstaller *This,
154 VARIANT_BOOL *retval )
155 {
156 FIXME("\n");
157 return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI update_installer_put_IsForced(
161 IUpdateInstaller *This,
162 VARIANT_BOOL value )
163 {
164 FIXME("\n");
165 return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI update_installer_get_ParentHwnd(
169 IUpdateInstaller *This,
170 HWND *retval )
171 {
172 FIXME("\n");
173 return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI update_installer_put_ParentHwnd(
177 IUpdateInstaller *This,
178 HWND value )
179 {
180 FIXME("\n");
181 return E_NOTIMPL;
182 }
183
184 static HRESULT WINAPI update_installer_put_ParentWindow(
185 IUpdateInstaller *This,
186 IUnknown *value )
187 {
188 FIXME("\n");
189 return E_NOTIMPL;
190 }
191
192 static HRESULT WINAPI update_installer_get_ParentWindow(
193 IUpdateInstaller *This,
194 IUnknown **retval )
195 {
196 FIXME("\n");
197 return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI update_installer_get_Updates(
201 IUpdateInstaller *This,
202 IUpdateCollection **retval )
203 {
204 FIXME("\n");
205 return E_NOTIMPL;
206 }
207
208 static HRESULT WINAPI update_installer_put_Updates(
209 IUpdateInstaller *This,
210 IUpdateCollection *value )
211 {
212 FIXME("\n");
213 return E_NOTIMPL;
214 }
215
216 static const struct IUpdateInstallerVtbl update_installer_vtbl =
217 {
218 update_installer_QueryInterface,
219 update_installer_AddRef,
220 update_installer_Release,
221 update_installer_GetTypeInfoCount,
222 update_installer_GetTypeInfo,
223 update_installer_GetIDsOfNames,
224 update_installer_Invoke,
225 update_installer_get_ClientApplicationID,
226 update_installer_put_ClientApplicationID,
227 update_installer_get_IsForced,
228 update_installer_put_IsForced,
229 update_installer_get_ParentHwnd,
230 update_installer_put_ParentHwnd,
231 update_installer_put_ParentWindow,
232 update_installer_get_ParentWindow,
233 update_installer_get_Updates,
234 update_installer_put_Updates,
235 };
236
237 HRESULT UpdateInstaller_create( IUnknown *pUnkOuter, LPVOID *ppObj )
238 {
239 update_installer *installer;
240
241 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
242
243 installer = HeapAlloc( GetProcessHeap(), 0, sizeof(*installer) );
244 if (!installer) return E_OUTOFMEMORY;
245
246 installer->vtbl = &update_installer_vtbl;
247 installer->refs = 1;
248
249 *ppObj = &installer->vtbl;
250
251 TRACE("returning iface %p\n", *ppObj);
252 return S_OK;
253 }