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


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

The following commit has been merged in the master branch:
commit 23e2b9dbf5421fc38dd5d6e1e7274bd3defe1896
Author: George Goldberg <george.goldberg at collabora.co.uk>
Date:   Fri Dec 10 22:35:41 2010 +0000

    Split Storage class into an Abstract interface and a Nepomuk implementation so that we can unit test more easily without having to use a Nepomuk sandbox except when testing the Storage class.
---
 kpeople/nepomuk-feeder/CMakeLists.txt              |  3 +-
 .../{service.h => abstract-storage.cpp}            | 27 +++++--------
 .../{service.h => abstract-storage.h}              | 30 +++++++++------
 kpeople/nepomuk-feeder/controller.cpp              |  4 +-
 kpeople/nepomuk-feeder/controller.h                |  6 +--
 .../{storage.cpp => nepomuk-storage.cpp}           | 40 ++++++++++----------
 .../{storage.h => nepomuk-storage.h}               | 44 +++++++++++-----------
 kpeople/nepomuk-feeder/service.cpp                 |  4 +-
 8 files changed, 81 insertions(+), 77 deletions(-)

diff --git a/kpeople/nepomuk-feeder/CMakeLists.txt b/kpeople/nepomuk-feeder/CMakeLists.txt
index 4b95cb8..9b67d60 100644
--- a/kpeople/nepomuk-feeder/CMakeLists.txt
+++ b/kpeople/nepomuk-feeder/CMakeLists.txt
@@ -49,9 +49,10 @@ add_subdirectory (ontologies)
 
 set (nepomuktelepathyservice_static_SRCS
      controller.cpp
-     storage.cpp
      account.cpp
      contact.cpp
+     abstract-storage.cpp
+     nepomuk-storage.cpp
 )
 
 kde4_add_library (nepomuktelepathyservice-static
diff --git a/kpeople/nepomuk-feeder/service.h b/kpeople/nepomuk-feeder/abstract-storage.cpp
similarity index 62%
copy from kpeople/nepomuk-feeder/service.h
copy to kpeople/nepomuk-feeder/abstract-storage.cpp
index 78127a5..1cc35fc 100644
--- a/kpeople/nepomuk-feeder/service.h
+++ b/kpeople/nepomuk-feeder/abstract-storage.cpp
@@ -1,7 +1,8 @@
 /*
  * This file is part of telepathy-nepomuk-service
  *
- * Copyright (C) 2010 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
+ * Copyright (C) 2010 Collabora Ltd. <info at collabora.co.uk>
+ *   @author George Goldberg <george.goldberg at collabora.co.uk>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,27 +19,19 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_NEPOMUK_SERVICE_SERVICE_H
-#define TELEPATHY_NEPOMUK_SERVICE_SERVICE_H
+#include "abstract-storage.h"
 
-#include <Nepomuk/Service>
-
-#include <QtCore/QVariantList>
+AbstractStorage::AbstractStorage(QObject* parent)
+  : QObject(parent)
+{
 
-class Controller;
+}
 
-class TelepathyService : public Nepomuk::Service
+AbstractStorage::~AbstractStorage()
 {
-    Q_OBJECT
-
-public:
-    TelepathyService(QObject* parent, const QVariantList&);
-    ~TelepathyService();
 
-private:
-    Controller *m_controller;
-};
+}
 
 
-#endif // TELEPATHY_NEPOMUK_SERVICE_SERVICE_H
+#include "abstract-storage.h"
 
diff --git a/kpeople/nepomuk-feeder/service.h b/kpeople/nepomuk-feeder/abstract-storage.h
similarity index 53%
copy from kpeople/nepomuk-feeder/service.h
copy to kpeople/nepomuk-feeder/abstract-storage.h
index 78127a5..18ad7b4 100644
--- a/kpeople/nepomuk-feeder/service.h
+++ b/kpeople/nepomuk-feeder/abstract-storage.h
@@ -1,7 +1,8 @@
 /*
  * This file is part of telepathy-nepomuk-service
  *
- * Copyright (C) 2010 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
+ * Copyright (C) 2010 Collabora Ltd. <info at collabora.co.uk>
+ *   @author George Goldberg <george.goldberg at collabora.co.uk>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,27 +19,32 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_NEPOMUK_SERVICE_SERVICE_H
-#define TELEPATHY_NEPOMUK_SERVICE_SERVICE_H
+#ifndef NEPOMUK_TELEPATHY_SERVICE_ABSTRACT_STORAGE_H
+#define NEPOMUK_TELEPATHY_SERVICE_ABSTRACT_STORAGE_H
 
-#include <Nepomuk/Service>
+#include <QtCore/QObject>
+#include <QtCore/QString>
 
-#include <QtCore/QVariantList>
+#include <TelepathyQt4/Contact>
+#include <TelepathyQt4/Types>
 
-class Controller;
-
-class TelepathyService : public Nepomuk::Service
+/**
+ * Abstract base class for all storage implementations. Primarily to ease
+ * unit testing, however, this could potentially be used to replace the Nepomuk
+ * storage layer with some other storage layer.
+ */
+class AbstractStorage : public QObject
 {
     Q_OBJECT
 
 public:
-    TelepathyService(QObject* parent, const QVariantList&);
-    ~TelepathyService();
+    explicit AbstractStorage(QObject *parent = 0);
+    virtual ~AbstractStorage();
 
 private:
-    Controller *m_controller;
+    Q_DISABLE_COPY(AbstractStorage);
 };
 
 
-#endif // TELEPATHY_NEPOMUK_SERVICE_SERVICE_H
+#endif // Header guard
 
diff --git a/kpeople/nepomuk-feeder/controller.cpp b/kpeople/nepomuk-feeder/controller.cpp
index dc09e68..23f6a46 100644
--- a/kpeople/nepomuk-feeder/controller.cpp
+++ b/kpeople/nepomuk-feeder/controller.cpp
@@ -22,13 +22,13 @@
 #include "controller.h"
 
 #include "account.h"
-#include "storage.h"
+#include "abstract-storage.h"
 
 #include <KDebug>
 
 #include <TelepathyQt4/PendingReady>
 
-Controller::Controller(Storage *storage, QObject *parent)
+Controller::Controller(AbstractStorage *storage, QObject *parent)
  : QObject(parent),
    m_storage(storage)
 {
diff --git a/kpeople/nepomuk-feeder/controller.h b/kpeople/nepomuk-feeder/controller.h
index f9b3232..4fb89a2 100644
--- a/kpeople/nepomuk-feeder/controller.h
+++ b/kpeople/nepomuk-feeder/controller.h
@@ -31,7 +31,7 @@ namespace Tp {
     class PendingOperation;
 }
 
-class Storage;
+class AbstractStorage;
 
 /**
  * Acts as the controller part of a MVC based system (with Storage and the Account/Channel/Contact
@@ -45,7 +45,7 @@ class Controller : public QObject
     Q_OBJECT
 
 public:
-    explicit Controller(Storage *storage, QObject *parent = 0);
+    explicit Controller(AbstractStorage *storage, QObject *parent = 0);
     ~Controller();
 
     void shutdown();
@@ -57,7 +57,7 @@ private Q_SLOTS:
 private:
     Q_DISABLE_COPY(Controller);
 
-    Storage *m_storage;
+    AbstractStorage *m_storage;
 
     Tp::AccountManagerPtr m_accountManager;
 };
diff --git a/kpeople/nepomuk-feeder/storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
similarity index 93%
rename from kpeople/nepomuk-feeder/storage.cpp
rename to kpeople/nepomuk-feeder/nepomuk-storage.cpp
index fa5d583..4442a9c 100644
--- a/kpeople/nepomuk-feeder/storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "storage.h"
+#include "nepomuk-storage.h"
 
 #include "ontologies/nco.h"
 #include "ontologies/pimo.h"
@@ -105,9 +105,11 @@ const Nepomuk::IMAccount &ContactResources::imAccount() const
 }
 
 
-Storage::Storage(QObject *parent)
-: QObject(parent)
+NepomukStorage::NepomukStorage(QObject *parent)
+: AbstractStorage(parent)
 {
+    kDebug();
+
     // Create an instance of the Nepomuk Resource Manager, and connect to it's error signal.
     m_resourceManager = Nepomuk::ResourceManager::instance();
 
@@ -148,17 +150,17 @@ Storage::Storage(QObject *parent)
     }
 }
 
-Storage::~Storage()
+NepomukStorage::~NepomukStorage()
 {
     // Don't delete the Nepomuk Resource manager. Nepomuk should take care of this itself.
 }
 
-void Storage::onNepomukError(const QString &uri, int errorCode)
+void NepomukStorage::onNepomukError(const QString &uri, int errorCode)
 {
     kWarning() << "A Nepomuk Error occurred:" << uri << errorCode;
 }
 
-void Storage::createAccount(const QString &path, const QString &id, const QString &protocol)
+void NepomukStorage::createAccount(const QString &path, const QString &id, const QString &protocol)
 {
     kDebug() << "Creating a new Account";
 
@@ -230,7 +232,7 @@ void Storage::createAccount(const QString &path, const QString &id, const QStrin
     m_accounts.insert(path, imAccount);
 }
 
-void Storage::destroyAccount(const QString &path)
+void NepomukStorage::destroyAccount(const QString &path)
 {
     // Check the account exists
     Q_ASSERT(m_accounts.contains(path));
@@ -247,7 +249,7 @@ void Storage::destroyAccount(const QString &path)
     account.setProperty(Nepomuk::Vocabulary::Telepathy::statusType(), Tp::ConnectionPresenceTypeUnknown);
 }
 
-void Storage::setAccountNickname(const QString &path, const QString &nickname)
+void NepomukStorage::setAccountNickname(const QString &path, const QString &nickname)
 {
     // Check the account exists
     Q_ASSERT(m_accounts.contains(path));
@@ -262,7 +264,7 @@ void Storage::setAccountNickname(const QString &path, const QString &nickname)
     account.setProperty(Nepomuk::Vocabulary::NCO::imNickname(), nickname);
 }
 
-void Storage::setAccountCurrentPresence(const QString &path, const Tp::SimplePresence &presence)
+void NepomukStorage::setAccountCurrentPresence(const QString &path, const Tp::SimplePresence &presence)
 {
     // Check the account exists
     Q_ASSERT(m_accounts.contains(path));
@@ -279,7 +281,7 @@ void Storage::setAccountCurrentPresence(const QString &path, const Tp::SimplePre
     account.setProperty(Nepomuk::Vocabulary::Telepathy::statusType(), presence.type);
 }
 
-void Storage::createContact(const QString &path, const QString &id)
+void NepomukStorage::createContact(const QString &path, const QString &id)
 {
     // First, check that we don't already have a record for this contact.
     ContactIdentifier identifier(path, id);
@@ -377,7 +379,7 @@ void Storage::createContact(const QString &path, const QString &id)
     m_contacts.insert(identifier, ContactResources(newPersonContact, newImAccount));
 }
 
-void Storage::destroyContact(const QString &path, const QString &id)
+void NepomukStorage::destroyContact(const QString &path, const QString &id)
 {
     ContactIdentifier identifier(path, id);
 
@@ -398,7 +400,7 @@ void Storage::destroyContact(const QString &path, const QString &id)
     imAccount.setProperty(Nepomuk::Vocabulary::Telepathy::statusType(), Tp::ConnectionPresenceTypeUnknown);
 }
 
-void Storage::setContactAlias(const QString &path, const QString &id, const QString &alias)
+void NepomukStorage::setContactAlias(const QString &path, const QString &id, const QString &alias)
 {
     ContactIdentifier identifier(path, id);
 
@@ -418,7 +420,7 @@ void Storage::setContactAlias(const QString &path, const QString &id, const QStr
     imAccount.setImNicknames(QStringList() << alias);
 }
 
-void Storage::setContactPresence(const QString &path,
+void NepomukStorage::setContactPresence(const QString &path,
                                  const QString &id,
                                  const Tp::SimplePresence &presence)
 {
@@ -442,17 +444,17 @@ void Storage::setContactPresence(const QString &path,
     imAccount.setImStatusMessages(QStringList() << presence.statusMessage);
 }
 
-void Storage::addContactToGroup(const QString &path, const QString &id, const QString &group)
+void NepomukStorage::addContactToGroup(const QString &path, const QString &id, const QString &group)
 {
     // TODO: Implement me!
 }
 
-void Storage::removeContactFromGroup(const QString &path, const QString &id, const QString &group)
+void NepomukStorage::removeContactFromGroup(const QString &path, const QString &id, const QString &group)
 {
     // TODO: Implement me!
 }
 
-void Storage::setContactBlockStatus(const QString &path, const QString &id, bool blocked)
+void NepomukStorage::setContactBlockStatus(const QString &path, const QString &id, bool blocked)
 {
     ContactIdentifier identifier(path, id);
 
@@ -472,7 +474,7 @@ void Storage::setContactBlockStatus(const QString &path, const QString &id, bool
     imAccount.setIsBlockeds(QList<bool>() << blocked);
 }
 
-void Storage::setContactPublishState(const QString &path,
+void NepomukStorage::setContactPublishState(const QString &path,
                                      const QString &id,
                                      const Tp::Contact::PresenceState &state)
 {
@@ -535,7 +537,7 @@ void Storage::setContactPublishState(const QString &path,
     }
 }
 
-void Storage::setContactSubscriptionState(const QString &path,
+void NepomukStorage::setContactSubscriptionState(const QString &path,
                                           const QString &id,
                                           const Tp::Contact::PresenceState &state)
 {
@@ -609,5 +611,5 @@ int qHash(ContactIdentifier c)
 }
 
 
-#include "storage.moc"
+#include "nepomuk-storage.moc"
 
diff --git a/kpeople/nepomuk-feeder/storage.h b/kpeople/nepomuk-feeder/nepomuk-storage.h
similarity index 59%
rename from kpeople/nepomuk-feeder/storage.h
rename to kpeople/nepomuk-feeder/nepomuk-storage.h
index fc29e8c..b03eaed 100644
--- a/kpeople/nepomuk-feeder/storage.h
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.h
@@ -19,8 +19,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef NEPOMUK_TELEPATHY_SERVICE_STORAGE_H
-#define NEPOMUK_TELEPATHY_SERVICE_STORAGE_H
+#ifndef NEPOMUK_TELEPATHY_SERVICE_NEPOMUK_STORAGE_H
+#define NEPOMUK_TELEPATHY_SERVICE_NEPOMUK_STORAGE_H
+
+#include "abstract-storage.h"
 
 #include "ontologies/imaccount.h"
 #include "ontologies/personcontact.h"
@@ -69,35 +71,35 @@ private:
 /**
  * All interaction with the Nepomuk database takes place in this class.
  */
-class Storage : public QObject
+class NepomukStorage : public AbstractStorage
 {
     Q_OBJECT
 
 public:
-    explicit Storage(QObject *parent = 0);
-    ~Storage();
+    explicit NepomukStorage(QObject *parent = 0);
+    virtual ~NepomukStorage();
 
 public Q_SLOTS:
-    void createAccount(const QString &path, const QString &id, const QString &protocol);
-    void destroyAccount(const QString &path);
-    void setAccountNickname(const QString &path, const QString &nickname);
-    void setAccountCurrentPresence(const QString &path, const Tp::SimplePresence &presence);
-
-    void createContact(const QString &path, const QString &id);
-    void destroyContact(const QString &path, const QString &id);
-    void setContactAlias(const QString &path, const QString &id, const QString &alias);
-    void setContactPresence(const QString &path, const QString &id, const Tp::SimplePresence &presence);
-    void addContactToGroup(const QString &path, const QString &id, const QString &group);
-    void removeContactFromGroup(const QString &path, const QString &id, const QString &group);
-    void setContactBlockStatus(const QString &path, const QString &id, bool blocked);
-    void setContactPublishState(const QString &path, const QString &id, const Tp::Contact::PresenceState &state);
-    void setContactSubscriptionState(const QString &path, const QString &id, const Tp::Contact::PresenceState &state);
+    virtual void createAccount(const QString &path, const QString &id, const QString &protocol);
+    virtual void destroyAccount(const QString &path);
+    virtual void setAccountNickname(const QString &path, const QString &nickname);
+    virtual void setAccountCurrentPresence(const QString &path, const Tp::SimplePresence &presence);
+
+    virtual void createContact(const QString &path, const QString &id);
+    virtual void destroyContact(const QString &path, const QString &id);
+    virtual void setContactAlias(const QString &path, const QString &id, const QString &alias);
+    virtual void setContactPresence(const QString &path, const QString &id, const Tp::SimplePresence &presence);
+    virtual void addContactToGroup(const QString &path, const QString &id, const QString &group);
+    virtual void removeContactFromGroup(const QString &path, const QString &id, const QString &group);
+    virtual void setContactBlockStatus(const QString &path, const QString &id, bool blocked);
+    virtual void setContactPublishState(const QString &path, const QString &id, const Tp::Contact::PresenceState &state);
+    virtual void setContactSubscriptionState(const QString &path, const QString &id, const Tp::Contact::PresenceState &state);
 
 private Q_SLOTS:
-    void onNepomukError(const QString &uri, int errorCode);
+    virtual void onNepomukError(const QString &uri, int errorCode);
 
 private:
-    Q_DISABLE_COPY(Storage);
+    Q_DISABLE_COPY(NepomukStorage);
 
     Nepomuk::ResourceManager *m_resourceManager;
     Nepomuk::PersonContact m_mePersonContact;
diff --git a/kpeople/nepomuk-feeder/service.cpp b/kpeople/nepomuk-feeder/service.cpp
index ca5a58b..4b65ec0 100644
--- a/kpeople/nepomuk-feeder/service.cpp
+++ b/kpeople/nepomuk-feeder/service.cpp
@@ -23,7 +23,7 @@
 #include "service.h"
 
 #include "controller.h"
-#include "storage.h"
+#include "nepomuk-storage.h"
 
 #include <KDebug>
 #include <KPluginFactory>
@@ -39,7 +39,7 @@ TelepathyService::TelepathyService(QObject *parent, const QVariantList &)
     Tp::registerTypes();
 
     // Create an instance of the Telepathy Account Monitor.
-    m_controller = new Controller(new Storage(), this);
+    m_controller = new Controller(new NepomukStorage(), this);
 
     setServiceInitialized(true);
 

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list