[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:07:09 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=1cc9221

The following commit has been merged in the master branch:
commit 1cc92215674f3e3ce4519705db7b694217375e67
Author: George Goldberg <grundleborg at googlemail.com>
Date:   Sat Feb 13 16:35:30 2010 +0000

    Look in Nepomuk for contacts, and get the resources if they already exist, otherwise create them.
    
    svn path=/trunk/playground/network/telepathy-integration-daemon/; revision=1089651
---
 kpeople/nepomuk-feeder/telepathycontact.cpp | 83 +++++++++++++++++++++++++++++
 kpeople/nepomuk-feeder/telepathycontact.h   |  5 ++
 2 files changed, 88 insertions(+)

diff --git a/kpeople/nepomuk-feeder/telepathycontact.cpp b/kpeople/nepomuk-feeder/telepathycontact.cpp
index 68abdf5..6748f6a 100644
--- a/kpeople/nepomuk-feeder/telepathycontact.cpp
+++ b/kpeople/nepomuk-feeder/telepathycontact.cpp
@@ -23,8 +23,18 @@
 
 #include "telepathyaccount.h"
 
+// Ontology Vocabularies
+#include "nco.h"
+#include "telepathy.h"
+
 #include <KDebug>
 
+#include <Nepomuk/ResourceManager>
+#include <Nepomuk/Variant>
+
+#include <Soprano/Model>
+#include <Soprano/QueryResultIterator>
+
 TelepathyContact::TelepathyContact(Tp::ContactPtr contact,
                                    Tp::ConnectionPtr connection,
                                    Nepomuk::IMAccount accountResource,
@@ -44,6 +54,9 @@ TelepathyContact::TelepathyContact(Tp::ContactPtr contact,
     connect(m_connection.data(),
             SIGNAL(invalidated(Tp::DBusProxy*, const QString&, const QString&)),
             SLOT(deleteLater()));
+
+    // Find the Nepomuk resource for this contact, or create a new one if necessary.
+    doNepomukSetup();
 }
 
 TelepathyContact::~TelepathyContact()
@@ -51,6 +64,76 @@ TelepathyContact::~TelepathyContact()
     kDebug();
 }
 
+void TelepathyContact::doNepomukSetup()
+{
+    // Query Nepomuk for all IM accounts that isBuddyOf the accountResource
+    QString query = QString("select distinct ?a ?b where { ?a %1 %2 . ?a a %3 . ?b %4 ?a . ?b a %5}")
+                            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::Telepathy::isBuddyOf()))
+                            .arg(Soprano::Node::resourceToN3(m_accountResource.uri()))
+                            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::IMAccount()))
+                            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::hasIMAccount()))
+                            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::PersonContact()));
+
+    Soprano::Model *model = Nepomuk::ResourceManager::instance()->mainModel();
+
+    Soprano::QueryResultIterator it = model->executeQuery(query, Soprano::Query::QueryLanguageSparql);
+
+    // Iterate over all the IMAccounts found.
+    while(it.next()) {
+        Nepomuk::IMAccount foundImAccount(it.binding("a").uri());
+        kDebug() << "Found IM Account: " << foundImAccount.uri();
+        Nepomuk::IMAccount foundPersonContact(it.binding("b").uri());
+        kDebug() << "Person Contact: " << foundPersonContact.uri();
+
+        // Check that the IM account only has one ID.
+        QStringList accountIDs = foundImAccount.imIDs();
+
+        if (accountIDs.size() != 1) {
+            kDebug() << "Account does not have 1 ID. Oops. Ignoring."
+                     << "Number of Identifiers: "
+                     << accountIDs.size();
+                     continue;
+        }
+
+        // Exactly one ID found. Check if it matches the one we are looking for.
+        QString accountID = accountIDs.first();
+        kDebug() << "Account ID:" << accountID;
+
+        if (accountID == m_contact->id()) {
+            kDebug() << "Found the corresponding IMAccount in Nepomuk.";
+                // It matches, so set our member variables to found resources and stop looping.
+                m_contactIMAccountResource = foundImAccount;
+                m_contactPersonContactResource = foundPersonContact;
+
+                // Sync any properties that may have changed since last time we were online.
+                if (m_contactIMAccountResource.property(Nepomuk::Vocabulary::NCO::imNickname())
+                    != m_contact->alias()) {
+                    //onNicknameChanged(m_account->nickname());
+                }
+                //onCurrentPresenceChanged(m_account->currentPresence()); // We can always assume this one needs syncing.
+                // FIXME: What other properties do we need to sync?
+
+                break;
+        }
+    }
+
+    // If the contactIMAccountResource is still empty, create a new IMAccount and PersonContact.
+    if (m_contactIMAccountResource.uri().isEmpty()) {
+        kDebug() << this << ": Create new IM Account and corresponding PersonContact";
+
+        m_contactIMAccountResource.addProperty(Nepomuk::Vocabulary::NCO::imID(),
+                                               m_contact->id());
+        m_contactIMAccountResource.addProperty(Nepomuk::Vocabulary::Telepathy::isBuddyOf(),
+                                               m_accountResource);
+        m_contactIMAccountResource.addProperty(Nepomuk::Vocabulary::NCO::imNickname(),
+                                               m_contact->alias());
+
+        m_contactPersonContactResource.addProperty(Nepomuk::Vocabulary::NCO::hasIMAccount(),
+                                                   m_contactIMAccountResource);
+        // FIXME: Store any other relevant Contact properties to Nepomuk.
+    }
+}
+
 
 #include "telepathycontact.moc"
 
diff --git a/kpeople/nepomuk-feeder/telepathycontact.h b/kpeople/nepomuk-feeder/telepathycontact.h
index ff34afb..560c156 100644
--- a/kpeople/nepomuk-feeder/telepathycontact.h
+++ b/kpeople/nepomuk-feeder/telepathycontact.h
@@ -23,6 +23,7 @@
 #define TELEPATHY_INTEGRATION_DAEMON_TELEPATHYCONTACT_H
 
 #include "imaccount.h"
+#include "personcontact.h"
 
 #include <QtCore/QObject>
 
@@ -48,10 +49,14 @@ public:
 private:
     Q_DISABLE_COPY(TelepathyContact);
 
+    void doNepomukSetup();
+
     TelepathyAccount *m_parent;
     Tp::ContactPtr m_contact;
     Tp::ConnectionPtr m_connection;
     Nepomuk::IMAccount m_accountResource;
+    Nepomuk::IMAccount m_contactIMAccountResource;
+    Nepomuk::PersonContact m_contactPersonContactResource;
 };
 
 

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list