* Sync up to trunk r55544.
[reactos.git] / dll / win32 / hnetcfg / service.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_service
38 {
39 INetFwService INetFwService_iface;
40 LONG refs;
41 } fw_service;
42
43 static inline fw_service *impl_from_INetFwService( INetFwService *iface )
44 {
45 return CONTAINING_RECORD(iface, fw_service, INetFwService_iface);
46 }
47
48 static ULONG WINAPI fw_service_AddRef(
49 INetFwService *iface )
50 {
51 fw_service *fw_service = impl_from_INetFwService( iface );
52 return InterlockedIncrement( &fw_service->refs );
53 }
54
55 static ULONG WINAPI fw_service_Release(
56 INetFwService *iface )
57 {
58 fw_service *fw_service = impl_from_INetFwService( iface );
59 LONG refs = InterlockedDecrement( &fw_service->refs );
60 if (!refs)
61 {
62 TRACE("destroying %p\n", fw_service);
63 HeapFree( GetProcessHeap(), 0, fw_service );
64 }
65 return refs;
66 }
67
68 static HRESULT WINAPI fw_service_QueryInterface(
69 INetFwService *iface,
70 REFIID riid,
71 void **ppvObject )
72 {
73 fw_service *This = impl_from_INetFwService( iface );
74
75 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
76
77 if ( IsEqualGUID( riid, &IID_INetFwService ) ||
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 INetFwService_AddRef( iface );
89 return S_OK;
90 }
91
92 static HRESULT WINAPI fw_service_GetTypeInfoCount(
93 INetFwService *iface,
94 UINT *pctinfo )
95 {
96 fw_service *This = impl_from_INetFwService( iface );
97
98 FIXME("%p %p\n", This, pctinfo);
99 return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI fw_service_GetTypeInfo(
103 INetFwService *iface,
104 UINT iTInfo,
105 LCID lcid,
106 ITypeInfo **ppTInfo )
107 {
108 fw_service *This = impl_from_INetFwService( iface );
109
110 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
111 return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI fw_service_GetIDsOfNames(
115 INetFwService *iface,
116 REFIID riid,
117 LPOLESTR *rgszNames,
118 UINT cNames,
119 LCID lcid,
120 DISPID *rgDispId )
121 {
122 fw_service *This = impl_from_INetFwService( 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_service_Invoke(
129 INetFwService *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_service *This = impl_from_INetFwService( 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_service_get_Name(
147 INetFwService *iface,
148 BSTR *name )
149 {
150 fw_service *This = impl_from_INetFwService( iface );
151
152 FIXME("%p %p\n", This, name);
153 return E_NOTIMPL;
154 }
155
156 static HRESULT WINAPI fw_service_get_Type(
157 INetFwService *iface,
158 NET_FW_SERVICE_TYPE *type )
159 {
160 fw_service *This = impl_from_INetFwService( iface );
161
162 FIXME("%p %p\n", This, type);
163 return E_NOTIMPL;
164 }
165
166 static HRESULT WINAPI fw_service_get_Customized(
167 INetFwService *iface,
168 VARIANT_BOOL *customized )
169 {
170 fw_service *This = impl_from_INetFwService( iface );
171
172 FIXME("%p %p\n", This, customized);
173 return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI fw_service_get_IpVersion(
177 INetFwService *iface,
178 NET_FW_IP_VERSION *ipVersion )
179 {
180 fw_service *This = impl_from_INetFwService( iface );
181
182 FIXME("%p %p\n", This, ipVersion);
183 return E_NOTIMPL;
184 }
185
186 static HRESULT WINAPI fw_service_put_IpVersion(
187 INetFwService *iface,
188 NET_FW_IP_VERSION ipVersion )
189 {
190 fw_service *This = impl_from_INetFwService( iface );
191
192 FIXME("%p %u\n", This, ipVersion);
193 return E_NOTIMPL;
194 }
195
196 static HRESULT WINAPI fw_service_get_Scope(
197 INetFwService *iface,
198 NET_FW_SCOPE *scope )
199 {
200 fw_service *This = impl_from_INetFwService( iface );
201
202 FIXME("%p %p\n", This, scope);
203 return E_NOTIMPL;
204 }
205
206 static HRESULT WINAPI fw_service_put_Scope(
207 INetFwService *iface,
208 NET_FW_SCOPE scope )
209 {
210 fw_service *This = impl_from_INetFwService( iface );
211
212 FIXME("%p %u\n", This, scope);
213 return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI fw_service_get_RemoteAddresses(
217 INetFwService *iface,
218 BSTR *remoteAddrs )
219 {
220 fw_service *This = impl_from_INetFwService( iface );
221
222 FIXME("%p %p\n", This, remoteAddrs);
223 return E_NOTIMPL;
224 }
225
226 static HRESULT WINAPI fw_service_put_RemoteAddresses(
227 INetFwService *iface,
228 BSTR remoteAddrs )
229 {
230 fw_service *This = impl_from_INetFwService( iface );
231
232 FIXME("%p %s\n", This, debugstr_w(remoteAddrs));
233 return E_NOTIMPL;
234 }
235
236 static HRESULT WINAPI fw_service_get_Enabled(
237 INetFwService *iface,
238 VARIANT_BOOL *enabled )
239 {
240 fw_service *This = impl_from_INetFwService( iface );
241
242 FIXME("%p %p\n", This, enabled);
243 return E_NOTIMPL;
244 }
245
246 static HRESULT WINAPI fw_service_put_Enabled(
247 INetFwService *iface,
248 VARIANT_BOOL enabled )
249 {
250 fw_service *This = impl_from_INetFwService( iface );
251
252 FIXME("%p %d\n", This, enabled);
253 return E_NOTIMPL;
254 }
255
256 static HRESULT WINAPI fw_service_get_GloballyOpenPorts(
257 INetFwService *iface,
258 INetFwOpenPorts **openPorts )
259 {
260 fw_service *This = impl_from_INetFwService( iface );
261
262 TRACE("%p %p\n", This, openPorts);
263 return NetFwOpenPorts_create( NULL, (void **)openPorts );
264 }
265
266 static const struct INetFwServiceVtbl fw_service_vtbl =
267 {
268 fw_service_QueryInterface,
269 fw_service_AddRef,
270 fw_service_Release,
271 fw_service_GetTypeInfoCount,
272 fw_service_GetTypeInfo,
273 fw_service_GetIDsOfNames,
274 fw_service_Invoke,
275 fw_service_get_Name,
276 fw_service_get_Type,
277 fw_service_get_Customized,
278 fw_service_get_IpVersion,
279 fw_service_put_IpVersion,
280 fw_service_get_Scope,
281 fw_service_put_Scope,
282 fw_service_get_RemoteAddresses,
283 fw_service_put_RemoteAddresses,
284 fw_service_get_Enabled,
285 fw_service_put_Enabled,
286 fw_service_get_GloballyOpenPorts
287 };
288
289 static HRESULT NetFwService_create( IUnknown *pUnkOuter, LPVOID *ppObj )
290 {
291 fw_service *fp;
292
293 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
294
295 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
296 if (!fp) return E_OUTOFMEMORY;
297
298 fp->INetFwService_iface.lpVtbl = &fw_service_vtbl;
299 fp->refs = 1;
300
301 *ppObj = &fp->INetFwService_iface;
302
303 TRACE("returning iface %p\n", *ppObj);
304 return S_OK;
305 }
306
307 typedef struct fw_services
308 {
309 INetFwServices INetFwServices_iface;
310 LONG refs;
311 } fw_services;
312
313 static inline fw_services *impl_from_INetFwServices( INetFwServices *iface )
314 {
315 return CONTAINING_RECORD(iface, fw_services, INetFwServices_iface);
316 }
317
318 static ULONG WINAPI fw_services_AddRef(
319 INetFwServices *iface )
320 {
321 fw_services *fw_services = impl_from_INetFwServices( iface );
322 return InterlockedIncrement( &fw_services->refs );
323 }
324
325 static ULONG WINAPI fw_services_Release(
326 INetFwServices *iface )
327 {
328 fw_services *fw_services = impl_from_INetFwServices( iface );
329 LONG refs = InterlockedDecrement( &fw_services->refs );
330 if (!refs)
331 {
332 TRACE("destroying %p\n", fw_services);
333 HeapFree( GetProcessHeap(), 0, fw_services );
334 }
335 return refs;
336 }
337
338 static HRESULT WINAPI fw_services_QueryInterface(
339 INetFwServices *iface,
340 REFIID riid,
341 void **ppvObject )
342 {
343 fw_services *This = impl_from_INetFwServices( iface );
344
345 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
346
347 if ( IsEqualGUID( riid, &IID_INetFwServices ) ||
348 IsEqualGUID( riid, &IID_IDispatch ) ||
349 IsEqualGUID( riid, &IID_IUnknown ) )
350 {
351 *ppvObject = iface;
352 }
353 else
354 {
355 FIXME("interface %s not implemented\n", debugstr_guid(riid));
356 return E_NOINTERFACE;
357 }
358 INetFwServices_AddRef( iface );
359 return S_OK;
360 }
361
362 static HRESULT WINAPI fw_services_GetTypeInfoCount(
363 INetFwServices *iface,
364 UINT *pctinfo )
365 {
366 fw_services *This = impl_from_INetFwServices( iface );
367
368 FIXME("%p %p\n", This, pctinfo);
369 return E_NOTIMPL;
370 }
371
372 static HRESULT WINAPI fw_services_GetTypeInfo(
373 INetFwServices *iface,
374 UINT iTInfo,
375 LCID lcid,
376 ITypeInfo **ppTInfo )
377 {
378 fw_services *This = impl_from_INetFwServices( iface );
379
380 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
381 return E_NOTIMPL;
382 }
383
384 static HRESULT WINAPI fw_services_GetIDsOfNames(
385 INetFwServices *iface,
386 REFIID riid,
387 LPOLESTR *rgszNames,
388 UINT cNames,
389 LCID lcid,
390 DISPID *rgDispId )
391 {
392 fw_services *This = impl_from_INetFwServices( iface );
393
394 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
395 return E_NOTIMPL;
396 }
397
398 static HRESULT WINAPI fw_services_Invoke(
399 INetFwServices *iface,
400 DISPID dispIdMember,
401 REFIID riid,
402 LCID lcid,
403 WORD wFlags,
404 DISPPARAMS *pDispParams,
405 VARIANT *pVarResult,
406 EXCEPINFO *pExcepInfo,
407 UINT *puArgErr )
408 {
409 fw_services *This = impl_from_INetFwServices( iface );
410
411 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
412 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
413 return E_NOTIMPL;
414 }
415
416 static HRESULT WINAPI fw_services_get_Count(
417 INetFwServices *iface,
418 LONG *count )
419 {
420 fw_services *This = impl_from_INetFwServices( iface );
421
422 FIXME("%p, %p\n", This, count);
423
424 *count = 0;
425 return S_OK;
426 }
427
428 static HRESULT WINAPI fw_services_Item(
429 INetFwServices *iface,
430 NET_FW_SERVICE_TYPE svcType,
431 INetFwService **service )
432 {
433 fw_services *This = impl_from_INetFwServices( iface );
434
435 FIXME("%p, %u, %p\n", This, svcType, service);
436 return NetFwService_create( NULL, (void **)service );
437 }
438
439 static HRESULT WINAPI fw_services_get__NewEnum(
440 INetFwServices *iface,
441 IUnknown **newEnum )
442 {
443 fw_services *This = impl_from_INetFwServices( iface );
444
445 FIXME("%p, %p\n", This, newEnum);
446 return E_NOTIMPL;
447 }
448
449 static const struct INetFwServicesVtbl fw_services_vtbl =
450 {
451 fw_services_QueryInterface,
452 fw_services_AddRef,
453 fw_services_Release,
454 fw_services_GetTypeInfoCount,
455 fw_services_GetTypeInfo,
456 fw_services_GetIDsOfNames,
457 fw_services_Invoke,
458 fw_services_get_Count,
459 fw_services_Item,
460 fw_services_get__NewEnum
461 };
462
463 HRESULT NetFwServices_create( IUnknown *pUnkOuter, LPVOID *ppObj )
464 {
465 fw_services *fp;
466
467 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
468
469 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
470 if (!fp) return E_OUTOFMEMORY;
471
472 fp->INetFwServices_iface.lpVtbl = &fw_services_vtbl;
473 fp->refs = 1;
474
475 *ppObj = &fp->INetFwServices_iface;
476
477 TRACE("returning iface %p\n", *ppObj);
478 return S_OK;
479 }