* Sync up to trunk head (r65426).
[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 #include "wuapi_private.h"
22
23 typedef struct _automatic_updates
24 {
25 IAutomaticUpdates IAutomaticUpdates_iface;
26 LONG refs;
27 } automatic_updates;
28
29 static inline automatic_updates *impl_from_IAutomaticUpdates( IAutomaticUpdates *iface )
30 {
31 return CONTAINING_RECORD(iface, automatic_updates, IAutomaticUpdates_iface);
32 }
33
34 static ULONG WINAPI automatic_updates_AddRef(
35 IAutomaticUpdates *iface )
36 {
37 automatic_updates *automatic_updates = impl_from_IAutomaticUpdates( iface );
38 return InterlockedIncrement( &automatic_updates->refs );
39 }
40
41 static ULONG WINAPI automatic_updates_Release(
42 IAutomaticUpdates *iface )
43 {
44 automatic_updates *automatic_updates = impl_from_IAutomaticUpdates( iface );
45 LONG refs = InterlockedDecrement( &automatic_updates->refs );
46 if (!refs)
47 {
48 TRACE("destroying %p\n", automatic_updates);
49 HeapFree( GetProcessHeap(), 0, automatic_updates );
50 }
51 return refs;
52 }
53
54 static HRESULT WINAPI automatic_updates_QueryInterface(
55 IAutomaticUpdates *iface,
56 REFIID riid,
57 void **ppvObject )
58 {
59 automatic_updates *This = impl_from_IAutomaticUpdates( iface );
60
61 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
62
63 if ( IsEqualGUID( riid, &IID_IAutomaticUpdates ) ||
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 IAutomaticUpdates_AddRef( iface );
75 return S_OK;
76 }
77
78 static HRESULT WINAPI automatic_updates_GetTypeInfoCount(
79 IAutomaticUpdates *iface,
80 UINT *pctinfo )
81 {
82 FIXME("\n");
83 return E_NOTIMPL;
84 }
85
86 static HRESULT WINAPI automatic_updates_GetTypeInfo(
87 IAutomaticUpdates *iface,
88 UINT iTInfo,
89 LCID lcid,
90 ITypeInfo **ppTInfo )
91 {
92 FIXME("\n");
93 return E_NOTIMPL;
94 }
95
96 static HRESULT WINAPI automatic_updates_GetIDsOfNames(
97 IAutomaticUpdates *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 automatic_updates_Invoke(
109 IAutomaticUpdates *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 automatic_updates_DetectNow(
124 IAutomaticUpdates *This )
125 {
126 FIXME("\n");
127 return E_NOTIMPL;
128 }
129
130 static HRESULT WINAPI automatic_updates_Pause(
131 IAutomaticUpdates *This )
132 {
133 FIXME("\n");
134 return S_OK;
135 }
136
137 static HRESULT WINAPI automatic_updates_Resume(
138 IAutomaticUpdates *This )
139 {
140 FIXME("\n");
141 return S_OK;
142 }
143
144 static HRESULT WINAPI automatic_updates_ShowSettingsDialog(
145 IAutomaticUpdates *This )
146 {
147 FIXME("\n");
148 return E_NOTIMPL;
149 }
150
151 static HRESULT WINAPI automatic_updates_EnableService(
152 IAutomaticUpdates *This )
153 {
154 FIXME("\n");
155 return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI automatic_updates_get_ServiceEnabled(
159 IAutomaticUpdates *This,
160 VARIANT_BOOL *retval )
161 {
162 FIXME("%p\n", retval);
163 return E_NOTIMPL;
164 }
165
166 static HRESULT WINAPI automatic_updates_get_Settings(
167 IAutomaticUpdates *This,
168 IAutomaticUpdatesSettings **retval )
169 {
170 FIXME("%p\n", retval);
171 return E_NOTIMPL;
172 }
173
174 static const struct IAutomaticUpdatesVtbl automatic_updates_vtbl =
175 {
176 automatic_updates_QueryInterface,
177 automatic_updates_AddRef,
178 automatic_updates_Release,
179 automatic_updates_GetTypeInfoCount,
180 automatic_updates_GetTypeInfo,
181 automatic_updates_GetIDsOfNames,
182 automatic_updates_Invoke,
183 automatic_updates_DetectNow,
184 automatic_updates_Pause,
185 automatic_updates_Resume,
186 automatic_updates_ShowSettingsDialog,
187 automatic_updates_get_Settings,
188 automatic_updates_get_ServiceEnabled,
189 automatic_updates_EnableService
190 };
191
192 HRESULT AutomaticUpdates_create( LPVOID *ppObj )
193 {
194 automatic_updates *updates;
195
196 TRACE("(%p)\n", ppObj);
197
198 updates = HeapAlloc( GetProcessHeap(), 0, sizeof(*updates) );
199 if (!updates) return E_OUTOFMEMORY;
200
201 updates->IAutomaticUpdates_iface.lpVtbl = &automatic_updates_vtbl;
202 updates->refs = 1;
203
204 *ppObj = &updates->IAutomaticUpdates_iface;
205
206 TRACE("returning iface %p\n", *ppObj);
207 return S_OK;
208 }