QNetConMonitor/Win: Drop all warnings down to debug
The things they warn about are not of any serious consequence to users or end-users and there's nothing they can do about it. Adding to that, in Qt 6 it has a reduced role since QNAM::networkAccessible was removed. Fixes: QTBUG-100482 Pick-to: 6.3 6.2 Change-Id: I178d056c513b5dbb122d5c731af602d3dc117d8e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
4fe8ed6288
commit
a6f4a1b282
@ -182,7 +182,7 @@ QNetworkConnectionEvents::QNetworkConnectionEvents(QNetworkConnectionMonitorPriv
|
|||||||
auto hr = CoCreateInstance(CLSID_NetworkListManager, nullptr, CLSCTX_INPROC_SERVER,
|
auto hr = CoCreateInstance(CLSID_NetworkListManager, nullptr, CLSCTX_INPROC_SERVER,
|
||||||
IID_INetworkListManager, &networkListManager);
|
IID_INetworkListManager, &networkListManager);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Could not get a NetworkListManager instance:"
|
qCDebug(lcNetMon) << "Could not get a NetworkListManager instance:"
|
||||||
<< errorStringFromHResult(hr);
|
<< errorStringFromHResult(hr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ QNetworkConnectionEvents::QNetworkConnectionEvents(QNetworkConnectionMonitorPriv
|
|||||||
&connectionPoint);
|
&connectionPoint);
|
||||||
}
|
}
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Failed to get connection point for network events:"
|
qCDebug(lcNetMon) << "Failed to get connection point for network events:"
|
||||||
<< errorStringFromHResult(hr);
|
<< errorStringFromHResult(hr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ ComPtr<INetworkConnection> QNetworkConnectionEvents::getNetworkConnectionFromAda
|
|||||||
ComPtr<IEnumNetworkConnections> connections;
|
ComPtr<IEnumNetworkConnections> connections;
|
||||||
auto hr = networkListManager->GetNetworkConnections(connections.GetAddressOf());
|
auto hr = networkListManager->GetNetworkConnections(connections.GetAddressOf());
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Failed to enumerate network connections:"
|
qCDebug(lcNetMon) << "Failed to enumerate network connections:"
|
||||||
<< errorStringFromHResult(hr);
|
<< errorStringFromHResult(hr);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ ComPtr<INetworkConnection> QNetworkConnectionEvents::getNetworkConnectionFromAda
|
|||||||
do {
|
do {
|
||||||
hr = connections->Next(1, connection.GetAddressOf(), nullptr);
|
hr = connections->Next(1, connection.GetAddressOf(), nullptr);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Failed to get next network connection in enumeration:"
|
qCDebug(lcNetMon) << "Failed to get next network connection in enumeration:"
|
||||||
<< errorStringFromHResult(hr);
|
<< errorStringFromHResult(hr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@ ComPtr<INetworkConnection> QNetworkConnectionEvents::getNetworkConnectionFromAda
|
|||||||
GUID adapterId;
|
GUID adapterId;
|
||||||
hr = connection->GetAdapterId(&adapterId);
|
hr = connection->GetAdapterId(&adapterId);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Failed to get adapter ID from network connection:"
|
qCDebug(lcNetMon) << "Failed to get adapter ID from network connection:"
|
||||||
<< errorStringFromHResult(hr);
|
<< errorStringFromHResult(hr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -276,22 +276,22 @@ bool QNetworkConnectionEvents::setTarget(const QNetworkInterface &iface)
|
|||||||
|
|
||||||
NET_LUID luid;
|
NET_LUID luid;
|
||||||
if (ConvertInterfaceIndexToLuid(iface.index(), &luid) != NO_ERROR) {
|
if (ConvertInterfaceIndexToLuid(iface.index(), &luid) != NO_ERROR) {
|
||||||
qCWarning(lcNetMon, "Could not get the LUID for the interface.");
|
qCDebug(lcNetMon, "Could not get the LUID for the interface.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GUID guid;
|
GUID guid;
|
||||||
if (ConvertInterfaceLuidToGuid(&luid, &guid) != NO_ERROR) {
|
if (ConvertInterfaceLuidToGuid(&luid, &guid) != NO_ERROR) {
|
||||||
qCWarning(lcNetMon, "Could not get the GUID for the interface.");
|
qCDebug(lcNetMon, "Could not get the GUID for the interface.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ComPtr<INetworkConnection> connection = getNetworkConnectionFromAdapterGuid(guid);
|
ComPtr<INetworkConnection> connection = getNetworkConnectionFromAdapterGuid(guid);
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
qCWarning(lcNetMon, "Could not get the INetworkConnection instance for the adapter GUID.");
|
qCDebug(lcNetMon, "Could not get the INetworkConnection instance for the adapter GUID.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto hr = connection->GetConnectionId(&guid);
|
auto hr = connection->GetConnectionId(&guid);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Failed to get the connection's GUID:" << errorStringFromHResult(hr);
|
qCDebug(lcNetMon) << "Failed to get the connection's GUID:" << errorStringFromHResult(hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
currentConnectionId = guid;
|
currentConnectionId = guid;
|
||||||
@ -302,18 +302,18 @@ bool QNetworkConnectionEvents::setTarget(const QNetworkInterface &iface)
|
|||||||
bool QNetworkConnectionEvents::startMonitoring()
|
bool QNetworkConnectionEvents::startMonitoring()
|
||||||
{
|
{
|
||||||
if (currentConnectionId.isNull()) {
|
if (currentConnectionId.isNull()) {
|
||||||
qCWarning(lcNetMon, "Can not start monitoring, set targets first");
|
qCDebug(lcNetMon, "Can not start monitoring, set targets first");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!connectionPoint) {
|
if (!connectionPoint) {
|
||||||
qCWarning(lcNetMon,
|
qCDebug(lcNetMon,
|
||||||
"We don't have the connection point, cannot start listening to events!");
|
"We don't have the connection point, cannot start listening to events!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hr = connectionPoint->Advise(this, &cookie);
|
auto hr = connectionPoint->Advise(this, &cookie);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Failed to subscribe to network connectivity events:"
|
qCDebug(lcNetMon) << "Failed to subscribe to network connectivity events:"
|
||||||
<< errorStringFromHResult(hr);
|
<< errorStringFromHResult(hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ bool QNetworkConnectionEvents::stopMonitoring()
|
|||||||
{
|
{
|
||||||
auto hr = connectionPoint->Unadvise(cookie);
|
auto hr = connectionPoint->Unadvise(cookie);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Failed to unsubscribe from network connection events:"
|
qCDebug(lcNetMon) << "Failed to unsubscribe from network connection events:"
|
||||||
<< errorStringFromHResult(hr);
|
<< errorStringFromHResult(hr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -337,7 +337,7 @@ QNetworkConnectionMonitorPrivate::QNetworkConnectionMonitorPrivate()
|
|||||||
{
|
{
|
||||||
auto hr = CoInitialize(nullptr);
|
auto hr = CoInitialize(nullptr);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(lcNetMon) << "Failed to initialize COM:" << errorStringFromHResult(hr);
|
qCDebug(lcNetMon) << "Failed to initialize COM:" << errorStringFromHResult(hr);
|
||||||
comInitFailed = true;
|
comInitFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ bool QNetworkConnectionMonitorPrivate::setTargets(const QHostAddress &local,
|
|||||||
addressEntries.cbegin(), addressEntries.cend(),
|
addressEntries.cbegin(), addressEntries.cend(),
|
||||||
[&local](const QNetworkAddressEntry &entry) { return entry.ip() == local; });
|
[&local](const QNetworkAddressEntry &entry) { return entry.ip() == local; });
|
||||||
if (Q_UNLIKELY(it == addressEntries.cend())) {
|
if (Q_UNLIKELY(it == addressEntries.cend())) {
|
||||||
qCWarning(lcNetMon, "The address entry we were working with disappeared");
|
qCDebug(lcNetMon, "The address entry we were working with disappeared");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sameSubnet = remote.isInSubnet(local, it->prefixLength());
|
sameSubnet = remote.isInSubnet(local, it->prefixLength());
|
||||||
@ -423,11 +423,11 @@ QNetworkConnectionMonitor::~QNetworkConnectionMonitor() = default;
|
|||||||
bool QNetworkConnectionMonitor::setTargets(const QHostAddress &local, const QHostAddress &remote)
|
bool QNetworkConnectionMonitor::setTargets(const QHostAddress &local, const QHostAddress &remote)
|
||||||
{
|
{
|
||||||
if (isMonitoring()) {
|
if (isMonitoring()) {
|
||||||
qCWarning(lcNetMon, "Monitor is already active, call stopMonitoring() first");
|
qCDebug(lcNetMon, "Monitor is already active, call stopMonitoring() first");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (local.isNull()) {
|
if (local.isNull()) {
|
||||||
qCWarning(lcNetMon, "Invalid (null) local address, cannot create a reachability target");
|
qCDebug(lcNetMon, "Invalid (null) local address, cannot create a reachability target");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Silently return false for loopback addresses instead of printing warnings later
|
// Silently return false for loopback addresses instead of printing warnings later
|
||||||
@ -441,7 +441,7 @@ bool QNetworkConnectionMonitor::startMonitoring()
|
|||||||
{
|
{
|
||||||
Q_D(QNetworkConnectionMonitor);
|
Q_D(QNetworkConnectionMonitor);
|
||||||
if (isMonitoring()) {
|
if (isMonitoring()) {
|
||||||
qCWarning(lcNetMon, "Monitor is already active, call stopMonitoring() first");
|
qCDebug(lcNetMon, "Monitor is already active, call stopMonitoring() first");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return d->startMonitoring();
|
return d->startMonitoring();
|
||||||
@ -456,7 +456,7 @@ void QNetworkConnectionMonitor::stopMonitoring()
|
|||||||
{
|
{
|
||||||
Q_D(QNetworkConnectionMonitor);
|
Q_D(QNetworkConnectionMonitor);
|
||||||
if (!isMonitoring()) {
|
if (!isMonitoring()) {
|
||||||
qCWarning(lcNetMon, "stopMonitoring was called when not monitoring!");
|
qCDebug(lcNetMon, "stopMonitoring was called when not monitoring!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->stopMonitoring();
|
d->stopMonitoring();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user