[Telepathy-commits] [telepathy-qt4/master] Channel: Represent actor of membersChanged as a Contact object.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Mon Feb 9 06:08:10 PST 2009


---
 TelepathyQt4/Client/channel.cpp |   19 +++++++++++++++----
 TelepathyQt4/Client/channel.h   |    3 ++-
 tests/dbus/chan-group.cpp       |    8 ++++----
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/TelepathyQt4/Client/channel.cpp b/TelepathyQt4/Client/channel.cpp
index 7da14c6..cf52686 100644
--- a/TelepathyQt4/Client/channel.cpp
+++ b/TelepathyQt4/Client/channel.cpp
@@ -475,9 +475,15 @@ void Channel::Private::buildContacts()
 
     ContactManager *manager = connection->contactManager();
 
+    UIntList toBuild = QSet<uint>(pendingGroupMembers +
+            pendingGroupLocalPendingMembers +
+            pendingGroupRemotePendingMembers).toList();
+    if (currentGroupMembersChangedInfo &&
+        currentGroupMembersChangedInfo->actor != 0) {
+        toBuild.append(currentGroupMembersChangedInfo->actor);
+    }
     PendingContacts *pendingContacts = manager->contactsForHandles(
-            QSet<uint>(pendingGroupMembers + pendingGroupLocalPendingMembers +
-                       pendingGroupRemotePendingMembers).toList());
+            toBuild);
     parent->connect(pendingContacts,
             SIGNAL(finished(Telepathy::Client::PendingOperation *)),
             SLOT(gotContacts(Telepathy::Client::PendingOperation *)));
@@ -542,6 +548,7 @@ void Channel::Private::updateContacts(const QList<QSharedPointer<Contact> > &con
     QList<QSharedPointer<Contact> > groupContactsAdded;
     QList<QSharedPointer<Contact> > groupLocalPendingContactsAdded;
     QList<QSharedPointer<Contact> > groupRemotePendingContactsAdded;
+    QSharedPointer<Contact> actorContact;
 
     foreach (QSharedPointer<Contact> contact, contacts) {
         uint handle = contact->handle()[0];
@@ -555,6 +562,10 @@ void Channel::Private::updateContacts(const QList<QSharedPointer<Contact> > &con
             groupRemotePendingContactsAdded.append(contact);
             groupRemotePendingContacts[handle] = contact;
         }
+        if (currentGroupMembersChangedInfo &&
+            currentGroupMembersChangedInfo->actor == contact->handle()[0]) {
+            actorContact = contact;
+        }
     }
 
     pendingGroupMembers.clear();
@@ -602,16 +613,16 @@ void Channel::Private::updateContacts(const QList<QSharedPointer<Contact> > &con
     }
     groupRemotePendingMembersToRemove.clear();
 
-    // TODO represent actor as a contact object also
     emit parent->groupMembersChanged(
             groupContactsAdded,
             groupLocalPendingContactsAdded,
             groupRemotePendingContactsAdded,
             groupContactsRemoved,
-            currentGroupMembersChangedInfo->actor,
+            actorContact,
             currentGroupMembersChangedInfo->reason,
             currentGroupMembersChangedInfo->message);
     delete currentGroupMembersChangedInfo;
+    currentGroupMembersChangedInfo = 0;
 
     processMembersChanged();
 }
diff --git a/TelepathyQt4/Client/channel.h b/TelepathyQt4/Client/channel.h
index 1d9e19f..e3204ec 100644
--- a/TelepathyQt4/Client/channel.h
+++ b/TelepathyQt4/Client/channel.h
@@ -137,7 +137,8 @@ Q_SIGNALS:
             const QList<QSharedPointer<Contact> > &groupLocalPendingMembersAdded,
             const QList<QSharedPointer<Contact> > &groupLocalPendingMembersRemoved,
             const QList<QSharedPointer<Contact> > &groupMembersRemoved,
-            uint actor, uint reason, const QString &message);
+            QSharedPointer<Contact> actor,
+            uint reason, const QString &message);
 
     void groupHandleOwnersChanged(const HandleOwnerMap &owners,
             const Telepathy::UIntList &added, const Telepathy::UIntList &removed);
diff --git a/tests/dbus/chan-group.cpp b/tests/dbus/chan-group.cpp
index 8554215..9b20ec5 100644
--- a/tests/dbus/chan-group.cpp
+++ b/tests/dbus/chan-group.cpp
@@ -43,7 +43,7 @@ protected Q_SLOTS:
             const QList<QSharedPointer<Contact> > &groupLocalPendingMembersAdded,
             const QList<QSharedPointer<Contact> > &groupRemotePendingMembersAdded,
             const QList<QSharedPointer<Contact> > &groupMembersRemoved,
-            uint actor, uint reason, const QString &message);
+            QSharedPointer<Contact> actor, uint reason, const QString &message);
 
 private Q_SLOTS:
     void initTestCase();
@@ -216,7 +216,7 @@ void TestChanGroup::onGroupMembersChanged(
         const QList<QSharedPointer<Contact> > &groupLocalPendingMembersAdded,
         const QList<QSharedPointer<Contact> > &groupRemotePendingMembersAdded,
         const QList<QSharedPointer<Contact> > &groupMembersRemoved,
-        uint actor, uint reason, const QString &message)
+        QSharedPointer<Contact> actor, uint reason, const QString &message)
 {
     int ret = -1;
 
@@ -401,13 +401,13 @@ void TestChanGroup::testCreateChannel()
                                 const QList<QSharedPointer<Contact> > &,
                                 const QList<QSharedPointer<Contact> > &,
                                 const QList<QSharedPointer<Contact> > &,
-                                uint, uint, const QString &)),
+                                QSharedPointer<Contact>, uint, const QString &)),
                         SLOT(onGroupMembersChanged(
                                 const QList<QSharedPointer<Contact> > &,
                                 const QList<QSharedPointer<Contact> > &,
                                 const QList<QSharedPointer<Contact> > &,
                                 const QList<QSharedPointer<Contact> > &,
-                                uint, uint, const QString &))));
+                                QSharedPointer<Contact>, uint, const QString &))));
         QCOMPARE(mLoop->exec(), 0);
 
         QStringList ids = QStringList() << "john@#room";
-- 
1.5.6.5




More information about the telepathy-commits mailing list