hnetcfg: Add typeinfo support to INetFwOpenPort.
[wine/multimedia.git] / dlls / hnetcfg / port.c
blob8468d308a19e54955cfe8c8a9075294d8a230453
1 /*
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
19 #include "config.h"
20 #include <stdarg.h>
21 #include <stdio.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "netfw.h"
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;
40 LONG refs;
41 } fw_port;
43 static inline fw_port *impl_from_INetFwOpenPort( INetFwOpenPort *iface )
45 return CONTAINING_RECORD(iface, fw_port, INetFwOpenPort_iface);
48 static ULONG WINAPI fw_port_AddRef(
49 INetFwOpenPort *iface )
51 fw_port *fw_port = impl_from_INetFwOpenPort( iface );
52 return InterlockedIncrement( &fw_port->refs );
55 static ULONG WINAPI fw_port_Release(
56 INetFwOpenPort *iface )
58 fw_port *fw_port = impl_from_INetFwOpenPort( iface );
59 LONG refs = InterlockedDecrement( &fw_port->refs );
60 if (!refs)
62 TRACE("destroying %p\n", fw_port);
63 HeapFree( GetProcessHeap(), 0, fw_port );
65 return refs;
68 static HRESULT WINAPI fw_port_QueryInterface(
69 INetFwOpenPort *iface,
70 REFIID riid,
71 void **ppvObject )
73 fw_port *This = impl_from_INetFwOpenPort( iface );
75 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
77 if ( IsEqualGUID( riid, &IID_INetFwOpenPort ) ||
78 IsEqualGUID( riid, &IID_IDispatch ) ||
79 IsEqualGUID( riid, &IID_IUnknown ) )
81 *ppvObject = iface;
83 else
85 FIXME("interface %s not implemented\n", debugstr_guid(riid));
86 return E_NOINTERFACE;
88 INetFwOpenPort_AddRef( iface );
89 return S_OK;
92 static HRESULT WINAPI fw_port_GetTypeInfoCount(
93 INetFwOpenPort *iface,
94 UINT *pctinfo )
96 fw_port *This = impl_from_INetFwOpenPort( iface );
98 TRACE("%p %p\n", This, pctinfo);
99 *pctinfo = 1;
100 return S_OK;
103 static HRESULT WINAPI fw_port_GetTypeInfo(
104 INetFwOpenPort *iface,
105 UINT iTInfo,
106 LCID lcid,
107 ITypeInfo **ppTInfo )
109 fw_port *This = impl_from_INetFwOpenPort( iface );
111 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
112 return get_typeinfo( INetFwOpenPort_tid, ppTInfo );
115 static HRESULT WINAPI fw_port_GetIDsOfNames(
116 INetFwOpenPort *iface,
117 REFIID riid,
118 LPOLESTR *rgszNames,
119 UINT cNames,
120 LCID lcid,
121 DISPID *rgDispId )
123 fw_port *This = impl_from_INetFwOpenPort( iface );
124 ITypeInfo *typeinfo;
125 HRESULT hr;
127 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
129 hr = get_typeinfo( INetFwOpenPort_tid, &typeinfo );
130 if (SUCCEEDED(hr))
132 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
133 ITypeInfo_Release( typeinfo );
135 return hr;
138 static HRESULT WINAPI fw_port_Invoke(
139 INetFwOpenPort *iface,
140 DISPID dispIdMember,
141 REFIID riid,
142 LCID lcid,
143 WORD wFlags,
144 DISPPARAMS *pDispParams,
145 VARIANT *pVarResult,
146 EXCEPINFO *pExcepInfo,
147 UINT *puArgErr )
149 fw_port *This = impl_from_INetFwOpenPort( iface );
150 ITypeInfo *typeinfo;
151 HRESULT hr;
153 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
154 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
156 hr = get_typeinfo( INetFwOpenPort_tid, &typeinfo );
157 if (SUCCEEDED(hr))
159 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwOpenPort_iface, dispIdMember,
160 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
161 ITypeInfo_Release( typeinfo );
163 return hr;
166 static HRESULT WINAPI fw_port_get_Name(
167 INetFwOpenPort *iface,
168 BSTR *name)
170 fw_port *This = impl_from_INetFwOpenPort( iface );
172 FIXME("%p %p\n", This, name);
173 return E_NOTIMPL;
176 static HRESULT WINAPI fw_port_put_Name(
177 INetFwOpenPort *iface,
178 BSTR name)
180 fw_port *This = impl_from_INetFwOpenPort( iface );
182 FIXME("%p %s\n", This, debugstr_w(name));
183 return E_NOTIMPL;
186 static HRESULT WINAPI fw_port_get_IpVersion(
187 INetFwOpenPort *iface,
188 NET_FW_IP_VERSION *ipVersion)
190 fw_port *This = impl_from_INetFwOpenPort( iface );
192 FIXME("%p %p\n", This, ipVersion);
193 return E_NOTIMPL;
196 static HRESULT WINAPI fw_port_put_IpVersion(
197 INetFwOpenPort *iface,
198 NET_FW_IP_VERSION ipVersion)
200 fw_port *This = impl_from_INetFwOpenPort( iface );
202 FIXME("%p %u\n", This, ipVersion);
203 return E_NOTIMPL;
206 static HRESULT WINAPI fw_port_get_Protocol(
207 INetFwOpenPort *iface,
208 NET_FW_IP_PROTOCOL *ipProtocol)
210 fw_port *This = impl_from_INetFwOpenPort( iface );
212 FIXME("%p %p\n", This, ipProtocol);
213 return E_NOTIMPL;
216 static HRESULT WINAPI fw_port_put_Protocol(
217 INetFwOpenPort *iface,
218 NET_FW_IP_PROTOCOL ipProtocol)
220 fw_port *This = impl_from_INetFwOpenPort( iface );
222 FIXME("%p %u\n", This, ipProtocol);
223 return E_NOTIMPL;
226 static HRESULT WINAPI fw_port_get_Port(
227 INetFwOpenPort *iface,
228 LONG *portNumber)
230 fw_port *This = impl_from_INetFwOpenPort( iface );
232 FIXME("%p %p\n", This, portNumber);
233 return E_NOTIMPL;
236 static HRESULT WINAPI fw_port_put_Port(
237 INetFwOpenPort *iface,
238 LONG portNumber)
240 fw_port *This = impl_from_INetFwOpenPort( iface );
242 FIXME("%p %d\n", This, portNumber);
243 return E_NOTIMPL;
246 static HRESULT WINAPI fw_port_get_Scope(
247 INetFwOpenPort *iface,
248 NET_FW_SCOPE *scope)
250 fw_port *This = impl_from_INetFwOpenPort( iface );
252 FIXME("%p %p\n", This, scope);
253 return E_NOTIMPL;
256 static HRESULT WINAPI fw_port_put_Scope(
257 INetFwOpenPort *iface,
258 NET_FW_SCOPE scope)
260 fw_port *This = impl_from_INetFwOpenPort( iface );
262 FIXME("%p %u\n", This, scope);
263 return E_NOTIMPL;
266 static HRESULT WINAPI fw_port_get_RemoteAddresses(
267 INetFwOpenPort *iface,
268 BSTR *remoteAddrs)
270 fw_port *This = impl_from_INetFwOpenPort( iface );
272 FIXME("%p %p\n", This, remoteAddrs);
273 return E_NOTIMPL;
276 static HRESULT WINAPI fw_port_put_RemoteAddresses(
277 INetFwOpenPort *iface,
278 BSTR remoteAddrs)
280 fw_port *This = impl_from_INetFwOpenPort( iface );
282 FIXME("%p %s\n", This, debugstr_w(remoteAddrs));
283 return E_NOTIMPL;
286 static HRESULT WINAPI fw_port_get_Enabled(
287 INetFwOpenPort *iface,
288 VARIANT_BOOL *enabled)
290 fw_port *This = impl_from_INetFwOpenPort( iface );
292 FIXME("%p %p\n", This, enabled);
294 *enabled = VARIANT_TRUE;
295 return S_OK;
298 static HRESULT WINAPI fw_port_put_Enabled(
299 INetFwOpenPort *iface,
300 VARIANT_BOOL enabled)
302 fw_port *This = impl_from_INetFwOpenPort( iface );
304 FIXME("%p %d\n", This, enabled);
305 return E_NOTIMPL;
308 static HRESULT WINAPI fw_port_get_BuiltIn(
309 INetFwOpenPort *iface,
310 VARIANT_BOOL *builtIn)
312 fw_port *This = impl_from_INetFwOpenPort( iface );
314 FIXME("%p %p\n", This, builtIn);
315 return E_NOTIMPL;
318 static const struct INetFwOpenPortVtbl fw_port_vtbl =
320 fw_port_QueryInterface,
321 fw_port_AddRef,
322 fw_port_Release,
323 fw_port_GetTypeInfoCount,
324 fw_port_GetTypeInfo,
325 fw_port_GetIDsOfNames,
326 fw_port_Invoke,
327 fw_port_get_Name,
328 fw_port_put_Name,
329 fw_port_get_IpVersion,
330 fw_port_put_IpVersion,
331 fw_port_get_Protocol,
332 fw_port_put_Protocol,
333 fw_port_get_Port,
334 fw_port_put_Port,
335 fw_port_get_Scope,
336 fw_port_put_Scope,
337 fw_port_get_RemoteAddresses,
338 fw_port_put_RemoteAddresses,
339 fw_port_get_Enabled,
340 fw_port_put_Enabled,
341 fw_port_get_BuiltIn
344 HRESULT NetFwOpenPort_create( IUnknown *pUnkOuter, LPVOID *ppObj )
346 fw_port *fp;
348 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
350 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
351 if (!fp) return E_OUTOFMEMORY;
353 fp->INetFwOpenPort_iface.lpVtbl = &fw_port_vtbl;
354 fp->refs = 1;
356 *ppObj = &fp->INetFwOpenPort_iface;
358 TRACE("returning iface %p\n", *ppObj);
359 return S_OK;
362 typedef struct fw_ports
364 INetFwOpenPorts INetFwOpenPorts_iface;
365 LONG refs;
366 } fw_ports;
368 static inline fw_ports *impl_from_INetFwOpenPorts( INetFwOpenPorts *iface )
370 return CONTAINING_RECORD(iface, fw_ports, INetFwOpenPorts_iface);
373 static ULONG WINAPI fw_ports_AddRef(
374 INetFwOpenPorts *iface )
376 fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
377 return InterlockedIncrement( &fw_ports->refs );
380 static ULONG WINAPI fw_ports_Release(
381 INetFwOpenPorts *iface )
383 fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
384 LONG refs = InterlockedDecrement( &fw_ports->refs );
385 if (!refs)
387 TRACE("destroying %p\n", fw_ports);
388 HeapFree( GetProcessHeap(), 0, fw_ports );
390 return refs;
393 static HRESULT WINAPI fw_ports_QueryInterface(
394 INetFwOpenPorts *iface,
395 REFIID riid,
396 void **ppvObject )
398 fw_ports *This = impl_from_INetFwOpenPorts( iface );
400 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
402 if ( IsEqualGUID( riid, &IID_INetFwOpenPorts ) ||
403 IsEqualGUID( riid, &IID_IDispatch ) ||
404 IsEqualGUID( riid, &IID_IUnknown ) )
406 *ppvObject = iface;
408 else
410 FIXME("interface %s not implemented\n", debugstr_guid(riid));
411 return E_NOINTERFACE;
413 INetFwOpenPorts_AddRef( iface );
414 return S_OK;
417 static HRESULT WINAPI fw_ports_GetTypeInfoCount(
418 INetFwOpenPorts *iface,
419 UINT *pctinfo )
421 fw_ports *This = impl_from_INetFwOpenPorts( iface );
423 FIXME("%p %p\n", This, pctinfo);
424 return E_NOTIMPL;
427 static HRESULT WINAPI fw_ports_GetTypeInfo(
428 INetFwOpenPorts *iface,
429 UINT iTInfo,
430 LCID lcid,
431 ITypeInfo **ppTInfo )
433 fw_ports *This = impl_from_INetFwOpenPorts( iface );
435 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
436 return E_NOTIMPL;
439 static HRESULT WINAPI fw_ports_GetIDsOfNames(
440 INetFwOpenPorts *iface,
441 REFIID riid,
442 LPOLESTR *rgszNames,
443 UINT cNames,
444 LCID lcid,
445 DISPID *rgDispId )
447 fw_ports *This = impl_from_INetFwOpenPorts( iface );
449 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
450 return E_NOTIMPL;
453 static HRESULT WINAPI fw_ports_Invoke(
454 INetFwOpenPorts *iface,
455 DISPID dispIdMember,
456 REFIID riid,
457 LCID lcid,
458 WORD wFlags,
459 DISPPARAMS *pDispParams,
460 VARIANT *pVarResult,
461 EXCEPINFO *pExcepInfo,
462 UINT *puArgErr )
464 fw_ports *This = impl_from_INetFwOpenPorts( iface );
466 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
467 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
468 return E_NOTIMPL;
471 static HRESULT WINAPI fw_ports_get_Count(
472 INetFwOpenPorts *iface,
473 LONG *count)
475 fw_ports *This = impl_from_INetFwOpenPorts( iface );
477 FIXME("%p, %p\n", This, count);
479 *count = 0;
480 return S_OK;
483 static HRESULT WINAPI fw_ports_Add(
484 INetFwOpenPorts *iface,
485 INetFwOpenPort *port)
487 fw_ports *This = impl_from_INetFwOpenPorts( iface );
489 FIXME("%p, %p\n", This, port);
490 return E_NOTIMPL;
493 static HRESULT WINAPI fw_ports_Remove(
494 INetFwOpenPorts *iface,
495 LONG portNumber,
496 NET_FW_IP_PROTOCOL ipProtocol)
498 fw_ports *This = impl_from_INetFwOpenPorts( iface );
500 FIXME("%p, %d, %u\n", This, portNumber, ipProtocol);
501 return E_NOTIMPL;
504 static HRESULT WINAPI fw_ports_Item(
505 INetFwOpenPorts *iface,
506 LONG portNumber,
507 NET_FW_IP_PROTOCOL ipProtocol,
508 INetFwOpenPort **openPort)
510 HRESULT hr;
511 fw_ports *This = impl_from_INetFwOpenPorts( iface );
513 FIXME("%p, %d, %u, %p\n", This, portNumber, ipProtocol, openPort);
515 hr = NetFwOpenPort_create( NULL, (void **)openPort );
516 if (SUCCEEDED(hr))
518 INetFwOpenPort_put_Protocol( *openPort, ipProtocol );
519 INetFwOpenPort_put_Port( *openPort, portNumber );
521 return hr;
524 static HRESULT WINAPI fw_ports_get__NewEnum(
525 INetFwOpenPorts *iface,
526 IUnknown **newEnum)
528 fw_ports *This = impl_from_INetFwOpenPorts( iface );
530 FIXME("%p, %p\n", This, newEnum);
531 return E_NOTIMPL;
534 static const struct INetFwOpenPortsVtbl fw_ports_vtbl =
536 fw_ports_QueryInterface,
537 fw_ports_AddRef,
538 fw_ports_Release,
539 fw_ports_GetTypeInfoCount,
540 fw_ports_GetTypeInfo,
541 fw_ports_GetIDsOfNames,
542 fw_ports_Invoke,
543 fw_ports_get_Count,
544 fw_ports_Add,
545 fw_ports_Remove,
546 fw_ports_Item,
547 fw_ports_get__NewEnum
550 HRESULT NetFwOpenPorts_create( IUnknown *pUnkOuter, LPVOID *ppObj )
552 fw_ports *fp;
554 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
556 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
557 if (!fp) return E_OUTOFMEMORY;
559 fp->INetFwOpenPorts_iface.lpVtbl = &fw_ports_vtbl;
560 fp->refs = 1;
562 *ppObj = &fp->INetFwOpenPorts_iface;
564 TRACE("returning iface %p\n", *ppObj);
565 return S_OK;