[SCM] ktp-contact-runner packaging branch, master, updated. debian/16.04.2-1-47-g3973a3e

Maximiliano Curia maxy at moszumanska.debian.org
Tue Sep 12 14:08:10 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-runner.git;a=commitdiff;h=820d661

The following commit has been merged in the master branch:
commit 820d6618b9c6f40f22caaf4673a6962e22c7dff7
Author: James D. Smith <smithjd15 at gmail.com>
Date:   Thu Jan 5 18:35:30 2017 -0700

    PresenceModel integration.
    Reviewed-by: David Edmundson
---
 src/contactrunner.cpp | 34 +++++++++++++++++++++++++++++++++-
 src/contactrunner.h   |  5 +++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/src/contactrunner.cpp b/src/contactrunner.cpp
index 2605792..42269e6 100644
--- a/src/contactrunner.cpp
+++ b/src/contactrunner.cpp
@@ -40,6 +40,7 @@
 
 #include <KTp/presence.h>
 #include <KTp/global-presence.h>
+#include <KTp/Models/presence-model.h>
 #include <KTp/actions.h>
 #include <KTp/contact-factory.h>
 #include <KTp/contact.h>
@@ -57,7 +58,8 @@ Q_DECLARE_METATYPE(MatchInfo);
 
 ContactRunner::ContactRunner(QObject *parent, const QVariantList &args):
     Plasma::AbstractRunner(parent, args),
-    m_globalPresence(new KTp::GlobalPresence(this))
+    m_globalPresence(new KTp::GlobalPresence(this)),
+    m_model(new KTp::PresenceModel(this))
 {
     Q_UNUSED(args);
 
@@ -127,6 +129,8 @@ ContactRunner::ContactRunner(QObject *parent, const QVariantList &args):
     connect(m_accountManager->becomeReady(Tp::AccountManager::FeatureCore),
             SIGNAL(finished(Tp::PendingOperation*)),
             this, SLOT(accountManagerReady(Tp::PendingOperation*)));
+    connect(this, SIGNAL(prepare()), SLOT(prepare()));
+    connect(this, SIGNAL(teardown()), SLOT(teardown()));
 }
 
 ContactRunner::~ContactRunner()
@@ -134,6 +138,21 @@ ContactRunner::~ContactRunner()
 
 }
 
+void ContactRunner::prepare()
+{
+    for (int i = 0; i < m_model->rowCount() ; i++) {
+        KTp::Presence presence = m_model->data(i).value<KTp::Presence>();
+        if (!presence.statusMessage().isEmpty()) {
+            m_modelCustomPresences.prepend(presence);
+        }
+    }
+}
+
+void ContactRunner::teardown()
+{
+    m_modelCustomPresences.clear();
+}
+
 void ContactRunner::accountManagerReady(Tp::PendingOperation *operation)
 {
     if (operation->isError()) {
@@ -440,6 +459,19 @@ void ContactRunner::matchPresence(Plasma::RunnerContext &context)
         }
     }
 
+    /* Presence model custom presence matches */
+    bool exactModelMatch = false;
+    Q_FOREACH(const KTp::Presence &presence, m_modelCustomPresences) {
+        if (presence.statusMessage().contains(statusMessage, Qt::CaseInsensitive) && presence.displayString().contains(presenceString, Qt::CaseInsensitive)) {
+            addPresenceMatch(context, presence.type(), presence.statusMessage());
+            exactModelMatch = (presence.statusMessage().compare(statusMessage, Qt::CaseInsensitive) == 0);
+        }
+    }
+
+    if (exactModelMatch) {
+        return;
+    }
+
     if (all || i18nc("IM presence", "online").contains(presenceString, Qt::CaseInsensitive) ||  (term == connectCommand)) {
         addPresenceMatch(context, Tp::ConnectionPresenceTypeAvailable, statusMessage);
     }
diff --git a/src/contactrunner.h b/src/contactrunner.h
index 19e94fe..bbb33c1 100644
--- a/src/contactrunner.h
+++ b/src/contactrunner.h
@@ -24,6 +24,7 @@
 #include <QLoggingCategory>
 
 #include <KRunner/AbstractRunner>
+#include <KTp/Models/presence-model.h>
 
 #include <TelepathyQt/AccountManager>
 
@@ -65,6 +66,8 @@ class ContactRunner : public Plasma::AbstractRunner
 
   private Q_SLOTS:
     void accountManagerReady(Tp::PendingOperation *operation);
+    void prepare();
+    void teardown();
 
   private:
     bool hasCapability(const Tp::ContactPtr &contact, Capability capability) const;
@@ -76,8 +79,10 @@ class ContactRunner : public Plasma::AbstractRunner
                           const QString &statusMessage);
 
     KTp::GlobalPresence *m_globalPresence;
+    KTp::PresenceModel *m_model;
     Tp::AccountManagerPtr m_accountManager;
 
+    QList<KTp::Presence> m_modelCustomPresences;
     bool m_loggerDisabled;
 };
 

-- 
ktp-contact-runner packaging



More information about the pkg-kde-commits mailing list