* Sync up to trunk head (r64829).
[reactos.git] / dll / win32 / hnetcfg / profile.c
1 /*
2 * Copyright 2009 Hans Leidekker for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include "hnetcfg_private.h"
20
21 typedef struct fw_profile
22 {
23 INetFwProfile INetFwProfile_iface;
24 LONG refs;
25 } fw_profile;
26
27 static inline fw_profile *impl_from_INetFwProfile( INetFwProfile *iface )
28 {
29 return CONTAINING_RECORD(iface, fw_profile, INetFwProfile_iface);
30 }
31
32 static ULONG WINAPI fw_profile_AddRef(
33 INetFwProfile *iface )
34 {
35 fw_profile *fw_profile = impl_from_INetFwProfile( iface );
36 return InterlockedIncrement( &fw_profile->refs );
37 }
38
39 static ULONG WINAPI fw_profile_Release(
40 INetFwProfile *iface )
41 {
42 fw_profile *fw_profile = impl_from_INetFwProfile( iface );
43 LONG refs = InterlockedDecrement( &fw_profile->refs );
44 if (!refs)
45 {
46 TRACE("destroying %p\n", fw_profile);
47 HeapFree( GetProcessHeap(), 0, fw_profile );
48 }
49 return refs;
50 }
51
52 static HRESULT WINAPI fw_profile_QueryInterface(
53 INetFwProfile *iface,
54 REFIID riid,
55 void **ppvObject )
56 {
57 fw_profile *This = impl_from_INetFwProfile( iface );
58
59 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
60
61 if ( IsEqualGUID( riid, &IID_INetFwProfile ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
64 {
65 *ppvObject = iface;
66 }
67 else
68 {
69 FIXME("interface %s not implemented\n", debugstr_guid(riid));
70 return E_NOINTERFACE;
71 }
72 INetFwProfile_AddRef( iface );
73 return S_OK;
74 }
75
76 static HRESULT WINAPI fw_profile_GetTypeInfoCount(
77 INetFwProfile *iface,
78 UINT *pctinfo )
79 {
80 fw_profile *This = impl_from_INetFwProfile( iface );
81
82 TRACE("%p %p\n", This, pctinfo);
83 *pctinfo = 1;
84 return S_OK;
85 }
86
87 static HRESULT WINAPI fw_profile_GetTypeInfo(
88 INetFwProfile *iface,
89 UINT iTInfo,
90 LCID lcid,
91 ITypeInfo **ppTInfo )
92 {
93 fw_profile *This = impl_from_INetFwProfile( iface );
94
95 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
96 return get_typeinfo( INetFwProfile_tid, ppTInfo );
97 }
98
99 static HRESULT WINAPI fw_profile_GetIDsOfNames(
100 INetFwProfile *iface,
101 REFIID riid,
102 LPOLESTR *rgszNames,
103 UINT cNames,
104 LCID lcid,
105 DISPID *rgDispId )
106 {
107 fw_profile *This = impl_from_INetFwProfile( iface );
108 ITypeInfo *typeinfo;
109 HRESULT hr;
110
111 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
112
113 hr = get_typeinfo( INetFwProfile_tid, &typeinfo );
114 if (SUCCEEDED(hr))
115 {
116 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
117 ITypeInfo_Release( typeinfo );
118 }
119 return hr;
120 }
121
122 static HRESULT WINAPI fw_profile_Invoke(
123 INetFwProfile *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 fw_profile *This = impl_from_INetFwProfile( iface );
134 ITypeInfo *typeinfo;
135 HRESULT hr;
136
137 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
138 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
139
140 hr = get_typeinfo( INetFwProfile_tid, &typeinfo );
141 if (SUCCEEDED(hr))
142 {
143 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwProfile_iface, dispIdMember,
144 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
145 ITypeInfo_Release( typeinfo );
146 }
147 return hr;
148 }
149
150 static HRESULT WINAPI fw_profile_get_Type(
151 INetFwProfile *iface,
152 NET_FW_PROFILE_TYPE *type )
153 {
154 fw_profile *This = impl_from_INetFwProfile( iface );
155
156 FIXME("%p, %p\n", This, type);
157 return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI fw_profile_get_FirewallEnabled(
161 INetFwProfile *iface,
162 VARIANT_BOOL *enabled )
163 {
164 fw_profile *This = impl_from_INetFwProfile( iface );
165
166 FIXME("%p, %p\n", This, enabled);
167
168 *enabled = VARIANT_FALSE;
169 return S_OK;
170 }
171
172 static HRESULT WINAPI fw_profile_put_FirewallEnabled(
173 INetFwProfile *iface,
174 VARIANT_BOOL enabled )
175 {
176 fw_profile *This = impl_from_INetFwProfile( iface );
177
178 FIXME("%p, %d\n", This, enabled);
179 return E_NOTIMPL;
180 }
181
182 static HRESULT WINAPI fw_profile_get_ExceptionsNotAllowed(
183 INetFwProfile *iface,
184 VARIANT_BOOL *notAllowed )
185 {
186 fw_profile *This = impl_from_INetFwProfile( iface );
187
188 FIXME("%p, %p\n", This, notAllowed);
189 return E_NOTIMPL;
190 }
191
192 static HRESULT WINAPI fw_profile_put_ExceptionsNotAllowed(
193 INetFwProfile *iface,
194 VARIANT_BOOL notAllowed )
195 {
196 fw_profile *This = impl_from_INetFwProfile( iface );
197
198 FIXME("%p, %d\n", This, notAllowed);
199 return E_NOTIMPL;
200 }
201
202 static HRESULT WINAPI fw_profile_get_NotificationsDisabled(
203 INetFwProfile *iface,
204 VARIANT_BOOL *disabled )
205 {
206 fw_profile *This = impl_from_INetFwProfile( iface );
207
208 FIXME("%p, %p\n", This, disabled);
209 return E_NOTIMPL;
210 }
211
212 static HRESULT WINAPI fw_profile_put_NotificationsDisabled(
213 INetFwProfile *iface,
214 VARIANT_BOOL disabled )
215 {
216 fw_profile *This = impl_from_INetFwProfile( iface );
217
218 FIXME("%p, %d\n", This, disabled);
219 return E_NOTIMPL;
220 }
221
222 static HRESULT WINAPI fw_profile_get_UnicastResponsesToMulticastBroadcastDisabled(
223 INetFwProfile *iface,
224 VARIANT_BOOL *disabled )
225 {
226 fw_profile *This = impl_from_INetFwProfile( iface );
227
228 FIXME("%p, %p\n", This, disabled);
229 return E_NOTIMPL;
230 }
231
232 static HRESULT WINAPI fw_profile_put_UnicastResponsesToMulticastBroadcastDisabled(
233 INetFwProfile *iface,
234 VARIANT_BOOL disabled )
235 {
236 fw_profile *This = impl_from_INetFwProfile( iface );
237
238 FIXME("%p, %d\n", This, disabled);
239 return E_NOTIMPL;
240 }
241
242 static HRESULT WINAPI fw_profile_get_RemoteAdminSettings(
243 INetFwProfile *iface,
244 INetFwRemoteAdminSettings **remoteAdminSettings )
245 {
246 fw_profile *This = impl_from_INetFwProfile( iface );
247
248 FIXME("%p, %p\n", This, remoteAdminSettings);
249 return E_NOTIMPL;
250 }
251
252 static HRESULT WINAPI fw_profile_get_IcmpSettings(
253 INetFwProfile *iface,
254 INetFwIcmpSettings **icmpSettings )
255 {
256 fw_profile *This = impl_from_INetFwProfile( iface );
257
258 FIXME("%p, %p\n", This, icmpSettings);
259 return E_NOTIMPL;
260 }
261
262 static HRESULT WINAPI fw_profile_get_GloballyOpenPorts(
263 INetFwProfile *iface,
264 INetFwOpenPorts **openPorts )
265 {
266 fw_profile *This = impl_from_INetFwProfile( iface );
267
268 TRACE("%p, %p\n", This, openPorts);
269 return NetFwOpenPorts_create( NULL, (void **)openPorts );
270 }
271
272 static HRESULT WINAPI fw_profile_get_Services(
273 INetFwProfile *iface,
274 INetFwServices **Services )
275 {
276 fw_profile *This = impl_from_INetFwProfile( iface );
277
278 TRACE("%p, %p\n", This, Services);
279 return NetFwServices_create( NULL, (void **)Services );
280 }
281
282 static HRESULT WINAPI fw_profile_get_AuthorizedApplications(
283 INetFwProfile *iface,
284 INetFwAuthorizedApplications **apps )
285 {
286 fw_profile *This = impl_from_INetFwProfile( iface );
287
288 TRACE("%p, %p\n", This, apps);
289 return NetFwAuthorizedApplications_create( NULL, (void **)apps );
290 }
291
292 static const struct INetFwProfileVtbl fw_profile_vtbl =
293 {
294 fw_profile_QueryInterface,
295 fw_profile_AddRef,
296 fw_profile_Release,
297 fw_profile_GetTypeInfoCount,
298 fw_profile_GetTypeInfo,
299 fw_profile_GetIDsOfNames,
300 fw_profile_Invoke,
301 fw_profile_get_Type,
302 fw_profile_get_FirewallEnabled,
303 fw_profile_put_FirewallEnabled,
304 fw_profile_get_ExceptionsNotAllowed,
305 fw_profile_put_ExceptionsNotAllowed,
306 fw_profile_get_NotificationsDisabled,
307 fw_profile_put_NotificationsDisabled,
308 fw_profile_get_UnicastResponsesToMulticastBroadcastDisabled,
309 fw_profile_put_UnicastResponsesToMulticastBroadcastDisabled,
310 fw_profile_get_RemoteAdminSettings,
311 fw_profile_get_IcmpSettings,
312 fw_profile_get_GloballyOpenPorts,
313 fw_profile_get_Services,
314 fw_profile_get_AuthorizedApplications
315 };
316
317 HRESULT NetFwProfile_create( IUnknown *pUnkOuter, LPVOID *ppObj )
318 {
319 fw_profile *fp;
320
321 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
322
323 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
324 if (!fp) return E_OUTOFMEMORY;
325
326 fp->INetFwProfile_iface.lpVtbl = &fw_profile_vtbl;
327 fp->refs = 1;
328
329 *ppObj = &fp->INetFwProfile_iface;
330
331 TRACE("returning iface %p\n", *ppObj);
332 return S_OK;
333 }