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
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
37 #include "netlistmgr.h"
40 #include "wine/debug.h"
41 #include "wine/list.h"
42 #include "netprofm_private.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(netprofm
);
46 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size
)
48 return HeapAlloc(GetProcessHeap(), 0, size
);
51 static inline BOOL
heap_free(void *mem
)
53 return HeapFree(GetProcessHeap(), 0, mem
);
58 INetwork INetwork_iface
;
62 VARIANT_BOOL connected_to_internet
;
63 VARIANT_BOOL connected
;
68 INetworkConnection INetworkConnection_iface
;
69 INetworkConnectionCost INetworkConnectionCost_iface
;
74 VARIANT_BOOL connected_to_internet
;
75 VARIANT_BOOL connected
;
80 INetworkListManager INetworkListManager_iface
;
81 INetworkCostManager INetworkCostManager_iface
;
82 IConnectionPointContainer IConnectionPointContainer_iface
;
85 struct list connections
;
88 struct connection_point
90 IConnectionPoint IConnectionPoint_iface
;
91 IConnectionPointContainer
*container
;
96 static inline struct list_manager
*impl_from_IConnectionPointContainer(IConnectionPointContainer
*iface
)
98 return CONTAINING_RECORD(iface
, struct list_manager
, IConnectionPointContainer_iface
);
101 static inline struct list_manager
*impl_from_INetworkCostManager(
102 INetworkCostManager
*iface
)
104 return CONTAINING_RECORD( iface
, struct list_manager
, INetworkCostManager_iface
);
107 static inline struct connection_point
*impl_from_IConnectionPoint(
108 IConnectionPoint
*iface
)
110 return CONTAINING_RECORD( iface
, struct connection_point
, IConnectionPoint_iface
);
113 static HRESULT WINAPI
connection_point_QueryInterface(
114 IConnectionPoint
*iface
,
118 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
119 TRACE( "%p, %s, %p\n", cp
, debugstr_guid(riid
), obj
);
121 if (IsEqualGUID( riid
, &IID_IConnectionPoint
) ||
122 IsEqualGUID( riid
, &IID_IUnknown
))
128 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
130 return E_NOINTERFACE
;
132 IConnectionPoint_AddRef( iface
);
136 static ULONG WINAPI
connection_point_AddRef(
137 IConnectionPoint
*iface
)
139 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
140 return InterlockedIncrement( &cp
->refs
);
143 static ULONG WINAPI
connection_point_Release(
144 IConnectionPoint
*iface
)
146 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
147 LONG refs
= InterlockedDecrement( &cp
->refs
);
150 TRACE( "destroying %p\n", cp
);
151 IConnectionPointContainer_Release( cp
->container
);
157 static HRESULT WINAPI
connection_point_GetConnectionInterface(
158 IConnectionPoint
*iface
,
161 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
162 TRACE( "%p, %p\n", cp
, iid
);
167 memcpy( iid
, &cp
->iid
, sizeof(*iid
) );
171 static HRESULT WINAPI
connection_point_GetConnectionPointContainer(
172 IConnectionPoint
*iface
,
173 IConnectionPointContainer
**container
)
175 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
176 TRACE( "%p, %p\n", cp
, container
);
181 IConnectionPointContainer_AddRef( cp
->container
);
182 *container
= cp
->container
;
186 static HRESULT WINAPI
connection_point_Advise(
187 IConnectionPoint
*iface
,
191 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
192 FIXME( "%p, %p, %p - stub\n", cp
, sink
, cookie
);
194 if (!sink
|| !cookie
)
197 return CONNECT_E_CANNOTCONNECT
;
200 static HRESULT WINAPI
connection_point_Unadvise(
201 IConnectionPoint
*iface
,
204 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
205 FIXME( "%p, %d - stub\n", cp
, cookie
);
210 static HRESULT WINAPI
connection_point_EnumConnections(
211 IConnectionPoint
*iface
,
212 IEnumConnections
**connections
)
214 struct connection_point
*cp
= impl_from_IConnectionPoint( iface
);
215 FIXME( "%p, %p - stub\n", cp
, connections
);
220 static const IConnectionPointVtbl connection_point_vtbl
=
222 connection_point_QueryInterface
,
223 connection_point_AddRef
,
224 connection_point_Release
,
225 connection_point_GetConnectionInterface
,
226 connection_point_GetConnectionPointContainer
,
227 connection_point_Advise
,
228 connection_point_Unadvise
,
229 connection_point_EnumConnections
232 static HRESULT
connection_point_create(
233 IConnectionPoint
**obj
,
235 IConnectionPointContainer
*container
)
237 struct connection_point
*cp
;
238 TRACE( "%p, %s, %p\n", obj
, debugstr_guid(riid
), container
);
240 if (!(cp
= heap_alloc( sizeof(*cp
) ))) return E_OUTOFMEMORY
;
241 cp
->IConnectionPoint_iface
.lpVtbl
= &connection_point_vtbl
;
242 cp
->container
= container
;
245 memcpy( &cp
->iid
, riid
, sizeof(*riid
) );
246 IConnectionPointContainer_AddRef( container
);
248 *obj
= &cp
->IConnectionPoint_iface
;
249 TRACE( "returning iface %p\n", *obj
);
253 static inline struct network
*impl_from_INetwork(
256 return CONTAINING_RECORD( iface
, struct network
, INetwork_iface
);
259 static HRESULT WINAPI
network_QueryInterface(
260 INetwork
*iface
, REFIID riid
, void **obj
)
262 struct network
*network
= impl_from_INetwork( iface
);
264 TRACE( "%p, %s, %p\n", network
, debugstr_guid(riid
), obj
);
266 if (IsEqualIID( riid
, &IID_INetwork
) ||
267 IsEqualIID( riid
, &IID_IDispatch
) ||
268 IsEqualIID( riid
, &IID_IUnknown
))
271 INetwork_AddRef( iface
);
276 WARN( "interface not supported %s\n", debugstr_guid(riid
) );
278 return E_NOINTERFACE
;
282 static ULONG WINAPI
network_AddRef(
285 struct network
*network
= impl_from_INetwork( iface
);
287 TRACE( "%p\n", network
);
288 return InterlockedIncrement( &network
->refs
);
291 static ULONG WINAPI
network_Release(
294 struct network
*network
= impl_from_INetwork( iface
);
297 TRACE( "%p\n", network
);
299 if (!(refs
= InterlockedDecrement( &network
->refs
)))
301 list_remove( &network
->entry
);
302 heap_free( network
);
307 static HRESULT WINAPI
network_GetTypeInfoCount(
315 static HRESULT WINAPI
network_GetTypeInfo(
325 static HRESULT WINAPI
network_GetIDsOfNames(
337 static HRESULT WINAPI
network_Invoke(
345 EXCEPINFO
*excep_info
,
352 static HRESULT WINAPI
network_GetName(
354 BSTR
*pszNetworkName
)
356 FIXME( "%p, %p\n", iface
, pszNetworkName
);
360 static HRESULT WINAPI
network_SetName(
362 BSTR szNetworkNewName
)
364 FIXME( "%p, %s\n", iface
, debugstr_w(szNetworkNewName
) );
368 static HRESULT WINAPI
network_GetDescription(
370 BSTR
*pszDescription
)
372 FIXME( "%p, %p\n", iface
, pszDescription
);
376 static HRESULT WINAPI
network_SetDescription(
380 FIXME( "%p, %s\n", iface
, debugstr_w(szDescription
) );
384 static HRESULT WINAPI
network_GetNetworkId(
386 GUID
*pgdGuidNetworkId
)
388 struct network
*network
= impl_from_INetwork( iface
);
390 TRACE( "%p, %p\n", iface
, pgdGuidNetworkId
);
392 *pgdGuidNetworkId
= network
->id
;
396 static HRESULT WINAPI
network_GetDomainType(
398 NLM_DOMAIN_TYPE
*pDomainType
)
400 FIXME( "%p, %p\n", iface
, pDomainType
);
402 *pDomainType
= NLM_DOMAIN_TYPE_NON_DOMAIN_NETWORK
;
406 static HRESULT WINAPI
network_GetNetworkConnections(
408 IEnumNetworkConnections
**ppEnumNetworkConnection
)
410 FIXME( "%p, %p\n", iface
, ppEnumNetworkConnection
);
414 static HRESULT WINAPI
network_GetTimeCreatedAndConnected(
416 DWORD
*pdwLowDateTimeCreated
,
417 DWORD
*pdwHighDateTimeCreated
,
418 DWORD
*pdwLowDateTimeConnected
,
419 DWORD
*pdwHighDateTimeConnected
)
421 FIXME( "%p, %p, %p, %p, %p\n", iface
, pdwLowDateTimeCreated
, pdwHighDateTimeCreated
,
422 pdwLowDateTimeConnected
, pdwHighDateTimeConnected
);
426 static HRESULT WINAPI
network_get_IsConnectedToInternet(
428 VARIANT_BOOL
*pbIsConnected
)
430 struct network
*network
= impl_from_INetwork( iface
);
432 TRACE( "%p, %p\n", iface
, pbIsConnected
);
434 *pbIsConnected
= network
->connected_to_internet
;
438 static HRESULT WINAPI
network_get_IsConnected(
440 VARIANT_BOOL
*pbIsConnected
)
442 struct network
*network
= impl_from_INetwork( iface
);
444 TRACE( "%p, %p\n", iface
, pbIsConnected
);
446 *pbIsConnected
= network
->connected
;
450 static HRESULT WINAPI
network_GetConnectivity(
452 NLM_CONNECTIVITY
*pConnectivity
)
454 FIXME( "%p, %p\n", iface
, pConnectivity
);
456 *pConnectivity
= NLM_CONNECTIVITY_IPV4_INTERNET
;
460 static HRESULT WINAPI
network_GetCategory(
462 NLM_NETWORK_CATEGORY
*pCategory
)
464 FIXME( "%p, %p\n", iface
, pCategory
);
466 *pCategory
= NLM_NETWORK_CATEGORY_PUBLIC
;
470 static HRESULT WINAPI
network_SetCategory(
472 NLM_NETWORK_CATEGORY NewCategory
)
474 FIXME( "%p, %u\n", iface
, NewCategory
);
478 static const struct INetworkVtbl network_vtbl
=
480 network_QueryInterface
,
483 network_GetTypeInfoCount
,
485 network_GetIDsOfNames
,
489 network_GetDescription
,
490 network_SetDescription
,
491 network_GetNetworkId
,
492 network_GetDomainType
,
493 network_GetNetworkConnections
,
494 network_GetTimeCreatedAndConnected
,
495 network_get_IsConnectedToInternet
,
496 network_get_IsConnected
,
497 network_GetConnectivity
,
502 static struct network
*create_network( const GUID
*id
)
506 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
508 ret
->INetwork_iface
.lpVtbl
= &network_vtbl
;
511 ret
->connected
= VARIANT_FALSE
;
512 ret
->connected_to_internet
= VARIANT_FALSE
;
513 list_init( &ret
->entry
);
518 static HRESULT WINAPI
cost_manager_QueryInterface(
519 INetworkCostManager
*iface
,
523 struct list_manager
*mgr
= impl_from_INetworkCostManager( iface
);
524 return INetworkListManager_QueryInterface( &mgr
->INetworkListManager_iface
, riid
, obj
);
527 static ULONG WINAPI
cost_manager_AddRef(
528 INetworkCostManager
*iface
)
530 struct list_manager
*mgr
= impl_from_INetworkCostManager( iface
);
531 return INetworkListManager_AddRef( &mgr
->INetworkListManager_iface
);
534 static ULONG WINAPI
cost_manager_Release(
535 INetworkCostManager
*iface
)
537 struct list_manager
*mgr
= impl_from_INetworkCostManager( iface
);
538 return INetworkListManager_Release( &mgr
->INetworkListManager_iface
);
541 static HRESULT WINAPI
cost_manager_GetCost(
542 INetworkCostManager
*iface
, DWORD
*pCost
, NLM_SOCKADDR
*pDestIPAddr
)
544 FIXME( "%p, %p, %p\n", iface
, pCost
, pDestIPAddr
);
546 if (!pCost
) return E_POINTER
;
548 *pCost
= NLM_CONNECTION_COST_UNRESTRICTED
;
552 static BOOL
map_address_6to4( const SOCKADDR_IN6
*addr6
, SOCKADDR_IN
*addr4
)
556 if (addr6
->sin6_family
!= WS_AF_INET6
) return FALSE
;
558 for (i
= 0; i
< 5; i
++)
559 if (addr6
->sin6_addr
.u
.Word
[i
]) return FALSE
;
561 if (addr6
->sin6_addr
.u
.Word
[5] != 0xffff) return FALSE
;
563 addr4
->sin_family
= WS_AF_INET
;
564 addr4
->sin_port
= addr6
->sin6_port
;
565 addr4
->sin_addr
.S_un
.S_addr
= addr6
->sin6_addr
.u
.Word
[6] << 16 | addr6
->sin6_addr
.u
.Word
[7];
566 memset( &addr4
->sin_zero
, 0, sizeof(addr4
->sin_zero
) );
571 static HRESULT WINAPI
cost_manager_GetDataPlanStatus(
572 INetworkCostManager
*iface
, NLM_DATAPLAN_STATUS
*pDataPlanStatus
,
573 NLM_SOCKADDR
*pDestIPAddr
)
577 SOCKADDR
*dst
= (SOCKADDR
*)pDestIPAddr
;
578 SOCKADDR_IN addr4
, *dst4
;
580 FIXME( "%p, %p, %p\n", iface
, pDataPlanStatus
, pDestIPAddr
);
582 if (!pDataPlanStatus
) return E_POINTER
;
584 if (dst
&& ((dst
->sa_family
== WS_AF_INET
&& (dst4
= (SOCKADDR_IN
*)dst
)) ||
585 ((dst
->sa_family
== WS_AF_INET6
&& map_address_6to4( (const SOCKADDR_IN6
*)dst
, &addr4
)
586 && (dst4
= &addr4
)))))
588 if ((ret
= GetBestInterface( dst4
->sin_addr
.S_un
.S_addr
, &index
)))
589 return HRESULT_FROM_WIN32( ret
);
591 if ((ret
= ConvertInterfaceIndexToLuid( index
, &luid
)))
592 return HRESULT_FROM_WIN32( ret
);
594 if ((ret
= ConvertInterfaceLuidToGuid( &luid
, &pDataPlanStatus
->InterfaceGuid
)))
595 return HRESULT_FROM_WIN32( ret
);
599 FIXME( "interface guid not found\n" );
600 memset( &pDataPlanStatus
->InterfaceGuid
, 0, sizeof(pDataPlanStatus
->InterfaceGuid
) );
603 pDataPlanStatus
->UsageData
.UsageInMegabytes
= NLM_UNKNOWN_DATAPLAN_STATUS
;
604 memset( &pDataPlanStatus
->UsageData
.LastSyncTime
, 0, sizeof(pDataPlanStatus
->UsageData
.LastSyncTime
) );
605 pDataPlanStatus
->DataLimitInMegabytes
= NLM_UNKNOWN_DATAPLAN_STATUS
;
606 pDataPlanStatus
->InboundBandwidthInKbps
= NLM_UNKNOWN_DATAPLAN_STATUS
;
607 pDataPlanStatus
->OutboundBandwidthInKbps
= NLM_UNKNOWN_DATAPLAN_STATUS
;
608 memset( &pDataPlanStatus
->NextBillingCycle
, 0, sizeof(pDataPlanStatus
->NextBillingCycle
) );
609 pDataPlanStatus
->MaxTransferSizeInMegabytes
= NLM_UNKNOWN_DATAPLAN_STATUS
;
610 pDataPlanStatus
->Reserved
= 0;
615 static HRESULT WINAPI
cost_manager_SetDestinationAddresses(
616 INetworkCostManager
*iface
, UINT32 length
, NLM_SOCKADDR
*pDestIPAddrList
,
617 VARIANT_BOOL bAppend
)
619 FIXME( "%p, %u, %p, %x\n", iface
, length
, pDestIPAddrList
, bAppend
);
623 static const INetworkCostManagerVtbl cost_manager_vtbl
=
625 cost_manager_QueryInterface
,
627 cost_manager_Release
,
628 cost_manager_GetCost
,
629 cost_manager_GetDataPlanStatus
,
630 cost_manager_SetDestinationAddresses
635 IEnumNetworks IEnumNetworks_iface
;
637 struct list_manager
*mgr
;
641 static inline struct networks_enum
*impl_from_IEnumNetworks(
642 IEnumNetworks
*iface
)
644 return CONTAINING_RECORD( iface
, struct networks_enum
, IEnumNetworks_iface
);
647 static HRESULT WINAPI
networks_enum_QueryInterface(
648 IEnumNetworks
*iface
, REFIID riid
, void **obj
)
650 struct networks_enum
*iter
= impl_from_IEnumNetworks( iface
);
652 TRACE( "%p, %s, %p\n", iter
, debugstr_guid(riid
), obj
);
654 if (IsEqualIID( riid
, &IID_IEnumNetworks
) ||
655 IsEqualIID( riid
, &IID_IDispatch
) ||
656 IsEqualIID( riid
, &IID_IUnknown
))
659 IEnumNetworks_AddRef( iface
);
664 WARN( "interface not supported %s\n", debugstr_guid(riid
) );
666 return E_NOINTERFACE
;
670 static ULONG WINAPI
networks_enum_AddRef(
671 IEnumNetworks
*iface
)
673 struct networks_enum
*iter
= impl_from_IEnumNetworks( iface
);
675 TRACE( "%p\n", iter
);
676 return InterlockedIncrement( &iter
->refs
);
679 static ULONG WINAPI
networks_enum_Release(
680 IEnumNetworks
*iface
)
682 struct networks_enum
*iter
= impl_from_IEnumNetworks( iface
);
685 TRACE( "%p\n", iter
);
687 if (!(refs
= InterlockedDecrement( &iter
->refs
)))
689 INetworkListManager_Release( &iter
->mgr
->INetworkListManager_iface
);
695 static HRESULT WINAPI
networks_enum_GetTypeInfoCount(
696 IEnumNetworks
*iface
,
703 static HRESULT WINAPI
networks_enum_GetTypeInfo(
704 IEnumNetworks
*iface
,
713 static HRESULT WINAPI
networks_enum_GetIDsOfNames(
714 IEnumNetworks
*iface
,
725 static HRESULT WINAPI
networks_enum_Invoke(
726 IEnumNetworks
*iface
,
733 EXCEPINFO
*excep_info
,
740 static HRESULT WINAPI
networks_enum_get__NewEnum(
741 IEnumNetworks
*iface
, IEnumVARIANT
**ppEnumVar
)
747 static HRESULT WINAPI
networks_enum_Next(
748 IEnumNetworks
*iface
, ULONG count
, INetwork
**ret
, ULONG
*fetched
)
750 struct networks_enum
*iter
= impl_from_IEnumNetworks( iface
);
753 TRACE( "%p, %u %p %p\n", iter
, count
, ret
, fetched
);
755 if (fetched
) *fetched
= 0;
756 if (!count
) return S_OK
;
758 while (iter
->cursor
&& i
< count
)
760 struct network
*network
= LIST_ENTRY( iter
->cursor
, struct network
, entry
);
761 ret
[i
] = &network
->INetwork_iface
;
762 INetwork_AddRef( ret
[i
] );
763 iter
->cursor
= list_next( &iter
->mgr
->networks
, iter
->cursor
);
766 if (fetched
) *fetched
= i
;
768 return i
< count
? S_FALSE
: S_OK
;
771 static HRESULT WINAPI
networks_enum_Skip(
772 IEnumNetworks
*iface
, ULONG count
)
774 struct networks_enum
*iter
= impl_from_IEnumNetworks( iface
);
776 TRACE( "%p, %u\n", iter
, count
);
778 if (!count
) return S_OK
;
779 if (!iter
->cursor
) return S_FALSE
;
783 iter
->cursor
= list_next( &iter
->mgr
->networks
, iter
->cursor
);
784 if (!iter
->cursor
) break;
787 return count
? S_FALSE
: S_OK
;
790 static HRESULT WINAPI
networks_enum_Reset(
791 IEnumNetworks
*iface
)
793 struct networks_enum
*iter
= impl_from_IEnumNetworks( iface
);
795 TRACE( "%p\n", iter
);
797 iter
->cursor
= list_head( &iter
->mgr
->networks
);
801 static HRESULT
create_networks_enum(
802 struct list_manager
*, IEnumNetworks
** );
804 static HRESULT WINAPI
networks_enum_Clone(
805 IEnumNetworks
*iface
, IEnumNetworks
**ret
)
807 struct networks_enum
*iter
= impl_from_IEnumNetworks( iface
);
809 TRACE( "%p, %p\n", iter
, ret
);
810 return create_networks_enum( iter
->mgr
, ret
);
813 static const IEnumNetworksVtbl networks_enum_vtbl
=
815 networks_enum_QueryInterface
,
816 networks_enum_AddRef
,
817 networks_enum_Release
,
818 networks_enum_GetTypeInfoCount
,
819 networks_enum_GetTypeInfo
,
820 networks_enum_GetIDsOfNames
,
821 networks_enum_Invoke
,
822 networks_enum_get__NewEnum
,
829 static HRESULT
create_networks_enum(
830 struct list_manager
*mgr
, IEnumNetworks
**ret
)
832 struct networks_enum
*iter
;
835 if (!(iter
= heap_alloc( sizeof(*iter
) ))) return E_OUTOFMEMORY
;
837 iter
->IEnumNetworks_iface
.lpVtbl
= &networks_enum_vtbl
;
838 iter
->cursor
= list_head( &mgr
->networks
);
840 INetworkListManager_AddRef( &mgr
->INetworkListManager_iface
);
843 *ret
= &iter
->IEnumNetworks_iface
;
847 static inline struct list_manager
*impl_from_INetworkListManager(
848 INetworkListManager
*iface
)
850 return CONTAINING_RECORD( iface
, struct list_manager
, INetworkListManager_iface
);
853 struct connections_enum
855 IEnumNetworkConnections IEnumNetworkConnections_iface
;
857 struct list_manager
*mgr
;
861 static inline struct connections_enum
*impl_from_IEnumNetworkConnections(
862 IEnumNetworkConnections
*iface
)
864 return CONTAINING_RECORD( iface
, struct connections_enum
, IEnumNetworkConnections_iface
);
867 static HRESULT WINAPI
connections_enum_QueryInterface(
868 IEnumNetworkConnections
*iface
, REFIID riid
, void **obj
)
870 struct connections_enum
*iter
= impl_from_IEnumNetworkConnections( iface
);
872 TRACE( "%p, %s, %p\n", iter
, debugstr_guid(riid
), obj
);
874 if (IsEqualIID( riid
, &IID_IEnumNetworkConnections
) ||
875 IsEqualIID( riid
, &IID_IDispatch
) ||
876 IsEqualIID( riid
, &IID_IUnknown
))
879 IEnumNetworkConnections_AddRef( iface
);
884 WARN( "interface not supported %s\n", debugstr_guid(riid
) );
886 return E_NOINTERFACE
;
890 static ULONG WINAPI
connections_enum_AddRef(
891 IEnumNetworkConnections
*iface
)
893 struct connections_enum
*iter
= impl_from_IEnumNetworkConnections( iface
);
895 TRACE( "%p\n", iter
);
896 return InterlockedIncrement( &iter
->refs
);
899 static ULONG WINAPI
connections_enum_Release(
900 IEnumNetworkConnections
*iface
)
902 struct connections_enum
*iter
= impl_from_IEnumNetworkConnections( iface
);
905 TRACE( "%p\n", iter
);
907 if (!(refs
= InterlockedDecrement( &iter
->refs
)))
909 INetworkListManager_Release( &iter
->mgr
->INetworkListManager_iface
);
915 static HRESULT WINAPI
connections_enum_GetTypeInfoCount(
916 IEnumNetworkConnections
*iface
,
923 static HRESULT WINAPI
connections_enum_GetTypeInfo(
924 IEnumNetworkConnections
*iface
,
933 static HRESULT WINAPI
connections_enum_GetIDsOfNames(
934 IEnumNetworkConnections
*iface
,
945 static HRESULT WINAPI
connections_enum_Invoke(
946 IEnumNetworkConnections
*iface
,
953 EXCEPINFO
*excep_info
,
960 static HRESULT WINAPI
connections_enum_get__NewEnum(
961 IEnumNetworkConnections
*iface
, IEnumVARIANT
**ppEnumVar
)
967 static HRESULT WINAPI
connections_enum_Next(
968 IEnumNetworkConnections
*iface
, ULONG count
, INetworkConnection
**ret
, ULONG
*fetched
)
970 struct connections_enum
*iter
= impl_from_IEnumNetworkConnections( iface
);
973 TRACE( "%p, %u %p %p\n", iter
, count
, ret
, fetched
);
975 if (fetched
) *fetched
= 0;
976 if (!count
) return S_OK
;
978 while (iter
->cursor
&& i
< count
)
980 struct connection
*connection
= LIST_ENTRY( iter
->cursor
, struct connection
, entry
);
981 ret
[i
] = &connection
->INetworkConnection_iface
;
982 INetworkConnection_AddRef( ret
[i
] );
983 iter
->cursor
= list_next( &iter
->mgr
->connections
, iter
->cursor
);
986 if (fetched
) *fetched
= i
;
988 return i
< count
? S_FALSE
: S_OK
;
991 static HRESULT WINAPI
connections_enum_Skip(
992 IEnumNetworkConnections
*iface
, ULONG count
)
994 struct connections_enum
*iter
= impl_from_IEnumNetworkConnections( iface
);
996 TRACE( "%p, %u\n", iter
, count
);
998 if (!count
) return S_OK
;
999 if (!iter
->cursor
) return S_FALSE
;
1003 iter
->cursor
= list_next( &iter
->mgr
->connections
, iter
->cursor
);
1004 if (!iter
->cursor
) break;
1007 return count
? S_FALSE
: S_OK
;
1010 static HRESULT WINAPI
connections_enum_Reset(
1011 IEnumNetworkConnections
*iface
)
1013 struct connections_enum
*iter
= impl_from_IEnumNetworkConnections( iface
);
1015 TRACE( "%p\n", iter
);
1017 iter
->cursor
= list_head( &iter
->mgr
->connections
);
1021 static HRESULT
create_connections_enum(
1022 struct list_manager
*, IEnumNetworkConnections
** );
1024 static HRESULT WINAPI
connections_enum_Clone(
1025 IEnumNetworkConnections
*iface
, IEnumNetworkConnections
**ret
)
1027 struct connections_enum
*iter
= impl_from_IEnumNetworkConnections( iface
);
1029 TRACE( "%p, %p\n", iter
, ret
);
1030 return create_connections_enum( iter
->mgr
, ret
);
1033 static const IEnumNetworkConnectionsVtbl connections_enum_vtbl
=
1035 connections_enum_QueryInterface
,
1036 connections_enum_AddRef
,
1037 connections_enum_Release
,
1038 connections_enum_GetTypeInfoCount
,
1039 connections_enum_GetTypeInfo
,
1040 connections_enum_GetIDsOfNames
,
1041 connections_enum_Invoke
,
1042 connections_enum_get__NewEnum
,
1043 connections_enum_Next
,
1044 connections_enum_Skip
,
1045 connections_enum_Reset
,
1046 connections_enum_Clone
1049 static HRESULT
create_connections_enum(
1050 struct list_manager
*mgr
, IEnumNetworkConnections
**ret
)
1052 struct connections_enum
*iter
;
1055 if (!(iter
= heap_alloc( sizeof(*iter
) ))) return E_OUTOFMEMORY
;
1057 iter
->IEnumNetworkConnections_iface
.lpVtbl
= &connections_enum_vtbl
;
1059 INetworkListManager_AddRef( &mgr
->INetworkListManager_iface
);
1060 iter
->cursor
= list_head( &iter
->mgr
->connections
);
1063 *ret
= &iter
->IEnumNetworkConnections_iface
;
1067 static ULONG WINAPI
list_manager_AddRef(
1068 INetworkListManager
*iface
)
1070 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1071 return InterlockedIncrement( &mgr
->refs
);
1074 static ULONG WINAPI
list_manager_Release(
1075 INetworkListManager
*iface
)
1077 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1078 LONG refs
= InterlockedDecrement( &mgr
->refs
);
1083 TRACE( "destroying %p\n", mgr
);
1085 while ((ptr
= list_head( &mgr
->networks
)))
1087 struct network
*network
= LIST_ENTRY( ptr
, struct network
, entry
);
1088 list_remove( &network
->entry
);
1089 INetwork_Release( &network
->INetwork_iface
);
1091 while ((ptr
= list_head( &mgr
->connections
)))
1093 struct connection
*connection
= LIST_ENTRY( ptr
, struct connection
, entry
);
1094 list_remove( &connection
->entry
);
1095 INetworkConnection_Release( &connection
->INetworkConnection_iface
);
1102 static HRESULT WINAPI
list_manager_QueryInterface(
1103 INetworkListManager
*iface
,
1107 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1109 TRACE( "%p, %s, %p\n", mgr
, debugstr_guid(riid
), obj
);
1111 if (IsEqualGUID( riid
, &IID_INetworkListManager
) ||
1112 IsEqualGUID( riid
, &IID_IDispatch
) ||
1113 IsEqualGUID( riid
, &IID_IUnknown
))
1117 else if (IsEqualGUID( riid
, &IID_INetworkCostManager
))
1119 *obj
= &mgr
->INetworkCostManager_iface
;
1121 else if (IsEqualGUID( riid
, &IID_IConnectionPointContainer
))
1123 *obj
= &mgr
->IConnectionPointContainer_iface
;
1127 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1129 return E_NOINTERFACE
;
1131 INetworkListManager_AddRef( iface
);
1135 static HRESULT WINAPI
list_manager_GetTypeInfoCount(
1136 INetworkListManager
*iface
,
1143 static HRESULT WINAPI
list_manager_GetTypeInfo(
1144 INetworkListManager
*iface
,
1153 static HRESULT WINAPI
list_manager_GetIDsOfNames(
1154 INetworkListManager
*iface
,
1165 static HRESULT WINAPI
list_manager_Invoke(
1166 INetworkListManager
*iface
,
1173 EXCEPINFO
*excep_info
,
1180 static HRESULT WINAPI
list_manager_GetNetworks(
1181 INetworkListManager
*iface
,
1182 NLM_ENUM_NETWORK Flags
,
1183 IEnumNetworks
**ppEnumNetwork
)
1185 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1187 TRACE( "%p, %x, %p\n", iface
, Flags
, ppEnumNetwork
);
1188 if (Flags
) FIXME( "flags %08x not supported\n", Flags
);
1190 return create_networks_enum( mgr
, ppEnumNetwork
);
1193 static HRESULT WINAPI
list_manager_GetNetwork(
1194 INetworkListManager
*iface
,
1196 INetwork
**ppNetwork
)
1198 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1199 struct network
*network
;
1201 TRACE( "%p, %s, %p\n", iface
, debugstr_guid(&gdNetworkId
), ppNetwork
);
1203 LIST_FOR_EACH_ENTRY( network
, &mgr
->networks
, struct network
, entry
)
1205 if (IsEqualGUID( &network
->id
, &gdNetworkId
))
1207 *ppNetwork
= &network
->INetwork_iface
;
1208 INetwork_AddRef( *ppNetwork
);
1216 static HRESULT WINAPI
list_manager_GetNetworkConnections(
1217 INetworkListManager
*iface
,
1218 IEnumNetworkConnections
**ppEnum
)
1220 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1222 TRACE( "%p, %p\n", iface
, ppEnum
);
1223 return create_connections_enum( mgr
, ppEnum
);
1226 static HRESULT WINAPI
list_manager_GetNetworkConnection(
1227 INetworkListManager
*iface
,
1228 GUID gdNetworkConnectionId
,
1229 INetworkConnection
**ppNetworkConnection
)
1231 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1232 struct connection
*connection
;
1234 TRACE( "%p, %s, %p\n", iface
, debugstr_guid(&gdNetworkConnectionId
),
1235 ppNetworkConnection
);
1237 LIST_FOR_EACH_ENTRY( connection
, &mgr
->connections
, struct connection
, entry
)
1239 if (IsEqualGUID( &connection
->id
, &gdNetworkConnectionId
))
1241 *ppNetworkConnection
= &connection
->INetworkConnection_iface
;
1242 INetworkConnection_AddRef( *ppNetworkConnection
);
1250 static HRESULT WINAPI
list_manager_IsConnectedToInternet(
1251 INetworkListManager
*iface
,
1252 VARIANT_BOOL
*pbIsConnected
)
1254 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1255 struct network
*network
;
1257 TRACE( "%p, %p\n", iface
, pbIsConnected
);
1259 LIST_FOR_EACH_ENTRY( network
, &mgr
->networks
, struct network
, entry
)
1261 if (network
->connected_to_internet
)
1263 *pbIsConnected
= VARIANT_TRUE
;
1268 *pbIsConnected
= VARIANT_FALSE
;
1272 static HRESULT WINAPI
list_manager_IsConnected(
1273 INetworkListManager
*iface
,
1274 VARIANT_BOOL
*pbIsConnected
)
1276 struct list_manager
*mgr
= impl_from_INetworkListManager( iface
);
1277 struct network
*network
;
1279 TRACE( "%p, %p\n", iface
, pbIsConnected
);
1281 LIST_FOR_EACH_ENTRY( network
, &mgr
->networks
, struct network
, entry
)
1283 if (network
->connected
)
1285 *pbIsConnected
= VARIANT_TRUE
;
1290 *pbIsConnected
= VARIANT_FALSE
;
1294 static HRESULT WINAPI
list_manager_GetConnectivity(
1295 INetworkListManager
*iface
,
1296 NLM_CONNECTIVITY
*pConnectivity
)
1298 FIXME( "%p, %p\n", iface
, pConnectivity
);
1300 *pConnectivity
= NLM_CONNECTIVITY_IPV4_INTERNET
;
1304 static const INetworkListManagerVtbl list_manager_vtbl
=
1306 list_manager_QueryInterface
,
1307 list_manager_AddRef
,
1308 list_manager_Release
,
1309 list_manager_GetTypeInfoCount
,
1310 list_manager_GetTypeInfo
,
1311 list_manager_GetIDsOfNames
,
1312 list_manager_Invoke
,
1313 list_manager_GetNetworks
,
1314 list_manager_GetNetwork
,
1315 list_manager_GetNetworkConnections
,
1316 list_manager_GetNetworkConnection
,
1317 list_manager_IsConnectedToInternet
,
1318 list_manager_IsConnected
,
1319 list_manager_GetConnectivity
1322 static HRESULT WINAPI
ConnectionPointContainer_QueryInterface(IConnectionPointContainer
*iface
,
1323 REFIID riid
, void **ppv
)
1325 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
1326 return INetworkListManager_QueryInterface(&This
->INetworkListManager_iface
, riid
, ppv
);
1329 static ULONG WINAPI
ConnectionPointContainer_AddRef(IConnectionPointContainer
*iface
)
1331 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
1332 return INetworkListManager_AddRef(&This
->INetworkListManager_iface
);
1335 static ULONG WINAPI
ConnectionPointContainer_Release(IConnectionPointContainer
*iface
)
1337 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
1338 return INetworkListManager_Release(&This
->INetworkListManager_iface
);
1341 static HRESULT WINAPI
ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer
*iface
,
1342 IEnumConnectionPoints
**ppEnum
)
1344 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
1345 FIXME("(%p)->(%p): stub\n", This
, ppEnum
);
1349 static HRESULT WINAPI
ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer
*iface
,
1350 REFIID riid
, IConnectionPoint
**cp
)
1352 struct list_manager
*This
= impl_from_IConnectionPointContainer( iface
);
1354 TRACE( "%p, %s, %p\n", This
, debugstr_guid(riid
), cp
);
1359 if (IsEqualGUID( riid
, &IID_INetworkListManagerEvents
) ||
1360 IsEqualGUID( riid
, &IID_INetworkCostManagerEvents
) ||
1361 IsEqualGUID( riid
, &IID_INetworkConnectionEvents
))
1362 return connection_point_create( cp
, riid
, iface
);
1364 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1367 return E_NOINTERFACE
;
1370 static const struct IConnectionPointContainerVtbl cpc_vtbl
=
1372 ConnectionPointContainer_QueryInterface
,
1373 ConnectionPointContainer_AddRef
,
1374 ConnectionPointContainer_Release
,
1375 ConnectionPointContainer_EnumConnectionPoints
,
1376 ConnectionPointContainer_FindConnectionPoint
1379 static inline struct connection
*impl_from_INetworkConnection(
1380 INetworkConnection
*iface
)
1382 return CONTAINING_RECORD( iface
, struct connection
, INetworkConnection_iface
);
1385 static HRESULT WINAPI
connection_QueryInterface(
1386 INetworkConnection
*iface
, REFIID riid
, void **obj
)
1388 struct connection
*connection
= impl_from_INetworkConnection( iface
);
1390 TRACE( "%p, %s, %p\n", connection
, debugstr_guid(riid
), obj
);
1392 if (IsEqualIID( riid
, &IID_INetworkConnection
) ||
1393 IsEqualIID( riid
, &IID_IDispatch
) ||
1394 IsEqualIID( riid
, &IID_IUnknown
))
1398 else if (IsEqualIID( riid
, &IID_INetworkConnectionCost
))
1400 *obj
= &connection
->INetworkConnectionCost_iface
;
1404 WARN( "interface not supported %s\n", debugstr_guid(riid
) );
1406 return E_NOINTERFACE
;
1408 INetworkConnection_AddRef( iface
);
1412 static ULONG WINAPI
connection_AddRef(
1413 INetworkConnection
*iface
)
1415 struct connection
*connection
= impl_from_INetworkConnection( iface
);
1417 TRACE( "%p\n", connection
);
1418 return InterlockedIncrement( &connection
->refs
);
1421 static ULONG WINAPI
connection_Release(
1422 INetworkConnection
*iface
)
1424 struct connection
*connection
= impl_from_INetworkConnection( iface
);
1427 TRACE( "%p\n", connection
);
1429 if (!(refs
= InterlockedDecrement( &connection
->refs
)))
1431 INetwork_Release( connection
->network
);
1432 list_remove( &connection
->entry
);
1433 heap_free( connection
);
1438 static HRESULT WINAPI
connection_GetTypeInfoCount(
1439 INetworkConnection
*iface
,
1446 static HRESULT WINAPI
connection_GetTypeInfo(
1447 INetworkConnection
*iface
,
1456 static HRESULT WINAPI
connection_GetIDsOfNames(
1457 INetworkConnection
*iface
,
1468 static HRESULT WINAPI
connection_Invoke(
1469 INetworkConnection
*iface
,
1476 EXCEPINFO
*excep_info
,
1483 static HRESULT WINAPI
connection_GetNetwork(
1484 INetworkConnection
*iface
,
1485 INetwork
**ppNetwork
)
1487 struct connection
*connection
= impl_from_INetworkConnection( iface
);
1489 TRACE( "%p, %p\n", iface
, ppNetwork
);
1491 *ppNetwork
= connection
->network
;
1492 INetwork_AddRef( *ppNetwork
);
1496 static HRESULT WINAPI
connection_get_IsConnectedToInternet(
1497 INetworkConnection
*iface
,
1498 VARIANT_BOOL
*pbIsConnected
)
1500 struct connection
*connection
= impl_from_INetworkConnection( iface
);
1502 TRACE( "%p, %p\n", iface
, pbIsConnected
);
1504 *pbIsConnected
= connection
->connected_to_internet
;
1508 static HRESULT WINAPI
connection_get_IsConnected(
1509 INetworkConnection
*iface
,
1510 VARIANT_BOOL
*pbIsConnected
)
1512 struct connection
*connection
= impl_from_INetworkConnection( iface
);
1514 TRACE( "%p, %p\n", iface
, pbIsConnected
);
1516 *pbIsConnected
= connection
->connected
;
1520 static HRESULT WINAPI
connection_GetConnectivity(
1521 INetworkConnection
*iface
,
1522 NLM_CONNECTIVITY
*pConnectivity
)
1524 FIXME( "%p, %p\n", iface
, pConnectivity
);
1526 *pConnectivity
= NLM_CONNECTIVITY_IPV4_INTERNET
;
1530 static HRESULT WINAPI
connection_GetConnectionId(
1531 INetworkConnection
*iface
,
1532 GUID
*pgdConnectionId
)
1534 struct connection
*connection
= impl_from_INetworkConnection( iface
);
1536 TRACE( "%p, %p\n", iface
, pgdConnectionId
);
1538 *pgdConnectionId
= connection
->id
;
1542 static HRESULT WINAPI
connection_GetAdapterId(
1543 INetworkConnection
*iface
,
1544 GUID
*pgdAdapterId
)
1546 struct connection
*connection
= impl_from_INetworkConnection( iface
);
1548 FIXME( "%p, %p\n", iface
, pgdAdapterId
);
1550 *pgdAdapterId
= connection
->id
;
1554 static HRESULT WINAPI
connection_GetDomainType(
1555 INetworkConnection
*iface
,
1556 NLM_DOMAIN_TYPE
*pDomainType
)
1558 FIXME( "%p, %p\n", iface
, pDomainType
);
1560 *pDomainType
= NLM_DOMAIN_TYPE_NON_DOMAIN_NETWORK
;
1564 static const struct INetworkConnectionVtbl connection_vtbl
=
1566 connection_QueryInterface
,
1569 connection_GetTypeInfoCount
,
1570 connection_GetTypeInfo
,
1571 connection_GetIDsOfNames
,
1573 connection_GetNetwork
,
1574 connection_get_IsConnectedToInternet
,
1575 connection_get_IsConnected
,
1576 connection_GetConnectivity
,
1577 connection_GetConnectionId
,
1578 connection_GetAdapterId
,
1579 connection_GetDomainType
1582 static inline struct connection
*impl_from_INetworkConnectionCost(
1583 INetworkConnectionCost
*iface
)
1585 return CONTAINING_RECORD( iface
, struct connection
, INetworkConnectionCost_iface
);
1588 static HRESULT WINAPI
connection_cost_QueryInterface(
1589 INetworkConnectionCost
*iface
,
1593 struct connection
*conn
= impl_from_INetworkConnectionCost( iface
);
1594 return INetworkConnection_QueryInterface( &conn
->INetworkConnection_iface
, riid
, obj
);
1597 static ULONG WINAPI
connection_cost_AddRef(
1598 INetworkConnectionCost
*iface
)
1600 struct connection
*conn
= impl_from_INetworkConnectionCost( iface
);
1601 return INetworkConnection_AddRef( &conn
->INetworkConnection_iface
);
1604 static ULONG WINAPI
connection_cost_Release(
1605 INetworkConnectionCost
*iface
)
1607 struct connection
*conn
= impl_from_INetworkConnectionCost( iface
);
1608 return INetworkConnection_Release( &conn
->INetworkConnection_iface
);
1611 static HRESULT WINAPI
connection_cost_GetCost(
1612 INetworkConnectionCost
*iface
, DWORD
*pCost
)
1614 FIXME( "%p, %p\n", iface
, pCost
);
1616 if (!pCost
) return E_POINTER
;
1618 *pCost
= NLM_CONNECTION_COST_UNRESTRICTED
;
1622 static HRESULT WINAPI
connection_cost_GetDataPlanStatus(
1623 INetworkConnectionCost
*iface
, NLM_DATAPLAN_STATUS
*pDataPlanStatus
)
1625 struct connection
*conn
= impl_from_INetworkConnectionCost( iface
);
1627 FIXME( "%p, %p\n", iface
, pDataPlanStatus
);
1629 if (!pDataPlanStatus
) return E_POINTER
;
1631 memcpy( &pDataPlanStatus
->InterfaceGuid
, &conn
->id
, sizeof(conn
->id
) );
1632 pDataPlanStatus
->UsageData
.UsageInMegabytes
= NLM_UNKNOWN_DATAPLAN_STATUS
;
1633 memset( &pDataPlanStatus
->UsageData
.LastSyncTime
, 0, sizeof(pDataPlanStatus
->UsageData
.LastSyncTime
) );
1634 pDataPlanStatus
->DataLimitInMegabytes
= NLM_UNKNOWN_DATAPLAN_STATUS
;
1635 pDataPlanStatus
->InboundBandwidthInKbps
= NLM_UNKNOWN_DATAPLAN_STATUS
;
1636 pDataPlanStatus
->OutboundBandwidthInKbps
= NLM_UNKNOWN_DATAPLAN_STATUS
;
1637 memset( &pDataPlanStatus
->NextBillingCycle
, 0, sizeof(pDataPlanStatus
->NextBillingCycle
) );
1638 pDataPlanStatus
->MaxTransferSizeInMegabytes
= NLM_UNKNOWN_DATAPLAN_STATUS
;
1639 pDataPlanStatus
->Reserved
= 0;
1644 static const INetworkConnectionCostVtbl connection_cost_vtbl
=
1646 connection_cost_QueryInterface
,
1647 connection_cost_AddRef
,
1648 connection_cost_Release
,
1649 connection_cost_GetCost
,
1650 connection_cost_GetDataPlanStatus
1653 static struct connection
*create_connection( const GUID
*id
)
1655 struct connection
*ret
;
1657 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
1659 ret
->INetworkConnection_iface
.lpVtbl
= &connection_vtbl
;
1660 ret
->INetworkConnectionCost_iface
.lpVtbl
= &connection_cost_vtbl
;
1663 ret
->network
= NULL
;
1664 ret
->connected
= VARIANT_FALSE
;
1665 ret
->connected_to_internet
= VARIANT_FALSE
;
1666 list_init( &ret
->entry
);
1671 static void init_networks( struct list_manager
*mgr
)
1674 IP_ADAPTER_ADDRESSES
*buf
, *aa
;
1676 ULONG ret
, flags
= GAA_FLAG_SKIP_ANYCAST
| GAA_FLAG_SKIP_MULTICAST
|
1677 GAA_FLAG_SKIP_DNS_SERVER
| GAA_FLAG_INCLUDE_ALL_GATEWAYS
;
1679 list_init( &mgr
->networks
);
1680 list_init( &mgr
->connections
);
1682 ret
= GetAdaptersAddresses( WS_AF_UNSPEC
, flags
, NULL
, NULL
, &size
);
1683 if (ret
!= ERROR_BUFFER_OVERFLOW
) return;
1685 if (!(buf
= heap_alloc( size
))) return;
1686 if (GetAdaptersAddresses( WS_AF_UNSPEC
, flags
, NULL
, buf
, &size
))
1692 memset( &id
, 0, sizeof(id
) );
1693 for (aa
= buf
; aa
; aa
= aa
->Next
)
1695 struct network
*network
;
1696 struct connection
*connection
;
1698 id
.Data1
= aa
->u
.s
.IfIndex
;
1700 /* assume a one-to-one mapping between networks and connections */
1701 if (!(network
= create_network( &id
))) goto done
;
1702 if (!(connection
= create_connection( &id
)))
1704 INetwork_Release( &network
->INetwork_iface
);
1708 if (aa
->FirstUnicastAddress
)
1710 network
->connected
= VARIANT_TRUE
;
1711 connection
->connected
= VARIANT_TRUE
;
1713 if (aa
->FirstGatewayAddress
)
1715 network
->connected_to_internet
= VARIANT_TRUE
;
1716 connection
->connected_to_internet
= VARIANT_TRUE
;
1719 connection
->network
= &network
->INetwork_iface
;
1720 INetwork_AddRef( connection
->network
);
1722 list_add_tail( &mgr
->networks
, &network
->entry
);
1723 list_add_tail( &mgr
->connections
, &connection
->entry
);
1730 HRESULT
list_manager_create( void **obj
)
1732 struct list_manager
*mgr
;
1734 TRACE( "%p\n", obj
);
1736 if (!(mgr
= heap_alloc( sizeof(*mgr
) ))) return E_OUTOFMEMORY
;
1737 mgr
->INetworkListManager_iface
.lpVtbl
= &list_manager_vtbl
;
1738 mgr
->INetworkCostManager_iface
.lpVtbl
= &cost_manager_vtbl
;
1739 mgr
->IConnectionPointContainer_iface
.lpVtbl
= &cpc_vtbl
;
1740 init_networks( mgr
);
1743 *obj
= &mgr
->INetworkListManager_iface
;
1744 TRACE( "returning iface %p\n", *obj
);