Sync with trunk (r48545)
[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 "config.h"
20 #include <stdarg.h>
21 #include <stdio.h>
22
23 #define COBJMACROS
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "netfw.h"
30
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
33 #include "hnetcfg_private.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
36
37 typedef struct fw_profile
38 {
39 const INetFwProfileVtbl *vtbl;
40 LONG refs;
41 } fw_profile;
42
43 static inline fw_profile *impl_from_INetFwProfile( INetFwProfile *iface )
44 {
45 return (fw_profile *)((char *)iface - FIELD_OFFSET( fw_profile, vtbl ));
46 }
47
48 static ULONG WINAPI fw_profile_AddRef(
49 INetFwProfile *iface )
50 {
51 fw_profile *fw_profile = impl_from_INetFwProfile( iface );
52 return InterlockedIncrement( &fw_profile->refs );
53 }
54
55 static ULONG WINAPI fw_profile_Release(
56 INetFwProfile *iface )
57 {
58 fw_profile *fw_profile = impl_from_INetFwProfile( iface );
59 LONG refs = InterlockedDecrement( &fw_profile->refs );
60 if (!refs)
61 {
62 TRACE("destroying %p\n", fw_profile);
63 HeapFree( GetProcessHeap(), 0, fw_profile );
64 }
65 return refs;
66 }
67
68 static HRESULT WINAPI fw_profile_QueryInterface(
69 INetFwProfile *iface,
70 REFIID riid,
71 void **ppvObject )
72 {
73 fw_profile *This = impl_from_INetFwProfile( iface );
74
75 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
76
77 if ( IsEqualGUID( riid, &IID_INetFwProfile ) ||
78 IsEqualGUID( riid, &IID_IDispatch ) ||
79 IsEqualGUID( riid, &IID_IUnknown ) )
80 {
81 *ppvObject = iface;
82 }
83 else
84 {
85 FIXME("interface %s not implemented\n", debugstr_guid(riid));
86 return E_NOINTERFACE;
87 }
88 INetFwProfile_AddRef( iface );
89 return S_OK;
90 }
91
92 static HRESULT WINAPI fw_profile_GetTypeInfoCount(
93 INetFwProfile *iface,
94 UINT *pctinfo )
95 {
96 fw_profile *This = impl_from_INetFwProfile( iface );
97
98 FIXME("%p %p\n", This, pctinfo);
99 return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI fw_profile_GetTypeInfo(
103 INetFwProfile *iface,
104 UINT iTInfo,
105 LCID lcid,
106 ITypeInfo **ppTInfo )
107 {
108 fw_profile *This = impl_from_INetFwProfile( iface );
109
110 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
111 return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI fw_profile_GetIDsOfNames(
115 INetFwProfile *iface,
116 REFIID riid,
117 LPOLESTR *rgszNames,
118 UINT cNames,
119 LCID lcid,
120 DISPID *rgDispId )
121 {
122 fw_profile *This = impl_from_INetFwProfile( iface );
123
124 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
125 return E_NOTIMPL;
126 }
127
128 static HRESULT WINAPI fw_profile_Invoke(
129 INetFwProfile *iface,
130 DISPID dispIdMember,
131 REFIID riid,
132 LCID lcid,
133 WORD wFlags,
134 DISPPARAMS *pDispParams,
135 VARIANT *pVarResult,
136 EXCEPINFO *pExcepInfo,
137 UINT *puArgErr )
138 {
139 fw_profile *This = impl_from_INetFwProfile( iface );
140
141 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
142 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
143 return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI fw_profile_get_Type(
147 INetFwProfile *iface,
148 NET_FW_PROFILE_TYPE *type )
149 {
150 fw_profile *This = impl_from_INetFwProfile( iface );
151
152 FIXME("%p, %p\n", This, type);
153 return E_NOTIMPL;
154 }
155
156 static HRESULT WINAPI fw_profile_get_FirewallEnabled(
157 INetFwProfile *iface,
158 VARIANT_BOOL *enabled )
159 {
160 fw_profile *This = impl_from_INetFwProfile( iface );
161
162 FIXME("%p, %p\n", This, enabled);
163
164 *enabled = VARIANT_FALSE;
165 return S_OK;
166 }
167
168 static HRESULT WINAPI fw_profile_put_FirewallEnabled(
169 INetFwProfile *iface,
170 VARIANT_BOOL enabled )
171 {
172 fw_profile *This = impl_from_INetFwProfile( iface );
173
174 FIXME("%p, %d\n", This, enabled);
175 return E_NOTIMPL;
176 }
177
178 static HRESULT WINAPI fw_profile_get_ExceptionsNotAllowed(
179 INetFwProfile *iface,
180 VARIANT_BOOL *notAllowed )
181 {
182 fw_profile *This = impl_from_INetFwProfile( iface );
183
184 FIXME("%p, %p\n", This, notAllowed);
185 return E_NOTIMPL;
186 }
187
188 static HRESULT WINAPI fw_profile_put_ExceptionsNotAllowed(
189 INetFwProfile *iface,
190 VARIANT_BOOL notAllowed )
191 {
192 fw_profile *This = impl_from_INetFwProfile( iface );
193
194 FIXME("%p, %d\n", This, notAllowed);
195 return E_NOTIMPL;
196 }
197
198 static HRESULT WINAPI fw_profile_get_NotificationsDisabled(
199 INetFwProfile *iface,
200 VARIANT_BOOL *disabled )
201 {
202 fw_profile *This = impl_from_INetFwProfile( iface );
203
204 FIXME("%p, %p\n", This, disabled);
205 return E_NOTIMPL;
206 }
207
208 static HRESULT WINAPI fw_profile_put_NotificationsDisabled(
209 INetFwProfile *iface,
210 VARIANT_BOOL disabled )
211 {
212 fw_profile *This = impl_from_INetFwProfile( iface );
213
214 FIXME("%p, %d\n", This, disabled);
215 return E_NOTIMPL;
216 }
217
218 static HRESULT WINAPI fw_profile_get_UnicastResponsesToMulticastBroadcastDisabled(
219 INetFwProfile *iface,
220 VARIANT_BOOL *disabled )
221 {
222 fw_profile *This = impl_from_INetFwProfile( iface );
223
224 FIXME("%p, %p\n", This, disabled);
225 return E_NOTIMPL;
226 }
227
228 static HRESULT WINAPI fw_profile_put_UnicastResponsesToMulticastBroadcastDisabled(
229 INetFwProfile *iface,
230 VARIANT_BOOL disabled )
231 {
232 fw_profile *This = impl_from_INetFwProfile( iface );
233
234 FIXME("%p, %d\n", This, disabled);
235 return E_NOTIMPL;
236 }
237
238 static HRESULT WINAPI fw_profile_get_RemoteAdminSettings(
239 INetFwProfile *iface,
240 INetFwRemoteAdminSettings **remoteAdminSettings )
241 {
242 fw_profile *This = impl_from_INetFwProfile( iface );
243
244 FIXME("%p, %p\n", This, remoteAdminSettings);
245 return E_NOTIMPL;
246 }
247
248 static HRESULT WINAPI fw_profile_get_IcmpSettings(
249 INetFwProfile *iface,
250 INetFwIcmpSettings **icmpSettings )
251 {
252 fw_profile *This = impl_from_INetFwProfile( iface );
253
254 FIXME("%p, %p\n", This, icmpSettings);
255 return E_NOTIMPL;
256 }
257
258 static HRESULT WINAPI fw_profile_get_GloballyOpenPorts(
259 INetFwProfile *iface,
260 INetFwOpenPorts **openPorts )
261 {
262 fw_profile *This = impl_from_INetFwProfile( iface );
263
264 TRACE("%p, %p\n", This, openPorts);
265 return NetFwOpenPorts_create( NULL, (void **)openPorts );
266 }
267
268 static HRESULT WINAPI fw_profile_get_Services(
269 INetFwProfile *iface,
270 INetFwServices **Services )
271 {
272 fw_profile *This = impl_from_INetFwProfile( iface );
273
274 TRACE("%p, %p\n", This, Services);
275 return NetFwServices_create( NULL, (void **)Services );
276 }
277
278 static HRESULT WINAPI fw_profile_get_AuthorizedApplications(
279 INetFwProfile *iface,
280 INetFwAuthorizedApplications **apps )
281 {
282 fw_profile *This = impl_from_INetFwProfile( iface );
283
284 TRACE("%p, %p\n", This, apps);
285 return NetFwAuthorizedApplications_create( NULL, (void **)apps );
286 }
287
288 static const struct INetFwProfileVtbl fw_profile_vtbl =
289 {
290 fw_profile_QueryInterface,
291 fw_profile_AddRef,
292 fw_profile_Release,
293 fw_profile_GetTypeInfoCount,
294 fw_profile_GetTypeInfo,
295 fw_profile_GetIDsOfNames,
296 fw_profile_Invoke,
297 fw_profile_get_Type,
298 fw_profile_get_FirewallEnabled,
299 fw_profile_put_FirewallEnabled,
300 fw_profile_get_ExceptionsNotAllowed,
301 fw_profile_put_ExceptionsNotAllowed,
302 fw_profile_get_NotificationsDisabled,
303 fw_profile_put_NotificationsDisabled,
304 fw_profile_get_UnicastResponsesToMulticastBroadcastDisabled,
305 fw_profile_put_UnicastResponsesToMulticastBroadcastDisabled,
306 fw_profile_get_RemoteAdminSettings,
307 fw_profile_get_IcmpSettings,
308 fw_profile_get_GloballyOpenPorts,
309 fw_profile_get_Services,
310 fw_profile_get_AuthorizedApplications
311 };
312
313 HRESULT NetFwProfile_create( IUnknown *pUnkOuter, LPVOID *ppObj )
314 {
315 fw_profile *fp;
316
317 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
318
319 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
320 if (!fp) return E_OUTOFMEMORY;
321
322 fp->vtbl = &fw_profile_vtbl;
323 fp->refs = 1;
324
325 *ppObj = &fp->vtbl;
326
327 TRACE("returning iface %p\n", *ppObj);
328 return S_OK;
329 }