Commit 3053f351 authored by Martin Klapetek's avatar Martin Klapetek Committed by Alexander Akulich
Browse files

[declarative] Add "canSendMessages" property to Conversation

parent 766fba5b
......@@ -316,3 +316,12 @@ bool Conversation::isContactTyping() const
return false;
}
bool Conversation::canSendMessages() const
{
if (d->messages && d->messages->textChannel()) {
return true;
}
return false;
}
......@@ -45,6 +45,7 @@ class Conversation : public QObject
Q_PROPERTY(KPeople::PersonData *personData READ personData CONSTANT)
Q_PROPERTY(bool hasUnreadMessages READ hasUnreadMessages NOTIFY unreadMessagesChanged)
Q_PROPERTY(bool isContactTyping READ isContactTyping NOTIFY contactTypingChanged)
Q_PROPERTY(bool canSendMessages READ canSendMessages NOTIFY canSendMessagesChanged)
public:
Conversation(const Tp::TextChannelPtr &channel, const Tp::AccountPtr &account, QObject *parent = 0);
......@@ -78,6 +79,7 @@ public:
bool hasUnreadMessages() const;
bool isContactTyping() const;
bool canSendMessages() const;
Q_SIGNALS:
void validityChanged(bool isValid);
......@@ -88,6 +90,7 @@ Q_SIGNALS:
void unreadMessagesChanged();
void lastMessageChanged();
void contactTypingChanged();
void canSendMessagesChanged();
public Q_SLOTS:
void delegateToProperClient();
......
......@@ -405,6 +405,11 @@ void MessagesModel::sendNewMessage(const QString &message)
if (message.isEmpty()) {
qCWarning(KTP_DECLARATIVE) << "Attempting to send empty string, this is not supported";
} else {
if (!d->textChannel) {
qWarning(KTP_DECLARATIVE) << "Attempting to send a message without a channel, returning";
return;
}
Tp::PendingOperation *op;
QString modifiedMessage = message;
if (d->textChannel->supportsMessageType(Tp::ChannelTextMessageTypeAction)
......
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