Commit f3a30eb3 authored by David Edmundson's avatar David Edmundson

Make sure ConversationModel never close a channels it is not handling

BUG: 293637
BUG: 317850
REVIEW: 109925
parent 4c4692ca
......@@ -31,6 +31,9 @@ class Conversation::ConversationPrivate
public:
MessagesModel *messages;
ConversationTarget *target;
//stores if the conversation has been delegated to another client and we are only observing the channel
//and not handling it.
bool delegated;
bool valid;
Tp::AccountPtr account;
};
......@@ -51,6 +54,8 @@ Conversation::Conversation(const Tp::TextChannelPtr &channel,
d->target = new ConversationTarget(account, KTp::ContactPtr::qObjectCast(channel->targetContact()), this);
d->valid = channel->isValid();
d->delegated = false;
connect(channel.data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
SLOT(onChannelInvalidated(Tp::DBusProxy*,QString,QString)));
}
......@@ -88,13 +93,17 @@ void Conversation::onChannelInvalidated(Tp::DBusProxy *proxy, const QString &err
void Conversation::delegateToProperClient()
{
ChannelDelegator::delegateChannel(d->account, d->messages->textChannel());
d->delegated = true;
Q_EMIT conversationDelegated();
}
void Conversation::requestClose()
{
kDebug();
d->messages->textChannel()->requestClose();
//if we are not handling the channel do nothing.
if (!d->delegated) {
d->messages->textChannel()->requestClose();
}
}
Conversation::~Conversation()
......
......@@ -21,7 +21,6 @@
#include "conversation.h"
#include "conversation-target.h"
#include "messages-model.h"
#include "channel-delegator.h"
#include <KDebug>
......@@ -121,7 +120,7 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> &
convo->messages()->setTextChannel(textChannel);
} else {
if (convo->messages()->textChannel() == textChannel) {
ChannelDelegator::delegateChannel(account, textChannel, userActionTime);
convo->delegateToProperClient();
}
}
handled = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment