[Telepathy-commits] [telepathy-qt4/master] Expose group self remove info

Olli Salli olli.salli at collabora.co.uk
Mon Oct 20 09:13:37 PDT 2008


---
 TelepathyQt4/cli-channel.cpp |   30 +++++++++++++++---------------
 TelepathyQt4/cli-channel.h   |   20 ++++++++++++++++++++
 2 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/TelepathyQt4/cli-channel.cpp b/TelepathyQt4/cli-channel.cpp
index 035ac8a..99c6056 100644
--- a/TelepathyQt4/cli-channel.cpp
+++ b/TelepathyQt4/cli-channel.cpp
@@ -75,10 +75,7 @@ struct Channel::Private
     uint groupSelfHandle;
 
     // Group remove info
-    bool groupRemoved;
-    uint groupRemoveActor;
-    uint groupRemoveReason;
-    QString groupRemoveMessage;
+    GroupMemberChangeInfo groupSelfRemoveInfo;
 
     Private(Channel& parent)
         : parent(parent)
@@ -96,9 +93,6 @@ struct Channel::Private
         groupAreHandleOwnersAvailable = false;
         groupIsSelfHandleTracked = false;
         groupSelfHandle = 0;
-        groupRemoved = false;
-        groupRemoveActor = 0;
-        groupRemoveReason = 0;
 
         debug() << "Connecting to Channel::Closed()";
         parent.connect(&parent,
@@ -302,7 +296,15 @@ struct Channel::Private
                 debug() << " Group: Self handle" << groupSelfHandle << "tracked:" << (groupIsSelfHandleTracked ? "yes" : "no");
             }
         } else {
+            Q_ASSERT(newReadiness == ReadinessDead);
+
             debug() << "R.I.P. Channel.";
+
+            if (groupSelfRemoveInfo.isValid()) {
+                debug() << " Group: removed by  " << groupSelfRemoveInfo.actor();
+                debug() << "        because of  " << groupSelfRemoveInfo.reason();
+                debug() << "        with message" << groupSelfRemoveInfo.message();
+            }
         }
 
         readiness = newReadiness;
@@ -397,6 +399,11 @@ uint Channel::groupSelfHandle() const
     return mPriv->groupSelfHandle;
 }
 
+Channel::GroupMemberChangeInfo Channel::groupSelfRemoveInfo() const
+{
+    return mPriv->groupSelfRemoveInfo;
+}
+
 void Channel::gotMainProperties(QDBusPendingCallWatcher* watcher)
 {
     QDBusPendingReply<QVariantMap> reply = *watcher;
@@ -701,17 +708,10 @@ void Channel::onMembersChanged(const QString& message, const Telepathy::UIntList
         if (mPriv->groupRemotePending.remove(handle))
             remoteRemoved.append(handle);
 
-#if 0
-        // TODO self rename before enabling again!
         if (handle == mPriv->groupSelfHandle) {
             debug() << " Self handle removed, saving info...";
-
-            mPriv->groupRemoved = true;
-            mPriv->groupRemoveActor = actor;
-            mPriv->groupRemoveReason = reason;
-            mPriv->groupRemoveMessage = message;
+            mPriv->groupSelfRemoveInfo = GroupMemberChangeInfo(actor, reason, message);
         }
-#endif
     }
 
     if (currentAdded.size() || currentRemoved.size()) {
diff --git a/TelepathyQt4/cli-channel.h b/TelepathyQt4/cli-channel.h
index 8bb8080..a47c16c 100644
--- a/TelepathyQt4/cli-channel.h
+++ b/TelepathyQt4/cli-channel.h
@@ -400,6 +400,26 @@ public:
      */
     uint groupSelfHandle() const;
 
+    /**
+     * Returns information on the removal of the local user from the group. If
+     * the user hasn't been removed from the group, an object for which
+     * GroupMemberChangeInfo::isValid() returns <code>false</code> is returned.
+     *
+     * This method works even when the channel has gone into readiness
+     * #ReadinessDead. This is useful for getting the remove information after
+     * missing the corresponding groupMembersChanged() (or
+     * groupLocalPendingChanged()/groupRemotePendingChanged()) signal, as the
+     * local user being removed usually causes the remote %Channel to be closed,
+     * and consequently the Channel object going into that readiness state.
+     *
+     * The returned information is not guaranteed to be correct if
+     * groupIsSelfHandleTracked() returns false and a self handle change has
+     * occurred on the remote object.
+     *
+     * \return The remove info in a GroupMemberChangeInfo object.
+     */
+    GroupMemberChangeInfo groupSelfRemoveInfo() const;
+
 Q_SIGNALS:
 
     /**
-- 
1.5.6.5




More information about the Telepathy-commits mailing list