Sync with trunk r63793.
[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 #include "wuapi_private.h"
22
23 typedef struct _update_session
24 {
25 IUpdateSession IUpdateSession_iface;
26 LONG refs;
27 } update_session;
28
29 static inline update_session *impl_from_IUpdateSession( IUpdateSession *iface )
30 {
31 return CONTAINING_RECORD(iface, update_session, IUpdateSession_iface);
32 }
33
34 static ULONG WINAPI update_session_AddRef(
35 IUpdateSession *iface )
36 {
37 update_session *update_session = impl_from_IUpdateSession( iface );
38 return InterlockedIncrement( &update_session->refs );
39 }
40
41 static ULONG WINAPI update_session_Release(
42 IUpdateSession *iface )
43 {
44 update_session *update_session = impl_from_IUpdateSession( iface );
45 LONG refs = InterlockedDecrement( &update_session->refs );
46 if (!refs)
47 {
48 TRACE("destroying %p\n", update_session);
49 HeapFree( GetProcessHeap(), 0, update_session );
50 }
51 return refs;
52 }
53
54 static HRESULT WINAPI update_session_QueryInterface(
55 IUpdateSession *iface,
56 REFIID riid,
57 void **ppvObject )
58 {
59 update_session *This = impl_from_IUpdateSession( iface );
60
61 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
62
63 if ( IsEqualGUID( riid, &IID_IUpdateSession ) ||
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 IUpdateSession_AddRef( iface );
75 return S_OK;
76 }
77
78 static HRESULT WINAPI update_session_GetTypeInfoCount(
79 IUpdateSession *iface,
80 UINT *pctinfo )
81 {
82 FIXME("\n");
83 return E_NOTIMPL;
84 }
85
86 static HRESULT WINAPI update_session_GetTypeInfo(
87 IUpdateSession *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_session_GetIDsOfNames(
97 IUpdateSession *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_session_Invoke(
109 IUpdateSession *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_session_get_ClientApplicationID(
124 IUpdateSession *This,
125 BSTR *retval )
126 {
127 FIXME("\n");
128 return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI update_session_put_ClientApplicationID(
132 IUpdateSession *This,
133 BSTR value )
134 {
135 FIXME("%p, %s\n", This, debugstr_w(value));
136 return S_OK;
137 }
138
139 static HRESULT WINAPI update_session_get_ReadOnly(
140 IUpdateSession *This,
141 VARIANT_BOOL *retval )
142 {
143 FIXME("\n");
144 return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI update_session_get_WebProxy(
148 IUpdateSession *This,
149 IWebProxy **retval )
150 {
151 FIXME("\n");
152 return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI update_session_put_WebProxy(
156 IUpdateSession *This,
157 IWebProxy *value )
158 {
159 FIXME("\n");
160 return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI update_session_CreateUpdateSearcher(
164 IUpdateSession *This,
165 IUpdateSearcher **retval )
166 {
167 TRACE("%p\n", This);
168 return UpdateSearcher_create( (LPVOID *)retval );
169 }
170
171 static HRESULT WINAPI update_session_CreateUpdateDownloader(
172 IUpdateSession *This,
173 IUpdateDownloader **retval )
174 {
175 TRACE("%p\n", This);
176 return UpdateDownloader_create( (LPVOID *)retval );
177 }
178
179 static HRESULT WINAPI update_session_CreateUpdateInstaller(
180 IUpdateSession *This,
181 IUpdateInstaller **retval )
182 {
183 TRACE("%p\n", This);
184 return UpdateInstaller_create( (LPVOID *)retval );
185 }
186
187 static const struct IUpdateSessionVtbl update_session_vtbl =
188 {
189 update_session_QueryInterface,
190 update_session_AddRef,
191 update_session_Release,
192 update_session_GetTypeInfoCount,
193 update_session_GetTypeInfo,
194 update_session_GetIDsOfNames,
195 update_session_Invoke,
196 update_session_get_ClientApplicationID,
197 update_session_put_ClientApplicationID,
198 update_session_get_ReadOnly,
199 update_session_get_WebProxy,
200 update_session_put_WebProxy,
201 update_session_CreateUpdateSearcher,
202 update_session_CreateUpdateDownloader,
203 update_session_CreateUpdateInstaller
204 };
205
206 HRESULT UpdateSession_create( LPVOID *ppObj )
207 {
208 update_session *session;
209
210 TRACE("(%p)\n", ppObj);
211
212 session = HeapAlloc( GetProcessHeap(), 0, sizeof(*session) );
213 if (!session) return E_OUTOFMEMORY;
214
215 session->IUpdateSession_iface.lpVtbl = &update_session_vtbl;
216 session->refs = 1;
217
218 *ppObj = &session->IUpdateSession_iface;
219
220 TRACE("returning iface %p\n", *ppObj);
221 return S_OK;
222 }