diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-18 00:12:24 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-18 00:12:24 (GMT) |
commit | 49f63d8f37fcd45ebe527f3554ff7b4c34d8545e (patch) | |
tree | d00a20f7a61f6d6c5cb0dcd5d32de49a653cb113 /src/plugins | |
parent | 4cd7e2ebd675fdc0b00d9a29f64e4189e74f7656 (diff) | |
download | Qt-49f63d8f37fcd45ebe527f3554ff7b4c34d8545e.zip Qt-49f63d8f37fcd45ebe527f3554ff7b4c34d8545e.tar.gz Qt-49f63d8f37fcd45ebe527f3554ff7b4c34d8545e.tar.bz2 |
Don't load NetworkManager plugin in NetworkManager is not available.
Diffstat (limited to 'src/plugins')
4 files changed, 20 insertions, 6 deletions
diff --git a/src/plugins/bearer/networkmanager/main.cpp b/src/plugins/bearer/networkmanager/main.cpp index f62b847..6c97a22 100644 --- a/src/plugins/bearer/networkmanager/main.cpp +++ b/src/plugins/bearer/networkmanager/main.cpp @@ -72,10 +72,15 @@ QStringList QNetworkManagerEnginePlugin::keys() const QBearerEngine *QNetworkManagerEnginePlugin::create(const QString &key) const { - if (key == QLatin1String("networkmanager")) - return new QNetworkManagerEngine; - else - return 0; + if (key == QLatin1String("networkmanager")) { + QNetworkManagerEngine *engine = new QNetworkManagerEngine; + if (engine->networkManagerAvailable()) + return engine; + else + delete engine; + } + + return 0; } Q_EXPORT_STATIC_PLUGIN(QNetworkManagerEnginePlugin) diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index 3f3e1bd..4c8928c 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -65,6 +65,9 @@ QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent) systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_SYSTEM_SETTINGS, this)), userSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_USER_SETTINGS, this)) { + if (!interface->isValid()) + return; + interface->setConnections(); connect(interface, SIGNAL(deviceAdded(QDBusObjectPath)), this, SLOT(deviceAdded(QDBusObjectPath))); @@ -115,6 +118,11 @@ QNetworkManagerEngine::~QNetworkManagerEngine() { } +bool QNetworkManagerEngine::networkManagerAvailable() const +{ + return interface->isValid(); +} + void QNetworkManagerEngine::doRequestUpdate() { emit updateCompleted(); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h index 70efc05..ca1f857 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -70,6 +70,8 @@ public: QNetworkManagerEngine(QObject *parent = 0); ~QNetworkManagerEngine(); + bool networkManagerAvailable() const; + QString getInterfaceFromId(const QString &id); bool hasIdentifier(const QString &id); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 7617e94..5dc0ea4 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -78,7 +78,6 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent) NM_DBUS_INTERFACE, dbusConnection); if (!d->connectionInterface->isValid()) { - qWarning() << "Could not find NetworkManager"; d->valid = false; return; } @@ -321,7 +320,7 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de dbusConnection); if (!d->connectionInterface->isValid()) { d->valid = false; - qWarning() << "Could not find NetworkManager"; + qWarning() << "Could not find NetworkManagerInterfaceDevice"; return; } d->valid = true; |