Synchronize with trunk r58528.
[reactos.git] / dll / win32 / wuapi / session.c
1 /*
2 * IUpdateSession 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 <wuapi.h>
34
35 #include <wine/debug.h>
36 #include "wuapi_private.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
39
40 typedef struct _update_session
41 {
42 IUpdateSession IUpdateSession_iface;
43 LONG refs;
44 } update_session;
45
46 static inline update_session *impl_from_IUpdateSession( IUpdateSession *iface )
47 {
48 return CONTAINING_RECORD(iface, update_session, IUpdateSession_iface);
49 }
50
51 static ULONG WINAPI update_session_AddRef(
52 IUpdateSession *iface )
53 {
54 update_session *update_session = impl_from_IUpdateSession( iface );
55 return InterlockedIncrement( &update_session->refs );
56 }
57
58 static ULONG WINAPI update_session_Release(
59 IUpdateSession *iface )
60 {
61 update_session *update_session = impl_from_IUpdateSession( iface );
62 LONG refs = InterlockedDecrement( &update_session->refs );
63 if (!refs)
64 {
65 TRACE("destroying %p\n", update_session);
66 HeapFree( GetProcessHeap(), 0, update_session );
67 }
68 return refs;
69 }
70
71 static HRESULT WINAPI update_session_QueryInterface(
72 IUpdateSession *iface,
73 REFIID riid,
74 void **ppvObject )
75 {
76 update_session *This = impl_from_IUpdateSession( iface );
77
78 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
79
80 if ( IsEqualGUID( riid, &IID_IUpdateSession ) ||
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 IUpdateSession_AddRef( iface );
92 return S_OK;
93 }
94
95 static HRESULT WINAPI update_session_GetTypeInfoCount(
96 IUpdateSession *iface,
97 UINT *pctinfo )
98 {
99 FIXME("\n");
100 return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI update_session_GetTypeInfo(
104 IUpdateSession *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_session_GetIDsOfNames(
114 IUpdateSession *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_session_Invoke(
126 IUpdateSession *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_session_get_ClientApplicationID(
141 IUpdateSession *This,
142 BSTR *retval )
143 {
144 FIXME("\n");
145 return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI update_session_put_ClientApplicationID(
149 IUpdateSession *This,
150 BSTR value )
151 {
152 FIXME("%p, %s\n", This, debugstr_w(value));
153 return S_OK;
154 }
155
156 static HRESULT WINAPI update_session_get_ReadOnly(
157 IUpdateSession *This,
158 VARIANT_BOOL *retval )
159 {
160 FIXME("\n");
161 return E_NOTIMPL;
162 }
163
164 static HRESULT WINAPI update_session_get_WebProxy(
165 IUpdateSession *This,
166 IWebProxy **retval )
167 {
168 FIXME("\n");
169 return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI update_session_put_WebProxy(
173 IUpdateSession *This,
174 IWebProxy *value )
175 {
176 FIXME("\n");
177 return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI update_session_CreateUpdateSearcher(
181 IUpdateSession *This,
182 IUpdateSearcher **retval )
183 {
184 TRACE("%p\n", This);
185 return UpdateSearcher_create( NULL, (LPVOID *)retval );
186 }
187
188 static HRESULT WINAPI update_session_CreateUpdateDownloader(
189 IUpdateSession *This,
190 IUpdateDownloader **retval )
191 {
192 TRACE("%p\n", This);
193 return UpdateDownloader_create( NULL, (LPVOID *)retval );
194 }
195
196 static HRESULT WINAPI update_session_CreateUpdateInstaller(
197 IUpdateSession *This,
198 IUpdateInstaller **retval )
199 {
200 TRACE("%p\n", This);
201 return UpdateInstaller_create( NULL, (LPVOID *)retval );
202 }
203
204 static const struct IUpdateSessionVtbl update_session_vtbl =
205 {
206 update_session_QueryInterface,
207 update_session_AddRef,
208 update_session_Release,
209 update_session_GetTypeInfoCount,
210 update_session_GetTypeInfo,
211 update_session_GetIDsOfNames,
212 update_session_Invoke,
213 update_session_get_ClientApplicationID,
214 update_session_put_ClientApplicationID,
215 update_session_get_ReadOnly,
216 update_session_get_WebProxy,
217 update_session_put_WebProxy,
218 update_session_CreateUpdateSearcher,
219 update_session_CreateUpdateDownloader,
220 update_session_CreateUpdateInstaller
221 };
222
223 HRESULT UpdateSession_create( IUnknown *pUnkOuter, LPVOID *ppObj )
224 {
225 update_session *session;
226
227 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
228
229 session = HeapAlloc( GetProcessHeap(), 0, sizeof(*session) );
230 if (!session) return E_OUTOFMEMORY;
231
232 session->IUpdateSession_iface.lpVtbl = &update_session_vtbl;
233 session->refs = 1;
234
235 *ppObj = &session->IUpdateSession_iface;
236
237 TRACE("returning iface %p\n", *ppObj);
238 return S_OK;
239 }