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


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

The following commit has been merged in the master branch:
commit b39bf44d56c47da53bf15e30284d2c2b7195e1fc
Author: George Goldberg <george.goldberg at collabora.co.uk>
Date:   Wed Aug 10 17:18:50 2011 +0100

    Make the loading of accounts and contacts at the start of the nepomuk service run fully asynchronous.
    
    Reviewed-By: Dario Freddi <dario.freddi at collabora.co.uk>
    REVIEW: 102289
---
 kpeople/nepomuk-feeder/abstract-storage.h        |   3 +
 kpeople/nepomuk-feeder/controller.cpp            |  15 ++-
 kpeople/nepomuk-feeder/controller.h              |   4 +
 kpeople/nepomuk-feeder/nepomuk-storage.cpp       | 149 +++++++++++++++++++----
 kpeople/nepomuk-feeder/nepomuk-storage.h         |  18 +++
 kpeople/nepomuk-feeder/service.cpp               |  12 ++
 kpeople/nepomuk-feeder/service.h                 |   3 +
 kpeople/nepomuk-feeder/tests/controller-test.cpp |  17 +++
 kpeople/nepomuk-feeder/tests/controller-test.h   |   4 +
 kpeople/nepomuk-feeder/tests/storage-test.cpp    |  18 +++
 10 files changed, 216 insertions(+), 27 deletions(-)

diff --git a/kpeople/nepomuk-feeder/abstract-storage.h b/kpeople/nepomuk-feeder/abstract-storage.h
index 24b47b5..cceb54e 100644
--- a/kpeople/nepomuk-feeder/abstract-storage.h
+++ b/kpeople/nepomuk-feeder/abstract-storage.h
@@ -59,6 +59,9 @@ public Q_SLOTS:
     virtual void setContactCapabilities(const QString &path, const QString &id, const Tp::ContactCapabilities &capabilities) = 0;
     virtual void setContactAvatar(const QString &path, const QString &id, const Tp::AvatarData &avatar) = 0;
 
+Q_SIGNALS:
+    void initialised(bool success);
+
 private:
     Q_DISABLE_COPY(AbstractStorage);
 };
diff --git a/kpeople/nepomuk-feeder/controller.cpp b/kpeople/nepomuk-feeder/controller.cpp
index 3ab1392..1f0f292 100644
--- a/kpeople/nepomuk-feeder/controller.cpp
+++ b/kpeople/nepomuk-feeder/controller.cpp
@@ -32,9 +32,22 @@ Controller::Controller(AbstractStorage *storage, QObject *parent)
  : QObject(parent),
    m_storage(storage)
 {
-    // Take ownership of the storage.
+    // Become the parent of the Storage class.
     m_storage->setParent(this);
 
+    // We must wait for the storage to be initialised before anything else happens.
+    connect(m_storage, SIGNAL(initialised(bool)), SLOT(onStorageInitialised(bool)));
+}
+
+void Controller::onStorageInitialised(bool success)
+{
+    if (!success) {
+        emit storageInitialisationFailed();
+        return;
+    }
+
+    kDebug() << "Storage initialisation succeeded. Setting up Telepathy stuff now.";
+
     // Set up the Factories.
     Tp::Features fAccountFactory;
     fAccountFactory << Tp::Account::FeatureCore
diff --git a/kpeople/nepomuk-feeder/controller.h b/kpeople/nepomuk-feeder/controller.h
index 4fb89a2..c84d29d 100644
--- a/kpeople/nepomuk-feeder/controller.h
+++ b/kpeople/nepomuk-feeder/controller.h
@@ -50,9 +50,13 @@ public:
 
     void shutdown();
 
+Q_SIGNALS:
+    void storageInitialisationFailed();
+
 private Q_SLOTS:
     void onAccountManagerReady(Tp::PendingOperation *op);
     void onNewAccount(const Tp::AccountPtr &account);
+    void onStorageInitialised(bool success);
 
 private:
     Q_DISABLE_COPY(Controller);
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
index 51382fc..52b01d9 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -47,6 +47,7 @@
 #include <Nepomuk/Query/Result>
 
 #include <QtCore/QSharedData>
+#include <QtCore/QTimer>
 
 #include <TelepathyQt4/Constants>
 #include <TelepathyQt4/AvatarData>
@@ -64,6 +65,9 @@ public:
         contactId(other.contactId)
     { }
 
+    Data()
+    { }
+
     ~Data()
     { }
 
@@ -83,6 +87,12 @@ ContactIdentifier::ContactIdentifier(const ContactIdentifier &other)
 
 }
 
+ContactIdentifier::ContactIdentifier()
+  : d(new Data())
+{
+
+}
+
 ContactIdentifier::~ContactIdentifier()
 {
 
@@ -166,6 +176,16 @@ const Nepomuk::IMAccount &ContactResources::imAccount() const
     return d->imAccount;
 }
 
+bool ContactResources::operator==(const ContactResources& other) const
+{
+    return ((other.personContact() == personContact()) && (other.imAccount() == imAccount()));
+}
+
+bool ContactResources::operator!=(const ContactResources& other) const
+{
+    return !(*this == other);
+}
+
 
 NepomukStorage::NepomukStorage(QObject *parent)
 : AbstractStorage(parent)
@@ -182,6 +202,22 @@ NepomukStorage::NepomukStorage(QObject *parent)
             SIGNAL(error(QString,int)),
             SLOT(onNepomukError(QString,int)));
 
+    QTimer::singleShot(0, this, SLOT(init()));
+}
+
+NepomukStorage::~NepomukStorage()
+{
+    // Don't delete the Nepomuk Resource manager. Nepomuk should take care of this itself.
+    kDebug();
+}
+
+void NepomukStorage::onNepomukError(const QString &uri, int errorCode)
+{
+    kWarning() << "A Nepomuk Error occurred:" << uri << errorCode;
+}
+
+void NepomukStorage::init()
+{
     // *********************************************************************************************
     // Get the ME PIMO:Person and NCO:PersonContact (creating them if necessary)
 
@@ -224,28 +260,39 @@ NepomukStorage::NepomukStorage(QObject *parent)
     // and every account and contact individually when we get to that one.
 
     // Query Nepomuk for all of the ME PersonContact's IMAccounts.
-    QList<Nepomuk::Query::Result> results;
     {
         using namespace Nepomuk::Query;
 
+        // Construct the query
         ComparisonTerm accountTerm(Nepomuk::Vocabulary::NCO::hasIMAccount(),
                                    ResourceTerm(m_mePersonContact));
         accountTerm.setInverted(true);
 
         Query query(AndTerm(accountTerm, ResourceTypeTerm(Nepomuk::Vocabulary::NCO::IMAccount())));
 
-        bool queryResult = true;
-        results = QueryServiceClient::syncQuery(query, &queryResult);
-
-        if (!queryResult) {
-            kWarning() << "Query failed.";
-        }
+        // Connect to the result signals and launch the query.
+        QueryServiceClient *client = new QueryServiceClient(this);
+        connect(client,
+                SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
+                SLOT(onAccountsQueryNewEntries(QList<Nepomuk::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()));
+        client->query(query);
     }
+}
 
-    kDebug() << results.size();
-
+void NepomukStorage::onAccountsQueryNewEntries(const QList<Nepomuk::Query::Result> &entries)
+{
+    kDebug();
     // Iterate over all the IMAccounts found.
-    foreach (const Nepomuk::Query::Result &result, results) {
+    foreach (const Nepomuk::Query::Result &result, entries) {
         Nepomuk::IMAccount foundImAccount(result.resource());
         kDebug() << this << ": Found IM Account: " << foundImAccount.uri();
 
@@ -256,19 +303,42 @@ NepomukStorage::NepomukStorage(QObject *parent)
         }
 
         kDebug() << "Found a Telepathy account in Nepomuk, ID:"
-                 << foundImAccount.accountIdentifier();
+        << foundImAccount.accountIdentifier();
 
         // If it does have a telepathy identifier, then it is added to the cache.
         m_accounts.insert(foundImAccount.accountIdentifier(), foundImAccount);
     }
 
+}
+
+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()
+{
+    kDebug() << "Accounts Query Finished Successfully.";
+    // Got all the accounts, now move on to the contacts.
+
     // Query Nepomuk for all know Contacts.
     {
         using namespace Nepomuk::Query;
 
         // Get the person contact owning this IMAccount
         ComparisonTerm pcterm(Nepomuk::Vocabulary::NCO::hasIMAccount(),
-                              ResourceTypeTerm(Nepomuk::Vocabulary::NCO::PersonContact()));
+                            ResourceTypeTerm(Nepomuk::Vocabulary::NCO::PersonContact()));
         pcterm.setVariableName("person");
         pcterm.setInverted(true);
 
@@ -276,26 +346,37 @@ NepomukStorage::NepomukStorage(QObject *parent)
         // resource for that.
         // This avoids race conditions and a lot of bad things.
         ComparisonTerm accountTerm(Nepomuk::Vocabulary::NCO::hasIMAccount(),
-                                   ResourceTerm(m_mePersonContact));
+                                ResourceTerm(m_mePersonContact));
         accountTerm.setInverted(true);
 
         ComparisonTerm accessedByTerm(Nepomuk::Vocabulary::NCO::isAccessedBy(),
-                                      ResourceTypeTerm(Nepomuk::Vocabulary::NCO::IMAccount()));
+                                    ResourceTypeTerm(Nepomuk::Vocabulary::NCO::IMAccount()));
         accessedByTerm.setVariableName("accessedBy");
 
         Query query(AndTerm(pcterm, NegationTerm::negateTerm(accountTerm), accessedByTerm,
                             ResourceTypeTerm(Nepomuk::Vocabulary::NCO::IMAccount())));
 
-        bool queryResult = true;
-        results = QueryServiceClient::syncQuery(query, &queryResult);
-
-        if (!queryResult) {
-            kWarning() << "Query failed.";
-        }
+        QueryServiceClient *client = new QueryServiceClient(this);
+        connect(client,
+                SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
+                SLOT(onContactsQueryNewEntries(QList<Nepomuk::Query::Result>)));
+        connect(client,
+                SIGNAL(entriesRemoved(QList<QUrl>)),
+                SLOT(onContactsQueryEntriesRemoved(QList<QUrl>)));
+        connect(client,
+                SIGNAL(error(QString)),
+                SLOT(onContactsQueryError(QString)));
+        connect(client,
+                SIGNAL(finishedListing()),
+                SLOT(onContactsQueryFinishedListing()));
+        client->query(query);
     }
+}
 
+void NepomukStorage::onContactsQueryNewEntries(const QList< Nepomuk::Query::Result > &entries)
+{
     // Iterate over all the IMAccounts found.
-    foreach (const Nepomuk::Query::Result &result, results) {
+    foreach (const Nepomuk::Query::Result &result, entries) {
         Nepomuk::IMAccount foundImAccount(result.resource());
         Nepomuk::IMAccount foundPersonContact(result.additionalBinding("person").toUrl());
         Nepomuk::IMAccount foundImAccountAccessedBy(result.additionalBinding("accessedBy").toUrl());
@@ -313,19 +394,35 @@ NepomukStorage::NepomukStorage(QObject *parent)
         // Cache the contact
         m_contacts.insert(ContactIdentifier(foundImAccountAccessedBy.accountIdentifier(),
                                             foundImAccount.imIDs().first()),
-                          ContactResources(foundPersonContact, foundImAccount));
+                            ContactResources(foundPersonContact, foundImAccount));
         kDebug() << "Contact found in Nepomuk. Caching.";
     }
 }
 
-NepomukStorage::~NepomukStorage()
+void NepomukStorage::onContactsQueryEntriesRemoved(const QList<QUrl> &entries)
 {
-    // Don't delete the Nepomuk Resource manager. Nepomuk should take care of this itself.
+    foreach (const QUrl &entry, entries) {
+        foreach (const ContactResources &resources, m_contacts.values()) {
+            if (resources.personContact().resourceUri() == entry) {
+                m_contacts.remove(m_contacts.key(resources));
+                break;
+            }
+        }
+    }
 }
 
-void NepomukStorage::onNepomukError(const QString &uri, int errorCode)
+void NepomukStorage::onContactsQueryError(const QString &errorMessage)
 {
-    kWarning() << "A Nepomuk Error occurred:" << uri << errorCode;
+    kWarning() << "A Nepomuk Error occurred:" << errorMessage;
+
+    emit initialised(false);
+}
+
+void NepomukStorage::onContactsQueryFinishedListing()
+{
+    kDebug() << "Contacts Query Finished Successfully.";
+
+    emit initialised(true);
 }
 
 void NepomukStorage::createAccount(const QString &path, const QString &id, const QString &protocol)
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.h b/kpeople/nepomuk-feeder/nepomuk-storage.h
index 8077c56..b0a3b4f 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.h
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.h
@@ -36,12 +36,16 @@
 
 namespace Nepomuk {
     class ResourceManager;
+    namespace Query {
+        class Result;
+    }
 }
 
 class ContactIdentifier {
 public:
     ContactIdentifier(const QString &accountId, const QString &contactId);
     ContactIdentifier(const ContactIdentifier &other);
+    ContactIdentifier();
     ~ContactIdentifier();
 
     const QString &accountId() const;
@@ -68,6 +72,9 @@ public:
     const Nepomuk::PersonContact &personContact() const;
     const Nepomuk::IMAccount &imAccount() const;
 
+    bool operator==(const ContactResources &other) const;
+    bool operator!=(const ContactResources &other) const;
+
 private:
     class Data;
     QSharedDataPointer<Data> d;
@@ -103,6 +110,17 @@ public Q_SLOTS:
 
 private Q_SLOTS:
     void onNepomukError(const QString &uri, int errorCode);
+    void init();
+
+    void onAccountsQueryNewEntries(const QList<Nepomuk::Query::Result> &entries);
+    void onAccountsQueryEntriesRemoved(const QList<QUrl> &entries);
+    void onAccountsQueryError(const QString &errorMessage);
+    void onAccountsQueryFinishedListing();
+
+    void onContactsQueryNewEntries(const QList<Nepomuk::Query::Result> &entries);
+    void onContactsQueryEntriesRemoved(const QList<QUrl> &entries);
+    void onContactsQueryError(const QString &errorMessage);
+    void onContactsQueryFinishedListing();
 
 private:
     Q_DISABLE_COPY(NepomukStorage);
diff --git a/kpeople/nepomuk-feeder/service.cpp b/kpeople/nepomuk-feeder/service.cpp
index 4b65ec0..d4821c0 100644
--- a/kpeople/nepomuk-feeder/service.cpp
+++ b/kpeople/nepomuk-feeder/service.cpp
@@ -41,6 +41,10 @@ TelepathyService::TelepathyService(QObject *parent, const QVariantList &)
     // Create an instance of the Telepathy Account Monitor.
     m_controller = new Controller(new NepomukStorage(), this);
 
+    connect(m_controller,
+            SIGNAL(storageInitialisationFailed()),
+            SLOT(onStorageInitialisationFailed()));
+
     setServiceInitialized(true);
 
     kDebug() << "We're off...";
@@ -51,6 +55,14 @@ TelepathyService::~TelepathyService()
     m_controller->shutdown();
 }
 
+void TelepathyService::onStorageInitialisationFailed()
+{
+    kDebug() << "Storage initialisation failed. Terminate the service.";
+
+    // Terminate the service
+    deleteLater();
+}
+
 
 NEPOMUK_EXPORT_SERVICE( TelepathyService, "nepomuktelepathyservice" );
 
diff --git a/kpeople/nepomuk-feeder/service.h b/kpeople/nepomuk-feeder/service.h
index 78127a5..796275f 100644
--- a/kpeople/nepomuk-feeder/service.h
+++ b/kpeople/nepomuk-feeder/service.h
@@ -35,6 +35,9 @@ public:
     TelepathyService(QObject* parent, const QVariantList&);
     ~TelepathyService();
 
+public Q_SLOTS:
+    void onStorageInitialisationFailed();
+
 private:
     Controller *m_controller;
 };
diff --git a/kpeople/nepomuk-feeder/tests/controller-test.cpp b/kpeople/nepomuk-feeder/tests/controller-test.cpp
index 68186c3..4e6d447 100644
--- a/kpeople/nepomuk-feeder/tests/controller-test.cpp
+++ b/kpeople/nepomuk-feeder/tests/controller-test.cpp
@@ -28,6 +28,8 @@
 
 #include <qtest_kde.h>
 
+#include <QtCore/QTimer>
+
 #include <TelepathyQt4/PendingAccount>
 #include <TelepathyQt4/PendingReady>
 
@@ -36,6 +38,8 @@ ConstructorDestructorFakeStorage::ConstructorDestructorFakeStorage(ControllerTes
   : m_test(test)
 {
     kDebug();
+
+    QTimer::singleShot(0, this, SIGNAL(emitInitialisedSignal()));
 }
 
 ConstructorDestructorFakeStorage::~ConstructorDestructorFakeStorage()
@@ -43,6 +47,11 @@ ConstructorDestructorFakeStorage::~ConstructorDestructorFakeStorage()
     kDebug();
 }
 
+void ConstructorDestructorFakeStorage::emitInitialisedSignal()
+{
+    emit initialised(true);
+}
+
 void ConstructorDestructorFakeStorage::createAccount(const QString &path,
                                                      const QString &id,
                                                      const QString &protocol)
@@ -64,6 +73,8 @@ OnNewAccountFakeStorage::OnNewAccountFakeStorage(ControllerTest *test)
 : m_test(test)
 {
     kDebug();
+
+    QTimer::singleShot(0, this, SIGNAL(emitInitialisedSignal()));
 }
 
 OnNewAccountFakeStorage::~OnNewAccountFakeStorage()
@@ -71,6 +82,12 @@ OnNewAccountFakeStorage::~OnNewAccountFakeStorage()
     kDebug();
 }
 
+
+void OnNewAccountFakeStorage::emitInitialisedSignal()
+{
+    emit initialised(true);
+}
+
 void OnNewAccountFakeStorage::createAccount(const QString &path,
                                             const QString &id,
                                             const QString &protocol)
diff --git a/kpeople/nepomuk-feeder/tests/controller-test.h b/kpeople/nepomuk-feeder/tests/controller-test.h
index be2f3b9..af41498 100644
--- a/kpeople/nepomuk-feeder/tests/controller-test.h
+++ b/kpeople/nepomuk-feeder/tests/controller-test.h
@@ -88,6 +88,8 @@ public Q_SLOTS:
     virtual void createAccount(const QString &path, const QString &id, const QString &protocol);
     virtual void destroyAccount(const QString &path);
 
+    virtual void emitInitialisedSignal();
+
     // Not used
     virtual void setAccountNickname(const QString &, const QString &) { }
     virtual void setAccountCurrentPresence(const QString &, const Tp::SimplePresence &) { }
@@ -117,6 +119,8 @@ public:
 public Q_SLOTS:
     virtual void createAccount(const QString &path, const QString &id, const QString &protocol);
 
+    virtual void emitInitialisedSignal();
+
     // Not used
     virtual void destroyAccount(const QString &) { }
     virtual void setAccountNickname(const QString &, const QString &) { }
diff --git a/kpeople/nepomuk-feeder/tests/storage-test.cpp b/kpeople/nepomuk-feeder/tests/storage-test.cpp
index c1771f1..a2f48f7 100644
--- a/kpeople/nepomuk-feeder/tests/storage-test.cpp
+++ b/kpeople/nepomuk-feeder/tests/storage-test.cpp
@@ -78,6 +78,7 @@ void StorageTest::testConstructorDestructor()
     // First test constructing the NepomukStorage on a Nepomuk database with no relevant
     // data already in it.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
 
     // Check that the Nepomuk mePersonContact has been created.
     QVERIFY(TestBackdoors::nepomukStorageMePersonContact(m_storage).exists());
@@ -95,6 +96,7 @@ void StorageTest::testConstructorDestructor()
 
     // Next, try constructing a NepomukStorage instance where the mePersonContact already exists.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
 
     // Check that the Nepomuk mePersonContact has been created.
     QVERIFY(TestBackdoors::nepomukStorageMePersonContact(m_storage).exists());
@@ -114,6 +116,7 @@ void StorageTest::testConstructorDestructor()
 void StorageTest::testCreateAccount()
 {
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     Nepomuk::PersonContact mePersonContact = TestBackdoors::nepomukStorageMePersonContact(m_storage);
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
 
@@ -158,6 +161,7 @@ void StorageTest::testCreateAccount()
     // Need to delete the storage class to get it to see the newly added account.
     m_storage->deleteLater();
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
 
     // Now tell the storage about that account.
@@ -220,6 +224,7 @@ void StorageTest::testDestroyAccount()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -259,6 +264,7 @@ void StorageTest::testSetAccountNickname()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -303,6 +309,7 @@ void StorageTest::testSetAccountCurrentPresence()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -357,6 +364,7 @@ void StorageTest::testCreateContact()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -446,6 +454,7 @@ void StorageTest::testCreateContact()
     // Recreate the Storage class to get it to reload the contacts
     m_storage->deleteLater();
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
     contacts = TestBackdoors::nepomukStorageContacts(m_storage);
 
@@ -527,6 +536,7 @@ void StorageTest::testDestroyContact()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -592,6 +602,7 @@ void StorageTest::testSetContactAlias()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -661,6 +672,7 @@ void StorageTest::testSetContactPresence()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -755,6 +767,7 @@ void StorageTest::testSetContactGroups()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -865,6 +878,7 @@ void StorageTest::testSetContactBlockedStatus()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -932,6 +946,7 @@ void StorageTest::testSetContactPublishState()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -1013,6 +1028,7 @@ void StorageTest::testSetContactSubscriptionState()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -1094,6 +1110,7 @@ void StorageTest::testSetContactCapabilities()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
@@ -1202,6 +1219,7 @@ void StorageTest::testSetAvatar()
 {
     // Create the Storage.
     m_storage = new NepomukStorage(this);
+    QTest::kWaitForSignal(m_storage, SIGNAL(initialised(bool)), 0);
     QVERIFY(m_storage);
 
     QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list