Commit 93f5e859 authored by Guillaume Beraudo's avatar Guillaume Beraudo

Expose chat message reason based on LinphoneReason.

The response code is not exposed to allow mrtp in the future.
There is no possibility to retrieve the code or the sip reason phrase.
parent e8bc43d7
......@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void process_error( SalOp* op) {
if (op->dir == SalOpDirOutgoing) {
op->base.root->callbacks.text_delivery_update(op,SalTextDeliveryFailed);
op->base.root->callbacks.text_delivery_update(op, SalTextDeliveryFailed, SalReasonUnknown);
} else {
ms_warning("unexpected io error for incoming message on op [%p]",op);
}
......@@ -65,8 +65,9 @@ static void process_response_event(void *op_base, const belle_sip_response_event
/*reset op to make sure transaction terminated does not need op
belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(client_transaction),NULL);*/
}
op->base.root->callbacks.text_delivery_update(op,status);
SalReason reason = code == 403 ? SalReasonForbidden : SalReasonUnknown;
op->base.root->callbacks.text_delivery_update(op,status, reason);
}
static bool_t is_plain_text(belle_sip_header_content_type_t* content_type) {
return strcmp("text",belle_sip_header_content_type_get_type(content_type))==0
......
......@@ -1024,7 +1024,7 @@ static int op_equals(LinphoneCall *a, SalOp *b) {
return a->op !=b; /*return 0 if equals*/
}
static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status){
static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status, SalReason reason){
LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )sal_op_get_user_pointer(op);
const MSList* calls;
......@@ -1035,6 +1035,7 @@ static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status){
calls = linphone_core_get_calls(chat_msg->chat_room->lc);
chat_msg->state=chatStatusSal2Linphone(status);
chat_msg->reason=reason;
linphone_chat_message_store_state(chat_msg);
if (chat_msg && chat_msg->cb) {
ms_message("Notifying text delivery with status %i",chat_msg->state);
......
......@@ -790,6 +790,10 @@ void linphone_chat_message_destroy(LinphoneChatMessage* msg) {
}
LinphoneReason linphone_chat_message_get_reason(LinphoneChatMessage* msg) {
return linphone_reason_from_sal(msg->reason);
}
/**
* @}
*/
......
......@@ -1044,6 +1044,7 @@ LINPHONE_PUBLIC const char * linphone_chat_message_get_custom_header(LinphoneCha
LINPHONE_PUBLIC bool_t linphone_chat_message_is_read(LinphoneChatMessage* message);
LINPHONE_PUBLIC bool_t linphone_chat_message_is_outgoing(LinphoneChatMessage* message);
LINPHONE_PUBLIC unsigned int linphone_chat_message_get_storage_id(LinphoneChatMessage* message);
LINPHONE_PUBLIC LinphoneReason linphone_chat_message_get_reason(LinphoneChatMessage* msg);
/**
* @}
*/
......
......@@ -2324,6 +2324,12 @@ extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv
return jvalue;
}
extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_getReason(JNIEnv* env
,jobject thiz
,jlong ptr) {
return linphone_chat_message_get_reason((LinphoneChatMessage*)ptr);
}
extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getCustomHeader(JNIEnv* env
,jobject thiz
,jlong ptr, jstring jheader_name) {
......
......@@ -25,6 +25,7 @@
#ifndef _PRIVATE_H
#define _PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "linphonecore.h"
......@@ -145,6 +146,7 @@ struct _LinphoneChatMessage {
LinphoneChatMessageState state;
bool_t is_read;
unsigned int storage_id;
LinphoneReason reason;
};
typedef struct StunCandidate{
......
......@@ -391,7 +391,7 @@ typedef void (*SalOnVfuRequest)(SalOp *op);
typedef void (*SalOnDtmfReceived)(SalOp *op, char dtmf);
typedef void (*SalOnRefer)(Sal *sal, SalOp *op, const char *referto);
typedef void (*SalOnTextReceived)(SalOp *op, const SalMessage *msg);
typedef void (*SalOnTextDeliveryUpdate)(SalOp *op, SalTextDeliveryStatus status);
typedef void (*SalOnTextDeliveryUpdate)(SalOp *op, SalTextDeliveryStatus, SalReason);
typedef void (*SalOnIsComposingReceived)(SalOp *op, const SalIsComposing *is_composing);
typedef void (*SalOnNotifyRefer)(SalOp *op, SalReferStatus state);
typedef void (*SalOnSubscribeResponse)(SalOp *op, SalSubscribeStatus status, SalError error, SalReason reason);
......
......@@ -141,4 +141,9 @@ public interface LinphoneChatMessage {
* @return the id used to id this message in the database
*/
int getStorageId();
/**
* @return the reason if response received
*/
Reason getReason();
}
......@@ -94,4 +94,10 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
public int getStorageId() {
return getStorageId(nativePtr);
}
private native int getReason(long ptr);
public Reason getReason() {
return Reason.fromInt(getReason(nativePtr));
}
}
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