[SCM] ktp-approver packaging branch, master, updated. debian/15.12.1-1-299-g62cbbd7

Maximiliano Curia maxy at moszumanska.debian.org
Fri May 27 09:13:06 UTC 2016


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

The following commit has been merged in the master branch:
commit b7f8e21983253f9349387130639e5d26ae44903e
Author: George Kiagiadakis <george.kiagiadakis at collabora.co.uk>
Date:   Mon Dec 6 19:07:22 2010 +0200

    Workaround the fact that contact factories in tp-qt4 don't work yet.
---
 src/textchannelapprover.cpp | 36 +++++++++++++++++++++++++++++++++++-
 src/textchannelapprover.h   | 20 ++++++++++++++++++++
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/src/textchannelapprover.cpp b/src/textchannelapprover.cpp
index a777582..3e4f9e3 100644
--- a/src/textchannelapprover.cpp
+++ b/src/textchannelapprover.cpp
@@ -20,8 +20,11 @@
 #include <KStatusNotifierItem>
 #include <KLocale>
 #include <KGlobal>
+#include <KDebug>
 #include <TelepathyQt4/ReceivedMessage>
 #include <TelepathyQt4/AvatarData>
+#include <TelepathyQt4/ContactManager>
+#include <TelepathyQt4/PendingContacts>
 
 TextChannelApprover::TextChannelApprover(const Tp::TextChannelPtr & channel, QObject *parent)
     : ChannelApprover(parent), m_notifierItem(getNotifierItem())
@@ -47,10 +50,17 @@ TextChannelApprover::~TextChannelApprover()
 
 void TextChannelApprover::onMessageReceived(const Tp::ReceivedMessage & msg)
 {
+    Tp::ContactPtr sender = msg.sender();
+    if (sender && (!sender->actualFeatures().contains(Tp::Contact::FeatureAlias) ||
+                   !sender->actualFeatures().contains(Tp::Contact::FeatureAvatarData)))
+    {
+        new MessageReceivedContactUpgrader(msg, this);
+        return;
+    }
+
     KNotification *notification = new KNotification("new_text_message");
     notification->setText(msg.text());
 
-    Tp::ContactPtr sender = msg.sender();
     if (sender) {
         notification->setTitle(i18n("Incoming message from %1", sender->alias()));
 
@@ -111,4 +121,28 @@ void TextChannelApprover::updateNotifierItemTooltip()
 }
 
 
+MessageReceivedContactUpgrader::MessageReceivedContactUpgrader(const Tp::ReceivedMessage & msg,
+                                                               TextChannelApprover *parent)
+    : QObject(parent), m_msg(msg), m_parent(parent)
+{
+    Tp::PendingContacts *pc = msg.sender()->manager()->upgradeContacts(
+        QList<Tp::ContactPtr>() << msg.sender(),
+        Tp::Features() << Tp::Contact::FeatureAlias << Tp::Contact::FeatureAvatarData
+    );
+
+    connect(pc, SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onUpgradeContactsFinished(Tp::PendingOperation*)));
+}
+
+void MessageReceivedContactUpgrader::onUpgradeContactsFinished(Tp::PendingOperation *operation)
+{
+    if (operation->isError()) {
+        kError() << "Could not upgrade contact" << operation->errorName()
+                                                << operation->errorMessage();
+    } else {
+        m_parent->onMessageReceived(m_msg);
+    }
+    deleteLater();
+}
+
 #include "textchannelapprover.moc"
diff --git a/src/textchannelapprover.h b/src/textchannelapprover.h
index 7f2e1db..ef3a6a2 100644
--- a/src/textchannelapprover.h
+++ b/src/textchannelapprover.h
@@ -22,6 +22,7 @@
 #include <QtCore/QSet>
 #include <QtCore/QSharedPointer>
 #include <TelepathyQt4/TextChannel>
+#include <TelepathyQt4/ReceivedMessage>
 
 class KStatusNotifierItem;
 class KNotification;
@@ -43,6 +44,25 @@ private:
 
     QSet<KNotification*> m_notifications;
     QSharedPointer<KStatusNotifierItem> m_notifierItem;
+
+    friend class MessageReceivedContactUpgrader;
+};
+
+
+/* This code is a temporary solution until tp-qt4 implements contact factories */
+class MessageReceivedContactUpgrader : public QObject
+{
+    Q_OBJECT
+public:
+    explicit MessageReceivedContactUpgrader(const Tp::ReceivedMessage & msg,
+                                            TextChannelApprover *parent);
+
+private Q_SLOTS:
+    void onUpgradeContactsFinished(Tp::PendingOperation *operation);
+
+private:
+    Tp::ReceivedMessage m_msg;
+    TextChannelApprover *m_parent;
 };
 
 #endif //TEXTCHANNELAPPROVER_H

-- 
ktp-approver packaging



More information about the pkg-kde-commits mailing list