commit 81839a1566d0c0209a308d71b03837f996a19c96
Author: Lukáš Tinkl <lukas@kde.org>
Date:   Sat Sep 6 17:54:00 2014 +0200

    delay the notifications and secret agent initializations until needed
    
    BUG:338513
    REVIEW:120082

Index: plasma-nm/kded/service.cpp
===================================================================
--- plasma-nm.orig/kded/service.cpp	2014-09-15 09:53:43.409980948 +0200
+++ plasma-nm/kded/service.cpp	2014-09-15 09:53:43.369982542 +0200
@@ -57,19 +57,13 @@
 {
     Q_D(NetworkManagementService);
 
-    QDBusReply<bool> notificationsReply = QDBusConnection::sessionBus().interface()->isServiceRegistered("org.freedesktop.Notifications");
-    if (notificationsReply.value()) {
-        initializeNotifications();
-    } else {
-        QDBusServiceWatcher * watcher = new QDBusServiceWatcher("org.freedesktop.Notifications", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
-        connect(watcher, SIGNAL(serviceRegistered()), this, SLOT(doInitializeNotifications()));
-    }
+    d->agent = Q_NULLPTR;
+    d->notification = Q_NULLPTR;
 
 #if WITH_MODEMMANAGER_SUPPORT
-    d->modemMonitor = new ModemMonitor(this);
+    d->modemMonitor = Q_NULLPTR;
 #endif
-    d->bluetoothMonitor = new BluetoothMonitor(this);
-    d->agent = new SecretAgent(this);
+    d->bluetoothMonitor = Q_NULLPTR;
 }
 
 NetworkManagementService::~NetworkManagementService()
@@ -77,17 +71,25 @@
     delete d_ptr;
 }
 
-void NetworkManagementService::doInitializeNotifications()
+void NetworkManagementService::init()
 {
-    QDBusServiceWatcher * watcher = static_cast<QDBusServiceWatcher*>(sender());
-    watcher->deleteLater();
+    Q_D(NetworkManagementService);
 
-    initializeNotifications();
-}
+    if (!d->agent) {
+        d->agent = new SecretAgent(this);
+    }
 
-void NetworkManagementService::initializeNotifications()
-{
-    Q_D(NetworkManagementService);
+    if (!d->notification) {
+        d->notification = new Notification(this);
+    }
+
+#if WITH_MODEMMANAGER_SUPPORT
+    if (!d->modemMonitor) {
+        d->modemMonitor = new ModemMonitor(this);
+    }
+#endif
 
-    d->notification = new Notification(this);
+    if (!d->bluetoothMonitor) {
+        d->bluetoothMonitor = new BluetoothMonitor(this);
+    }
 }
Index: plasma-nm/kded/service.h
===================================================================
--- plasma-nm.orig/kded/service.h	2014-09-15 09:53:43.409980948 +0200
+++ plasma-nm/kded/service.h	2014-09-15 09:53:43.369982542 +0200
@@ -35,18 +35,18 @@
 
 class PLASMA_NM_EXPORT NetworkManagementService : public KDEDModule
 {
+    Q_CLASSINFO("D-Bus Interface", "org.kde.plasmanetworkmanagement")
     Q_OBJECT
     Q_DECLARE_PRIVATE(NetworkManagementService)
 public:
     NetworkManagementService(QObject * parent, const QVariantList&);
     virtual ~NetworkManagementService();
+
 public Q_SLOTS:
-    void doInitializeNotifications();
+    Q_SCRIPTABLE void init();
 
 private:
     NetworkManagementServicePrivate * d_ptr;
-
-    void initializeNotifications();
 };
 
 #endif // PLASMANM_KDED_SERVICE_H
Index: plasma-nm/libs/handler.cpp
===================================================================
--- plasma-nm.orig/libs/handler.cpp	2014-09-15 09:53:43.409980948 +0200
+++ plasma-nm/libs/handler.cpp	2014-09-15 09:53:43.369982542 +0200
@@ -52,7 +52,10 @@
     , m_tmpWimaxEnabled(NetworkManager::isWimaxEnabled())
     , m_tmpWirelessEnabled(NetworkManager::isWirelessEnabled())
     , m_tmpWwanEnabled(NetworkManager::isWwanEnabled())
+    , m_agentIface(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/networkmanagement"),
+                   QStringLiteral("org.kde.plasmanetworkmanagement"))
 {
+    m_agentIface.call(QStringLiteral("init"));
 }
 
 Handler::~Handler()
Index: plasma-nm/libs/handler.h
===================================================================
--- plasma-nm.orig/libs/handler.h	2014-09-15 09:53:43.409980948 +0200
+++ plasma-nm/libs/handler.h	2014-09-15 09:53:43.369982542 +0200
@@ -21,6 +21,8 @@
 #ifndef PLASMA_NM_HANDLER_H
 #define PLASMA_NM_HANDLER_H
 
+#include <QDBusInterface>
+
 #include <NetworkManagerQt/Connection>
 
 #include "plasmanm_export.h"
@@ -109,6 +111,7 @@
     QString m_tmpSpecificPath;
 
     bool isBtEnabled();
+    QDBusInterface m_agentIface;
 };
 
 #endif // PLASMA_NM_HANDLER_H
