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


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

The following commit has been merged in the master branch:
commit 2cac9208c1aa26fd1666a9ac934123a7205f3310
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Thu Mar 14 13:58:54 2013 +0100

    Store avatar tokens to use them when contact is offline
    
    Workarounds a Tp bug/feature that returns an empty avatarToken for
    offline users, so we can't display proper avatars for offline contacts
    when (any) contact list is started.
    
    REVIEW: 109432
    BUG: 315939
    FIXED-IN: 0.6.0
---
 contactnotify.cpp    | 44 ++++++++++++++++++++++++++++++++++++++++++++
 contactnotify.h      |  6 +++++-
 telepathy-module.cpp |  1 +
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/contactnotify.cpp b/contactnotify.cpp
index ad82a73..4dd3249 100644
--- a/contactnotify.cpp
+++ b/contactnotify.cpp
@@ -26,6 +26,7 @@
 
 #include <KNotification>
 #include <KAboutData>
+#include <KConfigGroup>
 
 #include <KTp/presence.h>
 #include <KTp/global-contact-manager.h>
@@ -78,6 +79,17 @@ void ContactNotify::contactPresenceChanged(const Tp::Presence &presence)
     }
 
     m_presenceHash.insert(contact->id(), Presence::sortPriority(presence.type()));
+
+    //if the contact has gone offline, check if we're not getting an empty token
+    //which would overwrite already stored token
+    if (presence.type() == Tp::ConnectionPresenceTypeOffline) {
+        if (contact->avatarToken().isEmpty() && m_avatarTokensHash.contains(contact->id())) {
+            return;
+        }
+    }
+
+    m_avatarTokensHash.insert(contact->id(), contact->avatarToken());
+    QTimer::singleShot(0, this, SLOT(saveAvatarTokens()));
 }
 
 void ContactNotify::sendNotification(const QString &text, const KIcon &icon, const Tp::ContactPtr &contact)
@@ -102,13 +114,45 @@ void ContactNotify::onContactsChanged(const Tp::Contacts &contactsAdded, const T
     Q_FOREACH(const Tp::ContactPtr &contact, contactsAdded) {
         connect(contact.data(), SIGNAL(presenceChanged(Tp::Presence)),
                 SLOT(contactPresenceChanged(Tp::Presence)));
+        connect(contact.data(), SIGNAL(avatarTokenChanged(QString)),
+                SLOT(contactAvatarTokenChanged(QString)));
 
         currentPresence = contact->presence();
         m_presenceHash[contact->id()] = Presence::sortPriority(currentPresence.type());
+        m_avatarTokensHash[contact->id()] = contact->avatarToken();
 
     }
 
     Q_FOREACH(const Tp::ContactPtr &contact, contactsRemoved) {
         m_presenceHash.remove(contact->id());
     }
+
+    QTimer::singleShot(0, this, SLOT(saveAvatarTokens()));
  }
+
+void ContactNotify::saveAvatarTokens()
+{
+    KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("ktelepathy-avatarsrc"));
+
+    QHashIterator<QString, QString> i(m_avatarTokensHash);
+
+    while (i.hasNext()) {
+        i.next();
+        KConfigGroup avatarsGroup = config->group(i.key());
+        avatarsGroup.writeEntry(QLatin1String("avatarToken"), i.value());
+    }
+
+    config->sync();
+}
+
+void ContactNotify::contactAvatarTokenChanged(const QString &avatarToken)
+{
+    Tp::ContactPtr contact(qobject_cast<Tp::Contact*>(sender()));
+
+    if (!contact) {
+        return;
+    }
+
+    m_avatarTokensHash[contact->id()] = avatarToken;
+    QTimer::singleShot(0, this, SLOT(saveAvatarTokens()));
+}
diff --git a/contactnotify.h b/contactnotify.h
index 9018114..e3a5bb6 100644
--- a/contactnotify.h
+++ b/contactnotify.h
@@ -37,11 +37,15 @@ public:
 private Q_SLOTS:
     void onContactsChanged(const Tp::Contacts &contactsAdded, const Tp::Contacts &contactsRemoved);
     void contactPresenceChanged(const Tp::Presence &presence);
+    void contactAvatarTokenChanged(const QString &avatarToken);
+    void saveAvatarTokens();
 
 private:
-    Tp::AccountManagerPtr m_accountManager;
     void sendNotification(const QString &text, const KIcon &icon, const Tp::ContactPtr &contact);
+
+    Tp::AccountManagerPtr m_accountManager;
     QHash<QString, int> m_presenceHash;
+    QHash<QString, QString> m_avatarTokensHash;
 };
 
 #endif // CONTACTNOTIFY_H
diff --git a/telepathy-module.cpp b/telepathy-module.cpp
index 1c986b1..a28bca8 100644
--- a/telepathy-module.cpp
+++ b/telepathy-module.cpp
@@ -62,6 +62,7 @@ TelepathyModule::TelepathyModule(QObject* parent, const QList<QVariant>& args)
 
     Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(Tp::Features() << Tp::Contact::FeatureAlias
                                                                                       << Tp::Contact::FeatureSimplePresence
+                                                                                      << Tp::Contact::FeatureAvatarToken
                                                                                       << Tp::Contact::FeatureCapabilities);
 
     Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());

-- 
ktp-kded-integration-module packaging



More information about the pkg-kde-commits mailing list