mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 13:08:08 +00:00
Expose chat message response code and reason.
This commit is contained in:
parent
304361add5
commit
f021e9aa51
9 changed files with 64 additions and 16 deletions
|
|
@ -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,403, "process error");
|
||||
} else {
|
||||
ms_warning("unexpected io error for incoming message on op [%p]",op);
|
||||
}
|
||||
|
|
@ -54,19 +54,8 @@ static void process_response_event(void *op_base, const belle_sip_response_event
|
|||
SalOp* op = (SalOp*)op_base;
|
||||
/*belle_sip_client_transaction_t *client_transaction=belle_sip_response_event_get_client_transaction(event);*/
|
||||
int code = belle_sip_response_get_status_code(belle_sip_response_event_get_response(event));
|
||||
SalTextDeliveryStatus status;
|
||||
if (code>=100 && code <200)
|
||||
status=SalTextDeliveryInProgress;
|
||||
else if (code>=200 && code <300)
|
||||
status=SalTextDeliveryDone;
|
||||
else
|
||||
status=SalTextDeliveryFailed;
|
||||
if (status != SalTextDeliveryInProgress) {
|
||||
/*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);
|
||||
|
||||
const char *reason = belle_sip_response_get_reason_phrase(belle_sip_response_event_get_response(event));
|
||||
op->base.root->callbacks.text_delivery_update(op,code, 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,17 @@ 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 SalTextDeliveryStatus code_to_text_delivery_status(int code) {
|
||||
if (code>=100 && code <200)
|
||||
return SalTextDeliveryInProgress;
|
||||
else if (code>=200 && code <300)
|
||||
return SalTextDeliveryDone;
|
||||
else
|
||||
return SalTextDeliveryFailed;
|
||||
}
|
||||
|
||||
static void text_delivery_update(SalOp *op, int code, const char *reason){
|
||||
SalTextDeliveryStatus status = code_to_text_delivery_status(code);
|
||||
LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )sal_op_get_user_pointer(op);
|
||||
const MSList* calls;
|
||||
|
||||
|
|
@ -1035,6 +1045,8 @@ 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->response_code=code;
|
||||
chat_msg->response_reason=ms_strdup(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);
|
||||
|
|
|
|||
|
|
@ -786,9 +786,17 @@ void linphone_chat_message_destroy(LinphoneChatMessage* msg) {
|
|||
if (msg->from) linphone_address_destroy(msg->from);
|
||||
if (msg->to) linphone_address_destroy(msg->to);
|
||||
if (msg->custom_headers) sal_custom_header_free(msg->custom_headers);
|
||||
if (msg->response_reason) ms_free(msg->response_reason);
|
||||
ms_free(msg);
|
||||
}
|
||||
|
||||
int linphone_chat_message_get_response_code(LinphoneChatMessage* msg) {
|
||||
return msg->response_code;
|
||||
}
|
||||
|
||||
const char *linphone_chat_message_get_response_reason(LinphoneChatMessage* msg) {
|
||||
return msg->response_reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -1044,6 +1044,8 @@ 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 int linphone_chat_message_get_response_code(LinphoneChatMessage* msg);
|
||||
LINPHONE_PUBLIC const char *linphone_chat_message_get_response_reason(LinphoneChatMessage* msg);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2324,6 +2324,20 @@ extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv
|
|||
return jvalue;
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_getResponseCode(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr) {
|
||||
return linphone_chat_message_get_response_code((LinphoneChatMessage*)ptr);
|
||||
}
|
||||
|
||||
extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getResponseReason(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr) {
|
||||
const char *reason = linphone_chat_message_get_response_reason((LinphoneChatMessage*)ptr);
|
||||
return env->NewStringUTF(reason);
|
||||
|
||||
}
|
||||
|
||||
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,8 @@ struct _LinphoneChatMessage {
|
|||
LinphoneChatMessageState state;
|
||||
bool_t is_read;
|
||||
unsigned int storage_id;
|
||||
int response_code;
|
||||
char *response_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, int code, const char *reason);
|
||||
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,14 @@ public interface LinphoneChatMessage {
|
|||
* @return the id used to id this message in the database
|
||||
*/
|
||||
int getStorageId();
|
||||
|
||||
/**
|
||||
* @return the response code or 0 if no response received
|
||||
*/
|
||||
int getResponseCode();
|
||||
|
||||
/**
|
||||
* @return the response reason or null if no response received
|
||||
*/
|
||||
String getResponseReason();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
|
|||
private native boolean isOutgoing(long ptr);
|
||||
private native void store(long ptr);
|
||||
private native int getStorageId(long ptr);
|
||||
private native int getResponseCode(long ptr);
|
||||
private native String getResponseReason(long ptr);
|
||||
|
||||
protected LinphoneChatMessageImpl(long aNativePtr) {
|
||||
nativePtr = aNativePtr;
|
||||
|
|
@ -94,4 +96,12 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
|
|||
public int getStorageId() {
|
||||
return getStorageId(nativePtr);
|
||||
}
|
||||
|
||||
public int getResponseCode() {
|
||||
return getResponseCode(nativePtr);
|
||||
}
|
||||
|
||||
public String getResponseReason() {
|
||||
return getResponseReason(nativePtr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue