d52aecc7e25046861dff9b057fca5b1aa7d2f2d5
[reactos.git] / reactos / dll / win32 / hnetcfg / port.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_port
42 {
43 INetFwOpenPort INetFwOpenPort_iface;
44 LONG refs;
45 } fw_port;
46
47 static inline fw_port *impl_from_INetFwOpenPort( INetFwOpenPort *iface )
48 {
49 return CONTAINING_RECORD(iface, fw_port, INetFwOpenPort_iface);
50 }
51
52 static ULONG WINAPI fw_port_AddRef(
53 INetFwOpenPort *iface )
54 {
55 fw_port *fw_port = impl_from_INetFwOpenPort( iface );
56 return InterlockedIncrement( &fw_port->refs );
57 }
58
59 static ULONG WINAPI fw_port_Release(
60 INetFwOpenPort *iface )
61 {
62 fw_port *fw_port = impl_from_INetFwOpenPort( iface );
63 LONG refs = InterlockedDecrement( &fw_port->refs );
64 if (!refs)
65 {
66 TRACE("destroying %p\n", fw_port);
67 HeapFree( GetProcessHeap(), 0, fw_port );
68 }
69 return refs;
70 }
71
72 static HRESULT WINAPI fw_port_QueryInterface(
73 INetFwOpenPort *iface,
74 REFIID riid,
75 void **ppvObject )
76 {
77 fw_port *This = impl_from_INetFwOpenPort( iface );
78
79 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
80
81 if ( IsEqualGUID( riid, &IID_INetFwOpenPort ) ||
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 INetFwOpenPort_AddRef( iface );
93 return S_OK;
94 }
95
96 static HRESULT WINAPI fw_port_GetTypeInfoCount(
97 INetFwOpenPort *iface,
98 UINT *pctinfo )
99 {
100 fw_port *This = impl_from_INetFwOpenPort( iface );
101
102 FIXME("%p %p\n", This, pctinfo);
103 return E_NOTIMPL;
104 }
105
106 static HRESULT WINAPI fw_port_GetTypeInfo(
107 INetFwOpenPort *iface,
108 UINT iTInfo,
109 LCID lcid,
110 ITypeInfo **ppTInfo )
111 {
112 fw_port *This = impl_from_INetFwOpenPort( iface );
113
114 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
115 return E_NOTIMPL;
116 }
117
118 static HRESULT WINAPI fw_port_GetIDsOfNames(
119 INetFwOpenPort *iface,
120 REFIID riid,
121 LPOLESTR *rgszNames,
122 UINT cNames,
123 LCID lcid,
124 DISPID *rgDispId )
125 {
126 fw_port *This = impl_from_INetFwOpenPort( 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_port_Invoke(
133 INetFwOpenPort *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_port *This = impl_from_INetFwOpenPort( 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_port_get_Name(
151 INetFwOpenPort *iface,
152 BSTR *name)
153 {
154 fw_port *This = impl_from_INetFwOpenPort( iface );
155
156 FIXME("%p %p\n", This, name);
157 return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI fw_port_put_Name(
161 INetFwOpenPort *iface,
162 BSTR name)
163 {
164 fw_port *This = impl_from_INetFwOpenPort( iface );
165
166 FIXME("%p %s\n", This, debugstr_w(name));
167 return E_NOTIMPL;
168 }
169
170 static HRESULT WINAPI fw_port_get_IpVersion(
171 INetFwOpenPort *iface,
172 NET_FW_IP_VERSION *ipVersion)
173 {
174 fw_port *This = impl_from_INetFwOpenPort( iface );
175
176 FIXME("%p %p\n", This, ipVersion);
177 return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI fw_port_put_IpVersion(
181 INetFwOpenPort *iface,
182 NET_FW_IP_VERSION ipVersion)
183 {
184 fw_port *This = impl_from_INetFwOpenPort( iface );
185
186 FIXME("%p %u\n", This, ipVersion);
187 return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI fw_port_get_Protocol(
191 INetFwOpenPort *iface,
192 NET_FW_IP_PROTOCOL *ipProtocol)
193 {
194 fw_port *This = impl_from_INetFwOpenPort( iface );
195
196 FIXME("%p %p\n", This, ipProtocol);
197 return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI fw_port_put_Protocol(
201 INetFwOpenPort *iface,
202 NET_FW_IP_PROTOCOL ipProtocol)
203 {
204 fw_port *This = impl_from_INetFwOpenPort( iface );
205
206 FIXME("%p %u\n", This, ipProtocol);
207 return E_NOTIMPL;
208 }
209
210 static HRESULT WINAPI fw_port_get_Port(
211 INetFwOpenPort *iface,
212 LONG *portNumber)
213 {
214 fw_port *This = impl_from_INetFwOpenPort( iface );
215
216 FIXME("%p %p\n", This, portNumber);
217 return E_NOTIMPL;
218 }
219
220 static HRESULT WINAPI fw_port_put_Port(
221 INetFwOpenPort *iface,
222 LONG portNumber)
223 {
224 fw_port *This = impl_from_INetFwOpenPort( iface );
225
226 FIXME("%p %d\n", This, portNumber);
227 return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI fw_port_get_Scope(
231 INetFwOpenPort *iface,
232 NET_FW_SCOPE *scope)
233 {
234 fw_port *This = impl_from_INetFwOpenPort( iface );
235
236 FIXME("%p %p\n", This, scope);
237 return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI fw_port_put_Scope(
241 INetFwOpenPort *iface,
242 NET_FW_SCOPE scope)
243 {
244 fw_port *This = impl_from_INetFwOpenPort( iface );
245
246 FIXME("%p %u\n", This, scope);
247 return E_NOTIMPL;
248 }
249
250 static HRESULT WINAPI fw_port_get_RemoteAddresses(
251 INetFwOpenPort *iface,
252 BSTR *remoteAddrs)
253 {
254 fw_port *This = impl_from_INetFwOpenPort( iface );
255
256 FIXME("%p %p\n", This, remoteAddrs);
257 return E_NOTIMPL;
258 }
259
260 static HRESULT WINAPI fw_port_put_RemoteAddresses(
261 INetFwOpenPort *iface,
262 BSTR remoteAddrs)
263 {
264 fw_port *This = impl_from_INetFwOpenPort( iface );
265
266 FIXME("%p %s\n", This, debugstr_w(remoteAddrs));
267 return E_NOTIMPL;
268 }
269
270 static HRESULT WINAPI fw_port_get_Enabled(
271 INetFwOpenPort *iface,
272 VARIANT_BOOL *enabled)
273 {
274 fw_port *This = impl_from_INetFwOpenPort( iface );
275
276 FIXME("%p %p\n", This, enabled);
277
278 *enabled = VARIANT_TRUE;
279 return S_OK;
280 }
281
282 static HRESULT WINAPI fw_port_put_Enabled(
283 INetFwOpenPort *iface,
284 VARIANT_BOOL enabled)
285 {
286 fw_port *This = impl_from_INetFwOpenPort( iface );
287
288 FIXME("%p %d\n", This, enabled);
289 return E_NOTIMPL;
290 }
291
292 static HRESULT WINAPI fw_port_get_BuiltIn(
293 INetFwOpenPort *iface,
294 VARIANT_BOOL *builtIn)
295 {
296 fw_port *This = impl_from_INetFwOpenPort( iface );
297
298 FIXME("%p %p\n", This, builtIn);
299 return E_NOTIMPL;
300 }
301
302 static const struct INetFwOpenPortVtbl fw_port_vtbl =
303 {
304 fw_port_QueryInterface,
305 fw_port_AddRef,
306 fw_port_Release,
307 fw_port_GetTypeInfoCount,
308 fw_port_GetTypeInfo,
309 fw_port_GetIDsOfNames,
310 fw_port_Invoke,
311 fw_port_get_Name,
312 fw_port_put_Name,
313 fw_port_get_IpVersion,
314 fw_port_put_IpVersion,
315 fw_port_get_Protocol,
316 fw_port_put_Protocol,
317 fw_port_get_Port,
318 fw_port_put_Port,
319 fw_port_get_Scope,
320 fw_port_put_Scope,
321 fw_port_get_RemoteAddresses,
322 fw_port_put_RemoteAddresses,
323 fw_port_get_Enabled,
324 fw_port_put_Enabled,
325 fw_port_get_BuiltIn
326 };
327
328 static HRESULT NetFwOpenPort_create( IUnknown *pUnkOuter, LPVOID *ppObj )
329 {
330 fw_port *fp;
331
332 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
333
334 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
335 if (!fp) return E_OUTOFMEMORY;
336
337 fp->INetFwOpenPort_iface.lpVtbl = &fw_port_vtbl;
338 fp->refs = 1;
339
340 *ppObj = &fp->INetFwOpenPort_iface;
341
342 TRACE("returning iface %p\n", *ppObj);
343 return S_OK;
344 }
345
346 typedef struct fw_ports
347 {
348 INetFwOpenPorts INetFwOpenPorts_iface;
349 LONG refs;
350 } fw_ports;
351
352 static inline fw_ports *impl_from_INetFwOpenPorts( INetFwOpenPorts *iface )
353 {
354 return CONTAINING_RECORD(iface, fw_ports, INetFwOpenPorts_iface);
355 }
356
357 static ULONG WINAPI fw_ports_AddRef(
358 INetFwOpenPorts *iface )
359 {
360 fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
361 return InterlockedIncrement( &fw_ports->refs );
362 }
363
364 static ULONG WINAPI fw_ports_Release(
365 INetFwOpenPorts *iface )
366 {
367 fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
368 LONG refs = InterlockedDecrement( &fw_ports->refs );
369 if (!refs)
370 {
371 TRACE("destroying %p\n", fw_ports);
372 HeapFree( GetProcessHeap(), 0, fw_ports );
373 }
374 return refs;
375 }
376
377 static HRESULT WINAPI fw_ports_QueryInterface(
378 INetFwOpenPorts *iface,
379 REFIID riid,
380 void **ppvObject )
381 {
382 fw_ports *This = impl_from_INetFwOpenPorts( iface );
383
384 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
385
386 if ( IsEqualGUID( riid, &IID_INetFwOpenPorts ) ||
387 IsEqualGUID( riid, &IID_IDispatch ) ||
388 IsEqualGUID( riid, &IID_IUnknown ) )
389 {
390 *ppvObject = iface;
391 }
392 else
393 {
394 FIXME("interface %s not implemented\n", debugstr_guid(riid));
395 return E_NOINTERFACE;
396 }
397 INetFwOpenPorts_AddRef( iface );
398 return S_OK;
399 }
400
401 static HRESULT WINAPI fw_ports_GetTypeInfoCount(
402 INetFwOpenPorts *iface,
403 UINT *pctinfo )
404 {
405 fw_ports *This = impl_from_INetFwOpenPorts( iface );
406
407 FIXME("%p %p\n", This, pctinfo);
408 return E_NOTIMPL;
409 }
410
411 static HRESULT WINAPI fw_ports_GetTypeInfo(
412 INetFwOpenPorts *iface,
413 UINT iTInfo,
414 LCID lcid,
415 ITypeInfo **ppTInfo )
416 {
417 fw_ports *This = impl_from_INetFwOpenPorts( iface );
418
419 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
420 return E_NOTIMPL;
421 }
422
423 static HRESULT WINAPI fw_ports_GetIDsOfNames(
424 INetFwOpenPorts *iface,
425 REFIID riid,
426 LPOLESTR *rgszNames,
427 UINT cNames,
428 LCID lcid,
429 DISPID *rgDispId )
430 {
431 fw_ports *This = impl_from_INetFwOpenPorts( iface );
432
433 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
434 return E_NOTIMPL;
435 }
436
437 static HRESULT WINAPI fw_ports_Invoke(
438 INetFwOpenPorts *iface,
439 DISPID dispIdMember,
440 REFIID riid,
441 LCID lcid,
442 WORD wFlags,
443 DISPPARAMS *pDispParams,
444 VARIANT *pVarResult,
445 EXCEPINFO *pExcepInfo,
446 UINT *puArgErr )
447 {
448 fw_ports *This = impl_from_INetFwOpenPorts( iface );
449
450 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
451 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
452 return E_NOTIMPL;
453 }
454
455 static HRESULT WINAPI fw_ports_get_Count(
456 INetFwOpenPorts *iface,
457 LONG *count)
458 {
459 fw_ports *This = impl_from_INetFwOpenPorts( iface );
460
461 FIXME("%p, %p\n", This, count);
462
463 *count = 0;
464 return S_OK;
465 }
466
467 static HRESULT WINAPI fw_ports_Add(
468 INetFwOpenPorts *iface,
469 INetFwOpenPort *port)
470 {
471 fw_ports *This = impl_from_INetFwOpenPorts( iface );
472
473 FIXME("%p, %p\n", This, port);
474 return E_NOTIMPL;
475 }
476
477 static HRESULT WINAPI fw_ports_Remove(
478 INetFwOpenPorts *iface,
479 LONG portNumber,
480 NET_FW_IP_PROTOCOL ipProtocol)
481 {
482 fw_ports *This = impl_from_INetFwOpenPorts( iface );
483
484 FIXME("%p, %d, %u\n", This, portNumber, ipProtocol);
485 return E_NOTIMPL;
486 }
487
488 static HRESULT WINAPI fw_ports_Item(
489 INetFwOpenPorts *iface,
490 LONG portNumber,
491 NET_FW_IP_PROTOCOL ipProtocol,
492 INetFwOpenPort **openPort)
493 {
494 HRESULT hr;
495 fw_ports *This = impl_from_INetFwOpenPorts( iface );
496
497 FIXME("%p, %d, %u, %p\n", This, portNumber, ipProtocol, openPort);
498
499 hr = NetFwOpenPort_create( NULL, (void **)openPort );
500 if (SUCCEEDED(hr))
501 {
502 INetFwOpenPort_put_Protocol( *openPort, ipProtocol );
503 INetFwOpenPort_put_Port( *openPort, portNumber );
504 }
505 return hr;
506 }
507
508 static HRESULT WINAPI fw_ports_get__NewEnum(
509 INetFwOpenPorts *iface,
510 IUnknown **newEnum)
511 {
512 fw_ports *This = impl_from_INetFwOpenPorts( iface );
513
514 FIXME("%p, %p\n", This, newEnum);
515 return E_NOTIMPL;
516 }
517
518 static const struct INetFwOpenPortsVtbl fw_ports_vtbl =
519 {
520 fw_ports_QueryInterface,
521 fw_ports_AddRef,
522 fw_ports_Release,
523 fw_ports_GetTypeInfoCount,
524 fw_ports_GetTypeInfo,
525 fw_ports_GetIDsOfNames,
526 fw_ports_Invoke,
527 fw_ports_get_Count,
528 fw_ports_Add,
529 fw_ports_Remove,
530 fw_ports_Item,
531 fw_ports_get__NewEnum
532 };
533
534 HRESULT NetFwOpenPorts_create( IUnknown *pUnkOuter, LPVOID *ppObj )
535 {
536 fw_ports *fp;
537
538 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
539
540 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
541 if (!fp) return E_OUTOFMEMORY;
542
543 fp->INetFwOpenPorts_iface.lpVtbl = &fw_ports_vtbl;
544 fp->refs = 1;
545
546 *ppObj = &fp->INetFwOpenPorts_iface;
547
548 TRACE("returning iface %p\n", *ppObj);
549 return S_OK;
550 }