summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/connman
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/bearer/connman')
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.cpp144
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.h4
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux.cpp125
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux_p.h13
4 files changed, 208 insertions, 78 deletions
diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp
index 8775623..3b5ae86 100644
--- a/src/plugins/bearer/connman/qconnmanengine.cpp
+++ b/src/plugins/bearer/connman/qconnmanengine.cpp
@@ -125,9 +125,10 @@ QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations()
config->type = cpPriv->type;
config->roamingSupported = cpPriv->roamingSupported;
config->purpose = cpPriv->purpose;
- config->bearer = cpPriv->bearer;
+ config->bearerType = cpPriv->bearerType;
fetchedConfigurations.append(config);
+ delete config;
}
return fetchedConfigurations;
// return foundConfigurations;
@@ -149,7 +150,6 @@ void QConnmanEngine::getNetworkListing()
}
-
void QConnmanEngine::doRequestUpdate()
{
connmanManager->requestScan("");
@@ -169,30 +169,6 @@ bool QConnmanEngine::hasIdentifier(const QString &id)
return accessPointConfigurations.contains(id);
}
-QString QConnmanEngine::bearerName(const QString &id)
-{
- QMutexLocker locker(&mutex);
- QConnmanServiceInterface serv(serviceFromId(id));
- QString connectionType = serv.getType();
-
- if (connectionType == "ethernet")
- return QLatin1String("Ethernet");
- else if (connectionType == "wifi")
- return QLatin1String("WLAN");
- else if (connectionType == "cellular") {
- QString mode = serv.getMode();
- if(mode == "gprs" || mode == "edge") {
- return QLatin1String("2G");
- } else if(mode == "umts") {
- return QLatin1String("WCDMA");
- }
- }
- else if (connectionType == "wimax")
- return QLatin1String("WIMAX");
-
- return QString();
-}
-
void QConnmanEngine::connectToId(const QString &id)
{
QMutexLocker locker(&mutex);
@@ -336,6 +312,9 @@ QString QConnmanEngine::getServiceForNetwork(const QString &netPath)
QMutexLocker locker(&mutex);
QConnmanNetworkInterface network(netPath, this);
foreach(QString service,connmanManager->getServices()) {
+
+ QString devicePath = netPath.section("/",5,5);
+
QConnmanServiceInterface serv(service,this);
if(serv.getName() == network.getName()
&& network.getSignalStrength() == serv.getSignalStrength()) {
@@ -378,17 +357,6 @@ void QConnmanEngine::propertyChangedContext(const QString &path,const QString &i
technologies.insert(listPath, tech);
}
}
-
- foreach(const QString old, oldtech.keys()) {
- if(!newlist.contains(old)) {
- QConnmanTechnologyInterface *tech = oldtech.value(old);
- disconnect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
- this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant)));
-
- technologies.remove(old);
- getNetworkListing();
- }
- }
}
}
if(item == "State") {
@@ -409,15 +377,21 @@ void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QSt
}
}
-void QConnmanEngine::networkPropertyChangedContext(const QString &/*path*/,const QString &/*item*/, const QDBusVariant &/*value*/)
+void QConnmanEngine::networkPropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value)
{
QMutexLocker locker(&mutex);
+// qDebug() << __FUNCTION__ << path << item << value.variant();
}
void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const QString &item,const QDBusVariant &value)
{
+// qDebug() << __FUNCTION__ << devpath << item << value.variant();
QMutexLocker locker(&mutex);
if(item == "Networks") {
+
+ QConnmanNetworkInterface network(devpath, this);
+
+
QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant());
QStringList remainingNetworks = qdbus_cast<QStringList>(arg);
QString devicetype;
@@ -455,6 +429,7 @@ void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const Q
void QConnmanEngine::technologyPropertyChangedContext(const QString & path, const QString &item, const QDBusVariant &value)
{
+// qDebug() << __FUNCTION__ << path << item << value.variant();
if(item == "Devices") {
QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant());
QStringList list = qdbus_cast<QStringList>(arg);
@@ -476,6 +451,12 @@ void QConnmanEngine::technologyPropertyChangedContext(const QString & path, cons
}
if(value.variant().toString() == "offline") {
deviceMap.remove(path);
+ QConnmanTechnologyInterface tech(path);
+ disconnect(&tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
+ this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant)));
+
+ technologies.remove(path);
+ getNetworkListing();
}
}
}
@@ -538,25 +519,25 @@ QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QStri
return flag;
}
-QString QConnmanEngine::typeToBearer(const QString &type)
+QNetworkConfiguration::BearerType QConnmanEngine::typeToBearer(const QString &type)
{
- QMutexLocker locker(&mutex);
- if(type == "wifi")
- return "WLAN";
- if(type == "ethernet")
- return "Ethernet";
- if(type == "bluetooth")
- return "Bluetooth";
- if(type == "cellular") {
- return "Cellular";
+ if (type == "wifi")
+ return QNetworkConfiguration::BearerWLAN;
+ if (type == "ethernet")
+ return QNetworkConfiguration::BearerEthernet;
+ if (type == "bluetooth")
+ return QNetworkConfiguration::BearerBluetooth;
+ if (type == "cellular") {
+ return QNetworkConfiguration::Bearer2G;
// not handled: CDMA2000 HSPA
}
- if(type == "wimax")
- return "WiMax";
+ if (type == "wimax")
+ return QNetworkConfiguration::BearerWiMAX;
+
// if(type == "gps")
// if(type == "vpn")
- return "Unknown";
+ return QNetworkConfiguration::BearerUnknown;
}
void QConnmanEngine::removeConfiguration(const QString &id)
@@ -612,15 +593,35 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath)
QString networkName = serv->getName();
- if(serv->getType() == "Cellular") {
+ if(serv->getType() == "cellular") {
networkName = serv->getAPN();
+ if(networkName.isEmpty()) {
+ networkName = serv->getName();
+ }
}
cpPriv->name = networkName;
cpPriv->isValid = true;
cpPriv->id = id;
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
- cpPriv->bearer = bearerName(id);
+
+
+ const QString connectionType = serv->getType();
+ if (connectionType == "ethernet") {
+ cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
+ } else if (connectionType == "wifi") {
+ cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
+ } else if (connectionType == "cellular") {
+ const QString mode = serv->getMode();
+ if (mode == "gprs" || mode == "edge")
+ cpPriv->bearerType = QNetworkConfiguration::Bearer2G;
+ else if (mode == "umts")
+ cpPriv->bearerType = QNetworkConfiguration::BearerWCDMA;
+ } else if (connectionType == "wimax") {
+ cpPriv->bearerType = QNetworkConfiguration::BearerWiMAX;
+ } else {
+ cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
+ }
if(serv->getSecurity() == "none") {
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
@@ -650,6 +651,9 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath)
{
QMutexLocker locker(&mutex);
+ if(networkPath.isNull())
+ return;
+
QConnmanNetworkInterface *network;
network = new QConnmanNetworkInterface(networkPath, this);
QString servicePath = getServiceForNetwork(networkPath);
@@ -665,9 +669,10 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath)
serv = new QConnmanServiceInterface(servicePath,this);
connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant)));
+
}
- if (!accessPointConfigurations.contains(id)) {
+ if (!id.isEmpty() && !accessPointConfigurations.contains(id)) {
knownNetworks[device.getType()].append(networkPath);
@@ -683,31 +688,38 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath)
if(networkName.isEmpty())
networkName = "Hidden Network";
- QString bearerName;
+
+ QNetworkConfiguration::BearerType bearerType;
if(servicePath.isEmpty()) {
QString devicePath = networkPath.section("/",0,5);
+
QConnmanDeviceInterface device(devicePath,this);
- bearerName = typeToBearer(device.getType());
+ bearerType = typeToBearer(device.getType());
} else {
- bearerName = typeToBearer(serv->getType());
+ bearerType = typeToBearer(serv->getType());
}
- if(bearerName == "Cellular") {
+ if (bearerType == QNetworkConfiguration::Bearer2G) {
QString mode = serv->getMode();
- if(mode == "gprs" || mode == "edge") {
- bearerName = "2G";
- } else if(mode == "umts") {
- bearerName = "WCDMA";
+ if (mode == "gprs" || mode == "edge") {
+ bearerType = QNetworkConfiguration::Bearer2G;
+ } else if (mode == "umts") {
+ bearerType = QNetworkConfiguration::BearerWCDMA;
+ }
+ if(servicePath.isEmpty()) {
+ networkName = serv->getAPN();
+ if(networkName.isEmpty()) {
+ networkName = serv->getName();
+ }
}
- networkName = serv->getAPN();
}
cpPriv->name = networkName;
cpPriv->isValid = true;
cpPriv->id = id;
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
- cpPriv->bearer = bearerName;
+ cpPriv->bearerType = bearerType;
if(network->getWifiSecurity() == "none") {
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
@@ -729,7 +741,9 @@ void QConnmanEngine::addNetworkConfiguration(const QString &networkPath)
emit configurationAdded(ptr);
locker.relock();
emit updateCompleted();
- }
+ } /*else {
+ qDebug() << "Not added~~~~~~~~~~~";
+ }*/
}
bool QConnmanEngine::requiresPolling() const
diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h
index 0f6dc1c..2ee6da5 100644
--- a/src/plugins/bearer/connman/qconnmanengine.h
+++ b/src/plugins/bearer/connman/qconnmanengine.h
@@ -80,8 +80,6 @@ public:
virtual QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
- virtual QString bearerName(const QString &id);
-
virtual void connectToId(const QString &id);
virtual void disconnectFromId(const QString &id);
@@ -125,7 +123,7 @@ private:
QString networkFromId(const QString &id);
QNetworkConfiguration::StateFlags getStateForService(const QString &service);
- QString typeToBearer(const QString &type);
+ QNetworkConfiguration::BearerType typeToBearer(const QString &type);
void removeConfiguration(const QString &servicePath);
void addServiceConfiguration(const QString &servicePath);
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
index b20e7c1..0ffada9 100644
--- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp
+++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
@@ -53,6 +53,8 @@
#include "qconnmanservice_linux_p.h"
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
static QDBusConnection dbusConnection = QDBusConnection::systemBus();
@@ -129,8 +131,10 @@ QVariant QConnmanManagerInterface::getProperty(const QString &property)
QVariantMap QConnmanManagerInterface::getProperties()
{
- QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
- return reply.value();
+ if(this->isValid()) {
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+ } else return QVariantMap();
}
QString QConnmanManagerInterface::getState()
@@ -551,8 +555,12 @@ void QConnmanServiceInterface::disconnectNotify(const char *signal)
QVariantMap QConnmanServiceInterface::getProperties()
{
- QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties"));
- return reply.value();
+ if(this->isValid()) {
+ QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+ }
+ else
+ return QVariantMap();
}
QVariant QConnmanServiceInterface::getProperty(const QString &property)
@@ -725,6 +733,99 @@ QVariantMap QConnmanServiceInterface::getEthernet()
return qdbus_cast<QVariantMap >(var);
}
+QString QConnmanServiceInterface::getMethod()
+{
+ QVariant var;
+ QVariantMap map = getEthernet();
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Method") {
+ return it.value().toString();
+ }
+ }
+ return QString();
+}
+
+QString QConnmanServiceInterface::getInterface()
+{
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Interface") {
+ return it.value().toString();
+ }
+ }
+
+ return QString();
+}
+
+QString QConnmanServiceInterface::getMacAddress()
+{
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Address") {
+ return it.value().toString();
+ }
+ }
+ return QString();
+}
+
+quint16 QConnmanServiceInterface::getMtu()
+{
+ quint16 mtu=0;
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "MTU") {
+ return it.value().toUInt();
+ }
+ }
+ return mtu;
+}
+
+quint16 QConnmanServiceInterface::getSpeed()
+{
+ quint16 speed=0;
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Speed") {
+ return it.value().toUInt();
+ }
+ }
+ return speed;
+}
+
+QString QConnmanServiceInterface::getDuplex()
+{
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Duplex") {
+ return it.value().toString();
+ }
+ }
+ return QString();
+}
+
+
bool QConnmanServiceInterface::isOfflineMode()
{
QVariant var = getProperty("OfflineMode");
@@ -953,10 +1054,10 @@ bool QConnmanDeviceInterface::setProperty(const QString &name, const QDBusVarian
// QList<QVariant> args;
qWarning() << __FUNCTION__ << name << value.variant();
-// args << qVariantFromValue(name);
-// args << qVariantFromValue(value);
+// args << QVariant::fromValue(name);
+// args << QVariant::fromValue(value);
- QDBusMessage reply = this->call(QLatin1String("SetProperty"),name, qVariantFromValue(value));
+ QDBusMessage reply = this->call(QLatin1String("SetProperty"),name, QVariant::fromValue(value));
qWarning() << reply.errorMessage();
return true;
@@ -1020,7 +1121,7 @@ quint16 QConnmanDeviceInterface::getScanInterval()
bool QConnmanDeviceInterface::setScanInterval(const QString & interval)
{
// QList<QVariant> args;
-// args << qVariantFromValue(name)
+// args << QVariant::fromValue(name)
// << value.variant();
// QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args);
@@ -1043,8 +1144,8 @@ QStringList QConnmanDeviceInterface::getNetworks()
bool QConnmanDeviceInterface::setEnabled(bool powered)
{
QList<QVariant> args;
- args << qVariantFromValue(QString("Powered"))
- << qVariantFromValue(QDBusVariant(powered));
+ args << QVariant::fromValue(QString("Powered"))
+ << QVariant::fromValue(QDBusVariant(powered));
QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args);
qWarning() << reply.errorMessage() << reply.errorName();
@@ -1070,3 +1171,7 @@ void QConnmanDBusHelper::propertyChanged(const QString &item, const QDBusVariant
/////////////////
QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
+
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
index 35e3f3d..a2b1e73 100644
--- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h
+++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
@@ -65,6 +65,9 @@
#include <QtDBus/QDBusContext>
#include <QMap>
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
#ifndef __CONNMAN_DBUS_H
#define CONNMAN_SERVICE "org.moblin.connman"
@@ -249,6 +252,13 @@ public:
QVariantMap getProxy();
QVariantMap getEthernet();
+ QString getMethod();
+ QString getInterface();
+ QString getMacAddress();
+ quint16 getMtu();
+ quint16 getSpeed();
+ QString getDuplex();
+
bool isOfflineMode();
QStringList getServices();
@@ -378,4 +388,7 @@ Q_SIGNALS:
QT_END_NAMESPACE
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
+
#endif //QCONNMANSERVICE_H