- Sync with trunk r58248 to bring the latest changes from Amine (headers) and others...
[reactos.git] / dll / win32 / hnetcfg / policy.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 #define WIN32_NO_STATUS
20 #define _INC_WINDOWS
21 #define COM_NO_WINDOWS_H
22
23 #include <config.h>
24 #include <stdarg.h>
25 //#include <stdio.h>
26
27 #define COBJMACROS
28
29 #include <windef.h>
30 #include <winbase.h>
31 //#include "winuser.h"
32 #include <ole2.h>
33 #include <netfw.h>
34
35 #include <wine/debug.h>
36 //#include "wine/unicode.h"
37 #include "hnetcfg_private.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
40
41 typedef struct fw_policy
42 {
43 INetFwPolicy INetFwPolicy_iface;
44 LONG refs;
45 } fw_policy;
46
47 static inline fw_policy *impl_from_INetFwPolicy( INetFwPolicy *iface )
48 {
49 return CONTAINING_RECORD(iface, fw_policy, INetFwPolicy_iface);
50 }
51
52 static ULONG WINAPI fw_policy_AddRef(
53 INetFwPolicy *iface )
54 {
55 fw_policy *fw_policy = impl_from_INetFwPolicy( iface );
56 return InterlockedIncrement( &fw_policy->refs );
57 }
58
59 static ULONG WINAPI fw_policy_Release(
60 INetFwPolicy *iface )
61 {
62 fw_policy *fw_policy = impl_from_INetFwPolicy( iface );
63 LONG refs = InterlockedDecrement( &fw_policy->refs );
64 if (!refs)
65 {
66 TRACE("destroying %p\n", fw_policy);
67 HeapFree( GetProcessHeap(), 0, fw_policy );
68 }
69 return refs;
70 }
71
72 static HRESULT WINAPI fw_policy_QueryInterface(
73 INetFwPolicy *iface,
74 REFIID riid,
75 void **ppvObject )
76 {
77 fw_policy *This = impl_from_INetFwPolicy( iface );
78
79 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
80
81 if ( IsEqualGUID( riid, &IID_INetFwPolicy ) ||
82 IsEqualGUID( riid, &IID_IDispatch ) ||
83 IsEqualGUID( riid, &IID_IUnknown ) )
84 {
85 *ppvObject = iface;
86 }
87 else
88 {
89 FIXME("interface %s not implemented\n", debugstr_guid(riid));
90 return E_NOINTERFACE;
91 }
92 INetFwPolicy_AddRef( iface );
93 return S_OK;
94 }
95
96 static HRESULT WINAPI fw_policy_GetTypeInfoCount(
97 INetFwPolicy *iface,
98 UINT *pctinfo )
99 {
100 fw_policy *This = impl_from_INetFwPolicy( iface );
101
102 FIXME("%p %p\n", This, pctinfo);
103 return E_NOTIMPL;
104 }
105
106 static HRESULT WINAPI fw_policy_GetTypeInfo(
107 INetFwPolicy *iface,
108 UINT iTInfo,
109 LCID lcid,
110 ITypeInfo **ppTInfo )
111 {
112 fw_policy *This = impl_from_INetFwPolicy( iface );
113
114 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
115 return E_NOTIMPL;
116 }
117
118 static HRESULT WINAPI fw_policy_GetIDsOfNames(
119 INetFwPolicy *iface,
120 REFIID riid,
121 LPOLESTR *rgszNames,
122 UINT cNames,
123 LCID lcid,
124 DISPID *rgDispId )
125 {
126 fw_policy *This = impl_from_INetFwPolicy( iface );
127
128 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
129 return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI fw_policy_Invoke(
133 INetFwPolicy *iface,
134 DISPID dispIdMember,
135 REFIID riid,
136 LCID lcid,
137 WORD wFlags,
138 DISPPARAMS *pDispParams,
139 VARIANT *pVarResult,
140 EXCEPINFO *pExcepInfo,
141 UINT *puArgErr )
142 {
143 fw_policy *This = impl_from_INetFwPolicy( iface );
144
145 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
146 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
147 return E_NOTIMPL;
148 }
149
150 static HRESULT WINAPI fw_policy_get_CurrentProfile(
151 INetFwPolicy *iface,
152 INetFwProfile **profile )
153 {
154 fw_policy *This = impl_from_INetFwPolicy( iface );
155
156 TRACE("%p, %p\n", This, profile);
157 return NetFwProfile_create( NULL, (void **)profile );
158 }
159
160 static HRESULT WINAPI fw_policy_GetProfileByType(
161 INetFwPolicy *iface,
162 NET_FW_PROFILE_TYPE profileType,
163 INetFwProfile **profile )
164 {
165 fw_policy *This = impl_from_INetFwPolicy( iface );
166
167 FIXME("%p, %u, %p\n", This, profileType, profile);
168 return E_NOTIMPL;
169 }
170
171 static const struct INetFwPolicyVtbl fw_policy_vtbl =
172 {
173 fw_policy_QueryInterface,
174 fw_policy_AddRef,
175 fw_policy_Release,
176 fw_policy_GetTypeInfoCount,
177 fw_policy_GetTypeInfo,
178 fw_policy_GetIDsOfNames,
179 fw_policy_Invoke,
180 fw_policy_get_CurrentProfile,
181 fw_policy_GetProfileByType
182 };
183
184 HRESULT NetFwPolicy_create( IUnknown *pUnkOuter, LPVOID *ppObj )
185 {
186 fw_policy *fp;
187
188 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
189
190 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
191 if (!fp) return E_OUTOFMEMORY;
192
193 fp->INetFwPolicy_iface.lpVtbl = &fw_policy_vtbl;
194 fp->refs = 1;
195
196 *ppObj = &fp->INetFwPolicy_iface;
197
198 TRACE("returning iface %p\n", *ppObj);
199 return S_OK;
200 }