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