diff options
-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() |