[SCM] ktp-kded-integration-module packaging branch, master, updated. debian/15.12.1-2-382-gbd961c2
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:14:16 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-kded-module.git;a=commitdiff;h=140a26c
The following commit has been merged in the master branch:
commit 140a26c06e7bc951bcd5a7a35c491cae75b36c24
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sun Apr 8 00:15:37 2012 +0100
Simplify code considerably in presence code
Remove "unconnected dbus" signals being emitted
Removed the complex removing and adding things to a stack, just have a constant list (of two items) and loop through them.
Remove the priority code, as that now happens when you order the plugin list.
REVIEW: 104510
---
autoaway.cpp | 1 -
telepathy-kded-module-plugin.cpp | 2 +-
telepathy-kded-module-plugin.h | 3 --
telepathy-module.cpp | 104 ++++++++++++++-------------------------
telepathy-module.h | 5 ++
telepathy-mpris.cpp | 2 -
6 files changed, 42 insertions(+), 75 deletions(-)
diff --git a/autoaway.cpp b/autoaway.cpp
index c4d282d..24daab7 100644
--- a/autoaway.cpp
+++ b/autoaway.cpp
@@ -34,7 +34,6 @@ AutoAway::AutoAway(KTp::GlobalPresence* globalPresence, QObject* parent)
m_awayTimeoutId(-1),
m_extAwayTimeoutId(-1)
{
- setPluginPriority(99);
readConfig();
connect(KIdleTime::instance(), SIGNAL(timeoutReached(int)),
diff --git a/telepathy-kded-module-plugin.cpp b/telepathy-kded-module-plugin.cpp
index 418e96a..43cb383 100644
--- a/telepathy-kded-module-plugin.cpp
+++ b/telepathy-kded-module-plugin.cpp
@@ -25,7 +25,7 @@
TelepathyKDEDModulePlugin::TelepathyKDEDModulePlugin(KTp::GlobalPresence* globalPresence, QObject* parent)
: QObject(parent),
m_enabled(false),
- m_pluginPriority(50)
+ m_active(false)
{
m_globalPresence = globalPresence;
}
diff --git a/telepathy-kded-module-plugin.h b/telepathy-kded-module-plugin.h
index 431a46b..b2fe657 100644
--- a/telepathy-kded-module-plugin.h
+++ b/telepathy-kded-module-plugin.h
@@ -39,7 +39,6 @@ public:
bool isActive() const { return m_active; };
bool isEnabled() const { return m_enabled; };
- int pluginPriority() const { return m_pluginPriority; };
/// Deriving classes must return a valid plugin name in this method
virtual QString pluginName() const = 0;
@@ -52,7 +51,6 @@ Q_SIGNALS:
protected:
void setActive(bool active);
void setEnabled(bool enabled);
- void setPluginPriority(int priority) { m_pluginPriority = priority; };
void setRequestedPresence(const Tp::Presence &presence) { m_requestedPresence = presence; };
KTp::GlobalPresence *m_globalPresence;
@@ -61,7 +59,6 @@ private:
Tp::Presence m_requestedPresence;
bool m_enabled;
bool m_active;
- int m_pluginPriority;
};
#endif // TELEPATHY_KDED_MODULE_PLUGIN_H
diff --git a/telepathy-module.cpp b/telepathy-module.cpp
index 955ceec..f834b43 100644
--- a/telepathy-module.cpp
+++ b/telepathy-module.cpp
@@ -81,7 +81,6 @@ TelepathyModule::TelepathyModule(QObject* parent, const QList<QVariant>& args)
TelepathyModule::~TelepathyModule()
{
- onPresenceChanged(m_globalPresence->currentPresence());
}
void TelepathyModule::onAccountManagerReady(Tp::PendingOperation* op)
@@ -109,88 +108,57 @@ void TelepathyModule::onAccountManagerReady(Tp::PendingOperation* op)
connect(this, SIGNAL(settingsChanged()),
m_mpris, SLOT(onSettingsChanged()));
+ //earlier in list = higher priority
+ m_pluginStack << m_autoAway << m_mpris;
+
m_errorHandler = new ErrorHandler(m_accountManager, this);
m_contactHandler = new ContactRequestHandler(m_accountManager, this);
}
void TelepathyModule::onPresenceChanged(const KTp::Presence &presence)
{
- //only save if the presence is not auto-set
- if (m_pluginStack.isEmpty()) {
- KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("ktelepathyrc"));
- KConfigGroup presenceConfig = config->group("LastPresence");
+ //if it's any plugin - ignore it.
+ Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_pluginStack) {
+ if (plugin->isActive() && plugin->isEnabled()) {
+ return;
+ }
+ }
- presenceConfig.writeEntry(QLatin1String("PresenceType"), (uint)m_globalPresence->currentPresence().type());
- presenceConfig.writeEntry(QLatin1String("PresenceStatus"), m_globalPresence->currentPresence().status());
- presenceConfig.writeEntry(QLatin1String("PresenceMessage"), m_globalPresence->currentPresence().statusMessage());
+ //FUTURE
+ //instead of monitoring presence we monitor requestedPresence
+ // if this changes and presence != currentPluginPresence.. then it means the user has changed it.
+ // this will fix the kded presence bugs
- presenceConfig.sync();
- }
-}
+ //user is manually setting the presnece.
+ m_lastUserPresence = presence;
-void TelepathyModule::onPluginActivated(bool active)
-{
- TelepathyKDEDModulePlugin *plugin = qobject_cast<TelepathyKDEDModulePlugin*>(sender());
- Q_ASSERT(plugin);
-
- if (active) {
- kDebug() << "Received activation request, current active plugins:" << m_pluginStack.size();
- if (m_pluginStack.isEmpty()) {
- m_globalPresence->saveCurrentPresence();
- m_pluginStack.append(plugin);
- } else if (!m_pluginStack.contains(plugin)) {
- int i;
- for (i = 0; i < m_pluginStack.size(); i++) {
- if (plugin->pluginPriority() >= m_pluginStack.at(i)->pluginPriority()) {
- break;
- }
- }
- m_pluginStack.insert(i, plugin);
- }
+ KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("ktelepathyrc"));
+ KConfigGroup presenceConfig = config->group("LastPresence");
- kDebug() << "Activating" << plugin->pluginName();
+ presenceConfig.writeEntry(QLatin1String("PresenceType"), (uint)m_globalPresence->currentPresence().type());
+ presenceConfig.writeEntry(QLatin1String("PresenceStatus"), m_globalPresence->currentPresence().status());
+ presenceConfig.writeEntry(QLatin1String("PresenceMessage"), m_globalPresence->currentPresence().statusMessage());
- if (!m_globalPresence->onlineAccounts()->accounts().isEmpty()) {
- //signal all global presence instances that they should not save global presence message
- QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/Telepathy"),
- QLatin1String( "org.kde.Telepathy"),
- QLatin1String("presenceChanger"));
- message.setArguments(QList<QVariant>() << m_pluginStack.first()->pluginName());
- QDBusConnection::sessionBus().send(message);
+ presenceConfig.sync();
+}
- m_globalPresence->setPresence(m_pluginStack.first()->requestedPresence());
- }
- } else {
- kDebug() << "Received deactivation request, current active plugins:" << m_pluginStack.size();
- while (!m_pluginStack.isEmpty()) {
- if (!m_pluginStack.first()->isActive()) {
- kDebug() << "Deactivating" << m_pluginStack.first()->pluginName();
- m_pluginStack.removeFirst();
- } else {
- break;
- }
- }
+void TelepathyModule::onPluginActivated(bool active)
+{
+ Q_UNUSED(active);
+ //a plugin has changed state, set presence to whatever a plugin thinks it should be (or restore users setting)
+ m_globalPresence->setPresence(currentPluginPresence());
+}
- if (!m_globalPresence->onlineAccounts()->accounts().isEmpty()) {
- if (m_pluginStack.isEmpty()) {
- //signal out that presences are back to user control
- QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/Telepathy"),
- QLatin1String( "org.kde.Telepathy"),
- QLatin1String("presenceChanger"));
- message.setArguments(QList<QVariant>() << QString::fromLatin1("user"));
- QDBusConnection::sessionBus().send(message);
-
- m_globalPresence->restoreSavedPresence();
- } else {
- m_globalPresence->setPresence(m_pluginStack.first()->requestedPresence());
- }
+KTp::Presence TelepathyModule::currentPluginPresence()
+{
+ //search plugins in priority order. If a plugin is active, return the state it thinks it should be in.
+ Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_pluginStack) {
+ if (plugin->isActive() && plugin->isEnabled()) {
+ return plugin->requestedPresence();
}
}
-
- kDebug() << "Active plugins (" << m_pluginStack.size() << ")";
- for(int i = 0; i < m_pluginStack.size(); i++) {
- kDebug() << " " << m_pluginStack.at(i)->pluginName();
- }
+ //no plugins active, return the last presence the user set.
+ return m_lastUserPresence;
}
#include "telepathy-module.moc"
diff --git a/telepathy-module.h b/telepathy-module.h
index 05d8c38..3c94576 100644
--- a/telepathy-module.h
+++ b/telepathy-module.h
@@ -57,6 +57,10 @@ private Q_SLOTS:
void onPluginActivated(bool);
private:
+ /** Returns the presence we think we should be in. Either from the highest priority plugin, or if none are active, the last user set.*/
+ KTp::Presence currentPluginPresence();
+
+private:
Tp::AccountManagerPtr m_accountManager;
AutoAway *m_autoAway;
TelepathyMPRIS *m_mpris;
@@ -65,6 +69,7 @@ private:
ContactRequestHandler *m_contactHandler;
QList<TelepathyKDEDModulePlugin*> m_pluginStack;
+ KTp::Presence m_lastUserPresence;
};
#endif // TELEPATHY_MODULE_H
diff --git a/telepathy-mpris.cpp b/telepathy-mpris.cpp
index 543109c..c3c419d 100644
--- a/telepathy-mpris.cpp
+++ b/telepathy-mpris.cpp
@@ -37,8 +37,6 @@ TelepathyMPRIS::TelepathyMPRIS(KTp::GlobalPresence* globalPresence, QObject* par
: TelepathyKDEDModulePlugin(globalPresence, parent),
m_presenceActivated(false)
{
- setPluginPriority(50);
-
//read settings and detect players if plugin is enabled
onSettingsChanged();
--
ktp-kded-integration-module packaging
More information about the pkg-kde-commits
mailing list