2 * Copyright 2009 Hans Leidekker for CodeWeavers
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.
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.
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
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
33 #include "hnetcfg_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg
);
37 typedef struct fw_port
39 INetFwOpenPort INetFwOpenPort_iface
;
42 NET_FW_IP_PROTOCOL protocol
;
46 static inline fw_port
*impl_from_INetFwOpenPort( INetFwOpenPort
*iface
)
48 return CONTAINING_RECORD(iface
, fw_port
, INetFwOpenPort_iface
);
51 static ULONG WINAPI
fw_port_AddRef(
52 INetFwOpenPort
*iface
)
54 fw_port
*fw_port
= impl_from_INetFwOpenPort( iface
);
55 return InterlockedIncrement( &fw_port
->refs
);
58 static ULONG WINAPI
fw_port_Release(
59 INetFwOpenPort
*iface
)
61 fw_port
*fw_port
= impl_from_INetFwOpenPort( iface
);
62 LONG refs
= InterlockedDecrement( &fw_port
->refs
);
65 TRACE("destroying %p\n", fw_port
);
66 SysFreeString( fw_port
->name
);
67 HeapFree( GetProcessHeap(), 0, fw_port
);
72 static HRESULT WINAPI
fw_port_QueryInterface(
73 INetFwOpenPort
*iface
,
77 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
79 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
81 if ( IsEqualGUID( riid
, &IID_INetFwOpenPort
) ||
82 IsEqualGUID( riid
, &IID_IDispatch
) ||
83 IsEqualGUID( riid
, &IID_IUnknown
) )
89 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
92 INetFwOpenPort_AddRef( iface
);
96 static HRESULT WINAPI
fw_port_GetTypeInfoCount(
97 INetFwOpenPort
*iface
,
100 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
102 TRACE("%p %p\n", This
, pctinfo
);
107 static HRESULT WINAPI
fw_port_GetTypeInfo(
108 INetFwOpenPort
*iface
,
111 ITypeInfo
**ppTInfo
)
113 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
115 TRACE("%p %u %u %p\n", This
, iTInfo
, lcid
, ppTInfo
);
116 return get_typeinfo( INetFwOpenPort_tid
, ppTInfo
);
119 static HRESULT WINAPI
fw_port_GetIDsOfNames(
120 INetFwOpenPort
*iface
,
127 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
131 TRACE("%p %s %p %u %u %p\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
133 hr
= get_typeinfo( INetFwOpenPort_tid
, &typeinfo
);
136 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, rgszNames
, cNames
, rgDispId
);
137 ITypeInfo_Release( typeinfo
);
142 static HRESULT WINAPI
fw_port_Invoke(
143 INetFwOpenPort
*iface
,
148 DISPPARAMS
*pDispParams
,
150 EXCEPINFO
*pExcepInfo
,
153 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
157 TRACE("%p %d %s %d %d %p %p %p %p\n", This
, dispIdMember
, debugstr_guid(riid
),
158 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
160 hr
= get_typeinfo( INetFwOpenPort_tid
, &typeinfo
);
163 hr
= ITypeInfo_Invoke( typeinfo
, &This
->INetFwOpenPort_iface
, dispIdMember
,
164 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
165 ITypeInfo_Release( typeinfo
);
170 static HRESULT WINAPI
fw_port_get_Name(
171 INetFwOpenPort
*iface
,
174 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
176 FIXME("%p %p\n", This
, name
);
180 static HRESULT WINAPI
fw_port_put_Name(
181 INetFwOpenPort
*iface
,
184 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
186 TRACE("%p %s\n", This
, debugstr_w(name
));
188 if (!(name
= SysAllocString( name
)))
189 return E_OUTOFMEMORY
;
191 SysFreeString( This
->name
);
196 static HRESULT WINAPI
fw_port_get_IpVersion(
197 INetFwOpenPort
*iface
,
198 NET_FW_IP_VERSION
*ipVersion
)
200 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
202 FIXME("%p %p\n", This
, ipVersion
);
206 static HRESULT WINAPI
fw_port_put_IpVersion(
207 INetFwOpenPort
*iface
,
208 NET_FW_IP_VERSION ipVersion
)
210 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
212 FIXME("%p %u\n", This
, ipVersion
);
216 static HRESULT WINAPI
fw_port_get_Protocol(
217 INetFwOpenPort
*iface
,
218 NET_FW_IP_PROTOCOL
*ipProtocol
)
220 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
222 FIXME("%p %p\n", This
, ipProtocol
);
226 static HRESULT WINAPI
fw_port_put_Protocol(
227 INetFwOpenPort
*iface
,
228 NET_FW_IP_PROTOCOL ipProtocol
)
230 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
232 TRACE("%p %u\n", This
, ipProtocol
);
234 if (ipProtocol
!= NET_FW_IP_PROTOCOL_TCP
&& ipProtocol
!= NET_FW_IP_PROTOCOL_UDP
)
237 This
->protocol
= ipProtocol
;
241 static HRESULT WINAPI
fw_port_get_Port(
242 INetFwOpenPort
*iface
,
245 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
247 FIXME("%p %p\n", This
, portNumber
);
251 static HRESULT WINAPI
fw_port_put_Port(
252 INetFwOpenPort
*iface
,
255 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
257 TRACE("%p %d\n", This
, portNumber
);
258 This
->port
= portNumber
;
262 static HRESULT WINAPI
fw_port_get_Scope(
263 INetFwOpenPort
*iface
,
266 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
268 FIXME("%p %p\n", This
, scope
);
272 static HRESULT WINAPI
fw_port_put_Scope(
273 INetFwOpenPort
*iface
,
276 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
278 FIXME("%p %u\n", This
, scope
);
282 static HRESULT WINAPI
fw_port_get_RemoteAddresses(
283 INetFwOpenPort
*iface
,
286 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
288 FIXME("%p %p\n", This
, remoteAddrs
);
292 static HRESULT WINAPI
fw_port_put_RemoteAddresses(
293 INetFwOpenPort
*iface
,
296 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
298 FIXME("%p %s\n", This
, debugstr_w(remoteAddrs
));
302 static HRESULT WINAPI
fw_port_get_Enabled(
303 INetFwOpenPort
*iface
,
304 VARIANT_BOOL
*enabled
)
306 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
308 FIXME("%p %p\n", This
, enabled
);
310 *enabled
= VARIANT_TRUE
;
314 static HRESULT WINAPI
fw_port_put_Enabled(
315 INetFwOpenPort
*iface
,
316 VARIANT_BOOL enabled
)
318 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
320 FIXME("%p %d\n", This
, enabled
);
324 static HRESULT WINAPI
fw_port_get_BuiltIn(
325 INetFwOpenPort
*iface
,
326 VARIANT_BOOL
*builtIn
)
328 fw_port
*This
= impl_from_INetFwOpenPort( iface
);
330 FIXME("%p %p\n", This
, builtIn
);
334 static const struct INetFwOpenPortVtbl fw_port_vtbl
=
336 fw_port_QueryInterface
,
339 fw_port_GetTypeInfoCount
,
341 fw_port_GetIDsOfNames
,
345 fw_port_get_IpVersion
,
346 fw_port_put_IpVersion
,
347 fw_port_get_Protocol
,
348 fw_port_put_Protocol
,
353 fw_port_get_RemoteAddresses
,
354 fw_port_put_RemoteAddresses
,
360 HRESULT
NetFwOpenPort_create( IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
364 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
366 fp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fp
) );
367 if (!fp
) return E_OUTOFMEMORY
;
369 fp
->INetFwOpenPort_iface
.lpVtbl
= &fw_port_vtbl
;
372 fp
->protocol
= NET_FW_IP_PROTOCOL_TCP
;
375 *ppObj
= &fp
->INetFwOpenPort_iface
;
377 TRACE("returning iface %p\n", *ppObj
);
381 typedef struct fw_ports
383 INetFwOpenPorts INetFwOpenPorts_iface
;
387 static inline fw_ports
*impl_from_INetFwOpenPorts( INetFwOpenPorts
*iface
)
389 return CONTAINING_RECORD(iface
, fw_ports
, INetFwOpenPorts_iface
);
392 static ULONG WINAPI
fw_ports_AddRef(
393 INetFwOpenPorts
*iface
)
395 fw_ports
*fw_ports
= impl_from_INetFwOpenPorts( iface
);
396 return InterlockedIncrement( &fw_ports
->refs
);
399 static ULONG WINAPI
fw_ports_Release(
400 INetFwOpenPorts
*iface
)
402 fw_ports
*fw_ports
= impl_from_INetFwOpenPorts( iface
);
403 LONG refs
= InterlockedDecrement( &fw_ports
->refs
);
406 TRACE("destroying %p\n", fw_ports
);
407 HeapFree( GetProcessHeap(), 0, fw_ports
);
412 static HRESULT WINAPI
fw_ports_QueryInterface(
413 INetFwOpenPorts
*iface
,
417 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
419 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
421 if ( IsEqualGUID( riid
, &IID_INetFwOpenPorts
) ||
422 IsEqualGUID( riid
, &IID_IDispatch
) ||
423 IsEqualGUID( riid
, &IID_IUnknown
) )
429 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
430 return E_NOINTERFACE
;
432 INetFwOpenPorts_AddRef( iface
);
436 static HRESULT WINAPI
fw_ports_GetTypeInfoCount(
437 INetFwOpenPorts
*iface
,
440 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
442 TRACE("%p %p\n", This
, pctinfo
);
447 static HRESULT WINAPI
fw_ports_GetTypeInfo(
448 INetFwOpenPorts
*iface
,
451 ITypeInfo
**ppTInfo
)
453 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
455 TRACE("%p %u %u %p\n", This
, iTInfo
, lcid
, ppTInfo
);
456 return get_typeinfo( INetFwOpenPorts_tid
, ppTInfo
);
459 static HRESULT WINAPI
fw_ports_GetIDsOfNames(
460 INetFwOpenPorts
*iface
,
467 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
471 TRACE("%p %s %p %u %u %p\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
473 hr
= get_typeinfo( INetFwOpenPorts_tid
, &typeinfo
);
476 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, rgszNames
, cNames
, rgDispId
);
477 ITypeInfo_Release( typeinfo
);
482 static HRESULT WINAPI
fw_ports_Invoke(
483 INetFwOpenPorts
*iface
,
488 DISPPARAMS
*pDispParams
,
490 EXCEPINFO
*pExcepInfo
,
493 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
497 TRACE("%p %d %s %d %d %p %p %p %p\n", This
, dispIdMember
, debugstr_guid(riid
),
498 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
500 hr
= get_typeinfo( INetFwOpenPorts_tid
, &typeinfo
);
503 hr
= ITypeInfo_Invoke( typeinfo
, &This
->INetFwOpenPorts_iface
, dispIdMember
,
504 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
505 ITypeInfo_Release( typeinfo
);
510 static HRESULT WINAPI
fw_ports_get_Count(
511 INetFwOpenPorts
*iface
,
514 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
516 FIXME("%p, %p\n", This
, count
);
522 static HRESULT WINAPI
fw_ports_Add(
523 INetFwOpenPorts
*iface
,
524 INetFwOpenPort
*port
)
526 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
528 FIXME("%p, %p\n", This
, port
);
532 static HRESULT WINAPI
fw_ports_Remove(
533 INetFwOpenPorts
*iface
,
535 NET_FW_IP_PROTOCOL ipProtocol
)
537 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
539 FIXME("%p, %d, %u\n", This
, portNumber
, ipProtocol
);
543 static HRESULT WINAPI
fw_ports_Item(
544 INetFwOpenPorts
*iface
,
546 NET_FW_IP_PROTOCOL ipProtocol
,
547 INetFwOpenPort
**openPort
)
550 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
552 FIXME("%p, %d, %u, %p\n", This
, portNumber
, ipProtocol
, openPort
);
554 hr
= NetFwOpenPort_create( NULL
, (void **)openPort
);
557 INetFwOpenPort_put_Protocol( *openPort
, ipProtocol
);
558 INetFwOpenPort_put_Port( *openPort
, portNumber
);
563 static HRESULT WINAPI
fw_ports_get__NewEnum(
564 INetFwOpenPorts
*iface
,
567 fw_ports
*This
= impl_from_INetFwOpenPorts( iface
);
569 FIXME("%p, %p\n", This
, newEnum
);
573 static const struct INetFwOpenPortsVtbl fw_ports_vtbl
=
575 fw_ports_QueryInterface
,
578 fw_ports_GetTypeInfoCount
,
579 fw_ports_GetTypeInfo
,
580 fw_ports_GetIDsOfNames
,
586 fw_ports_get__NewEnum
589 HRESULT
NetFwOpenPorts_create( IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
593 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
595 fp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fp
) );
596 if (!fp
) return E_OUTOFMEMORY
;
598 fp
->INetFwOpenPorts_iface
.lpVtbl
= &fw_ports_vtbl
;
601 *ppObj
= &fp
->INetFwOpenPorts_iface
;
603 TRACE("returning iface %p\n", *ppObj
);