From 263d6444bb1dbf58d6797a3307e5cde91d11b8df Mon Sep 17 00:00:00 2001
From: "Lamarque V. Souza" <lamarque@kde.org>
Date: Sun, 27 Nov 2011 12:54:08 -0200
Subject: [PATCH 01/10] Caches deviceUni and activatableType for
RemoteActivatable class to prevent dbus calls from
stalling the entire desktop.
CCBUG: 287002
---
libs/client/remoteactivatable.cpp | 50 +++++++++++++++++++++++--------------
libs/client/remoteactivatable.h | 2 +
libs/client/remoteactivatable_p.h | 2 +
plasma_nm_version.h | 2 +-
4 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/libs/client/remoteactivatable.cpp b/libs/client/remoteactivatable.cpp
index 75450a4..f23ac9d 100644
--- a/libs/client/remoteactivatable.cpp
+++ b/libs/client/remoteactivatable.cpp
@@ -18,6 +18,8 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <KDebug>
+
#include "remoteactivatable.h"
#include "remoteactivatable_p.h"
@@ -31,11 +33,7 @@ RemoteActivatable::RemoteActivatable(RemoteActivatablePrivate & dd, const QStrin
{
Q_D(RemoteActivatable);
d->activatableIface = new ActivatableInterface("org.kde.networkmanagement", dbusPath, QDBusConnection::sessionBus(), this);
- //kDebug() << "ActivatableInterface is (" << d->activatableIface << ") on" << d_ptr;
- connect(d->activatableIface, SIGNAL(activated()),
- this, SIGNAL(activated()));
- connect(d->activatableIface, SIGNAL(changed()),
- this, SIGNAL(changed()));
+ init();
}
RemoteActivatable::RemoteActivatable(const QString &dbusPath, QObject * parent)
@@ -43,10 +41,7 @@ RemoteActivatable::RemoteActivatable(const QString &dbusPath, QObject * parent)
{
Q_D(RemoteActivatable);
d->activatableIface = new ActivatableInterface("org.kde.networkmanagement", dbusPath, QDBusConnection::sessionBus(), this);
- connect(d->activatableIface, SIGNAL(activated()),
- this, SIGNAL(activated()));
- connect(d->activatableIface, SIGNAL(changed()),
- this, SIGNAL(changed()));
+ init();
}
RemoteActivatable::~RemoteActivatable()
@@ -54,24 +49,41 @@ RemoteActivatable::~RemoteActivatable()
delete d_ptr;
}
-Knm::Activatable::ActivatableType RemoteActivatable::activatableType() const
+void RemoteActivatable::init()
{
- Q_D(const RemoteActivatable);
- QDBusReply<uint> reply = d->activatableIface->activatableType();
+ Q_D(RemoteActivatable);
+ //kDebug() << "ActivatableInterface is (" << d->activatableIface << ") on" << d_ptr;
+ connect(d->activatableIface, SIGNAL(activated()),
+ this, SIGNAL(activated()));
+ connect(d->activatableIface, SIGNAL(changed()),
+ this, SIGNAL(changed()));
+
+ QDBusReply<QString> reply = d->activatableIface->deviceUni();
if (reply.isValid()) {
- return (Knm::Activatable::ActivatableType)reply.value();
+ d->deviceUni = reply.value();
+ } else {
+ kDebug() << "deviceUni reply is invalid";
+ }
+
+ QDBusReply<uint> reply2 = d->activatableIface->activatableType();
+ if (reply2.isValid()) {
+ d->activatableType = (Knm::Activatable::ActivatableType)reply2.value();
+ } else {
+ d->activatableType = Knm::Activatable::InterfaceConnection;
+ kDebug() << "activatableType reply is invalid";
}
- return Knm::Activatable::InterfaceConnection;
+}
+
+Knm::Activatable::ActivatableType RemoteActivatable::activatableType() const
+{
+ Q_D(const RemoteActivatable);
+ return d->activatableType;
}
QString RemoteActivatable::deviceUni() const
{
Q_D(const RemoteActivatable);
- QDBusReply<QString> reply = d->activatableIface->deviceUni();
- if (reply.isValid()) {
- return reply.value();
- }
- return QString();
+ return d->deviceUni;
}
void RemoteActivatable::activate()
diff --git a/libs/client/remoteactivatable.h b/libs/client/remoteactivatable.h
index 089a1c7..37b83ea 100644
--- a/libs/client/remoteactivatable.h
+++ b/libs/client/remoteactivatable.h
@@ -54,6 +54,8 @@ protected:
RemoteActivatable(const QString &dbusPath, QObject * parent);
RemoteActivatable(RemoteActivatablePrivate & dd, const QString &dbusPath, QObject * parent);
RemoteActivatablePrivate * d_ptr;
+private:
+ void init();
};
#endif // REMOTEACTIVATABLE_H
diff --git a/libs/client/remoteactivatable_p.h b/libs/client/remoteactivatable_p.h
index 51e183b..5fb573b 100644
--- a/libs/client/remoteactivatable_p.h
+++ b/libs/client/remoteactivatable_p.h
@@ -28,6 +28,8 @@ class RemoteActivatablePrivate
public:
virtual ~RemoteActivatablePrivate();
ActivatableInterface * activatableIface;
+ QString deviceUni;
+ Knm::Activatable::ActivatableType activatableType;
};
#endif // REMOTEACTIVATABLE_P_H
diff --git a/plasma_nm_version.h b/plasma_nm_version.h
index abb8a67..396e12c 100644
--- a/plasma_nm_version.h
+++ b/plasma_nm_version.h
@@ -1,4 +1,4 @@
#ifndef PLASMA_NM_VERSION_H
#define PLASMA_NM_VERSION_H
-static const char * plasmaNmVersion = "0.9.0_rc3 (nm09 20111126)";
+static const char * plasmaNmVersion = "0.9.0_rc3 (nm09 20111127)";
#endif
--
1.7.7.4