2 * Copyright 2014 Hans Leidekker for CodeWeavers
3 * Copyright 2015 Michael Müller
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "netlistmgr.h"
32 #include "wine/debug.h"
33 #include "netprofm_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(netprofm
);
39 INetworkListManager INetworkListManager_iface
;
40 INetworkCostManager INetworkCostManager_iface
;
41 IConnectionPointContainer IConnectionPointContainer_iface
;
45 struct connection_point
47 IConnectionPoint IConnectionPoint_iface
;
48 IConnectionPointContainer
*container
;
53 static inline struct list_manager
*impl_from_IConnectionPointContainer(IConnectionPointContainer
*iface
)
55 return CONTAINING_RECORD(iface
, struct list_manager
, IConnectionPointContainer_iface
);
58 static inline struct list_manager
*impl_from_INetworkCostManager(
59 INetworkCostManager
*iface
)
61 return CONTAINING_RECORD( iface
, struct list_manager
, INetworkCostManager_iface
);
64 static inline struct connection_point
*impl_from_IConnectionPoint(
65 IConnectionPoint
*iface
)
67 return CONTAINING_RECORD( iface
, struct connection_point
, IConnectionPoint_iface
);
70 static HRESULT WINAPI
connection_point_QueryInterface(
71 IConnectionPoint
*iface
,
75 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
76 TRACE( "%p, %s, %p\n", cp
, debugstr_guid(riid
), obj
);
78 if (IsEqualGUID( riid
, &IID_IConnectionPoint
) ||
79 IsEqualGUID( riid
, &IID_IUnknown
))
85 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
88 IConnectionPoint_AddRef( iface
);
92 static ULONG WINAPI
connection_point_AddRef(
93 IConnectionPoint
*iface
)
95 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
96 return InterlockedIncrement( &cp
->refs
);
99 static ULONG WINAPI
connection_point_Release(
100 IConnectionPoint
*iface
)
102 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
103 LONG refs
= InterlockedDecrement( &cp
->refs
);
106 TRACE( "destroying %p\n", cp
);
107 IConnectionPointContainer_Release( cp
->container
);
108 HeapFree( GetProcessHeap(), 0, cp
);
113 static HRESULT WINAPI
connection_point_GetConnectionInterface(
114 IConnectionPoint
*iface
,
117 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
118 TRACE( "%p, %p\n", cp
, iid
);
123 memcpy( iid
, &cp
->iid
, sizeof(*iid
) );
127 static HRESULT WINAPI
connection_point_GetConnectionPointContainer(
128 IConnectionPoint
*iface
,
129 IConnectionPointContainer
**container
)
131 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
132 TRACE( "%p, %p\n", cp
, container
);
137 IConnectionPointContainer_AddRef( cp
->container
);
138 *container
= cp
->container
;
142 static HRESULT WINAPI
connection_point_Advise(
143 IConnectionPoint
*iface
,
147 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
148 FIXME( "%p, %p, %p - stub\n", cp
, sink
, cookie
);
150 if (!sink
|| !cookie
)
153 return CONNECT_E_CANNOTCONNECT
;
156 static HRESULT WINAPI
connection_point_Unadvise(
157 IConnectionPoint
*iface
,
160 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
161 FIXME( "%p, %d - stub\n", cp
, cookie
);
166 static HRESULT WINAPI
connection_point_EnumConnections(
167 IConnectionPoint
*iface
,
168 IEnumConnections
**connections
)
170 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
171 FIXME( "%p, %p - stub\n", cp
, connections
);
176 static const IConnectionPointVtbl connection_point_vtbl
=
178 connection_point_QueryInterface
,
179 connection_point_AddRef
,
180 connection_point_Release
,
181 connection_point_GetConnectionInterface
,
182 connection_point_GetConnectionPointContainer
,
183 connection_point_Advise
,
184 connection_point_Unadvise
,
185 connection_point_EnumConnections
188 static HRESULT
connection_point_create(
189 IConnectionPoint
**obj
,
191 IConnectionPointContainer
*container
)
193 struct connection_point
*cp
;
194 TRACE( "%p, %s, %p\n", obj
, debugstr_guid(riid
), container
);
196 if (!(cp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cp
) ))) return E_OUTOFMEMORY
;
197 cp
->IConnectionPoint_iface
.lpVtbl
= &connection_point_vtbl
;
198 cp
->container
= container
;
201 memcpy( &cp
->iid
, riid
, sizeof(*riid
) );
202 IConnectionPointContainer_AddRef( container
);
204 *obj
= &cp
->IConnectionPoint_iface
;
205 TRACE( "returning iface %p\n", *obj
);
209 static HRESULT WINAPI
cost_manager_QueryInterface(
210 INetworkCostManager
*iface
,
214 struct list_manager
*mgr
= impl_from_INetworkCostManager( iface
);
215 return INetworkListManager_QueryInterface( &mgr
->INetworkListManager_iface
, riid
, obj
);
218 static ULONG WINAPI
cost_manager_AddRef(
219 INetworkCostManager
*iface
)
221 struct list_manager
*mgr
= impl_from_INetworkCostManager( iface
);
222 return INetworkListManager_AddRef( &mgr
->INetworkListManager_iface
);
225 static ULONG WINAPI
cost_manager_Release(
226 INetworkCostManager
*iface
)
228 struct list_manager
*mgr
= impl_from_INetworkCostManager( iface
);
229 return INetworkListManager_Release( &mgr
->INetworkListManager_iface
);
232 static HRESULT WINAPI
cost_manager_GetCost(
233 INetworkCostManager
*iface
, DWORD
*pCost
, NLM_SOCKADDR
*pDestIPAddr
)
235 FIXME( "%p, %p, %p\n", iface
, pCost
, pDestIPAddr
);
237 if (!pCost
) return E_POINTER
;
239 *pCost
= NLM_CONNECTION_COST_UNRESTRICTED
;
243 static HRESULT WINAPI
cost_manager_GetDataPlanStatus(
244 INetworkCostManager
*iface
, NLM_DATAPLAN_STATUS
*pDataPlanStatus
,
245 NLM_SOCKADDR
*pDestIPAddr
)
247 FIXME( "%p, %p, %p\n", iface
, pDataPlanStatus
, pDestIPAddr
);
251 static HRESULT WINAPI
cost_manager_SetDestinationAddresses(
252 INetworkCostManager
*iface
, UINT32 length
, NLM_SOCKADDR
*pDestIPAddrList
,
253 VARIANT_BOOL bAppend
)
255 FIXME( "%p, %u, %p, %x\n", iface
, length
, pDestIPAddrList
, bAppend
);
259 static const INetworkCostManagerVtbl cost_manager_vtbl
=
261 cost_manager_QueryInterface
,
263 cost_manager_Release
,
264 cost_manager_GetCost
,
265 cost_manager_GetDataPlanStatus
,
266 cost_manager_SetDestinationAddresses
269 static inline struct list_manager
*impl_from_INetworkListManager(
270 INetworkListManager
*iface
)
272 return CONTAINING_RECORD( iface
, struct list_manager
, INetworkListManager_iface
);
275 static ULONG WINAPI
list_manager_AddRef(
276 INetworkListManager
*iface
)
278 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
279 return InterlockedIncrement( &mgr
->refs
);
282 static ULONG WINAPI
list_manager_Release(
283 INetworkListManager
*iface
)
285 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
286 LONG refs
= InterlockedDecrement( &mgr
->refs
);
289 TRACE( "destroying %p\n", mgr
);
290 HeapFree( GetProcessHeap(), 0, mgr
);
295 static HRESULT WINAPI
list_manager_QueryInterface(
296 INetworkListManager
*iface
,
300 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
302 TRACE( "%p, %s, %p\n", mgr
, debugstr_guid(riid
), obj
);
304 if (IsEqualGUID( riid
, &IID_INetworkListManager
) ||
305 IsEqualGUID( riid
, &IID_IUnknown
))
309 else if (IsEqualGUID( riid
, &IID_INetworkCostManager
))
311 *obj
= &mgr
->INetworkCostManager_iface
;
313 else if (IsEqualGUID( riid
, &IID_IConnectionPointContainer
))
315 *obj
= &mgr
->IConnectionPointContainer_iface
;
319 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
320 return E_NOINTERFACE
;
322 INetworkListManager_AddRef( iface
);
326 static HRESULT WINAPI
list_manager_GetTypeInfoCount(
327 INetworkListManager
*iface
,
334 static HRESULT WINAPI
list_manager_GetTypeInfo(
335 INetworkListManager
*iface
,
344 static HRESULT WINAPI
list_manager_GetIDsOfNames(
345 INetworkListManager
*iface
,
356 static HRESULT WINAPI
list_manager_Invoke(
357 INetworkListManager
*iface
,
364 EXCEPINFO
*excep_info
,
371 static HRESULT WINAPI
list_manager_GetNetworks(
372 INetworkListManager
*iface
,
373 NLM_ENUM_NETWORK Flags
,
374 IEnumNetworks
**ppEnumNetwork
)
376 FIXME( "%p, %x, %p\n", iface
, Flags
, ppEnumNetwork
);
380 static HRESULT WINAPI
list_manager_GetNetwork(
381 INetworkListManager
*iface
,
383 INetwork
**ppNetwork
)
385 FIXME( "%p, %s, %p\n", iface
, debugstr_guid(&gdNetworkId
), ppNetwork
);
389 static HRESULT WINAPI
list_manager_GetNetworkConnections(
390 INetworkListManager
*iface
,
391 IEnumNetworkConnections
**ppEnum
)
393 FIXME( "%p, %p\n", iface
, ppEnum
);
397 static HRESULT WINAPI
list_manager_GetNetworkConnection(
398 INetworkListManager
*iface
,
399 GUID gdNetworkConnectionId
,
400 INetworkConnection
**ppNetworkConnection
)
402 FIXME( "%p, %s, %p\n", iface
, debugstr_guid(&gdNetworkConnectionId
),
403 ppNetworkConnection
);
407 static HRESULT WINAPI
list_manager_IsConnectedToInternet(
408 INetworkListManager
*iface
,
409 VARIANT_BOOL
*pbIsConnected
)
411 FIXME( "%p, %p\n", iface
, pbIsConnected
);
413 *pbIsConnected
= VARIANT_TRUE
;
417 static HRESULT WINAPI
list_manager_IsConnected(
418 INetworkListManager
*iface
,
419 VARIANT_BOOL
*pbIsConnected
)
421 FIXME( "%p, %p\n", iface
, pbIsConnected
);
423 *pbIsConnected
= VARIANT_TRUE
;
427 static HRESULT WINAPI
list_manager_GetConnectivity(
428 INetworkListManager
*iface
,
429 NLM_CONNECTIVITY
*pConnectivity
)
431 FIXME( "%p, %p\n", iface
, pConnectivity
);
433 *pConnectivity
= NLM_CONNECTIVITY_IPV4_INTERNET
;
437 static const INetworkListManagerVtbl list_manager_vtbl
=
439 list_manager_QueryInterface
,
441 list_manager_Release
,
442 list_manager_GetTypeInfoCount
,
443 list_manager_GetTypeInfo
,
444 list_manager_GetIDsOfNames
,
446 list_manager_GetNetworks
,
447 list_manager_GetNetwork
,
448 list_manager_GetNetworkConnections
,
449 list_manager_GetNetworkConnection
,
450 list_manager_IsConnectedToInternet
,
451 list_manager_IsConnected
,
452 list_manager_GetConnectivity
455 static HRESULT WINAPI
ConnectionPointContainer_QueryInterface(IConnectionPointContainer
*iface
,
456 REFIID riid
, void **ppv
)
458 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
459 return INetworkListManager_QueryInterface(&This
->INetworkListManager_iface
, riid
, ppv
);
462 static ULONG WINAPI
ConnectionPointContainer_AddRef(IConnectionPointContainer
*iface
)
464 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
465 return INetworkListManager_AddRef(&This
->INetworkListManager_iface
);
468 static ULONG WINAPI
ConnectionPointContainer_Release(IConnectionPointContainer
*iface
)
470 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
471 return INetworkListManager_Release(&This
->INetworkListManager_iface
);
474 static HRESULT WINAPI
ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer
*iface
,
475 IEnumConnectionPoints
**ppEnum
)
477 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
478 FIXME("(%p)->(%p): stub\n", This
, ppEnum
);
482 static HRESULT WINAPI
ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer
*iface
,
483 REFIID riid
, IConnectionPoint
**cp
)
485 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
487 TRACE( "%p, %s, %p\n", This
, debugstr_guid(riid
), cp
);
492 if (IsEqualGUID( riid
, &IID_INetworkListManagerEvents
))
493 return connection_point_create( cp
, riid
, iface
);
495 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
498 return E_NOINTERFACE
;
501 static const struct IConnectionPointContainerVtbl cpc_vtbl
=
503 ConnectionPointContainer_QueryInterface
,
504 ConnectionPointContainer_AddRef
,
505 ConnectionPointContainer_Release
,
506 ConnectionPointContainer_EnumConnectionPoints
,
507 ConnectionPointContainer_FindConnectionPoint
510 HRESULT
list_manager_create( void **obj
)
512 struct list_manager
*mgr
;
514 TRACE( "%p\n", obj
);
516 if (!(mgr
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mgr
) ))) return E_OUTOFMEMORY
;
517 mgr
->INetworkListManager_iface
.lpVtbl
= &list_manager_vtbl
;
518 mgr
->INetworkCostManager_iface
.lpVtbl
= &cost_manager_vtbl
;
519 mgr
->IConnectionPointContainer_iface
.lpVtbl
= &cpc_vtbl
;
522 *obj
= &mgr
->INetworkListManager_iface
;
523 TRACE( "returning iface %p\n", *obj
);