mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Fix message retrieved from history being converted to UTF-8 twice
This commit is contained in:
parent
2643b9a802
commit
b7e9402521
3 changed files with 35 additions and 28 deletions
|
|
@ -385,7 +385,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
|
|||
int retval = -1;
|
||||
LinphoneCore *lc = cr->lc;
|
||||
LinphoneImEncryptionEngine *imee = lc->im_encryption_engine;
|
||||
|
||||
|
||||
/*stubed rtt text*/
|
||||
if (cr->call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(cr->call))) {
|
||||
uint32_t new_line = 0x2028;
|
||||
|
|
@ -634,7 +634,7 @@ static void create_file_transfer_information_from_vnd_gsma_rcs_ft_http_xml(Linph
|
|||
file_url = xmlGetProp(cur, (const xmlChar *)"url");
|
||||
}
|
||||
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"file-key")) {
|
||||
if (!xmlStrcmp(cur->name, (const xmlChar *)"file-key")) {
|
||||
/* there is a key in the msg: file has been encrypted */
|
||||
/* convert the key from base 64 */
|
||||
xmlChar *keyb64 = xmlNodeListGetString(xmlMessageBody, cur->xmlChildrenNode, 1);
|
||||
|
|
@ -642,7 +642,7 @@ static void create_file_transfer_information_from_vnd_gsma_rcs_ft_http_xml(Linph
|
|||
uint8_t *keyBuffer = (uint8_t *)malloc(keyLength);
|
||||
/* decode the key into local key buffer */
|
||||
b64::b64_decode((char *)keyb64, strlen((char *)keyb64), keyBuffer, keyLength);
|
||||
linphone_content_set_key(msg->file_transfer_information, (char *)keyBuffer, keyLength);
|
||||
linphone_content_set_key(msg->file_transfer_information, (char *)keyBuffer, keyLength);
|
||||
/* duplicate key value into the linphone content private structure */
|
||||
xmlFree(keyb64);
|
||||
free(keyBuffer);
|
||||
|
|
@ -664,25 +664,6 @@ static void create_file_transfer_information_from_vnd_gsma_rcs_ft_http_xml(Linph
|
|||
xmlFree(file_url);
|
||||
}
|
||||
|
||||
static LinphoneChatMessage *_linphone_chat_room_create_message(LinphoneChatRoom *cr, const char *message) {
|
||||
LinphoneChatMessage *msg = belle_sip_object_new(LinphoneChatMessage);
|
||||
msg->state = LinphoneChatMessageStateIdle;
|
||||
msg->callbacks = linphone_chat_message_cbs_new();
|
||||
msg->chat_room = (LinphoneChatRoom *)cr;
|
||||
msg->message = message ? ms_strdup(message) : NULL;
|
||||
msg->locale_message = NULL;
|
||||
msg->content_type = ms_strdup("text/plain");
|
||||
msg->file_transfer_information = NULL; /* this property is used only when transfering file */
|
||||
msg->http_request = NULL;
|
||||
msg->time = ms_time(0);
|
||||
msg->is_secured = FALSE;
|
||||
return msg;
|
||||
}
|
||||
|
||||
static LinphoneChatMessage *_linphone_chat_room_create_message_without_conversion(LinphoneChatRoom *cr, const char *message) {
|
||||
return _linphone_chat_room_create_message(cr, message);
|
||||
}
|
||||
|
||||
LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *sal_msg) {
|
||||
LinphoneChatRoom *cr = NULL;
|
||||
LinphoneAddress *addr;
|
||||
|
|
@ -704,7 +685,7 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const
|
|||
goto end;
|
||||
}
|
||||
|
||||
msg = _linphone_chat_room_create_message_without_conversion(cr, sal_msg->text);
|
||||
msg = linphone_chat_room_create_message_without_conversion(cr, sal_msg->text);
|
||||
linphone_chat_message_set_content_type(msg, sal_msg->content_type);
|
||||
linphone_chat_message_set_from(msg, cr->peer_url);
|
||||
|
||||
|
|
@ -981,6 +962,25 @@ const LinphoneAddress *linphone_chat_room_get_peer_address(LinphoneChatRoom *cr)
|
|||
return cr->peer_url;
|
||||
}
|
||||
|
||||
static LinphoneChatMessage *_linphone_chat_room_create_message(LinphoneChatRoom *cr, const char *message) {
|
||||
LinphoneChatMessage *msg = belle_sip_object_new(LinphoneChatMessage);
|
||||
msg->state = LinphoneChatMessageStateIdle;
|
||||
msg->callbacks = linphone_chat_message_cbs_new();
|
||||
msg->chat_room = (LinphoneChatRoom *)cr;
|
||||
msg->message = message ? ms_strdup(message) : NULL;
|
||||
msg->locale_message = NULL;
|
||||
msg->content_type = ms_strdup("text/plain");
|
||||
msg->file_transfer_information = NULL; /* this property is used only when transfering file */
|
||||
msg->http_request = NULL;
|
||||
msg->time = ms_time(0);
|
||||
msg->is_secured = FALSE;
|
||||
return msg;
|
||||
}
|
||||
|
||||
LinphoneChatMessage *linphone_chat_room_create_message_without_conversion(LinphoneChatRoom *cr, const char *message) {
|
||||
return _linphone_chat_room_create_message(cr, message);
|
||||
}
|
||||
|
||||
LinphoneChatMessage *linphone_chat_room_create_message(LinphoneChatRoom *cr, const char *message) {
|
||||
LinphoneChatMessage *msg = _linphone_chat_room_create_message(cr, message);
|
||||
_linphone_chat_message_convert_to_utf8(msg);
|
||||
|
|
@ -1302,7 +1302,7 @@ static void linphone_chat_message_send_imdn(LinphoneChatMessage *cm, enum ImdnTy
|
|||
if (retval <= 0) {
|
||||
sal_message_send(op, identity, cr->peer, msg->content_type, msg->message, NULL);
|
||||
}
|
||||
|
||||
|
||||
linphone_chat_message_unref(msg);
|
||||
linphone_address_unref(from_addr);
|
||||
linphone_address_unref(to_addr);
|
||||
|
|
@ -1654,7 +1654,7 @@ int linphone_chat_message_set_text(LinphoneChatMessage *msg, const char* text) {
|
|||
msg->message = NULL;
|
||||
msg->locale_message = NULL;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ static int create_chat_message(void *data, int argc, char **argv, char **colName
|
|||
new_message = get_transient_message(cr, storage_id);
|
||||
}
|
||||
if (new_message == NULL) {
|
||||
new_message = linphone_chat_room_create_message(cr, argv[4]);
|
||||
new_message = linphone_chat_room_create_message_without_conversion(cr, argv[4]);
|
||||
|
||||
if(atoi(argv[3])==LinphoneChatMessageIncoming){
|
||||
new_message->dir=LinphoneChatMessageIncoming;
|
||||
|
|
@ -584,7 +584,7 @@ bctbx_list_t* linphone_chat_room_find_messages(LinphoneChatRoom *cr, const char
|
|||
char *buf;
|
||||
char *peer;
|
||||
bctbx_list_t* messages;
|
||||
|
||||
|
||||
if (lc->db == NULL) return NULL;
|
||||
peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
|
||||
cr->messages_hist = NULL;
|
||||
|
|
@ -611,7 +611,7 @@ LinphoneChatMessage * linphone_chat_room_find_message_with_dir(LinphoneChatRoom
|
|||
}
|
||||
if (messages)
|
||||
bctbx_list_free_with_data(messages, (bctbx_list_free_func)linphone_chat_message_unref);
|
||||
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,13 @@ LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_room_create_message(LinphoneC
|
|||
* @return a new #LinphoneChatMessage
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_room_create_message_2(LinphoneChatRoom *cr, const char* message, const char* external_body_url, LinphoneChatMessageState state, time_t time, bool_t is_read, bool_t is_incoming);
|
||||
/**
|
||||
* Create a message attached to a dedicated chat room without converting the message to UTF-8;
|
||||
* @param cr the chat room.
|
||||
* @param message text message, NULL if absent.
|
||||
* @return a new #LinphoneChatMessage
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneChatMessage *linphone_chat_room_create_message_without_conversion(LinphoneChatRoom *cr, const char *message);
|
||||
|
||||
/**
|
||||
* Acquire a reference to the chat room.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue