netstat: Initial implementation.
[wine] / dlls / 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 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 "initguid.h"
31 #include "wuapi.h"
32
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
36
37 typedef struct _update_downloader
38 {
39     IUpdateDownloader IUpdateDownloader_iface;
40     LONG refs;
41 } update_downloader;
42
43 static inline update_downloader *impl_from_IUpdateDownloader( IUpdateDownloader *iface )
44 {
45     return CONTAINING_RECORD(iface, update_downloader, IUpdateDownloader_iface);
46 }
47
48 static ULONG WINAPI update_downloader_AddRef(
49     IUpdateDownloader *iface )
50 {
51     update_downloader *update_downloader = impl_from_IUpdateDownloader( iface );
52     return InterlockedIncrement( &update_downloader->refs );
53 }
54
55 static ULONG WINAPI update_downloader_Release(
56     IUpdateDownloader *iface )
57 {
58     update_downloader *update_downloader = impl_from_IUpdateDownloader( iface );
59     LONG refs = InterlockedDecrement( &update_downloader->refs );
60     if (!refs)
61     {
62         TRACE("destroying %p\n", update_downloader);
63         HeapFree( GetProcessHeap(), 0, update_downloader );
64     }
65     return refs;
66 }
67
68 static HRESULT WINAPI update_downloader_QueryInterface(
69     IUpdateDownloader *iface,
70     REFIID riid,
71     void **ppvObject )
72 {
73     update_downloader *This = impl_from_IUpdateDownloader( iface );
74
75     TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
76
77     if ( IsEqualGUID( riid, &IID_IUpdateDownloader ) ||
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     IUpdateDownloader_AddRef( iface );
89     return S_OK;
90 }
91
92 static HRESULT WINAPI update_downloader_GetTypeInfoCount(
93     IUpdateDownloader *iface,
94     UINT *pctinfo )
95 {
96     FIXME("\n");
97     return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI update_downloader_GetTypeInfo(
101     IUpdateDownloader *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_downloader_GetIDsOfNames(
111     IUpdateDownloader *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_downloader_Invoke(
123     IUpdateDownloader *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_downloader_get_IsForced(
138     IUpdateDownloader *This,
139     VARIANT_BOOL *retval )
140 {
141     FIXME("\n");
142     return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI update_downloader_put_IsForced(
146     IUpdateDownloader *This,
147     VARIANT_BOOL value )
148 {
149     FIXME("%p, %d\n", This, value);
150     return S_OK;
151 }
152
153 static HRESULT WINAPI update_downloader_get_ClientApplicationID(
154     IUpdateDownloader *This,
155     BSTR *retval )
156 {
157     FIXME("\n");
158     return E_NOTIMPL;
159 }
160
161 static HRESULT WINAPI update_downloader_put_ClientApplicationID(
162     IUpdateDownloader *This,
163     BSTR value )
164 {
165     FIXME("%p, %s\n", This, debugstr_w(value));
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI update_downloader_get_Priority(
170     IUpdateDownloader *This,
171     DownloadPriority *retval )
172 {
173     FIXME("\n");
174     return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI update_downloader_put_Priority(
178     IUpdateDownloader *This,
179     DownloadPriority value )
180 {
181     FIXME("\n");
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI update_downloader_get_Updates(
186     IUpdateDownloader *This,
187     IUpdateCollection **retval )
188 {
189     FIXME("\n");
190     return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI update_downloader_put_Updates(
194     IUpdateDownloader *This,
195     IUpdateCollection *value )
196 {
197     FIXME("\n");
198     return E_NOTIMPL;
199 }
200
201 static HRESULT WINAPI update_downloader_BeginDownload(
202     IUpdateDownloader *This,
203     IUnknown *onProgressChanged,
204     IUnknown *onCompleted,
205     VARIANT state,
206     IDownloadJob **retval )
207 {
208     FIXME("\n");
209     return E_NOTIMPL;
210 }
211
212 static HRESULT WINAPI update_downloader_Download(
213     IUpdateDownloader *This,
214     IDownloadResult **retval )
215 {
216     FIXME("\n");
217     return E_NOTIMPL;
218 }
219
220 static HRESULT WINAPI update_downloader_EndDownload(
221     IUpdateDownloader *This,
222     IDownloadJob *value,
223     IDownloadResult **retval )
224 {
225     FIXME("\n");
226     return E_NOTIMPL;
227 }
228
229 static const struct IUpdateDownloaderVtbl update_downloader_vtbl =
230 {
231     update_downloader_QueryInterface,
232     update_downloader_AddRef,
233     update_downloader_Release,
234     update_downloader_GetTypeInfoCount,
235     update_downloader_GetTypeInfo,
236     update_downloader_GetIDsOfNames,
237     update_downloader_Invoke,
238     update_downloader_get_ClientApplicationID,
239     update_downloader_put_ClientApplicationID,
240     update_downloader_get_IsForced,
241     update_downloader_put_IsForced,
242     update_downloader_get_Priority,
243     update_downloader_put_Priority,
244     update_downloader_get_Updates,
245     update_downloader_put_Updates,
246     update_downloader_BeginDownload,
247     update_downloader_Download,
248     update_downloader_EndDownload
249 };
250
251 HRESULT UpdateDownloader_create( IUnknown *pUnkOuter, LPVOID *ppObj )
252 {
253     update_downloader *downloader;
254
255     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
256
257     downloader = HeapAlloc( GetProcessHeap(), 0, sizeof(*downloader) );
258     if (!downloader) return E_OUTOFMEMORY;
259
260     downloader->IUpdateDownloader_iface.lpVtbl = &update_downloader_vtbl;
261     downloader->refs = 1;
262
263     *ppObj = &downloader->IUpdateDownloader_iface;
264
265     TRACE("returning iface %p\n", *ppObj);
266     return S_OK;
267 }