diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/networksettings/connman/qnetworksettingsmanager_p.cpp | 89 | ||||
-rw-r--r-- | src/networksettings/connman/qnetworksettingsmanager_p.h | 14 | ||||
-rw-r--r-- | src/networksettings/qnetworksettings.cpp | 7 | ||||
-rw-r--r-- | src/networksettings/qnetworksettingsinterfacemodel.cpp | 9 | ||||
-rw-r--r-- | src/timedatesettings/timezonemodel.h | 2 |
5 files changed, 89 insertions, 32 deletions
diff --git a/src/networksettings/connman/qnetworksettingsmanager_p.cpp b/src/networksettings/connman/qnetworksettingsmanager_p.cpp index a56edca..36dddfe 100644 --- a/src/networksettings/connman/qnetworksettingsmanager_p.cpp +++ b/src/networksettings/connman/qnetworksettingsmanager_p.cpp @@ -141,8 +141,7 @@ void QNetworkSettingsManagerPrivate::tryNextConnection() } if (!service) { if (!m_unnamedServicesForSsidConnection.isEmpty()) { - service = *m_unnamedServicesForSsidConnection.begin(); - m_unnamedServicesForSsidConnection.erase(m_unnamedServicesForSsidConnection.begin()); + service = m_unnamedServicesForSsidConnection.take(m_unnamedServicesForSsidConnection.firstKey()); } else { q->clearConnectionState(); } @@ -152,6 +151,26 @@ void QNetworkSettingsManagerPrivate::tryNextConnection() } } +void QNetworkSettingsManagerPrivate::setCurrentWifiConnection(QNetworkSettingsService *connection) +{ + m_currentWifiConnection = connection; +} + +QNetworkSettingsService *QNetworkSettingsManagerPrivate::currentWifiConnection() const +{ + return m_currentWifiConnection.data(); +} + +void QNetworkSettingsManagerPrivate::setCurrentWiredConnection(QNetworkSettingsService *connection) +{ + m_currentWiredConnection = connection; +} + +QNetworkSettingsService *QNetworkSettingsManagerPrivate::currentWiredConnection() const +{ + return m_currentWiredConnection.data(); +} + void QNetworkSettingsManagerPrivate::onConnmanServiceRegistered(const QString &serviceName) { if (serviceName == ConnManServiceName) { @@ -188,7 +207,7 @@ void QNetworkSettingsManagerPrivate::onTechnologyRemoved(const QDBusObjectPath & foreach (QNetworkSettingsInterface* item, m_interfaceModel.getModel()) { ConnmanSettingsInterface* tech = qobject_cast<ConnmanSettingsInterface*>(item); if (tech->path() == technology.path()) { - m_interfaceModel.removeInterface(technology.path()); + m_interfaceModel.removeInterface(tech->name()); emit q->interfacesChanged(); } } @@ -233,21 +252,43 @@ void QNetworkSettingsManagerPrivate::getTechnologiesFinished(QDBusPendingCallWat void QNetworkSettingsManagerPrivate::onServicesChanged(ConnmanMapStructList changed, const QList<QDBusObjectPath> &removed) { - foreach (QDBusObjectPath path, removed) { - m_serviceModel->removeService(path.path()); - auto serviceIter = m_unnamedServices.find(path.path()); - if (serviceIter != m_unnamedServices.end()) { - serviceIter.value()->deleteLater(); - m_unnamedServices.erase(serviceIter); - } + Q_Q(QNetworkSettingsManager); + foreach (const QDBusObjectPath &dpath, removed) { + QString path = dpath.path(); + + if (m_serviceModel->removeService(path)) + emit q->servicesChanged(); + + if (auto service = m_unnamedServices.take(path)) + if (!service->placeholderState()) { + disconnect(service, &QNetworkSettingsService::nameChanged, + this, &QNetworkSettingsManagerPrivate::serviceReady); + disconnect(service, &QNetworkSettingsService::typeChanged, + this, &QNetworkSettingsManagerPrivate::serviceReady); + service->deleteLater(); + } + if (auto service = m_unknownServices.take(path)) + if (!service->placeholderState()) { + disconnect(service, &QNetworkSettingsService::nameChanged, + this, &QNetworkSettingsManagerPrivate::serviceReady); + disconnect(service, &QNetworkSettingsService::typeChanged, + this, &QNetworkSettingsManagerPrivate::serviceReady); + service->deleteLater(); + } + m_unnamedServicesForSsidConnection.remove(path); // do not delete here } QStringList newServices; - foreach (ConnmanMapStruct map, changed) { + foreach (const ConnmanMapStruct &map, changed) { + QString path = map.objectPath.path(); + + if (m_unknownServices.contains(path) || m_unnamedServices.contains(path)) + continue; + bool found = false; foreach (QNetworkSettingsService* service, m_serviceModel->getModel()) { - if (service->id() == map.objectPath.path() && service->placeholderState() == false) { - found =true; + if (service->id() == path && service->placeholderState() == false) { + found = true; break; } } @@ -283,9 +324,20 @@ void QNetworkSettingsManagerPrivate::handleNewService(const QString &servicePath } } else { + bool isUnnamedWifi = false; + //Service name or type not set, wait for update - connect(service, &QNetworkSettingsService::nameChanged, this, &QNetworkSettingsManagerPrivate::serviceReady); - connect(service, &QNetworkSettingsService::typeChanged, this, &QNetworkSettingsManagerPrivate::serviceReady); + if (service->name().isEmpty()) { + connect(service, &QNetworkSettingsService::nameChanged, this, &QNetworkSettingsManagerPrivate::serviceReady); + isUnnamedWifi = (service->type() == QNetworkSettingsType::Wifi); + } + if (service->type() == QNetworkSettingsType::Unknown) + connect(service, &QNetworkSettingsService::typeChanged, this, &QNetworkSettingsManagerPrivate::serviceReady); + + if (isUnnamedWifi) + m_unnamedServices.insert(service->id(), service); + else + m_unknownServices.insert(service->id(), service); } } @@ -300,11 +352,14 @@ void QNetworkSettingsManagerPrivate::serviceReady() QNetworkSettingsService* service = qobject_cast<QNetworkSettingsService*>(sender()); - if (service->type() != QNetworkSettingsType::Unknown - && service->type() == QNetworkSettingsType::Wifi) { + // the type changed from Unknown to Wifi + if ((service->type() == QNetworkSettingsType::Wifi) + && m_unknownServices.contains(service->id())) { + m_unknownServices.remove(service->id()); m_unnamedServices.insert(service->id(), service); } + // we have a name and a length now if (service->name().length() > 0 && service->type() != QNetworkSettingsType::Unknown) { service->disconnect(this); m_unnamedServices.remove(service->id()); diff --git a/src/networksettings/connman/qnetworksettingsmanager_p.h b/src/networksettings/connman/qnetworksettingsmanager_p.h index c6f31e6..16cb899 100644 --- a/src/networksettings/connman/qnetworksettingsmanager_p.h +++ b/src/networksettings/connman/qnetworksettingsmanager_p.h @@ -43,6 +43,7 @@ #include <QObject> #include <QtDBus> #include <QMap> +#include <QPointer> #include "connmancommon.h" #include "qnetworksettingsmanager.h" #include "qnetworksettingsinterfacemodel.h" @@ -70,10 +71,10 @@ public: void connectBySsid(const QString &name); void clearConnectionState(); void tryNextConnection(); - void setCurrentWifiConnection(QNetworkSettingsService *connection) {m_currentWifiConnection = connection;} - QNetworkSettingsService* currentWifiConnection() const {return m_currentWifiConnection;} - void setCurrentWiredConnection(QNetworkSettingsService *connection) {m_currentWiredConnection = connection;} - QNetworkSettingsService* currentWiredConnection() const {return m_currentWiredConnection;} + void setCurrentWifiConnection(QNetworkSettingsService *connection); + QNetworkSettingsService* currentWifiConnection() const; + void setCurrentWiredConnection(QNetworkSettingsService *connection); + QNetworkSettingsService* currentWiredConnection() const; QString usbEthernetInternetProtocolAddress(); QString usbVirtualEthernetLinkProtocol(); bool hasUsbEthernetProtocolConfiguration(); @@ -99,6 +100,7 @@ private: protected: QNetworkSettingsInterfaceModel m_interfaceModel; QNetworkSettingsServiceModel *m_serviceModel; + QMap<QString, QNetworkSettingsService*> m_unknownServices; QMap<QString, QNetworkSettingsService*> m_unnamedServices; QMap<QString, QNetworkSettingsService*> m_unnamedServicesForSsidConnection; QNetworkSettingsServiceFilter *m_serviceFilter; @@ -107,8 +109,8 @@ private: QNetworkSettingsUserAgent *m_agent; QDBusServiceWatcher *m_serviceWatcher; QString m_currentSsid; - QNetworkSettingsService *m_currentWifiConnection; - QNetworkSettingsService *m_currentWiredConnection; + QPointer<QNetworkSettingsService> m_currentWifiConnection; + QPointer<QNetworkSettingsService> m_currentWiredConnection; bool m_initialized; }; diff --git a/src/networksettings/qnetworksettings.cpp b/src/networksettings/qnetworksettings.cpp index e4ddbad..be477e5 100644 --- a/src/networksettings/qnetworksettings.cpp +++ b/src/networksettings/qnetworksettings.cpp @@ -587,7 +587,12 @@ void QNetworkSettingsProxy::setMethod(const MethodType& method) { Creates a new Wifi network configuration with the parent \a parent. */ QNetworkSettingsWireless::QNetworkSettingsWireless(QObject* parent) - : QObject(parent) { + : QObject(parent) + , m_securityFlags(None) + , m_hidden(false) + , m_signalStrength(0) + , m_isOutOfRange(false) +{ } /*! diff --git a/src/networksettings/qnetworksettingsinterfacemodel.cpp b/src/networksettings/qnetworksettingsinterfacemodel.cpp index 045d3ff..8d6ca60 100644 --- a/src/networksettings/qnetworksettingsinterfacemodel.cpp +++ b/src/networksettings/qnetworksettingsinterfacemodel.cpp @@ -122,12 +122,7 @@ QVariant QNetworkSettingsInterfaceModel::data(const QModelIndex & index, int rol */ void QNetworkSettingsInterfaceModel::append(QNetworkSettingsInterface* item) { - item->setParent(this); - connectStateChanges(item); - - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_items.append(item); - endInsertRows(); + insert(rowCount(), item); } /*! @@ -155,7 +150,7 @@ void QNetworkSettingsInterfaceModel::connectStateChanges(QNetworkSettingsInterfa void QNetworkSettingsInterfaceModel::remove(int row) { beginRemoveRows(QModelIndex(), row, row); - m_items.removeFirst(); + m_items.takeAt(row)->deleteLater(); endRemoveRows(); } diff --git a/src/timedatesettings/timezonemodel.h b/src/timedatesettings/timezonemodel.h index 6684472..bfc63d2 100644 --- a/src/timedatesettings/timezonemodel.h +++ b/src/timedatesettings/timezonemodel.h @@ -36,7 +36,7 @@ QT_BEGIN_NAMESPACE -class TimezoneItem : public QObject +class Q_DECL_EXPORT TimezoneItem : public QObject { Q_OBJECT Q_PROPERTY(QString id READ id CONSTANT) |