Synchronize with trunk revision 59636 (just before Alex's CreateProcess revamp).
[reactos.git] / dll / win32 / wuapi / downloader.c
1 /*
2 * IUpdateDownloader 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 "initguid.h"
34 #include <wuapi.h>
35
36 #include <wine/debug.h>
37
38 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
39
40 typedef struct _update_downloader
41 {
42 IUpdateDownloader IUpdateDownloader_iface;
43 LONG refs;
44 } update_downloader;
45
46 static inline update_downloader *impl_from_IUpdateDownloader( IUpdateDownloader *iface )
47 {
48 return CONTAINING_RECORD(iface, update_downloader, IUpdateDownloader_iface);
49 }
50
51 static ULONG WINAPI update_downloader_AddRef(
52 IUpdateDownloader *iface )
53 {
54 update_downloader *update_downloader = impl_from_IUpdateDownloader( iface );
55 return InterlockedIncrement( &update_downloader->refs );
56 }
57
58 static ULONG WINAPI update_downloader_Release(
59 IUpdateDownloader *iface )
60 {
61 update_downloader *update_downloader = impl_from_IUpdateDownloader( iface );
62 LONG refs = InterlockedDecrement( &update_downloader->refs );
63 if (!refs)
64 {
65 TRACE("destroying %p\n", update_downloader);
66 HeapFree( GetProcessHeap(), 0, update_downloader );
67 }
68 return refs;
69 }
70
71 static HRESULT WINAPI update_downloader_QueryInterface(
72 IUpdateDownloader *iface,
73 REFIID riid,
74 void **ppvObject )
75 {
76 update_downloader *This = impl_from_IUpdateDownloader( iface );
77
78 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
79
80 if ( IsEqualGUID( riid, &IID_IUpdateDownloader ) ||
81 IsEqualGUID( riid, &IID_IDispatch ) ||
82 IsEqualGUID( riid, &IID_IUnknown ) )
83 {
84 *ppvObject = iface;
85 }
86 else
87 {
88 FIXME("interface %s not implemented\n", debugstr_guid(riid));
89 return E_NOINTERFACE;
90 }
91 IUpdateDownloader_AddRef( iface );
92 return S_OK;
93 }
94
95 static HRESULT WINAPI update_downloader_GetTypeInfoCount(
96 IUpdateDownloader *iface,
97 UINT *pctinfo )
98 {
99 FIXME("\n");
100 return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI update_downloader_GetTypeInfo(
104 IUpdateDownloader *iface,
105 UINT iTInfo,
106 LCID lcid,
107 ITypeInfo **ppTInfo )
108 {
109 FIXME("\n");
110 return E_NOTIMPL;
111 }
112
113 static HRESULT WINAPI update_downloader_GetIDsOfNames(
114 IUpdateDownloader *iface,
115 REFIID riid,
116 LPOLESTR *rgszNames,
117 UINT cNames,
118 LCID lcid,
119 DISPID *rgDispId )
120 {
121 FIXME("\n");
122 return E_NOTIMPL;
123 }
124
125 static HRESULT WINAPI update_downloader_Invoke(
126 IUpdateDownloader *iface,
127 DISPID dispIdMember,
128 REFIID riid,
129 LCID lcid,
130 WORD wFlags,
131 DISPPARAMS *pDispParams,
132 VARIANT *pVarResult,
133 EXCEPINFO *pExcepInfo,
134 UINT *puArgErr )
135 {
136 FIXME("\n");
137 return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI update_downloader_get_IsForced(
141 IUpdateDownloader *This,
142 VARIANT_BOOL *retval )
143 {
144 FIXME("\n");
145 return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI update_downloader_put_IsForced(
149 IUpdateDownloader *This,
150 VARIANT_BOOL value )
151 {
152 FIXME("%p, %d\n", This, value);
153 return S_OK;
154 }
155
156 static HRESULT WINAPI update_downloader_get_ClientApplicationID(
157 IUpdateDownloader *This,
158 BSTR *retval )
159 {
160 FIXME("\n");
161 return E_NOTIMPL;
162 }
163
164 static HRESULT WINAPI update_downloader_put_ClientApplicationID(
165 IUpdateDownloader *This,
166 BSTR value )
167 {
168 FIXME("%p, %s\n", This, debugstr_w(value));
169 return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI update_downloader_get_Priority(
173 IUpdateDownloader *This,
174 DownloadPriority *retval )
175 {
176 FIXME("\n");
177 return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI update_downloader_put_Priority(
181 IUpdateDownloader *This,
182 DownloadPriority value )
183 {
184 FIXME("\n");
185 return E_NOTIMPL;
186 }
187
188 static HRESULT WINAPI update_downloader_get_Updates(
189 IUpdateDownloader *This,
190 IUpdateCollection **retval )
191 {
192 FIXME("\n");
193 return E_NOTIMPL;
194 }
195
196 static HRESULT WINAPI update_downloader_put_Updates(
197 IUpdateDownloader *This,
198 IUpdateCollection *value )
199 {
200 FIXME("\n");
201 return E_NOTIMPL;
202 }
203
204 static HRESULT WINAPI update_downloader_BeginDownload(
205 IUpdateDownloader *This,
206 IUnknown *onProgressChanged,
207 IUnknown *onCompleted,
208 VARIANT state,
209 IDownloadJob **retval )
210 {
211 FIXME("\n");
212 return E_NOTIMPL;
213 }
214
215 static HRESULT WINAPI update_downloader_Download(
216 IUpdateDownloader *This,
217 IDownloadResult **retval )
218 {
219 FIXME("\n");
220 return E_NOTIMPL;
221 }
222
223 static HRESULT WINAPI update_downloader_EndDownload(
224 IUpdateDownloader *This,
225 IDownloadJob *value,
226 IDownloadResult **retval )
227 {
228 FIXME("\n");
229 return E_NOTIMPL;
230 }
231
232 static const struct IUpdateDownloaderVtbl update_downloader_vtbl =
233 {
234 update_downloader_QueryInterface,
235 update_downloader_AddRef,
236 update_downloader_Release,
237 update_downloader_GetTypeInfoCount,
238 update_downloader_GetTypeInfo,
239 update_downloader_GetIDsOfNames,
240 update_downloader_Invoke,
241 update_downloader_get_ClientApplicationID,
242 update_downloader_put_ClientApplicationID,
243 update_downloader_get_IsForced,
244 update_downloader_put_IsForced,
245 update_downloader_get_Priority,
246 update_downloader_put_Priority,
247 update_downloader_get_Updates,
248 update_downloader_put_Updates,
249 update_downloader_BeginDownload,
250 update_downloader_Download,
251 update_downloader_EndDownload
252 };
253
254 HRESULT UpdateDownloader_create( IUnknown *pUnkOuter, LPVOID *ppObj )
255 {
256 update_downloader *downloader;
257
258 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
259
260 downloader = HeapAlloc( GetProcessHeap(), 0, sizeof(*downloader) );
261 if (!downloader) return E_OUTOFMEMORY;
262
263 downloader->IUpdateDownloader_iface.lpVtbl = &update_downloader_vtbl;
264 downloader->refs = 1;
265
266 *ppObj = &downloader->IUpdateDownloader_iface;
267
268 TRACE("returning iface %p\n", *ppObj);
269 return S_OK;
270 }