hnetcfg: Store port name for INetFwOpenPort.
[wine.git] / dlls / hnetcfg / port.c
blob0ef2a1d507e77ff5f1559b1ede8681363c83edbd
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 BSTR name;
42 } fw_port;
44 static inline fw_port *impl_from_INetFwOpenPort( INetFwOpenPort *iface )
46 return CONTAINING_RECORD(iface, fw_port, INetFwOpenPort_iface);
49 static ULONG WINAPI fw_port_AddRef(
50 INetFwOpenPort *iface )
52 fw_port *fw_port = impl_from_INetFwOpenPort( iface );
53 return InterlockedIncrement( &fw_port->refs );
56 static ULONG WINAPI fw_port_Release(
57 INetFwOpenPort *iface )
59 fw_port *fw_port = impl_from_INetFwOpenPort( iface );
60 LONG refs = InterlockedDecrement( &fw_port->refs );
61 if (!refs)
63 TRACE("destroying %p\n", fw_port);
64 SysFreeString( fw_port->name );
65 HeapFree( GetProcessHeap(), 0, fw_port );
67 return refs;
70 static HRESULT WINAPI fw_port_QueryInterface(
71 INetFwOpenPort *iface,
72 REFIID riid,
73 void **ppvObject )
75 fw_port *This = impl_from_INetFwOpenPort( iface );
77 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
79 if ( IsEqualGUID( riid, &IID_INetFwOpenPort ) ||
80 IsEqualGUID( riid, &IID_IDispatch ) ||
81 IsEqualGUID( riid, &IID_IUnknown ) )
83 *ppvObject = iface;
85 else
87 FIXME("interface %s not implemented\n", debugstr_guid(riid));
88 return E_NOINTERFACE;
90 INetFwOpenPort_AddRef( iface );
91 return S_OK;
94 static HRESULT WINAPI fw_port_GetTypeInfoCount(
95 INetFwOpenPort *iface,
96 UINT *pctinfo )
98 fw_port *This = impl_from_INetFwOpenPort( iface );
100 TRACE("%p %p\n", This, pctinfo);
101 *pctinfo = 1;
102 return S_OK;
105 static HRESULT WINAPI fw_port_GetTypeInfo(
106 INetFwOpenPort *iface,
107 UINT iTInfo,
108 LCID lcid,
109 ITypeInfo **ppTInfo )
111 fw_port *This = impl_from_INetFwOpenPort( iface );
113 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
114 return get_typeinfo( INetFwOpenPort_tid, ppTInfo );
117 static HRESULT WINAPI fw_port_GetIDsOfNames(
118 INetFwOpenPort *iface,
119 REFIID riid,
120 LPOLESTR *rgszNames,
121 UINT cNames,
122 LCID lcid,
123 DISPID *rgDispId )
125 fw_port *This = impl_from_INetFwOpenPort( iface );
126 ITypeInfo *typeinfo;
127 HRESULT hr;
129 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
131 hr = get_typeinfo( INetFwOpenPort_tid, &typeinfo );
132 if (SUCCEEDED(hr))
134 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
135 ITypeInfo_Release( typeinfo );
137 return hr;
140 static HRESULT WINAPI fw_port_Invoke(
141 INetFwOpenPort *iface,
142 DISPID dispIdMember,
143 REFIID riid,
144 LCID lcid,
145 WORD wFlags,
146 DISPPARAMS *pDispParams,
147 VARIANT *pVarResult,
148 EXCEPINFO *pExcepInfo,
149 UINT *puArgErr )
151 fw_port *This = impl_from_INetFwOpenPort( iface );
152 ITypeInfo *typeinfo;
153 HRESULT hr;
155 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
156 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
158 hr = get_typeinfo( INetFwOpenPort_tid, &typeinfo );
159 if (SUCCEEDED(hr))
161 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwOpenPort_iface, dispIdMember,
162 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
163 ITypeInfo_Release( typeinfo );
165 return hr;
168 static HRESULT WINAPI fw_port_get_Name(
169 INetFwOpenPort *iface,
170 BSTR *name)
172 fw_port *This = impl_from_INetFwOpenPort( iface );
174 FIXME("%p %p\n", This, name);
175 return E_NOTIMPL;
178 static HRESULT WINAPI fw_port_put_Name(
179 INetFwOpenPort *iface,
180 BSTR name)
182 fw_port *This = impl_from_INetFwOpenPort( iface );
184 TRACE("%p %s\n", This, debugstr_w(name));
186 if (!(name = SysAllocString( name )))
187 return E_OUTOFMEMORY;
189 SysFreeString( This->name );
190 This->name = name;
191 return S_OK;
194 static HRESULT WINAPI fw_port_get_IpVersion(
195 INetFwOpenPort *iface,
196 NET_FW_IP_VERSION *ipVersion)
198 fw_port *This = impl_from_INetFwOpenPort( iface );
200 FIXME("%p %p\n", This, ipVersion);
201 return E_NOTIMPL;
204 static HRESULT WINAPI fw_port_put_IpVersion(
205 INetFwOpenPort *iface,
206 NET_FW_IP_VERSION ipVersion)
208 fw_port *This = impl_from_INetFwOpenPort( iface );
210 FIXME("%p %u\n", This, ipVersion);
211 return E_NOTIMPL;
214 static HRESULT WINAPI fw_port_get_Protocol(
215 INetFwOpenPort *iface,
216 NET_FW_IP_PROTOCOL *ipProtocol)
218 fw_port *This = impl_from_INetFwOpenPort( iface );
220 FIXME("%p %p\n", This, ipProtocol);
221 return E_NOTIMPL;
224 static HRESULT WINAPI fw_port_put_Protocol(
225 INetFwOpenPort *iface,
226 NET_FW_IP_PROTOCOL ipProtocol)
228 fw_port *This = impl_from_INetFwOpenPort( iface );
230 FIXME("%p %u\n", This, ipProtocol);
231 return E_NOTIMPL;
234 static HRESULT WINAPI fw_port_get_Port(
235 INetFwOpenPort *iface,
236 LONG *portNumber)
238 fw_port *This = impl_from_INetFwOpenPort( iface );
240 FIXME("%p %p\n", This, portNumber);
241 return E_NOTIMPL;
244 static HRESULT WINAPI fw_port_put_Port(
245 INetFwOpenPort *iface,
246 LONG portNumber)
248 fw_port *This = impl_from_INetFwOpenPort( iface );
250 FIXME("%p %d\n", This, portNumber);
251 return E_NOTIMPL;
254 static HRESULT WINAPI fw_port_get_Scope(
255 INetFwOpenPort *iface,
256 NET_FW_SCOPE *scope)
258 fw_port *This = impl_from_INetFwOpenPort( iface );
260 FIXME("%p %p\n", This, scope);
261 return E_NOTIMPL;
264 static HRESULT WINAPI fw_port_put_Scope(
265 INetFwOpenPort *iface,
266 NET_FW_SCOPE scope)
268 fw_port *This = impl_from_INetFwOpenPort( iface );
270 FIXME("%p %u\n", This, scope);
271 return E_NOTIMPL;
274 static HRESULT WINAPI fw_port_get_RemoteAddresses(
275 INetFwOpenPort *iface,
276 BSTR *remoteAddrs)
278 fw_port *This = impl_from_INetFwOpenPort( iface );
280 FIXME("%p %p\n", This, remoteAddrs);
281 return E_NOTIMPL;
284 static HRESULT WINAPI fw_port_put_RemoteAddresses(
285 INetFwOpenPort *iface,
286 BSTR remoteAddrs)
288 fw_port *This = impl_from_INetFwOpenPort( iface );
290 FIXME("%p %s\n", This, debugstr_w(remoteAddrs));
291 return E_NOTIMPL;
294 static HRESULT WINAPI fw_port_get_Enabled(
295 INetFwOpenPort *iface,
296 VARIANT_BOOL *enabled)
298 fw_port *This = impl_from_INetFwOpenPort( iface );
300 FIXME("%p %p\n", This, enabled);
302 *enabled = VARIANT_TRUE;
303 return S_OK;
306 static HRESULT WINAPI fw_port_put_Enabled(
307 INetFwOpenPort *iface,
308 VARIANT_BOOL enabled)
310 fw_port *This = impl_from_INetFwOpenPort( iface );
312 FIXME("%p %d\n", This, enabled);
313 return E_NOTIMPL;
316 static HRESULT WINAPI fw_port_get_BuiltIn(
317 INetFwOpenPort *iface,
318 VARIANT_BOOL *builtIn)
320 fw_port *This = impl_from_INetFwOpenPort( iface );
322 FIXME("%p %p\n", This, builtIn);
323 return E_NOTIMPL;
326 static const struct INetFwOpenPortVtbl fw_port_vtbl =
328 fw_port_QueryInterface,
329 fw_port_AddRef,
330 fw_port_Release,
331 fw_port_GetTypeInfoCount,
332 fw_port_GetTypeInfo,
333 fw_port_GetIDsOfNames,
334 fw_port_Invoke,
335 fw_port_get_Name,
336 fw_port_put_Name,
337 fw_port_get_IpVersion,
338 fw_port_put_IpVersion,
339 fw_port_get_Protocol,
340 fw_port_put_Protocol,
341 fw_port_get_Port,
342 fw_port_put_Port,
343 fw_port_get_Scope,
344 fw_port_put_Scope,
345 fw_port_get_RemoteAddresses,
346 fw_port_put_RemoteAddresses,
347 fw_port_get_Enabled,
348 fw_port_put_Enabled,
349 fw_port_get_BuiltIn
352 HRESULT NetFwOpenPort_create( IUnknown *pUnkOuter, LPVOID *ppObj )
354 fw_port *fp;
356 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
358 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
359 if (!fp) return E_OUTOFMEMORY;
361 fp->INetFwOpenPort_iface.lpVtbl = &fw_port_vtbl;
362 fp->refs = 1;
363 fp->name = NULL;
365 *ppObj = &fp->INetFwOpenPort_iface;
367 TRACE("returning iface %p\n", *ppObj);
368 return S_OK;
371 typedef struct fw_ports
373 INetFwOpenPorts INetFwOpenPorts_iface;
374 LONG refs;
375 } fw_ports;
377 static inline fw_ports *impl_from_INetFwOpenPorts( INetFwOpenPorts *iface )
379 return CONTAINING_RECORD(iface, fw_ports, INetFwOpenPorts_iface);
382 static ULONG WINAPI fw_ports_AddRef(
383 INetFwOpenPorts *iface )
385 fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
386 return InterlockedIncrement( &fw_ports->refs );
389 static ULONG WINAPI fw_ports_Release(
390 INetFwOpenPorts *iface )
392 fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
393 LONG refs = InterlockedDecrement( &fw_ports->refs );
394 if (!refs)
396 TRACE("destroying %p\n", fw_ports);
397 HeapFree( GetProcessHeap(), 0, fw_ports );
399 return refs;
402 static HRESULT WINAPI fw_ports_QueryInterface(
403 INetFwOpenPorts *iface,
404 REFIID riid,
405 void **ppvObject )
407 fw_ports *This = impl_from_INetFwOpenPorts( iface );
409 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
411 if ( IsEqualGUID( riid, &IID_INetFwOpenPorts ) ||
412 IsEqualGUID( riid, &IID_IDispatch ) ||
413 IsEqualGUID( riid, &IID_IUnknown ) )
415 *ppvObject = iface;
417 else
419 FIXME("interface %s not implemented\n", debugstr_guid(riid));
420 return E_NOINTERFACE;
422 INetFwOpenPorts_AddRef( iface );
423 return S_OK;
426 static HRESULT WINAPI fw_ports_GetTypeInfoCount(
427 INetFwOpenPorts *iface,
428 UINT *pctinfo )
430 fw_ports *This = impl_from_INetFwOpenPorts( iface );
432 FIXME("%p %p\n", This, pctinfo);
433 return E_NOTIMPL;
436 static HRESULT WINAPI fw_ports_GetTypeInfo(
437 INetFwOpenPorts *iface,
438 UINT iTInfo,
439 LCID lcid,
440 ITypeInfo **ppTInfo )
442 fw_ports *This = impl_from_INetFwOpenPorts( iface );
444 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
445 return E_NOTIMPL;
448 static HRESULT WINAPI fw_ports_GetIDsOfNames(
449 INetFwOpenPorts *iface,
450 REFIID riid,
451 LPOLESTR *rgszNames,
452 UINT cNames,
453 LCID lcid,
454 DISPID *rgDispId )
456 fw_ports *This = impl_from_INetFwOpenPorts( iface );
458 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
459 return E_NOTIMPL;
462 static HRESULT WINAPI fw_ports_Invoke(
463 INetFwOpenPorts *iface,
464 DISPID dispIdMember,
465 REFIID riid,
466 LCID lcid,
467 WORD wFlags,
468 DISPPARAMS *pDispParams,
469 VARIANT *pVarResult,
470 EXCEPINFO *pExcepInfo,
471 UINT *puArgErr )
473 fw_ports *This = impl_from_INetFwOpenPorts( iface );
475 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
476 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
477 return E_NOTIMPL;
480 static HRESULT WINAPI fw_ports_get_Count(
481 INetFwOpenPorts *iface,
482 LONG *count)
484 fw_ports *This = impl_from_INetFwOpenPorts( iface );
486 FIXME("%p, %p\n", This, count);
488 *count = 0;
489 return S_OK;
492 static HRESULT WINAPI fw_ports_Add(
493 INetFwOpenPorts *iface,
494 INetFwOpenPort *port)
496 fw_ports *This = impl_from_INetFwOpenPorts( iface );
498 FIXME("%p, %p\n", This, port);
499 return E_NOTIMPL;
502 static HRESULT WINAPI fw_ports_Remove(
503 INetFwOpenPorts *iface,
504 LONG portNumber,
505 NET_FW_IP_PROTOCOL ipProtocol)
507 fw_ports *This = impl_from_INetFwOpenPorts( iface );
509 FIXME("%p, %d, %u\n", This, portNumber, ipProtocol);
510 return E_NOTIMPL;
513 static HRESULT WINAPI fw_ports_Item(
514 INetFwOpenPorts *iface,
515 LONG portNumber,
516 NET_FW_IP_PROTOCOL ipProtocol,
517 INetFwOpenPort **openPort)
519 HRESULT hr;
520 fw_ports *This = impl_from_INetFwOpenPorts( iface );
522 FIXME("%p, %d, %u, %p\n", This, portNumber, ipProtocol, openPort);
524 hr = NetFwOpenPort_create( NULL, (void **)openPort );
525 if (SUCCEEDED(hr))
527 INetFwOpenPort_put_Protocol( *openPort, ipProtocol );
528 INetFwOpenPort_put_Port( *openPort, portNumber );
530 return hr;
533 static HRESULT WINAPI fw_ports_get__NewEnum(
534 INetFwOpenPorts *iface,
535 IUnknown **newEnum)
537 fw_ports *This = impl_from_INetFwOpenPorts( iface );
539 FIXME("%p, %p\n", This, newEnum);
540 return E_NOTIMPL;
543 static const struct INetFwOpenPortsVtbl fw_ports_vtbl =
545 fw_ports_QueryInterface,
546 fw_ports_AddRef,
547 fw_ports_Release,
548 fw_ports_GetTypeInfoCount,
549 fw_ports_GetTypeInfo,
550 fw_ports_GetIDsOfNames,
551 fw_ports_Invoke,
552 fw_ports_get_Count,
553 fw_ports_Add,
554 fw_ports_Remove,
555 fw_ports_Item,
556 fw_ports_get__NewEnum
559 HRESULT NetFwOpenPorts_create( IUnknown *pUnkOuter, LPVOID *ppObj )
561 fw_ports *fp;
563 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
565 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
566 if (!fp) return E_OUTOFMEMORY;
568 fp->INetFwOpenPorts_iface.lpVtbl = &fw_ports_vtbl;
569 fp->refs = 1;
571 *ppObj = &fp->INetFwOpenPorts_iface;
573 TRACE("returning iface %p\n", *ppObj);
574 return S_OK;