diff options
Diffstat (limited to 'src/plugins/bearer')
24 files changed, 411 insertions, 410 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 da421bc..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"); @@ -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 diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h index 4d90648..56da66a 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.h +++ b/src/plugins/bearer/corewlan/qcorewlanengine.h @@ -68,8 +68,6 @@ public: QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); - QString bearerName(const QString &id); - void connectToId(const QString &id); void disconnectFromId(const QString &id); diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 6ba9504..131f36d 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -264,7 +264,7 @@ QStringList QScanThread::foundNetwork(const QString &id, const QString &name, co ptr->id = id; ptr->state = state; ptr->type = QNetworkConfiguration::InternetAccessPoint; - ptr->bearer = QLatin1String("WLAN"); + ptr->bearerType = QNetworkConfiguration::BearerWLAN; ptr->purpose = purpose; fetchedConfigurations.append( ptr); @@ -789,8 +789,8 @@ void QCoreWlanEngine::networksChanged() changed = true; } - if (ptr->bearer != cpPriv->bearer) { - ptr->bearer = cpPriv->bearer; + if (ptr->bearerType != cpPriv->bearerType) { + ptr->bearerType = cpPriv->bearerType; changed = true; } diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 652fe4a..fad3ae8 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_NETWORKINTERFACE -static QString qGetInterfaceType(const QString &interface) +static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface) { #ifdef Q_OS_WIN32 unsigned long oid; @@ -78,10 +78,10 @@ static QString qGetInterfaceType(const QString &interface) NDIS_MEDIUM medium; NDIS_PHYSICAL_MEDIUM physicalMedium; - HANDLE handle = CreateFile((TCHAR *)QString("\\\\.\\%1").arg(interface).utf16(), 0, + HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (handle == INVALID_HANDLE_VALUE) - return QLatin1String("Unknown"); + return QNetworkConfiguration::BearerUnknown; oid = OID_GEN_MEDIA_SUPPORTED; bytesWritten = 0; @@ -89,7 +89,7 @@ static QString qGetInterfaceType(const QString &interface) &medium, sizeof(medium), &bytesWritten, 0); if (!result) { CloseHandle(handle); - return QLatin1String("Unknown"); + return QNetworkConfiguration::BearerUnknown; } oid = OID_GEN_PHYSICAL_MEDIUM; @@ -100,9 +100,9 @@ static QString qGetInterfaceType(const QString &interface) CloseHandle(handle); if (medium == NdisMedium802_3) - return QLatin1String("Ethernet"); + return QNetworkConfiguration::BearerEthernet; else - return QLatin1String("Unknown"); + return QNetworkConfiguration::BearerUnknown; } CloseHandle(handle); @@ -110,16 +110,16 @@ static QString qGetInterfaceType(const QString &interface) if (medium == NdisMedium802_3) { switch (physicalMedium) { case NdisPhysicalMediumWirelessLan: - return QLatin1String("WLAN"); + return QNetworkConfiguration::BearerWLAN; case NdisPhysicalMediumBluetooth: - return QLatin1String("Bluetooth"); + return QNetworkConfiguration::BearerBluetooth; case NdisPhysicalMediumWiMax: - return QLatin1String("WiMAX"); + return QNetworkConfiguration::BearerWiMAX; default: #ifdef BEARER_MANAGEMENT_DEBUG qDebug() << "Physical Medium" << physicalMedium; #endif - return QLatin1String("Ethernet"); + return QNetworkConfiguration::BearerEthernet; } } @@ -135,12 +135,12 @@ static QString qGetInterfaceType(const QString &interface) close(sock); if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER) - return QLatin1String("Ethernet"); + return QNetworkConfiguration::BearerEthernet; #else Q_UNUSED(interface); #endif - return QLatin1String("Unknown"); + return QNetworkConfiguration::BearerUnknown; } #endif @@ -214,7 +214,7 @@ void QGenericEngine::doRequestUpdate() continue; // ignore WLAN interface handled in separate engine - if (qGetInterfaceType(interface.name()) == QLatin1String("WLAN")) + if (qGetInterfaceType(interface.name()) == QNetworkConfiguration::BearerWLAN) continue; uint identifier; @@ -277,7 +277,7 @@ void QGenericEngine::doRequestUpdate() ptr->id = id; ptr->state = state; ptr->type = QNetworkConfiguration::InternetAccessPoint; - ptr->bearer = qGetInterfaceType(interface.name()); + ptr->bearerType = qGetInterfaceType(interface.name()); accessPointConfigurations.insert(id, ptr); configurationInterface.insert(id, interface.name()); diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h index cdbbc9d..021b35b 100644 --- a/src/plugins/bearer/generic/qgenericengine.h +++ b/src/plugins/bearer/generic/qgenericengine.h @@ -65,8 +65,6 @@ public: QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); - QString bearerName(const QString &id); - void connectToId(const QString &id); void disconnectFromId(const QString &id); diff --git a/src/plugins/bearer/icd/icd.pro b/src/plugins/bearer/icd/icd.pro index c7337f5..b2c58e9 100644 --- a/src/plugins/bearer/icd/icd.pro +++ b/src/plugins/bearer/icd/icd.pro @@ -3,8 +3,8 @@ include(../../qpluginbase.pri) QT += network dbus -QMAKE_CXXFLAGS += $$QT_CFLAGS_ICD -LIBS += $$QT_LIBS_ICD +QMAKE_CXXFLAGS *= $$QT_CFLAGS_DBUS $$QT_CFLAGS_CONNSETTINGS +LIBS += $$QT_LIBS_CONNSETTINGS HEADERS += qicdengine.h \ qnetworksession_impl.h @@ -15,6 +15,9 @@ SOURCES += main.cpp \ #DEFINES += BEARER_MANAGEMENT_DEBUG +include(../../../3rdparty/libconninet.pri) +include(../../../3rdparty/libgq.pri) + QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer INSTALLS += target diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp index 0083380..0900329 100644 --- a/src/plugins/bearer/icd/qicdengine.cpp +++ b/src/plugins/bearer/icd/qicdengine.cpp @@ -60,16 +60,11 @@ IcdNetworkConfigurationPrivate::~IcdNetworkConfigurationPrivate() { } -QString IcdNetworkConfigurationPrivate::bearerName() const +QString IcdNetworkConfigurationPrivate::bearerTypeName() const { - if (iap_type == QLatin1String("WLAN_INFRA") || - iap_type == QLatin1String("WLAN_ADHOC")) { - return QLatin1String("WLAN"); - } else if (iap_type == QLatin1String("GPRS")) { - return QLatin1String("HSPA"); - } else { - return iap_type; - } + QMutexLocker locker(&mutex); + + return iap_type; } /* The IapAddTimer is a helper class that makes sure we update @@ -222,7 +217,7 @@ void IapMonitor::iapRemoved(const QString &iap_id) } QIcdEngine::QIcdEngine(QObject *parent) -: QBearerEngine(parent), iapMonitor(new IapMonitor), m_dbusInterface(0), +: QBearerEngine(parent), iapMonitor(0), m_dbusInterface(0), firstUpdate(true), m_scanGoingOn(false) { } @@ -263,6 +258,7 @@ void QIcdEngine::initialize() startListeningStateSignalsForAllConnections(); /* Turn on IAP add/remove monitoring */ + iapMonitor = new IapMonitor; iapMonitor->setup(this); /* We create a default configuration which is a pseudo config */ @@ -400,6 +396,7 @@ void QIcdEngine::addConfiguration(QString& iap_id) ptr->mutex.lock(); ptr->id = iap_id; toIcdConfig(ptr)->iap_type = iap_type; + ptr->bearerType = bearerTypeFromIapType(iap_type); toIcdConfig(ptr)->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString()); toIcdConfig(ptr)->network_id = ssid; toIcdConfig(ptr)->service_id = saved_iap.value("service_id").toString(); @@ -424,6 +421,7 @@ void QIcdEngine::addConfiguration(QString& iap_id) cpPriv->isValid = true; cpPriv->id = iap_id; cpPriv->iap_type = iap_type; + cpPriv->bearerType = bearerTypeFromIapType(iap_type); cpPriv->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString()); cpPriv->service_id = saved_iap.value("service_id").toString(); cpPriv->service_type = saved_iap.value("service_type").toString(); @@ -480,6 +478,7 @@ void QIcdEngine::addConfiguration(QString& iap_id) ptr->isValid = true; if (toIcdConfig(ptr)->iap_type != iap_type) { toIcdConfig(ptr)->iap_type = iap_type; + ptr->bearerType = bearerTypeFromIapType(iap_type); update_needed = true; } if (iap_type.startsWith(QLatin1String("WLAN"))) { @@ -522,8 +521,6 @@ void QIcdEngine::addConfiguration(QString& iap_id) void QIcdEngine::doRequestUpdate(QList<Maemo::IcdScanResult> scanned) { - QMutexLocker locker(&mutex); - /* Contains all known iap_ids from storage */ QList<QString> knownConfigs = accessPointConfigurations.keys(); @@ -580,6 +577,7 @@ void QIcdEngine::doRequestUpdate(QList<Maemo::IcdScanResult> scanned) cpPriv->network_id = ssid; cpPriv->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString()); cpPriv->iap_type = iap_type; + cpPriv->bearerType = bearerTypeFromIapType(iap_type); cpPriv->service_id = saved_ap.value("service_id").toString(); cpPriv->service_type = saved_ap.value("service_type").toString(); cpPriv->type = QNetworkConfiguration::InternetAccessPoint; @@ -588,9 +586,9 @@ void QIcdEngine::doRequestUpdate(QList<Maemo::IcdScanResult> scanned) QNetworkConfigurationPrivatePointer ptr(cpPriv); accessPointConfigurations.insert(iap_id, ptr); - locker.unlock(); + mutex.unlock(); emit configurationAdded(ptr); - locker.relock(); + mutex.lock(); #ifdef BEARER_MANAGEMENT_DEBUG qDebug("IAP: %s, name: %s, ssid: %s, added to known list", @@ -643,9 +641,9 @@ void QIcdEngine::doRequestUpdate(QList<Maemo::IcdScanResult> scanned) ptr->mutex.unlock(); if (changed) { - locker.unlock(); + mutex.unlock(); emit configurationChanged(ptr); - locker.relock(); + mutex.lock(); } if (!ap.scan.network_type.startsWith(QLatin1String("WLAN"))) @@ -688,6 +686,7 @@ rescan_list: cpPriv->id = scanned_ssid.data(); // Note: id is now ssid, it should be set to IAP id if the IAP is saved cpPriv->network_id = scanned_ssid; cpPriv->iap_type = ap.scan.network_type; + cpPriv->bearerType = bearerTypeFromIapType(cpPriv->iap_type); cpPriv->network_attrs = ap.scan.network_attrs; cpPriv->service_id = ap.scan.service_id; cpPriv->service_type = ap.scan.service_type; @@ -703,9 +702,9 @@ rescan_list: QNetworkConfigurationPrivatePointer ptr(cpPriv); accessPointConfigurations.insert(ptr->id, ptr); - locker.unlock(); + mutex.unlock(); emit configurationAdded(ptr); - locker.relock(); + mutex.lock(); } else { knownConfigs.removeOne(scanned_ssid); } @@ -733,9 +732,9 @@ rescan_list: ptr->state = QNetworkConfiguration::Defined; configLocker.unlock(); - locker.unlock(); + mutex.unlock(); emit configurationChanged(ptr); - locker.relock(); + mutex.lock(); } } } @@ -744,9 +743,9 @@ rescan_list: foreach (const QString &oldIface, knownConfigs) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(oldIface); if (ptr) { - locker.unlock(); + mutex.unlock(); emit configurationRemoved(ptr); - locker.relock(); + mutex.lock(); //if we would have SNAP support we would have to remove the references //from existing ServiceNetworks to the removed access point configuration } @@ -762,9 +761,9 @@ rescan_list: } if (!firstUpdate) { - locker.unlock(); + mutex.unlock(); emit updateCompleted(); - locker.relock(); + mutex.lock(); } if (firstUpdate) @@ -781,8 +780,6 @@ QNetworkConfigurationPrivatePointer QIcdEngine::defaultConfiguration() void QIcdEngine::startListeningStateSignalsForAllConnections() { - QMutexLocker locker(&mutex); - // Start listening ICD_DBUS_API_STATE_SIG signals m_dbusInterface->connection().connect(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, @@ -906,8 +903,6 @@ void QIcdEngine::requestUpdate() void QIcdEngine::cancelAsyncConfigurationUpdate() { - QMutexLocker locker(&mutex); - if (!m_scanGoingOn) { return; } @@ -947,7 +942,9 @@ void QIcdEngine::asyncUpdateConfigurationsSlot(QDBusMessage msg) if (icd_scan_status == ICD_SCAN_COMPLETE) { m_typesToBeScanned.removeOne(arguments[6].toString()); if (!m_typesToBeScanned.count()) { + locker.unlock(); finishAsyncConfigurationUpdate(); + locker.relock(); } } else { Maemo::IcdScanResult scanResult; @@ -977,7 +974,8 @@ void QIcdEngine::cleanup() m_scanTimer.stop(); m_dbusInterface->call(ICD_DBUS_API_SCAN_CANCEL); } - iapMonitor->cleanup(); + if (iapMonitor) + iapMonitor->cleanup(); } bool QIcdEngine::hasIdentifier(const QString &id) diff --git a/src/plugins/bearer/icd/qicdengine.h b/src/plugins/bearer/icd/qicdengine.h index 1b291eb..a768d84 100644 --- a/src/plugins/bearer/icd/qicdengine.h +++ b/src/plugins/bearer/icd/qicdengine.h @@ -54,13 +54,25 @@ class QNetworkConfigurationPrivate; class IapMonitor; class QDBusInterface; +inline QNetworkConfiguration::BearerType bearerTypeFromIapType(const QString &iapType) +{ + if (iapType == QLatin1String("WLAN_INFRA") || + iapType == QLatin1String("WLAN_ADHOC")) { + return QNetworkConfiguration::BearerWLAN; + } else if (iapType == QLatin1String("GPRS")) { + return QNetworkConfiguration::BearerHSPA; + } else { + return QNetworkConfiguration::BearerUnknown; + } +} + class IcdNetworkConfigurationPrivate : public QNetworkConfigurationPrivate { public: IcdNetworkConfigurationPrivate(); ~IcdNetworkConfigurationPrivate(); - QString bearerName() const; + virtual QString bearerTypeName() const; // In Maemo the id field (defined in QNetworkConfigurationPrivate) // is the IAP id (which typically is UUID) @@ -114,13 +126,13 @@ public: QMutexLocker locker(&mutex); accessPointConfigurations.insert(ptr->id, ptr); + + locker.unlock(); emit configurationAdded(ptr); } inline void changedSessionConfiguration(QNetworkConfigurationPrivatePointer ptr) { - QMutexLocker locker(&mutex); - emit configurationChanged(ptr); } @@ -132,14 +144,14 @@ Q_SIGNALS: void iapStateChanged(const QString& iapid, uint icd_connection_state); private Q_SLOTS: - void doRequestUpdate(QList<Maemo::IcdScanResult> scanned = QList<Maemo::IcdScanResult>()); - void cancelAsyncConfigurationUpdate(); void finishAsyncConfigurationUpdate(); void asyncUpdateConfigurationsSlot(QDBusMessage msg); void connectionStateSignalsSlot(QDBusMessage msg); private: void startListeningStateSignalsForAllConnections(); + void doRequestUpdate(QList<Maemo::IcdScanResult> scanned = QList<Maemo::IcdScanResult>()); + void cancelAsyncConfigurationUpdate(); private: IapMonitor *iapMonitor; diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp index e8e5183..2583b28 100644 --- a/src/plugins/bearer/icd/qnetworksession_impl.cpp +++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp @@ -318,6 +318,7 @@ QNetworkConfiguration& QNetworkSessionPrivateImpl::copyConfig(QNetworkConfigurat cpPriv->purpose = fromPriv->purpose; cpPriv->network_id = fromPriv->network_id; cpPriv->iap_type = fromPriv->iap_type; + cpPriv->bearerType = fromPriv->bearerType; cpPriv->network_attrs = fromPriv->network_attrs; cpPriv->service_type = fromPriv->service_type; cpPriv->service_id = fromPriv->service_id; @@ -443,6 +444,7 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() ptr->id = toIcdConfig(ptr)->network_id; toIcdConfig(ptr)->network_attrs = state_results.first().params.network_attrs; toIcdConfig(ptr)->iap_type = state_results.first().params.network_type; + ptr->bearerType = bearerTypeFromIapType(toIcdConfig(ptr)->iap_type); toIcdConfig(ptr)->service_type = state_results.first().params.service_type; toIcdConfig(ptr)->service_id = state_results.first().params.service_id; toIcdConfig(ptr)->service_attrs = state_results.first().params.service_attrs; @@ -819,6 +821,7 @@ void QNetworkSessionPrivateImpl::stateChange(const QDBusMessage& rep) icdConfig->name = name; icdConfig->iap_type = rep.arguments().at(3).toString(); // connect_result.connect.network_type; + icdConfig->bearerType = bearerTypeFromIapType(icdConfig->iap_type); icdConfig->isValid = true; icdConfig->state = QNetworkConfiguration::Active; icdConfig->type = QNetworkConfiguration::InternetAccessPoint; diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp index 1a55402..ba8297e 100644 --- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp @@ -206,7 +206,7 @@ void QNativeWifiEngine::scanComplete() ptr->id = id; ptr->state = state; ptr->type = QNetworkConfiguration::InternetAccessPoint; - ptr->bearer = QLatin1String("WLAN"); + ptr->bearerType = QNetworkConfiguration::BearerWLAN; accessPointConfigurations.insert(id, ptr); @@ -350,11 +350,6 @@ bool QNativeWifiEngine::hasIdentifier(const QString &id) return false; } -/*QString QNativeWifiEngine::bearerName(const QString &) -{ - return QLatin1String("WLAN"); -}*/ - void QNativeWifiEngine::connectToId(const QString &id) { QMutexLocker locker(&mutex); diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.h b/src/plugins/bearer/nativewifi/qnativewifiengine.h index 0e9576b..dccf2e2 100644 --- a/src/plugins/bearer/nativewifi/qnativewifiengine.h +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.h @@ -75,8 +75,6 @@ public: QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); - //QString bearerName(const QString &id); - void connectToId(const QString &id); void disconnectFromId(const QString &id); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index 3ebc356..29445ce 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -104,14 +104,23 @@ void QNetworkManagerEngine::initialize() QMutexLocker locker(&mutex); // Get current list of access points. - foreach (const QDBusObjectPath &devicePath, interface->getDevices()) + foreach (const QDBusObjectPath &devicePath, interface->getDevices()) { + locker.unlock(); deviceAdded(devicePath); + locker.relock(); + } // Get connections. - foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) + foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) { + locker.unlock(); newConnection(settingsPath, systemSettings); - foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) + locker.relock(); + } + foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) { + locker.unlock(); newConnection(settingsPath, userSettings); + locker.relock(); + } // Get active connections. foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { @@ -132,11 +141,6 @@ bool QNetworkManagerEngine::networkManagerAvailable() const return interface->isValid(); } -void QNetworkManagerEngine::doRequestUpdate() -{ - emit updateCompleted(); -} - QString QNetworkManagerEngine::getInterfaceFromId(const QString &id) { QMutexLocker locker(&mutex); @@ -181,30 +185,6 @@ bool QNetworkManagerEngine::hasIdentifier(const QString &id) return false; } -QString QNetworkManagerEngine::bearerName(const QString &id) -{ - QMutexLocker locker(&mutex); - - QNetworkManagerSettingsConnection *connection = connectionFromId(id); - - if (!connection) - return QString(); - - QNmSettingsMap map = connection->getSettings(); - const QString connectionType = map.value("connection").value("type").toString(); - - if (connectionType == "802-3-ethernet") - return QLatin1String("Ethernet"); - else if (connectionType == "802-11-wireless") - return QLatin1String("WLAN"); - else if (connectionType == "gsm") - return QLatin1String("2G"); - else if (connectionType == "cdma") - return QLatin1String("CDMA2000"); - else - return QString(); -} - void QNetworkManagerEngine::connectToId(const QString &id) { QMutexLocker locker(&mutex); @@ -257,9 +237,7 @@ void QNetworkManagerEngine::disconnectFromId(const QString &id) void QNetworkManagerEngine::requestUpdate() { - QMutexLocker locker(&mutex); - - QTimer::singleShot(0, this, SLOT(doRequestUpdate())); + QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection); } void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path, @@ -385,13 +363,10 @@ void QNetworkManagerEngine::devicePropertiesChanged(const QString &path, void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) { - QMutexLocker locker(&mutex); - QNetworkManagerInterfaceDevice device(path.path()); if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) { QNetworkManagerInterfaceDeviceWireless *wirelessDevice = new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path()); - wirelessDevices.insert(path.path(), wirelessDevice); wirelessDevice->setConnections(); connect(wirelessDevice, SIGNAL(accessPointAdded(QString,QDBusObjectPath)), @@ -403,6 +378,10 @@ void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints()) newAccessPoint(QString(), apPath); + + mutex.lock(); + wirelessDevices.insert(path.path(), wirelessDevice); + mutex.unlock(); } } @@ -611,7 +590,7 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjec ptr->purpose = QNetworkConfiguration::PublicPurpose; } ptr->state = QNetworkConfiguration::Undefined; - ptr->bearer = QLatin1String("WLAN"); + ptr->bearerType = QNetworkConfiguration::BearerWLAN; accessPointConfigurations.insert(ptr->id, ptr); @@ -709,8 +688,6 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri const QString &settingsPath, const QNmSettingsMap &map) { - QMutexLocker locker(&mutex); - QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate; cpPriv->name = map.value("connection").value("id").toString(); cpPriv->isValid = true; @@ -724,7 +701,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri const QString connectionType = map.value("connection").value("type").toString(); if (connectionType == QLatin1String("802-3-ethernet")) { - cpPriv->bearer = QLatin1String("Ethernet"); + cpPriv->bearerType = QNetworkConfiguration::BearerEthernet; cpPriv->purpose = QNetworkConfiguration::PublicPurpose; foreach (const QDBusObjectPath &devicePath, interface->getDevices()) { @@ -739,7 +716,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri } } } else if (connectionType == QLatin1String("802-11-wireless")) { - cpPriv->bearer = QLatin1String("WLAN"); + cpPriv->bearerType = QNetworkConfiguration::BearerWLAN; const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString(); const QString connectionSecurity = map.value("802-11-wireless").value("security").toString(); @@ -759,17 +736,17 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(accessPointId); - locker.unlock(); + mutex.unlock(); emit configurationRemoved(ptr); - locker.relock(); + mutex.lock(); } break; } } } else if (connectionType == "gsm") { - cpPriv->bearer = QLatin1String("2G"); + cpPriv->bearerType = QNetworkConfiguration::Bearer2G; } else if (connectionType == "cdma") { - cpPriv->bearer = QLatin1String("CDMA2000"); + cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000; } return cpPriv; @@ -777,8 +754,6 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const QString &id) const { - QMutexLocker locker(&mutex); - for (int i = 0; i < connections.count(); ++i) { QNetworkManagerSettingsConnection *connection = connections.at(i); const QString service = connection->connectionInterface()->service(); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h index 8e95a2c..78ebb0a 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -78,8 +78,6 @@ public: QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); - QString bearerName(const QString &id); - void connectToId(const QString &id); void disconnectFromId(const QString &id); @@ -118,8 +116,6 @@ private Q_SLOTS: void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath); void updateAccessPoint(const QMap<QString, QVariant> &map); - void doRequestUpdate(); - private: QNetworkConfigurationPrivate *parseConnection(const QString &service, const QString &settingsPath, diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 31a9aa1..f47c97c 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -718,146 +718,80 @@ QNmSettingsMap QNetworkManagerSettingsConnection::getSettings() NMDeviceType QNetworkManagerSettingsConnection::getType() { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("type")); - while (ii != innerMap.end() && ii.key() == QLatin1String("type")) { - QString devType = ii.value().toString(); - if (devType == QLatin1String("802-3-ethernet")) { - return DEVICE_TYPE_802_3_ETHERNET; - } - if (devType == QLatin1String("802-11-wireless")) { - return DEVICE_TYPE_802_11_WIRELESS; - } - ii++; - } - i++; - } - return DEVICE_TYPE_UNKNOWN; + const QString devType = + d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString(); + + if (devType == QLatin1String("802-3-ethernet")) + return DEVICE_TYPE_802_3_ETHERNET; + else if (devType == QLatin1String("802-11-wireless")) + return DEVICE_TYPE_802_11_WIRELESS; + else + return DEVICE_TYPE_UNKNOWN; } bool QNetworkManagerSettingsConnection::isAutoConnect() { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("autoconnect")); - while (ii != innerMap.end() && ii.key() == QLatin1String("autoconnect")) { - return ii.value().toBool(); - ii++; - } - i++; - } - return true; //default networkmanager is autoconnect + const QVariant autoConnect = + d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect")); + + // NetworkManager default is to auto connect + if (!autoConnect.isValid()) + return true; + + return autoConnect.toBool(); } quint64 QNetworkManagerSettingsConnection::getTimestamp() { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("timestamp")); - while (ii != innerMap.end() && ii.key() == QLatin1String("timestamp")) { - return ii.value().toUInt(); - ii++; - } - i++; - } - return 0; + qDebug() << d->settingsMap.value(QLatin1String("connection")); + + return d->settingsMap.value(QLatin1String("connection")) + .value(QLatin1String("timestamp")).toUInt(); } QString QNetworkManagerSettingsConnection::getId() { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("id")); - while (ii != innerMap.end() && ii.key() == QLatin1String("id")) { - return ii.value().toString(); - ii++; - } - i++; - } - return QString(); + return d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString(); } QString QNetworkManagerSettingsConnection::getUuid() { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("uuid")); - while (ii != innerMap.end() && ii.key() == QLatin1String("uuid")) { - return ii.value().toString(); - ii++; - } - i++; - } + const QString id = d->settingsMap.value(QLatin1String("connection")) + .value(QLatin1String("uuid")).toString(); + // is no uuid, return the connection path - return d->connectionInterface->path(); + return id.isEmpty() ? d->connectionInterface->path() : id; } QString QNetworkManagerSettingsConnection::getSsid() { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("802-11-wireless")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("802-11-wireless")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("ssid")); - while (ii != innerMap.end() && ii.key() == QLatin1String("ssid")) { - return ii.value().toString(); - ii++; - } - i++; - } - return QString(); + return d->settingsMap.value(QLatin1String("802-11-wireless")) + .value(QLatin1String("ssid")).toString(); } QString QNetworkManagerSettingsConnection::getMacAddress() { - if(getType() == DEVICE_TYPE_802_3_ETHERNET) { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("802-3-ethernet")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("802-3-ethernet")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("mac-address")); - while (ii != innerMap.end() && ii.key() == QLatin1String("mac-address")) { - return ii.value().toString(); - ii++; - } - i++; - } - } + NMDeviceType type = getType(); - else if(getType() == DEVICE_TYPE_802_11_WIRELESS) { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("802-11-wireless")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("802-11-wireless")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("mac-address")); - while (ii != innerMap.end() && ii.key() == QLatin1String("mac-address")) { - return ii.value().toString(); - ii++; - } - i++; - } + if (type == DEVICE_TYPE_802_3_ETHERNET) { + return d->settingsMap.value(QLatin1String("802-3-ethernet")) + .value(QLatin1String("mac-address")).toString(); + } else if (type == DEVICE_TYPE_802_11_WIRELESS) { + return d->settingsMap.value(QLatin1String("802-11-wireless")) + .value(QLatin1String("mac-address")).toString(); + } else { + return QString(); } - return QString(); -} - -QStringList QNetworkManagerSettingsConnection::getSeenBssids() -{ - if(getType() == DEVICE_TYPE_802_11_WIRELESS) { - QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("802-11-wireless")); - while (i != d->settingsMap.end() && i.key() == QLatin1String("802-11-wireless")) { - QMap<QString,QVariant> innerMap = i.value(); - QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("seen-bssids")); - while (ii != innerMap.end() && ii.key() == QLatin1String("seen-bssids")) { - return ii.value().toStringList(); - ii++; - } - i++; - } +} + +QStringList QNetworkManagerSettingsConnection::getSeenBssids() +{ + if (getType() == DEVICE_TYPE_802_11_WIRELESS) { + return d->settingsMap.value(QLatin1String("802-11-wireless")) + .value(QLatin1String("seen-bssids")).toStringList(); + } else { + return QStringList(); } - return QStringList(); } class QNetworkManagerConnectionActivePrivate diff --git a/src/plugins/bearer/nla/qnlaengine.cpp b/src/plugins/bearer/nla/qnlaengine.cpp index 9ab9924..fd50099 100644 --- a/src/plugins/bearer/nla/qnlaengine.cpp +++ b/src/plugins/bearer/nla/qnlaengine.cpp @@ -119,7 +119,7 @@ static void printBlob(NLA_BLOB *blob) } #endif -static QString qGetInterfaceType(const QString &interface) +static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface) { #ifdef Q_OS_WINCE Q_UNUSED(interface) @@ -130,10 +130,10 @@ static QString qGetInterfaceType(const QString &interface) NDIS_MEDIUM medium; NDIS_PHYSICAL_MEDIUM physicalMedium; - HANDLE handle = CreateFile((TCHAR *)QString(QLatin1String("\\\\.\\%1")).arg(interface).utf16(), - 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0, + FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (handle == INVALID_HANDLE_VALUE) - return QLatin1String("Unknown"); + return QNetworkConfiguration::BearerUnknown; oid = OID_GEN_MEDIA_SUPPORTED; bytesWritten = 0; @@ -141,7 +141,7 @@ static QString qGetInterfaceType(const QString &interface) &medium, sizeof(medium), &bytesWritten, 0); if (!result) { CloseHandle(handle); - return QLatin1String("Unknown"); + return QNetworkConfiguration::BearerUnknown; } oid = OID_GEN_PHYSICAL_MEDIUM; @@ -152,9 +152,9 @@ static QString qGetInterfaceType(const QString &interface) CloseHandle(handle); if (medium == NdisMedium802_3) - return QLatin1String("Ethernet"); + return QNetworkConfiguration::BearerEthernet; else - return QLatin1String("Unknown"); + return QNetworkConfiguration::BearerUnknown; } CloseHandle(handle); @@ -162,16 +162,16 @@ static QString qGetInterfaceType(const QString &interface) if (medium == NdisMedium802_3) { switch (physicalMedium) { case NdisPhysicalMediumWirelessLan: - return QLatin1String("WLAN"); + return QNetworkConfiguration::BearerWLAN; case NdisPhysicalMediumBluetooth: - return QLatin1String("Bluetooth"); + return QNetworkConfiguration::BearerBluetooth; case NdisPhysicalMediumWiMax: - return QLatin1String("WiMAX"); + return QNetworkConfiguration::BearerWiMAX; default: #ifdef BEARER_MANAGEMENT_DEBUG qDebug() << "Physical Medium" << physicalMedium; #endif - return QLatin1String("Ethernet"); + return QNetworkConfiguration::BearerEthernet; } } @@ -181,7 +181,7 @@ static QString qGetInterfaceType(const QString &interface) #endif - return QLatin1String("Unknown"); + return QNetworkConfiguration::BearerUnknown; } class QNlaThread : public QThread @@ -374,10 +374,9 @@ DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv #endif break; case NLA_CONNECTIVITY: - if (blob->data.connectivity.internet == NLA_INTERNET_YES) - cpPriv->internet = true; - else - cpPriv->internet = false; +#ifdef BEARER_MANAGEMENT_DEBUG + qDebug("%s: unhandled header type NLA_CONNECTIVITY", __FUNCTION__); +#endif break; case NLA_ICS: #ifdef BEARER_MANAGEMENT_DEBUG @@ -438,8 +437,10 @@ QNetworkConfigurationPrivate *QNlaThread::parseQuerySet(const WSAQUERYSET *query } while (offset != 0 && offset < querySet->lpBlob->cbSize); } - if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) - cpPriv->bearer = engine->bearerName(cpPriv->id); + if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) { + const QString interface = engine->getInterfaceFromId(cpPriv->id); + cpPriv->bearerType = qGetInterfaceType(interface); + } return cpPriv; } @@ -586,16 +587,6 @@ bool QNlaEngine::hasIdentifier(const QString &id) return configurationInterface.contains(id.toUInt()); } -QString QNlaEngine::bearerName(const QString &id) -{ - QString interface = getInterfaceFromId(id); - - if (interface.isEmpty()) - return QString(); - - return qGetInterfaceType(interface); -} - void QNlaEngine::connectToId(const QString &id) { emit connectionError(id, OperationNotSupported); diff --git a/src/plugins/bearer/nla/qnlaengine.h b/src/plugins/bearer/nla/qnlaengine.h index 1d49464..69f54c9 100644 --- a/src/plugins/bearer/nla/qnlaengine.h +++ b/src/plugins/bearer/nla/qnlaengine.h @@ -85,8 +85,6 @@ public: QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); - QString bearerName(const QString &id); - void connectToId(const QString &id); void disconnectFromId(const QString &id); diff --git a/src/plugins/bearer/symbian/3_1/3_1.pro b/src/plugins/bearer/symbian/3_1/3_1.pro index 2d721a8..b7c6aef 100644 --- a/src/plugins/bearer/symbian/3_1/3_1.pro +++ b/src/plugins/bearer/symbian/3_1/3_1.pro @@ -1,5 +1,9 @@ include(../symbian.pri) -LIBS += -lapengine +is_using_gnupoc { + LIBS += -lapengine +} else { + LIBS += -lAPEngine +} TARGET = $${TARGET}_3_1 TARGET.UID3 = 0x2002131C diff --git a/src/plugins/bearer/symbian/symbian.pri b/src/plugins/bearer/symbian/symbian.pri index afe84dc..9b3f50c 100644 --- a/src/plugins/bearer/symbian/symbian.pri +++ b/src/plugins/bearer/symbian/symbian.pri @@ -14,8 +14,6 @@ INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE symbian-abld:INCLUDEPATH += $$QT_BUILD_TREE/include/QtNetwork/private LIBS += -lcommdb \ - -lapsettingshandlerui \ - -lconnmon \ -lcentralrepository \ -lesock \ -linsock \ @@ -23,6 +21,14 @@ LIBS += -lcommdb \ -lefsrv \ -lnetmeta +is_using_gnupoc { + LIBS += -lconnmon \ + -lapsettingshandlerui +} else { + LIBS += -lConnMon \ + -lApSettingsHandlerUI +} + QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer INSTALLS += target diff --git a/src/plugins/bearer/symbian/symbian_3/symbian_3.pro b/src/plugins/bearer/symbian/symbian_3/symbian_3.pro index ff0f11c..fd66198 100644 --- a/src/plugins/bearer/symbian/symbian_3/symbian_3.pro +++ b/src/plugins/bearer/symbian/symbian_3/symbian_3.pro @@ -12,7 +12,11 @@ symbian { } } else { # Fall back to 3_1 implementation on platforms that do not have cmmanager - LIBS += -lapengine + is_using_gnupoc { + LIBS += -lapengine + } else { + LIBS += -lAPEngine + } } } diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 4bd6d2f..9593461 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -63,9 +63,9 @@ #include <cmpluginpacketdatadef.h> #include <cmplugindialcommondefs.h> #else - #include <apaccesspointitem.h> - #include <apdatahandler.h> - #include <aputils.h> + #include <ApAccessPointItem.h> + #include <ApDataHandler.h> + #include <ApUtils.h> #endif #ifndef QT_NO_BEARERMANAGEMENT @@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE static const int KUserChoiceIAPId = 0; SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() -: bearer(BearerUnknown), numericId(0), connectionId(0) +: numericId(0), connectionId(0) { } @@ -83,32 +83,6 @@ SymbianNetworkConfigurationPrivate::~SymbianNetworkConfigurationPrivate() { } -QString SymbianNetworkConfigurationPrivate::bearerName() const -{ - QMutexLocker locker(&mutex); - - switch (bearer) { - case BearerEthernet: - return QLatin1String("Ethernet"); - case BearerWLAN: - return QLatin1String("WLAN"); - case Bearer2G: - return QLatin1String("2G"); - case BearerCDMA2000: - return QLatin1String("CDMA2000"); - case BearerWCDMA: - return QLatin1String("WCDMA"); - case BearerHSPA: - return QLatin1String("HSPA"); - case BearerBluetooth: - return QLatin1String("Bluetooth"); - case BearerWiMAX: - return QLatin1String("WiMAX"); - default: - return QString(); - } -} - SymbianEngine::SymbianEngine(QObject *parent) : QBearerEngine(parent), CActive(CActive::EPriorityHigh), iFirstUpdate(true), iInitOk(true), iUpdatePending(false) @@ -146,7 +120,7 @@ void SymbianEngine::initialize() SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; cpPriv->name = "UserChoice"; - cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; cpPriv->state = QNetworkConfiguration::Discovered; cpPriv->isValid = true; cpPriv->id = QString::number(qHash(KUserChoiceIAPId)); @@ -517,25 +491,25 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( TUint32 bearerId = connectionMethod.GetIntAttributeL(CMManager::ECmCommsDBBearerType); switch (bearerId) { case KCommDbBearerCSD: - cpPriv->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + cpPriv->bearerType = QNetworkConfiguration::Bearer2G; break; case KCommDbBearerWcdma: - cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; + cpPriv->bearerType = QNetworkConfiguration::BearerWCDMA; break; case KCommDbBearerLAN: - cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; + cpPriv->bearerType = QNetworkConfiguration::BearerEthernet; break; case KCommDbBearerVirtual: - cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; break; case KCommDbBearerPAN: - cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; break; case KCommDbBearerWLAN: - cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerWLAN; + cpPriv->bearerType = QNetworkConfiguration::BearerWLAN; break; default: - cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; break; } @@ -619,28 +593,28 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( apNetworkConfiguration->roamingSupported = false; switch (pAPItem->BearerTypeL()) { case EApBearerTypeCSD: - apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + apNetworkConfiguration->bearerType = QNetworkConfiguration::Bearer2G; break; case EApBearerTypeGPRS: - apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + apNetworkConfiguration->bearerType = QNetworkConfiguration::Bearer2G; break; case EApBearerTypeHSCSD: - apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerHSPA; break; case EApBearerTypeCDMA: - apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000; + apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerCDMA2000; break; case EApBearerTypeWLAN: - apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerWLAN; + apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerWLAN; break; case EApBearerTypeLAN: - apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; + apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerEthernet; break; case EApBearerTypeLANModem: - apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; + apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerEthernet; break; default: - apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerUnknown; break; } @@ -870,38 +844,38 @@ void SymbianEngine::updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo) SymbianNetworkConfigurationPrivate *p = toSymbianConfig(ptr); - if (p->bearer >= SymbianNetworkConfigurationPrivate::Bearer2G && - p->bearer <= SymbianNetworkConfigurationPrivate::BearerHSPA) { + if (p->bearerType >= QNetworkConfiguration::Bearer2G && + p->bearerType <= QNetworkConfiguration::BearerHSPA) { switch (bearerInfo) { case EBearerInfoCSD: - p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + p->bearerType = QNetworkConfiguration::Bearer2G; break; case EBearerInfoWCDMA: - p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; + p->bearerType = QNetworkConfiguration::BearerWCDMA; break; case EBearerInfoCDMA2000: - p->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000; + p->bearerType = QNetworkConfiguration::BearerCDMA2000; break; case EBearerInfoGPRS: - p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + p->bearerType = QNetworkConfiguration::Bearer2G; break; case EBearerInfoHSCSD: - p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + p->bearerType = QNetworkConfiguration::Bearer2G; break; case EBearerInfoEdgeGPRS: - p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + p->bearerType = QNetworkConfiguration::Bearer2G; break; case EBearerInfoWcdmaCSD: - p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; + p->bearerType = QNetworkConfiguration::BearerWCDMA; break; case EBearerInfoHSDPA: - p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + p->bearerType = QNetworkConfiguration::BearerHSPA; break; case EBearerInfoHSUPA: - p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + p->bearerType = QNetworkConfiguration::BearerHSPA; break; case EBearerInfoHSxPA: - p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + p->bearerType = QNetworkConfiguration::BearerHSPA; break; } } diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index ecd858d..1fe6395 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -73,23 +73,9 @@ class AccessPointsAvailabilityScanner; class SymbianNetworkConfigurationPrivate : public QNetworkConfigurationPrivate { public: - enum Bearer { - BearerEthernet, - BearerWLAN, - Bearer2G, - BearerCDMA2000, - BearerWCDMA, - BearerHSPA, - BearerBluetooth, - BearerWiMAX, - BearerUnknown = -1 - }; - SymbianNetworkConfigurationPrivate(); ~SymbianNetworkConfigurationPrivate(); - QString bearerName() const; - inline TUint32 numericIdentifier() const { QMutexLocker locker(&mutex); @@ -110,8 +96,6 @@ public: QString mappingName; - Bearer bearer; - // So called IAP id from the platform. Remains constant as long as the // platform is aware of the configuration ie. it is stored in the databases // --> does not depend on whether connections are currently open or not. |