hnetcfg: Improve the stub for INetFwServices::Item.
[wine/hacks.git] / dlls / hnetcfg / port.c
blobc80b5f7bfcea9c06a8d05bc3911afc63bfda0dcf
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 const INetFwOpenPortVtbl *vtbl;
40 LONG refs;
41 } fw_port;
43 static inline fw_port *impl_from_INetFwOpenPort( INetFwOpenPort *iface )
45 return (fw_port *)((char *)iface - FIELD_OFFSET( fw_port, vtbl ));
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 FIXME("%p %p\n", This, pctinfo);
99 return E_NOTIMPL;
102 static HRESULT WINAPI fw_port_GetTypeInfo(
103 INetFwOpenPort *iface,
104 UINT iTInfo,
105 LCID lcid,
106 ITypeInfo **ppTInfo )
108 fw_port *This = impl_from_INetFwOpenPort( iface );
110 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
111 return E_NOTIMPL;
114 static HRESULT WINAPI fw_port_GetIDsOfNames(
115 INetFwOpenPort *iface,
116 REFIID riid,
117 LPOLESTR *rgszNames,
118 UINT cNames,
119 LCID lcid,
120 DISPID *rgDispId )
122 fw_port *This = impl_from_INetFwOpenPort( iface );
124 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
125 return E_NOTIMPL;
128 static HRESULT WINAPI fw_port_Invoke(
129 INetFwOpenPort *iface,
130 DISPID dispIdMember,
131 REFIID riid,
132 LCID lcid,
133 WORD wFlags,
134 DISPPARAMS *pDispParams,
135 VARIANT *pVarResult,
136 EXCEPINFO *pExcepInfo,
137 UINT *puArgErr )
139 fw_port *This = impl_from_INetFwOpenPort( iface );
141 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
142 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
143 return E_NOTIMPL;
146 static HRESULT WINAPI fw_port_get_Name(
147 INetFwOpenPort *iface,
148 BSTR *name)
150 fw_port *This = impl_from_INetFwOpenPort( iface );
152 FIXME("%p %p\n", This, name);
153 return E_NOTIMPL;
156 static HRESULT WINAPI fw_port_put_Name(
157 INetFwOpenPort *iface,
158 BSTR name)
160 fw_port *This = impl_from_INetFwOpenPort( iface );
162 FIXME("%p %s\n", This, debugstr_w(name));
163 return E_NOTIMPL;
166 static HRESULT WINAPI fw_port_get_IpVersion(
167 INetFwOpenPort *iface,
168 NET_FW_IP_VERSION *ipVersion)
170 fw_port *This = impl_from_INetFwOpenPort( iface );
172 FIXME("%p %p\n", This, ipVersion);
173 return E_NOTIMPL;
176 static HRESULT WINAPI fw_port_put_IpVersion(
177 INetFwOpenPort *iface,
178 NET_FW_IP_VERSION ipVersion)
180 fw_port *This = impl_from_INetFwOpenPort( iface );
182 FIXME("%p %u\n", This, ipVersion);
183 return E_NOTIMPL;
186 static HRESULT WINAPI fw_port_get_Protocol(
187 INetFwOpenPort *iface,
188 NET_FW_IP_PROTOCOL *ipProtocol)
190 fw_port *This = impl_from_INetFwOpenPort( iface );
192 FIXME("%p %p\n", This, ipProtocol);
193 return E_NOTIMPL;
196 static HRESULT WINAPI fw_port_put_Protocol(
197 INetFwOpenPort *iface,
198 NET_FW_IP_PROTOCOL ipProtocol)
200 fw_port *This = impl_from_INetFwOpenPort( iface );
202 FIXME("%p %u\n", This, ipProtocol);
203 return E_NOTIMPL;
206 static HRESULT WINAPI fw_port_get_Port(
207 INetFwOpenPort *iface,
208 LONG *portNumber)
210 fw_port *This = impl_from_INetFwOpenPort( iface );
212 FIXME("%p %p\n", This, portNumber);
213 return E_NOTIMPL;
216 static HRESULT WINAPI fw_port_put_Port(
217 INetFwOpenPort *iface,
218 LONG portNumber)
220 fw_port *This = impl_from_INetFwOpenPort( iface );
222 FIXME("%p %d\n", This, portNumber);
223 return E_NOTIMPL;
226 static HRESULT WINAPI fw_port_get_Scope(
227 INetFwOpenPort *iface,
228 NET_FW_SCOPE *scope)
230 fw_port *This = impl_from_INetFwOpenPort( iface );
232 FIXME("%p %p\n", This, scope);
233 return E_NOTIMPL;
236 static HRESULT WINAPI fw_port_put_Scope(
237 INetFwOpenPort *iface,
238 NET_FW_SCOPE scope)
240 fw_port *This = impl_from_INetFwOpenPort( iface );
242 FIXME("%p %u\n", This, scope);
243 return E_NOTIMPL;
246 static HRESULT WINAPI fw_port_get_RemoteAddresses(
247 INetFwOpenPort *iface,
248 BSTR *remoteAddrs)
250 fw_port *This = impl_from_INetFwOpenPort( iface );
252 FIXME("%p %p\n", This, remoteAddrs);
253 return E_NOTIMPL;
256 static HRESULT WINAPI fw_port_put_RemoteAddresses(
257 INetFwOpenPort *iface,
258 BSTR remoteAddrs)
260 fw_port *This = impl_from_INetFwOpenPort( iface );
262 FIXME("%p %s\n", This, debugstr_w(remoteAddrs));
263 return E_NOTIMPL;
266 static HRESULT WINAPI fw_port_get_Enabled(
267 INetFwOpenPort *iface,
268 VARIANT_BOOL *enabled)
270 fw_port *This = impl_from_INetFwOpenPort( iface );
272 FIXME("%p %p\n", This, enabled);
273 return E_NOTIMPL;
276 static HRESULT WINAPI fw_port_put_Enabled(
277 INetFwOpenPort *iface,
278 VARIANT_BOOL enabled)
280 fw_port *This = impl_from_INetFwOpenPort( iface );
282 FIXME("%p %d\n", This, enabled);
283 return E_NOTIMPL;
286 static HRESULT WINAPI fw_port_get_BuiltIn(
287 INetFwOpenPort *iface,
288 VARIANT_BOOL *builtIn)
290 fw_port *This = impl_from_INetFwOpenPort( iface );
292 FIXME("%p %p\n", This, builtIn);
293 return E_NOTIMPL;
296 static const struct INetFwOpenPortVtbl fw_port_vtbl =
298 fw_port_QueryInterface,
299 fw_port_AddRef,
300 fw_port_Release,
301 fw_port_GetTypeInfoCount,
302 fw_port_GetTypeInfo,
303 fw_port_GetIDsOfNames,
304 fw_port_Invoke,
305 fw_port_get_Name,
306 fw_port_put_Name,
307 fw_port_get_IpVersion,
308 fw_port_put_IpVersion,
309 fw_port_get_Protocol,
310 fw_port_put_Protocol,
311 fw_port_get_Port,
312 fw_port_put_Port,
313 fw_port_get_Scope,
314 fw_port_put_Scope,
315 fw_port_get_RemoteAddresses,
316 fw_port_put_RemoteAddresses,
317 fw_port_get_Enabled,
318 fw_port_put_Enabled,
319 fw_port_get_BuiltIn
322 static HRESULT NetFwOpenPort_create( IUnknown *pUnkOuter, LPVOID *ppObj )
324 fw_port *fp;
326 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
328 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
329 if (!fp) return E_OUTOFMEMORY;
331 fp->vtbl = &fw_port_vtbl;
332 fp->refs = 1;
334 *ppObj = &fp->vtbl;
336 TRACE("returning iface %p\n", *ppObj);
337 return S_OK;
340 typedef struct fw_ports
342 const INetFwOpenPortsVtbl *vtbl;
343 LONG refs;
344 } fw_ports;
346 static inline fw_ports *impl_from_INetFwOpenPorts( INetFwOpenPorts *iface )
348 return (fw_ports *)((char *)iface - FIELD_OFFSET( fw_ports, vtbl ));
351 static ULONG WINAPI fw_ports_AddRef(
352 INetFwOpenPorts *iface )
354 fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
355 return InterlockedIncrement( &fw_ports->refs );
358 static ULONG WINAPI fw_ports_Release(
359 INetFwOpenPorts *iface )
361 fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
362 LONG refs = InterlockedDecrement( &fw_ports->refs );
363 if (!refs)
365 TRACE("destroying %p\n", fw_ports);
366 HeapFree( GetProcessHeap(), 0, fw_ports );
368 return refs;
371 static HRESULT WINAPI fw_ports_QueryInterface(
372 INetFwOpenPorts *iface,
373 REFIID riid,
374 void **ppvObject )
376 fw_ports *This = impl_from_INetFwOpenPorts( iface );
378 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
380 if ( IsEqualGUID( riid, &IID_INetFwOpenPorts ) ||
381 IsEqualGUID( riid, &IID_IDispatch ) ||
382 IsEqualGUID( riid, &IID_IUnknown ) )
384 *ppvObject = iface;
386 else
388 FIXME("interface %s not implemented\n", debugstr_guid(riid));
389 return E_NOINTERFACE;
391 INetFwOpenPorts_AddRef( iface );
392 return S_OK;
395 static HRESULT WINAPI fw_ports_GetTypeInfoCount(
396 INetFwOpenPorts *iface,
397 UINT *pctinfo )
399 fw_ports *This = impl_from_INetFwOpenPorts( iface );
401 FIXME("%p %p\n", This, pctinfo);
402 return E_NOTIMPL;
405 static HRESULT WINAPI fw_ports_GetTypeInfo(
406 INetFwOpenPorts *iface,
407 UINT iTInfo,
408 LCID lcid,
409 ITypeInfo **ppTInfo )
411 fw_ports *This = impl_from_INetFwOpenPorts( iface );
413 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
414 return E_NOTIMPL;
417 static HRESULT WINAPI fw_ports_GetIDsOfNames(
418 INetFwOpenPorts *iface,
419 REFIID riid,
420 LPOLESTR *rgszNames,
421 UINT cNames,
422 LCID lcid,
423 DISPID *rgDispId )
425 fw_ports *This = impl_from_INetFwOpenPorts( iface );
427 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
428 return E_NOTIMPL;
431 static HRESULT WINAPI fw_ports_Invoke(
432 INetFwOpenPorts *iface,
433 DISPID dispIdMember,
434 REFIID riid,
435 LCID lcid,
436 WORD wFlags,
437 DISPPARAMS *pDispParams,
438 VARIANT *pVarResult,
439 EXCEPINFO *pExcepInfo,
440 UINT *puArgErr )
442 fw_ports *This = impl_from_INetFwOpenPorts( iface );
444 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
445 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
446 return E_NOTIMPL;
449 static HRESULT WINAPI fw_ports_get_Count(
450 INetFwOpenPorts *iface,
451 LONG *count)
453 fw_ports *This = impl_from_INetFwOpenPorts( iface );
455 FIXME("%p, %p\n", This, count);
457 *count = 0;
458 return S_OK;
461 static HRESULT WINAPI fw_ports_Add(
462 INetFwOpenPorts *iface,
463 INetFwOpenPort *port)
465 fw_ports *This = impl_from_INetFwOpenPorts( iface );
467 FIXME("%p, %p\n", This, port);
468 return E_NOTIMPL;
471 static HRESULT WINAPI fw_ports_Remove(
472 INetFwOpenPorts *iface,
473 LONG portNumber,
474 NET_FW_IP_PROTOCOL ipProtocol)
476 fw_ports *This = impl_from_INetFwOpenPorts( iface );
478 FIXME("%p, %d, %u\n", This, portNumber, ipProtocol);
479 return E_NOTIMPL;
482 static HRESULT WINAPI fw_ports_Item(
483 INetFwOpenPorts *iface,
484 LONG portNumber,
485 NET_FW_IP_PROTOCOL ipProtocol,
486 INetFwOpenPort **openPort)
488 HRESULT hr;
489 fw_ports *This = impl_from_INetFwOpenPorts( iface );
491 FIXME("%p, %d, %u, %p\n", This, portNumber, ipProtocol, openPort);
493 hr = NetFwOpenPort_create( NULL, (void **)openPort );
494 if (SUCCEEDED(hr))
496 INetFwOpenPort_put_Protocol( *openPort, ipProtocol );
497 INetFwOpenPort_put_Port( *openPort, portNumber );
499 return hr;
502 static HRESULT WINAPI fw_ports_get__NewEnum(
503 INetFwOpenPorts *iface,
504 IUnknown **newEnum)
506 fw_ports *This = impl_from_INetFwOpenPorts( iface );
508 FIXME("%p, %p\n", This, newEnum);
509 return E_NOTIMPL;
512 static const struct INetFwOpenPortsVtbl fw_ports_vtbl =
514 fw_ports_QueryInterface,
515 fw_ports_AddRef,
516 fw_ports_Release,
517 fw_ports_GetTypeInfoCount,
518 fw_ports_GetTypeInfo,
519 fw_ports_GetIDsOfNames,
520 fw_ports_Invoke,
521 fw_ports_get_Count,
522 fw_ports_Add,
523 fw_ports_Remove,
524 fw_ports_Item,
525 fw_ports_get__NewEnum
528 HRESULT NetFwOpenPorts_create( IUnknown *pUnkOuter, LPVOID *ppObj )
530 fw_ports *fp;
532 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
534 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
535 if (!fp) return E_OUTOFMEMORY;
537 fp->vtbl = &fw_ports_vtbl;
538 fp->refs = 1;
540 *ppObj = &fp->vtbl;
542 TRACE("returning iface %p\n", *ppObj);
543 return S_OK;