[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:15:37 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-kded-module.git;a=commitdiff;h=fffcc2e

The following commit has been merged in the master branch:
commit fffcc2e011b6380a5478a9833d4dcd331b7906e6
Author: James Smith <smithjd15 at gmail.com>
Date:   Thu Feb 13 11:22:40 2014 +0100

    Fix delayed status update for KTp
    
    Fixes bug where state changes are slow to be returned to user-set values
    after autoaway / screensaveraway interruption.
    
    REVIEW: 114569
---
 telepathy-kded-module-plugin.h |  4 ++
 telepathy-module.cpp           | 86 ++++++++++++++++++++++++++++++++++++++----
 telepathy-module.h             |  6 +++
 telepathy-mpris.cpp            |  9 +----
 4 files changed, 90 insertions(+), 15 deletions(-)

diff --git a/telepathy-kded-module-plugin.h b/telepathy-kded-module-plugin.h
index b837903..4c16169 100644
--- a/telepathy-kded-module-plugin.h
+++ b/telepathy-kded-module-plugin.h
@@ -42,6 +42,7 @@ public:
     virtual QString pluginName() const = 0;
 
     Tp::Presence requestedPresence() const { return m_requestedPresence; }
+    QString requestedStatusMessage() const { return m_requestedStatusMessage; }
 
 public Q_SLOTS:
     /// Deriving classes with configuration must have this method reimplemented
@@ -49,17 +50,20 @@ public Q_SLOTS:
 
 Q_SIGNALS:
     void requestPresenceChange(const Tp::Presence &presence);
+    void requestStatusMessageChange(const QString statusMessage);
     void activate(bool);
 
 protected:
     void setActive(bool active);
     void setEnabled(bool enabled);
     void setRequestedPresence(const Tp::Presence &presence) { m_requestedPresence = presence; }
+    void setRequestedStatusMessage(const QString statusMessage) { m_requestedStatusMessage = statusMessage; }
 
     KTp::GlobalPresence *m_globalPresence;
 
 private:
     Tp::Presence m_requestedPresence;
+    QString m_requestedStatusMessage;
     bool m_enabled;
     bool m_active;
 };
diff --git a/telepathy-module.cpp b/telepathy-module.cpp
index 32e3a43..5eb70e2 100644
--- a/telepathy-module.cpp
+++ b/telepathy-module.cpp
@@ -109,7 +109,10 @@ void TelepathyModule::onAccountManagerReady(Tp::PendingOperation *op)
     m_autoConnect = new AutoConnect(this);
 
     //earlier in list = higher priority
-    m_pluginStack << m_autoAway << m_screenSaverAway << m_mpris;
+    m_pluginStack << m_autoAway << m_screenSaverAway;
+
+    //status message plugins are second to user-set status messages and presences
+    m_statusMessagePluginStack << m_mpris;
 
     m_errorHandler = new ErrorHandler(this);
     m_contactHandler = new ContactRequestHandler(this);
@@ -130,7 +133,7 @@ void TelepathyModule::onRequestedPresenceChanged(const KTp::Presence &presence)
     }
 
     //if it's changed to what we set it to. Ignore it.
-    if (presence == currentPluginPresence()) {
+    if (presence == presenceThrottle()) {
         return;
     }
 
@@ -139,13 +142,49 @@ void TelepathyModule::onRequestedPresenceChanged(const KTp::Presence &presence)
 
     //save presence (needed for autoconnect)
     m_autoConnect->savePresence(presence);
+
+    // keep status messages current. User-requested status message changes (or plugin-requested status and message) won't return
+    // to automatic status message until the next status message plugin signals.
+    if (activeStatusMessagePlugin()) {
+        if (!presence.statusMessage().isEmpty()) {
+            return;
+        }
+        if (presence != presenceThrottle()) {
+            setPresence(presenceThrottle());
+        }
+    }
 }
 
 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)
-    setPresence(currentPluginPresence());
+    // cut down on unneccessary status updates by only updating when the current global presence isn't the same as the filtered 
+    // presence. This also helps with misbehaving plugins, in particular the mpris2 plugin ticks and outputs every second.
+    if (m_globalPresence->currentPresence() != presenceThrottle()) {
+        setPresence(presenceThrottle());
+    }
+}
+
+const QString TelepathyModule::statusMessageStack()
+{
+    QString expectedStatusMessage = m_lastUserPresence.statusMessage();
+    if (activeStatusMessagePlugin() && m_lastUserPresence.statusMessage().isEmpty()) {
+        expectedStatusMessage = currentPluginStatusMessage();
+    }
+    if (activePlugin() && !currentPluginPresence().statusMessage().isEmpty()) {
+        expectedStatusMessage = currentPluginPresence().statusMessage();
+    }
+    return expectedStatusMessage;
+}
+
+KTp::Presence TelepathyModule::presenceThrottle()
+{
+    KTp::Presence expectedPresence = m_lastUserPresence;
+    if (activePlugin()) {
+        expectedPresence = currentPluginPresence();
+    }
+    expectedPresence.setStatusMessage(statusMessageStack());
+    return expectedPresence;
 }
 
 void TelepathyModule::setPresence(const KTp::Presence &presence)
@@ -161,14 +200,47 @@ void TelepathyModule::setPresence(const KTp::Presence &presence)
 
 KTp::Presence TelepathyModule::currentPluginPresence() const
 {
+    KTp::Presence requestedPresence;
     //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();
+            requestedPresence = plugin->requestedPresence();
         }
     }
-    //no plugins active, return the last presence the user set.
-    return m_lastUserPresence;
+    return requestedPresence;
 }
 
+QString TelepathyModule::currentPluginStatusMessage()
+{
+    QString requestedStatusMessage;
+    //search plugins in priority order. If a plugin is active, return the message it thinks it should.
+    Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_statusMessagePluginStack) {
+    if (plugin->isActive() && plugin->isEnabled()) {
+        requestedStatusMessage = plugin->requestedStatusMessage();
+        }
+    }
+    return requestedStatusMessage;
+}
+
+bool TelepathyModule::activePlugin()
+{ 
+    bool activePlugin = false;
+    Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_pluginStack) {
+        if (plugin->isActive()) {
+            activePlugin = true;
+        }
+    }
+    return activePlugin;
+}
+
+bool TelepathyModule::activeStatusMessagePlugin()
+{
+    bool activeStatusMessagePlugin = false;
+    Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_statusMessagePluginStack) {
+        if (plugin->isActive()) {
+           activeStatusMessagePlugin = true;
+        }
+    }
+    return activeStatusMessagePlugin;
+}
 #include "telepathy-module.moc"
diff --git a/telepathy-module.h b/telepathy-module.h
index a99c990..2213cdf 100644
--- a/telepathy-module.h
+++ b/telepathy-module.h
@@ -62,6 +62,11 @@ private Q_SLOTS:
 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() const;
+    QString currentPluginStatusMessage();
+    KTp::Presence presenceThrottle();
+    const QString statusMessageStack();
+    bool activePlugin();
+    bool activeStatusMessagePlugin();
     void setPresence(const KTp::Presence &presence);
 
 private:
@@ -75,6 +80,7 @@ private:
     ScreenSaverAway         *m_screenSaverAway;
 
     QList<TelepathyKDEDModulePlugin*> m_pluginStack;
+    QList<TelepathyKDEDModulePlugin*> m_statusMessagePluginStack;
     KTp::Presence m_lastUserPresence;
 };
 
diff --git a/telepathy-mpris.cpp b/telepathy-mpris.cpp
index 12d049d..69e8562 100644
--- a/telepathy-mpris.cpp
+++ b/telepathy-mpris.cpp
@@ -261,14 +261,7 @@ void TelepathyMPRIS::setTrackToPresence()
     statusMessage.replace(QLatin1String("%album"), album, Qt::CaseInsensitive);
     statusMessage.replace(QLatin1String("%track"), trackNumber, Qt::CaseInsensitive);
 
-    Tp::Presence requestedPresence = m_globalPresence->requestedPresence();
-    Tp::SimplePresence presence;
-
-    presence.type = requestedPresence.type();
-    presence.status = requestedPresence.status();
-    presence.statusMessage = statusMessage;
-
-    setRequestedPresence(Tp::Presence(presence));
+    setRequestedStatusMessage(statusMessage);
     setActive(true);
 }
 

-- 
ktp-kded-integration-module packaging



More information about the pkg-kde-commits mailing list