Commit e2ca3cbb authored by Ghislain MARY's avatar Ghislain MARY

Prevent encryption of IMDN messages signaling an error.

parent 64e74b6e
......@@ -93,6 +93,8 @@ public:
void setChatRoom (const std::shared_ptr<AbstractChatRoom> &chatRoom);
void setEncryptionPrevented (bool value) { encryptionPrevented = value; }
// -----------------------------------------------------------------------------
// Deprecated methods only used for C wrapper, to be removed some day...
// -----------------------------------------------------------------------------
......@@ -169,6 +171,7 @@ private:
ChatMessage::State state = ChatMessage::State::Idle;
ChatMessage::Direction direction = ChatMessage::Direction::Incoming;
bool encryptionPrevented = false;
bool toBeStored = true;
L_DECLARE_PUBLIC(ChatMessage);
......
......@@ -353,6 +353,8 @@ void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) {
content->setBody(Imdn::createXml(imdnId, time, imdnType, reason));
msg->addContent(*content);
if (reason != LinphoneReasonNone)
msg->getPrivate()->setEncryptionPrevented(true);
msg->setToBeStored(false);
msg->getPrivate()->send();
......@@ -628,15 +630,17 @@ void ChatMessagePrivate::send () {
if ((currentSendStep &ChatMessagePrivate::Step::Encryption) == ChatMessagePrivate::Step::Encryption) {
lInfo() << "Encryption step already done, skipping";
} else {
EncryptionChatMessageModifier ecmm;
ChatMessageModifier::Result result = ecmm.encode(q->getSharedFromThis(), errorCode);
if (result == ChatMessageModifier::Result::Error) {
sal_error_info_set((SalErrorInfo *)op->get_error_info(), SalReasonNotAcceptable, "SIP", errorCode, "Unable to encrypt IM", nullptr);
setState(ChatMessage::State::NotDelivered);
return;
} else if (result == ChatMessageModifier::Result::Suspended) {
currentSendStep |= ChatMessagePrivate::Step::Encryption;
return;
if (!encryptionPrevented) {
EncryptionChatMessageModifier ecmm;
ChatMessageModifier::Result result = ecmm.encode(q->getSharedFromThis(), errorCode);
if (result == ChatMessageModifier::Result::Error) {
sal_error_info_set((SalErrorInfo *)op->get_error_info(), SalReasonNotAcceptable, "SIP", errorCode, "Unable to encrypt IM", nullptr);
setState(ChatMessage::State::NotDelivered);
return;
} else if (result == ChatMessageModifier::Result::Suspended) {
currentSendStep |= ChatMessagePrivate::Step::Encryption;
return;
}
}
currentSendStep |= ChatMessagePrivate::Step::Encryption;
}
......
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