oleaut32: Use WdtpInterfacePointer_* functions in VARIANT marshalling.
[wine.git] / dlls / hnetcfg / policy.c
blobe340ffbafa5b68f57859e19e165df6823afd0ed9
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 static ULONG WINAPI fw_policy_AddRef(
49 INetFwPolicy *iface )
51 fw_policy *fw_policy = impl_from_INetFwPolicy( iface );
52 return InterlockedIncrement( &fw_policy->refs );
55 static ULONG WINAPI fw_policy_Release(
56 INetFwPolicy *iface )
58 fw_policy *fw_policy = impl_from_INetFwPolicy( iface );
59 LONG refs = InterlockedDecrement( &fw_policy->refs );
60 if (!refs)
62 TRACE("destroying %p\n", fw_policy);
63 HeapFree( GetProcessHeap(), 0, fw_policy );
65 return refs;
68 static HRESULT WINAPI fw_policy_QueryInterface(
69 INetFwPolicy *iface,
70 REFIID riid,
71 void **ppvObject )
73 fw_policy *This = impl_from_INetFwPolicy( iface );
75 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
77 if ( IsEqualGUID( riid, &IID_INetFwPolicy ) ||
78 IsEqualGUID( riid, &IID_IDispatch ) ||
79 IsEqualGUID( riid, &IID_IUnknown ) )
81 *ppvObject = iface;
83 else
85 FIXME("interface %s not implemented\n", debugstr_guid(riid));
86 return E_NOINTERFACE;
88 INetFwPolicy_AddRef( iface );
89 return S_OK;
92 static HRESULT WINAPI fw_policy_GetTypeInfoCount(
93 INetFwPolicy *iface,
94 UINT *pctinfo )
96 fw_policy *This = impl_from_INetFwPolicy( iface );
98 TRACE("%p %p\n", This, pctinfo);
99 *pctinfo = 1;
100 return S_OK;
103 static HRESULT WINAPI fw_policy_GetTypeInfo(
104 INetFwPolicy *iface,
105 UINT iTInfo,
106 LCID lcid,
107 ITypeInfo **ppTInfo )
109 fw_policy *This = impl_from_INetFwPolicy( iface );
111 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
112 return get_typeinfo( INetFwPolicy_tid, ppTInfo );
115 static HRESULT WINAPI fw_policy_GetIDsOfNames(
116 INetFwPolicy *iface,
117 REFIID riid,
118 LPOLESTR *rgszNames,
119 UINT cNames,
120 LCID lcid,
121 DISPID *rgDispId )
123 fw_policy *This = impl_from_INetFwPolicy( iface );
124 ITypeInfo *typeinfo;
125 HRESULT hr;
127 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
129 hr = get_typeinfo( INetFwPolicy_tid, &typeinfo );
130 if (SUCCEEDED(hr))
132 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
133 ITypeInfo_Release( typeinfo );
135 return hr;
138 static HRESULT WINAPI fw_policy_Invoke(
139 INetFwPolicy *iface,
140 DISPID dispIdMember,
141 REFIID riid,
142 LCID lcid,
143 WORD wFlags,
144 DISPPARAMS *pDispParams,
145 VARIANT *pVarResult,
146 EXCEPINFO *pExcepInfo,
147 UINT *puArgErr )
149 fw_policy *This = impl_from_INetFwPolicy( iface );
150 ITypeInfo *typeinfo;
151 HRESULT hr;
153 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
154 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
156 hr = get_typeinfo( INetFwPolicy_tid, &typeinfo );
157 if (SUCCEEDED(hr))
159 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwPolicy_iface, dispIdMember,
160 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
161 ITypeInfo_Release( typeinfo );
163 return hr;
166 static HRESULT WINAPI fw_policy_get_CurrentProfile(
167 INetFwPolicy *iface,
168 INetFwProfile **profile )
170 fw_policy *This = impl_from_INetFwPolicy( iface );
172 TRACE("%p, %p\n", This, profile);
173 return NetFwProfile_create( NULL, (void **)profile );
176 static HRESULT WINAPI fw_policy_GetProfileByType(
177 INetFwPolicy *iface,
178 NET_FW_PROFILE_TYPE profileType,
179 INetFwProfile **profile )
181 fw_policy *This = impl_from_INetFwPolicy( iface );
183 FIXME("%p, %u, %p\n", This, profileType, profile);
184 return E_NOTIMPL;
187 static const struct INetFwPolicyVtbl fw_policy_vtbl =
189 fw_policy_QueryInterface,
190 fw_policy_AddRef,
191 fw_policy_Release,
192 fw_policy_GetTypeInfoCount,
193 fw_policy_GetTypeInfo,
194 fw_policy_GetIDsOfNames,
195 fw_policy_Invoke,
196 fw_policy_get_CurrentProfile,
197 fw_policy_GetProfileByType
200 HRESULT NetFwPolicy_create( IUnknown *pUnkOuter, LPVOID *ppObj )
202 fw_policy *fp;
204 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
206 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
207 if (!fp) return E_OUTOFMEMORY;
209 fp->INetFwPolicy_iface.lpVtbl = &fw_policy_vtbl;
210 fp->refs = 1;
212 *ppObj = &fp->INetFwPolicy_iface;
214 TRACE("returning iface %p\n", *ppObj);
215 return S_OK;