Handle IMDN negative-delivery.

This commit is contained in:
Ghislain MARY 2018-04-20 17:43:20 +02:00
parent d1dc223898
commit dfde23f205
2 changed files with 11 additions and 2 deletions

View file

@ -548,7 +548,9 @@ LinphoneReason ChatMessagePrivate::receive () {
/* Unable to decrypt message */
chatRoom->getPrivate()->notifyUndecryptableChatMessageReceived(q->getSharedFromThis());
reason = linphone_error_code_to_reason(errorCode);
q->sendDeliveryNotification(reason);
if (getNegativeDeliveryNotificationRequired()) {
q->sendDeliveryNotification(reason);
}
return reason;
} else if (result == ChatMessageModifier::Result::Suspended) {
currentRecvStep |= ChatMessagePrivate::Step::Encryption;
@ -632,7 +634,9 @@ LinphoneReason ChatMessagePrivate::receive () {
if (errorCode > 0) {
reason = linphone_error_code_to_reason(errorCode);
q->sendDeliveryNotification(reason);
if (getNegativeDeliveryNotificationRequired()) {
q->sendDeliveryNotification(reason);
}
return reason;
}

View file

@ -46,6 +46,7 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptr<Ch
cpimMessage.addMessageHeader(cpimToHeader);
if (message->getPrivate()->getPositiveDeliveryNotificationRequired()
|| message->getPrivate()->getNegativeDeliveryNotificationRequired()
|| message->getPrivate()->getDisplayNotificationRequired()
) {
const string imdnNamespace = "imdn";
@ -66,6 +67,8 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptr<Ch
vector<string> dispositionNotificationValues;
if (message->getPrivate()->getPositiveDeliveryNotificationRequired())
dispositionNotificationValues.emplace_back("positive-delivery");
if (message->getPrivate()->getNegativeDeliveryNotificationRequired())
dispositionNotificationValues.emplace_back("negative-delivery");
if (message->getPrivate()->getDisplayNotificationRequired())
dispositionNotificationValues.emplace_back("display");
dispositionNotificationHeader.setValue(Utils::join(dispositionNotificationValues, ", "));
@ -184,6 +187,8 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptr<Ch
for (const auto &value : values)
if (value == "positive-delivery")
message->getPrivate()->setPositiveDeliveryNotificationRequired(true);
else if (value == "negative-delivery")
message->getPrivate()->setNegativeDeliveryNotificationRequired(true);
else if (value == "display")
message->getPrivate()->setDisplayNotificationRequired(true);
}