Sync with trunk.
[reactos.git] / dll / win32 / wuapi / updates.c
1 /*
2 * IAutomaticUpdates 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
37 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
38
39 typedef struct _automatic_updates
40 {
41 IAutomaticUpdates IAutomaticUpdates_iface;
42 LONG refs;
43 } automatic_updates;
44
45 static inline automatic_updates *impl_from_IAutomaticUpdates( IAutomaticUpdates *iface )
46 {
47 return CONTAINING_RECORD(iface, automatic_updates, IAutomaticUpdates_iface);
48 }
49
50 static ULONG WINAPI automatic_updates_AddRef(
51 IAutomaticUpdates *iface )
52 {
53 automatic_updates *automatic_updates = impl_from_IAutomaticUpdates( iface );
54 return InterlockedIncrement( &automatic_updates->refs );
55 }
56
57 static ULONG WINAPI automatic_updates_Release(
58 IAutomaticUpdates *iface )
59 {
60 automatic_updates *automatic_updates = impl_from_IAutomaticUpdates( iface );
61 LONG refs = InterlockedDecrement( &automatic_updates->refs );
62 if (!refs)
63 {
64 TRACE("destroying %p\n", automatic_updates);
65 HeapFree( GetProcessHeap(), 0, automatic_updates );
66 }
67 return refs;
68 }
69
70 static HRESULT WINAPI automatic_updates_QueryInterface(
71 IAutomaticUpdates *iface,
72 REFIID riid,
73 void **ppvObject )
74 {
75 automatic_updates *This = impl_from_IAutomaticUpdates( iface );
76
77 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
78
79 if ( IsEqualGUID( riid, &IID_IAutomaticUpdates ) ||
80 IsEqualGUID( riid, &IID_IDispatch ) ||
81 IsEqualGUID( riid, &IID_IUnknown ) )
82 {
83 *ppvObject = iface;
84 }
85 else
86 {
87 FIXME("interface %s not implemented\n", debugstr_guid(riid));
88 return E_NOINTERFACE;
89 }
90 IAutomaticUpdates_AddRef( iface );
91 return S_OK;
92 }
93
94 static HRESULT WINAPI automatic_updates_GetTypeInfoCount(
95 IAutomaticUpdates *iface,
96 UINT *pctinfo )
97 {
98 FIXME("\n");
99 return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI automatic_updates_GetTypeInfo(
103 IAutomaticUpdates *iface,
104 UINT iTInfo,
105 LCID lcid,
106 ITypeInfo **ppTInfo )
107 {
108 FIXME("\n");
109 return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI automatic_updates_GetIDsOfNames(
113 IAutomaticUpdates *iface,
114 REFIID riid,
115 LPOLESTR *rgszNames,
116 UINT cNames,
117 LCID lcid,
118 DISPID *rgDispId )
119 {
120 FIXME("\n");
121 return E_NOTIMPL;
122 }
123
124 static HRESULT WINAPI automatic_updates_Invoke(
125 IAutomaticUpdates *iface,
126 DISPID dispIdMember,
127 REFIID riid,
128 LCID lcid,
129 WORD wFlags,
130 DISPPARAMS *pDispParams,
131 VARIANT *pVarResult,
132 EXCEPINFO *pExcepInfo,
133 UINT *puArgErr )
134 {
135 FIXME("\n");
136 return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI automatic_updates_DetectNow(
140 IAutomaticUpdates *This )
141 {
142 FIXME("\n");
143 return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI automatic_updates_Pause(
147 IAutomaticUpdates *This )
148 {
149 FIXME("\n");
150 return S_OK;
151 }
152
153 static HRESULT WINAPI automatic_updates_Resume(
154 IAutomaticUpdates *This )
155 {
156 FIXME("\n");
157 return S_OK;
158 }
159
160 static HRESULT WINAPI automatic_updates_ShowSettingsDialog(
161 IAutomaticUpdates *This )
162 {
163 FIXME("\n");
164 return E_NOTIMPL;
165 }
166
167 static HRESULT WINAPI automatic_updates_EnableService(
168 IAutomaticUpdates *This )
169 {
170 FIXME("\n");
171 return E_NOTIMPL;
172 }
173
174 static HRESULT WINAPI automatic_updates_get_ServiceEnabled(
175 IAutomaticUpdates *This,
176 VARIANT_BOOL *retval )
177 {
178 FIXME("%p\n", retval);
179 return E_NOTIMPL;
180 }
181
182 static HRESULT WINAPI automatic_updates_get_Settings(
183 IAutomaticUpdates *This,
184 IAutomaticUpdatesSettings **retval )
185 {
186 FIXME("%p\n", retval);
187 return E_NOTIMPL;
188 }
189
190 static const struct IAutomaticUpdatesVtbl automatic_updates_vtbl =
191 {
192 automatic_updates_QueryInterface,
193 automatic_updates_AddRef,
194 automatic_updates_Release,
195 automatic_updates_GetTypeInfoCount,
196 automatic_updates_GetTypeInfo,
197 automatic_updates_GetIDsOfNames,
198 automatic_updates_Invoke,
199 automatic_updates_DetectNow,
200 automatic_updates_Pause,
201 automatic_updates_Resume,
202 automatic_updates_ShowSettingsDialog,
203 automatic_updates_get_Settings,
204 automatic_updates_get_ServiceEnabled,
205 automatic_updates_EnableService
206 };
207
208 HRESULT AutomaticUpdates_create( IUnknown *pUnkOuter, LPVOID *ppObj )
209 {
210 automatic_updates *updates;
211
212 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
213
214 updates = HeapAlloc( GetProcessHeap(), 0, sizeof(*updates) );
215 if (!updates) return E_OUTOFMEMORY;
216
217 updates->IAutomaticUpdates_iface.lpVtbl = &automatic_updates_vtbl;
218 updates->refs = 1;
219
220 *ppObj = &updates->IAutomaticUpdates_iface;
221
222 TRACE("returning iface %p\n", *ppObj);
223 return S_OK;
224 }