Create the AHCI branch for Aman's work
[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 #include "wuapi_private.h"
22
23 typedef struct _update_downloader
24 {
25 IUpdateDownloader IUpdateDownloader_iface;
26 LONG refs;
27 } update_downloader;
28
29 static inline update_downloader *impl_from_IUpdateDownloader( IUpdateDownloader *iface )
30 {
31 return CONTAINING_RECORD(iface, update_downloader, IUpdateDownloader_iface);
32 }
33
34 static ULONG WINAPI update_downloader_AddRef(
35 IUpdateDownloader *iface )
36 {
37 update_downloader *update_downloader = impl_from_IUpdateDownloader( iface );
38 return InterlockedIncrement( &update_downloader->refs );
39 }
40
41 static ULONG WINAPI update_downloader_Release(
42 IUpdateDownloader *iface )
43 {
44 update_downloader *update_downloader = impl_from_IUpdateDownloader( iface );
45 LONG refs = InterlockedDecrement( &update_downloader->refs );
46 if (!refs)
47 {
48 TRACE("destroying %p\n", update_downloader);
49 HeapFree( GetProcessHeap(), 0, update_downloader );
50 }
51 return refs;
52 }
53
54 static HRESULT WINAPI update_downloader_QueryInterface(
55 IUpdateDownloader *iface,
56 REFIID riid,
57 void **ppvObject )
58 {
59 update_downloader *This = impl_from_IUpdateDownloader( iface );
60
61 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
62
63 if ( IsEqualGUID( riid, &IID_IUpdateDownloader ) ||
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 IUpdateDownloader_AddRef( iface );
75 return S_OK;
76 }
77
78 static HRESULT WINAPI update_downloader_GetTypeInfoCount(
79 IUpdateDownloader *iface,
80 UINT *pctinfo )
81 {
82 FIXME("\n");
83 return E_NOTIMPL;
84 }
85
86 static HRESULT WINAPI update_downloader_GetTypeInfo(
87 IUpdateDownloader *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_downloader_GetIDsOfNames(
97 IUpdateDownloader *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_downloader_Invoke(
109 IUpdateDownloader *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_downloader_get_IsForced(
124 IUpdateDownloader *This,
125 VARIANT_BOOL *retval )
126 {
127 FIXME("\n");
128 return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI update_downloader_put_IsForced(
132 IUpdateDownloader *This,
133 VARIANT_BOOL value )
134 {
135 FIXME("%p, %d\n", This, value);
136 return S_OK;
137 }
138
139 static HRESULT WINAPI update_downloader_get_ClientApplicationID(
140 IUpdateDownloader *This,
141 BSTR *retval )
142 {
143 FIXME("\n");
144 return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI update_downloader_put_ClientApplicationID(
148 IUpdateDownloader *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_downloader_get_Priority(
156 IUpdateDownloader *This,
157 DownloadPriority *retval )
158 {
159 FIXME("\n");
160 return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI update_downloader_put_Priority(
164 IUpdateDownloader *This,
165 DownloadPriority value )
166 {
167 FIXME("\n");
168 return E_NOTIMPL;
169 }
170
171 static HRESULT WINAPI update_downloader_get_Updates(
172 IUpdateDownloader *This,
173 IUpdateCollection **retval )
174 {
175 FIXME("\n");
176 return E_NOTIMPL;
177 }
178
179 static HRESULT WINAPI update_downloader_put_Updates(
180 IUpdateDownloader *This,
181 IUpdateCollection *value )
182 {
183 FIXME("\n");
184 return E_NOTIMPL;
185 }
186
187 static HRESULT WINAPI update_downloader_BeginDownload(
188 IUpdateDownloader *This,
189 IUnknown *onProgressChanged,
190 IUnknown *onCompleted,
191 VARIANT state,
192 IDownloadJob **retval )
193 {
194 FIXME("\n");
195 return E_NOTIMPL;
196 }
197
198 static HRESULT WINAPI update_downloader_Download(
199 IUpdateDownloader *This,
200 IDownloadResult **retval )
201 {
202 FIXME("\n");
203 return E_NOTIMPL;
204 }
205
206 static HRESULT WINAPI update_downloader_EndDownload(
207 IUpdateDownloader *This,
208 IDownloadJob *value,
209 IDownloadResult **retval )
210 {
211 FIXME("\n");
212 return E_NOTIMPL;
213 }
214
215 static const struct IUpdateDownloaderVtbl update_downloader_vtbl =
216 {
217 update_downloader_QueryInterface,
218 update_downloader_AddRef,
219 update_downloader_Release,
220 update_downloader_GetTypeInfoCount,
221 update_downloader_GetTypeInfo,
222 update_downloader_GetIDsOfNames,
223 update_downloader_Invoke,
224 update_downloader_get_ClientApplicationID,
225 update_downloader_put_ClientApplicationID,
226 update_downloader_get_IsForced,
227 update_downloader_put_IsForced,
228 update_downloader_get_Priority,
229 update_downloader_put_Priority,
230 update_downloader_get_Updates,
231 update_downloader_put_Updates,
232 update_downloader_BeginDownload,
233 update_downloader_Download,
234 update_downloader_EndDownload
235 };
236
237 HRESULT UpdateDownloader_create( LPVOID *ppObj )
238 {
239 update_downloader *downloader;
240
241 TRACE("(%p)\n", ppObj);
242
243 downloader = HeapAlloc( GetProcessHeap(), 0, sizeof(*downloader) );
244 if (!downloader) return E_OUTOFMEMORY;
245
246 downloader->IUpdateDownloader_iface.lpVtbl = &update_downloader_vtbl;
247 downloader->refs = 1;
248
249 *ppObj = &downloader->IUpdateDownloader_iface;
250
251 TRACE("returning iface %p\n", *ppObj);
252 return S_OK;
253 }