diff options
author | Olli Salli <ollisal@gmail.com> | 2011-01-01 20:53:04 +0200 |
---|---|---|
committer | Olli Salli <ollisal@gmail.com> | 2011-01-01 20:53:04 +0200 |
commit | 7f5391900be01a5c6be25b8fe8a00f36a806adec (patch) | |
tree | beac0dd94832b4ff24be4c30d37d8364e5204d15 | |
parent | cba954bb2215de9412deddae44e380f7efb9ae5e (diff) |
Make the requestLeave "already left" check more sensible
-rw-r--r-- | TelepathyQt4/channel.cpp | 8 | ||||
-rw-r--r-- | tests/dbus/chan-group.cpp | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/TelepathyQt4/channel.cpp b/TelepathyQt4/channel.cpp index 592a89ea..ea45ad81 100644 --- a/TelepathyQt4/channel.cpp +++ b/TelepathyQt4/channel.cpp @@ -1708,13 +1708,15 @@ PendingOperation *Channel::requestLeave(const QString &message, ChannelGroupChan return requestClose(); } - if (mPriv->groupSelfContactRemoveInfo.isValid()) { + ContactPtr self = groupSelfContact(); + + if (!groupContacts().contains(self) && !groupLocalPendingContacts().contains(self) + && !groupRemotePendingContacts().contains(self)) { debug() << "Channel::requestLeave() called for " << objectPath() << - "which has already been left"; + "which we aren't a member of"; return new PendingSuccess(ChannelPtr(this)); } - // TODO: use PendingLeave which handles errors correctly by falling back to Close return new PendingLeave(ChannelPtr(this), message, reason); } diff --git a/tests/dbus/chan-group.cpp b/tests/dbus/chan-group.cpp index 3621c3c2..f21fe2c5 100644 --- a/tests/dbus/chan-group.cpp +++ b/tests/dbus/chan-group.cpp @@ -448,6 +448,12 @@ void TestChanGroup::testLeave() QVERIFY(mChan->groupSelfContactRemoveInfo().isValid()); QVERIFY(mChan->groupSelfContactRemoveInfo().hasActor()); QVERIFY(mChan->groupSelfContactRemoveInfo().actor() == mConn->selfContact()); + + // Another leave should no-op succeed, because we aren't a member + QVERIFY(connect(mChan->requestLeave(leaveMessage), + SIGNAL(finished(Tp::PendingOperation*)), + SLOT(expectSuccessfulCall(Tp::PendingOperation*)))); + QCOMPARE(mLoop->exec(), 0); } void TestChanGroup::testLeaveWithFallback() |