diff options
author | Alexandr Akulich <akulichalexander@gmail.com> | 2015-09-27 14:13:54 +0500 |
---|---|---|
committer | Alexandr Akulich <akulichalexander@gmail.com> | 2015-10-11 03:36:57 +0500 |
commit | e5a7abd70ac0f81afd138bc969b006e7eebd2692 (patch) | |
tree | eb969c1ad07e4f030731e49c589bd39d21962f52 | |
parent | 3716c048d65d4984513591cb8b1031858201db6c (diff) |
Services/Conn.I.SimplePresence: Emit presenseChanged() only when needed.
Added a check if presence is actually changed.
-rw-r--r-- | TelepathyQt/base-connection.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/TelepathyQt/base-connection.cpp b/TelepathyQt/base-connection.cpp index 93ae17dc..a332a563 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) |