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