| | 1 | From 1df2cd6af5c40db588fc3ec40c7adfafc1b5eea3 Mon Sep 17 00:00:00 2001 |
| | 2 | From: Lorn Potter <lorn.potter@gmail.com> |
| | 3 | Date: Wed, 29 Oct 2014 19:40:43 +1000 |
| | 4 | Subject: [PATCH] Use a property cache to cut down on blocking calls |
| | 5 | |
| | 6 | Refactor old code |
| | 7 | Stop memory leaks |
| | 8 | Properly support mobile data (ofono) |
| | 9 | |
| | 10 | Change-Id: I7f23882ee0ee345a049a4a93ddd452b6d2e53710 |
| | 11 | --- |
| | 12 | src/plugins/bearer/connman/connman.pro | 4 +- |
| | 13 | src/plugins/bearer/connman/qconnmanengine.h | 2 +- |
| | 14 | src/plugins/bearer/connman/qofonoservice_linux.cpp | 303 --------- |
| | 15 | src/plugins/bearer/connman/qofonoservice_linux_p.h | 172 ----- |
| | 16 | .../bearer/linux_common/qofonoservice_linux.cpp | 370 +++++++++++ |
| | 17 | .../bearer/linux_common/qofonoservice_linux_p.h | 195 ++++++ |
| | 18 | .../bearer/networkmanager/networkmanager.pro | 6 +- |
| | 19 | .../networkmanager/qnetworkmanagerengine.cpp | 364 +++++------ |
| | 20 | .../bearer/networkmanager/qnetworkmanagerengine.h | 22 +- |
| | 21 | .../networkmanager/qnetworkmanagerservice.cpp | 693 +++++++++++++++------ |
| | 22 | .../bearer/networkmanager/qnetworkmanagerservice.h | 105 +++- |
| | 23 | .../bearer/networkmanager/qnmdbushelper.cpp | 140 ----- |
| | 24 | src/plugins/bearer/networkmanager/qnmdbushelper.h | 73 --- |
| | 25 | 13 files changed, 1318 insertions(+), 1131 deletions(-) |
| | 26 | delete mode 100644 src/plugins/bearer/connman/qofonoservice_linux.cpp |
| | 27 | delete mode 100644 src/plugins/bearer/connman/qofonoservice_linux_p.h |
| | 28 | create mode 100644 src/plugins/bearer/linux_common/qofonoservice_linux.cpp |
| | 29 | create mode 100644 src/plugins/bearer/linux_common/qofonoservice_linux_p.h |
| | 30 | delete mode 100644 src/plugins/bearer/networkmanager/qnmdbushelper.cpp |
| | 31 | delete mode 100644 src/plugins/bearer/networkmanager/qnmdbushelper.h |
| | 32 | |
| | 33 | --- qtbase/src/plugins/bearer/connman/connman.pro |
| | 34 | +++ qtbase/src/plugins/bearer/connman/connman.pro |
| | 35 | @@ -8,14 +8,14 @@ |
| | 36 | CONFIG += link_pkgconfig |
| | 37 | |
| | 38 | HEADERS += qconnmanservice_linux_p.h \ |
| | 39 | - qofonoservice_linux_p.h \ |
| | 40 | + ../linux_common/qofonoservice_linux_p.h \ |
| | 41 | qconnmanengine.h \ |
| | 42 | ../qnetworksession_impl.h \ |
| | 43 | ../qbearerengine_impl.h |
| | 44 | |
| | 45 | SOURCES += main.cpp \ |
| | 46 | qconnmanservice_linux.cpp \ |
| | 47 | - qofonoservice_linux.cpp \ |
| | 48 | + ../linux_common/qofonoservice_linux.cpp \ |
| | 49 | qconnmanengine.cpp \ |
| | 50 | ../qnetworksession_impl.cpp |
| | 51 | |
| | 52 | --- qtbase/src/plugins/bearer/connman/qconnmanengine.h |
| | 53 | +++ qtbase/src/plugins/bearer/connman/qconnmanengine.h |
| | 54 | @@ -56,7 +56,7 @@ |
| | 55 | #include "../qbearerengine_impl.h" |
| | 56 | |
| | 57 | #include "qconnmanservice_linux_p.h" |
| | 58 | -#include "qofonoservice_linux_p.h" |
| | 59 | +#include "../linux_common/qofonoservice_linux_p.h" |
| | 60 | |
| | 61 | #include <QMap> |
| | 62 | #include <QVariant> |
| | 63 | --- /dev/null |
| | 64 | +++ qtbase/src/plugins/bearer/linux_common/qofonoservice_linux.cpp |
| | 65 | @@ -0,0 +1,370 @@ |
| | 66 | +/**************************************************************************** |
| | 67 | +** |
| | 68 | +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
| | 69 | +** Contact: http://www.qt-project.org/legal |
| | 70 | +** |
| | 71 | +** This file is part of the plugins of the Qt Toolkit. |
| | 72 | +** |
| | 73 | +** $QT_BEGIN_LICENSE:LGPL21$ |
| | 74 | +** Commercial License Usage |
| | 75 | +** Licensees holding valid commercial Qt licenses may use this file in |
| | 76 | +** accordance with the commercial license agreement provided with the |
| | 77 | +** Software or, alternatively, in accordance with the terms contained in |
| | 78 | +** a written agreement between you and Digia. For licensing terms and |
| | 79 | +** conditions see http://qt.digia.com/licensing. For further information |
| | 80 | +** use the contact form at http://qt.digia.com/contact-us. |
| | 81 | +** |
| | 82 | +** GNU Lesser General Public License Usage |
| | 83 | +** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 84 | +** General Public License version 2.1 or version 3 as published by the Free |
| | 85 | +** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| | 86 | +** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| | 87 | +** following information to ensure the GNU Lesser General Public License |
| | 88 | +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| | 89 | +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 90 | +** |
| | 91 | +** In addition, as a special exception, Digia gives you certain additional |
| | 92 | +** rights. These rights are described in the Digia Qt LGPL Exception |
| | 93 | +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 94 | +** |
| | 95 | +** $QT_END_LICENSE$ |
| | 96 | +** |
| | 97 | +****************************************************************************/ |
| | 98 | + |
| | 99 | +#include <QObject> |
| | 100 | +#include <QList> |
| | 101 | +#include <QtDBus/QtDBus> |
| | 102 | +#include <QtDBus/QDBusConnection> |
| | 103 | +#include <QtDBus/QDBusError> |
| | 104 | +#include <QtDBus/QDBusInterface> |
| | 105 | +#include <QtDBus/QDBusMessage> |
| | 106 | +#include <QtDBus/QDBusReply> |
| | 107 | +#include <QtDBus/QDBusPendingCallWatcher> |
| | 108 | +#include <QtDBus/QDBusObjectPath> |
| | 109 | +#include <QtDBus/QDBusPendingCall> |
| | 110 | + |
| | 111 | +#include "qofonoservice_linux_p.h" |
| | 112 | + |
| | 113 | +#ifndef QT_NO_BEARERMANAGEMENT |
| | 114 | +#ifndef QT_NO_DBUS |
| | 115 | + |
| | 116 | +QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &item) |
| | 117 | +{ |
| | 118 | + argument.beginStructure(); |
| | 119 | + argument << item.path << item.properties; |
| | 120 | + argument.endStructure(); |
| | 121 | + return argument; |
| | 122 | +} |
| | 123 | + |
| | 124 | +const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathProperties &item) |
| | 125 | +{ |
| | 126 | + argument.beginStructure(); |
| | 127 | + argument >> item.path >> item.properties; |
| | 128 | + argument.endStructure(); |
| | 129 | + return argument; |
| | 130 | +} |
| | 131 | + |
| | 132 | +QT_BEGIN_NAMESPACE |
| | 133 | + |
| | 134 | +QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent) |
| | 135 | + : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), |
| | 136 | + QStringLiteral(OFONO_MANAGER_PATH), |
| | 137 | + OFONO_MANAGER_INTERFACE, |
| | 138 | + QDBusConnection::systemBus(), parent) |
| | 139 | +{ |
| | 140 | + qDBusRegisterMetaType<ObjectPathProperties>(); |
| | 141 | + qDBusRegisterMetaType<PathPropertiesList>(); |
| | 142 | + |
| | 143 | + QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), |
| | 144 | + QStringLiteral(OFONO_MANAGER_PATH), |
| | 145 | + QStringLiteral(OFONO_MANAGER_INTERFACE), |
| | 146 | + QStringLiteral("ModemAdded"), |
| | 147 | + this,SLOT(modemAdded(QDBusObjectPath, QVariantMap))); |
| | 148 | + QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), |
| | 149 | + QStringLiteral(OFONO_MANAGER_PATH), |
| | 150 | + QStringLiteral(OFONO_MANAGER_INTERFACE), |
| | 151 | + QStringLiteral("ModemRemoved"), |
| | 152 | + this,SLOT(modemRemoved(QDBusObjectPath))); |
| | 153 | +} |
| | 154 | + |
| | 155 | +QOfonoManagerInterface::~QOfonoManagerInterface() |
| | 156 | +{ |
| | 157 | +} |
| | 158 | + |
| | 159 | +QStringList QOfonoManagerInterface::getModems() |
| | 160 | +{ |
| | 161 | + if (modemList.isEmpty()) { |
| | 162 | + QList<QVariant> argumentList; |
| | 163 | + QDBusPendingReply<PathPropertiesList> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetModems"), argumentList); |
| | 164 | + reply.waitForFinished(); |
| | 165 | + if (!reply.isError()) { |
| | 166 | + foreach (ObjectPathProperties modem, reply.value()) { |
| | 167 | + modemList << modem.path.path(); |
| | 168 | + } |
| | 169 | + } |
| | 170 | + } |
| | 171 | + |
| | 172 | + return modemList; |
| | 173 | +} |
| | 174 | + |
| | 175 | +QString QOfonoManagerInterface::currentModem() |
| | 176 | +{ |
| | 177 | + QStringList modems = getModems(); |
| | 178 | + foreach (const QString &modem, modems) { |
| | 179 | + QOfonoModemInterface device(modem); |
| | 180 | + if (device.isPowered() && device.isOnline()) |
| | 181 | + return modem; |
| | 182 | + } |
| | 183 | + return QString(); |
| | 184 | +} |
| | 185 | + |
| | 186 | +void QOfonoManagerInterface::modemAdded(const QDBusObjectPath &path, const QVariantMap &/*var*/) |
| | 187 | +{ |
| | 188 | + if (!modemList.contains(path.path())) { |
| | 189 | + modemList << path.path(); |
| | 190 | + Q_EMIT modemChanged(); |
| | 191 | + } |
| | 192 | +} |
| | 193 | + |
| | 194 | +void QOfonoManagerInterface::modemRemoved(const QDBusObjectPath &path) |
| | 195 | +{ |
| | 196 | + if (modemList.contains(path.path())) { |
| | 197 | + modemList.removeOne(path.path()); |
| | 198 | + Q_EMIT modemChanged(); |
| | 199 | + } |
| | 200 | +} |
| | 201 | + |
| | 202 | + |
| | 203 | +QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent) |
| | 204 | + : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), |
| | 205 | + dbusPathName, |
| | 206 | + OFONO_MODEM_INTERFACE, |
| | 207 | + QDBusConnection::systemBus(), parent) |
| | 208 | +{ |
| | 209 | + QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), |
| | 210 | + path(), |
| | 211 | + OFONO_MODEM_INTERFACE, |
| | 212 | + QStringLiteral("PropertyChanged"), |
| | 213 | + this,SLOT(propertyChanged(QString,QDBusVariant))); |
| | 214 | +} |
| | 215 | + |
| | 216 | +QOfonoModemInterface::~QOfonoModemInterface() |
| | 217 | +{ |
| | 218 | +} |
| | 219 | + |
| | 220 | +void QOfonoModemInterface::propertyChanged(const QString &name,const QDBusVariant &value) |
| | 221 | +{ |
| | 222 | + propertiesMap[name] = value.variant(); |
| | 223 | +} |
| | 224 | + |
| | 225 | +bool QOfonoModemInterface::isPowered() |
| | 226 | +{ |
| | 227 | + QVariant var = getProperty(QStringLiteral("Powered")); |
| | 228 | + return qdbus_cast<bool>(var); |
| | 229 | +} |
| | 230 | + |
| | 231 | +bool QOfonoModemInterface::isOnline() |
| | 232 | +{ |
| | 233 | + QVariant var = getProperty(QStringLiteral("Online")); |
| | 234 | + return qdbus_cast<bool>(var); |
| | 235 | +} |
| | 236 | + |
| | 237 | +QVariantMap QOfonoModemInterface::getProperties() |
| | 238 | +{ |
| | 239 | + if (propertiesMap.isEmpty()) { |
| | 240 | + QList<QVariant> argumentList; |
| | 241 | + QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList); |
| | 242 | + if (!reply.isError()) { |
| | 243 | + propertiesMap = reply.value(); |
| | 244 | + } |
| | 245 | + } |
| | 246 | + return propertiesMap; |
| | 247 | +} |
| | 248 | + |
| | 249 | +QVariant QOfonoModemInterface::getProperty(const QString &property) |
| | 250 | +{ |
| | 251 | + QVariant var; |
| | 252 | + QVariantMap map = getProperties(); |
| | 253 | + if (map.contains(property)) |
| | 254 | + var = map.value(property); |
| | 255 | + return var; |
| | 256 | +} |
| | 257 | + |
| | 258 | + |
| | 259 | +QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent) |
| | 260 | + : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), |
| | 261 | + dbusPathName, |
| | 262 | + OFONO_NETWORK_REGISTRATION_INTERFACE, |
| | 263 | + QDBusConnection::systemBus(), parent) |
| | 264 | +{ |
| | 265 | +} |
| | 266 | + |
| | 267 | +QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface() |
| | 268 | +{ |
| | 269 | +} |
| | 270 | + |
| | 271 | +QString QOfonoNetworkRegistrationInterface::getTechnology() |
| | 272 | +{ |
| | 273 | + QVariant var = getProperty(QStringLiteral("Technology")); |
| | 274 | + return qdbus_cast<QString>(var); |
| | 275 | +} |
| | 276 | + |
| | 277 | +QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property) |
| | 278 | +{ |
| | 279 | + QVariant var; |
| | 280 | + QVariantMap map = getProperties(); |
| | 281 | + if (map.contains(property)) |
| | 282 | + var = map.value(property); |
| | 283 | + return var; |
| | 284 | +} |
| | 285 | + |
| | 286 | +QVariantMap QOfonoNetworkRegistrationInterface::getProperties() |
| | 287 | +{ |
| | 288 | + if (propertiesMap.isEmpty()) { |
| | 289 | + QList<QVariant> argumentList; |
| | 290 | + QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList); |
| | 291 | + reply.waitForFinished(); |
| | 292 | + if (!reply.isError()) { |
| | 293 | + propertiesMap = reply.value(); |
| | 294 | + } |
| | 295 | + } |
| | 296 | + return propertiesMap; |
| | 297 | +} |
| | 298 | + |
| | 299 | +QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent) |
| | 300 | + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), |
| | 301 | + dbusPathName, |
| | 302 | + OFONO_DATA_CONNECTION_MANAGER_INTERFACE, |
| | 303 | + QDBusConnection::systemBus(), parent) |
| | 304 | +{ |
| | 305 | + QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), |
| | 306 | + path(), |
| | 307 | + QLatin1String(OFONO_MODEM_INTERFACE), |
| | 308 | + QLatin1String("PropertyChanged"), |
| | 309 | + this,SLOT(propertyChanged(QString,QDBusVariant))); |
| | 310 | +} |
| | 311 | + |
| | 312 | +QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface() |
| | 313 | +{ |
| | 314 | +} |
| | 315 | + |
| | 316 | +QStringList QOfonoDataConnectionManagerInterface::contexts() |
| | 317 | +{ |
| | 318 | + if (contextList.isEmpty()) { |
| | 319 | + QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts")); |
| | 320 | + reply.waitForFinished(); |
| | 321 | + if (!reply.isError()) { |
| | 322 | + foreach (ObjectPathProperties context, reply.value()) { |
| | 323 | + contextList << context.path.path(); |
| | 324 | + } |
| | 325 | + } |
| | 326 | + } |
| | 327 | + return contextList; |
| | 328 | +} |
| | 329 | + |
| | 330 | +bool QOfonoDataConnectionManagerInterface::roamingAllowed() |
| | 331 | +{ |
| | 332 | + QVariant var = getProperty(QStringLiteral("RoamingAllowed")); |
| | 333 | + return qdbus_cast<bool>(var); |
| | 334 | +} |
| | 335 | + |
| | 336 | +QString QOfonoDataConnectionManagerInterface::bearer() |
| | 337 | +{ |
| | 338 | + QVariant var = getProperty(QStringLiteral("Bearer")); |
| | 339 | + return qdbus_cast<QString>(var); |
| | 340 | +} |
| | 341 | + |
| | 342 | +QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property) |
| | 343 | +{ |
| | 344 | + QVariant var; |
| | 345 | + QVariantMap map = getProperties(); |
| | 346 | + if (map.contains(property)) |
| | 347 | + var = map.value(property); |
| | 348 | + return var; |
| | 349 | +} |
| | 350 | + |
| | 351 | +QVariantMap QOfonoDataConnectionManagerInterface::getProperties() |
| | 352 | +{ |
| | 353 | + if (propertiesMap.isEmpty()) { |
| | 354 | + QList<QVariant> argumentList; |
| | 355 | + QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList); |
| | 356 | + if (!reply.isError()) { |
| | 357 | + propertiesMap = reply.value(); |
| | 358 | + } |
| | 359 | + } |
| | 360 | + return propertiesMap; |
| | 361 | +} |
| | 362 | + |
| | 363 | +void QOfonoDataConnectionManagerInterface::propertyChanged(const QString &name, const QDBusVariant &value) |
| | 364 | +{ |
| | 365 | + propertiesMap[name] = value.variant(); |
| | 366 | + if (name == QLatin1String("RoamingAllowed")) |
| | 367 | + Q_EMIT roamingAllowedChanged(value.variant().toBool()); |
| | 368 | +} |
| | 369 | + |
| | 370 | + |
| | 371 | +QOfonoConnectionContextInterface::QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent) |
| | 372 | + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), |
| | 373 | + dbusPathName, |
| | 374 | + OFONO_CONNECTION_CONTEXT_INTERFACE, |
| | 375 | + QDBusConnection::systemBus(), parent) |
| | 376 | +{ |
| | 377 | + QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), |
| | 378 | + path(), |
| | 379 | + QLatin1String(OFONO_MODEM_INTERFACE), |
| | 380 | + QLatin1String("PropertyChanged"), |
| | 381 | + this,SLOT(propertyChanged(QString,QDBusVariant))); |
| | 382 | +} |
| | 383 | + |
| | 384 | +QOfonoConnectionContextInterface::~QOfonoConnectionContextInterface() |
| | 385 | +{ |
| | 386 | +} |
| | 387 | + |
| | 388 | +QVariantMap QOfonoConnectionContextInterface::getProperties() |
| | 389 | +{ |
| | 390 | + if (propertiesMap.isEmpty()) { |
| | 391 | + QList<QVariant> argumentList; |
| | 392 | + QDBusPendingReply<QVariantMap> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetProperties"), argumentList); |
| | 393 | + if (!reply.isError()) { |
| | 394 | + propertiesMap = reply.value(); |
| | 395 | + } |
| | 396 | + } |
| | 397 | + return propertiesMap; |
| | 398 | +} |
| | 399 | + |
| | 400 | +void QOfonoConnectionContextInterface::propertyChanged(const QString &name, const QDBusVariant &value) |
| | 401 | +{ |
| | 402 | + propertiesMap[name] = value.variant(); |
| | 403 | +} |
| | 404 | + |
| | 405 | +QVariant QOfonoConnectionContextInterface::getProperty(const QString &property) |
| | 406 | +{ |
| | 407 | + QVariant var; |
| | 408 | + QVariantMap map = getProperties(); |
| | 409 | + if (map.contains(property)) |
| | 410 | + var = map.value(property); |
| | 411 | + return var; |
| | 412 | +} |
| | 413 | + |
| | 414 | +bool QOfonoConnectionContextInterface::active() |
| | 415 | +{ |
| | 416 | + QVariant var = getProperty(QStringLiteral("Active")); |
| | 417 | + return qdbus_cast<bool>(var); |
| | 418 | +} |
| | 419 | + |
| | 420 | +QString QOfonoConnectionContextInterface::accessPointName() |
| | 421 | +{ |
| | 422 | + QVariant var = getProperty(QStringLiteral("AccessPointName")); |
| | 423 | + return qdbus_cast<QString>(var); |
| | 424 | +} |
| | 425 | + |
| | 426 | +QString QOfonoConnectionContextInterface::name() |
| | 427 | +{ |
| | 428 | + QVariant var = getProperty(QStringLiteral("Name")); |
| | 429 | + return qdbus_cast<QString>(var); |
| | 430 | +} |
| | 431 | + |
| | 432 | +QT_END_NAMESPACE |
| | 433 | + |
| | 434 | +#endif // QT_NO_DBUS |
| | 435 | +#endif // QT_NO_BEARERMANAGEMENT |
| | 436 | --- /dev/null |
| | 437 | +++ qtbase/src/plugins/bearer/linux_common/qofonoservice_linux_p.h |
| | 438 | @@ -0,0 +1,195 @@ |
| | 439 | +/**************************************************************************** |
| | 440 | +** |
| | 441 | +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
| | 442 | +** Contact: http://www.qt-project.org/legal |
| | 443 | +** |
| | 444 | +** This file is part of the plugins of the Qt Toolkit. |
| | 445 | +** |
| | 446 | +** $QT_BEGIN_LICENSE:LGPL21$ |
| | 447 | +** Commercial License Usage |
| | 448 | +** Licensees holding valid commercial Qt licenses may use this file in |
| | 449 | +** accordance with the commercial license agreement provided with the |
| | 450 | +** Software or, alternatively, in accordance with the terms contained in |
| | 451 | +** a written agreement between you and Digia. For licensing terms and |
| | 452 | +** conditions see http://qt.digia.com/licensing. For further information |
| | 453 | +** use the contact form at http://qt.digia.com/contact-us. |
| | 454 | +** |
| | 455 | +** GNU Lesser General Public License Usage |
| | 456 | +** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 457 | +** General Public License version 2.1 or version 3 as published by the Free |
| | 458 | +** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| | 459 | +** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| | 460 | +** following information to ensure the GNU Lesser General Public License |
| | 461 | +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| | 462 | +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 463 | +** |
| | 464 | +** In addition, as a special exception, Digia gives you certain additional |
| | 465 | +** rights. These rights are described in the Digia Qt LGPL Exception |
| | 466 | +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 467 | +** |
| | 468 | +** $QT_END_LICENSE$ |
| | 469 | +** |
| | 470 | +****************************************************************************/ |
| | 471 | + |
| | 472 | +#ifndef QOFONOSERVICE_H |
| | 473 | +#define QOFONOSERVICE_H |
| | 474 | + |
| | 475 | +// |
| | 476 | +// W A R N I N G |
| | 477 | +// ------------- |
| | 478 | +// |
| | 479 | +// This file is not part of the Qt API. It exists purely as an |
| | 480 | +// implementation detail. This header file may change from version to |
| | 481 | +// version without notice, or even be removed. |
| | 482 | +// |
| | 483 | +// We mean it. |
| | 484 | +// |
| | 485 | + |
| | 486 | +#include <QtDBus/QtDBus> |
| | 487 | +#include <QtDBus/QDBusConnection> |
| | 488 | +#include <QtDBus/QDBusError> |
| | 489 | +#include <QtDBus/QDBusInterface> |
| | 490 | +#include <QtDBus/QDBusMessage> |
| | 491 | +#include <QtDBus/QDBusReply> |
| | 492 | + |
| | 493 | +#include <QtDBus/QDBusPendingCallWatcher> |
| | 494 | +#include <QtDBus/QDBusObjectPath> |
| | 495 | +#include <QtDBus/QDBusContext> |
| | 496 | +#include <QMap> |
| | 497 | + |
| | 498 | +#ifndef QT_NO_BEARERMANAGEMENT |
| | 499 | +#ifndef QT_NO_DBUS |
| | 500 | + |
| | 501 | +#define OFONO_SERVICE "org.ofono" |
| | 502 | +#define OFONO_MANAGER_INTERFACE "org.ofono.Manager" |
| | 503 | +#define OFONO_MANAGER_PATH "/" |
| | 504 | + |
| | 505 | +#define OFONO_MODEM_INTERFACE "org.ofono.Modem" |
| | 506 | +#define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration" |
| | 507 | +#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.ConnectionManager" |
| | 508 | +#define OFONO_CONNECTION_CONTEXT_INTERFACE "org.ofono.ConnectionContext" |
| | 509 | + |
| | 510 | +QT_BEGIN_NAMESPACE |
| | 511 | + |
| | 512 | +QT_END_NAMESPACE |
| | 513 | + |
| | 514 | +struct ObjectPathProperties |
| | 515 | +{ |
| | 516 | + QDBusObjectPath path; |
| | 517 | + QVariantMap properties; |
| | 518 | +}; |
| | 519 | +typedef QList<ObjectPathProperties> PathPropertiesList; |
| | 520 | +Q_DECLARE_METATYPE(ObjectPathProperties) |
| | 521 | +Q_DECLARE_METATYPE (PathPropertiesList) |
| | 522 | + |
| | 523 | +QT_BEGIN_NAMESPACE |
| | 524 | + |
| | 525 | +class QOfonoManagerInterface : public QDBusAbstractInterface |
| | 526 | +{ |
| | 527 | + Q_OBJECT |
| | 528 | + |
| | 529 | +public: |
| | 530 | + |
| | 531 | + QOfonoManagerInterface( QObject *parent = 0); |
| | 532 | + ~QOfonoManagerInterface(); |
| | 533 | + |
| | 534 | + QStringList getModems(); |
| | 535 | + QString currentModem(); |
| | 536 | +signals: |
| | 537 | + void modemChanged(); |
| | 538 | +private: |
| | 539 | + QStringList modemList; |
| | 540 | +private slots: |
| | 541 | + void modemAdded(const QDBusObjectPath &path, const QVariantMap &var); |
| | 542 | + void modemRemoved(const QDBusObjectPath &path); |
| | 543 | +}; |
| | 544 | + |
| | 545 | +class QOfonoModemInterface : public QDBusAbstractInterface |
| | 546 | +{ |
| | 547 | + Q_OBJECT |
| | 548 | + |
| | 549 | +public: |
| | 550 | + |
| | 551 | + explicit QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0); |
| | 552 | + ~QOfonoModemInterface(); |
| | 553 | + |
| | 554 | + bool isPowered(); |
| | 555 | + bool isOnline(); |
| | 556 | +private: |
| | 557 | + QVariantMap getProperties(); |
| | 558 | + QVariantMap propertiesMap; |
| | 559 | + QVariant getProperty(const QString &); |
| | 560 | + void propertyChanged(const QString &, const QDBusVariant &value); |
| | 561 | +}; |
| | 562 | + |
| | 563 | + |
| | 564 | +class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface |
| | 565 | +{ |
| | 566 | + Q_OBJECT |
| | 567 | + |
| | 568 | +public: |
| | 569 | + |
| | 570 | + explicit QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0); |
| | 571 | + ~QOfonoNetworkRegistrationInterface(); |
| | 572 | + |
| | 573 | + QString getTechnology(); |
| | 574 | + |
| | 575 | +private: |
| | 576 | + QVariantMap getProperties(); |
| | 577 | + QVariant getProperty(const QString &); |
| | 578 | + QVariantMap propertiesMap; |
| | 579 | +Q_SIGNALS: |
| | 580 | + void propertyChanged(const QString &, const QDBusVariant &value); |
| | 581 | +}; |
| | 582 | + |
| | 583 | +class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface |
| | 584 | +{ |
| | 585 | + Q_OBJECT |
| | 586 | + |
| | 587 | +public: |
| | 588 | + |
| | 589 | + explicit QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0); |
| | 590 | + ~QOfonoDataConnectionManagerInterface(); |
| | 591 | + |
| | 592 | + QStringList contexts(); |
| | 593 | + bool roamingAllowed(); |
| | 594 | + QVariant getProperty(const QString &); |
| | 595 | + QString bearer(); |
| | 596 | +Q_SIGNALS: |
| | 597 | + void roamingAllowedChanged(bool); |
| | 598 | +private: |
| | 599 | + QVariantMap getProperties(); |
| | 600 | + QVariantMap propertiesMap; |
| | 601 | + QStringList contextList; |
| | 602 | +private slots: |
| | 603 | + void propertyChanged(const QString &, const QDBusVariant &value); |
| | 604 | +}; |
| | 605 | + |
| | 606 | +class QOfonoConnectionContextInterface : public QDBusAbstractInterface |
| | 607 | +{ |
| | 608 | + Q_OBJECT |
| | 609 | + |
| | 610 | +public: |
| | 611 | + |
| | 612 | + explicit QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent = 0); |
| | 613 | + ~QOfonoConnectionContextInterface(); |
| | 614 | + |
| | 615 | + QVariant getProperty(const QString &); |
| | 616 | + bool active(); |
| | 617 | + QString accessPointName(); |
| | 618 | + QString name(); |
| | 619 | + |
| | 620 | +Q_SIGNALS: |
| | 621 | +private: |
| | 622 | + QVariantMap getProperties(); |
| | 623 | + QVariantMap propertiesMap; |
| | 624 | +private slots: |
| | 625 | + void propertyChanged(const QString &, const QDBusVariant &value); |
| | 626 | +}; |
| | 627 | + |
| | 628 | +QT_END_NAMESPACE |
| | 629 | + |
| | 630 | +#endif // QT_NO_DBUS |
| | 631 | +#endif // QT_NO_BEARERMANAGEMENT |
| | 632 | + |
| | 633 | +#endif //QOFONOSERVICE_H |
| | 634 | --- qtbase/src/plugins/bearer/connman/qofonoservice_linux.cpp |
| | 635 | +++ /dev/null |
| | 636 | @@ -1,311 +0,0 @@ |
| | 637 | -/**************************************************************************** |
| | 638 | -** |
| | 639 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 640 | -** Contact: http://www.qt-project.org/legal |
| | 641 | -** |
| | 642 | -** This file is part of the plugins of the Qt Toolkit. |
| | 643 | -** |
| | 644 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 645 | -** Commercial License Usage |
| | 646 | -** Licensees holding valid commercial Qt licenses may use this file in |
| | 647 | -** accordance with the commercial license agreement provided with the |
| | 648 | -** Software or, alternatively, in accordance with the terms contained in |
| | 649 | -** a written agreement between you and Digia. For licensing terms and |
| | 650 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 651 | -** use the contact form at http://qt.digia.com/contact-us. |
| | 652 | -** |
| | 653 | -** GNU Lesser General Public License Usage |
| | 654 | -** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 655 | -** General Public License version 2.1 as published by the Free Software |
| | 656 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 657 | -** packaging of this file. Please review the following information to |
| | 658 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 659 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 660 | -** |
| | 661 | -** In addition, as a special exception, Digia gives you certain additional |
| | 662 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 663 | -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 664 | -** |
| | 665 | -** GNU General Public License Usage |
| | 666 | -** Alternatively, this file may be used under the terms of the GNU |
| | 667 | -** General Public License version 3.0 as published by the Free Software |
| | 668 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 669 | -** packaging of this file. Please review the following information to |
| | 670 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 671 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 672 | -** |
| | 673 | -** |
| | 674 | -** $QT_END_LICENSE$ |
| | 675 | -** |
| | 676 | -****************************************************************************/ |
| | 677 | - |
| | 678 | -#include <QObject> |
| | 679 | -#include <QList> |
| | 680 | -#include <QtDBus/QtDBus> |
| | 681 | -#include <QtDBus/QDBusConnection> |
| | 682 | -#include <QtDBus/QDBusError> |
| | 683 | -#include <QtDBus/QDBusInterface> |
| | 684 | -#include <QtDBus/QDBusMessage> |
| | 685 | -#include <QtDBus/QDBusReply> |
| | 686 | -#include <QtDBus/QDBusPendingCallWatcher> |
| | 687 | -#include <QtDBus/QDBusObjectPath> |
| | 688 | -#include <QtDBus/QDBusPendingCall> |
| | 689 | - |
| | 690 | -#include "qofonoservice_linux_p.h" |
| | 691 | - |
| | 692 | -#ifndef QT_NO_BEARERMANAGEMENT |
| | 693 | -#ifndef QT_NO_DBUS |
| | 694 | - |
| | 695 | -QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &item) |
| | 696 | -{ |
| | 697 | - argument.beginStructure(); |
| | 698 | - argument << item.path << item.properties; |
| | 699 | - argument.endStructure(); |
| | 700 | - return argument; |
| | 701 | -} |
| | 702 | - |
| | 703 | -const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathProperties &item) |
| | 704 | -{ |
| | 705 | - argument.beginStructure(); |
| | 706 | - argument >> item.path >> item.properties; |
| | 707 | - argument.endStructure(); |
| | 708 | - return argument; |
| | 709 | -} |
| | 710 | - |
| | 711 | -QT_BEGIN_NAMESPACE |
| | 712 | - |
| | 713 | -QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent) |
| | 714 | - : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), |
| | 715 | - QStringLiteral(OFONO_MANAGER_PATH), |
| | 716 | - OFONO_MANAGER_INTERFACE, |
| | 717 | - QDBusConnection::systemBus(), parent) |
| | 718 | -{ |
| | 719 | - qDBusRegisterMetaType<ObjectPathProperties>(); |
| | 720 | - qDBusRegisterMetaType<PathPropertiesList>(); |
| | 721 | - |
| | 722 | - QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), |
| | 723 | - QStringLiteral(OFONO_MANAGER_PATH), |
| | 724 | - QStringLiteral(OFONO_MANAGER_INTERFACE), |
| | 725 | - QStringLiteral("ModemAdded"), |
| | 726 | - this,SLOT(modemAdded(QDBusObjectPath, QVariantMap))); |
| | 727 | - QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), |
| | 728 | - QStringLiteral(OFONO_MANAGER_PATH), |
| | 729 | - QStringLiteral(OFONO_MANAGER_INTERFACE), |
| | 730 | - QStringLiteral("ModemRemoved"), |
| | 731 | - this,SLOT(modemRemoved(QDBusObjectPath))); |
| | 732 | -} |
| | 733 | - |
| | 734 | -QOfonoManagerInterface::~QOfonoManagerInterface() |
| | 735 | -{ |
| | 736 | -} |
| | 737 | - |
| | 738 | -QStringList QOfonoManagerInterface::getModems() |
| | 739 | -{ |
| | 740 | - if (modemList.isEmpty()) { |
| | 741 | - QList<QVariant> argumentList; |
| | 742 | - QDBusPendingReply<PathPropertiesList> reply = asyncCallWithArgumentList(QLatin1String("GetModems"), argumentList); |
| | 743 | - reply.waitForFinished(); |
| | 744 | - if (!reply.isError()) { |
| | 745 | - foreach (ObjectPathProperties modem, reply.value()) { |
| | 746 | - modemList << modem.path.path(); |
| | 747 | - } |
| | 748 | - } else { |
| | 749 | - qDebug() << reply.error().message(); |
| | 750 | - } |
| | 751 | - } |
| | 752 | - |
| | 753 | - return modemList; |
| | 754 | -} |
| | 755 | - |
| | 756 | -QString QOfonoManagerInterface::currentModem() |
| | 757 | -{ |
| | 758 | - QStringList modems = getModems(); |
| | 759 | - foreach (const QString &modem, modems) { |
| | 760 | - QOfonoModemInterface device(modem); |
| | 761 | - if (device.isPowered() && device.isOnline()) |
| | 762 | - return modem; |
| | 763 | - } |
| | 764 | - return QString(); |
| | 765 | -} |
| | 766 | - |
| | 767 | -void QOfonoManagerInterface::modemAdded(const QDBusObjectPath &path, const QVariantMap &/*var*/) |
| | 768 | -{ |
| | 769 | - if (!modemList.contains(path.path())) { |
| | 770 | - modemList << path.path(); |
| | 771 | - Q_EMIT modemChanged(); |
| | 772 | - } |
| | 773 | -} |
| | 774 | - |
| | 775 | -void QOfonoManagerInterface::modemRemoved(const QDBusObjectPath &path) |
| | 776 | -{ |
| | 777 | - if (modemList.contains(path.path())) { |
| | 778 | - modemList.removeOne(path.path()); |
| | 779 | - Q_EMIT modemChanged(); |
| | 780 | - } |
| | 781 | -} |
| | 782 | - |
| | 783 | - |
| | 784 | -QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent) |
| | 785 | - : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), |
| | 786 | - dbusPathName, |
| | 787 | - OFONO_MODEM_INTERFACE, |
| | 788 | - QDBusConnection::systemBus(), parent) |
| | 789 | -{ |
| | 790 | - QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), |
| | 791 | - path(), |
| | 792 | - OFONO_MODEM_INTERFACE, |
| | 793 | - QStringLiteral("PropertyChanged"), |
| | 794 | - this,SLOT(propertyChanged(QString,QDBusVariant))); |
| | 795 | -} |
| | 796 | - |
| | 797 | -QOfonoModemInterface::~QOfonoModemInterface() |
| | 798 | -{ |
| | 799 | -} |
| | 800 | - |
| | 801 | -void QOfonoModemInterface::propertyChanged(const QString &name,const QDBusVariant &value) |
| | 802 | -{ |
| | 803 | - propertiesMap[name] = value.variant(); |
| | 804 | -} |
| | 805 | - |
| | 806 | -bool QOfonoModemInterface::isPowered() |
| | 807 | -{ |
| | 808 | - QVariant var = getProperty(QStringLiteral("Powered")); |
| | 809 | - return qdbus_cast<bool>(var); |
| | 810 | -} |
| | 811 | - |
| | 812 | -bool QOfonoModemInterface::isOnline() |
| | 813 | -{ |
| | 814 | - QVariant var = getProperty(QStringLiteral("Online")); |
| | 815 | - return qdbus_cast<bool>(var); |
| | 816 | -} |
| | 817 | - |
| | 818 | -QVariantMap QOfonoModemInterface::getProperties() |
| | 819 | -{ |
| | 820 | - if (propertiesMap.isEmpty()) { |
| | 821 | - QList<QVariant> argumentList; |
| | 822 | - QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); |
| | 823 | - if (!reply.isError()) { |
| | 824 | - propertiesMap = reply.value(); |
| | 825 | - } |
| | 826 | - } |
| | 827 | - return propertiesMap; |
| | 828 | -} |
| | 829 | - |
| | 830 | -QVariant QOfonoModemInterface::getProperty(const QString &property) |
| | 831 | -{ |
| | 832 | - QVariant var; |
| | 833 | - QVariantMap map = getProperties(); |
| | 834 | - var = map.value(property); |
| | 835 | - return var; |
| | 836 | -} |
| | 837 | - |
| | 838 | - |
| | 839 | -QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent) |
| | 840 | - : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), |
| | 841 | - dbusPathName, |
| | 842 | - OFONO_NETWORK_REGISTRATION_INTERFACE, |
| | 843 | - QDBusConnection::systemBus(), parent) |
| | 844 | -{ |
| | 845 | -} |
| | 846 | - |
| | 847 | -QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface() |
| | 848 | -{ |
| | 849 | -} |
| | 850 | - |
| | 851 | -QString QOfonoNetworkRegistrationInterface::getTechnology() |
| | 852 | -{ |
| | 853 | - QVariant var = getProperty(QStringLiteral("Technology")); |
| | 854 | - return qdbus_cast<QString>(var); |
| | 855 | -} |
| | 856 | - |
| | 857 | -QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property) |
| | 858 | -{ |
| | 859 | - QVariant var; |
| | 860 | - QVariantMap map = getProperties(); |
| | 861 | - var = map.value(property); |
| | 862 | - return var; |
| | 863 | -} |
| | 864 | - |
| | 865 | -QVariantMap QOfonoNetworkRegistrationInterface::getProperties() |
| | 866 | -{ |
| | 867 | - if (propertiesMap.isEmpty()) { |
| | 868 | - QList<QVariant> argumentList; |
| | 869 | - QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); |
| | 870 | - reply.waitForFinished(); |
| | 871 | - if (!reply.isError()) { |
| | 872 | - propertiesMap = reply.value(); |
| | 873 | - } else { |
| | 874 | - qDebug() << reply.error().message(); |
| | 875 | - } |
| | 876 | - } |
| | 877 | - return propertiesMap; |
| | 878 | -} |
| | 879 | - |
| | 880 | -QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent) |
| | 881 | - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), |
| | 882 | - dbusPathName, |
| | 883 | - OFONO_DATA_CONNECTION_MANAGER_INTERFACE, |
| | 884 | - QDBusConnection::systemBus(), parent) |
| | 885 | -{ |
| | 886 | - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), |
| | 887 | - path(), |
| | 888 | - QLatin1String(OFONO_MODEM_INTERFACE), |
| | 889 | - QLatin1String("PropertyChanged"), |
| | 890 | - this,SLOT(propertyChanged(QString,QDBusVariant))); |
| | 891 | -} |
| | 892 | - |
| | 893 | -QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface() |
| | 894 | -{ |
| | 895 | -} |
| | 896 | - |
| | 897 | -QStringList QOfonoDataConnectionManagerInterface::contexts() |
| | 898 | -{ |
| | 899 | - if (contextList.isEmpty()) { |
| | 900 | - QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts")); |
| | 901 | - reply.waitForFinished(); |
| | 902 | - if (!reply.isError()) { |
| | 903 | - foreach (ObjectPathProperties context, reply.value()) { |
| | 904 | - contextList << context.path.path(); |
| | 905 | - } |
| | 906 | - } |
| | 907 | - } |
| | 908 | - return contextList; |
| | 909 | -} |
| | 910 | - |
| | 911 | -bool QOfonoDataConnectionManagerInterface::roamingAllowed() |
| | 912 | -{ |
| | 913 | - QVariant var = getProperty(QStringLiteral("RoamingAllowed")); |
| | 914 | - return qdbus_cast<bool>(var); |
| | 915 | -} |
| | 916 | - |
| | 917 | -QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property) |
| | 918 | -{ |
| | 919 | - QVariant var; |
| | 920 | - QVariantMap map = getProperties(); |
| | 921 | - var = map.value(property); |
| | 922 | - return var; |
| | 923 | -} |
| | 924 | - |
| | 925 | -QVariantMap QOfonoDataConnectionManagerInterface::getProperties() |
| | 926 | -{ |
| | 927 | - if (propertiesMap.isEmpty()) { |
| | 928 | - QList<QVariant> argumentList; |
| | 929 | - QDBusPendingReply<QVariantMap> reply = asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); |
| | 930 | - if (!reply.isError()) { |
| | 931 | - propertiesMap = reply.value(); |
| | 932 | - } |
| | 933 | - } |
| | 934 | - return propertiesMap; |
| | 935 | -} |
| | 936 | - |
| | 937 | -void QOfonoDataConnectionManagerInterface::propertyChanged(const QString &name, const QDBusVariant &value) |
| | 938 | -{ |
| | 939 | - propertiesMap[name] = value.variant(); |
| | 940 | - if (name == QStringLiteral("RoamingAllowed")) |
| | 941 | - Q_EMIT roamingAllowedChanged(value.variant().toBool()); |
| | 942 | -} |
| | 943 | - |
| | 944 | -QT_END_NAMESPACE |
| | 945 | - |
| | 946 | -#endif // QT_NO_DBUS |
| | 947 | -#endif // QT_NO_BEARERMANAGEMENT |
| | 948 | --- qtbase/src/plugins/bearer/connman/qofonoservice_linux_p.h |
| | 949 | +++ /dev/null |
| | 950 | @@ -1,180 +0,0 @@ |
| | 951 | -/**************************************************************************** |
| | 952 | -** |
| | 953 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 954 | -** Contact: http://www.qt-project.org/legal |
| | 955 | -** |
| | 956 | -** This file is part of the plugins of the Qt Toolkit. |
| | 957 | -** |
| | 958 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 959 | -** Commercial License Usage |
| | 960 | -** Licensees holding valid commercial Qt licenses may use this file in |
| | 961 | -** accordance with the commercial license agreement provided with the |
| | 962 | -** Software or, alternatively, in accordance with the terms contained in |
| | 963 | -** a written agreement between you and Digia. For licensing terms and |
| | 964 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 965 | -** use the contact form at http://qt.digia.com/contact-us. |
| | 966 | -** |
| | 967 | -** GNU Lesser General Public License Usage |
| | 968 | -** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 969 | -** General Public License version 2.1 as published by the Free Software |
| | 970 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 971 | -** packaging of this file. Please review the following information to |
| | 972 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 973 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 974 | -** |
| | 975 | -** In addition, as a special exception, Digia gives you certain additional |
| | 976 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 977 | -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 978 | -** |
| | 979 | -** GNU General Public License Usage |
| | 980 | -** Alternatively, this file may be used under the terms of the GNU |
| | 981 | -** General Public License version 3.0 as published by the Free Software |
| | 982 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 983 | -** packaging of this file. Please review the following information to |
| | 984 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 985 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 986 | -** |
| | 987 | -** |
| | 988 | -** $QT_END_LICENSE$ |
| | 989 | -** |
| | 990 | -****************************************************************************/ |
| | 991 | - |
| | 992 | -#ifndef QOFONOSERVICE_H |
| | 993 | -#define QOFONOSERVICE_H |
| | 994 | - |
| | 995 | -// |
| | 996 | -// W A R N I N G |
| | 997 | -// ------------- |
| | 998 | -// |
| | 999 | -// This file is not part of the Qt API. It exists purely as an |
| | 1000 | -// implementation detail. This header file may change from version to |
| | 1001 | -// version without notice, or even be removed. |
| | 1002 | -// |
| | 1003 | -// We mean it. |
| | 1004 | -// |
| | 1005 | - |
| | 1006 | -#include <QtDBus/QtDBus> |
| | 1007 | -#include <QtDBus/QDBusConnection> |
| | 1008 | -#include <QtDBus/QDBusError> |
| | 1009 | -#include <QtDBus/QDBusInterface> |
| | 1010 | -#include <QtDBus/QDBusMessage> |
| | 1011 | -#include <QtDBus/QDBusReply> |
| | 1012 | - |
| | 1013 | -#include <QtDBus/QDBusPendingCallWatcher> |
| | 1014 | -#include <QtDBus/QDBusObjectPath> |
| | 1015 | -#include <QtDBus/QDBusContext> |
| | 1016 | -#include <QMap> |
| | 1017 | - |
| | 1018 | -#ifndef QT_NO_BEARERMANAGEMENT |
| | 1019 | -#ifndef QT_NO_DBUS |
| | 1020 | - |
| | 1021 | -#define OFONO_SERVICE "org.ofono" |
| | 1022 | -#define OFONO_MANAGER_INTERFACE "org.ofono.Manager" |
| | 1023 | -#define OFONO_MANAGER_PATH "/" |
| | 1024 | - |
| | 1025 | -#define OFONO_MODEM_INTERFACE "org.ofono.Modem" |
| | 1026 | -#define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration" |
| | 1027 | -#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.ConnectionManager" |
| | 1028 | - |
| | 1029 | -QT_BEGIN_NAMESPACE |
| | 1030 | - |
| | 1031 | -QT_END_NAMESPACE |
| | 1032 | - |
| | 1033 | -struct ObjectPathProperties |
| | 1034 | -{ |
| | 1035 | - QDBusObjectPath path; |
| | 1036 | - QVariantMap properties; |
| | 1037 | -}; |
| | 1038 | -typedef QList<ObjectPathProperties> PathPropertiesList; |
| | 1039 | -Q_DECLARE_METATYPE(ObjectPathProperties) |
| | 1040 | -Q_DECLARE_METATYPE (PathPropertiesList) |
| | 1041 | - |
| | 1042 | -QT_BEGIN_NAMESPACE |
| | 1043 | - |
| | 1044 | -class QOfonoManagerInterface : public QDBusAbstractInterface |
| | 1045 | -{ |
| | 1046 | - Q_OBJECT |
| | 1047 | - |
| | 1048 | -public: |
| | 1049 | - |
| | 1050 | - QOfonoManagerInterface( QObject *parent = 0); |
| | 1051 | - ~QOfonoManagerInterface(); |
| | 1052 | - |
| | 1053 | - QStringList getModems(); |
| | 1054 | - QString currentModem(); |
| | 1055 | -signals: |
| | 1056 | - void modemChanged(); |
| | 1057 | -private: |
| | 1058 | - QStringList modemList; |
| | 1059 | -private slots: |
| | 1060 | - void modemAdded(const QDBusObjectPath &path, const QVariantMap &var); |
| | 1061 | - void modemRemoved(const QDBusObjectPath &path); |
| | 1062 | -}; |
| | 1063 | - |
| | 1064 | -class QOfonoModemInterface : public QDBusAbstractInterface |
| | 1065 | -{ |
| | 1066 | - Q_OBJECT |
| | 1067 | - |
| | 1068 | -public: |
| | 1069 | - |
| | 1070 | - explicit QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0); |
| | 1071 | - ~QOfonoModemInterface(); |
| | 1072 | - |
| | 1073 | - bool isPowered(); |
| | 1074 | - bool isOnline(); |
| | 1075 | -private: |
| | 1076 | - QVariantMap getProperties(); |
| | 1077 | - QVariantMap propertiesMap; |
| | 1078 | - QVariant getProperty(const QString &); |
| | 1079 | - void propertyChanged(const QString &, const QDBusVariant &value); |
| | 1080 | -}; |
| | 1081 | - |
| | 1082 | - |
| | 1083 | -class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface |
| | 1084 | -{ |
| | 1085 | - Q_OBJECT |
| | 1086 | - |
| | 1087 | -public: |
| | 1088 | - |
| | 1089 | - explicit QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0); |
| | 1090 | - ~QOfonoNetworkRegistrationInterface(); |
| | 1091 | - |
| | 1092 | - QString getTechnology(); |
| | 1093 | - |
| | 1094 | -private: |
| | 1095 | - QVariantMap getProperties(); |
| | 1096 | - QVariant getProperty(const QString &); |
| | 1097 | - QVariantMap propertiesMap; |
| | 1098 | -Q_SIGNALS: |
| | 1099 | - void propertyChanged(const QString &, const QDBusVariant &value); |
| | 1100 | -}; |
| | 1101 | - |
| | 1102 | -class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface |
| | 1103 | -{ |
| | 1104 | - Q_OBJECT |
| | 1105 | - |
| | 1106 | -public: |
| | 1107 | - |
| | 1108 | - explicit QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0); |
| | 1109 | - ~QOfonoDataConnectionManagerInterface(); |
| | 1110 | - |
| | 1111 | - QStringList contexts(); |
| | 1112 | - bool roamingAllowed(); |
| | 1113 | -Q_SIGNALS: |
| | 1114 | - void roamingAllowedChanged(bool); |
| | 1115 | -private: |
| | 1116 | - QVariantMap getProperties(); |
| | 1117 | - QVariantMap propertiesMap; |
| | 1118 | - QVariant getProperty(const QString &); |
| | 1119 | - QStringList contextList; |
| | 1120 | -private slots: |
| | 1121 | - void propertyChanged(const QString &, const QDBusVariant &value); |
| | 1122 | -}; |
| | 1123 | - |
| | 1124 | - |
| | 1125 | -QT_END_NAMESPACE |
| | 1126 | - |
| | 1127 | -#endif // QT_NO_DBUS |
| | 1128 | -#endif // QT_NO_BEARERMANAGEMENT |
| | 1129 | - |
| | 1130 | -#endif //QOFONOSERVICE_H |
| | 1131 | --- qtbase/src/plugins/bearer/networkmanager/main.cpp |
| | 1132 | +++ qtbase/src/plugins/bearer/networkmanager/main.cpp |
| | 1133 | @@ -1,40 +1,32 @@ |
| | 1134 | /**************************************************************************** |
| | 1135 | ** |
| | 1136 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 1137 | +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
| | 1138 | ** Contact: http://www.qt-project.org/legal |
| | 1139 | ** |
| | 1140 | ** This file is part of the plugins of the Qt Toolkit. |
| | 1141 | ** |
| | 1142 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 1143 | +** $QT_BEGIN_LICENSE:LGPL21$ |
| | 1144 | ** Commercial License Usage |
| | 1145 | ** Licensees holding valid commercial Qt licenses may use this file in |
| | 1146 | ** accordance with the commercial license agreement provided with the |
| | 1147 | ** Software or, alternatively, in accordance with the terms contained in |
| | 1148 | -** a written agreement between you and Digia. For licensing terms and |
| | 1149 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 1150 | +** a written agreement between you and Digia. For licensing terms and |
| | 1151 | +** conditions see http://qt.digia.com/licensing. For further information |
| | 1152 | ** use the contact form at http://qt.digia.com/contact-us. |
| | 1153 | ** |
| | 1154 | ** GNU Lesser General Public License Usage |
| | 1155 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 1156 | -** General Public License version 2.1 as published by the Free Software |
| | 1157 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 1158 | -** packaging of this file. Please review the following information to |
| | 1159 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 1160 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 1161 | +** General Public License version 2.1 or version 3 as published by the Free |
| | 1162 | +** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| | 1163 | +** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| | 1164 | +** following information to ensure the GNU Lesser General Public License |
| | 1165 | +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| | 1166 | +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 1167 | ** |
| | 1168 | ** In addition, as a special exception, Digia gives you certain additional |
| | 1169 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 1170 | +** rights. These rights are described in the Digia Qt LGPL Exception |
| | 1171 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 1172 | ** |
| | 1173 | -** GNU General Public License Usage |
| | 1174 | -** Alternatively, this file may be used under the terms of the GNU |
| | 1175 | -** General Public License version 3.0 as published by the Free Software |
| | 1176 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 1177 | -** packaging of this file. Please review the following information to |
| | 1178 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 1179 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 1180 | -** |
| | 1181 | -** |
| | 1182 | ** $QT_END_LICENSE$ |
| | 1183 | ** |
| | 1184 | ****************************************************************************/ |
| | 1185 | --- qtbase/src/plugins/bearer/networkmanager/networkmanager.pro |
| | 1186 | +++ qtbase/src/plugins/bearer/networkmanager/networkmanager.pro |
| | 1187 | @@ -6,16 +6,16 @@ |
| | 1188 | |
| | 1189 | QT = core network-private dbus |
| | 1190 | |
| | 1191 | -HEADERS += qnmdbushelper.h \ |
| | 1192 | - qnetworkmanagerservice.h \ |
| | 1193 | +HEADERS += qnetworkmanagerservice.h \ |
| | 1194 | qnetworkmanagerengine.h \ |
| | 1195 | + ../linux_common/qofonoservice_linux_p.h \ |
| | 1196 | ../qnetworksession_impl.h \ |
| | 1197 | ../qbearerengine_impl.h |
| | 1198 | |
| | 1199 | SOURCES += main.cpp \ |
| | 1200 | - qnmdbushelper.cpp \ |
| | 1201 | qnetworkmanagerservice.cpp \ |
| | 1202 | qnetworkmanagerengine.cpp \ |
| | 1203 | + ../linux_common/qofonoservice_linux.cpp \ |
| | 1204 | ../qnetworksession_impl.cpp |
| | 1205 | |
| | 1206 | OTHER_FILES += networkmanager.json |
| | 1207 | --- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp |
| | 1208 | +++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp |
| | 1209 | @@ -1,40 +1,32 @@ |
| | 1210 | /**************************************************************************** |
| | 1211 | ** |
| | 1212 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 1213 | +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
| | 1214 | ** Contact: http://www.qt-project.org/legal |
| | 1215 | ** |
| | 1216 | ** This file is part of the plugins of the Qt Toolkit. |
| | 1217 | ** |
| | 1218 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 1219 | +** $QT_BEGIN_LICENSE:LGPL21$ |
| | 1220 | ** Commercial License Usage |
| | 1221 | ** Licensees holding valid commercial Qt licenses may use this file in |
| | 1222 | ** accordance with the commercial license agreement provided with the |
| | 1223 | ** Software or, alternatively, in accordance with the terms contained in |
| | 1224 | -** a written agreement between you and Digia. For licensing terms and |
| | 1225 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 1226 | +** a written agreement between you and Digia. For licensing terms and |
| | 1227 | +** conditions see http://qt.digia.com/licensing. For further information |
| | 1228 | ** use the contact form at http://qt.digia.com/contact-us. |
| | 1229 | ** |
| | 1230 | ** GNU Lesser General Public License Usage |
| | 1231 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 1232 | -** General Public License version 2.1 as published by the Free Software |
| | 1233 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 1234 | -** packaging of this file. Please review the following information to |
| | 1235 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 1236 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 1237 | +** General Public License version 2.1 or version 3 as published by the Free |
| | 1238 | +** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| | 1239 | +** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| | 1240 | +** following information to ensure the GNU Lesser General Public License |
| | 1241 | +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| | 1242 | +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 1243 | ** |
| | 1244 | ** In addition, as a special exception, Digia gives you certain additional |
| | 1245 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 1246 | +** rights. These rights are described in the Digia Qt LGPL Exception |
| | 1247 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 1248 | ** |
| | 1249 | -** GNU General Public License Usage |
| | 1250 | -** Alternatively, this file may be used under the terms of the GNU |
| | 1251 | -** General Public License version 3.0 as published by the Free Software |
| | 1252 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 1253 | -** packaging of this file. Please review the following information to |
| | 1254 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 1255 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 1256 | -** |
| | 1257 | -** |
| | 1258 | ** $QT_END_LICENSE$ |
| | 1259 | ** |
| | 1260 | ****************************************************************************/ |
| | 1261 | @@ -55,6 +47,7 @@ |
| | 1262 | #include <QDBusInterface> |
| | 1263 | #include <QDBusMessage> |
| | 1264 | #include <QDBusReply> |
| | 1265 | +#include "../linux_common/qofonoservice_linux_p.h" |
| | 1266 | |
| | 1267 | #ifndef QT_NO_BEARERMANAGEMENT |
| | 1268 | #ifndef QT_NO_DBUS |
| | 1269 | @@ -63,130 +56,113 @@ |
| | 1270 | |
| | 1271 | QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent) |
| | 1272 | : QBearerEngineImpl(parent), |
| | 1273 | - interface(new QNetworkManagerInterface(this)), |
| | 1274 | - systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_SYSTEM_SETTINGS, this)), |
| | 1275 | - userSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_USER_SETTINGS, this)) |
| | 1276 | + managerInterface(new QNetworkManagerInterface(this)), |
| | 1277 | + systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE, this)), |
| | 1278 | + ofonoManager(new QOfonoManagerInterface(this)) |
| | 1279 | { |
| | 1280 | - if (!interface->isValid()) |
| | 1281 | + |
| | 1282 | + if (!managerInterface->isValid()) |
| | 1283 | return; |
| | 1284 | |
| | 1285 | - interface->setConnections(); |
| | 1286 | - connect(interface, SIGNAL(deviceAdded(QDBusObjectPath)), |
| | 1287 | + qDBusRegisterMetaType<QNmSettingsMap>(); |
| | 1288 | + |
| | 1289 | + connect(managerInterface, SIGNAL(deviceAdded(QDBusObjectPath)), |
| | 1290 | this, SLOT(deviceAdded(QDBusObjectPath))); |
| | 1291 | - connect(interface, SIGNAL(deviceRemoved(QDBusObjectPath)), |
| | 1292 | + connect(managerInterface, SIGNAL(deviceRemoved(QDBusObjectPath)), |
| | 1293 | this, SLOT(deviceRemoved(QDBusObjectPath))); |
| | 1294 | -#if 0 |
| | 1295 | - connect(interface, SIGNAL(stateChanged(QString,quint32)), |
| | 1296 | - this, SIGNAL(configurationsChanged())); |
| | 1297 | -#endif |
| | 1298 | - connect(interface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)), |
| | 1299 | + connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)), |
| | 1300 | this, SLOT(activationFinished(QDBusPendingCallWatcher*))); |
| | 1301 | - connect(interface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)), |
| | 1302 | - this, SLOT(interfacePropertiesChanged(QString,QMap<QString,QVariant>))); |
| | 1303 | - |
| | 1304 | - qDBusRegisterMetaType<QNmSettingsMap>(); |
| | 1305 | + connect(managerInterface, SIGNAL(propertiesChanged(QMap<QString,QVariant>)), |
| | 1306 | + this, SLOT(interfacePropertiesChanged(QMap<QString,QVariant>))); |
| | 1307 | + managerInterface->setConnections(); |
| | 1308 | |
| | 1309 | - systemSettings->setConnections(); |
| | 1310 | connect(systemSettings, SIGNAL(newConnection(QDBusObjectPath)), |
| | 1311 | this, SLOT(newConnection(QDBusObjectPath))); |
| | 1312 | - |
| | 1313 | - userSettings->setConnections(); |
| | 1314 | - connect(userSettings, SIGNAL(newConnection(QDBusObjectPath)), |
| | 1315 | - this, SLOT(newConnection(QDBusObjectPath))); |
| | 1316 | + systemSettings->setConnections(); |
| | 1317 | } |
| | 1318 | |
| | 1319 | QNetworkManagerEngine::~QNetworkManagerEngine() |
| | 1320 | { |
| | 1321 | qDeleteAll(connections); |
| | 1322 | + connections.clear(); |
| | 1323 | qDeleteAll(accessPoints); |
| | 1324 | + accessPoints.clear(); |
| | 1325 | qDeleteAll(wirelessDevices); |
| | 1326 | - qDeleteAll(activeConnections); |
| | 1327 | + wirelessDevices.clear(); |
| | 1328 | + qDeleteAll(activeConnectionsList); |
| | 1329 | + activeConnectionsList.clear(); |
| | 1330 | + qDeleteAll(interfaceDevices); |
| | 1331 | + interfaceDevices.clear(); |
| | 1332 | + |
| | 1333 | + connectionInterfaces.clear(); |
| | 1334 | + |
| | 1335 | + qDeleteAll(ofonoContextManagers); |
| | 1336 | + ofonoContextManagers.clear(); |
| | 1337 | + |
| | 1338 | + qDeleteAll(wiredDevices); |
| | 1339 | + wiredDevices.clear(); |
| | 1340 | } |
| | 1341 | |
| | 1342 | void QNetworkManagerEngine::initialize() |
| | 1343 | { |
| | 1344 | QMutexLocker locker(&mutex); |
| | 1345 | |
| | 1346 | - // Get current list of access points. |
| | 1347 | - foreach (const QDBusObjectPath &devicePath, interface->getDevices()) { |
| | 1348 | + if (ofonoManager->isValid()) { |
| | 1349 | + Q_FOREACH (const QString &modem, ofonoManager->getModems()) { |
| | 1350 | + QOfonoDataConnectionManagerInterface *ofonoContextManager |
| | 1351 | + = new QOfonoDataConnectionManagerInterface(modem,this); |
| | 1352 | + ofonoContextManagers.insert(modem, ofonoContextManager); |
| | 1353 | + } |
| | 1354 | + } |
| | 1355 | + // Get active connections. |
| | 1356 | + foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) { |
| | 1357 | + |
| | 1358 | + QNetworkManagerConnectionActive *activeConnection = |
| | 1359 | + new QNetworkManagerConnectionActive(acPath.path(),this); |
| | 1360 | + activeConnectionsList.insert(acPath.path(), activeConnection); |
| | 1361 | + connect(activeConnection, SIGNAL(propertiesChanged(QMap<QString,QVariant>)), |
| | 1362 | + this, SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>))); |
| | 1363 | + activeConnection->setConnections(); |
| | 1364 | + |
| | 1365 | + QStringList devices = activeConnection->devices(); |
| | 1366 | + if (!devices.isEmpty()) { |
| | 1367 | + QNetworkManagerInterfaceDevice device(devices.at(0),this); |
| | 1368 | + connectionInterfaces.insert(activeConnection->connection().path(),device.networkInterface()); |
| | 1369 | + } |
| | 1370 | + } |
| | 1371 | + |
| | 1372 | + // Get current list of access points. |
| | 1373 | + foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) { |
| | 1374 | locker.unlock(); |
| | 1375 | - deviceAdded(devicePath); |
| | 1376 | + deviceAdded(devicePath); //add all accesspoints |
| | 1377 | locker.relock(); |
| | 1378 | } |
| | 1379 | |
| | 1380 | // Get connections. |
| | 1381 | foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) { |
| | 1382 | locker.unlock(); |
| | 1383 | - newConnection(settingsPath, systemSettings); |
| | 1384 | - locker.relock(); |
| | 1385 | - } |
| | 1386 | - foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) { |
| | 1387 | - locker.unlock(); |
| | 1388 | - newConnection(settingsPath, userSettings); |
| | 1389 | + if (!hasIdentifier(settingsPath.path())) |
| | 1390 | + newConnection(settingsPath, systemSettings); //add system connection configs |
| | 1391 | locker.relock(); |
| | 1392 | } |
| | 1393 | |
| | 1394 | - // Get active connections. |
| | 1395 | - foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { |
| | 1396 | - QNetworkManagerConnectionActive *activeConnection = |
| | 1397 | - new QNetworkManagerConnectionActive(acPath.path()); |
| | 1398 | - activeConnections.insert(acPath.path(), activeConnection); |
| | 1399 | - |
| | 1400 | - activeConnection->setConnections(); |
| | 1401 | - connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)), |
| | 1402 | - this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>))); |
| | 1403 | - } |
| | 1404 | + Q_EMIT updateCompleted(); |
| | 1405 | } |
| | 1406 | |
| | 1407 | bool QNetworkManagerEngine::networkManagerAvailable() const |
| | 1408 | { |
| | 1409 | - QMutexLocker locker(&mutex); |
| | 1410 | - |
| | 1411 | - return interface->isValid(); |
| | 1412 | + return managerInterface->isValid(); |
| | 1413 | } |
| | 1414 | |
| | 1415 | -QString QNetworkManagerEngine::getInterfaceFromId(const QString &id) |
| | 1416 | +QString QNetworkManagerEngine::getInterfaceFromId(const QString &settingsPath) |
| | 1417 | { |
| | 1418 | - QMutexLocker locker(&mutex); |
| | 1419 | - |
| | 1420 | - foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { |
| | 1421 | - QNetworkManagerConnectionActive activeConnection(acPath.path()); |
| | 1422 | - |
| | 1423 | - const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' + |
| | 1424 | - activeConnection.connection().path())); |
| | 1425 | - |
| | 1426 | - if (id == identifier) { |
| | 1427 | - QList<QDBusObjectPath> devices = activeConnection.devices(); |
| | 1428 | - |
| | 1429 | - if (devices.isEmpty()) |
| | 1430 | - continue; |
| | 1431 | - |
| | 1432 | - QNetworkManagerInterfaceDevice device(devices.at(0).path()); |
| | 1433 | - return device.networkInterface(); |
| | 1434 | - } |
| | 1435 | - } |
| | 1436 | - |
| | 1437 | - return QString(); |
| | 1438 | + return connectionInterfaces.value(settingsPath); |
| | 1439 | } |
| | 1440 | |
| | 1441 | bool QNetworkManagerEngine::hasIdentifier(const QString &id) |
| | 1442 | { |
| | 1443 | QMutexLocker locker(&mutex); |
| | 1444 | - |
| | 1445 | - if (connectionFromId(id)) |
| | 1446 | - return true; |
| | 1447 | - |
| | 1448 | - for (int i = 0; i < accessPoints.count(); ++i) { |
| | 1449 | - QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i); |
| | 1450 | - |
| | 1451 | - const QString identifier = |
| | 1452 | - QString::number(qHash(accessPoint->connectionInterface()->path())); |
| | 1453 | - |
| | 1454 | - if (id == identifier) |
| | 1455 | - return true; |
| | 1456 | - } |
| | 1457 | - |
| | 1458 | - return false; |
| | 1459 | + return accessPointConfigurations.contains(id); |
| | 1460 | } |
| | 1461 | |
| | 1462 | void QNetworkManagerEngine::connectToId(const QString &id) |
| | 1463 | @@ -198,47 +174,54 @@ |
| | 1464 | if (!connection) |
| | 1465 | return; |
| | 1466 | |
| | 1467 | - QNmSettingsMap map = connection->getSettings(); |
| | 1468 | - const QString connectionType = map.value("connection").value("type").toString(); |
| | 1469 | + NMDeviceType connectionType = connection->getType(); |
| | 1470 | |
| | 1471 | QString dbusDevicePath; |
| | 1472 | - foreach (const QDBusObjectPath &devicePath, interface->getDevices()) { |
| | 1473 | - QNetworkManagerInterfaceDevice device(devicePath.path()); |
| | 1474 | - if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET && |
| | 1475 | - connectionType == QLatin1String("802-3-ethernet")) { |
| | 1476 | - dbusDevicePath = devicePath.path(); |
| | 1477 | + const QString settingsPath = connection->connectionInterface()->path(); |
| | 1478 | + QString specificPath = configuredAccessPoints.key(settingsPath); |
| | 1479 | + |
| | 1480 | + QHashIterator<QString, QNetworkManagerInterfaceDevice*> i(interfaceDevices); |
| | 1481 | + while (i.hasNext()) { |
| | 1482 | + i.next(); |
| | 1483 | + if (i.value()->deviceType() == DEVICE_TYPE_ETHERNET && |
| | 1484 | + connectionType == DEVICE_TYPE_ETHERNET) { |
| | 1485 | + dbusDevicePath = i.key(); |
| | 1486 | break; |
| | 1487 | - } else if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS && |
| | 1488 | - connectionType == QLatin1String("802-11-wireless")) { |
| | 1489 | - dbusDevicePath = devicePath.path(); |
| | 1490 | + } else if (i.value()->deviceType() == DEVICE_TYPE_WIFI && |
| | 1491 | + connectionType == DEVICE_TYPE_WIFI) { |
| | 1492 | + dbusDevicePath = i.key(); |
| | 1493 | break; |
| | 1494 | - } |
| | 1495 | - else if (device.deviceType() == DEVICE_TYPE_GSM && |
| | 1496 | - connectionType == QLatin1String("gsm")) { |
| | 1497 | - dbusDevicePath = devicePath.path(); |
| | 1498 | + } else if (i.value()->deviceType() == DEVICE_TYPE_MODEM && |
| | 1499 | + connectionType == DEVICE_TYPE_MODEM) { |
| | 1500 | + dbusDevicePath = i.key(); |
| | 1501 | break; |
| | 1502 | } |
| | 1503 | } |
| | 1504 | |
| | 1505 | - const QString service = connection->connectionInterface()->service(); |
| | 1506 | - const QString settingsPath = connection->connectionInterface()->path(); |
| | 1507 | + if (specificPath.isEmpty()) |
| | 1508 | + specificPath = "/"; |
| | 1509 | |
| | 1510 | - interface->activateConnection(service, QDBusObjectPath(settingsPath), |
| | 1511 | - QDBusObjectPath(dbusDevicePath), QDBusObjectPath("/")); |
| | 1512 | + managerInterface->activateConnection(QDBusObjectPath(settingsPath), |
| | 1513 | + QDBusObjectPath(dbusDevicePath), QDBusObjectPath(specificPath)); |
| | 1514 | } |
| | 1515 | |
| | 1516 | void QNetworkManagerEngine::disconnectFromId(const QString &id) |
| | 1517 | { |
| | 1518 | QMutexLocker locker(&mutex); |
| | 1519 | |
| | 1520 | - foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { |
| | 1521 | - QNetworkManagerConnectionActive activeConnection(acPath.path()); |
| | 1522 | - |
| | 1523 | - const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' + |
| | 1524 | - activeConnection.connection().path())); |
| | 1525 | + QNetworkManagerSettingsConnection *connection = connectionFromId(id); |
| | 1526 | + QNmSettingsMap map = connection->getSettings(); |
| | 1527 | + bool connectionAutoconnect = map.value("connection").value("autoconnect",true).toBool(); //if not present is true !! |
| | 1528 | + if (connectionAutoconnect) { //autoconnect connections will simply be reconnected by nm |
| | 1529 | + emit connectionError(id, QBearerEngineImpl::OperationNotSupported); |
| | 1530 | + return; |
| | 1531 | + } |
| | 1532 | |
| | 1533 | - if (id == identifier && accessPointConfigurations.contains(id)) { |
| | 1534 | - interface->deactivateConnection(acPath); |
| | 1535 | + QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList); |
| | 1536 | + while (i.hasNext()) { |
| | 1537 | + i.next(); |
| | 1538 | + if (id == i.value()->connection().path() && accessPointConfigurations.contains(id)) { |
| | 1539 | + managerInterface->deactivateConnection(QDBusObjectPath(i.key())); |
| | 1540 | break; |
| | 1541 | } |
| | 1542 | } |
| | 1543 | @@ -246,16 +229,24 @@ |
| | 1544 | |
| | 1545 | void QNetworkManagerEngine::requestUpdate() |
| | 1546 | { |
| | 1547 | + if (managerInterface->wirelessEnabled()) { |
| | 1548 | + QHashIterator<QString, QNetworkManagerInterfaceDeviceWireless *> i(wirelessDevices); |
| | 1549 | + while (i.hasNext()) { |
| | 1550 | + i.next(); |
| | 1551 | + i.value()->requestScan(); |
| | 1552 | + } |
| | 1553 | + } |
| | 1554 | QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection); |
| | 1555 | } |
| | 1556 | |
| | 1557 | -void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path, |
| | 1558 | - const QMap<QString, QVariant> &properties) |
| | 1559 | +void QNetworkManagerEngine::scanFinished() |
| | 1560 | { |
| | 1561 | - QMutexLocker locker(&mutex); |
| | 1562 | - |
| | 1563 | - Q_UNUSED(path) |
| | 1564 | + QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection); |
| | 1565 | +} |
| | 1566 | |
| | 1567 | +void QNetworkManagerEngine::interfacePropertiesChanged(const QMap<QString, QVariant> &properties) |
| | 1568 | +{ |
| | 1569 | + QMutexLocker locker(&mutex); |
| | 1570 | QMapIterator<QString, QVariant> i(properties); |
| | 1571 | while (i.hasNext()) { |
| | 1572 | i.next(); |
| | 1573 | @@ -267,35 +258,37 @@ |
| | 1574 | qdbus_cast<QList<QDBusObjectPath> >(i.value().value<QDBusArgument>()); |
| | 1575 | |
| | 1576 | QStringList identifiers = accessPointConfigurations.keys(); |
| | 1577 | - foreach (const QString &id, identifiers) |
| | 1578 | - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); |
| | 1579 | - |
| | 1580 | - QStringList priorActiveConnections = this->activeConnections.keys(); |
| | 1581 | + QStringList priorActiveConnections = activeConnectionsList.keys(); |
| | 1582 | |
| | 1583 | foreach (const QDBusObjectPath &acPath, activeConnections) { |
| | 1584 | priorActiveConnections.removeOne(acPath.path()); |
| | 1585 | QNetworkManagerConnectionActive *activeConnection = |
| | 1586 | - this->activeConnections.value(acPath.path()); |
| | 1587 | + activeConnectionsList.value(acPath.path()); |
| | 1588 | + |
| | 1589 | if (!activeConnection) { |
| | 1590 | - activeConnection = new QNetworkManagerConnectionActive(acPath.path()); |
| | 1591 | - this->activeConnections.insert(acPath.path(), activeConnection); |
| | 1592 | + activeConnection = new QNetworkManagerConnectionActive(acPath.path(),this); |
| | 1593 | + activeConnectionsList.insert(acPath.path(), activeConnection); |
| | 1594 | |
| | 1595 | + connect(activeConnection, SIGNAL(propertiesChanged(QMap<QString,QVariant>)), |
| | 1596 | + this, SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>))); |
| | 1597 | activeConnection->setConnections(); |
| | 1598 | - connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)), |
| | 1599 | - this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>))); |
| | 1600 | } |
| | 1601 | |
| | 1602 | - const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' + |
| | 1603 | - activeConnection->connection().path())); |
| | 1604 | + const QString id = activeConnection->connection().path(); |
| | 1605 | |
| | 1606 | identifiers.removeOne(id); |
| | 1607 | |
| | 1608 | QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); |
| | 1609 | if (ptr) { |
| | 1610 | ptr->mutex.lock(); |
| | 1611 | - if (activeConnection->state() == 2 && |
| | 1612 | + if (activeConnection->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED && |
| | 1613 | ptr->state != QNetworkConfiguration::Active) { |
| | 1614 | ptr->state = QNetworkConfiguration::Active; |
| | 1615 | + |
| | 1616 | + if (activeConnectionsList.value(id) && activeConnectionsList.value(id)->defaultRoute() |
| | 1617 | + && managerInterface->state() < QNetworkManagerInterface::NM_STATE_CONNECTED_GLOBAL) { |
| | 1618 | + ptr->purpose = QNetworkConfiguration::PrivatePurpose; |
| | 1619 | + } |
| | 1620 | ptr->mutex.unlock(); |
| | 1621 | |
| | 1622 | locker.unlock(); |
| | 1623 | @@ -308,16 +301,16 @@ |
| | 1624 | } |
| | 1625 | |
| | 1626 | while (!priorActiveConnections.isEmpty()) |
| | 1627 | - delete this->activeConnections.take(priorActiveConnections.takeFirst()); |
| | 1628 | + delete activeConnectionsList.take(priorActiveConnections.takeFirst()); |
| | 1629 | |
| | 1630 | while (!identifiers.isEmpty()) { |
| | 1631 | - // These configurations are not active |
| | 1632 | QNetworkConfigurationPrivatePointer ptr = |
| | 1633 | accessPointConfigurations.value(identifiers.takeFirst()); |
| | 1634 | |
| | 1635 | ptr->mutex.lock(); |
| | 1636 | if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { |
| | 1637 | - ptr->state = QNetworkConfiguration::Discovered; |
| | 1638 | + QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; |
| | 1639 | + ptr->state = (flag | QNetworkConfiguration::Discovered); |
| | 1640 | ptr->mutex.unlock(); |
| | 1641 | |
| | 1642 | locker.unlock(); |
| | 1643 | @@ -331,66 +324,96 @@ |
| | 1644 | } |
| | 1645 | } |
| | 1646 | |
| | 1647 | -void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &path, |
| | 1648 | - const QMap<QString, QVariant> &properties) |
| | 1649 | +void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QMap<QString, QVariant> &properties) |
| | 1650 | { |
| | 1651 | QMutexLocker locker(&mutex); |
| | 1652 | |
| | 1653 | Q_UNUSED(properties) |
| | 1654 | |
| | 1655 | - QNetworkManagerConnectionActive *activeConnection = activeConnections.value(path); |
| | 1656 | + QNetworkManagerConnectionActive *activeConnection = qobject_cast<QNetworkManagerConnectionActive *>(sender()); |
| | 1657 | |
| | 1658 | if (!activeConnection) |
| | 1659 | return; |
| | 1660 | |
| | 1661 | - const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' + |
| | 1662 | - activeConnection->connection().path())); |
| | 1663 | + const QString id = activeConnection->connection().path(); |
| | 1664 | |
| | 1665 | QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); |
| | 1666 | if (ptr) { |
| | 1667 | ptr->mutex.lock(); |
| | 1668 | - if (activeConnection->state() == 2 && |
| | 1669 | - ptr->state != QNetworkConfiguration::Active) { |
| | 1670 | - ptr->state = QNetworkConfiguration::Active; |
| | 1671 | + if (properties.value("State").toUInt() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { |
| | 1672 | + QStringList devices = activeConnection->devices(); |
| | 1673 | + if (!devices.isEmpty()) { |
| | 1674 | + QNetworkManagerInterfaceDevice device(devices.at(0),this); |
| | 1675 | + connectionInterfaces.insert(id,device.networkInterface()); |
| | 1676 | + } |
| | 1677 | + |
| | 1678 | + ptr->state |= QNetworkConfiguration::Active; |
| | 1679 | ptr->mutex.unlock(); |
| | 1680 | |
| | 1681 | locker.unlock(); |
| | 1682 | emit configurationChanged(ptr); |
| | 1683 | locker.relock(); |
| | 1684 | } else { |
| | 1685 | + connectionInterfaces.remove(id); |
| | 1686 | ptr->mutex.unlock(); |
| | 1687 | } |
| | 1688 | } |
| | 1689 | } |
| | 1690 | |
| | 1691 | -void QNetworkManagerEngine::devicePropertiesChanged(const QString &path, |
| | 1692 | - const QMap<QString, QVariant> &properties) |
| | 1693 | +void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &connectionsList) |
| | 1694 | { |
| | 1695 | - Q_UNUSED(path); |
| | 1696 | - Q_UNUSED(properties); |
| | 1697 | + QMutexLocker locker(&mutex); |
| | 1698 | + for (int i = 0; i < connections.count(); ++i) { |
| | 1699 | + if (connectionsList.contains(connections.at(i)->connectionInterface()->path())) |
| | 1700 | + continue; |
| | 1701 | + |
| | 1702 | + const QString settingsPath = connections.at(i)->connectionInterface()->path(); |
| | 1703 | + |
| | 1704 | + QNetworkConfigurationPrivatePointer ptr = |
| | 1705 | + accessPointConfigurations.value(settingsPath); |
| | 1706 | + ptr->mutex.lock(); |
| | 1707 | + QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; |
| | 1708 | + ptr->state = (flag | QNetworkConfiguration::Discovered); |
| | 1709 | + ptr->mutex.unlock(); |
| | 1710 | + |
| | 1711 | + locker.unlock(); |
| | 1712 | + emit configurationChanged(ptr); |
| | 1713 | + locker.relock(); |
| | 1714 | + Q_EMIT updateCompleted(); |
| | 1715 | + } |
| | 1716 | } |
| | 1717 | |
| | 1718 | void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) |
| | 1719 | { |
| | 1720 | - QNetworkManagerInterfaceDevice device(path.path()); |
| | 1721 | - if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) { |
| | 1722 | + QNetworkManagerInterfaceDevice *iDevice; |
| | 1723 | + iDevice = new QNetworkManagerInterfaceDevice(path.path(),this); |
| | 1724 | + connect(iDevice,SIGNAL(connectionsChanged(QStringList)), |
| | 1725 | + this,SLOT(deviceConnectionsChanged(QStringList))); |
| | 1726 | + |
| | 1727 | + iDevice->setConnections(); |
| | 1728 | + interfaceDevices.insert(path.path(),iDevice); |
| | 1729 | + if (iDevice->deviceType() == DEVICE_TYPE_WIFI) { |
| | 1730 | QNetworkManagerInterfaceDeviceWireless *wirelessDevice = |
| | 1731 | - new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path()); |
| | 1732 | + new QNetworkManagerInterfaceDeviceWireless(iDevice->connectionInterface()->path(),this); |
| | 1733 | |
| | 1734 | + connect(wirelessDevice, SIGNAL(accessPointAdded(QString)), |
| | 1735 | + this, SLOT(newAccessPoint(QString))); |
| | 1736 | + connect(wirelessDevice, SIGNAL(accessPointRemoved(QString)), |
| | 1737 | + this, SLOT(removeAccessPoint(QString))); |
| | 1738 | + connect(wirelessDevice,SIGNAL(scanDone()),this,SLOT(scanFinished())); |
| | 1739 | wirelessDevice->setConnections(); |
| | 1740 | - connect(wirelessDevice, SIGNAL(accessPointAdded(QString,QDBusObjectPath)), |
| | 1741 | - this, SLOT(newAccessPoint(QString,QDBusObjectPath))); |
| | 1742 | - connect(wirelessDevice, SIGNAL(accessPointRemoved(QString,QDBusObjectPath)), |
| | 1743 | - this, SLOT(removeAccessPoint(QString,QDBusObjectPath))); |
| | 1744 | - connect(wirelessDevice, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)), |
| | 1745 | - this, SLOT(devicePropertiesChanged(QString,QMap<QString,QVariant>))); |
| | 1746 | |
| | 1747 | foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints()) |
| | 1748 | - newAccessPoint(QString(), apPath); |
| | 1749 | + newAccessPoint(apPath.path()); |
| | 1750 | |
| | 1751 | - mutex.lock(); |
| | 1752 | wirelessDevices.insert(path.path(), wirelessDevice); |
| | 1753 | - mutex.unlock(); |
| | 1754 | + } |
| | 1755 | + |
| | 1756 | + if (iDevice->deviceType() == DEVICE_TYPE_ETHERNET) { |
| | 1757 | + QNetworkManagerInterfaceDeviceWired *wiredDevice = |
| | 1758 | + new QNetworkManagerInterfaceDeviceWired(iDevice->connectionInterface()->path(),this); |
| | 1759 | + connect(wiredDevice,SIGNAL(carrierChanged(bool)),this,SLOT(wiredCarrierChanged(bool))); |
| | 1760 | + wiredDevices.insert(iDevice->connectionInterface()->path(), wiredDevice); |
| | 1761 | } |
| | 1762 | } |
| | 1763 | |
| | 1764 | @@ -398,50 +421,126 @@ |
| | 1765 | { |
| | 1766 | QMutexLocker locker(&mutex); |
| | 1767 | |
| | 1768 | - delete wirelessDevices.take(path.path()); |
| | 1769 | + if (interfaceDevices.contains(path.path())) { |
| | 1770 | + locker.unlock(); |
| | 1771 | + delete interfaceDevices.take(path.path()); |
| | 1772 | + locker.relock(); |
| | 1773 | + } |
| | 1774 | + if (wirelessDevices.contains(path.path())) { |
| | 1775 | + locker.unlock(); |
| | 1776 | + delete wirelessDevices.take(path.path()); |
| | 1777 | + locker.relock(); |
| | 1778 | + } |
| | 1779 | + if (wiredDevices.contains(path.path())) { |
| | 1780 | + locker.unlock(); |
| | 1781 | + delete wiredDevices.take(path.path()); |
| | 1782 | + locker.relock(); |
| | 1783 | + } |
| | 1784 | +} |
| | 1785 | + |
| | 1786 | +void QNetworkManagerEngine::wiredCarrierChanged(bool carrier) |
| | 1787 | +{ |
| | 1788 | + QNetworkManagerInterfaceDeviceWired *deviceWired = qobject_cast<QNetworkManagerInterfaceDeviceWired *>(sender()); |
| | 1789 | + if (!deviceWired) |
| | 1790 | + return; |
| | 1791 | + QMutexLocker locker(&mutex); |
| | 1792 | + foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) { |
| | 1793 | + for (int i = 0; i < connections.count(); ++i) { |
| | 1794 | + QNetworkManagerSettingsConnection *connection = connections.at(i); |
| | 1795 | + if (connection->getType() == DEVICE_TYPE_ETHERNET |
| | 1796 | + && settingsPath.path() == connection->connectionInterface()->path()) { |
| | 1797 | + QNetworkConfigurationPrivatePointer ptr = |
| | 1798 | + accessPointConfigurations.value(settingsPath.path()); |
| | 1799 | + |
| | 1800 | + if (ptr) { |
| | 1801 | + ptr->mutex.lock(); |
| | 1802 | + if (carrier) |
| | 1803 | + ptr->state |= QNetworkConfiguration::Discovered; |
| | 1804 | + else |
| | 1805 | + ptr->state = QNetworkConfiguration::Defined; |
| | 1806 | + ptr->mutex.unlock(); |
| | 1807 | + locker.unlock(); |
| | 1808 | + emit configurationChanged(ptr); |
| | 1809 | + return; |
| | 1810 | + } |
| | 1811 | + } |
| | 1812 | + } |
| | 1813 | + } |
| | 1814 | } |
| | 1815 | |
| | 1816 | void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, |
| | 1817 | QNetworkManagerSettings *settings) |
| | 1818 | { |
| | 1819 | QMutexLocker locker(&mutex); |
| | 1820 | - |
| | 1821 | if (!settings) |
| | 1822 | settings = qobject_cast<QNetworkManagerSettings *>(sender()); |
| | 1823 | |
| | 1824 | - if (!settings) |
| | 1825 | + if (!settings) { |
| | 1826 | return; |
| | 1827 | + } |
| | 1828 | |
| | 1829 | QNetworkManagerSettingsConnection *connection = |
| | 1830 | new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(), |
| | 1831 | - path.path()); |
| | 1832 | + path.path(),this); |
| | 1833 | + const QString settingsPath = connection->connectionInterface()->path(); |
| | 1834 | + if (accessPointConfigurations.contains(settingsPath)) { |
| | 1835 | + return; |
| | 1836 | + } |
| | 1837 | + |
| | 1838 | connections.append(connection); |
| | 1839 | |
| | 1840 | - connect(connection, SIGNAL(removed(QString)), this, SLOT(removeConnection(QString))); |
| | 1841 | - connect(connection, SIGNAL(updated(QNmSettingsMap)), |
| | 1842 | - this, SLOT(updateConnection(QNmSettingsMap))); |
| | 1843 | + connect(connection,SIGNAL(removed(QString)),this,SLOT(removeConnection(QString))); |
| | 1844 | + connect(connection,SIGNAL(updated()),this,SLOT(updateConnection())); |
| | 1845 | + connection->setConnections(); |
| | 1846 | |
| | 1847 | - const QString service = connection->connectionInterface()->service(); |
| | 1848 | - const QString settingsPath = connection->connectionInterface()->path(); |
| | 1849 | + NMDeviceType deviceType = connection->getType(); |
| | 1850 | + |
| | 1851 | + if (deviceType == DEVICE_TYPE_WIFI) { |
| | 1852 | + QString apPath; |
| | 1853 | + for (int i = 0; i < accessPoints.count(); ++i) { |
| | 1854 | + if (connection->getSsid() == accessPoints.at(i)->ssid()) { |
| | 1855 | + // remove the corresponding accesspoint from configurations |
| | 1856 | + apPath = accessPoints.at(i)->connectionInterface()->path(); |
| | 1857 | + QNetworkConfigurationPrivatePointer ptr |
| | 1858 | + = accessPointConfigurations.take(apPath); |
| | 1859 | + if (ptr) { |
| | 1860 | + locker.unlock(); |
| | 1861 | + emit configurationRemoved(ptr); |
| | 1862 | + locker.relock(); |
| | 1863 | + } |
| | 1864 | + } |
| | 1865 | + } |
| | 1866 | + if (!configuredAccessPoints.contains(settingsPath)) |
| | 1867 | + configuredAccessPoints.insert(apPath,settingsPath); |
| | 1868 | + } |
| | 1869 | |
| | 1870 | QNetworkConfigurationPrivate *cpPriv = |
| | 1871 | - parseConnection(service, settingsPath, connection->getSettings()); |
| | 1872 | + parseConnection(settingsPath, connection->getSettings()); |
| | 1873 | |
| | 1874 | // Check if connection is active. |
| | 1875 | - foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { |
| | 1876 | - QNetworkManagerConnectionActive activeConnection(acPath.path()); |
| | 1877 | - |
| | 1878 | - if (activeConnection.serviceName() == service && |
| | 1879 | - activeConnection.connection().path() == settingsPath && |
| | 1880 | - activeConnection.state() == 2) { |
| | 1881 | + QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList); |
| | 1882 | + while (i.hasNext()) { |
| | 1883 | + i.next(); |
| | 1884 | + if (i.value()->connection().path() == settingsPath) { |
| | 1885 | cpPriv->state |= QNetworkConfiguration::Active; |
| | 1886 | break; |
| | 1887 | } |
| | 1888 | } |
| | 1889 | - |
| | 1890 | + if (deviceType == DEVICE_TYPE_ETHERNET) { |
| | 1891 | + QHashIterator<QString, QNetworkManagerInterfaceDevice*> i(interfaceDevices); |
| | 1892 | + while (i.hasNext()) { |
| | 1893 | + i.next(); |
| | 1894 | + if (i.value()->deviceType() == deviceType) { |
| | 1895 | + QNetworkManagerInterfaceDeviceWired *wiredDevice |
| | 1896 | + = wiredDevices.value(i.value()->connectionInterface()->path()); |
| | 1897 | + if (wiredDevice->carrier()) { |
| | 1898 | + cpPriv->state |= QNetworkConfiguration::Discovered; |
| | 1899 | + } |
| | 1900 | + } |
| | 1901 | + } |
| | 1902 | + } |
| | 1903 | QNetworkConfigurationPrivatePointer ptr(cpPriv); |
| | 1904 | accessPointConfigurations.insert(ptr->id, ptr); |
| | 1905 | - |
| | 1906 | locker.unlock(); |
| | 1907 | emit configurationAdded(ptr); |
| | 1908 | } |
| | 1909 | @@ -450,27 +549,36 @@ |
| | 1910 | { |
| | 1911 | QMutexLocker locker(&mutex); |
| | 1912 | |
| | 1913 | - Q_UNUSED(path) |
| | 1914 | - |
| | 1915 | QNetworkManagerSettingsConnection *connection = |
| | 1916 | qobject_cast<QNetworkManagerSettingsConnection *>(sender()); |
| | 1917 | + |
| | 1918 | if (!connection) |
| | 1919 | return; |
| | 1920 | |
| | 1921 | + connection->deleteLater(); |
| | 1922 | connections.removeAll(connection); |
| | 1923 | |
| | 1924 | - const QString id = QString::number(qHash(connection->connectionInterface()->service() + ' ' + |
| | 1925 | - connection->connectionInterface()->path())); |
| | 1926 | + const QString id = path; |
| | 1927 | |
| | 1928 | QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id); |
| | 1929 | |
| | 1930 | - connection->deleteLater(); |
| | 1931 | - |
| | 1932 | - locker.unlock(); |
| | 1933 | - emit configurationRemoved(ptr); |
| | 1934 | + if (ptr) { |
| | 1935 | + locker.unlock(); |
| | 1936 | + emit configurationRemoved(ptr); |
| | 1937 | + locker.relock(); |
| | 1938 | + } |
| | 1939 | + // add base AP back into configurations |
| | 1940 | + QMapIterator<QString, QString> i(configuredAccessPoints); |
| | 1941 | + while (i.hasNext()) { |
| | 1942 | + i.next(); |
| | 1943 | + if (i.value() == path) { |
| | 1944 | + configuredAccessPoints.remove(i.key()); |
| | 1945 | + newAccessPoint(i.key()); |
| | 1946 | + } |
| | 1947 | + } |
| | 1948 | } |
| | 1949 | |
| | 1950 | -void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings) |
| | 1951 | +void QNetworkManagerEngine::updateConnection() |
| | 1952 | { |
| | 1953 | QMutexLocker locker(&mutex); |
| | 1954 | |
| | 1955 | @@ -478,18 +586,15 @@ |
| | 1956 | qobject_cast<QNetworkManagerSettingsConnection *>(sender()); |
| | 1957 | if (!connection) |
| | 1958 | return; |
| | 1959 | - |
| | 1960 | - const QString service = connection->connectionInterface()->service(); |
| | 1961 | const QString settingsPath = connection->connectionInterface()->path(); |
| | 1962 | |
| | 1963 | - QNetworkConfigurationPrivate *cpPriv = parseConnection(service, settingsPath, settings); |
| | 1964 | + QNetworkConfigurationPrivate *cpPriv = parseConnection(settingsPath, connection->getSettings()); |
| | 1965 | |
| | 1966 | // Check if connection is active. |
| | 1967 | - foreach (const QDBusObjectPath &acPath, interface->activeConnections()) { |
| | 1968 | + foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) { |
| | 1969 | QNetworkManagerConnectionActive activeConnection(acPath.path()); |
| | 1970 | |
| | 1971 | - if (activeConnection.serviceName() == service && |
| | 1972 | - activeConnection.connection().path() == settingsPath && |
| | 1973 | + if (activeConnection.connection().path() == settingsPath && |
| | 1974 | activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { |
| | 1975 | cpPriv->state |= QNetworkConfiguration::Active; |
| | 1976 | break; |
| | 1977 | @@ -509,28 +614,29 @@ |
| | 1978 | |
| | 1979 | locker.unlock(); |
| | 1980 | emit configurationChanged(ptr); |
| | 1981 | + locker.relock(); |
| | 1982 | delete cpPriv; |
| | 1983 | } |
| | 1984 | |
| | 1985 | void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher) |
| | 1986 | { |
| | 1987 | QMutexLocker locker(&mutex); |
| | 1988 | - |
| | 1989 | QDBusPendingReply<QDBusObjectPath> reply(*watcher); |
| | 1990 | + watcher->deleteLater(); |
| | 1991 | + |
| | 1992 | if (!reply.isError()) { |
| | 1993 | QDBusObjectPath result = reply.value(); |
| | 1994 | |
| | 1995 | QNetworkManagerConnectionActive activeConnection(result.path()); |
| | 1996 | |
| | 1997 | - const QString id = QString::number(qHash(activeConnection.serviceName() + ' ' + |
| | 1998 | - activeConnection.connection().path())); |
| | 1999 | + const QString id = activeConnection.connection().path(); |
| | 2000 | |
| | 2001 | QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); |
| | 2002 | if (ptr) { |
| | 2003 | ptr->mutex.lock(); |
| | 2004 | - if (activeConnection.state() == 2 && |
| | 2005 | + if (activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED && |
| | 2006 | ptr->state != QNetworkConfiguration::Active) { |
| | 2007 | - ptr->state = QNetworkConfiguration::Active; |
| | 2008 | + ptr->state |= QNetworkConfiguration::Active; |
| | 2009 | ptr->mutex.unlock(); |
| | 2010 | |
| | 2011 | locker.unlock(); |
| | 2012 | @@ -543,42 +649,40 @@ |
| | 2013 | } |
| | 2014 | } |
| | 2015 | |
| | 2016 | -void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjectPath &objectPath) |
| | 2017 | +void QNetworkManagerEngine::newAccessPoint(const QString &path) |
| | 2018 | { |
| | 2019 | QMutexLocker locker(&mutex); |
| | 2020 | |
| | 2021 | - Q_UNUSED(path) |
| | 2022 | - |
| | 2023 | QNetworkManagerInterfaceAccessPoint *accessPoint = |
| | 2024 | - new QNetworkManagerInterfaceAccessPoint(objectPath.path()); |
| | 2025 | - accessPoints.append(accessPoint); |
| | 2026 | + new QNetworkManagerInterfaceAccessPoint(path,this); |
| | 2027 | |
| | 2028 | - accessPoint->setConnections(); |
| | 2029 | - connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)), |
| | 2030 | - this, SLOT(updateAccessPoint(QMap<QString,QVariant>))); |
| | 2031 | - |
| | 2032 | - // Check if configuration for this SSID already exists. |
| | 2033 | + bool okToAdd = true; |
| | 2034 | for (int i = 0; i < accessPoints.count(); ++i) { |
| | 2035 | - if (accessPoint != accessPoints.at(i) && |
| | 2036 | - accessPoint->ssid() == accessPoints.at(i)->ssid()) { |
| | 2037 | - return; |
| | 2038 | + if (accessPoints.at(i)->connectionInterface()->path() == path) { |
| | 2039 | + okToAdd = false; |
| | 2040 | } |
| | 2041 | } |
| | 2042 | - |
| | 2043 | + if (okToAdd) { |
| | 2044 | + accessPoints.append(accessPoint); |
| | 2045 | + accessPoint->setConnections(); |
| | 2046 | + } |
| | 2047 | // Check if configuration exists for connection. |
| | 2048 | if (!accessPoint->ssid().isEmpty()) { |
| | 2049 | + |
| | 2050 | for (int i = 0; i < connections.count(); ++i) { |
| | 2051 | QNetworkManagerSettingsConnection *connection = connections.at(i); |
| | 2052 | + const QString settingsPath = connection->connectionInterface()->path(); |
| | 2053 | |
| | 2054 | if (accessPoint->ssid() == connection->getSsid()) { |
| | 2055 | - const QString service = connection->connectionInterface()->service(); |
| | 2056 | - const QString settingsPath = connection->connectionInterface()->path(); |
| | 2057 | - const QString connectionId = QString::number(qHash(service + ' ' + settingsPath)); |
| | 2058 | + if (!configuredAccessPoints.contains(path)) { |
| | 2059 | + configuredAccessPoints.insert(path,settingsPath); |
| | 2060 | + } |
| | 2061 | |
| | 2062 | QNetworkConfigurationPrivatePointer ptr = |
| | 2063 | - accessPointConfigurations.value(connectionId); |
| | 2064 | + accessPointConfigurations.value(settingsPath); |
| | 2065 | ptr->mutex.lock(); |
| | 2066 | - ptr->state = QNetworkConfiguration::Discovered; |
| | 2067 | + QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; |
| | 2068 | + ptr->state = (flag | QNetworkConfiguration::Discovered); |
| | 2069 | ptr->mutex.unlock(); |
| | 2070 | |
| | 2071 | locker.unlock(); |
| | 2072 | @@ -593,13 +697,9 @@ |
| | 2073 | |
| | 2074 | ptr->name = accessPoint->ssid(); |
| | 2075 | ptr->isValid = true; |
| | 2076 | - ptr->id = QString::number(qHash(objectPath.path())); |
| | 2077 | + ptr->id = path; |
| | 2078 | ptr->type = QNetworkConfiguration::InternetAccessPoint; |
| | 2079 | - if(accessPoint->flags() == NM_802_11_AP_FLAGS_PRIVACY) { |
| | 2080 | - ptr->purpose = QNetworkConfiguration::PrivatePurpose; |
| | 2081 | - } else { |
| | 2082 | - ptr->purpose = QNetworkConfiguration::PublicPurpose; |
| | 2083 | - } |
| | 2084 | + ptr->purpose = QNetworkConfiguration::PublicPurpose; |
| | 2085 | ptr->state = QNetworkConfiguration::Undefined; |
| | 2086 | ptr->bearerType = QNetworkConfiguration::BearerWLAN; |
| | 2087 | |
| | 2088 | @@ -609,30 +709,24 @@ |
| | 2089 | emit configurationAdded(ptr); |
| | 2090 | } |
| | 2091 | |
| | 2092 | -void QNetworkManagerEngine::removeAccessPoint(const QString &path, |
| | 2093 | - const QDBusObjectPath &objectPath) |
| | 2094 | +void QNetworkManagerEngine::removeAccessPoint(const QString &path) |
| | 2095 | { |
| | 2096 | QMutexLocker locker(&mutex); |
| | 2097 | - |
| | 2098 | - Q_UNUSED(path) |
| | 2099 | - |
| | 2100 | for (int i = 0; i < accessPoints.count(); ++i) { |
| | 2101 | QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i); |
| | 2102 | - |
| | 2103 | - if (accessPoint->connectionInterface()->path() == objectPath.path()) { |
| | 2104 | + if (accessPoint->connectionInterface()->path() == path) { |
| | 2105 | accessPoints.removeOne(accessPoint); |
| | 2106 | |
| | 2107 | - if (configuredAccessPoints.contains(accessPoint)) { |
| | 2108 | + if (configuredAccessPoints.contains(accessPoint->connectionInterface()->path())) { |
| | 2109 | // find connection and change state to Defined |
| | 2110 | - configuredAccessPoints.removeOne(accessPoint); |
| | 2111 | + configuredAccessPoints.remove(accessPoint->connectionInterface()->path()); |
| | 2112 | + |
| | 2113 | for (int i = 0; i < connections.count(); ++i) { |
| | 2114 | QNetworkManagerSettingsConnection *connection = connections.at(i); |
| | 2115 | |
| | 2116 | - if (accessPoint->ssid() == connection->getSsid()) { |
| | 2117 | - const QString service = connection->connectionInterface()->service(); |
| | 2118 | + if (accessPoint->ssid() == connection->getSsid()) {//might not have bssid yet |
| | 2119 | const QString settingsPath = connection->connectionInterface()->path(); |
| | 2120 | - const QString connectionId = |
| | 2121 | - QString::number(qHash(service + ' ' + settingsPath)); |
| | 2122 | + const QString connectionId = settingsPath; |
| | 2123 | |
| | 2124 | QNetworkConfigurationPrivatePointer ptr = |
| | 2125 | accessPointConfigurations.value(connectionId); |
| | 2126 | @@ -648,7 +742,7 @@ |
| | 2127 | } |
| | 2128 | } else { |
| | 2129 | QNetworkConfigurationPrivatePointer ptr = |
| | 2130 | - accessPointConfigurations.take(QString::number(qHash(objectPath.path()))); |
| | 2131 | + accessPointConfigurations.take(path); |
| | 2132 | |
| | 2133 | if (ptr) { |
| | 2134 | locker.unlock(); |
| | 2135 | @@ -656,111 +750,74 @@ |
| | 2136 | locker.relock(); |
| | 2137 | } |
| | 2138 | } |
| | 2139 | - |
| | 2140 | delete accessPoint; |
| | 2141 | - |
| | 2142 | break; |
| | 2143 | } |
| | 2144 | } |
| | 2145 | } |
| | 2146 | |
| | 2147 | -void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map) |
| | 2148 | -{ |
| | 2149 | - QMutexLocker locker(&mutex); |
| | 2150 | - |
| | 2151 | - Q_UNUSED(map) |
| | 2152 | - |
| | 2153 | - QNetworkManagerInterfaceAccessPoint *accessPoint = |
| | 2154 | - qobject_cast<QNetworkManagerInterfaceAccessPoint *>(sender()); |
| | 2155 | - if (!accessPoint) |
| | 2156 | - return; |
| | 2157 | - |
| | 2158 | - for (int i = 0; i < connections.count(); ++i) { |
| | 2159 | - QNetworkManagerSettingsConnection *connection = connections.at(i); |
| | 2160 | - |
| | 2161 | - if (accessPoint->ssid() == connection->getSsid()) { |
| | 2162 | - const QString service = connection->connectionInterface()->service(); |
| | 2163 | - const QString settingsPath = connection->connectionInterface()->path(); |
| | 2164 | - const QString connectionId = QString::number(qHash(service + ' ' + settingsPath)); |
| | 2165 | - |
| | 2166 | - QNetworkConfigurationPrivatePointer ptr = |
| | 2167 | - accessPointConfigurations.value(connectionId); |
| | 2168 | - ptr->mutex.lock(); |
| | 2169 | - ptr->state = QNetworkConfiguration::Discovered; |
| | 2170 | - ptr->mutex.unlock(); |
| | 2171 | - |
| | 2172 | - locker.unlock(); |
| | 2173 | - emit configurationChanged(ptr); |
| | 2174 | - return; |
| | 2175 | - } |
| | 2176 | - } |
| | 2177 | -} |
| | 2178 | - |
| | 2179 | -QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &service, |
| | 2180 | - const QString &settingsPath, |
| | 2181 | +QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &settingsPath, |
| | 2182 | const QNmSettingsMap &map) |
| | 2183 | { |
| | 2184 | + QMutexLocker locker(&mutex); |
| | 2185 | QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate; |
| | 2186 | cpPriv->name = map.value("connection").value("id").toString(); |
| | 2187 | + |
| | 2188 | cpPriv->isValid = true; |
| | 2189 | - cpPriv->id = QString::number(qHash(service + ' ' + settingsPath)); |
| | 2190 | + cpPriv->id = settingsPath; |
| | 2191 | cpPriv->type = QNetworkConfiguration::InternetAccessPoint; |
| | 2192 | |
| | 2193 | cpPriv->purpose = QNetworkConfiguration::PublicPurpose; |
| | 2194 | |
| | 2195 | cpPriv->state = QNetworkConfiguration::Defined; |
| | 2196 | - |
| | 2197 | const QString connectionType = map.value("connection").value("type").toString(); |
| | 2198 | |
| | 2199 | if (connectionType == QLatin1String("802-3-ethernet")) { |
| | 2200 | cpPriv->bearerType = QNetworkConfiguration::BearerEthernet; |
| | 2201 | - cpPriv->purpose = QNetworkConfiguration::PublicPurpose; |
| | 2202 | |
| | 2203 | - foreach (const QDBusObjectPath &devicePath, interface->getDevices()) { |
| | 2204 | - QNetworkManagerInterfaceDevice device(devicePath.path()); |
| | 2205 | - if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET) { |
| | 2206 | - QNetworkManagerInterfaceDeviceWired wiredDevice(device.connectionInterface()->path()); |
| | 2207 | - if (wiredDevice.carrier()) { |
| | 2208 | + foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) { |
| | 2209 | + QNetworkManagerInterfaceDevice device(devicePath.path(),this); |
| | 2210 | + if (device.deviceType() == DEVICE_TYPE_ETHERNET) { |
| | 2211 | + QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.connectionInterface()->path()); |
| | 2212 | + if (wiredDevice->carrier()) { |
| | 2213 | cpPriv->state |= QNetworkConfiguration::Discovered; |
| | 2214 | break; |
| | 2215 | } |
| | 2216 | - |
| | 2217 | } |
| | 2218 | } |
| | 2219 | } else if (connectionType == QLatin1String("802-11-wireless")) { |
| | 2220 | cpPriv->bearerType = QNetworkConfiguration::BearerWLAN; |
| | 2221 | |
| | 2222 | const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString(); |
| | 2223 | - const QString connectionSecurity = map.value("802-11-wireless").value("security").toString(); |
| | 2224 | - if(!connectionSecurity.isEmpty()) { |
| | 2225 | - cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; |
| | 2226 | - } else { |
| | 2227 | - cpPriv->purpose = QNetworkConfiguration::PublicPurpose; |
| | 2228 | - } |
| | 2229 | for (int i = 0; i < accessPoints.count(); ++i) { |
| | 2230 | - if (connectionSsid == accessPoints.at(i)->ssid()) { |
| | 2231 | + if (connectionSsid == accessPoints.at(i)->ssid() |
| | 2232 | + && map.value("802-11-wireless").value("seen-bssids").toStringList().contains(accessPoints.at(i)->hwAddress())) { |
| | 2233 | cpPriv->state |= QNetworkConfiguration::Discovered; |
| | 2234 | - if (!configuredAccessPoints.contains(accessPoints.at(i))) { |
| | 2235 | - configuredAccessPoints.append(accessPoints.at(i)); |
| | 2236 | + if (!configuredAccessPoints.contains(accessPoints.at(i)->connectionInterface()->path())) { |
| | 2237 | + configuredAccessPoints.insert(accessPoints.at(i)->connectionInterface()->path(),settingsPath); |
| | 2238 | |
| | 2239 | - const QString accessPointId = |
| | 2240 | - QString::number(qHash(accessPoints.at(i)->connectionInterface()->path())); |
| | 2241 | + const QString accessPointId = accessPoints.at(i)->connectionInterface()->path(); |
| | 2242 | QNetworkConfigurationPrivatePointer ptr = |
| | 2243 | accessPointConfigurations.take(accessPointId); |
| | 2244 | |
| | 2245 | if (ptr) { |
| | 2246 | - mutex.unlock(); |
| | 2247 | + locker.unlock(); |
| | 2248 | emit configurationRemoved(ptr); |
| | 2249 | - mutex.lock(); |
| | 2250 | + locker.relock(); |
| | 2251 | } |
| | 2252 | } |
| | 2253 | break; |
| | 2254 | } |
| | 2255 | } |
| | 2256 | - } else if (connectionType == "gsm") { |
| | 2257 | - cpPriv->bearerType = QNetworkConfiguration::Bearer2G; |
| | 2258 | - } else if (connectionType == "cdma") { |
| | 2259 | - cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000; |
| | 2260 | + } else if (connectionType == QLatin1String("gsm")) { |
| | 2261 | + |
| | 2262 | + const QString contextPath = map.value("connection").value("id").toString(); |
| | 2263 | + cpPriv->name = contextName(contextPath); |
| | 2264 | + cpPriv->bearerType = currentBearerType(contextPath); |
| | 2265 | + |
| | 2266 | + if (map.value("connection").contains("timestamp")) { |
| | 2267 | + cpPriv->state |= QNetworkConfiguration::Discovered; |
| | 2268 | + } |
| | 2269 | } |
| | 2270 | |
| | 2271 | return cpPriv; |
| | 2272 | @@ -770,12 +827,7 @@ |
| | 2273 | { |
| | 2274 | for (int i = 0; i < connections.count(); ++i) { |
| | 2275 | QNetworkManagerSettingsConnection *connection = connections.at(i); |
| | 2276 | - const QString service = connection->connectionInterface()->service(); |
| | 2277 | - const QString settingsPath = connection->connectionInterface()->path(); |
| | 2278 | - |
| | 2279 | - const QString identifier = QString::number(qHash(service + ' ' + settingsPath)); |
| | 2280 | - |
| | 2281 | - if (id == identifier) |
| | 2282 | + if (id == connection->connectionInterface()->path()) |
| | 2283 | return connection; |
| | 2284 | } |
| | 2285 | |
| | 2286 | @@ -785,7 +837,6 @@ |
| | 2287 | QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &id) |
| | 2288 | { |
| | 2289 | QMutexLocker locker(&mutex); |
| | 2290 | - |
| | 2291 | QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); |
| | 2292 | |
| | 2293 | if (!ptr) |
| | 2294 | @@ -794,11 +845,10 @@ |
| | 2295 | if (!ptr->isValid) |
| | 2296 | return QNetworkSession::Invalid; |
| | 2297 | |
| | 2298 | - foreach (const QString &acPath, activeConnections.keys()) { |
| | 2299 | - QNetworkManagerConnectionActive *activeConnection = activeConnections.value(acPath); |
| | 2300 | + foreach (const QString &acPath, activeConnectionsList.keys()) { |
| | 2301 | + QNetworkManagerConnectionActive *activeConnection = activeConnectionsList.value(acPath); |
| | 2302 | |
| | 2303 | - const QString identifier = QString::number(qHash(activeConnection->serviceName() + ' ' + |
| | 2304 | - activeConnection->connection().path())); |
| | 2305 | + const QString identifier = activeConnection->connection().path(); |
| | 2306 | |
| | 2307 | if (id == identifier) { |
| | 2308 | switch (activeConnection->state()) { |
| | 2309 | @@ -828,7 +878,7 @@ |
| | 2310 | |
| | 2311 | QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); |
| | 2312 | if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { |
| | 2313 | - const QString networkInterface = getInterfaceFromId(id); |
| | 2314 | + const QString networkInterface = connectionInterfaces.value(id); |
| | 2315 | if (!networkInterface.isEmpty()) { |
| | 2316 | const QString devFile = QLatin1String("/sys/class/net/") + |
| | 2317 | networkInterface + |
| | 2318 | @@ -856,7 +906,7 @@ |
| | 2319 | |
| | 2320 | QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); |
| | 2321 | if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { |
| | 2322 | - const QString networkInterface = getInterfaceFromId(id); |
| | 2323 | + const QString networkInterface = connectionInterfaces.value(id); |
| | 2324 | if (!networkInterface.isEmpty()) { |
| | 2325 | const QString devFile = QLatin1String("/sys/class/net/") + |
| | 2326 | networkInterface + |
| | 2327 | @@ -892,7 +942,8 @@ |
| | 2328 | QNetworkConfigurationManager::Capabilities QNetworkManagerEngine::capabilities() const |
| | 2329 | { |
| | 2330 | return QNetworkConfigurationManager::ForcedRoaming | |
| | 2331 | - QNetworkConfigurationManager::CanStartAndStopInterfaces; |
| | 2332 | + QNetworkConfigurationManager::DataStatistics | |
| | 2333 | + QNetworkConfigurationManager::CanStartAndStopInterfaces; |
| | 2334 | } |
| | 2335 | |
| | 2336 | QNetworkSessionPrivate *QNetworkManagerEngine::createSessionBackend() |
| | 2337 | @@ -902,9 +953,67 @@ |
| | 2338 | |
| | 2339 | QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration() |
| | 2340 | { |
| | 2341 | + QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList); |
| | 2342 | + while (i.hasNext()) { |
| | 2343 | + i.next(); |
| | 2344 | + QNetworkManagerConnectionActive *activeConnection = i.value(); |
| | 2345 | + if ((activeConnection->defaultRoute() || activeConnection->default6Route())) { |
| | 2346 | + return accessPointConfigurations.value(activeConnection->connection().path()); |
| | 2347 | + } |
| | 2348 | + } |
| | 2349 | + |
| | 2350 | return QNetworkConfigurationPrivatePointer(); |
| | 2351 | } |
| | 2352 | |
| | 2353 | +QNetworkConfiguration::BearerType QNetworkManagerEngine::currentBearerType(const QString &id) |
| | 2354 | +{ |
| | 2355 | + if (ofonoManager->isValid()) { |
| | 2356 | + QString contextPart = id.section('/', -1); |
| | 2357 | + |
| | 2358 | + QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers); |
| | 2359 | + while (i.hasNext()) { |
| | 2360 | + i.next(); |
| | 2361 | + QString contextPath = i.key() +"/"+contextPart; |
| | 2362 | + if (i.value()->contexts().contains(contextPath)) { |
| | 2363 | + |
| | 2364 | + QString bearer = i.value()->bearer(); |
| | 2365 | + if (bearer == QStringLiteral("gsm")) { |
| | 2366 | + return QNetworkConfiguration::Bearer2G; |
| | 2367 | + } else if (bearer == QStringLiteral("edge")) { |
| | 2368 | + return QNetworkConfiguration::Bearer2G; |
| | 2369 | + } else if (bearer == QStringLiteral("umts")) { |
| | 2370 | + return QNetworkConfiguration::BearerWCDMA; |
| | 2371 | + } else if (bearer == QStringLiteral("hspa") |
| | 2372 | + || bearer == QStringLiteral("hsdpa") |
| | 2373 | + || bearer == QStringLiteral("hsupa")) { |
| | 2374 | + return QNetworkConfiguration::BearerHSPA; |
| | 2375 | + } else if (bearer == QStringLiteral("lte")) { |
| | 2376 | + return QNetworkConfiguration::BearerLTE; |
| | 2377 | + } |
| | 2378 | + } |
| | 2379 | + } |
| | 2380 | + } |
| | 2381 | + return QNetworkConfiguration::BearerUnknown; |
| | 2382 | +} |
| | 2383 | + |
| | 2384 | +QString QNetworkManagerEngine::contextName(const QString &path) |
| | 2385 | +{ |
| | 2386 | + if (ofonoManager->isValid()) { |
| | 2387 | + QString contextPart = path.section('/', -1); |
| | 2388 | + QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers); |
| | 2389 | + while (i.hasNext()) { |
| | 2390 | + i.next(); |
| | 2391 | + Q_FOREACH (const QString &oContext, i.value()->contexts()) { |
| | 2392 | + if (oContext.contains(contextPart)) { |
| | 2393 | + QOfonoConnectionContextInterface contextInterface(oContext,this); |
| | 2394 | + return contextInterface.name(); |
| | 2395 | + } |
| | 2396 | + } |
| | 2397 | + } |
| | 2398 | + } |
| | 2399 | + return path; |
| | 2400 | +} |
| | 2401 | + |
| | 2402 | QT_END_NAMESPACE |
| | 2403 | |
| | 2404 | #endif // QT_NO_DBUS |
| | 2405 | --- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h |
| | 2406 | +++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h |
| | 2407 | @@ -1,40 +1,32 @@ |
| | 2408 | /**************************************************************************** |
| | 2409 | ** |
| | 2410 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 2411 | +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
| | 2412 | ** Contact: http://www.qt-project.org/legal |
| | 2413 | ** |
| | 2414 | ** This file is part of the plugins of the Qt Toolkit. |
| | 2415 | ** |
| | 2416 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 2417 | +** $QT_BEGIN_LICENSE:LGPL21$ |
| | 2418 | ** Commercial License Usage |
| | 2419 | ** Licensees holding valid commercial Qt licenses may use this file in |
| | 2420 | ** accordance with the commercial license agreement provided with the |
| | 2421 | ** Software or, alternatively, in accordance with the terms contained in |
| | 2422 | -** a written agreement between you and Digia. For licensing terms and |
| | 2423 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 2424 | +** a written agreement between you and Digia. For licensing terms and |
| | 2425 | +** conditions see http://qt.digia.com/licensing. For further information |
| | 2426 | ** use the contact form at http://qt.digia.com/contact-us. |
| | 2427 | ** |
| | 2428 | ** GNU Lesser General Public License Usage |
| | 2429 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 2430 | -** General Public License version 2.1 as published by the Free Software |
| | 2431 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 2432 | -** packaging of this file. Please review the following information to |
| | 2433 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 2434 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 2435 | +** General Public License version 2.1 or version 3 as published by the Free |
| | 2436 | +** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| | 2437 | +** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| | 2438 | +** following information to ensure the GNU Lesser General Public License |
| | 2439 | +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| | 2440 | +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 2441 | ** |
| | 2442 | ** In addition, as a special exception, Digia gives you certain additional |
| | 2443 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 2444 | +** rights. These rights are described in the Digia Qt LGPL Exception |
| | 2445 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 2446 | ** |
| | 2447 | -** GNU General Public License Usage |
| | 2448 | -** Alternatively, this file may be used under the terms of the GNU |
| | 2449 | -** General Public License version 3.0 as published by the Free Software |
| | 2450 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 2451 | -** packaging of this file. Please review the following information to |
| | 2452 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 2453 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 2454 | -** |
| | 2455 | -** |
| | 2456 | ** $QT_END_LICENSE$ |
| | 2457 | ** |
| | 2458 | ****************************************************************************/ |
| | 2459 | @@ -57,6 +49,8 @@ |
| | 2460 | |
| | 2461 | #include "qnetworkmanagerservice.h" |
| | 2462 | |
| | 2463 | +#include "../linux_common/qofonoservice_linux_p.h" |
| | 2464 | + |
| | 2465 | #include <QMap> |
| | 2466 | #include <QVariant> |
| | 2467 | |
| | 2468 | @@ -97,40 +91,47 @@ |
| | 2469 | QNetworkConfigurationPrivatePointer defaultConfiguration(); |
| | 2470 | |
| | 2471 | private Q_SLOTS: |
| | 2472 | - void interfacePropertiesChanged(const QString &path, |
| | 2473 | - const QMap<QString, QVariant> &properties); |
| | 2474 | - void activeConnectionPropertiesChanged(const QString &path, |
| | 2475 | - const QMap<QString, QVariant> &properties); |
| | 2476 | - void devicePropertiesChanged(const QString &path, |
| | 2477 | - const QMap<QString, QVariant> &properties); |
| | 2478 | + void interfacePropertiesChanged(const QMap<QString, QVariant> &properties); |
| | 2479 | + void activeConnectionPropertiesChanged(const QMap<QString, QVariant> &properties); |
| | 2480 | |
| | 2481 | void deviceAdded(const QDBusObjectPath &path); |
| | 2482 | void deviceRemoved(const QDBusObjectPath &path); |
| | 2483 | |
| | 2484 | void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0); |
| | 2485 | void removeConnection(const QString &path); |
| | 2486 | - void updateConnection(const QNmSettingsMap &settings); |
| | 2487 | + void updateConnection(); |
| | 2488 | void activationFinished(QDBusPendingCallWatcher *watcher); |
| | 2489 | + void deviceConnectionsChanged(const QStringList &activeConnectionsList); |
| | 2490 | |
| | 2491 | - void newAccessPoint(const QString &path, const QDBusObjectPath &objectPath); |
| | 2492 | - void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath); |
| | 2493 | - void updateAccessPoint(const QMap<QString, QVariant> &map); |
| | 2494 | + void newAccessPoint(const QString &path); |
| | 2495 | + void removeAccessPoint(const QString &path); |
| | 2496 | + void scanFinished(); |
| | 2497 | + |
| | 2498 | + void wiredCarrierChanged(bool); |
| | 2499 | |
| | 2500 | private: |
| | 2501 | - QNetworkConfigurationPrivate *parseConnection(const QString &service, |
| | 2502 | - const QString &settingsPath, |
| | 2503 | + QNetworkConfigurationPrivate *parseConnection(const QString &settingsPath, |
| | 2504 | const QNmSettingsMap &map); |
| | 2505 | QNetworkManagerSettingsConnection *connectionFromId(const QString &id) const; |
| | 2506 | |
| | 2507 | -private: |
| | 2508 | - QNetworkManagerInterface *interface; |
| | 2509 | + QNetworkManagerInterface *managerInterface; |
| | 2510 | QNetworkManagerSettings *systemSettings; |
| | 2511 | - QNetworkManagerSettings *userSettings; |
| | 2512 | + QHash<QString, QNetworkManagerInterfaceDeviceWired *> wiredDevices; |
| | 2513 | QHash<QString, QNetworkManagerInterfaceDeviceWireless *> wirelessDevices; |
| | 2514 | - QHash<QString, QNetworkManagerConnectionActive *> activeConnections; |
| | 2515 | + |
| | 2516 | + QHash<QString, QNetworkManagerConnectionActive *> activeConnectionsList; |
| | 2517 | QList<QNetworkManagerSettingsConnection *> connections; |
| | 2518 | QList<QNetworkManagerInterfaceAccessPoint *> accessPoints; |
| | 2519 | - QList<QNetworkManagerInterfaceAccessPoint *> configuredAccessPoints; |
| | 2520 | + QHash<QString, QNetworkManagerInterfaceDevice *> interfaceDevices; |
| | 2521 | + |
| | 2522 | + QMap<QString,QString> configuredAccessPoints; //ap, settings path |
| | 2523 | + QHash<QString,QString> connectionInterfaces; // ac, interface |
| | 2524 | + |
| | 2525 | + QOfonoManagerInterface *ofonoManager; |
| | 2526 | + QHash <QString, QOfonoDataConnectionManagerInterface *> ofonoContextManagers; |
| | 2527 | + QNetworkConfiguration::BearerType currentBearerType(const QString &id); |
| | 2528 | + QString contextName(const QString &path); |
| | 2529 | + |
| | 2530 | }; |
| | 2531 | |
| | 2532 | QT_END_NAMESPACE |
| | 2533 | --- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp |
| | 2534 | +++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp |
| | 2535 | @@ -1,40 +1,32 @@ |
| | 2536 | /**************************************************************************** |
| | 2537 | ** |
| | 2538 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 2539 | +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
| | 2540 | ** Contact: http://www.qt-project.org/legal |
| | 2541 | ** |
| | 2542 | ** This file is part of the plugins of the Qt Toolkit. |
| | 2543 | ** |
| | 2544 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 2545 | +** $QT_BEGIN_LICENSE:LGPL21$ |
| | 2546 | ** Commercial License Usage |
| | 2547 | ** Licensees holding valid commercial Qt licenses may use this file in |
| | 2548 | ** accordance with the commercial license agreement provided with the |
| | 2549 | ** Software or, alternatively, in accordance with the terms contained in |
| | 2550 | -** a written agreement between you and Digia. For licensing terms and |
| | 2551 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 2552 | +** a written agreement between you and Digia. For licensing terms and |
| | 2553 | +** conditions see http://qt.digia.com/licensing. For further information |
| | 2554 | ** use the contact form at http://qt.digia.com/contact-us. |
| | 2555 | ** |
| | 2556 | ** GNU Lesser General Public License Usage |
| | 2557 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 2558 | -** General Public License version 2.1 as published by the Free Software |
| | 2559 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 2560 | -** packaging of this file. Please review the following information to |
| | 2561 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 2562 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 2563 | +** General Public License version 2.1 or version 3 as published by the Free |
| | 2564 | +** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| | 2565 | +** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| | 2566 | +** following information to ensure the GNU Lesser General Public License |
| | 2567 | +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| | 2568 | +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 2569 | ** |
| | 2570 | ** In addition, as a special exception, Digia gives you certain additional |
| | 2571 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 2572 | +** rights. These rights are described in the Digia Qt LGPL Exception |
| | 2573 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 2574 | ** |
| | 2575 | -** GNU General Public License Usage |
| | 2576 | -** Alternatively, this file may be used under the terms of the GNU |
| | 2577 | -** General Public License version 3.0 as published by the Free Software |
| | 2578 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 2579 | -** packaging of this file. Please review the following information to |
| | 2580 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 2581 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 2582 | -** |
| | 2583 | -** |
| | 2584 | ** $QT_END_LICENSE$ |
| | 2585 | ** |
| | 2586 | ****************************************************************************/ |
| | 2587 | @@ -52,7 +44,6 @@ |
| | 2588 | #include <QtDBus/QDBusPendingCall> |
| | 2589 | |
| | 2590 | #include "qnetworkmanagerservice.h" |
| | 2591 | -#include "qnmdbushelper.h" |
| | 2592 | |
| | 2593 | #ifndef QT_NO_DBUS |
| | 2594 | |
| | 2595 | @@ -72,18 +63,38 @@ |
| | 2596 | d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 2597 | QLatin1String(NM_DBUS_PATH), |
| | 2598 | QLatin1String(NM_DBUS_INTERFACE), |
| | 2599 | - QDBusConnection::systemBus()); |
| | 2600 | + QDBusConnection::systemBus(),parent); |
| | 2601 | if (!d->connectionInterface->isValid()) { |
| | 2602 | d->valid = false; |
| | 2603 | return; |
| | 2604 | } |
| | 2605 | d->valid = true; |
| | 2606 | - nmDBusHelper = new QNmDBusHelper(this); |
| | 2607 | - connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), |
| | 2608 | - this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); |
| | 2609 | - connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)), |
| | 2610 | - this, SIGNAL(stateChanged(QString,quint32))); |
| | 2611 | |
| | 2612 | + QDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 2613 | + QLatin1String(NM_DBUS_PATH), |
| | 2614 | + QLatin1String("org.freedesktop.DBus.Properties"), |
| | 2615 | + QDBusConnection::systemBus()); |
| | 2616 | + QList<QVariant> argumentList; |
| | 2617 | + argumentList << QLatin1String(NM_DBUS_INTERFACE); |
| | 2618 | + QDBusPendingReply<QVariantMap> propsReply |
| | 2619 | + = managerPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), |
| | 2620 | + argumentList); |
| | 2621 | + if (!propsReply.isError()) { |
| | 2622 | + propertyMap = propsReply.value(); |
| | 2623 | + } |
| | 2624 | + |
| | 2625 | + QDBusPendingReply<QList <QDBusObjectPath> > nmReply |
| | 2626 | + = d->connectionInterface->call(QLatin1String("GetDevices")); |
| | 2627 | + nmReply.waitForFinished(); |
| | 2628 | + if (!nmReply.isError()) { |
| | 2629 | + devicesPathList = nmReply.value(); |
| | 2630 | + } |
| | 2631 | + |
| | 2632 | + QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2633 | + QLatin1String(NM_DBUS_PATH), |
| | 2634 | + QLatin1String(NM_DBUS_INTERFACE), |
| | 2635 | + QLatin1String("PropertiesChanged"), |
| | 2636 | + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); |
| | 2637 | } |
| | 2638 | |
| | 2639 | QNetworkManagerInterface::~QNetworkManagerInterface() |
| | 2640 | @@ -99,27 +110,24 @@ |
| | 2641 | |
| | 2642 | bool QNetworkManagerInterface::setConnections() |
| | 2643 | { |
| | 2644 | - if(!isValid() ) |
| | 2645 | + if (!isValid()) |
| | 2646 | return false; |
| | 2647 | |
| | 2648 | - QDBusConnection dbusConnection = QDBusConnection::systemBus(); |
| | 2649 | - |
| | 2650 | - bool allOk = false; |
| | 2651 | - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2652 | + QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2653 | QLatin1String(NM_DBUS_PATH), |
| | 2654 | QLatin1String(NM_DBUS_INTERFACE), |
| | 2655 | QLatin1String("PropertiesChanged"), |
| | 2656 | - nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) { |
| | 2657 | - allOk = true; |
| | 2658 | - } |
| | 2659 | - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2660 | + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); |
| | 2661 | + |
| | 2662 | + bool allOk = false; |
| | 2663 | + if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2664 | QLatin1String(NM_DBUS_PATH), |
| | 2665 | QLatin1String(NM_DBUS_INTERFACE), |
| | 2666 | QLatin1String("DeviceAdded"), |
| | 2667 | this,SIGNAL(deviceAdded(QDBusObjectPath)))) { |
| | 2668 | allOk = true; |
| | 2669 | } |
| | 2670 | - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2671 | + if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2672 | QLatin1String(NM_DBUS_PATH), |
| | 2673 | QLatin1String(NM_DBUS_INTERFACE), |
| | 2674 | QLatin1String("DeviceRemoved"), |
| | 2675 | @@ -135,52 +143,106 @@ |
| | 2676 | return d->connectionInterface; |
| | 2677 | } |
| | 2678 | |
| | 2679 | -QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() const |
| | 2680 | +QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() |
| | 2681 | { |
| | 2682 | - QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetDevices")); |
| | 2683 | - return reply.value(); |
| | 2684 | + if (devicesPathList.isEmpty()) { |
| | 2685 | + qWarning() << "using blocking call!"; |
| | 2686 | + QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetDevices")); |
| | 2687 | + devicesPathList = reply.value(); |
| | 2688 | + } |
| | 2689 | + return devicesPathList; |
| | 2690 | } |
| | 2691 | |
| | 2692 | -void QNetworkManagerInterface::activateConnection( const QString &serviceName, |
| | 2693 | - QDBusObjectPath connectionPath, |
| | 2694 | +void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath, |
| | 2695 | QDBusObjectPath devicePath, |
| | 2696 | QDBusObjectPath specificObject) |
| | 2697 | { |
| | 2698 | QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("ActivateConnection"), |
| | 2699 | - QVariant(serviceName), |
| | 2700 | QVariant::fromValue(connectionPath), |
| | 2701 | QVariant::fromValue(devicePath), |
| | 2702 | QVariant::fromValue(specificObject)); |
| | 2703 | |
| | 2704 | - QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall, this); |
| | 2705 | + QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall); |
| | 2706 | connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), |
| | 2707 | this, SIGNAL(activationFinished(QDBusPendingCallWatcher*))); |
| | 2708 | } |
| | 2709 | |
| | 2710 | void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) const |
| | 2711 | { |
| | 2712 | - d->connectionInterface->call(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath)); |
| | 2713 | + d->connectionInterface->asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath)); |
| | 2714 | } |
| | 2715 | |
| | 2716 | bool QNetworkManagerInterface::wirelessEnabled() const |
| | 2717 | { |
| | 2718 | - return d->connectionInterface->property("WirelessEnabled").toBool(); |
| | 2719 | + if (propertyMap.contains("WirelessEnabled")) |
| | 2720 | + return propertyMap.value("WirelessEnabled").toBool(); |
| | 2721 | + return false; |
| | 2722 | } |
| | 2723 | |
| | 2724 | bool QNetworkManagerInterface::wirelessHardwareEnabled() const |
| | 2725 | { |
| | 2726 | - return d->connectionInterface->property("WirelessHardwareEnabled").toBool(); |
| | 2727 | + if (propertyMap.contains("WirelessHardwareEnabled")) |
| | 2728 | + return propertyMap.value("WirelessHardwareEnabled").toBool(); |
| | 2729 | + return false; |
| | 2730 | } |
| | 2731 | |
| | 2732 | QList <QDBusObjectPath> QNetworkManagerInterface::activeConnections() const |
| | 2733 | { |
| | 2734 | - QVariant prop = d->connectionInterface->property("ActiveConnections"); |
| | 2735 | - return prop.value<QList<QDBusObjectPath> >(); |
| | 2736 | + if (propertyMap.contains("ActiveConnections")) { |
| | 2737 | + |
| | 2738 | + const QDBusArgument &dbusArgs = propertyMap.value("ActiveConnections").value<QDBusArgument>(); |
| | 2739 | + QDBusObjectPath path; |
| | 2740 | + QList <QDBusObjectPath> list; |
| | 2741 | + |
| | 2742 | + dbusArgs.beginArray(); |
| | 2743 | + while (!dbusArgs.atEnd()) { |
| | 2744 | + dbusArgs >> path; |
| | 2745 | + list.append(path); |
| | 2746 | + } |
| | 2747 | + dbusArgs.endArray(); |
| | 2748 | + |
| | 2749 | + return list; |
| | 2750 | + } |
| | 2751 | + |
| | 2752 | + QList <QDBusObjectPath> list; |
| | 2753 | + list << QDBusObjectPath(); |
| | 2754 | + return list; |
| | 2755 | } |
| | 2756 | |
| | 2757 | -quint32 QNetworkManagerInterface::state() |
| | 2758 | +QNetworkManagerInterface::NMState QNetworkManagerInterface::state() |
| | 2759 | { |
| | 2760 | - return d->connectionInterface->property("State").toUInt(); |
| | 2761 | + if (propertyMap.contains("State")) |
| | 2762 | + return static_cast<QNetworkManagerInterface::NMState>(propertyMap.value("State").toUInt()); |
| | 2763 | + return QNetworkManagerInterface::NM_STATE_UNKNOWN; |
| | 2764 | +} |
| | 2765 | + |
| | 2766 | +QString QNetworkManagerInterface::version() const |
| | 2767 | +{ |
| | 2768 | + if (propertyMap.contains("Version")) |
| | 2769 | + return propertyMap.value("Version").toString(); |
| | 2770 | + return QString(); |
| | 2771 | +} |
| | 2772 | + |
| | 2773 | +void QNetworkManagerInterface::propertiesSwap(QMap<QString,QVariant> map) |
| | 2774 | +{ |
| | 2775 | + QMapIterator<QString, QVariant> i(map); |
| | 2776 | + while (i.hasNext()) { |
| | 2777 | + i.next(); |
| | 2778 | + propertyMap.insert(i.key(),i.value()); |
| | 2779 | + |
| | 2780 | + if (i.key() == QStringLiteral("State")) { |
| | 2781 | + quint32 state = i.value().toUInt(); |
| | 2782 | + if (state == NM_DEVICE_STATE_ACTIVATED |
| | 2783 | + || state == NM_DEVICE_STATE_DISCONNECTED |
| | 2784 | + || state == NM_DEVICE_STATE_UNAVAILABLE |
| | 2785 | + || state == NM_DEVICE_STATE_FAILED) { |
| | 2786 | + Q_EMIT propertiesChanged(map); |
| | 2787 | + Q_EMIT stateChanged(state); |
| | 2788 | + } |
| | 2789 | + } else if (i.key() == QStringLiteral("ActiveConnections")) { |
| | 2790 | + Q_EMIT propertiesChanged(map); |
| | 2791 | + } |
| | 2792 | + } |
| | 2793 | } |
| | 2794 | |
| | 2795 | class QNetworkManagerInterfaceAccessPointPrivate |
| | 2796 | @@ -192,18 +254,38 @@ |
| | 2797 | }; |
| | 2798 | |
| | 2799 | QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent) |
| | 2800 | - : QObject(parent), nmDBusHelper(0) |
| | 2801 | + : QObject(parent) |
| | 2802 | { |
| | 2803 | d = new QNetworkManagerInterfaceAccessPointPrivate(); |
| | 2804 | d->path = dbusPathName; |
| | 2805 | d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 2806 | d->path, |
| | 2807 | QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), |
| | 2808 | - QDBusConnection::systemBus()); |
| | 2809 | + QDBusConnection::systemBus(),parent); |
| | 2810 | if (!d->connectionInterface->isValid()) { |
| | 2811 | d->valid = false; |
| | 2812 | return; |
| | 2813 | } |
| | 2814 | + QDBusInterface accessPointPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 2815 | + d->path, |
| | 2816 | + QLatin1String("org.freedesktop.DBus.Properties"), |
| | 2817 | + QDBusConnection::systemBus()); |
| | 2818 | + |
| | 2819 | + QList<QVariant> argumentList; |
| | 2820 | + argumentList << QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT); |
| | 2821 | + QDBusPendingReply<QVariantMap> propsReply |
| | 2822 | + = accessPointPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), |
| | 2823 | + argumentList); |
| | 2824 | + if (!propsReply.isError()) { |
| | 2825 | + propertyMap = propsReply.value(); |
| | 2826 | + } |
| | 2827 | + |
| | 2828 | + QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2829 | + d->path, |
| | 2830 | + QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), |
| | 2831 | + QLatin1String("PropertiesChanged"), |
| | 2832 | + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); |
| | 2833 | + |
| | 2834 | d->valid = true; |
| | 2835 | |
| | 2836 | } |
| | 2837 | @@ -221,24 +303,10 @@ |
| | 2838 | |
| | 2839 | bool QNetworkManagerInterfaceAccessPoint::setConnections() |
| | 2840 | { |
| | 2841 | - if(!isValid() ) |
| | 2842 | + if (!isValid()) |
| | 2843 | return false; |
| | 2844 | |
| | 2845 | - bool allOk = false; |
| | 2846 | - delete nmDBusHelper; |
| | 2847 | - nmDBusHelper = new QNmDBusHelper(this); |
| | 2848 | - connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), |
| | 2849 | - this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); |
| | 2850 | - |
| | 2851 | - if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2852 | - d->path, |
| | 2853 | - QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), |
| | 2854 | - QLatin1String("PropertiesChanged"), |
| | 2855 | - nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) { |
| | 2856 | - allOk = true; |
| | 2857 | - |
| | 2858 | - } |
| | 2859 | - return allOk; |
| | 2860 | + return true; |
| | 2861 | } |
| | 2862 | |
| | 2863 | QDBusInterface *QNetworkManagerInterfaceAccessPoint::connectionInterface() const |
| | 2864 | @@ -248,47 +316,74 @@ |
| | 2865 | |
| | 2866 | quint32 QNetworkManagerInterfaceAccessPoint::flags() const |
| | 2867 | { |
| | 2868 | - return d->connectionInterface->property("Flags").toUInt(); |
| | 2869 | + if (propertyMap.contains("Flags")) |
| | 2870 | + return propertyMap.value("Flags").toUInt(); |
| | 2871 | + return 0; |
| | 2872 | } |
| | 2873 | |
| | 2874 | quint32 QNetworkManagerInterfaceAccessPoint::wpaFlags() const |
| | 2875 | { |
| | 2876 | - return d->connectionInterface->property("WpaFlags").toUInt(); |
| | 2877 | + if (propertyMap.contains("WpaFlags")) |
| | 2878 | + return propertyMap.value("WpaFlags").toUInt(); |
| | 2879 | + return 0; |
| | 2880 | } |
| | 2881 | |
| | 2882 | quint32 QNetworkManagerInterfaceAccessPoint::rsnFlags() const |
| | 2883 | { |
| | 2884 | - return d->connectionInterface->property("RsnFlags").toUInt(); |
| | 2885 | + if (propertyMap.contains("RsnFlags")) |
| | 2886 | + return propertyMap.value("RsnFlags").toUInt(); |
| | 2887 | + return 0; |
| | 2888 | } |
| | 2889 | |
| | 2890 | QString QNetworkManagerInterfaceAccessPoint::ssid() const |
| | 2891 | { |
| | 2892 | - return d->connectionInterface->property("Ssid").toString(); |
| | 2893 | + if (propertyMap.contains("Ssid")) |
| | 2894 | + return propertyMap.value("Ssid").toString(); |
| | 2895 | + return QString(); |
| | 2896 | } |
| | 2897 | |
| | 2898 | quint32 QNetworkManagerInterfaceAccessPoint::frequency() const |
| | 2899 | { |
| | 2900 | - return d->connectionInterface->property("Frequency").toUInt(); |
| | 2901 | + if (propertyMap.contains("Frequency")) |
| | 2902 | + return propertyMap.value("Frequency").toUInt(); |
| | 2903 | + return 0; |
| | 2904 | } |
| | 2905 | |
| | 2906 | QString QNetworkManagerInterfaceAccessPoint::hwAddress() const |
| | 2907 | { |
| | 2908 | - return d->connectionInterface->property("HwAddress").toString(); |
| | 2909 | + if (propertyMap.contains("HwAddress")) |
| | 2910 | + return propertyMap.value("HwAddress").toString(); |
| | 2911 | + return QString(); |
| | 2912 | } |
| | 2913 | |
| | 2914 | quint32 QNetworkManagerInterfaceAccessPoint::mode() const |
| | 2915 | { |
| | 2916 | - return d->connectionInterface->property("Mode").toUInt(); |
| | 2917 | + if (propertyMap.contains("Mode")) |
| | 2918 | + return propertyMap.value("Mode").toUInt(); |
| | 2919 | + return 0; |
| | 2920 | } |
| | 2921 | |
| | 2922 | quint32 QNetworkManagerInterfaceAccessPoint::maxBitrate() const |
| | 2923 | { |
| | 2924 | - return d->connectionInterface->property("MaxBitrate").toUInt(); |
| | 2925 | + if (propertyMap.contains("MaxBitrate")) |
| | 2926 | + return propertyMap.value("MaxBitrate").toUInt(); |
| | 2927 | + return 0; |
| | 2928 | } |
| | 2929 | |
| | 2930 | quint32 QNetworkManagerInterfaceAccessPoint::strength() const |
| | 2931 | { |
| | 2932 | - return d->connectionInterface->property("Strength").toUInt(); |
| | 2933 | + if (propertyMap.contains("Strength")) |
| | 2934 | + return propertyMap.value("Strength").toUInt(); |
| | 2935 | + return 0; |
| | 2936 | +} |
| | 2937 | + |
| | 2938 | +void QNetworkManagerInterfaceAccessPoint::propertiesSwap(QMap<QString,QVariant> map) |
| | 2939 | +{ |
| | 2940 | + QMapIterator<QString, QVariant> i(map); |
| | 2941 | + while (i.hasNext()) { |
| | 2942 | + i.next(); |
| | 2943 | + propertyMap.insert(i.key(),i.value()); |
| | 2944 | + } |
| | 2945 | } |
| | 2946 | |
| | 2947 | class QNetworkManagerInterfaceDevicePrivate |
| | 2948 | @@ -300,18 +395,39 @@ |
| | 2949 | }; |
| | 2950 | |
| | 2951 | QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent) |
| | 2952 | - : QObject(parent), nmDBusHelper(0) |
| | 2953 | + : QObject(parent) |
| | 2954 | { |
| | 2955 | + |
| | 2956 | d = new QNetworkManagerInterfaceDevicePrivate(); |
| | 2957 | d->path = deviceObjectPath; |
| | 2958 | d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 2959 | d->path, |
| | 2960 | QLatin1String(NM_DBUS_INTERFACE_DEVICE), |
| | 2961 | - QDBusConnection::systemBus()); |
| | 2962 | + QDBusConnection::systemBus(),parent); |
| | 2963 | if (!d->connectionInterface->isValid()) { |
| | 2964 | d->valid = false; |
| | 2965 | return; |
| | 2966 | } |
| | 2967 | + QDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 2968 | + d->path, |
| | 2969 | + QLatin1String("org.freedesktop.DBus.Properties"), |
| | 2970 | + QDBusConnection::systemBus(),parent); |
| | 2971 | + |
| | 2972 | + QList<QVariant> argumentList; |
| | 2973 | + argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE); |
| | 2974 | + QDBusPendingReply<QVariantMap> propsReply |
| | 2975 | + = devicePropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), |
| | 2976 | + argumentList); |
| | 2977 | + |
| | 2978 | + if (!propsReply.isError()) { |
| | 2979 | + propertyMap = propsReply.value(); |
| | 2980 | + } |
| | 2981 | + |
| | 2982 | + QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 2983 | + d->path, |
| | 2984 | + QLatin1String(NM_DBUS_INTERFACE_DEVICE), |
| | 2985 | + QLatin1String("PropertiesChanged"), |
| | 2986 | + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); |
| | 2987 | d->valid = true; |
| | 2988 | } |
| | 2989 | |
| | 2990 | @@ -328,22 +444,10 @@ |
| | 2991 | |
| | 2992 | bool QNetworkManagerInterfaceDevice::setConnections() |
| | 2993 | { |
| | 2994 | - if(!isValid() ) |
| | 2995 | + if (!isValid()) |
| | 2996 | return false; |
| | 2997 | |
| | 2998 | - bool allOk = false; |
| | 2999 | - delete nmDBusHelper; |
| | 3000 | - nmDBusHelper = new QNmDBusHelper(this); |
| | 3001 | - connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)), |
| | 3002 | - this, SIGNAL(stateChanged(QString,quint32))); |
| | 3003 | - if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3004 | - d->path, |
| | 3005 | - QLatin1String(NM_DBUS_INTERFACE_DEVICE), |
| | 3006 | - QLatin1String("StateChanged"), |
| | 3007 | - nmDBusHelper,SLOT(deviceStateChanged(quint32)))) { |
| | 3008 | - allOk = true; |
| | 3009 | - } |
| | 3010 | - return allOk; |
| | 3011 | + return true; |
| | 3012 | } |
| | 3013 | |
| | 3014 | QDBusInterface *QNetworkManagerInterfaceDevice::connectionInterface() const |
| | 3015 | @@ -353,33 +457,66 @@ |
| | 3016 | |
| | 3017 | QString QNetworkManagerInterfaceDevice::udi() const |
| | 3018 | { |
| | 3019 | - return d->connectionInterface->property("Udi").toString(); |
| | 3020 | + if (propertyMap.contains("Udi")) |
| | 3021 | + return propertyMap.value("Udi").toString(); |
| | 3022 | + return QString(); |
| | 3023 | } |
| | 3024 | |
| | 3025 | QString QNetworkManagerInterfaceDevice::networkInterface() const |
| | 3026 | { |
| | 3027 | - return d->connectionInterface->property("Interface").toString(); |
| | 3028 | + if (propertyMap.contains("Interface")) |
| | 3029 | + return propertyMap.value("Interface").toString(); |
| | 3030 | + return QString(); |
| | 3031 | } |
| | 3032 | |
| | 3033 | quint32 QNetworkManagerInterfaceDevice::ip4Address() const |
| | 3034 | { |
| | 3035 | - return d->connectionInterface->property("Ip4Address").toUInt(); |
| | 3036 | + if (propertyMap.contains("Ip4Address")) |
| | 3037 | + return propertyMap.value("Ip4Address").toUInt(); |
| | 3038 | + return 0; |
| | 3039 | } |
| | 3040 | |
| | 3041 | quint32 QNetworkManagerInterfaceDevice::state() const |
| | 3042 | { |
| | 3043 | - return d->connectionInterface->property("State").toUInt(); |
| | 3044 | + if (propertyMap.contains("State")) |
| | 3045 | + return propertyMap.value("State").toUInt(); |
| | 3046 | + return 0; |
| | 3047 | } |
| | 3048 | |
| | 3049 | quint32 QNetworkManagerInterfaceDevice::deviceType() const |
| | 3050 | { |
| | 3051 | - return d->connectionInterface->property("DeviceType").toUInt(); |
| | 3052 | + if (propertyMap.contains("DeviceType")) |
| | 3053 | + return propertyMap.value("DeviceType").toUInt(); |
| | 3054 | + return 0; |
| | 3055 | } |
| | 3056 | |
| | 3057 | QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const |
| | 3058 | { |
| | 3059 | - QVariant prop = d->connectionInterface->property("Ip4Config"); |
| | 3060 | - return prop.value<QDBusObjectPath>(); |
| | 3061 | + if (propertyMap.contains("Ip4Config")) |
| | 3062 | + return propertyMap.value("Ip4Config").value<QDBusObjectPath>(); |
| | 3063 | + return QDBusObjectPath(); |
| | 3064 | +} |
| | 3065 | + |
| | 3066 | +void QNetworkManagerInterfaceDevice::propertiesSwap(QMap<QString,QVariant> map) |
| | 3067 | +{ |
| | 3068 | + QMapIterator<QString, QVariant> i(map); |
| | 3069 | + while (i.hasNext()) { |
| | 3070 | + i.next(); |
| | 3071 | + if (i.key() == QStringLiteral("AvailableConnections")) { //Device |
| | 3072 | + const QDBusArgument &dbusArgs = i.value().value<QDBusArgument>(); |
| | 3073 | + QDBusObjectPath path; |
| | 3074 | + QStringList paths; |
| | 3075 | + dbusArgs.beginArray(); |
| | 3076 | + while (!dbusArgs.atEnd()) { |
| | 3077 | + dbusArgs >> path; |
| | 3078 | + paths << path.path(); |
| | 3079 | + } |
| | 3080 | + dbusArgs.endArray(); |
| | 3081 | + Q_EMIT connectionsChanged(paths); |
| | 3082 | + } |
| | 3083 | + propertyMap.insert(i.key(),i.value()); |
| | 3084 | + } |
| | 3085 | + Q_EMIT propertiesChanged(map); |
| | 3086 | } |
| | 3087 | |
| | 3088 | class QNetworkManagerInterfaceDeviceWiredPrivate |
| | 3089 | @@ -391,7 +528,7 @@ |
| | 3090 | }; |
| | 3091 | |
| | 3092 | QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent) |
| | 3093 | - : QObject(parent), nmDBusHelper(0) |
| | 3094 | + : QObject(parent) |
| | 3095 | { |
| | 3096 | d = new QNetworkManagerInterfaceDeviceWiredPrivate(); |
| | 3097 | d->path = ifaceDevicePath; |
| | 3098 | @@ -403,6 +540,27 @@ |
| | 3099 | d->valid = false; |
| | 3100 | return; |
| | 3101 | } |
| | 3102 | + QDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 3103 | + d->path, |
| | 3104 | + QLatin1String("org.freedesktop.DBus.Properties"), |
| | 3105 | + QDBusConnection::systemBus(),parent); |
| | 3106 | + |
| | 3107 | + QList<QVariant> argumentList; |
| | 3108 | + argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED); |
| | 3109 | + QDBusPendingReply<QVariantMap> propsReply |
| | 3110 | + = deviceWiredPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), |
| | 3111 | + argumentList); |
| | 3112 | + |
| | 3113 | + if (!propsReply.isError()) { |
| | 3114 | + propertyMap = propsReply.value(); |
| | 3115 | + } |
| | 3116 | + |
| | 3117 | + QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3118 | + d->path, |
| | 3119 | + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), |
| | 3120 | + QLatin1String("PropertiesChanged"), |
| | 3121 | + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); |
| | 3122 | + |
| | 3123 | d->valid = true; |
| | 3124 | } |
| | 3125 | |
| | 3126 | @@ -420,23 +578,9 @@ |
| | 3127 | |
| | 3128 | bool QNetworkManagerInterfaceDeviceWired::setConnections() |
| | 3129 | { |
| | 3130 | - if(!isValid() ) |
| | 3131 | + if (!isValid()) |
| | 3132 | return false; |
| | 3133 | - |
| | 3134 | - bool allOk = false; |
| | 3135 | - |
| | 3136 | - delete nmDBusHelper; |
| | 3137 | - nmDBusHelper = new QNmDBusHelper(this); |
| | 3138 | - connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), |
| | 3139 | - this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); |
| | 3140 | - if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3141 | - d->path, |
| | 3142 | - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), |
| | 3143 | - QLatin1String("PropertiesChanged"), |
| | 3144 | - nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) { |
| | 3145 | - allOk = true; |
| | 3146 | - } |
| | 3147 | - return allOk; |
| | 3148 | + return true; |
| | 3149 | } |
| | 3150 | |
| | 3151 | QDBusInterface *QNetworkManagerInterfaceDeviceWired::connectionInterface() const |
| | 3152 | @@ -446,17 +590,53 @@ |
| | 3153 | |
| | 3154 | QString QNetworkManagerInterfaceDeviceWired::hwAddress() const |
| | 3155 | { |
| | 3156 | - return d->connectionInterface->property("HwAddress").toString(); |
| | 3157 | + if (propertyMap.contains("HwAddress")) |
| | 3158 | + return propertyMap.value("HwAddress").toString(); |
| | 3159 | + return QString(); |
| | 3160 | } |
| | 3161 | |
| | 3162 | quint32 QNetworkManagerInterfaceDeviceWired::speed() const |
| | 3163 | { |
| | 3164 | - return d->connectionInterface->property("Speed").toUInt(); |
| | 3165 | + if (propertyMap.contains("Speed")) |
| | 3166 | + return propertyMap.value("Speed").toUInt(); |
| | 3167 | + return 0; |
| | 3168 | } |
| | 3169 | |
| | 3170 | bool QNetworkManagerInterfaceDeviceWired::carrier() const |
| | 3171 | { |
| | 3172 | - return d->connectionInterface->property("Carrier").toBool(); |
| | 3173 | + if (propertyMap.contains("Carrier")) |
| | 3174 | + return propertyMap.value("Carrier").toBool(); |
| | 3175 | + return false; |
| | 3176 | +} |
| | 3177 | + |
| | 3178 | +QStringList QNetworkManagerInterfaceDeviceWired::availableConnections() |
| | 3179 | +{ |
| | 3180 | + QStringList list; |
| | 3181 | + if (propertyMap.contains("AvailableConnections")) { |
| | 3182 | + const QDBusArgument &dbusArgs = propertyMap.value("Carrier").value<QDBusArgument>(); |
| | 3183 | + QDBusObjectPath path; |
| | 3184 | + dbusArgs.beginArray(); |
| | 3185 | + while (!dbusArgs.atEnd()) { |
| | 3186 | + dbusArgs >> path; |
| | 3187 | + list << path.path(); |
| | 3188 | + } |
| | 3189 | + dbusArgs.endArray(); |
| | 3190 | + } |
| | 3191 | + |
| | 3192 | + return list; |
| | 3193 | +} |
| | 3194 | + |
| | 3195 | +void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap<QString,QVariant> map) |
| | 3196 | +{ |
| | 3197 | + QMapIterator<QString, QVariant> i(map); |
| | 3198 | + while (i.hasNext()) { |
| | 3199 | + i.next(); |
| | 3200 | + propertyMap.insert(i.key(),i.value()); |
| | 3201 | + if (i.key() == QStringLiteral("Carrier")) { |
| | 3202 | + Q_EMIT carrierChanged(i.value().toBool()); |
| | 3203 | + } |
| | 3204 | + } |
| | 3205 | + Q_EMIT propertiesChanged(map); |
| | 3206 | } |
| | 3207 | |
| | 3208 | class QNetworkManagerInterfaceDeviceWirelessPrivate |
| | 3209 | @@ -468,7 +648,7 @@ |
| | 3210 | }; |
| | 3211 | |
| | 3212 | QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent) |
| | 3213 | - : QObject(parent), nmDBusHelper(0) |
| | 3214 | + : QObject(parent) |
| | 3215 | { |
| | 3216 | d = new QNetworkManagerInterfaceDeviceWirelessPrivate(); |
| | 3217 | d->path = ifaceDevicePath; |
| | 3218 | @@ -480,6 +660,34 @@ |
| | 3219 | d->valid = false; |
| | 3220 | return; |
| | 3221 | } |
| | 3222 | + |
| | 3223 | + |
| | 3224 | + QDBusPendingReply<QList <QDBusObjectPath> > nmReply |
| | 3225 | + = d->connectionInterface->call(QLatin1String("GetAccessPoints")); |
| | 3226 | + |
| | 3227 | + if (!nmReply.isError()) { |
| | 3228 | + accessPointsList = nmReply.value(); |
| | 3229 | + } |
| | 3230 | + |
| | 3231 | + QDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 3232 | + d->path, |
| | 3233 | + QLatin1String("org.freedesktop.DBus.Properties"), |
| | 3234 | + QDBusConnection::systemBus(),parent); |
| | 3235 | + |
| | 3236 | + QList<QVariant> argumentList; |
| | 3237 | + argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS); |
| | 3238 | + QDBusPendingReply<QVariantMap> propsReply |
| | 3239 | + = deviceWirelessPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), |
| | 3240 | + argumentList); |
| | 3241 | + if (!propsReply.isError()) { |
| | 3242 | + propertyMap = propsReply.value(); |
| | 3243 | + } |
| | 3244 | + |
| | 3245 | + QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3246 | + d->path, |
| | 3247 | + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), |
| | 3248 | + QLatin1String("PropertiesChanged"), |
| | 3249 | + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); |
| | 3250 | d->valid = true; |
| | 3251 | } |
| | 3252 | |
| | 3253 | @@ -494,50 +702,50 @@ |
| | 3254 | return d->valid; |
| | 3255 | } |
| | 3256 | |
| | 3257 | +void QNetworkManagerInterfaceDeviceWireless::slotAccessPointAdded(QDBusObjectPath path) |
| | 3258 | +{ |
| | 3259 | + if (path.path().length() > 2) |
| | 3260 | + Q_EMIT accessPointAdded(path.path()); |
| | 3261 | +} |
| | 3262 | + |
| | 3263 | +void QNetworkManagerInterfaceDeviceWireless::slotAccessPointRemoved(QDBusObjectPath path) |
| | 3264 | +{ |
| | 3265 | + if (path.path().length() > 2) |
| | 3266 | + Q_EMIT accessPointRemoved(path.path()); |
| | 3267 | +} |
| | 3268 | + |
| | 3269 | bool QNetworkManagerInterfaceDeviceWireless::setConnections() |
| | 3270 | { |
| | 3271 | - if(!isValid() ) |
| | 3272 | + if (!isValid()) |
| | 3273 | return false; |
| | 3274 | |
| | 3275 | QDBusConnection dbusConnection = QDBusConnection::systemBus(); |
| | 3276 | - bool allOk = false; |
| | 3277 | - delete nmDBusHelper; |
| | 3278 | - nmDBusHelper = new QNmDBusHelper(this); |
| | 3279 | - connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), |
| | 3280 | - this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); |
| | 3281 | + bool allOk = true; |
| | 3282 | |
| | 3283 | - connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(QString,QDBusObjectPath)), |
| | 3284 | - this,SIGNAL(accessPointAdded(QString,QDBusObjectPath))); |
| | 3285 | - |
| | 3286 | - connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(QString,QDBusObjectPath)), |
| | 3287 | - this,SIGNAL(accessPointRemoved(QString,QDBusObjectPath))); |
| | 3288 | - |
| | 3289 | - if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3290 | - d->path, |
| | 3291 | + if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3292 | + d->path, |
| | 3293 | QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), |
| | 3294 | QLatin1String("AccessPointAdded"), |
| | 3295 | - nmDBusHelper, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { |
| | 3296 | - allOk = true; |
| | 3297 | + this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { |
| | 3298 | + allOk = false; |
| | 3299 | } |
| | 3300 | |
| | 3301 | |
| | 3302 | - if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3303 | + if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3304 | d->path, |
| | 3305 | QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), |
| | 3306 | QLatin1String("AccessPointRemoved"), |
| | 3307 | - nmDBusHelper, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) { |
| | 3308 | - allOk = true; |
| | 3309 | + this, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) { |
| | 3310 | + allOk = false; |
| | 3311 | } |
| | 3312 | |
| | 3313 | - |
| | 3314 | - if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3315 | - d->path, |
| | 3316 | - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), |
| | 3317 | - QLatin1String("PropertiesChanged"), |
| | 3318 | - nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) { |
| | 3319 | - allOk = true; |
| | 3320 | + if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3321 | + d->path, |
| | 3322 | + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), |
| | 3323 | + QLatin1String("ScanDone"), |
| | 3324 | + this, SLOT(scanIsDone()))) { |
| | 3325 | + allOk = false; |
| | 3326 | } |
| | 3327 | - |
| | 3328 | return allOk; |
| | 3329 | } |
| | 3330 | |
| | 3331 | @@ -548,33 +756,162 @@ |
| | 3332 | |
| | 3333 | QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints() |
| | 3334 | { |
| | 3335 | - QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetAccessPoints")); |
| | 3336 | - return reply.value(); |
| | 3337 | + if (accessPointsList.isEmpty()) { |
| | 3338 | + qWarning() << "Using blocking call!"; |
| | 3339 | + QDBusReply<QList<QDBusObjectPath> > reply |
| | 3340 | + = d->connectionInterface->call(QLatin1String("GetAccessPoints")); |
| | 3341 | + accessPointsList = reply.value(); |
| | 3342 | + } |
| | 3343 | + return accessPointsList; |
| | 3344 | } |
| | 3345 | |
| | 3346 | QString QNetworkManagerInterfaceDeviceWireless::hwAddress() const |
| | 3347 | { |
| | 3348 | - return d->connectionInterface->property("HwAddress").toString(); |
| | 3349 | + if (propertyMap.contains("HwAddress")) |
| | 3350 | + return propertyMap.value("HwAddress").toString(); |
| | 3351 | + return QString(); |
| | 3352 | } |
| | 3353 | |
| | 3354 | quint32 QNetworkManagerInterfaceDeviceWireless::mode() const |
| | 3355 | { |
| | 3356 | - return d->connectionInterface->property("Mode").toUInt(); |
| | 3357 | + if (propertyMap.contains("Mode")) |
| | 3358 | + return propertyMap.value("Mode").toUInt(); |
| | 3359 | + return 0; |
| | 3360 | } |
| | 3361 | |
| | 3362 | quint32 QNetworkManagerInterfaceDeviceWireless::bitrate() const |
| | 3363 | { |
| | 3364 | - return d->connectionInterface->property("Bitrate").toUInt(); |
| | 3365 | + if (propertyMap.contains("Bitrate")) |
| | 3366 | + return propertyMap.value("Bitrate").toUInt(); |
| | 3367 | + return 0; |
| | 3368 | } |
| | 3369 | |
| | 3370 | QDBusObjectPath QNetworkManagerInterfaceDeviceWireless::activeAccessPoint() const |
| | 3371 | { |
| | 3372 | - return d->connectionInterface->property("ActiveAccessPoint").value<QDBusObjectPath>(); |
| | 3373 | + if (propertyMap.contains("ActiveAccessPoint")) |
| | 3374 | + return propertyMap.value("ActiveAccessPoint").value<QDBusObjectPath>(); |
| | 3375 | + return QDBusObjectPath(); |
| | 3376 | } |
| | 3377 | |
| | 3378 | quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const |
| | 3379 | { |
| | 3380 | - return d->connectionInterface->property("WirelelessCapabilities").toUInt(); |
| | 3381 | + if (propertyMap.contains("WirelelessCapabilities")) |
| | 3382 | + return propertyMap.value("WirelelessCapabilities").toUInt(); |
| | 3383 | + return 0; |
| | 3384 | +} |
| | 3385 | + |
| | 3386 | +void QNetworkManagerInterfaceDeviceWireless::scanIsDone() |
| | 3387 | +{ |
| | 3388 | + Q_EMIT scanDone(); |
| | 3389 | +} |
| | 3390 | + |
| | 3391 | +void QNetworkManagerInterfaceDeviceWireless::requestScan() |
| | 3392 | +{ |
| | 3393 | + d->connectionInterface->asyncCall(QLatin1String("RequestScan")); |
| | 3394 | +} |
| | 3395 | + |
| | 3396 | +void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap<QString,QVariant> map) |
| | 3397 | +{ |
| | 3398 | + QMapIterator<QString, QVariant> i(map); |
| | 3399 | + while (i.hasNext()) { |
| | 3400 | + i.next(); |
| | 3401 | + propertyMap.insert(i.key(),i.value()); |
| | 3402 | + if (i.key() == QStringLiteral("ActiveAccessPoint")) { //DeviceWireless |
| | 3403 | + Q_EMIT propertiesChanged(map); |
| | 3404 | + } |
| | 3405 | + } |
| | 3406 | +} |
| | 3407 | + |
| | 3408 | +class QNetworkManagerInterfaceDeviceModemPrivate |
| | 3409 | +{ |
| | 3410 | +public: |
| | 3411 | + QDBusInterface *connectionInterface; |
| | 3412 | + QString path; |
| | 3413 | + bool valid; |
| | 3414 | +}; |
| | 3415 | + |
| | 3416 | +QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath, QObject *parent) |
| | 3417 | + : QObject(parent) |
| | 3418 | +{ |
| | 3419 | + d = new QNetworkManagerInterfaceDeviceModemPrivate(); |
| | 3420 | + d->path = ifaceDevicePath; |
| | 3421 | + d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 3422 | + d->path, |
| | 3423 | + QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM), |
| | 3424 | + QDBusConnection::systemBus(), parent); |
| | 3425 | + if (!d->connectionInterface->isValid()) { |
| | 3426 | + d->valid = false; |
| | 3427 | + return; |
| | 3428 | + } |
| | 3429 | + QDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 3430 | + d->path, |
| | 3431 | + QLatin1String("org.freedesktop.DBus.Properties"), |
| | 3432 | + QDBusConnection::systemBus(),parent); |
| | 3433 | + |
| | 3434 | + QList<QVariant> argumentList; |
| | 3435 | + argumentList << QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM); |
| | 3436 | + QDBusPendingReply<QVariantMap> propsReply |
| | 3437 | + = deviceModemPropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), |
| | 3438 | + argumentList); |
| | 3439 | + if (!propsReply.isError()) { |
| | 3440 | + propertyMap = propsReply.value(); |
| | 3441 | + } |
| | 3442 | + |
| | 3443 | + QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3444 | + d->path, |
| | 3445 | + QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM), |
| | 3446 | + QLatin1String("PropertiesChanged"), |
| | 3447 | + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); |
| | 3448 | + d->valid = true; |
| | 3449 | +} |
| | 3450 | + |
| | 3451 | +QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem() |
| | 3452 | +{ |
| | 3453 | + delete d->connectionInterface; |
| | 3454 | + delete d; |
| | 3455 | +} |
| | 3456 | + |
| | 3457 | +bool QNetworkManagerInterfaceDeviceModem::isValid() |
| | 3458 | +{ |
| | 3459 | + |
| | 3460 | + return d->valid; |
| | 3461 | +} |
| | 3462 | + |
| | 3463 | +bool QNetworkManagerInterfaceDeviceModem::setConnections() |
| | 3464 | +{ |
| | 3465 | + if (!isValid() ) |
| | 3466 | + return false; |
| | 3467 | + |
| | 3468 | + return true; |
| | 3469 | +} |
| | 3470 | + |
| | 3471 | +QDBusInterface *QNetworkManagerInterfaceDeviceModem::connectionInterface() const |
| | 3472 | +{ |
| | 3473 | + return d->connectionInterface; |
| | 3474 | +} |
| | 3475 | + |
| | 3476 | +QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::modemCapabilities() const |
| | 3477 | +{ |
| | 3478 | + if (propertyMap.contains("ModemCapabilities")) |
| | 3479 | + return static_cast<QNetworkManagerInterfaceDeviceModem::ModemCapabilities>(propertyMap.value("ModemCapabilities").toUInt()); |
| | 3480 | + return QNetworkManagerInterfaceDeviceModem::None; |
| | 3481 | +} |
| | 3482 | + |
| | 3483 | +QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::currentCapabilities() const |
| | 3484 | +{ |
| | 3485 | + if (propertyMap.contains("CurrentCapabilities")) |
| | 3486 | + return static_cast<QNetworkManagerInterfaceDeviceModem::ModemCapabilities>(propertyMap.value("CurrentCapabilities").toUInt()); |
| | 3487 | + return QNetworkManagerInterfaceDeviceModem::None; |
| | 3488 | +} |
| | 3489 | + |
| | 3490 | +void QNetworkManagerInterfaceDeviceModem::propertiesSwap(QMap<QString,QVariant> map) |
| | 3491 | +{ |
| | 3492 | + QMapIterator<QString, QVariant> i(map); |
| | 3493 | + while (i.hasNext()) { |
| | 3494 | + i.next(); |
| | 3495 | + propertyMap.insert(i.key(),i.value()); |
| | 3496 | + } |
| | 3497 | + Q_EMIT propertiesChanged(map); |
| | 3498 | } |
| | 3499 | |
| | 3500 | class QNetworkManagerSettingsPrivate |
| | 3501 | @@ -598,6 +935,14 @@ |
| | 3502 | d->valid = false; |
| | 3503 | return; |
| | 3504 | } |
| | 3505 | + |
| | 3506 | + QDBusPendingReply<QList <QDBusObjectPath> > nmReply |
| | 3507 | + = d->connectionInterface->call(QLatin1String("ListConnections")); |
| | 3508 | + |
| | 3509 | + if (!nmReply.isError()) { |
| | 3510 | + connectionsList = nmReply.value(); |
| | 3511 | + } |
| | 3512 | + |
| | 3513 | d->valid = true; |
| | 3514 | } |
| | 3515 | |
| | 3516 | @@ -614,12 +959,14 @@ |
| | 3517 | |
| | 3518 | bool QNetworkManagerSettings::setConnections() |
| | 3519 | { |
| | 3520 | - bool allOk = false; |
| | 3521 | + bool allOk = true; |
| | 3522 | |
| | 3523 | - if (!QDBusConnection::systemBus().connect(d->path, QLatin1String(NM_DBUS_PATH_SETTINGS), |
| | 3524 | - QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"), |
| | 3525 | - this, SIGNAL(newConnection(QDBusObjectPath)))) { |
| | 3526 | - allOk = true; |
| | 3527 | + if (!QDBusConnection::systemBus().connect(d->path, |
| | 3528 | + QLatin1String(NM_DBUS_PATH_SETTINGS), |
| | 3529 | + QLatin1String(NM_DBUS_IFACE_SETTINGS), |
| | 3530 | + QLatin1String("NewConnection"), |
| | 3531 | + this, SIGNAL(newConnection(QDBusObjectPath)))) { |
| | 3532 | + allOk = false; |
| | 3533 | } |
| | 3534 | |
| | 3535 | return allOk; |
| | 3536 | @@ -627,8 +974,22 @@ |
| | 3537 | |
| | 3538 | QList <QDBusObjectPath> QNetworkManagerSettings::listConnections() |
| | 3539 | { |
| | 3540 | - QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("ListConnections")); |
| | 3541 | - return reply.value(); |
| | 3542 | + if (connectionsList.isEmpty()) { |
| | 3543 | + qWarning() << "Using blocking call!"; |
| | 3544 | + QDBusReply<QList<QDBusObjectPath> > reply |
| | 3545 | + = d->connectionInterface->call(QLatin1String("ListConnections")); |
| | 3546 | + connectionsList = reply.value(); |
| | 3547 | + } |
| | 3548 | + return connectionsList; |
| | 3549 | +} |
| | 3550 | + |
| | 3551 | + |
| | 3552 | +QString QNetworkManagerSettings::getConnectionByUuid(const QString &uuid) |
| | 3553 | +{ |
| | 3554 | + QList<QVariant> argumentList; |
| | 3555 | + argumentList << QVariant::fromValue(uuid); |
| | 3556 | + QDBusReply<QDBusObjectPath > reply = d->connectionInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList); |
| | 3557 | + return reply.value().path(); |
| | 3558 | } |
| | 3559 | |
| | 3560 | QDBusInterface *QNetworkManagerSettings::connectionInterface() const |
| | 3561 | @@ -648,7 +1009,7 @@ |
| | 3562 | }; |
| | 3563 | |
| | 3564 | QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent) |
| | 3565 | - : QObject(parent), nmDBusHelper(0) |
| | 3566 | + : QObject(parent) |
| | 3567 | { |
| | 3568 | qDBusRegisterMetaType<QNmSettingsMap>(); |
| | 3569 | d = new QNetworkManagerSettingsConnectionPrivate(); |
| | 3570 | @@ -663,8 +1024,12 @@ |
| | 3571 | return; |
| | 3572 | } |
| | 3573 | d->valid = true; |
| | 3574 | - QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings")); |
| | 3575 | - d->settingsMap = rep.value(); |
| | 3576 | + |
| | 3577 | + QDBusPendingReply<QNmSettingsMap> nmReply |
| | 3578 | + = d->connectionInterface->call(QLatin1String("GetSettings")); |
| | 3579 | + if (!nmReply.isError()) { |
| | 3580 | + d->settingsMap = nmReply.value(); |
| | 3581 | + } |
| | 3582 | } |
| | 3583 | |
| | 3584 | QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection() |
| | 3585 | @@ -680,33 +1045,34 @@ |
| | 3586 | |
| | 3587 | bool QNetworkManagerSettingsConnection::setConnections() |
| | 3588 | { |
| | 3589 | - if(!isValid() ) |
| | 3590 | + if (!isValid()) |
| | 3591 | return false; |
| | 3592 | |
| | 3593 | QDBusConnection dbusConnection = QDBusConnection::systemBus(); |
| | 3594 | - bool allOk = false; |
| | 3595 | - if(!dbusConnection.connect(d->service, d->path, |
| | 3596 | - QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"), |
| | 3597 | - this, SIGNAL(updated(QNmSettingsMap)))) { |
| | 3598 | - allOk = true; |
| | 3599 | - } else { |
| | 3600 | - QDBusError error = dbusConnection.lastError(); |
| | 3601 | + bool allOk = true; |
| | 3602 | + if (!dbusConnection.connect(d->service, |
| | 3603 | + d->path, |
| | 3604 | + QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), |
| | 3605 | + QLatin1String("Updated"), |
| | 3606 | + this, SIGNAL(updated()))) { |
| | 3607 | + allOk = false; |
| | 3608 | } |
| | 3609 | |
| | 3610 | - delete nmDBusHelper; |
| | 3611 | - nmDBusHelper = new QNmDBusHelper(this); |
| | 3612 | - connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(QString)), |
| | 3613 | - this,SIGNAL(removed(QString))); |
| | 3614 | - |
| | 3615 | - if (!dbusConnection.connect(d->service, d->path, |
| | 3616 | - QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"), |
| | 3617 | - nmDBusHelper, SIGNAL(slotSettingsRemoved()))) { |
| | 3618 | - allOk = true; |
| | 3619 | + if (!dbusConnection.connect(d->service, |
| | 3620 | + d->path, |
| | 3621 | + QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), |
| | 3622 | + QLatin1String("Removed"), |
| | 3623 | + this, SIGNAL(slotSettingsRemoved()))) { |
| | 3624 | + allOk = false; |
| | 3625 | } |
| | 3626 | - |
| | 3627 | return allOk; |
| | 3628 | } |
| | 3629 | |
| | 3630 | +void QNetworkManagerSettingsConnection::slotSettingsRemoved() |
| | 3631 | +{ |
| | 3632 | + Q_EMIT removed(d->path); |
| | 3633 | +} |
| | 3634 | + |
| | 3635 | QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const |
| | 3636 | { |
| | 3637 | return d->connectionInterface; |
| | 3638 | @@ -714,8 +1080,11 @@ |
| | 3639 | |
| | 3640 | QNmSettingsMap QNetworkManagerSettingsConnection::getSettings() |
| | 3641 | { |
| | 3642 | - QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings")); |
| | 3643 | - d->settingsMap = rep.value(); |
| | 3644 | + if (d->settingsMap.isEmpty()) { |
| | 3645 | + qWarning() << "Using blocking call!"; |
| | 3646 | + QDBusReply<QNmSettingsMap> reply = d->connectionInterface->call(QLatin1String("GetSettings")); |
| | 3647 | + d->settingsMap = reply.value(); |
| | 3648 | + } |
| | 3649 | return d->settingsMap; |
| | 3650 | } |
| | 3651 | |
| | 3652 | @@ -725,9 +1094,11 @@ |
| | 3653 | d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString(); |
| | 3654 | |
| | 3655 | if (devType == QLatin1String("802-3-ethernet")) |
| | 3656 | - return DEVICE_TYPE_802_3_ETHERNET; |
| | 3657 | + return DEVICE_TYPE_ETHERNET; |
| | 3658 | else if (devType == QLatin1String("802-11-wireless")) |
| | 3659 | - return DEVICE_TYPE_802_11_WIRELESS; |
| | 3660 | + return DEVICE_TYPE_WIFI; |
| | 3661 | + else if (devType == QLatin1String("gsm")) |
| | 3662 | + return DEVICE_TYPE_MODEM; |
| | 3663 | else |
| | 3664 | return DEVICE_TYPE_UNKNOWN; |
| | 3665 | } |
| | 3666 | @@ -774,10 +1145,10 @@ |
| | 3667 | { |
| | 3668 | NMDeviceType type = getType(); |
| | 3669 | |
| | 3670 | - if (type == DEVICE_TYPE_802_3_ETHERNET) { |
| | 3671 | + if (type == DEVICE_TYPE_ETHERNET) { |
| | 3672 | return d->settingsMap.value(QLatin1String("802-3-ethernet")) |
| | 3673 | .value(QLatin1String("mac-address")).toString(); |
| | 3674 | - } else if (type == DEVICE_TYPE_802_11_WIRELESS) { |
| | 3675 | + } else if (type == DEVICE_TYPE_WIFI) { |
| | 3676 | return d->settingsMap.value(QLatin1String("802-11-wireless")) |
| | 3677 | .value(QLatin1String("mac-address")).toString(); |
| | 3678 | } else { |
| | 3679 | @@ -787,7 +1158,7 @@ |
| | 3680 | |
| | 3681 | QStringList QNetworkManagerSettingsConnection::getSeenBssids() |
| | 3682 | { |
| | 3683 | - if (getType() == DEVICE_TYPE_802_11_WIRELESS) { |
| | 3684 | + if (getType() == DEVICE_TYPE_WIFI) { |
| | 3685 | return d->settingsMap.value(QLatin1String("802-11-wireless")) |
| | 3686 | .value(QLatin1String("seen-bssids")).toStringList(); |
| | 3687 | } else { |
| | 3688 | @@ -803,8 +1174,8 @@ |
| | 3689 | bool valid; |
| | 3690 | }; |
| | 3691 | |
| | 3692 | -QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString &activeConnectionObjectPath, QObject *parent) |
| | 3693 | - : QObject(parent), nmDBusHelper(0) |
| | 3694 | +QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &activeConnectionObjectPath, QObject *parent) |
| | 3695 | + : QObject(parent) |
| | 3696 | { |
| | 3697 | d = new QNetworkManagerConnectionActivePrivate(); |
| | 3698 | d->path = activeConnectionObjectPath; |
| | 3699 | @@ -816,6 +1187,29 @@ |
| | 3700 | d->valid = false; |
| | 3701 | return; |
| | 3702 | } |
| | 3703 | + QDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE), |
| | 3704 | + d->path, |
| | 3705 | + QLatin1String("org.freedesktop.DBus.Properties"), |
| | 3706 | + QDBusConnection::systemBus()); |
| | 3707 | + |
| | 3708 | + |
| | 3709 | + QList<QVariant> argumentList; |
| | 3710 | + argumentList << QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION); |
| | 3711 | + QDBusPendingReply<QVariantMap> propsReply |
| | 3712 | + = connectionActivePropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), |
| | 3713 | + argumentList); |
| | 3714 | + |
| | 3715 | + if (!propsReply.isError()) { |
| | 3716 | + propertyMap = propsReply.value(); |
| | 3717 | + } else { |
| | 3718 | + qWarning() << propsReply.error().message(); |
| | 3719 | + } |
| | 3720 | + |
| | 3721 | + QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3722 | + d->path, |
| | 3723 | + QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), |
| | 3724 | + QLatin1String("PropertiesChanged"), |
| | 3725 | + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); |
| | 3726 | d->valid = true; |
| | 3727 | } |
| | 3728 | |
| | 3729 | @@ -832,23 +1226,10 @@ |
| | 3730 | |
| | 3731 | bool QNetworkManagerConnectionActive::setConnections() |
| | 3732 | { |
| | 3733 | - if(!isValid() ) |
| | 3734 | + if (!isValid()) |
| | 3735 | return false; |
| | 3736 | |
| | 3737 | - bool allOk = false; |
| | 3738 | - delete nmDBusHelper; |
| | 3739 | - nmDBusHelper = new QNmDBusHelper(this); |
| | 3740 | - connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), |
| | 3741 | - this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); |
| | 3742 | - if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), |
| | 3743 | - d->path, |
| | 3744 | - QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), |
| | 3745 | - QLatin1String("PropertiesChanged"), |
| | 3746 | - nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) { |
| | 3747 | - allOk = true; |
| | 3748 | - } |
| | 3749 | - |
| | 3750 | - return allOk; |
| | 3751 | + return true; |
| | 3752 | } |
| | 3753 | |
| | 3754 | QDBusInterface *QNetworkManagerConnectionActive::connectionInterface() const |
| | 3755 | @@ -856,37 +1237,72 @@ |
| | 3756 | return d->connectionInterface; |
| | 3757 | } |
| | 3758 | |
| | 3759 | -QString QNetworkManagerConnectionActive::serviceName() const |
| | 3760 | -{ |
| | 3761 | - return d->connectionInterface->property("ServiceName").toString(); |
| | 3762 | -} |
| | 3763 | - |
| | 3764 | QDBusObjectPath QNetworkManagerConnectionActive::connection() const |
| | 3765 | { |
| | 3766 | - QVariant prop = d->connectionInterface->property("Connection"); |
| | 3767 | - return prop.value<QDBusObjectPath>(); |
| | 3768 | + if (propertyMap.contains("Connection")) |
| | 3769 | + return propertyMap.value("Connection").value<QDBusObjectPath>(); |
| | 3770 | + return QDBusObjectPath(); |
| | 3771 | } |
| | 3772 | |
| | 3773 | QDBusObjectPath QNetworkManagerConnectionActive::specificObject() const |
| | 3774 | { |
| | 3775 | - QVariant prop = d->connectionInterface->property("SpecificObject"); |
| | 3776 | - return prop.value<QDBusObjectPath>(); |
| | 3777 | -} |
| | 3778 | - |
| | 3779 | -QList<QDBusObjectPath> QNetworkManagerConnectionActive::devices() const |
| | 3780 | -{ |
| | 3781 | - QVariant prop = d->connectionInterface->property("Devices"); |
| | 3782 | - return prop.value<QList<QDBusObjectPath> >(); |
| | 3783 | + if (propertyMap.contains("SpecificObject")) |
| | 3784 | + return propertyMap.value("SpecificObject").value<QDBusObjectPath>(); |
| | 3785 | + return QDBusObjectPath(); |
| | 3786 | +} |
| | 3787 | + |
| | 3788 | +QStringList QNetworkManagerConnectionActive::devices() const |
| | 3789 | +{ |
| | 3790 | + QStringList list; |
| | 3791 | + if (propertyMap.contains("Devices")) { |
| | 3792 | + const QDBusArgument &dbusArgs = propertyMap.value("Devices").value<QDBusArgument>(); |
| | 3793 | + QDBusObjectPath path; |
| | 3794 | + |
| | 3795 | + dbusArgs.beginArray(); |
| | 3796 | + while (!dbusArgs.atEnd()) { |
| | 3797 | + dbusArgs >> path; |
| | 3798 | + list.append(path.path()); |
| | 3799 | + } |
| | 3800 | + dbusArgs.endArray(); |
| | 3801 | + } |
| | 3802 | + return list; |
| | 3803 | } |
| | 3804 | |
| | 3805 | quint32 QNetworkManagerConnectionActive::state() const |
| | 3806 | { |
| | 3807 | - return d->connectionInterface->property("State").toUInt(); |
| | 3808 | + if (propertyMap.contains("State")) |
| | 3809 | + return propertyMap.value("State").toUInt(); |
| | 3810 | + return 0; |
| | 3811 | } |
| | 3812 | |
| | 3813 | bool QNetworkManagerConnectionActive::defaultRoute() const |
| | 3814 | { |
| | 3815 | - return d->connectionInterface->property("Default").toBool(); |
| | 3816 | + if (propertyMap.contains("Default")) |
| | 3817 | + return propertyMap.value("Default").toBool(); |
| | 3818 | + return false; |
| | 3819 | +} |
| | 3820 | + |
| | 3821 | +bool QNetworkManagerConnectionActive::default6Route() const |
| | 3822 | +{ |
| | 3823 | + if (propertyMap.contains("Default6")) |
| | 3824 | + return propertyMap.value("Default6").toBool(); |
| | 3825 | + return false; |
| | 3826 | +} |
| | 3827 | + |
| | 3828 | +void QNetworkManagerConnectionActive::propertiesSwap(QMap<QString,QVariant> map) |
| | 3829 | +{ |
| | 3830 | + QMapIterator<QString, QVariant> i(map); |
| | 3831 | + while (i.hasNext()) { |
| | 3832 | + i.next(); |
| | 3833 | + propertyMap.insert(i.key(),i.value()); |
| | 3834 | + if (i.key() == QStringLiteral("State")) { |
| | 3835 | + quint32 state = i.value().toUInt(); |
| | 3836 | + if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED |
| | 3837 | + || state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { |
| | 3838 | + Q_EMIT propertiesChanged(map); |
| | 3839 | + } |
| | 3840 | + } |
| | 3841 | + } |
| | 3842 | } |
| | 3843 | |
| | 3844 | class QNetworkManagerIp4ConfigPrivate |
| | 3845 | --- qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h |
| | 3846 | +++ qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h |
| | 3847 | @@ -1,40 +1,32 @@ |
| | 3848 | /**************************************************************************** |
| | 3849 | ** |
| | 3850 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 3851 | +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
| | 3852 | ** Contact: http://www.qt-project.org/legal |
| | 3853 | ** |
| | 3854 | ** This file is part of the plugins of the Qt Toolkit. |
| | 3855 | ** |
| | 3856 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 3857 | +** $QT_BEGIN_LICENSE:LGPL21$ |
| | 3858 | ** Commercial License Usage |
| | 3859 | ** Licensees holding valid commercial Qt licenses may use this file in |
| | 3860 | ** accordance with the commercial license agreement provided with the |
| | 3861 | ** Software or, alternatively, in accordance with the terms contained in |
| | 3862 | -** a written agreement between you and Digia. For licensing terms and |
| | 3863 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 3864 | +** a written agreement between you and Digia. For licensing terms and |
| | 3865 | +** conditions see http://qt.digia.com/licensing. For further information |
| | 3866 | ** use the contact form at http://qt.digia.com/contact-us. |
| | 3867 | ** |
| | 3868 | ** GNU Lesser General Public License Usage |
| | 3869 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 3870 | -** General Public License version 2.1 as published by the Free Software |
| | 3871 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 3872 | -** packaging of this file. Please review the following information to |
| | 3873 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 3874 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 3875 | +** General Public License version 2.1 or version 3 as published by the Free |
| | 3876 | +** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| | 3877 | +** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| | 3878 | +** following information to ensure the GNU Lesser General Public License |
| | 3879 | +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| | 3880 | +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 3881 | ** |
| | 3882 | ** In addition, as a special exception, Digia gives you certain additional |
| | 3883 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 3884 | +** rights. These rights are described in the Digia Qt LGPL Exception |
| | 3885 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 3886 | ** |
| | 3887 | -** GNU General Public License Usage |
| | 3888 | -** Alternatively, this file may be used under the terms of the GNU |
| | 3889 | -** General Public License version 3.0 as published by the Free Software |
| | 3890 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 3891 | -** packaging of this file. Please review the following information to |
| | 3892 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 3893 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 3894 | -** |
| | 3895 | -** |
| | 3896 | ** $QT_END_LICENSE$ |
| | 3897 | ** |
| | 3898 | ****************************************************************************/ |
| | 3899 | @@ -64,7 +56,6 @@ |
| | 3900 | #include <QtDBus/QDBusObjectPath> |
| | 3901 | #include <QtDBus/QDBusContext> |
| | 3902 | #include <QMap> |
| | 3903 | -#include "qnmdbushelper.h" |
| | 3904 | |
| | 3905 | #ifndef QT_NO_DBUS |
| | 3906 | |
| | 3907 | @@ -72,31 +63,32 @@ |
| | 3908 | typedef enum NMDeviceType |
| | 3909 | { |
| | 3910 | DEVICE_TYPE_UNKNOWN = 0, |
| | 3911 | - DEVICE_TYPE_802_3_ETHERNET, |
| | 3912 | - DEVICE_TYPE_802_11_WIRELESS, |
| | 3913 | - DEVICE_TYPE_GSM, |
| | 3914 | - DEVICE_TYPE_CDMA |
| | 3915 | + DEVICE_TYPE_ETHERNET, |
| | 3916 | + DEVICE_TYPE_WIFI, |
| | 3917 | + DEVICE_TYPE_MODEM = 8 |
| | 3918 | } NMDeviceType; |
| | 3919 | |
| | 3920 | typedef enum |
| | 3921 | { |
| | 3922 | NM_DEVICE_STATE_UNKNOWN = 0, |
| | 3923 | - NM_DEVICE_STATE_UNMANAGED, |
| | 3924 | - NM_DEVICE_STATE_UNAVAILABLE, |
| | 3925 | - NM_DEVICE_STATE_DISCONNECTED, |
| | 3926 | - NM_DEVICE_STATE_PREPARE, |
| | 3927 | - NM_DEVICE_STATE_CONFIG, |
| | 3928 | - NM_DEVICE_STATE_NEED_AUTH, |
| | 3929 | - NM_DEVICE_STATE_IP_CONFIG, |
| | 3930 | - NM_DEVICE_STATE_ACTIVATED, |
| | 3931 | - NM_DEVICE_STATE_FAILED |
| | 3932 | + NM_DEVICE_STATE_UNMANAGED = 10, |
| | 3933 | + NM_DEVICE_STATE_UNAVAILABLE = 20, |
| | 3934 | + NM_DEVICE_STATE_DISCONNECTED = 30, |
| | 3935 | + NM_DEVICE_STATE_PREPARE = 40, |
| | 3936 | + NM_DEVICE_STATE_CONFIG = 50, |
| | 3937 | + NM_DEVICE_STATE_NEED_AUTH = 60, |
| | 3938 | + NM_DEVICE_STATE_IP_CONFIG = 70, |
| | 3939 | + NM_DEVICE_STATE_ACTIVATED = 100, |
| | 3940 | + NM_DEVICE_STATE_DEACTIVATING = 110, |
| | 3941 | + NM_DEVICE_STATE_FAILED = 120 |
| | 3942 | } NMDeviceState; |
| | 3943 | |
| | 3944 | typedef enum |
| | 3945 | { |
| | 3946 | NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0, |
| | 3947 | NM_ACTIVE_CONNECTION_STATE_ACTIVATING, |
| | 3948 | - NM_ACTIVE_CONNECTION_STATE_ACTIVATED |
| | 3949 | + NM_ACTIVE_CONNECTION_STATE_ACTIVATED, |
| | 3950 | + NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4 |
| | 3951 | } NMActiveConnectionState; |
| | 3952 | |
| | 3953 | #define NM_DBUS_SERVICE "org.freedesktop.NetworkManager" |
| | 3954 | @@ -106,13 +98,14 @@ |
| | 3955 | #define NM_DBUS_INTERFACE_DEVICE NM_DBUS_INTERFACE ".Device" |
| | 3956 | #define NM_DBUS_INTERFACE_DEVICE_WIRED NM_DBUS_INTERFACE_DEVICE ".Wired" |
| | 3957 | #define NM_DBUS_INTERFACE_DEVICE_WIRELESS NM_DBUS_INTERFACE_DEVICE ".Wireless" |
| | 3958 | +#define NM_DBUS_INTERFACE_DEVICE_MODEM NM_DBUS_INTERFACE_DEVICE ".Modem" |
| | 3959 | #define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint" |
| | 3960 | #define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint" |
| | 3961 | |
| | 3962 | -#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManagerSettings" |
| | 3963 | +#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings" |
| | 3964 | |
| | 3965 | -#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManagerSettings.Connection" |
| | 3966 | -#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManagerSettings" |
| | 3967 | +#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManager.Settings.Connection" |
| | 3968 | +#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManager.Settings" |
| | 3969 | #define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active" |
| | 3970 | #define NM_DBUS_INTERFACE_IP4_CONFIG NM_DBUS_INTERFACE ".IP4Config" |
| | 3971 | |
| | 3972 | @@ -141,12 +134,23 @@ |
| | 3973 | Q_OBJECT |
| | 3974 | |
| | 3975 | public: |
| | 3976 | + typedef enum |
| | 3977 | + { |
| | 3978 | + NM_STATE_UNKNOWN = 0, |
| | 3979 | + NM_STATE_ASLEEP = 10, |
| | 3980 | + NM_STATE_DISCONNECTED = 20, |
| | 3981 | + NM_STATE_DISCONNECTING = 30, |
| | 3982 | + NM_STATE_CONNECTING = 40, |
| | 3983 | + NM_STATE_CONNECTED_LOCAL = 50, |
| | 3984 | + NM_STATE_CONNECTED_SITE = 60, |
| | 3985 | + NM_STATE_CONNECTED_GLOBAL = 70 |
| | 3986 | + } NMState; |
| | 3987 | |
| | 3988 | QNetworkManagerInterface(QObject *parent = 0); |
| | 3989 | ~QNetworkManagerInterface(); |
| | 3990 | |
| | 3991 | - QList <QDBusObjectPath> getDevices() const; |
| | 3992 | - void activateConnection(const QString &serviceName, QDBusObjectPath connection, QDBusObjectPath device, QDBusObjectPath specificObject); |
| | 3993 | + QList <QDBusObjectPath> getDevices(); |
| | 3994 | + void activateConnection(QDBusObjectPath connection,QDBusObjectPath device, QDBusObjectPath specificObject); |
| | 3995 | void deactivateConnection(QDBusObjectPath connectionPath) const; |
| | 3996 | |
| | 3997 | QDBusObjectPath path() const; |
| | 3998 | @@ -155,21 +159,28 @@ |
| | 3999 | bool wirelessEnabled() const; |
| | 4000 | bool wirelessHardwareEnabled() const; |
| | 4001 | QList <QDBusObjectPath> activeConnections() const; |
| | 4002 | - quint32 state(); |
| | 4003 | + NMState state(); |
| | 4004 | + QString version() const; |
| | 4005 | bool setConnections(); |
| | 4006 | bool isValid(); |
| | 4007 | |
| | 4008 | Q_SIGNALS: |
| | 4009 | void deviceAdded(QDBusObjectPath); |
| | 4010 | void deviceRemoved(QDBusObjectPath); |
| | 4011 | - void propertiesChanged( const QString &, QMap<QString,QVariant>); |
| | 4012 | - void stateChanged(const QString&, quint32); |
| | 4013 | + void propertiesChanged(QMap<QString,QVariant>); |
| | 4014 | + void stateChanged(quint32); |
| | 4015 | void activationFinished(QDBusPendingCallWatcher*); |
| | 4016 | + void propertiesReady(); |
| | 4017 | + void devicesListReady(); |
| | 4018 | |
| | 4019 | private Q_SLOTS: |
| | 4020 | + void propertiesSwap(QMap<QString,QVariant>); |
| | 4021 | + |
| | 4022 | private: |
| | 4023 | QNetworkManagerInterfacePrivate *d; |
| | 4024 | - QNmDBusHelper *nmDBusHelper; |
| | 4025 | + QVariantMap propertyMap; |
| | 4026 | + QList<QDBusObjectPath> devicesPathList; |
| | 4027 | + |
| | 4028 | }; |
| | 4029 | |
| | 4030 | class QNetworkManagerInterfaceAccessPointPrivate; |
| | 4031 | @@ -234,11 +245,14 @@ |
| | 4032 | |
| | 4033 | Q_SIGNALS: |
| | 4034 | void propertiesChanged(QMap <QString,QVariant>); |
| | 4035 | - void propertiesChanged( const QString &, QMap<QString,QVariant>); |
| | 4036 | + void propertiesReady(); |
| | 4037 | + |
| | 4038 | +private Q_SLOTS: |
| | 4039 | + void propertiesSwap(QMap<QString,QVariant>); |
| | 4040 | + |
| | 4041 | private: |
| | 4042 | QNetworkManagerInterfaceAccessPointPrivate *d; |
| | 4043 | - QNmDBusHelper *nmDBusHelper; |
| | 4044 | - |
| | 4045 | + QVariantMap propertyMap; |
| | 4046 | }; |
| | 4047 | |
| | 4048 | class QNetworkManagerInterfaceDevicePrivate; |
| | 4049 | @@ -264,10 +278,14 @@ |
| | 4050 | |
| | 4051 | Q_SIGNALS: |
| | 4052 | void stateChanged(const QString &, quint32); |
| | 4053 | - |
| | 4054 | + void propertiesChanged(QMap<QString,QVariant>); |
| | 4055 | + void connectionsChanged(QStringList); |
| | 4056 | + void propertiesReady(); |
| | 4057 | +private Q_SLOTS: |
| | 4058 | + void propertiesSwap(QMap<QString,QVariant>); |
| | 4059 | private: |
| | 4060 | QNetworkManagerInterfaceDevicePrivate *d; |
| | 4061 | - QNmDBusHelper *nmDBusHelper; |
| | 4062 | + QVariantMap propertyMap; |
| | 4063 | }; |
| | 4064 | |
| | 4065 | class QNetworkManagerInterfaceDeviceWiredPrivate; |
| | 4066 | @@ -287,12 +305,19 @@ |
| | 4067 | bool carrier() const; |
| | 4068 | bool setConnections(); |
| | 4069 | bool isValid(); |
| | 4070 | + QStringList availableConnections(); |
| | 4071 | |
| | 4072 | Q_SIGNALS: |
| | 4073 | - void propertiesChanged( const QString &, QMap<QString,QVariant>); |
| | 4074 | + void propertiesChanged(QMap<QString,QVariant>); |
| | 4075 | + void propertiesReady(); |
| | 4076 | + void carrierChanged(bool); |
| | 4077 | + |
| | 4078 | +private Q_SLOTS: |
| | 4079 | + void propertiesSwap(QMap<QString,QVariant>); |
| | 4080 | + |
| | 4081 | private: |
| | 4082 | QNetworkManagerInterfaceDeviceWiredPrivate *d; |
| | 4083 | - QNmDBusHelper *nmDBusHelper; |
| | 4084 | + QVariantMap propertyMap; |
| | 4085 | }; |
| | 4086 | |
| | 4087 | class QNetworkManagerInterfaceDeviceWirelessPrivate; |
| | 4088 | @@ -328,15 +353,71 @@ |
| | 4089 | bool setConnections(); |
| | 4090 | bool isValid(); |
| | 4091 | |
| | 4092 | + void requestScan(); |
| | 4093 | Q_SIGNALS: |
| | 4094 | - void propertiesChanged( const QString &, QMap<QString,QVariant>); |
| | 4095 | - void accessPointAdded(const QString &,QDBusObjectPath); |
| | 4096 | - void accessPointRemoved(const QString &,QDBusObjectPath); |
| | 4097 | + void propertiesChanged(QMap<QString,QVariant>); |
| | 4098 | + void accessPointAdded(const QString &); |
| | 4099 | + void accessPointRemoved(const QString &); |
| | 4100 | + void scanDone(); |
| | 4101 | + void propertiesReady(); |
| | 4102 | + void accessPointsReady(); |
| | 4103 | + |
| | 4104 | +private Q_SLOTS: |
| | 4105 | + void scanIsDone(); |
| | 4106 | + void propertiesSwap(QMap<QString,QVariant>); |
| | 4107 | + |
| | 4108 | + void slotAccessPointAdded(QDBusObjectPath); |
| | 4109 | + void slotAccessPointRemoved(QDBusObjectPath); |
| | 4110 | + |
| | 4111 | private: |
| | 4112 | QNetworkManagerInterfaceDeviceWirelessPrivate *d; |
| | 4113 | - QNmDBusHelper *nmDBusHelper; |
| | 4114 | + QVariantMap propertyMap; |
| | 4115 | + QList <QDBusObjectPath> accessPointsList; |
| | 4116 | +}; |
| | 4117 | + |
| | 4118 | +class QNetworkManagerInterfaceDeviceModemPrivate; |
| | 4119 | +class QNetworkManagerInterfaceDeviceModem : public QObject |
| | 4120 | +{ |
| | 4121 | + Q_OBJECT |
| | 4122 | + |
| | 4123 | +public: |
| | 4124 | + |
| | 4125 | + enum ModemCapability { |
| | 4126 | + None = 0x0, |
| | 4127 | + Pots = 0x1, |
| | 4128 | + Cmda_Edvo = 0x2, |
| | 4129 | + Gsm_Umts = 0x4, |
| | 4130 | + Lte = 0x08 |
| | 4131 | + }; |
| | 4132 | + Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability) |
| | 4133 | + |
| | 4134 | + explicit QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath, |
| | 4135 | + QObject *parent = 0); |
| | 4136 | + ~QNetworkManagerInterfaceDeviceModem(); |
| | 4137 | + |
| | 4138 | + QDBusObjectPath path() const; |
| | 4139 | + QDBusInterface *connectionInterface() const; |
| | 4140 | + |
| | 4141 | + bool setConnections(); |
| | 4142 | + bool isValid(); |
| | 4143 | + |
| | 4144 | + ModemCapabilities modemCapabilities() const; |
| | 4145 | + ModemCapabilities currentCapabilities() const; |
| | 4146 | + |
| | 4147 | +Q_SIGNALS: |
| | 4148 | + void propertiesChanged(QMap<QString,QVariant>); |
| | 4149 | + void propertiesReady(); |
| | 4150 | + |
| | 4151 | +private Q_SLOTS: |
| | 4152 | + void propertiesSwap(QMap<QString,QVariant>); |
| | 4153 | + |
| | 4154 | +private: |
| | 4155 | + QNetworkManagerInterfaceDeviceModemPrivate *d; |
| | 4156 | + QVariantMap propertyMap; |
| | 4157 | }; |
| | 4158 | |
| | 4159 | +Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkManagerInterfaceDeviceModem::ModemCapabilities) |
| | 4160 | + |
| | 4161 | class QNetworkManagerSettingsPrivate; |
| | 4162 | class QNetworkManagerSettings : public QObject |
| | 4163 | { |
| | 4164 | @@ -349,13 +430,16 @@ |
| | 4165 | |
| | 4166 | QDBusInterface *connectionInterface() const; |
| | 4167 | QList <QDBusObjectPath> listConnections(); |
| | 4168 | + QString getConnectionByUuid(const QString &uuid); |
| | 4169 | bool setConnections(); |
| | 4170 | bool isValid(); |
| | 4171 | |
| | 4172 | Q_SIGNALS: |
| | 4173 | void newConnection(QDBusObjectPath); |
| | 4174 | + void connectionsListReady(); |
| | 4175 | private: |
| | 4176 | QNetworkManagerSettingsPrivate *d; |
| | 4177 | + QList <QDBusObjectPath> connectionsList; |
| | 4178 | }; |
| | 4179 | |
| | 4180 | class QNetworkManagerSettingsConnectionPrivate; |
| | 4181 | @@ -382,12 +466,14 @@ |
| | 4182 | bool isValid(); |
| | 4183 | |
| | 4184 | Q_SIGNALS: |
| | 4185 | - |
| | 4186 | - void updated(const QNmSettingsMap &settings); |
| | 4187 | + void updated(); |
| | 4188 | void removed(const QString &path); |
| | 4189 | + void settingsReady(); |
| | 4190 | + |
| | 4191 | +private Q_SLOTS: |
| | 4192 | + void slotSettingsRemoved(); |
| | 4193 | |
| | 4194 | private: |
| | 4195 | - QNmDBusHelper *nmDBusHelper; |
| | 4196 | QNetworkManagerSettingsConnectionPrivate *d; |
| | 4197 | }; |
| | 4198 | |
| | 4199 | @@ -408,22 +494,26 @@ |
| | 4200 | ~ QNetworkManagerConnectionActive(); |
| | 4201 | |
| | 4202 | QDBusInterface *connectionInterface() const; |
| | 4203 | - QString serviceName() const; |
| | 4204 | QDBusObjectPath connection() const; |
| | 4205 | QDBusObjectPath specificObject() const; |
| | 4206 | - QList<QDBusObjectPath> devices() const; |
| | 4207 | + QStringList devices() const; |
| | 4208 | quint32 state() const; |
| | 4209 | bool defaultRoute() const; |
| | 4210 | + bool default6Route() const; |
| | 4211 | bool setConnections(); |
| | 4212 | bool isValid(); |
| | 4213 | |
| | 4214 | |
| | 4215 | Q_SIGNALS: |
| | 4216 | - void propertiesChanged(QList<QDBusObjectPath>); |
| | 4217 | - void propertiesChanged( const QString &, QMap<QString,QVariant>); |
| | 4218 | + void propertiesChanged(QMap<QString,QVariant>); |
| | 4219 | + void propertiesReady(); |
| | 4220 | + |
| | 4221 | +private Q_SLOTS: |
| | 4222 | + void propertiesSwap(QMap<QString,QVariant>); |
| | 4223 | + |
| | 4224 | private: |
| | 4225 | QNetworkManagerConnectionActivePrivate *d; |
| | 4226 | - QNmDBusHelper *nmDBusHelper; |
| | 4227 | + QVariantMap propertyMap; |
| | 4228 | }; |
| | 4229 | |
| | 4230 | class QNetworkManagerIp4ConfigPrivate; |
| | 4231 | --- qtbase/src/plugins/bearer/networkmanager/qnmdbushelper.cpp |
| | 4232 | +++ /dev/null |
| | 4233 | @@ -1,130 +0,0 @@ |
| | 4234 | -/**************************************************************************** |
| | 4235 | -** |
| | 4236 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 4237 | -** Contact: http://www.qt-project.org/legal |
| | 4238 | -** |
| | 4239 | -** This file is part of the plugins of the Qt Toolkit. |
| | 4240 | -** |
| | 4241 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 4242 | -** Commercial License Usage |
| | 4243 | -** Licensees holding valid commercial Qt licenses may use this file in |
| | 4244 | -** accordance with the commercial license agreement provided with the |
| | 4245 | -** Software or, alternatively, in accordance with the terms contained in |
| | 4246 | -** a written agreement between you and Digia. For licensing terms and |
| | 4247 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 4248 | -** use the contact form at http://qt.digia.com/contact-us. |
| | 4249 | -** |
| | 4250 | -** GNU Lesser General Public License Usage |
| | 4251 | -** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 4252 | -** General Public License version 2.1 as published by the Free Software |
| | 4253 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 4254 | -** packaging of this file. Please review the following information to |
| | 4255 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 4256 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 4257 | -** |
| | 4258 | -** In addition, as a special exception, Digia gives you certain additional |
| | 4259 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 4260 | -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 4261 | -** |
| | 4262 | -** GNU General Public License Usage |
| | 4263 | -** Alternatively, this file may be used under the terms of the GNU |
| | 4264 | -** General Public License version 3.0 as published by the Free Software |
| | 4265 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 4266 | -** packaging of this file. Please review the following information to |
| | 4267 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 4268 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 4269 | -** |
| | 4270 | -** |
| | 4271 | -** $QT_END_LICENSE$ |
| | 4272 | -** |
| | 4273 | -****************************************************************************/ |
| | 4274 | - |
| | 4275 | -// this class is for helping qdbus get stuff |
| | 4276 | - |
| | 4277 | -#include "qnmdbushelper.h" |
| | 4278 | - |
| | 4279 | -#include "qnetworkmanagerservice.h" |
| | 4280 | - |
| | 4281 | -#include <QDBusError> |
| | 4282 | -#include <QDBusInterface> |
| | 4283 | -#include <QDBusMessage> |
| | 4284 | -#include <QDBusReply> |
| | 4285 | - |
| | 4286 | -#include <QDebug> |
| | 4287 | - |
| | 4288 | -#ifndef QT_NO_DBUS |
| | 4289 | - |
| | 4290 | -QT_BEGIN_NAMESPACE |
| | 4291 | - |
| | 4292 | -QNmDBusHelper::QNmDBusHelper(QObject * parent) |
| | 4293 | - : QObject(parent) |
| | 4294 | -{ |
| | 4295 | -} |
| | 4296 | - |
| | 4297 | -QNmDBusHelper::~QNmDBusHelper() |
| | 4298 | -{ |
| | 4299 | -} |
| | 4300 | - |
| | 4301 | -void QNmDBusHelper::deviceStateChanged(quint32 state) |
| | 4302 | - { |
| | 4303 | - QDBusMessage msg = this->message(); |
| | 4304 | - if(state == NM_DEVICE_STATE_ACTIVATED |
| | 4305 | - || state == NM_DEVICE_STATE_DISCONNECTED |
| | 4306 | - || state == NM_DEVICE_STATE_UNAVAILABLE |
| | 4307 | - || state == NM_DEVICE_STATE_FAILED) { |
| | 4308 | - emit pathForStateChanged(msg.path(), state); |
| | 4309 | - } |
| | 4310 | - } |
| | 4311 | - |
| | 4312 | -void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path) |
| | 4313 | -{ |
| | 4314 | - if(path.path().length() > 2) { |
| | 4315 | - QDBusMessage msg = this->message(); |
| | 4316 | - emit pathForAccessPointAdded(msg.path(), path); |
| | 4317 | - } |
| | 4318 | -} |
| | 4319 | - |
| | 4320 | -void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path) |
| | 4321 | -{ |
| | 4322 | - if(path.path().length() > 2) { |
| | 4323 | - QDBusMessage msg = this->message(); |
| | 4324 | - emit pathForAccessPointRemoved(msg.path(), path); |
| | 4325 | - } |
| | 4326 | -} |
| | 4327 | - |
| | 4328 | -void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map) |
| | 4329 | -{ |
| | 4330 | - QDBusMessage msg = this->message(); |
| | 4331 | - QMapIterator<QString, QVariant> i(map); |
| | 4332 | - while (i.hasNext()) { |
| | 4333 | - i.next(); |
| | 4334 | - if( i.key() == "State") { //state only applies to device interfaces |
| | 4335 | - quint32 state = i.value().toUInt(); |
| | 4336 | - if( state == NM_DEVICE_STATE_ACTIVATED |
| | 4337 | - || state == NM_DEVICE_STATE_DISCONNECTED |
| | 4338 | - || state == NM_DEVICE_STATE_UNAVAILABLE |
| | 4339 | - || state == NM_DEVICE_STATE_FAILED) { |
| | 4340 | - emit pathForPropertiesChanged( msg.path(), map); |
| | 4341 | - } |
| | 4342 | - } else if( i.key() == "ActiveAccessPoint") { |
| | 4343 | - emit pathForPropertiesChanged(msg.path(), map); |
| | 4344 | - // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path(); |
| | 4345 | - // } else if( i.key() == "Strength") |
| | 4346 | - // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt(); |
| | 4347 | - // else |
| | 4348 | - // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value(); |
| | 4349 | - } else if (i.key() == "ActiveConnections") { |
| | 4350 | - emit pathForPropertiesChanged(msg.path(), map); |
| | 4351 | - } |
| | 4352 | - } |
| | 4353 | -} |
| | 4354 | - |
| | 4355 | -void QNmDBusHelper::slotSettingsRemoved() |
| | 4356 | -{ |
| | 4357 | - QDBusMessage msg = this->message(); |
| | 4358 | - emit pathForSettingsRemoved(msg.path()); |
| | 4359 | -} |
| | 4360 | - |
| | 4361 | -QT_END_NAMESPACE |
| | 4362 | - |
| | 4363 | -#endif // QT_NO_DBUS |
| | 4364 | --- qtbase/src/plugins/bearer/networkmanager/qnmdbushelper.h |
| | 4365 | +++ /dev/null |
| | 4366 | @@ -1,79 +0,0 @@ |
| | 4367 | -/**************************************************************************** |
| | 4368 | -** |
| | 4369 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
| | 4370 | -** Contact: http://www.qt-project.org/legal |
| | 4371 | -** |
| | 4372 | -** This file is part of the plugins of the Qt Toolkit. |
| | 4373 | -** |
| | 4374 | -** $QT_BEGIN_LICENSE:LGPL$ |
| | 4375 | -** Commercial License Usage |
| | 4376 | -** Licensees holding valid commercial Qt licenses may use this file in |
| | 4377 | -** accordance with the commercial license agreement provided with the |
| | 4378 | -** Software or, alternatively, in accordance with the terms contained in |
| | 4379 | -** a written agreement between you and Digia. For licensing terms and |
| | 4380 | -** conditions see http://qt.digia.com/licensing. For further information |
| | 4381 | -** use the contact form at http://qt.digia.com/contact-us. |
| | 4382 | -** |
| | 4383 | -** GNU Lesser General Public License Usage |
| | 4384 | -** Alternatively, this file may be used under the terms of the GNU Lesser |
| | 4385 | -** General Public License version 2.1 as published by the Free Software |
| | 4386 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
| | 4387 | -** packaging of this file. Please review the following information to |
| | 4388 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
| | 4389 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| | 4390 | -** |
| | 4391 | -** In addition, as a special exception, Digia gives you certain additional |
| | 4392 | -** rights. These rights are described in the Digia Qt LGPL Exception |
| | 4393 | -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| | 4394 | -** |
| | 4395 | -** GNU General Public License Usage |
| | 4396 | -** Alternatively, this file may be used under the terms of the GNU |
| | 4397 | -** General Public License version 3.0 as published by the Free Software |
| | 4398 | -** Foundation and appearing in the file LICENSE.GPL included in the |
| | 4399 | -** packaging of this file. Please review the following information to |
| | 4400 | -** ensure the GNU General Public License version 3.0 requirements will be |
| | 4401 | -** met: http://www.gnu.org/copyleft/gpl.html. |
| | 4402 | -** |
| | 4403 | -** |
| | 4404 | -** $QT_END_LICENSE$ |
| | 4405 | -** |
| | 4406 | -****************************************************************************/ |
| | 4407 | - |
| | 4408 | -#ifndef QNMDBUSHELPERPRIVATE_H |
| | 4409 | -#define QNMDBUSHELPERPRIVATE_H |
| | 4410 | - |
| | 4411 | -#include <QDBusObjectPath> |
| | 4412 | -#include <QDBusContext> |
| | 4413 | -#include <QMap> |
| | 4414 | - |
| | 4415 | -#ifndef QT_NO_DBUS |
| | 4416 | - |
| | 4417 | -QT_BEGIN_NAMESPACE |
| | 4418 | - |
| | 4419 | -class QNmDBusHelper: public QObject, protected QDBusContext |
| | 4420 | - { |
| | 4421 | - Q_OBJECT |
| | 4422 | - public: |
| | 4423 | - QNmDBusHelper(QObject *parent = 0); |
| | 4424 | - ~QNmDBusHelper(); |
| | 4425 | - |
| | 4426 | - public slots: |
| | 4427 | - void deviceStateChanged(quint32); |
| | 4428 | - void slotAccessPointAdded( QDBusObjectPath ); |
| | 4429 | - void slotAccessPointRemoved( QDBusObjectPath ); |
| | 4430 | - void slotPropertiesChanged( QMap<QString,QVariant>); |
| | 4431 | - void slotSettingsRemoved(); |
| | 4432 | - |
| | 4433 | -Q_SIGNALS: |
| | 4434 | - void pathForStateChanged(const QString &, quint32); |
| | 4435 | - void pathForAccessPointAdded(const QString &, QDBusObjectPath ); |
| | 4436 | - void pathForAccessPointRemoved(const QString &, QDBusObjectPath ); |
| | 4437 | - void pathForPropertiesChanged(const QString &, QMap<QString,QVariant>); |
| | 4438 | - void pathForSettingsRemoved(const QString &); |
| | 4439 | -}; |
| | 4440 | - |
| | 4441 | -QT_END_NAMESPACE |
| | 4442 | - |
| | 4443 | -#endif // QT_NO_DBUS |
| | 4444 | - |
| | 4445 | -#endif// QNMDBUSHELPERPRIVATE_H |