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-10 14:09:30 +0000
commit4221fd2f9e5b72090fe5c2c5f19aa16ab8bf68b8 (patch)
tree82a6e7e606c85e75e36cdd71c07f6f5aed802f4d /network/wirednetworkmodel.cpp
parenta824dc2de24ac3789207a5fb9d89400bc83891f9 (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
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());