diff options
author | Scott Murray <scott.murray@konsulko.com> | 2022-01-28 16:54:55 -0500 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2022-01-28 17:00:09 -0500 |
commit | 5ef90db242ad29c9772f2237b477c58ef65545c7 (patch) | |
tree | f9b7b2e56a0aaec37bb9ef99faa316465613b941 /network/wifinetworkmodel.cpp | |
parent | 0fee9bfb0f656b78f34c44542329760be2980892 (diff) |
Re-enable network supportmarlin_12.92.0marlin/12.92.012.92.0
Rework network support code to use new connman-glib library instead
of the previously disabled agl-service-network API. The only user
visible change is that a few extra previously exported header files
have been pruned from installation to avoid exposing GLib usage
and potentially requiring users needing to build against it.
Bug-AGL: SPEC-4182
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: Iab8f3c9d04ee603e06b80dfd92ac03d9d52af477
Diffstat (limited to 'network/wifinetworkmodel.cpp')
-rw-r--r-- | network/wifinetworkmodel.cpp | 115 |
1 files changed, 65 insertions, 50 deletions
diff --git a/network/wifinetworkmodel.cpp b/network/wifinetworkmodel.cpp index 7c32779..6df4116 100644 --- a/network/wifinetworkmodel.cpp +++ b/network/wifinetworkmodel.cpp @@ -10,71 +10,86 @@ WifiNetworkModel::WifiNetworkModel(QObject *parent) QVariant WifiNetworkModel::data(const QModelIndex &index, int role) const { - if (index.row() < 0 || index.row() >= m_networks.count()) - return QVariant(); + if (index.row() < 0 || index.row() >= m_networks.count()) + return QVariant(); - ConnectionProfile *network = m_networks[index.row()]; + ConnectionProfile *network = m_networks[index.row()]; - switch (role) { + switch (role) { case AddressRole: - return network->address(); + return network->address(); case SecurityRole: - return network->security(); + return network->security(); case ServiceRole: - return network->service(); + return network->service(); case SsidRole: - return network->ssid(); + return network->ssid(); case StateRole: - return network->state(); + return network->state(); case StrengthRole: - return network->strength(); - } + return network->strength(); + } - return QVariant(); + return QVariant(); } QHash<int, QByteArray> WifiNetworkModel::roleNames() const { - QHash<int, QByteArray> roles; - roles[AddressRole] = "address"; - roles[SecurityRole] = "security"; - roles[ServiceRole] = "service"; - roles[SsidRole] = "ssid"; - roles[StateRole] = "sstate"; - roles[StrengthRole] = "strength"; + QHash<int, QByteArray> roles; + roles[AddressRole] = "address"; + roles[SecurityRole] = "security"; + roles[ServiceRole] = "service"; + roles[SsidRole] = "ssid"; + roles[StateRole] = "sstate"; + roles[StrengthRole] = "strength"; - return roles; + return roles; } -void WifiNetworkModel::updateProperties(QString service, QJsonObject properties) +void WifiNetworkModel::updateProperties(const QString &service, const QVariantMap &properties) { - ConnectionProfile *network; - QVector<int> vroles; - bool sbcast = false; + ConnectionProfile *network; + QVector<int> vroles; + bool sbcast = false; - if ((network = getNetwork(service))) { - if (properties.contains("ipv4")) { - QString address = properties.value("ipv4").toObject().value("address").toString(); - network->setAddress(address); - vroles.push_back(AddressRole); - } - if (properties.contains("state")) { - network->setState(properties.value("state").toString()); - vroles.push_back(StateRole); - if ((network->state() == "ready") || - (network->state() == "online")) - sbcast = true; - } - if (properties.contains("strength")) { - network->setStrength(properties.value("strength").toInt()); - vroles.push_back(StrengthRole); - if ((network->state() == "ready") || - (network->state() == "online")) - sbcast = true; - } - if (!vroles.isEmpty()) { - emit dataChanged(indexOf(network), indexOf(network), vroles); - if (sbcast) - emit strengthChanged(network->strength()); - } - } + network = getNetwork(service); + if (!network) + return; + + QString key = "IPv4"; + if (properties.contains(key)) { + QVariantMap ip4_map = properties.value(key).toMap(); + + key = "Address"; + if (ip4_map.contains(key)) { + QString address = ip4_map.value(key).toString(); + network->setAddress(address); + vroles.push_back(AddressRole); + } + } + + key = "State"; + if (properties.contains(key)) { + QString state = properties.value(key).toString(); + network->setState(state); + vroles.push_back(StateRole); + if ((network->state() == "ready") || + (network->state() == "online")) + sbcast = true; + } + + key = "Strength"; + if (properties.contains(key)) { + int strength = properties.value(key).toInt(); + network->setStrength(strength); + vroles.push_back(StrengthRole); + if ((network->state() == "ready") || + (network->state() == "online")) + sbcast = true; + } + + if (!vroles.isEmpty()) { + emit dataChanged(indexOf(network), indexOf(network), vroles); + if (sbcast) + emit strengthChanged(network->strength()); + } } |