Commit ef515f51 authored by David Edmundson's avatar David Edmundson

Set the conversation to valid if a new TextChannel is set

REVIEW: 110682
parent 8576b805
......@@ -49,15 +49,11 @@ Conversation::Conversation(const Tp::TextChannelPtr &channel,
d->account = account;
d->messages = new MessagesModel(account, this);
d->messages->setTextChannel(channel);
setTextChannel(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)));
}
Conversation::Conversation(QObject *parent) : QObject(parent)
......@@ -66,6 +62,20 @@ Conversation::Conversation(QObject *parent) : QObject(parent)
Q_ASSERT(false);
}
void Conversation::setTextChannel(const Tp::TextChannelPtr& channel)
{
d->messages->setTextChannel(channel);
d->valid = channel->isValid();
connect(channel.data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
SLOT(onChannelInvalidated(Tp::DBusProxy*,QString,QString)));
Q_EMIT validityChanged(d->valid);
}
Tp::TextChannelPtr Conversation::textChannel() const
{
return d->messages->textChannel();
}
MessagesModel* Conversation::messages() const
{
return d->messages;
......
......@@ -44,6 +44,9 @@ public:
Conversation(QObject *parent = 0);
virtual ~Conversation();
void setTextChannel(const Tp::TextChannelPtr &channel);
Tp::TextChannelPtr textChannel() const;
MessagesModel* messages() const;
ConversationTarget* target() const;
......
......@@ -115,12 +115,12 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> &
//if we are handling but should delegate, call delegate channel
Q_FOREACH(Conversation *convo, d->conversations) {
if (convo->target()->id() == textChannel->targetId() &&
convo->messages()->textChannel()->targetHandleType() == textChannel->targetHandleType())
convo->textChannel()->targetHandleType() == textChannel->targetHandleType())
{
if (!shouldDelegate) {
convo->messages()->setTextChannel(textChannel);
convo->setTextChannel(textChannel);
} else {
if (convo->messages()->textChannel() == textChannel) {
if (convo->textChannel() == textChannel) {
convo->delegateToProperClient();
}
}
......
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