summaryrefslogtreecommitdiffstats
path: root/network/wirednetworkmodel.cpp
diff options
context:
space:
mode:
authorRaquel Medina <raquel.medina@konsulko.com>2019-09-09 00:35:55 +0200
committerraquel medina <raquel.medina@konsulko.com>2019-09-20 15:38:55 +0000
commit18dde87f580d41f6743b64b824b55d68df81aff1 (patch)
treed5666e316fc98c1d2ed70199c3309ee472c82de2 /network/wirednetworkmodel.cpp
parentfc0369fdb69dcdcefeea80d3ddb580980e5365f4 (diff)
wired: add hooks for addressing configuration
- Add new roles to provide UI clients with the active configuration (values obtained from the stack: agl-service-network binding + connman). - Add Q_INVOKABLE methods to feed new values from the UI client. SPEC-2676 Signed-off-by: Raquel Medina <raquel.medina@konsulko.com> Change-Id: Id239ddc549ec8471d44d56f7631d4e9e3efda798 (cherry picked from commit 4221fd2f9e5b72090fe5c2c5f19aa16ab8bf68b8)
Diffstat (limited to 'network/wirednetworkmodel.cpp')
-rw-r--r--network/wirednetworkmodel.cpp55
1 files changed, 53 insertions, 2 deletions
diff --git a/network/wirednetworkmodel.cpp b/network/wirednetworkmodel.cpp
index 01a50fb..0d1209e 100644
--- a/network/wirednetworkmodel.cpp
+++ b/network/wirednetworkmodel.cpp
@@ -8,6 +8,40 @@ WiredNetworkModel::WiredNetworkModel(QObject *parent)
{
}
+QVariantList WiredNetworkModel::readCurrentRouteConfig(const QModelIndex &index) const
+{
+ QVariantList ret;
+
+ if (!index.isValid())
+ return ret;
+
+ if (index.row() < 0 || index.row() >= this->m_networks.count())
+ return ret;
+
+ const ConnectionProfile *network = this->m_networks[index.row()];
+ ret.append(network->addrmethod());
+ ret.append(network->address());
+ ret.append(network->netmask());
+ ret.append(network->gateway());
+ return ret;
+}
+
+QVariantList WiredNetworkModel::readCurrentNameServerConfig(const QModelIndex &index) const
+{
+ QVariantList ret;
+
+ if (!index.isValid())
+ return ret;
+
+ if (index.row() < 0 || index.row() >= this->m_networks.count())
+ return ret;
+
+ const ConnectionProfile *network = this->m_networks[index.row()];
+ ret.append(network->nsmethod());
+ ret.append(network->nameservers());
+ return ret;
+}
+
QVariant WiredNetworkModel::data(const QModelIndex &index, int role) const
{
QVariant ret;
@@ -29,6 +63,10 @@ QVariant WiredNetworkModel::data(const QModelIndex &index, int role) const
return network->service();
case StateRole:
return network->state();
+ case RouteRole:
+ return readCurrentRouteConfig(index);
+ case NameServerRole:
+ return readCurrentNameServerConfig(index);
}
return ret;
@@ -40,6 +78,8 @@ QHash<int, QByteArray> WiredNetworkModel::roleNames() const {
roles[SecurityRole] = "security";
roles[ServiceRole] = "service";
roles[StateRole] = "sstate";
+ roles[RouteRole] = "sroute";
+ roles[NameServerRole] = "nservers";
return roles;
}
@@ -51,9 +91,20 @@ void WiredNetworkModel::updateProperties(QString service, QJsonObject properties
if ((network = getNetwork(service))) {
if (properties.contains("ipv4")) {
- QString address = properties.value("ipv4").toObject().value("address").toString();
- network->setAddress(address);
+ QJsonObject ipv4obj = properties.value("ipv4").toObject();
+ network->setAddress(ipv4obj.value("address").toString());
+ network->setNetmask(ipv4obj.value("netmask").toString());
+ network->setGateway(ipv4obj.value("gateway").toString());
+ network->setAddrMethod(ipv4obj.value("method").toString());
vroles.push_back(AddressRole);
+ vroles.push_back(RouteRole);
+ }
+ if (properties.contains("nameservers")) {
+ QString nservers = properties.value("nameservers").toString();
+ network->setNameservers(nservers);
+ (network->addrmethod() == "dhcp")? network->setNSMethod("auto") :
+ network->setNSMethod("manual");
+ vroles.push_back(NameServerRole);
}
if (properties.contains("state")) {
network->setState(properties.value("state").toString());