[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=231d191
The following commit has been merged in the master branch:
commit 231d1914961b5137d87db983e1ea88a2d7a066a4
Author: George Goldberg <george.goldberg at collabora.co.uk>
Date: Thu Aug 11 14:46:54 2011 +0100
When an account comes online, pass the entire contact list to the storage in one go:
This lets it:
- Ghost contacts who are no longer server side
- (In future) batch add contacts to speed things up.
---
kpeople/nepomuk-feeder/abstract-storage.h | 1 +
kpeople/nepomuk-feeder/account.cpp | 14 +++++++++-
kpeople/nepomuk-feeder/account.h | 1 +
kpeople/nepomuk-feeder/controller.cpp | 2 ++
kpeople/nepomuk-feeder/nepomuk-storage.cpp | 38 ++++++++++++++++++++++++++
kpeople/nepomuk-feeder/nepomuk-storage.h | 1 +
kpeople/nepomuk-feeder/tests/controller-test.h | 2 ++
7 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/kpeople/nepomuk-feeder/abstract-storage.h b/kpeople/nepomuk-feeder/abstract-storage.h
index cceb54e..5e31399 100644
--- a/kpeople/nepomuk-feeder/abstract-storage.h
+++ b/kpeople/nepomuk-feeder/abstract-storage.h
@@ -47,6 +47,7 @@ public Q_SLOTS:
virtual void destroyAccount(const QString &path) = 0;
virtual void setAccountNickname(const QString &path, const QString &nickname) = 0;
virtual void setAccountCurrentPresence(const QString &path, const Tp::SimplePresence &presence) = 0;
+ virtual void cleanupAccountContacts(const QString &path, const QList<QString> &ids) = 0;
virtual void createContact(const QString &path, const QString &id) = 0;
virtual void destroyContact(const QString &path, const QString &id) = 0;
diff --git a/kpeople/nepomuk-feeder/account.cpp b/kpeople/nepomuk-feeder/account.cpp
index d6e33ba..75652a4 100644
--- a/kpeople/nepomuk-feeder/account.cpp
+++ b/kpeople/nepomuk-feeder/account.cpp
@@ -99,7 +99,10 @@ void Account::onConnectionChanged(const Tp::ConnectionPtr &connection)
}
//add contacts as soon as the contact manager is ready.
- connect(m_connection->contactManager().data(), SIGNAL(stateChanged(Tp::ContactListState)), SLOT(onContactManagerStateChanged(Tp::ContactListState)));
+ connect(m_connection->contactManager().data(),
+ SIGNAL(stateChanged(Tp::ContactListState)),
+ SLOT(onContactManagerStateChanged(Tp::ContactListState)));
+ // Simulate a state change signal in case it is already ready.
onContactManagerStateChanged(m_connection->contactManager()->state());
} else {
@@ -116,6 +119,15 @@ void Account::onContactManagerStateChanged(Tp::ContactListState state)
if (state == Tp::ContactListStateSuccess) {
Tp::Contacts contacts = m_connection->contactManager()->allKnownContacts();
+ // Create the hash containing all the contacts to notify the storage of the
+ // full set of contacts that still exist when the account is connected.
+ // This *must* be done before creating the contact wrapper objects.
+ QList<QString> initialContacts;
+ foreach (const Tp::ContactPtr &contact, contacts) {
+ initialContacts.append(contact->id());
+ }
+ emit initialContactsLoaded(m_account->objectPath(), initialContacts);
+
// Create wrapper objects for all the Contacts.
foreach (const Tp::ContactPtr &contact, contacts) {
kDebug();
diff --git a/kpeople/nepomuk-feeder/account.h b/kpeople/nepomuk-feeder/account.h
index 4689b69..e1c46da 100644
--- a/kpeople/nepomuk-feeder/account.h
+++ b/kpeople/nepomuk-feeder/account.h
@@ -54,6 +54,7 @@ Q_SIGNALS:
void accountDestroyed(const QString &path);
void nicknameChanged(const QString &path, const QString &nickname);
void currentPresenceChanged(const QString &path, const Tp::SimplePresence &presence);
+ void initialContactsLoaded(const QString &path, const QList<QString> &ids);
void contactCreated(const QString &path, const QString &id);
void contactDestroyed(const QString &path, const QString &id);
diff --git a/kpeople/nepomuk-feeder/controller.cpp b/kpeople/nepomuk-feeder/controller.cpp
index 1f0f292..e512b21 100644
--- a/kpeople/nepomuk-feeder/controller.cpp
+++ b/kpeople/nepomuk-feeder/controller.cpp
@@ -135,6 +135,8 @@ void Controller::onNewAccount(const Tp::AccountPtr &account)
m_storage, SLOT(setAccountNickname(QString,QString)));
connect(acc, SIGNAL(currentPresenceChanged(QString,Tp::SimplePresence)),
m_storage, SLOT(setAccountCurrentPresence(QString,Tp::SimplePresence)));
+ connect(acc, SIGNAL(initialContactsLoaded(QString,QList<QString>)),
+ m_storage, SLOT(cleanupAccountContacts(QString,QList<QString>)));
// Connect to all the signals/slots that signify the contacts are changing in some way.
connect(acc, SIGNAL(contactCreated(QString,QString)),
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
index 52b01d9..3cb7517 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -497,6 +497,44 @@ void NepomukStorage::setAccountCurrentPresence(const QString &path, const Tp::Si
account.setProperty(Nepomuk::Vocabulary::Telepathy::statusType(), presence.type);
}
+void NepomukStorage::cleanupAccountContacts(const QString &path, const QList<QString> &ids)
+{
+ kDebug();
+
+ // Go through all the contacts in the cache and make any that are not in the list we
+ // received from the account into Ghost Contacts. Do this as a batch job to improve performance.
+ foreach (const ContactIdentifier &cid, m_contacts.keys()) {
+ if (cid.accountId() == path) {
+ if (!ids.contains(cid.contactId())) {
+ // TODO: Do this properly once the ontology supports this
+ // TODO: Do this as a batch job to reduce the number of nepomuk queries that result.
+ kDebug() << "Ghosting contact: " << cid.contactId();
+ setContactPublishState(path, cid.contactId(), Tp::Contact::PresenceStateNo);
+ setContactSubscriptionState(path, cid.contactId(), Tp::Contact::PresenceStateNo);
+ }
+ }
+ }
+
+ // Go through all the contacts that we have received from the account and create any
+ // new ones in neponmuk. Do this as a batch job to improve performance.
+ foreach (const QString &id, ids) {
+ bool found = false;
+ foreach (const ContactIdentifier &cid, m_contacts.keys()) {
+ if (cid.accountId() == path) {
+ if (cid.contactId() == id) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (!found) {
+ // TODO: Add all these accounts as a batch job
+ kDebug() << "Adding contact:" << id;
+ createContact(path, id);
+ }
+ }
+}
+
void NepomukStorage::createContact(const QString &path, const QString &id)
{
// First, check that we don't already have a record for this contact.
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.h b/kpeople/nepomuk-feeder/nepomuk-storage.h
index b0a3b4f..8242c9e 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.h
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.h
@@ -96,6 +96,7 @@ public Q_SLOTS:
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 cleanupAccountContacts(const QString &path, const QList<QString> &ids);
virtual void createContact(const QString &path, const QString &id);
virtual void destroyContact(const QString &path, const QString &id);
diff --git a/kpeople/nepomuk-feeder/tests/controller-test.h b/kpeople/nepomuk-feeder/tests/controller-test.h
index af41498..908b6d5 100644
--- a/kpeople/nepomuk-feeder/tests/controller-test.h
+++ b/kpeople/nepomuk-feeder/tests/controller-test.h
@@ -93,6 +93,7 @@ public Q_SLOTS:
// Not used
virtual void setAccountNickname(const QString &, const QString &) { }
virtual void setAccountCurrentPresence(const QString &, const Tp::SimplePresence &) { }
+ virtual void cleanupAccountContacts(const QString &, const QList<QString> &) { }
virtual void createContact(const QString &, const QString &) { }
virtual void destroyContact(const QString &, const QString &) { }
virtual void setContactAlias(const QString &, const QString &, const QString &) { }
@@ -125,6 +126,7 @@ public Q_SLOTS:
virtual void destroyAccount(const QString &) { }
virtual void setAccountNickname(const QString &, const QString &) { }
virtual void setAccountCurrentPresence(const QString &, const Tp::SimplePresence &) { }
+ virtual void cleanupAccountContacts(const QString &, const QList<QString> &) { }
virtual void createContact(const QString &, const QString &) { }
virtual void destroyContact(const QString &, const QString &) { }
virtual void setContactAlias(const QString &, const QString &, const QString &) { }
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list