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