summaryrefslogtreecommitdiffstats
path: root/network/network.cpp
diff options
context:
space:
mode:
authorMatt Porter <mporter@konsulko.com>2018-07-27 11:54:56 -0400
committerMatt Porter <mporter@konsulko.com>2018-07-27 11:54:56 -0400
commit0c4d8bf4e0af08563c907148216ffdb485dd1922 (patch)
treeb6934d4d2c483a017705ab23e46f866f6c39f826 /network/network.cpp
parentcd445ba31ca2f4ca4cec0ce7d451f50fa6c5fa72 (diff)
network: add wifiStrength property
Add a wifiStrength property which exposes the signal strength of the currently connected network. This is intended to be used by global status indicators, such as a status bar WiFi strength indicator. Bug-AGL: SPEC-1626 Change-Id: I7285b04095bc67278c862fc363a2dfbfff57d44d Signed-off-by: Matt Porter <mporter@konsulko.com>
Diffstat (limited to 'network/network.cpp')
-rw-r--r--network/network.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/network/network.cpp b/network/network.cpp
index d2a00ff..7bcf6d0 100644
--- a/network/network.cpp
+++ b/network/network.cpp
@@ -31,7 +31,8 @@ Network::Network (QUrl &url, QQmlContext *context, QObject * parent) :
m_mloop(nullptr),
m_wifi(nullptr),
m_wifiConnected(false),
- m_wifiEnabled(false)
+ m_wifiEnabled(false),
+ m_wifiStrength(0)
{
m_mloop = new MessageEngine(url);
m_wifi = new WifiNetworkModel();
@@ -41,6 +42,7 @@ Network::Network (QUrl &url, QQmlContext *context, QObject * parent) :
QObject::connect(m_mloop, &MessageEngine::connected, this, &Network::onConnected);
QObject::connect(m_mloop, &MessageEngine::disconnected, this, &Network::onDisconnected);
QObject::connect(m_mloop, &MessageEngine::messageReceived, this, &Network::onMessageReceived);
+ QObject::connect(m_wifi, &WifiNetworkModel::strengthChanged, this, &Network::updateWifiStrength);
}
Network::~Network()
@@ -159,6 +161,9 @@ bool Network::addService(QJsonObject service)
WifiNetwork *network = new WifiNetwork(address, security, id, ssid, state, strength);
m_wifi->addNetwork(network);
+ if ((state == "ready") || (state == "online"))
+ updateWifiStrength(strength);
+
return true;
}
@@ -202,6 +207,12 @@ void Network::updateWifiStatus(QJsonObject properties)
}
}
+void Network::updateWifiStrength(int strength)
+{
+ m_wifiStrength = strength;
+ emit wifiStrengthChanged(m_wifiStrength);
+}
+
void Network::parseTechnologies(QJsonArray technologies)
{
for (auto value : technologies) {