diff options
author | Olli Salli <ollisal@gmail.com> | 2010-12-31 16:29:52 +0200 |
---|---|---|
committer | Olli Salli <ollisal@gmail.com> | 2010-12-31 16:35:01 +0200 |
commit | 606b622176e736b3715215e01513b0f49f2808a3 (patch) | |
tree | c92f02e87a5fd5aa6603e56fa17ecd4c515e8466 | |
parent | f34da7ebe26a127c4dfab575ff429dc0da1c4c14 (diff) |
Make PendingLeave ensure the member remove event has been picked up before finishing
-rw-r--r-- | TelepathyQt4/channel-internal.h | 2 | ||||
-rw-r--r-- | TelepathyQt4/channel.cpp | 33 | ||||
-rw-r--r-- | tests/dbus/chan-group.cpp | 20 |
3 files changed, 37 insertions, 18 deletions
diff --git a/TelepathyQt4/channel-internal.h b/TelepathyQt4/channel-internal.h index ec1ccb38..74e02f63 100644 --- a/TelepathyQt4/channel-internal.h +++ b/TelepathyQt4/channel-internal.h @@ -39,6 +39,8 @@ public: private Q_SLOTS: void onChanInvalidated(Tp::DBusProxy *proxy); void onRemoveFinished(Tp::PendingOperation *); + void onMembersChanged(const Tp::Contacts &, const Tp::Contacts &, const Tp::Contacts &, + const Tp::Contacts &); void onCloseFinished(Tp::PendingOperation *); }; diff --git a/TelepathyQt4/channel.cpp b/TelepathyQt4/channel.cpp index b80401bc..592a89ea 100644 --- a/TelepathyQt4/channel.cpp +++ b/TelepathyQt4/channel.cpp @@ -1602,7 +1602,22 @@ void Channel::PendingLeave::onRemoveFinished(Tp::PendingOperation *op) if (op->isValid()) { debug() << "We left the channel" << chan->objectPath(); - setFinished(); + + ContactPtr c = chan->groupSelfContact(); + + if (chan->groupContacts().contains(c) + || chan->groupLocalPendingContacts().contains(c) + || chan->groupRemotePendingContacts().contains(c)) { + debug() << "Waiting for self remove to be picked up"; + connect(chan.data(), + SIGNAL(groupMembersChanged(Tp::Contacts,Tp::Contacts,Tp::Contacts,Tp::Contacts, + Tp::Channel::GroupMemberChangeDetails)), + this, + SLOT(onMembersChanged(Tp::Contacts,Tp::Contacts,Tp::Contacts,Tp::Contacts))); + } else { + setFinished(); + } + return; } @@ -1617,6 +1632,22 @@ void Channel::PendingLeave::onRemoveFinished(Tp::PendingOperation *op) SLOT(onCloseFinished(Tp::PendingOperation*))); } +void Channel::PendingLeave::onMembersChanged(const Tp::Contacts &, const Tp::Contacts &, + const Tp::Contacts &, const Tp::Contacts &removed) +{ + if (isFinished()) { + return; + } + + ChannelPtr chan = ChannelPtr::staticCast(object()); + ContactPtr c = chan->groupSelfContact(); + + if (removed.contains(c)) { + debug() << "Leave event picked up for" << chan->objectPath(); + setFinished(); + } +} + void Channel::PendingLeave::onCloseFinished(Tp::PendingOperation *op) { if (isFinished()) { diff --git a/tests/dbus/chan-group.cpp b/tests/dbus/chan-group.cpp index 966d9ad2..27d88d46 100644 --- a/tests/dbus/chan-group.cpp +++ b/tests/dbus/chan-group.cpp @@ -430,29 +430,15 @@ void TestChanGroup::testLeave() SLOT(expectSuccessfulCall(Tp::PendingOperation*)))); QCOMPARE(mLoop->exec(), 0); + QVERIFY(mChan->groupContacts().contains(mConn->selfContact())); + QString leaveMessage(QLatin1String("I'm sick of this lot")); QVERIFY(connect(mChan->requestLeave(leaveMessage), SIGNAL(finished(Tp::PendingOperation*)), SLOT(expectSuccessfulCall(Tp::PendingOperation*)))); QCOMPARE(mLoop->exec(), 0); - if (!mChan->groupSelfContactRemoveInfo().isValid()) { - // Wait for the group to pick up the self remove - QVERIFY(connect(mChan.data(), - SIGNAL(groupMembersChanged( - const Tp::Contacts &, - const Tp::Contacts &, - const Tp::Contacts &, - const Tp::Contacts &, - const Tp::Channel::GroupMemberChangeDetails &)), - SLOT(onGroupMembersChanged( - const Tp::Contacts &, - const Tp::Contacts &, - const Tp::Contacts &, - const Tp::Contacts &, - const Tp::Channel::GroupMemberChangeDetails &)))); - QCOMPARE(mLoop->exec(), 0); - } + QVERIFY(!mChan->groupContacts().contains(mConn->selfContact())); // We left gracefully, which we have details for. // Unfortunately, the test CM used here ignores the message and the reason specified, so can't |