Make networkmanager bearer backend work better
This fixes QNetworkConfigurations when user: - configures new AP - deletes connection configuration - switches wifi AP Change-Id: I38c543c6de7b61f49d7ac96fa05f7a6fc4fba70f Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
This commit is contained in:
parent
6c308e6f1d
commit
0ca0ecdb32
@ -55,21 +55,21 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent)
|
||||
: QBearerEngineImpl(parent),
|
||||
interface(new QNetworkManagerInterface(this)),
|
||||
managerInterface(new QNetworkManagerInterface(this)),
|
||||
systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE, this)),
|
||||
userSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE, this))
|
||||
{
|
||||
if (!interface->isValid())
|
||||
if (!managerInterface->isValid())
|
||||
return;
|
||||
|
||||
interface->setConnections();
|
||||
connect(interface, SIGNAL(deviceAdded(QDBusObjectPath)),
|
||||
managerInterface->setConnections();
|
||||
connect(managerInterface, SIGNAL(deviceAdded(QDBusObjectPath)),
|
||||
this, SLOT(deviceAdded(QDBusObjectPath)));
|
||||
connect(interface, SIGNAL(deviceRemoved(QDBusObjectPath)),
|
||||
connect(managerInterface, SIGNAL(deviceRemoved(QDBusObjectPath)),
|
||||
this, SLOT(deviceRemoved(QDBusObjectPath)));
|
||||
connect(interface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
|
||||
connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
|
||||
this, SLOT(activationFinished(QDBusPendingCallWatcher*)));
|
||||
connect(interface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
connect(managerInterface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this, SLOT(interfacePropertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
|
||||
qDBusRegisterMetaType<QNmSettingsMap>();
|
||||
@ -96,9 +96,9 @@ void QNetworkManagerEngine::initialize()
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
// Get current list of access points.
|
||||
foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
|
||||
foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
|
||||
locker.unlock();
|
||||
deviceAdded(devicePath);
|
||||
deviceAdded(devicePath); //add all accesspoints
|
||||
locker.relock();
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ void QNetworkManagerEngine::initialize()
|
||||
foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) {
|
||||
locker.unlock();
|
||||
if (!hasIdentifier(settingsPath.path()))
|
||||
newConnection(settingsPath, systemSettings);
|
||||
newConnection(settingsPath, systemSettings); //add system connection configs
|
||||
locker.relock();
|
||||
}
|
||||
|
||||
@ -119,10 +119,9 @@ void QNetworkManagerEngine::initialize()
|
||||
}
|
||||
|
||||
// Get active connections.
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive *activeConnection =
|
||||
new QNetworkManagerConnectionActive(acPath.path(),this);
|
||||
|
||||
activeConnections.insert(acPath.path(), activeConnection);
|
||||
|
||||
activeConnection->setConnections();
|
||||
@ -136,14 +135,14 @@ bool QNetworkManagerEngine::networkManagerAvailable() const
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
return interface->isValid();
|
||||
return managerInterface->isValid();
|
||||
}
|
||||
|
||||
QString QNetworkManagerEngine::getInterfaceFromId(const QString &id)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive activeConnection(acPath.path());
|
||||
|
||||
const QString identifier = activeConnection.connection().path();
|
||||
@ -182,18 +181,17 @@ void QNetworkManagerEngine::connectToId(const QString &id)
|
||||
const QString connectionType = map.value("connection").value("type").toString();
|
||||
|
||||
QString dbusDevicePath;
|
||||
foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
|
||||
foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
|
||||
QNetworkManagerInterfaceDevice device(devicePath.path());
|
||||
if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET &&
|
||||
if (device.deviceType() == DEVICE_TYPE_ETHERNET &&
|
||||
connectionType == QLatin1String("802-3-ethernet")) {
|
||||
dbusDevicePath = devicePath.path();
|
||||
break;
|
||||
} else if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS &&
|
||||
} else if (device.deviceType() == DEVICE_TYPE_WIFI &&
|
||||
connectionType == QLatin1String("802-11-wireless")) {
|
||||
dbusDevicePath = devicePath.path();
|
||||
break;
|
||||
}
|
||||
else if (device.deviceType() == DEVICE_TYPE_GSM &&
|
||||
} else if (device.deviceType() == DEVICE_TYPE_MODEM &&
|
||||
connectionType == QLatin1String("gsm")) {
|
||||
dbusDevicePath = devicePath.path();
|
||||
break;
|
||||
@ -207,7 +205,7 @@ void QNetworkManagerEngine::connectToId(const QString &id)
|
||||
if (specificPath.isEmpty())
|
||||
specificPath = "/";
|
||||
|
||||
interface->activateConnection(service, QDBusObjectPath(settingsPath),
|
||||
managerInterface->activateConnection(service, QDBusObjectPath(settingsPath),
|
||||
QDBusObjectPath(dbusDevicePath), QDBusObjectPath(specificPath));
|
||||
}
|
||||
|
||||
@ -223,19 +221,31 @@ void QNetworkManagerEngine::disconnectFromId(const QString &id)
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive activeConnection(acPath.path());
|
||||
|
||||
const QString identifier = activeConnection.connection().path();
|
||||
|
||||
if (id == identifier && accessPointConfigurations.contains(id)) {
|
||||
interface->deactivateConnection(acPath);
|
||||
managerInterface->deactivateConnection(acPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::requestUpdate()
|
||||
{
|
||||
if (managerInterface->wirelessEnabled()) {
|
||||
QHashIterator<QString, QNetworkManagerInterfaceDeviceWireless *> i(wirelessDevices);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
i.value()->requestScan();
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::scanFinished()
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
|
||||
}
|
||||
@ -282,7 +292,7 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
if (ptr) {
|
||||
ptr->mutex.lock();
|
||||
if (activeConnection->state() == 2 &&
|
||||
if (activeConnection->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
|
||||
ptr->state != QNetworkConfiguration::Active) {
|
||||
ptr->state = QNetworkConfiguration::Active;
|
||||
ptr->mutex.unlock();
|
||||
@ -300,13 +310,13 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
|
||||
delete this->activeConnections.take(priorActiveConnections.takeFirst());
|
||||
|
||||
while (!identifiers.isEmpty()) {
|
||||
// These configurations are not active
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.value(identifiers.takeFirst());
|
||||
|
||||
ptr->mutex.lock();
|
||||
if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
|
||||
ptr->state = QNetworkConfiguration::Discovered;
|
||||
QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
|
||||
ptr->state = (flag | QNetworkConfiguration::Discovered);
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
@ -337,9 +347,9 @@ void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &pat
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
if (ptr) {
|
||||
ptr->mutex.lock();
|
||||
if (activeConnection->state() == 2 &&
|
||||
if (activeConnection->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
|
||||
ptr->state != QNetworkConfiguration::Active) {
|
||||
ptr->state = QNetworkConfiguration::Active;
|
||||
ptr->state |= QNetworkConfiguration::Active;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
@ -351,35 +361,63 @@ void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &pat
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::devicePropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties)
|
||||
void QNetworkManagerEngine::devicePropertiesChanged(const QString &/*path*/,quint32 /*state*/)
|
||||
{
|
||||
Q_UNUSED(path);
|
||||
Q_UNUSED(properties);
|
||||
// Q_UNUSED(path);
|
||||
// Q_UNUSED(state)
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &activeConnectionsList)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
if (activeConnectionsList.contains(connections.at(i)->connectionInterface()->path()))
|
||||
continue;
|
||||
|
||||
const QString settingsPath = connections.at(i)->connectionInterface()->path();
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.value(settingsPath);
|
||||
ptr->mutex.lock();
|
||||
QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
|
||||
ptr->state = (flag | QNetworkConfiguration::Discovered);
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.relock();
|
||||
Q_EMIT updateCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path)
|
||||
{
|
||||
QNetworkManagerInterfaceDevice device(path.path());
|
||||
if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
|
||||
QMutexLocker locker(&mutex);
|
||||
QNetworkManagerInterfaceDevice *iDevice;
|
||||
iDevice = new QNetworkManagerInterfaceDevice(path.path(),this);
|
||||
connect(iDevice,SIGNAL(connectionsChanged(QStringList)),
|
||||
this,SLOT(deviceConnectionsChanged(QStringList)));
|
||||
|
||||
connect(iDevice,SIGNAL(stateChanged(QString,quint32)),
|
||||
this,SLOT(devicePropertiesChanged(QString,quint32)));
|
||||
iDevice->setConnections();
|
||||
interfaceDevices.insert(path.path(),iDevice);
|
||||
|
||||
if (iDevice->deviceType() == DEVICE_TYPE_WIFI) {
|
||||
QNetworkManagerInterfaceDeviceWireless *wirelessDevice =
|
||||
new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path(),this);
|
||||
new QNetworkManagerInterfaceDeviceWireless(iDevice->connectionInterface()->path(),this);
|
||||
|
||||
wirelessDevice->setConnections();
|
||||
connect(wirelessDevice, SIGNAL(accessPointAdded(QString,QDBusObjectPath)),
|
||||
this, SLOT(newAccessPoint(QString,QDBusObjectPath)));
|
||||
connect(wirelessDevice, SIGNAL(accessPointRemoved(QString,QDBusObjectPath)),
|
||||
this, SLOT(removeAccessPoint(QString,QDBusObjectPath)));
|
||||
connect(wirelessDevice, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this, SLOT(devicePropertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
connect(wirelessDevice, SIGNAL(accessPointAdded(QString)),
|
||||
this, SLOT(newAccessPoint(QString)));
|
||||
connect(wirelessDevice, SIGNAL(accessPointRemoved(QString)),
|
||||
this, SLOT(removeAccessPoint(QString)));
|
||||
connect(wirelessDevice,SIGNAL(scanDone()),this,SLOT(scanFinished()));
|
||||
|
||||
foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints()) {
|
||||
newAccessPoint(QString(), apPath);
|
||||
}
|
||||
foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints())
|
||||
newAccessPoint(apPath.path());
|
||||
|
||||
mutex.lock();
|
||||
wirelessDevices.insert(path.path(), wirelessDevice);
|
||||
mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,42 +425,69 @@ void QNetworkManagerEngine::deviceRemoved(const QDBusObjectPath &path)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
delete wirelessDevices.take(path.path());
|
||||
if (interfaceDevices.contains(path.path())) {
|
||||
locker.unlock();
|
||||
delete interfaceDevices.take(path.path());
|
||||
locker.relock();
|
||||
}
|
||||
if (wirelessDevices.contains(path.path())) {
|
||||
locker.unlock();
|
||||
delete wirelessDevices.take(path.path());
|
||||
locker.relock();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
|
||||
QNetworkManagerSettings *settings)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
if (!settings)
|
||||
settings = qobject_cast<QNetworkManagerSettings *>(sender());
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
settings->deleteLater();
|
||||
QNetworkManagerSettingsConnection *connection =
|
||||
new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(),
|
||||
path.path(),this);
|
||||
QString apPath;
|
||||
for (int i = 0; i < accessPoints.count(); ++i) {
|
||||
if (connection->getSsid() == accessPoints.at(i)->ssid()) {
|
||||
// remove the corresponding accesspoint from configurations
|
||||
apPath = accessPoints.at(i)->connectionInterface()->path();
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr
|
||||
= accessPointConfigurations.take(apPath);
|
||||
if (ptr) {
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
locker.relock();
|
||||
}
|
||||
}
|
||||
}
|
||||
connections.append(connection);
|
||||
|
||||
connect(connection, SIGNAL(removed(QString)), this, SLOT(removeConnection(QString)));
|
||||
connect(connection, SIGNAL(updated(QNmSettingsMap)),
|
||||
this, SLOT(updateConnection(QNmSettingsMap)));
|
||||
connect(connection,SIGNAL(removed(QString)),this,SLOT(removeConnection(QString)));
|
||||
connect(connection,SIGNAL(updated()),this,SLOT(updateConnection()));
|
||||
connection->setConnections();
|
||||
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
|
||||
if (connection->getType() == DEVICE_TYPE_WIFI
|
||||
&& !configuredAccessPoints.contains(settingsPath))
|
||||
configuredAccessPoints.insert(apPath,settingsPath);
|
||||
|
||||
QNetworkConfigurationPrivate *cpPriv =
|
||||
parseConnection(service, settingsPath, connection->getSettings());
|
||||
parseConnection(settingsPath, connection->getSettings());
|
||||
|
||||
// Check if connection is active.
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive activeConnection(acPath.path());
|
||||
|
||||
if (activeConnection.defaultRoute() &&
|
||||
activeConnection.connection().path() == settingsPath &&
|
||||
activeConnection.state() == 2) {
|
||||
activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
cpPriv->state |= QNetworkConfiguration::Active;
|
||||
break;
|
||||
}
|
||||
@ -438,26 +503,34 @@ void QNetworkManagerEngine::removeConnection(const QString &path)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
Q_UNUSED(path)
|
||||
|
||||
QNetworkManagerSettingsConnection *connection =
|
||||
qobject_cast<QNetworkManagerSettingsConnection *>(sender());
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
connection->deleteLater();
|
||||
connections.removeAll(connection);
|
||||
|
||||
const QString id = connection->connectionInterface()->path();
|
||||
const QString id = path;
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
|
||||
|
||||
connection->deleteLater();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
if (ptr) {
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
locker.relock();
|
||||
}
|
||||
// add base AP back into configurations
|
||||
QMapIterator<QString, QString> i(configuredAccessPoints);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (i.value() == path) {
|
||||
newAccessPoint(i.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
|
||||
void QNetworkManagerEngine::updateConnection()
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
@ -466,13 +539,13 @@ void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
connection->deleteLater();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
|
||||
QNetworkConfigurationPrivate *cpPriv = parseConnection(service, settingsPath, settings);
|
||||
QNetworkConfigurationPrivate *cpPriv = parseConnection(settingsPath, connection->getSettings());
|
||||
|
||||
// Check if connection is active.
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive activeConnection(acPath.path());
|
||||
|
||||
if (activeConnection.connection().path() == settingsPath &&
|
||||
@ -495,6 +568,7 @@ void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.relock();
|
||||
delete cpPriv;
|
||||
}
|
||||
|
||||
@ -515,9 +589,9 @@ void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher)
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
if (ptr) {
|
||||
ptr->mutex.lock();
|
||||
if (activeConnection.state() == 2 &&
|
||||
if (activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
|
||||
ptr->state != QNetworkConfiguration::Active) {
|
||||
ptr->state = QNetworkConfiguration::Active;
|
||||
ptr->state |= QNetworkConfiguration::Active;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
@ -530,42 +604,41 @@ void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher)
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjectPath &objectPath)
|
||||
void QNetworkManagerEngine::newAccessPoint(const QString &path)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
Q_UNUSED(path)
|
||||
|
||||
QNetworkManagerInterfaceAccessPoint *accessPoint =
|
||||
new QNetworkManagerInterfaceAccessPoint(objectPath.path(),this);
|
||||
accessPoints.append(accessPoint);
|
||||
new QNetworkManagerInterfaceAccessPoint(path,this);
|
||||
|
||||
accessPoint->setConnections();
|
||||
connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
|
||||
this, SLOT(updateAccessPoint(QMap<QString,QVariant>)));
|
||||
|
||||
// Check if configuration for this SSID already exists.
|
||||
bool okToAdd = true;
|
||||
for (int i = 0; i < accessPoints.count(); ++i) {
|
||||
if (accessPoint != accessPoints.at(i) &&
|
||||
accessPoint->ssid() == accessPoints.at(i)->ssid()) {
|
||||
return;
|
||||
if (accessPoints.at(i)->connectionInterface()->path() == path) {
|
||||
okToAdd = false;
|
||||
}
|
||||
}
|
||||
if (okToAdd) {
|
||||
accessPoints.append(accessPoint);
|
||||
accessPoint->setConnections();
|
||||
connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
|
||||
this, SLOT(updateAccessPoint(QMap<QString,QVariant>)));
|
||||
}
|
||||
|
||||
// Check if configuration exists for connection.
|
||||
if (!accessPoint->ssid().isEmpty()) {
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
QNetworkManagerSettingsConnection *connection = connections.at(i);
|
||||
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
if (accessPoint->ssid() == connection->getSsid()) {
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
const QString connectionId = settingsPath;
|
||||
if (!configuredAccessPoints.contains(path)) {
|
||||
configuredAccessPoints.insert(path,settingsPath);
|
||||
}
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.value(connectionId);
|
||||
accessPointConfigurations.value(settingsPath);
|
||||
ptr->mutex.lock();
|
||||
ptr->state = QNetworkConfiguration::Discovered;
|
||||
QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
|
||||
ptr->state = (flag | QNetworkConfiguration::Discovered);
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
@ -580,7 +653,7 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjec
|
||||
|
||||
ptr->name = accessPoint->ssid();
|
||||
ptr->isValid = true;
|
||||
ptr->id = objectPath.path();
|
||||
ptr->id = path;
|
||||
ptr->type = QNetworkConfiguration::InternetAccessPoint;
|
||||
if (accessPoint->flags() == NM_802_11_AP_FLAGS_PRIVACY) {
|
||||
ptr->purpose = QNetworkConfiguration::PrivatePurpose;
|
||||
@ -596,17 +669,13 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjec
|
||||
emit configurationAdded(ptr);
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::removeAccessPoint(const QString &path,
|
||||
const QDBusObjectPath &objectPath)
|
||||
void QNetworkManagerEngine::removeAccessPoint(const QString &path)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
Q_UNUSED(path)
|
||||
|
||||
for (int i = 0; i < accessPoints.count(); ++i) {
|
||||
QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
|
||||
|
||||
if (accessPoint->connectionInterface()->path() == objectPath.path()) {
|
||||
if (accessPoint->connectionInterface()->path() == path) {
|
||||
accessPoints.removeOne(accessPoint);
|
||||
|
||||
if (configuredAccessPoints.contains(accessPoint->connectionInterface()->path())) {
|
||||
@ -615,8 +684,7 @@ void QNetworkManagerEngine::removeAccessPoint(const QString &path,
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
QNetworkManagerSettingsConnection *connection = connections.at(i);
|
||||
|
||||
if (accessPoint->ssid() == connection->getSsid()) {
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
if (accessPoint->ssid() == connection->getSsid()) {//might not have bssid yet
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
const QString connectionId = settingsPath;
|
||||
|
||||
@ -634,17 +702,17 @@ void QNetworkManagerEngine::removeAccessPoint(const QString &path,
|
||||
}
|
||||
} else {
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.take(objectPath.path());
|
||||
accessPointConfigurations.take(path);
|
||||
|
||||
if (ptr) {
|
||||
locker.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
locker.relock();
|
||||
}
|
||||
}
|
||||
|
||||
delete accessPoint;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -660,19 +728,19 @@ void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map
|
||||
qobject_cast<QNetworkManagerInterfaceAccessPoint *>(sender());
|
||||
if (!accessPoint)
|
||||
return;
|
||||
|
||||
accessPoint->deleteLater();
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
QNetworkManagerSettingsConnection *connection = connections.at(i);
|
||||
|
||||
if (accessPoint->ssid() == connection->getSsid()) {
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
const QString connectionId = settingsPath;
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.value(connectionId);
|
||||
ptr->mutex.lock();
|
||||
ptr->state = QNetworkConfiguration::Discovered;
|
||||
QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
|
||||
ptr->state = (flag | QNetworkConfiguration::Discovered);
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
@ -682,11 +750,11 @@ void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map
|
||||
}
|
||||
}
|
||||
|
||||
QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &service,
|
||||
const QString &settingsPath,
|
||||
QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &settingsPath,
|
||||
const QNmSettingsMap &map)
|
||||
{
|
||||
Q_UNUSED(service);
|
||||
// Q_UNUSED(service);
|
||||
QMutexLocker locker(&mutex);
|
||||
QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
|
||||
cpPriv->name = map.value("connection").value("id").toString();
|
||||
|
||||
@ -704,15 +772,14 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
|
||||
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
|
||||
|
||||
foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
|
||||
foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
|
||||
QNetworkManagerInterfaceDevice device(devicePath.path());
|
||||
if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
|
||||
if (device.deviceType() == DEVICE_TYPE_ETHERNET) {
|
||||
QNetworkManagerInterfaceDeviceWired wiredDevice(device.connectionInterface()->path());
|
||||
if (wiredDevice.carrier()) {
|
||||
cpPriv->state |= QNetworkConfiguration::Discovered;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else if (connectionType == QLatin1String("802-11-wireless")) {
|
||||
@ -737,9 +804,9 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
|
||||
accessPointConfigurations.take(accessPointId);
|
||||
|
||||
if (ptr) {
|
||||
mutex.unlock();
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
mutex.lock();
|
||||
locker.relock();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -747,10 +814,10 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
|
||||
}
|
||||
} else if (connectionType == QLatin1String("gsm")) {
|
||||
|
||||
foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
|
||||
foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
|
||||
QNetworkManagerInterfaceDevice device(devicePath.path());
|
||||
|
||||
if (device.deviceType() == DEVICE_TYPE_GSM) {
|
||||
if (device.deviceType() == DEVICE_TYPE_MODEM) {
|
||||
QNetworkManagerInterfaceDeviceModem deviceModem(device.connectionInterface()->path(),this);
|
||||
switch (deviceModem.currentCapabilities()) {
|
||||
case 2:
|
||||
@ -771,9 +838,6 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
|
||||
|
||||
cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
|
||||
cpPriv->state |= QNetworkConfiguration::Discovered;
|
||||
} else if (connectionType == QLatin1String("cdma")) {
|
||||
cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000;
|
||||
}
|
||||
|
||||
return cpPriv;
|
||||
@ -783,12 +847,7 @@ QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const
|
||||
{
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
QNetworkManagerSettingsConnection *connection = connections.at(i);
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
|
||||
const QString identifier = settingsPath;
|
||||
|
||||
if (id == identifier)
|
||||
if (id == connection->connectionInterface()->path())
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
@ -93,35 +93,35 @@ private Q_SLOTS:
|
||||
const QMap<QString, QVariant> &properties);
|
||||
void activeConnectionPropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties);
|
||||
void devicePropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties);
|
||||
void devicePropertiesChanged(const QString &path, quint32);
|
||||
|
||||
void deviceAdded(const QDBusObjectPath &path);
|
||||
void deviceRemoved(const QDBusObjectPath &path);
|
||||
|
||||
void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0);
|
||||
void removeConnection(const QString &path);
|
||||
void updateConnection(const QNmSettingsMap &settings);
|
||||
void updateConnection();
|
||||
void activationFinished(QDBusPendingCallWatcher *watcher);
|
||||
void deviceConnectionsChanged(const QStringList &activeConnectionsList);
|
||||
|
||||
void newAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
|
||||
void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
|
||||
void newAccessPoint(const QString &path);
|
||||
void removeAccessPoint(const QString &path);
|
||||
void updateAccessPoint(const QMap<QString, QVariant> &map);
|
||||
void scanFinished();
|
||||
|
||||
private:
|
||||
QNetworkConfigurationPrivate *parseConnection(const QString &service,
|
||||
const QString &settingsPath,
|
||||
QNetworkConfigurationPrivate *parseConnection(const QString &settingsPath,
|
||||
const QNmSettingsMap &map);
|
||||
QNetworkManagerSettingsConnection *connectionFromId(const QString &id) const;
|
||||
|
||||
private:
|
||||
QNetworkManagerInterface *interface;
|
||||
QNetworkManagerInterface *managerInterface;
|
||||
QNetworkManagerSettings *systemSettings;
|
||||
QNetworkManagerSettings *userSettings;
|
||||
QHash<QString, QNetworkManagerInterfaceDeviceWireless *> wirelessDevices;
|
||||
QHash<QString, QNetworkManagerConnectionActive *> activeConnections;
|
||||
QList<QNetworkManagerSettingsConnection *> connections;
|
||||
QList<QNetworkManagerInterfaceAccessPoint *> accessPoints;
|
||||
QHash<QString, QNetworkManagerInterfaceDevice *> interfaceDevices;
|
||||
|
||||
QMap<QString,QString> configuredAccessPoints; //ap, settings path
|
||||
};
|
||||
|
@ -322,18 +322,31 @@ bool QNetworkManagerInterfaceDevice::setConnections()
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
bool allOk = true;
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)),
|
||||
this, SIGNAL(stateChanged(QString,quint32)));
|
||||
|
||||
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE),
|
||||
QLatin1String("StateChanged"),
|
||||
nmDBusHelper,SLOT(deviceStateChanged(quint32)))) {
|
||||
allOk = true;
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
connect(nmDBusHelper, SIGNAL(pathForConnectionsChanged(QStringList)),
|
||||
this,SIGNAL(connectionsChanged(QStringList)));
|
||||
|
||||
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
@ -414,18 +427,18 @@ bool QNetworkManagerInterfaceDeviceWired::setConnections()
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
bool allOk = true;
|
||||
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
if (!QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
|
||||
allOk = true;
|
||||
allOk = false;
|
||||
}
|
||||
return allOk;
|
||||
}
|
||||
@ -491,44 +504,50 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
|
||||
return false;
|
||||
|
||||
QDBusConnection dbusConnection = QDBusConnection::systemBus();
|
||||
bool allOk = false;
|
||||
bool allOk = true;
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
|
||||
connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(QString,QDBusObjectPath)),
|
||||
this,SIGNAL(accessPointAdded(QString,QDBusObjectPath)));
|
||||
connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(QString)),
|
||||
this,SIGNAL(accessPointAdded(QString)));
|
||||
|
||||
connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(QString,QDBusObjectPath)),
|
||||
this,SIGNAL(accessPointRemoved(QString,QDBusObjectPath)));
|
||||
connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(QString)),
|
||||
this,SIGNAL(accessPointRemoved(QString)));
|
||||
|
||||
if (dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
|
||||
QLatin1String("AccessPointAdded"),
|
||||
nmDBusHelper, SLOT(slotAccessPointAdded(QDBusObjectPath)))) {
|
||||
allOk = true;
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
|
||||
if (dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
|
||||
QLatin1String("AccessPointRemoved"),
|
||||
nmDBusHelper, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) {
|
||||
allOk = true;
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
|
||||
if (dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) {
|
||||
allOk = true;
|
||||
allOk = false;
|
||||
}
|
||||
if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
|
||||
QLatin1String("ScanDone"),
|
||||
this, SLOT(scanIsDone()))) {
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
@ -568,6 +587,17 @@ quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const
|
||||
return d->connectionInterface->property("WirelelessCapabilities").toUInt();
|
||||
}
|
||||
|
||||
void QNetworkManagerInterfaceDeviceWireless::scanIsDone()
|
||||
{
|
||||
Q_EMIT scanDone();
|
||||
}
|
||||
|
||||
void QNetworkManagerInterfaceDeviceWireless::requestScan()
|
||||
{
|
||||
d->connectionInterface->asyncCall(QLatin1String("RequestScan"));
|
||||
}
|
||||
|
||||
|
||||
class QNetworkManagerInterfaceDeviceModemPrivate
|
||||
{
|
||||
public:
|
||||
@ -609,18 +639,18 @@ bool QNetworkManagerInterfaceDeviceModem::setConnections()
|
||||
if (!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
bool allOk = true;
|
||||
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
if (!QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotDevicePropertiesChanged(QMap<QString,QVariant>))) ) {
|
||||
allOk = true;
|
||||
allOk = false;
|
||||
}
|
||||
return allOk;
|
||||
}
|
||||
@ -640,9 +670,6 @@ quint32 QNetworkManagerInterfaceDeviceModem::currentCapabilities() const
|
||||
return d->connectionInterface->property("CurrentCapabilities").toUInt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class QNetworkManagerSettingsPrivate
|
||||
{
|
||||
public:
|
||||
@ -680,12 +707,14 @@ bool QNetworkManagerSettings::isValid()
|
||||
|
||||
bool QNetworkManagerSettings::setConnections()
|
||||
{
|
||||
bool allOk = false;
|
||||
bool allOk = true;
|
||||
|
||||
if (QDBusConnection::systemBus().connect(d->path, QLatin1String(NM_DBUS_PATH_SETTINGS),
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"),
|
||||
this, SIGNAL(newConnection(QDBusObjectPath)))) {
|
||||
allOk = true;
|
||||
if (!QDBusConnection::systemBus().connect(d->path,
|
||||
QLatin1String(NM_DBUS_PATH_SETTINGS),
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS),
|
||||
QLatin1String("NewConnection"),
|
||||
this, SIGNAL(newConnection(QDBusObjectPath)))) {
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
@ -697,6 +726,14 @@ QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QString QNetworkManagerSettings::getConnectionByUuid(const QString &uuid)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(uuid);
|
||||
QDBusReply<QDBusObjectPath > reply = d->connectionInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList);
|
||||
return reply.value().path();
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerSettings::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
@ -750,13 +787,13 @@ bool QNetworkManagerSettingsConnection::setConnections()
|
||||
return false;
|
||||
|
||||
QDBusConnection dbusConnection = QDBusConnection::systemBus();
|
||||
bool allOk = false;
|
||||
if (dbusConnection.connect(d->service, d->path,
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"),
|
||||
this, SIGNAL(updated(QNmSettingsMap)))) {
|
||||
allOk = true;
|
||||
} else {
|
||||
QDBusError error = dbusConnection.lastError();
|
||||
bool allOk = true;
|
||||
if (!dbusConnection.connect(d->service,
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
|
||||
QLatin1String("Updated"),
|
||||
this, SIGNAL(updated()))) {
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
delete nmDBusHelper;
|
||||
@ -764,12 +801,13 @@ bool QNetworkManagerSettingsConnection::setConnections()
|
||||
connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(QString)),
|
||||
this,SIGNAL(removed(QString)));
|
||||
|
||||
if (dbusConnection.connect(d->service, d->path,
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"),
|
||||
nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
|
||||
allOk = true;
|
||||
if (!dbusConnection.connect(d->service,
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
|
||||
QLatin1String("Removed"),
|
||||
nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
@ -791,9 +829,9 @@ NMDeviceType QNetworkManagerSettingsConnection::getType()
|
||||
d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
|
||||
|
||||
if (devType == QLatin1String("802-3-ethernet"))
|
||||
return DEVICE_TYPE_802_3_ETHERNET;
|
||||
return DEVICE_TYPE_ETHERNET;
|
||||
else if (devType == QLatin1String("802-11-wireless"))
|
||||
return DEVICE_TYPE_802_11_WIRELESS;
|
||||
return DEVICE_TYPE_WIFI;
|
||||
else
|
||||
return DEVICE_TYPE_UNKNOWN;
|
||||
}
|
||||
@ -840,10 +878,10 @@ QString QNetworkManagerSettingsConnection::getMacAddress()
|
||||
{
|
||||
NMDeviceType type = getType();
|
||||
|
||||
if (type == DEVICE_TYPE_802_3_ETHERNET) {
|
||||
if (type == DEVICE_TYPE_ETHERNET) {
|
||||
return d->settingsMap.value(QLatin1String("802-3-ethernet"))
|
||||
.value(QLatin1String("mac-address")).toString();
|
||||
} else if (type == DEVICE_TYPE_802_11_WIRELESS) {
|
||||
} else if (type == DEVICE_TYPE_WIFI) {
|
||||
return d->settingsMap.value(QLatin1String("802-11-wireless"))
|
||||
.value(QLatin1String("mac-address")).toString();
|
||||
} else {
|
||||
@ -853,7 +891,7 @@ QString QNetworkManagerSettingsConnection::getMacAddress()
|
||||
|
||||
QStringList QNetworkManagerSettingsConnection::getSeenBssids()
|
||||
{
|
||||
if (getType() == DEVICE_TYPE_802_11_WIRELESS) {
|
||||
if (getType() == DEVICE_TYPE_WIFI) {
|
||||
return d->settingsMap.value(QLatin1String("802-11-wireless"))
|
||||
.value(QLatin1String("seen-bssids")).toStringList();
|
||||
} else {
|
||||
@ -901,17 +939,18 @@ bool QNetworkManagerConnectionActive::setConnections()
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
bool allOk = true;
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
|
||||
if (!QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
|
||||
allOk = true;
|
||||
nmDBusHelper,SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>))) ) {
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
|
@ -64,31 +64,32 @@
|
||||
typedef enum NMDeviceType
|
||||
{
|
||||
DEVICE_TYPE_UNKNOWN = 0,
|
||||
DEVICE_TYPE_802_3_ETHERNET,
|
||||
DEVICE_TYPE_802_11_WIRELESS,
|
||||
DEVICE_TYPE_GSM,
|
||||
DEVICE_TYPE_CDMA
|
||||
DEVICE_TYPE_ETHERNET,
|
||||
DEVICE_TYPE_WIFI,
|
||||
DEVICE_TYPE_MODEM = 8
|
||||
} NMDeviceType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NM_DEVICE_STATE_UNKNOWN = 0,
|
||||
NM_DEVICE_STATE_UNMANAGED,
|
||||
NM_DEVICE_STATE_UNAVAILABLE,
|
||||
NM_DEVICE_STATE_DISCONNECTED,
|
||||
NM_DEVICE_STATE_PREPARE,
|
||||
NM_DEVICE_STATE_CONFIG,
|
||||
NM_DEVICE_STATE_NEED_AUTH,
|
||||
NM_DEVICE_STATE_IP_CONFIG,
|
||||
NM_DEVICE_STATE_ACTIVATED,
|
||||
NM_DEVICE_STATE_FAILED
|
||||
NM_DEVICE_STATE_UNMANAGED = 10,
|
||||
NM_DEVICE_STATE_UNAVAILABLE = 20,
|
||||
NM_DEVICE_STATE_DISCONNECTED = 30,
|
||||
NM_DEVICE_STATE_PREPARE = 40,
|
||||
NM_DEVICE_STATE_CONFIG = 50,
|
||||
NM_DEVICE_STATE_NEED_AUTH = 60,
|
||||
NM_DEVICE_STATE_IP_CONFIG = 70,
|
||||
NM_DEVICE_STATE_ACTIVATED = 100,
|
||||
NM_DEVICE_STATE_DEACTIVATING = 110,
|
||||
NM_DEVICE_STATE_FAILED = 120
|
||||
} NMDeviceState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
|
||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
|
||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|
||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
|
||||
NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
|
||||
} NMActiveConnectionState;
|
||||
|
||||
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
|
||||
@ -257,7 +258,8 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void stateChanged(const QString &, quint32);
|
||||
|
||||
void propertiesChanged(const QString &, QMap<QString,QVariant>);
|
||||
void connectionsChanged(QStringList);
|
||||
private:
|
||||
QNetworkManagerInterfaceDevicePrivate *d;
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
@ -321,10 +323,14 @@ public:
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
void requestScan();
|
||||
Q_SIGNALS:
|
||||
void propertiesChanged( const QString &, QMap<QString,QVariant>);
|
||||
void accessPointAdded(const QString &,QDBusObjectPath);
|
||||
void accessPointRemoved(const QString &,QDBusObjectPath);
|
||||
void accessPointAdded(const QString &);
|
||||
void accessPointRemoved(const QString &);
|
||||
void scanDone();
|
||||
private Q_SLOTS:
|
||||
void scanIsDone();
|
||||
private:
|
||||
QNetworkManagerInterfaceDeviceWirelessPrivate *d;
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
@ -378,6 +384,7 @@ public:
|
||||
|
||||
QDBusInterface *connectionInterface() const;
|
||||
QList <QDBusObjectPath> listConnections();
|
||||
QString getConnectionByUuid(const QString &uuid);
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
@ -412,7 +419,7 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
void updated(const QNmSettingsMap &settings);
|
||||
void updated();
|
||||
void removed(const QString &path);
|
||||
|
||||
private:
|
||||
|
@ -60,7 +60,7 @@ QNmDBusHelper::~QNmDBusHelper()
|
||||
void QNmDBusHelper::deviceStateChanged(quint32 state)
|
||||
{
|
||||
QDBusMessage msg = this->message();
|
||||
if(state == NM_DEVICE_STATE_ACTIVATED
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED
|
||||
|| state == NM_DEVICE_STATE_DISCONNECTED
|
||||
|| state == NM_DEVICE_STATE_UNAVAILABLE
|
||||
|| state == NM_DEVICE_STATE_FAILED) {
|
||||
@ -70,18 +70,14 @@ void QNmDBusHelper::deviceStateChanged(quint32 state)
|
||||
|
||||
void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path)
|
||||
{
|
||||
if(path.path().length() > 2) {
|
||||
QDBusMessage msg = this->message();
|
||||
emit pathForAccessPointAdded(msg.path(), path);
|
||||
}
|
||||
if (path.path().length() > 2)
|
||||
emit pathForAccessPointAdded(path.path());
|
||||
}
|
||||
|
||||
void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path)
|
||||
{
|
||||
if(path.path().length() > 2) {
|
||||
QDBusMessage msg = this->message();
|
||||
emit pathForAccessPointRemoved(msg.path(), path);
|
||||
}
|
||||
if (path.path().length() > 2)
|
||||
emit pathForAccessPointRemoved(path.path());
|
||||
}
|
||||
|
||||
void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
|
||||
@ -90,23 +86,29 @@ void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
|
||||
QMapIterator<QString, QVariant> i(map);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if( i.key() == "State") { //state only applies to device interfaces
|
||||
if (i.key() == QStringLiteral("State")) {
|
||||
quint32 state = i.value().toUInt();
|
||||
if( state == NM_DEVICE_STATE_ACTIVATED
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED
|
||||
|| state == NM_DEVICE_STATE_DISCONNECTED
|
||||
|| state == NM_DEVICE_STATE_UNAVAILABLE
|
||||
|| state == NM_DEVICE_STATE_FAILED) {
|
||||
emit pathForPropertiesChanged( msg.path(), map);
|
||||
emit pathForPropertiesChanged(msg.path(), map);
|
||||
}
|
||||
} else if( i.key() == "ActiveAccessPoint") {
|
||||
} else if (i.key() == QStringLiteral("ActiveAccessPoint")) {
|
||||
emit pathForPropertiesChanged(msg.path(), map);
|
||||
// qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path();
|
||||
// } else if( i.key() == "Strength")
|
||||
// qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt();
|
||||
// else
|
||||
// qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value();
|
||||
} else if (i.key() == "ActiveConnections") {
|
||||
} else if (i.key() == QStringLiteral("ActiveConnections")) {
|
||||
emit pathForPropertiesChanged(msg.path(), map);
|
||||
} else if (i.key() == QStringLiteral("AvailableConnections")) {
|
||||
const QDBusArgument &dbusArgs = i.value().value<QDBusArgument>();
|
||||
QDBusObjectPath path;
|
||||
QStringList paths;
|
||||
dbusArgs.beginArray();
|
||||
while (!dbusArgs.atEnd()) {
|
||||
dbusArgs >> path;
|
||||
paths << path.path();
|
||||
}
|
||||
dbusArgs.endArray();
|
||||
emit pathForConnectionsChanged(paths);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,6 +119,22 @@ void QNmDBusHelper::slotSettingsRemoved()
|
||||
emit pathForSettingsRemoved(msg.path());
|
||||
}
|
||||
|
||||
void QNmDBusHelper::activeConnectionPropertiesChanged(QMap<QString,QVariant> map)
|
||||
{
|
||||
QDBusMessage msg = this->message();
|
||||
QMapIterator<QString, QVariant> i(map);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (i.key() == QStringLiteral("State")) {
|
||||
quint32 state = i.value().toUInt();
|
||||
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|
||||
|| state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
|
||||
emit pathForPropertiesChanged(msg.path(), map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
|
@ -51,17 +51,19 @@ class QNmDBusHelper: public QObject, protected QDBusContext
|
||||
|
||||
public slots:
|
||||
void deviceStateChanged(quint32);
|
||||
void slotAccessPointAdded( QDBusObjectPath );
|
||||
void slotAccessPointRemoved( QDBusObjectPath );
|
||||
void slotPropertiesChanged( QMap<QString,QVariant>);
|
||||
void slotAccessPointAdded(QDBusObjectPath);
|
||||
void slotAccessPointRemoved(QDBusObjectPath);
|
||||
void slotPropertiesChanged(QMap<QString,QVariant>);
|
||||
void slotSettingsRemoved();
|
||||
void activeConnectionPropertiesChanged(QMap<QString,QVariant>);
|
||||
|
||||
Q_SIGNALS:
|
||||
void pathForStateChanged(const QString &, quint32);
|
||||
void pathForAccessPointAdded(const QString &, QDBusObjectPath );
|
||||
void pathForAccessPointRemoved(const QString &, QDBusObjectPath );
|
||||
void pathForAccessPointAdded(const QString &);
|
||||
void pathForAccessPointRemoved(const QString &);
|
||||
void pathForPropertiesChanged(const QString &, QMap<QString,QVariant>);
|
||||
void pathForSettingsRemoved(const QString &);
|
||||
void pathForConnectionsChanged(const QStringList &pathsList);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user