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


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

The following commit has been merged in the master branch:
commit 476bd2968a8196edd0c820f705b0ad5791660734
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sun Oct 13 19:23:32 2013 +0000

    Wipe all KTp contacts when we release
    
    REVIEW: 113235
---
 kpeople/nepomuk-feeder/controller.cpp | 64 ++++++++++++++++++++++++++++++++---
 kpeople/nepomuk-feeder/controller.h   |  1 +
 2 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/kpeople/nepomuk-feeder/controller.cpp b/kpeople/nepomuk-feeder/controller.cpp
index fa37b7e..5814c65 100644
--- a/kpeople/nepomuk-feeder/controller.cpp
+++ b/kpeople/nepomuk-feeder/controller.cpp
@@ -25,9 +25,21 @@
 #include "abstract-storage.h"
 
 #include <KDebug>
+#include <KJob>
+#include <KConfig>
+#include <KConfigGroup>
 
 #include <TelepathyQt/PendingReady>
 
+
+#include <Nepomuk2/DataManagement>
+#include <Nepomuk2/Resource>
+#include <Nepomuk2/ResourceManager>
+#include <Soprano/Model>
+#include <Soprano/QueryResultIterator>
+
+#define CURRENT_FEEDER_VERSION 1
+
 Controller::Controller(AbstractStorage *storage, QObject *parent)
  : QObject(parent),
    m_storage(storage)
@@ -46,6 +58,54 @@ void Controller::onStorageInitialised(bool success)
         return;
     }
 
+    QTimer::singleShot(0, this, SLOT(start()));
+}
+
+
+
+Controller::~Controller()
+{
+    kDebug();
+}
+
+void Controller::start()
+{
+    //if old data, wipe everything before we start
+    //wiping this file will trigger a re-import
+    KSharedConfigPtr config = KSharedConfig::openConfig("telepathyfeeder");
+    KConfigGroup configGroup = config->group("Feeder");
+
+    if (configGroup.readEntry<int>("feederVersion", 0) != CURRENT_FEEDER_VERSION) {
+        kDebug() << "wiping old data";
+        //wipe contacts
+        {
+            const QString query = QString::fromLatin1("select distinct ?uri where {?uri a nco:PersonContact. ?uri nco:hasIMAccount ?x. }");
+            Soprano::Model *model = Nepomuk2::ResourceManager::instance()->mainModel();
+            Soprano::QueryResultIterator it = model->executeQuery(query, Soprano::Query::QueryLanguageSparql);
+            while (it.next()) {
+                KJob *job = Nepomuk2::removeResources(QList<QUrl>() << it["uri"].uri());
+                job->exec();
+            }
+            kDebug() << "wiping old contacts done";
+        }
+        //wipe people with no grounding occurences
+        {
+            const QString query = QString::fromLatin1("select ?uri ?where {?uri a pimo:Person. FILTER NOT EXISTS {?uri pimo:groundingOccurrence ?x}}");
+            Soprano::Model *model = Nepomuk2::ResourceManager::instance()->mainModel();
+            Soprano::QueryResultIterator it = model->executeQuery(query, Soprano::Query::QueryLanguageSparql);
+            while (it.next()) {
+                KJob *job = Nepomuk2::removeResources(QList<QUrl>() << it["uri"].uri());
+                job->exec();
+            }
+            kDebug() << "wiping old pimo:Persons done";
+        }
+    }
+
+    //update config file so this is only run once
+    configGroup.writeEntry("feederVersion", CURRENT_FEEDER_VERSION);
+    config->sync();
+
+
     kDebug() << "Storage initialisation succeeded. Setting up Telepathy stuff now.";
 
     // Set up the Factories.
@@ -91,10 +151,6 @@ void Controller::onStorageInitialised(bool success)
     kDebug() << "Calling becomeReady on the AM.";
 }
 
-Controller::~Controller()
-{
-    kDebug();
-}
 
 void Controller::onAccountManagerReady(Tp::PendingOperation *op)
 {
diff --git a/kpeople/nepomuk-feeder/controller.h b/kpeople/nepomuk-feeder/controller.h
index b358c8e..2190f28 100644
--- a/kpeople/nepomuk-feeder/controller.h
+++ b/kpeople/nepomuk-feeder/controller.h
@@ -54,6 +54,7 @@ Q_SIGNALS:
     void storageInitialisationFailed();
 
 private Q_SLOTS:
+    void start();
     void onAccountManagerReady(Tp::PendingOperation *op);
     void onNewAccount(const Tp::AccountPtr &account);
     void onStorageInitialised(bool success);

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list