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