devenum: Implement IMoniker::GetClassID().
[wine.git] / dlls / hnetcfg / policy.c
blob285ee0fa79ce9f921076651649e648a24198fbe2
1 /*
2 * Copyright 2009 Hans Leidekker for CodeWeavers
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.
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.
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
19 #include "config.h"
20 #include <stdarg.h>
21 #include <stdio.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "netfw.h"
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
33 #include "hnetcfg_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
37 typedef struct fw_policy
39 INetFwPolicy INetFwPolicy_iface;
40 LONG refs;
41 } fw_policy;
43 static inline fw_policy *impl_from_INetFwPolicy( INetFwPolicy *iface )
45 return CONTAINING_RECORD(iface, fw_policy, INetFwPolicy_iface);
48 typedef struct fw_policy2
50 INetFwPolicy2 INetFwPolicy2_iface;
51 LONG refs;
52 } fw_policy2;
54 static inline fw_policy2 *impl_from_INetFwPolicy2( INetFwPolicy2 *iface )
56 return CONTAINING_RECORD(iface, fw_policy2, INetFwPolicy2_iface);
59 static ULONG WINAPI fw_policy_AddRef(
60 INetFwPolicy *iface )
62 fw_policy *fw_policy = impl_from_INetFwPolicy( iface );
63 return InterlockedIncrement( &fw_policy->refs );
66 static ULONG WINAPI fw_policy_Release(
67 INetFwPolicy *iface )
69 fw_policy *fw_policy = impl_from_INetFwPolicy( iface );
70 LONG refs = InterlockedDecrement( &fw_policy->refs );
71 if (!refs)
73 TRACE("destroying %p\n", fw_policy);
74 HeapFree( GetProcessHeap(), 0, fw_policy );
76 return refs;
79 static HRESULT WINAPI fw_policy_QueryInterface(
80 INetFwPolicy *iface,
81 REFIID riid,
82 void **ppvObject )
84 fw_policy *This = impl_from_INetFwPolicy( iface );
86 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
88 if ( IsEqualGUID( riid, &IID_INetFwPolicy ) ||
89 IsEqualGUID( riid, &IID_IDispatch ) ||
90 IsEqualGUID( riid, &IID_IUnknown ) )
92 *ppvObject = iface;
94 else
96 FIXME("interface %s not implemented\n", debugstr_guid(riid));
97 return E_NOINTERFACE;
99 INetFwPolicy_AddRef( iface );
100 return S_OK;
103 static HRESULT WINAPI fw_policy_GetTypeInfoCount(
104 INetFwPolicy *iface,
105 UINT *pctinfo )
107 fw_policy *This = impl_from_INetFwPolicy( iface );
109 TRACE("%p %p\n", This, pctinfo);
110 *pctinfo = 1;
111 return S_OK;
114 static HRESULT WINAPI fw_policy_GetTypeInfo(
115 INetFwPolicy *iface,
116 UINT iTInfo,
117 LCID lcid,
118 ITypeInfo **ppTInfo )
120 fw_policy *This = impl_from_INetFwPolicy( iface );
122 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
123 return get_typeinfo( INetFwPolicy_tid, ppTInfo );
126 static HRESULT WINAPI fw_policy_GetIDsOfNames(
127 INetFwPolicy *iface,
128 REFIID riid,
129 LPOLESTR *rgszNames,
130 UINT cNames,
131 LCID lcid,
132 DISPID *rgDispId )
134 fw_policy *This = impl_from_INetFwPolicy( iface );
135 ITypeInfo *typeinfo;
136 HRESULT hr;
138 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
140 hr = get_typeinfo( INetFwPolicy_tid, &typeinfo );
141 if (SUCCEEDED(hr))
143 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
144 ITypeInfo_Release( typeinfo );
146 return hr;
149 static HRESULT WINAPI fw_policy_Invoke(
150 INetFwPolicy *iface,
151 DISPID dispIdMember,
152 REFIID riid,
153 LCID lcid,
154 WORD wFlags,
155 DISPPARAMS *pDispParams,
156 VARIANT *pVarResult,
157 EXCEPINFO *pExcepInfo,
158 UINT *puArgErr )
160 fw_policy *This = impl_from_INetFwPolicy( iface );
161 ITypeInfo *typeinfo;
162 HRESULT hr;
164 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
165 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
167 hr = get_typeinfo( INetFwPolicy_tid, &typeinfo );
168 if (SUCCEEDED(hr))
170 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwPolicy_iface, dispIdMember,
171 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
172 ITypeInfo_Release( typeinfo );
174 return hr;
177 static HRESULT WINAPI fw_policy_get_CurrentProfile(
178 INetFwPolicy *iface,
179 INetFwProfile **profile )
181 fw_policy *This = impl_from_INetFwPolicy( iface );
183 TRACE("%p, %p\n", This, profile);
184 return NetFwProfile_create( NULL, (void **)profile );
187 static HRESULT WINAPI fw_policy_GetProfileByType(
188 INetFwPolicy *iface,
189 NET_FW_PROFILE_TYPE profileType,
190 INetFwProfile **profile )
192 fw_policy *This = impl_from_INetFwPolicy( iface );
194 FIXME("%p, %u, %p\n", This, profileType, profile);
195 return E_NOTIMPL;
198 static const struct INetFwPolicyVtbl fw_policy_vtbl =
200 fw_policy_QueryInterface,
201 fw_policy_AddRef,
202 fw_policy_Release,
203 fw_policy_GetTypeInfoCount,
204 fw_policy_GetTypeInfo,
205 fw_policy_GetIDsOfNames,
206 fw_policy_Invoke,
207 fw_policy_get_CurrentProfile,
208 fw_policy_GetProfileByType
211 HRESULT NetFwPolicy_create( IUnknown *pUnkOuter, LPVOID *ppObj )
213 fw_policy *fp;
215 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
217 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
218 if (!fp) return E_OUTOFMEMORY;
220 fp->INetFwPolicy_iface.lpVtbl = &fw_policy_vtbl;
221 fp->refs = 1;
223 *ppObj = &fp->INetFwPolicy_iface;
225 TRACE("returning iface %p\n", *ppObj);
226 return S_OK;
229 static HRESULT WINAPI fwpolicy2_QueryInterface(INetFwPolicy2 *iface, REFIID riid, void **out)
231 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
233 TRACE("%p %s %p\n", This, debugstr_guid( riid ), out );
235 if ( IsEqualGUID( riid, &IID_INetFwPolicy2 ) ||
236 IsEqualGUID( riid, &IID_IDispatch ) ||
237 IsEqualGUID( riid, &IID_IUnknown ) )
239 *out = iface;
241 else
243 FIXME("interface %s not implemented\n", debugstr_guid(riid));
244 return E_NOINTERFACE;
246 INetFwPolicy2_AddRef( iface );
247 return S_OK;
250 static ULONG WINAPI fwpolicy2_AddRef(INetFwPolicy2 *iface)
252 fw_policy2 *fw_policy = impl_from_INetFwPolicy2( iface );
253 return InterlockedIncrement( &fw_policy->refs );
256 static ULONG WINAPI fwpolicy2_Release(INetFwPolicy2 *iface)
258 fw_policy2 *fw_policy = impl_from_INetFwPolicy2( iface );
259 LONG refs = InterlockedDecrement( &fw_policy->refs );
260 if (!refs)
262 TRACE("destroying %p\n", fw_policy);
263 HeapFree( GetProcessHeap(), 0, fw_policy );
265 return refs;
268 static HRESULT WINAPI fwpolicy2_GetTypeInfoCount(INetFwPolicy2 *iface, UINT *pctinfo)
270 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
272 TRACE("%p %p\n", This, pctinfo);
273 *pctinfo = 1;
274 return S_OK;
277 static HRESULT WINAPI fwpolicy2_GetTypeInfo(INetFwPolicy2 *iface, UINT iTInfo, LCID lcid, ITypeInfo **info)
279 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
281 TRACE("%p %u %u %p\n", This, iTInfo, lcid, info);
282 return get_typeinfo( INetFwPolicy2_tid, info );
285 static HRESULT WINAPI fwpolicy2_GetIDsOfNames(INetFwPolicy2 *iface, REFIID riid, LPOLESTR *rgszNames,
286 UINT cNames, LCID lcid, DISPID *rgDispId)
288 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
289 ITypeInfo *typeinfo;
290 HRESULT hr;
292 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
294 hr = get_typeinfo( INetFwPolicy2_tid, &typeinfo );
295 if (SUCCEEDED(hr))
297 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
298 ITypeInfo_Release( typeinfo );
300 return hr;
303 static HRESULT WINAPI fwpolicy2_Invoke(INetFwPolicy2 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
304 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
306 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
307 ITypeInfo *typeinfo;
308 HRESULT hr;
310 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
311 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
313 hr = get_typeinfo( INetFwPolicy2_tid, &typeinfo );
314 if (SUCCEEDED(hr))
316 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwPolicy2_iface, dispIdMember,
317 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
318 ITypeInfo_Release( typeinfo );
320 return hr;
323 static HRESULT WINAPI fwpolicy2_get_CurrentProfileTypes(INetFwPolicy2 *iface, LONG *profile)
325 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
327 FIXME("%p %p\n", This, profile);
328 return E_NOTIMPL;
331 static HRESULT WINAPI fwpolicy2_get_FirewallEnabled(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT_BOOL *enabled)
333 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
335 FIXME("%p %d %p\n", This, profileType, enabled);
336 return E_NOTIMPL;
339 static HRESULT WINAPI fwpolicy2_put_FirewallEnabled(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT_BOOL enabled)
341 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
343 FIXME("%p %d %d\n", This, profileType, enabled);
344 return E_NOTIMPL;
347 static HRESULT WINAPI fwpolicy2_get_ExcludedInterfaces(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT *interfaces)
349 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
351 FIXME("%p %d %p\n", This, profileType, interfaces);
352 return E_NOTIMPL;
355 static HRESULT WINAPI fwpolicy2_put_ExcludedInterfaces(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT interfaces)
357 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
358 FIXME("%p %d\n", This, profileType);
359 return E_NOTIMPL;
362 static HRESULT WINAPI fwpolicy2_get_BlockAllInboundTraffic(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT_BOOL *block)
364 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
366 FIXME("%p %d %p\n", This, profileType, block);
367 return E_NOTIMPL;
370 static HRESULT WINAPI fwpolicy2_put_BlockAllInboundTraffic(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT_BOOL block)
372 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
374 FIXME("%p %d %d\n", This, profileType, block);
375 return E_NOTIMPL;
378 static HRESULT WINAPI fwpolicy2_get_NotificationsDisabled(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT_BOOL *disabled)
380 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
382 FIXME("%p %d %p\n", This, profileType, disabled);
383 return E_NOTIMPL;
386 static HRESULT WINAPI fwpolicy2_put_NotificationsDisabled(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT_BOOL disabled)
388 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
390 FIXME("%p %d %d\n", This, profileType, disabled);
391 return E_NOTIMPL;
394 static HRESULT WINAPI fwpolicy2_get_UnicastResponsesToMulticastBroadcastDisabled(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT_BOOL *disabled)
396 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
398 FIXME("%p %d %p\n", This, profileType, disabled);
399 return E_NOTIMPL;
402 static HRESULT WINAPI fwpolicy2_put_UnicastResponsesToMulticastBroadcastDisabled(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, VARIANT_BOOL disabled)
404 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
406 FIXME("%p %d %d\n", This, profileType, disabled);
407 return E_NOTIMPL;
410 static HRESULT WINAPI fwpolicy2_get_Rules(INetFwPolicy2 *iface, INetFwRules **rules)
412 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
414 FIXME("%p %p\n", This, rules);
415 return E_NOTIMPL;
418 static HRESULT WINAPI fwpolicy2_get_ServiceRestriction(INetFwPolicy2 *iface, INetFwServiceRestriction **ServiceRestriction)
420 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
422 FIXME("%p %p\n", This, ServiceRestriction);
423 return E_NOTIMPL;
426 static HRESULT WINAPI fwpolicy2_EnableRuleGroup(INetFwPolicy2 *iface, LONG bitmask, BSTR group, VARIANT_BOOL enable)
428 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
430 FIXME("%p %d %s %d\n", This, bitmask, debugstr_w(group), enable);
431 return E_NOTIMPL;
434 static HRESULT WINAPI fwpolicy2_IsRuleGroupEnabled(INetFwPolicy2 *iface, LONG bitmask, BSTR group, VARIANT_BOOL *enabled)
436 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
438 FIXME("%p %d %s %p\n", This, bitmask, debugstr_w(group), enabled);
439 return E_NOTIMPL;
442 static HRESULT WINAPI fwpolicy2_RestoreLocalFirewallDefaults(INetFwPolicy2 *iface)
444 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
446 FIXME("%p\n", This);
447 return E_NOTIMPL;
450 static HRESULT WINAPI fwpolicy2_get_DefaultInboundAction(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, NET_FW_ACTION *action)
452 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
454 FIXME("%p %d %p\n", This, profileType, action);
455 return E_NOTIMPL;
458 static HRESULT WINAPI fwpolicy2_put_DefaultInboundAction(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, NET_FW_ACTION action)
460 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
462 FIXME("%p %d %d\n", This, profileType, action);
463 return E_NOTIMPL;
466 static HRESULT WINAPI fwpolicy2_get_DefaultOutboundAction(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, NET_FW_ACTION *action)
468 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
470 FIXME("%p %d %p\n", This, profileType, action);
471 return E_NOTIMPL;
474 static HRESULT WINAPI fwpolicy2_put_DefaultOutboundAction(INetFwPolicy2 *iface, NET_FW_PROFILE_TYPE2 profileType, NET_FW_ACTION action)
476 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
478 FIXME("%p %d %d\n", This, profileType, action);
479 return E_NOTIMPL;
482 static HRESULT WINAPI fwpolicy2_get_IsRuleGroupCurrentlyEnabled(INetFwPolicy2 *iface, BSTR group, VARIANT_BOOL *enabled)
484 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
486 FIXME("%p %s %p\n", This, debugstr_w(group), enabled);
487 return E_NOTIMPL;
490 static HRESULT WINAPI fwpolicy2_get_LocalPolicyModifyState(INetFwPolicy2 *iface, NET_FW_MODIFY_STATE *modifyState)
492 fw_policy2 *This = impl_from_INetFwPolicy2( iface );
494 FIXME("%p %p\n", This, modifyState);
495 return E_NOTIMPL;
498 static const struct INetFwPolicy2Vtbl fw_policy2_vtbl =
500 fwpolicy2_QueryInterface,
501 fwpolicy2_AddRef,
502 fwpolicy2_Release,
503 fwpolicy2_GetTypeInfoCount,
504 fwpolicy2_GetTypeInfo,
505 fwpolicy2_GetIDsOfNames,
506 fwpolicy2_Invoke,
507 fwpolicy2_get_CurrentProfileTypes,
508 fwpolicy2_get_FirewallEnabled,
509 fwpolicy2_put_FirewallEnabled,
510 fwpolicy2_get_ExcludedInterfaces,
511 fwpolicy2_put_ExcludedInterfaces,
512 fwpolicy2_get_BlockAllInboundTraffic,
513 fwpolicy2_put_BlockAllInboundTraffic,
514 fwpolicy2_get_NotificationsDisabled,
515 fwpolicy2_put_NotificationsDisabled,
516 fwpolicy2_get_UnicastResponsesToMulticastBroadcastDisabled,
517 fwpolicy2_put_UnicastResponsesToMulticastBroadcastDisabled,
518 fwpolicy2_get_Rules,
519 fwpolicy2_get_ServiceRestriction,
520 fwpolicy2_EnableRuleGroup,
521 fwpolicy2_IsRuleGroupEnabled,
522 fwpolicy2_RestoreLocalFirewallDefaults,
523 fwpolicy2_get_DefaultInboundAction,
524 fwpolicy2_put_DefaultInboundAction,
525 fwpolicy2_get_DefaultOutboundAction,
526 fwpolicy2_put_DefaultOutboundAction,
527 fwpolicy2_get_IsRuleGroupCurrentlyEnabled,
528 fwpolicy2_get_LocalPolicyModifyState
531 HRESULT NetFwPolicy2_create( IUnknown *outer, void **obj )
533 fw_policy2 *fp;
535 TRACE("(%p,%p)\n", outer, obj);
537 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
538 if (!fp) return E_OUTOFMEMORY;
540 fp->INetFwPolicy2_iface.lpVtbl = &fw_policy2_vtbl;
541 fp->refs = 1;
543 *obj = &fp->INetFwPolicy2_iface;
545 TRACE("returning iface %p\n", *obj);
546 return S_OK;