[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:10 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=674cef5
The following commit has been merged in the master branch:
commit 674cef5564c3e46681c0c0e13571f28693a5f3a7
Author: George Goldberg <grundleborg at googlemail.com>
Date: Sun Mar 7 12:41:02 2010 +0000
Synchronize server-side contact groups to Nepomuk.
svn path=/trunk/playground/network/telepathy-integration-daemon/; revision=1100384
---
kpeople/nepomuk-feeder/telepathyaccount.cpp | 3 +-
kpeople/nepomuk-feeder/telepathycontact.cpp | 75 +++++++++++++++++++++++++++--
kpeople/nepomuk-feeder/telepathycontact.h | 2 +
3 files changed, 75 insertions(+), 5 deletions(-)
diff --git a/kpeople/nepomuk-feeder/telepathyaccount.cpp b/kpeople/nepomuk-feeder/telepathyaccount.cpp
index ca4b1ad..670d356 100644
--- a/kpeople/nepomuk-feeder/telepathyaccount.cpp
+++ b/kpeople/nepomuk-feeder/telepathyaccount.cpp
@@ -188,7 +188,8 @@ void TelepathyAccount::onHaveConnectionChanged(bool haveConnection)
features << Tp::Connection::FeatureCore
<< Tp::Connection::FeatureSimplePresence
<< Tp::Connection::FeatureSelfContact
- << Tp::Connection::FeatureRoster;
+ << Tp::Connection::FeatureRoster
+ << Tp::Connection::FeatureRosterGroups;
connect(m_connection->becomeReady(features),
SIGNAL(finished(Tp::PendingOperation*)),
diff --git a/kpeople/nepomuk-feeder/telepathycontact.cpp b/kpeople/nepomuk-feeder/telepathycontact.cpp
index 6f46262..82ba734 100644
--- a/kpeople/nepomuk-feeder/telepathycontact.cpp
+++ b/kpeople/nepomuk-feeder/telepathycontact.cpp
@@ -27,6 +27,9 @@
#include "nco.h"
#include "telepathy.h"
+// Full Resource Classes
+#include "contactgroup.h"
+
#include <KDebug>
#include <Nepomuk/ResourceManager>
@@ -62,6 +65,12 @@ TelepathyContact::TelepathyContact(Tp::ContactPtr contact,
connect(m_contact.data(),
SIGNAL(aliasChanged(QString)),
SLOT(onAliasChanged(QString)));
+ connect(m_contact.data(),
+ SIGNAL(addedToGroup(QString)),
+ SLOT(onAddedToGroup(QString)));
+ connect(m_contact.data(),
+ SIGNAL(removedFromGroup(QString)),
+ SLOT(onRemovedFromGroup(QString)));
// FIXME: Connect to any other signals of sync-worthy properties here.
// Find the Nepomuk resource for this contact, or create a new one if necessary.
@@ -90,9 +99,7 @@ void TelepathyContact::doNepomukSetup()
// Iterate over all the IMAccounts found.
while(it.next()) {
Nepomuk::IMAccount foundImAccount(it.binding("a").uri());
- kDebug() << "Found IM Account: " << foundImAccount.uri();
Nepomuk::IMAccount foundPersonContact(it.binding("b").uri());
- kDebug() << "Person Contact: " << foundPersonContact.uri();
// Check that the IM account only has one ID.
QStringList accountIDs = foundImAccount.imIDs();
@@ -106,10 +113,8 @@ void TelepathyContact::doNepomukSetup()
// Exactly one ID found. Check if it matches the one we are looking for.
QString accountID = accountIDs.first();
- kDebug() << "Account ID:" << accountID;
if (accountID == m_contact->id()) {
- kDebug() << "Found the corresponding IMAccount in Nepomuk.";
// It matches, so set our member variables to found resources and stop looping.
m_contactIMAccountResource = foundImAccount;
m_contactPersonContactResource = foundPersonContact;
@@ -122,6 +127,11 @@ void TelepathyContact::doNepomukSetup()
onPresenceChanged(m_contact->presenceStatus(),
m_contact->presenceType(),
m_contact->presenceMessage()); // We can always assume this one needs syncing.
+ // Call onAddedToGroup for all the groups this contact is in. (it will ignore ones
+ // where Nepomuk already knows the contact is in this group.
+ foreach (const QString &group, m_contact->groups()) {
+ onAddedToGroup(group);
+ }
// FIXME: What other properties do we need to sync?
break;
@@ -173,6 +183,63 @@ void TelepathyContact::onPresenceChanged(const QString& status, uint type, const
}
}
+void TelepathyContact::onAddedToGroup(const QString &group)
+{
+ // Only update the properties if we already have the contactIMAccountResource.
+ if (!m_contactIMAccountResource.resourceUri().isEmpty()) {
+
+ // Check if the contact is already in that group
+ foreach(Nepomuk::ContactGroup g, m_contactPersonContactResource.belongsToGroups()) {
+ if (g.contactGroupName() == group) {
+ // Already in that group
+ return;
+ }
+ }
+
+ // Not already in that group. Check the group exists.
+ // FIXME: Once we have a "ContactList" resource for Telepathy Contacts, we should only
+ // get the groups associated with that.
+ Nepomuk::ContactGroup groupResource;
+ foreach (Nepomuk::ContactGroup g, Nepomuk::ContactGroup::allContactGroups()) {
+ if (g.contactGroupName() == group) {
+ groupResource = g;
+ break;
+ }
+ }
+
+ // If the group doesn't already exist, create it.
+ if (groupResource.resourceUri().isEmpty()) {
+ kDebug() << "Resource URI is empty.";
+ // FIXME: Once we have a "ContactList" resource for Telepathy Contacts, we should
+ // create this group as a child of that resource.
+ groupResource.setContactGroupName(group);
+ }
+
+ // Add the contact to the group.
+ m_contactPersonContactResource.addBelongsToGroup(groupResource);
+ }
+}
+
+void TelepathyContact::onRemovedFromGroup(const QString &group)
+{
+ // Only update the properties if we already have the contactIMAccountResource.
+ if (!m_contactIMAccountResource.resourceUri().isEmpty()) {
+
+ // Loop through all the contact's groups and if we find one with the
+ // right name, remove it from the list.
+ QList<Nepomuk::ContactGroup> oldGroups = m_contactPersonContactResource.belongsToGroups();
+ QList<Nepomuk::ContactGroup> newGroups = m_contactPersonContactResource.belongsToGroups();
+
+ foreach (const Nepomuk::ContactGroup &g, oldGroups) {
+ if (g.contactGroupName() == group) {
+ newGroups.removeAll(g);
+ }
+ }
+
+ m_contactPersonContactResource.setBelongsToGroups(newGroups);
+ }
+}
+
#include "telepathycontact.moc"
diff --git a/kpeople/nepomuk-feeder/telepathycontact.h b/kpeople/nepomuk-feeder/telepathycontact.h
index 3cb6767..383cb49 100644
--- a/kpeople/nepomuk-feeder/telepathycontact.h
+++ b/kpeople/nepomuk-feeder/telepathycontact.h
@@ -49,6 +49,8 @@ public:
private Q_SLOTS:
void onAliasChanged(const QString &alias);
void onPresenceChanged(const QString &status, uint type, const QString &message);
+ void onAddedToGroup(const QString &group);
+ void onRemovedFromGroup(const QString &group);
private:
Q_DISABLE_COPY(TelepathyContact);
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list