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


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

The following commit has been merged in the master branch:
commit 752bdabffd8279611d7959415ad9a5b6971db077
Author: Vishesh Handa <me at vhanda.in>
Date:   Wed Aug 29 01:53:45 2012 +0530

    Account Query - Use a sparql query
    
    Instead of the complicated QueryLib query which is a lot slower, and
    takes a considerable overhead. Additionally, sparql queries are easier
    to optimize.
---
 kpeople/nepomuk-feeder/nepomuk-storage.cpp | 94 +++++++-----------------------
 kpeople/nepomuk-feeder/nepomuk-storage.h   |  3 -
 2 files changed, 22 insertions(+), 75 deletions(-)

diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
index 4a44231..4472003 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -378,85 +378,35 @@ void NepomukStorage::init()
 
     // Query Nepomuk for all of the ME PersonContact's IMAccounts.
     {
-        using namespace Nepomuk2::Query;
-
-        // Construct the query
-        ComparisonTerm accountTerm(Nepomuk2::Vocabulary::NCO::hasIMAccount(),
-                                   ResourceTerm(m_mePersonContact));
-        accountTerm.setInverted(true);
-
-        ComparisonTerm hasTelepathyIdTerm(Nepomuk2::Vocabulary::Telepathy::accountIdentifier(),
-                                          LiteralTerm());
-        hasTelepathyIdTerm.setVariableName("accountIdentifier");
-        ComparisonTerm hasProtocolTerm(Nepomuk2::Vocabulary::NCO::imAccountType(),
-                                       LiteralTerm());
-        hasProtocolTerm.setVariableName("protocol");
-
-        Query query(AndTerm(accountTerm,
-                            ResourceTypeTerm(Nepomuk2::Vocabulary::NCO::IMAccount()),
-                            hasTelepathyIdTerm, hasProtocolTerm));
-
-        // Connect to the result signals and launch the query.
-        QueryServiceClient *client = new QueryServiceClient(this);
-        connect(client,
-                SIGNAL(newEntries(QList<Nepomuk2::Query::Result>)),
-                SLOT(onAccountsQueryNewEntries(QList<Nepomuk2::Query::Result>)));
-        connect(client,
-                SIGNAL(entriesRemoved(QList<QUrl>)),
-                SLOT(onAccountsQueryEntriesRemoved(QList<QUrl>)));
-        connect(client,
-                SIGNAL(error(QString)),
-                SLOT(onAccountsQueryError(QString)));
-        connect(client,
-                SIGNAL(finishedListing()),
-                SLOT(onAccountsQueryFinishedListing()));
-        connect(client, SIGNAL(finishedListing()),
-                client, SLOT(deleteLater()));
-        kDebug() << "Me Query : " << query.toSparqlQuery();
-        client->query(query);
-    }
-}
+        QString query = QString::fromLatin1("select distinct ?r ?protocol ?accountIdentifier where {"
+                                            " ?r a nco:IMAccount . ?r nco:imAccountType ?protocol ."
+                                            " ?r %1 ?accountIdentifier . "
+                                            " %2 nco:hasIMAccount ?r . }")
+                        .arg( Soprano::Node::resourceToN3(Telepathy::accountIdentifier()),
+                              Soprano::Node::resourceToN3( m_mePersonContact ) );
+
+        Soprano::QueryResultIterator it = model->executeQuery( query, Soprano::Query::QueryLanguageSparql );
+        while( it.next() ) {
+            QUrl imAccount(it["r"].uri());
+
+            // If no Telepathy identifier, then the account is ignored.
+            QString identifier = it["accountIdentifier"].literal().toString();
+            // FIXME: This doesn't seem possible
+            if (identifier.isEmpty()) {
+                kDebug() << "Account does not have a Telepathy Account Identifier. Oops. Ignoring.";
+                continue;
+            }
 
-void NepomukStorage::onAccountsQueryNewEntries(const QList<Nepomuk2::Query::Result> &entries)
-{
-    kDebug();
-    // Iterate over all the IMAccounts found.
-    foreach (const Nepomuk2::Query::Result &result, entries) {
-        QUrl foundImAccount(result.resource().uri());
-        kDebug() << this << ": Found IM Account: " << foundImAccount;
 
-        // If no Telepathy identifier, then the account is ignored.
-        QString foundImAccountIdentifier(result.additionalBinding("accountIdentifier").toString());
-        if (foundImAccountIdentifier.isEmpty()) {
-            kDebug() << "Account does not have a Telepathy Account Identifier. Oops. Ignoring.";
-            continue;
+            // If it does have a telepathy identifier, then it is added to the cache.
+            AccountResources acRes( imAccount, it["protocol"].literal().toString() );
+            m_accounts.insert( identifier, imAccount );
         }
 
-        kDebug() << "Found a Telepathy account in Nepomuk, ID:" << foundImAccountIdentifier;
-
-        // If it does have a telepathy identifier, then it is added to the cache.
-        m_accounts.insert(foundImAccountIdentifier,
-                          AccountResources(foundImAccount,
-                                           result.additionalBinding("protocol").toString()));
+        QTimer::singleShot( 0, this, SLOT(onAccountsQueryFinishedListing()) );
     }
-
 }
 
-void NepomukStorage::onAccountsQueryEntriesRemoved(const QList<QUrl> &entries)
-{
-    kDebug();
-    // Remove the account from the cache
-    foreach (const QUrl &url, entries) {
-        m_accounts.remove(m_accounts.key(url));
-    }
-}
-
-void NepomukStorage::onAccountsQueryError(const QString &errorMessage)
-{
-    kWarning() << "A Nepomuk Error occurred:" << errorMessage;
-
-    emit initialised(false);
-}
 
 void NepomukStorage::onAccountsQueryFinishedListing()
 {
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.h b/kpeople/nepomuk-feeder/nepomuk-storage.h
index 64e1fd6..0774886 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.h
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.h
@@ -148,9 +148,6 @@ private Q_SLOTS:
     void init();
     void onSaveJobResult(KJob *job);
 
-    void onAccountsQueryNewEntries(const QList<Nepomuk2::Query::Result> &entries);
-    void onAccountsQueryEntriesRemoved(const QList<QUrl> &entries);
-    void onAccountsQueryError(const QString &errorMessage);
     void onAccountsQueryFinishedListing();
 
     void onContactsQueryNewEntries(const QList<Nepomuk2::Query::Result> &entries);

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list