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


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

The following commit has been merged in the master branch:
commit 2e43d21e4c40e8fb81ec23ef3d1ec78fa9c30c99
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sat Aug 31 01:13:34 2013 +0100

    Populate new contact alias, avatar and groups on initial load
    
    Whilst this makes fetching data from Telepathy have a slightly higher
    latency than inserting minimal data and then updating it the
    stress this causes on Nepomuk and in particular anything using the database
    having to update everything twice is much greater.
    
    BUG: 322032
    REVIEW: 112393
---
 kpeople/nepomuk-feeder/account.cpp         | 11 ------
 kpeople/nepomuk-feeder/controller.cpp      |  2 +-
 kpeople/nepomuk-feeder/nepomuk-storage.cpp | 55 +++++++++++++++++++-----------
 kpeople/nepomuk-feeder/nepomuk-storage.h   |  5 +++
 4 files changed, 41 insertions(+), 32 deletions(-)

diff --git a/kpeople/nepomuk-feeder/account.cpp b/kpeople/nepomuk-feeder/account.cpp
index c21809e..de20f99 100644
--- a/kpeople/nepomuk-feeder/account.cpp
+++ b/kpeople/nepomuk-feeder/account.cpp
@@ -160,13 +160,6 @@ void Account::onNewContact(const Tp::ContactPtr &contact)
 
         m_contacts.append(contact);
 
-        // Become ready asynchronously with the avatar data, since this may take some time and we
-        // don't want to delay the rest of the contact's attributes being ready.
-        // Fire and forget because we can't do anything even if this fails.
-        contact->manager()->upgradeContacts(QList<Tp::ContactPtr>() << contact, 
-                                            Tp::Features() << Tp::Contact::FeatureAvatarData
-                                                           << Tp::Contact::FeatureAvatarToken);
-
         // Connect to all its signals
         connect(contact.data(),
                 SIGNAL(aliasChanged(QString)),
@@ -180,10 +173,6 @@ void Account::onNewContact(const Tp::ContactPtr &contact)
         connect(contact.data(),
                 SIGNAL(avatarDataChanged(Tp::AvatarData)),
                 SLOT(onContactAvatarChanged(Tp::AvatarData)));
-
-        onContactAliasChanged(contact);
-        onContactAddedToGroup(contact);
-
         emit contactCreated(m_account->objectPath(), contact);
     }
 }
diff --git a/kpeople/nepomuk-feeder/controller.cpp b/kpeople/nepomuk-feeder/controller.cpp
index 0afb5d1..9f7afc7 100644
--- a/kpeople/nepomuk-feeder/controller.cpp
+++ b/kpeople/nepomuk-feeder/controller.cpp
@@ -74,7 +74,7 @@ void Controller::onStorageInitialised(bool success)
             QDBusConnection::sessionBus());
 
     Tp::Features fContactFactory;
-    fContactFactory << Tp::Contact::FeatureAlias;
+    fContactFactory << Tp::Contact::FeatureAlias << Tp::Contact::FeatureAvatarData;
 
     Tp::ContactFactoryConstPtr contactFactory = Tp::ContactFactory::create(fContactFactory);
 
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
index 7b05a22..3f5b1fb 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -603,10 +603,12 @@ void NepomukStorage::createContact(const QString &path, const Tp::ContactPtr &co
     newImAccount.setProperty(NCO::imID(), contact->id());
     newImAccount.setProperty(NCO::imAccountType(), accountRes.protocol());
     newImAccount.addProperty(NCO::isAccessedBy(), accountUri);
-    newImAccount.addProperty(NCO::imNickname(), contact->alias());
 
     newPersonContact.addProperty(NCO::hasIMAccount(), newImAccount);
-    newPersonContact.addProperty(NCO::nickname(), contact->alias());
+    updateAlias(newPersonContact, newImAccount, contact->alias());
+    updateContactGroups(newPersonContact, contact->groups());
+    updateContactAvatar(newPersonContact, newImAccount, contact->avatarData());
+
 
     Nepomuk2::SimpleResourceGraph graph;
     graph << newPersonContact << newImAccount;
@@ -636,15 +638,20 @@ void NepomukStorage::setContactAlias(const QString &path, const QString &id, con
         return;
     }
 
-    Nepomuk2::SimpleResource &imAccount = m_graph[contact.imAccount()];
-    imAccount.setProperty(NCO::imNickname(), alias);
-
     Nepomuk2::SimpleResource &personContact = m_graph[contact.personContact()];
-    personContact.setProperty(NCO::nickname(), alias);
+    Nepomuk2::SimpleResource &imAccount = m_graph[contact.imAccount()];
 
+    updateAlias(personContact, imAccount, alias);
     fireGraphTimer();
 }
 
+void NepomukStorage::updateAlias(Nepomuk2::SimpleResource &contactResource, Nepomuk2::SimpleResource &imAccountResource, const QString &alias)
+{
+    contactResource.setProperty(NCO::nickname(), alias);
+    imAccountResource.setProperty(NCO::imNickname(), alias);
+}
+
+
 QUrl NepomukStorage::findGroup(const QString& groupName)
 {
     QHash< QString, QUrl >::const_iterator fit = m_groupCache.constFind( groupName );
@@ -706,19 +713,22 @@ void NepomukStorage::setContactGroups(const QString &path,
         return;
     }
 
+    Nepomuk2::SimpleResource &personContact = m_graph[contact.personContact()];
+
+    updateContactGroups(personContact, groups);
+    fireGraphTimer();
+}
+
+void NepomukStorage::updateContactGroups(Nepomuk2::SimpleResource &contactResource, const QStringList &groups)
+{
     QVariantList groupUris;
     foreach (const QString &groupName, groups) {
         groupUris << findGroup(groupName);
     }
+    contactResource.setProperty(NCO::belongsToGroup(), groupUris);
+}
 
-    QUrl contactUri = contact.personContact();
-
-    Nepomuk2::SimpleResource &contactRes = m_graph[contactUri];
-    contactRes.setUri(contactUri);
-    contactRes.setProperty(NCO::belongsToGroup(), groupUris);
 
-    fireGraphTimer();
-}
 
 void NepomukStorage::setContactAvatar(const QString &path,
                                       const QString &id,
@@ -729,22 +739,27 @@ void NepomukStorage::setContactAvatar(const QString &path,
         return;
     }
 
-    QUrl avatarUrl = avatar.fileName;
-    if (avatarUrl.isEmpty()) {
-        return;
-    }
 
     //FIXME: Do not remove the old avatar from the photos list?
     Nepomuk2::SimpleResource &personContact = m_graph[contact.personContact()];
-    personContact.setProperty(NCO::photo(), avatarUrl);
-
     Nepomuk2::SimpleResource &imAccount = m_graph[contact.imAccount()];
-    imAccount.setProperty(Telepathy::avatar(), avatarUrl);
+    updateContactAvatar(personContact, imAccount, avatar);
 
     fireGraphTimer();
     //TODO: Find a way to index the file as well.
 }
 
+void NepomukStorage::updateContactAvatar(Nepomuk2::SimpleResource &contactResource, Nepomuk2::SimpleResource &imAccountResource, const Tp::AvatarData &avatar)
+{
+    const QUrl &avatarUrl = avatar.fileName;
+    if (avatarUrl.isEmpty()) {
+        return;
+    }
+
+    contactResource.setProperty(NCO::photo(), avatarUrl);
+    imAccountResource.setProperty(Telepathy::avatar(), avatarUrl);
+}
+
 void NepomukStorage::onContactTimer()
 {
     QHash<QUrl, QVariant> additional;
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.h b/kpeople/nepomuk-feeder/nepomuk-storage.h
index a921e22..ae062bb 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.h
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.h
@@ -141,7 +141,12 @@ private Q_SLOTS:
     void onContactTimer();
     void onContactGraphJob(KJob *job);
 
+
 private:
+    void updateAlias(Nepomuk2::SimpleResource &contactResource, Nepomuk2::SimpleResource &imAccountResource, const QString &alias);
+    void updateContactGroups(Nepomuk2::SimpleResource &contactResource, const QStringList &groups);
+    void updateContactAvatar(Nepomuk2::SimpleResource &contactResource, Nepomuk2::SimpleResource &imAccountResource, const Tp::AvatarData &avatar);
+
     Q_DISABLE_COPY(NepomukStorage);
 
     friend class TestBackdoors;

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list