diff options
Diffstat (limited to 'src/network/kernel/qnetworkinterface_winrt.cpp')
-rw-r--r-- | src/network/kernel/qnetworkinterface_winrt.cpp | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/src/network/kernel/qnetworkinterface_winrt.cpp b/src/network/kernel/qnetworkinterface_winrt.cpp index 48a96928a8..4fe30fe696 100644 --- a/src/network/kernel/qnetworkinterface_winrt.cpp +++ b/src/network/kernel/qnetworkinterface_winrt.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNetwork module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -73,12 +65,11 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() QList<HostNameInfo> hostList; - INetworkInformationStatics *hostNameStatics; + ComPtr<INetworkInformationStatics> hostNameStatics; GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Connectivity_NetworkInformation).Get(), &hostNameStatics); - IVectorView<HostName*> *hostNames = 0; + ComPtr<IVectorView<HostName *>> hostNames; hostNameStatics->GetHostNames(&hostNames); - hostNameStatics->Release(); if (!hostNames) return interfaces; @@ -86,7 +77,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() hostNames->get_Size(&hostNameCount); for (unsigned i = 0; i < hostNameCount; ++i) { HostNameInfo hostInfo; - IHostName *hostName; + ComPtr<IHostName> hostName; hostNames->GetAt(i, &hostName); HostNameType type; @@ -94,20 +85,17 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() if (type == HostNameType_DomainName) continue; - IIPInformation *ipInformation; + ComPtr<IIPInformation> ipInformation; hostName->get_IPInformation(&ipInformation); - INetworkAdapter *currentAdapter; + ComPtr<INetworkAdapter> currentAdapter; ipInformation->get_NetworkAdapter(¤tAdapter); currentAdapter->get_NetworkAdapterId(&hostInfo.adapterId); - currentAdapter->Release(); - IReference<unsigned char> *prefixLengthReference; + ComPtr<IReference<unsigned char>> prefixLengthReference; ipInformation->get_PrefixLength(&prefixLengthReference); - ipInformation->Release(); prefixLengthReference->get_Value(&hostInfo.prefixLength); - prefixLengthReference->Release(); // invalid prefixes if ((type == HostNameType_Ipv4 && hostInfo.prefixLength > 32) @@ -116,20 +104,17 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() HString name; hostName->get_CanonicalName(name.GetAddressOf()); - hostName->Release(); UINT32 length; PCWSTR rawString = name.GetRawBuffer(&length); hostInfo.address = QString::fromWCharArray(rawString, length); hostList << hostInfo; } - hostNames->Release(); INetworkInformationStatics *networkInfoStatics; GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Connectivity_NetworkInformation).Get(), &networkInfoStatics); - IVectorView<ConnectionProfile *> *connectionProfiles = 0; + ComPtr<IVectorView<ConnectionProfile *>> connectionProfiles; networkInfoStatics->GetConnectionProfiles(&connectionProfiles); - networkInfoStatics->Release(); if (!connectionProfiles) return interfaces; @@ -139,7 +124,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate; interfaces << iface; - IConnectionProfile *profile; + ComPtr<IConnectionProfile> profile; connectionProfiles->GetAt(i, &profile); NetworkConnectivityLevel connectivityLevel; @@ -147,16 +132,14 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() if (connectivityLevel != NetworkConnectivityLevel_None) iface->flags = QNetworkInterface::IsUp | QNetworkInterface::IsRunning; - INetworkAdapter *adapter; + ComPtr<INetworkAdapter> adapter; profile->get_NetworkAdapter(&adapter); - profile->Release(); UINT32 type; adapter->get_IanaInterfaceType(&type); if (type == 23) iface->flags |= QNetworkInterface::IsPointToPoint; GUID id; adapter->get_NetworkAdapterId(&id); - adapter->Release(); OLECHAR adapterName[39]={0}; StringFromGUID2(id, adapterName, 39); iface->name = QString::fromWCharArray(adapterName); @@ -179,7 +162,6 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() --i; } } - connectionProfiles->Release(); return interfaces; } |