[telepathy-qt4/master] ContactManager: Added contactGroups method.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Wed Jul 22 01:01:53 PDT 2009


---
 TelepathyQt4/contact-manager.cpp |   22 ++++++++++++++++++++++
 TelepathyQt4/contact-manager.h   |    1 +
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/contact-manager.cpp b/TelepathyQt4/contact-manager.cpp
index b1014b3..9bb29e4 100644
--- a/TelepathyQt4/contact-manager.cpp
+++ b/TelepathyQt4/contact-manager.cpp
@@ -185,6 +185,28 @@ PendingOperation *ContactManager::removeGroup(const QString &group)
     return channel->requestClose();
 }
 
+QStringList ContactManager::contactGroups(const ContactPtr &contact) const
+{
+    if (!contact) {
+        return QStringList();
+    }
+
+    QStringList result;
+    ChannelPtr contactListGroupChannel;
+    QMap<QString, ChannelPtr>::const_iterator i = mPriv->contactListGroupsChannels.constBegin();
+    QMap<QString, ChannelPtr>::const_iterator end = mPriv->contactListGroupsChannels.constEnd();
+    while (i != end) {
+        contactListGroupChannel = i.value();
+        if (contactListGroupChannel->groupContacts().contains(contact)) {
+            QString id = contactListGroupChannel->immutableProperties().value(
+                QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetID")).toString();
+            result << id;
+        }
+        ++i;
+    }
+    return result;
+}
+
 Contacts ContactManager::groupContacts(const QString &group) const
 {
     if (!mPriv->contactListGroupsChannels.contains(group)) {
diff --git a/TelepathyQt4/contact-manager.h b/TelepathyQt4/contact-manager.h
index 7f2ef63..1399198 100644
--- a/TelepathyQt4/contact-manager.h
+++ b/TelepathyQt4/contact-manager.h
@@ -59,6 +59,7 @@ public:
     PendingOperation *addGroup(const QString &group);
     PendingOperation *removeGroup(const QString &group);
 
+    QStringList contactGroups(const ContactPtr &contact) const;
     Contacts groupContacts(const QString &group) const;
     PendingOperation *groupAddContacts(const QString &group,
             const QList<ContactPtr> &contacts);
-- 
1.5.6.5




More information about the telepathy-commits mailing list