[Connectivity Report] Only emit signal when it has actually changed

Avoids pointless DBus traffic
This commit is contained in:
Kai Uwe Broulik 2021-11-30 23:33:30 +01:00
parent 034e5fb03c
commit 2a3ab4104e

View file

@ -43,11 +43,17 @@ bool ConnectivityReportPlugin::receivePacket(const NetworkPacket& np)
auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap()); auto subscriptions = np.get<QVariantMap>(QStringLiteral("signalStrengths"), QVariantMap());
auto networkInfo = subscriptions.first().toMap(); auto networkInfo = subscriptions.first().toMap();
const auto oldCellularNetworkType = m_cellularNetworkType;
const auto oldNetworkStrength = m_cellularNetworkStrength;
m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString(); m_cellularNetworkType = networkInfo.value(QStringLiteral("networkType")).toString();
m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt(); m_cellularNetworkStrength = networkInfo.value(QStringLiteral("signalStrength")).toInt();
if (oldCellularNetworkType != m_cellularNetworkType ||
oldNetworkStrength != m_cellularNetworkStrength) {
Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength); Q_EMIT refreshed(m_cellularNetworkType, m_cellularNetworkStrength);
} }
}
return true; return true;
} }