telepathy-qt: Services/Conn.I.SimplePresence: Emit presenseChanged() only when needed.

Alexandr Akulich kaffeine at kemper.freedesktop.org
Fri Nov 20 08:40:11 PST 2015


Module: telepathy-qt
Branch: master
Commit: e5a7abd70ac0f81afd138bc969b006e7eebd2692
URL:    http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=e5a7abd70ac0f81afd138bc969b006e7eebd2692

Author: Alexandr Akulich <akulichalexander at gmail.com>
Date:   Sun Sep 27 14:13:54 2015 +0500

Services/Conn.I.SimplePresence: Emit presenseChanged() only when needed.

Added a check if presence is actually changed.

---

 TelepathyQt/base-connection.cpp |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/TelepathyQt/base-connection.cpp b/TelepathyQt/base-connection.cpp
index 93ae17d..a332a56 100644
--- a/TelepathyQt/base-connection.cpp
+++ b/TelepathyQt/base-connection.cpp
@@ -1161,10 +1161,19 @@ void BaseConnectionSimplePresenceInterface::createAdaptor()
 
 void BaseConnectionSimplePresenceInterface::setPresences(const Tp::SimpleContactPresences &presences)
 {
+    Tp::SimpleContactPresences newPresences;
+
     foreach(uint handle, presences.keys()) {
+        if (mPriv->presences.contains(handle) && mPriv->presences.value(handle) == presences.value(handle)) {
+            continue;
+        }
         mPriv->presences[handle] = presences[handle];
+        newPresences[handle] = presences[handle];
+    }
+
+    if (!newPresences.isEmpty()) {
+        QMetaObject::invokeMethod(mPriv->adaptee, "presencesChanged", Q_ARG(Tp::SimpleContactPresences, newPresences)); //Can simply use emit in Qt5
     }
-    QMetaObject::invokeMethod(mPriv->adaptee, "presencesChanged", Q_ARG(Tp::SimpleContactPresences, presences)); //Can simply use emit in Qt5
 }
 
 void BaseConnectionSimplePresenceInterface::setSetPresenceCallback(const SetPresenceCallback &cb)



More information about the telepathy-commits mailing list