Commit bf62bf20 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

improve chat

parent 94396dac
......@@ -209,16 +209,15 @@ static int create_chat_message(void *data, int argc, char **argv, char **colName
// check if the message exists in the transient list, in which case we should return that one.
LinphoneChatMessage* new_message = get_transient_message(cr, storage_id);
if( new_message == NULL ){
LinphoneAddress *local_addr=linphone_address_new(argv[1]);
new_message = linphone_chat_room_create_message(cr, argv[4]);
if(atoi(argv[3])==LinphoneChatMessageIncoming){
new_message->dir=LinphoneChatMessageIncoming;
linphone_chat_message_set_from(new_message,linphone_chat_room_get_peer_address(cr));
new_message->to = local_addr; /*direct assignation to avoid a copy*/
new_message->to = NULL; /*will be filled at the end */
} else {
new_message->dir=LinphoneChatMessageOutgoing;
new_message->from = local_addr; /*direct assignation to avoid a copy*/
new_message->from = NULL; /*will be filled at the end */
linphone_chat_message_set_to(new_message,linphone_chat_room_get_peer_address(cr));
}
......@@ -501,6 +500,23 @@ bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int sta
ms_message("%s(): completed in %i ms",__FUNCTION__, (int)(end-begin));
}
ms_free(buf);
if (cr->messages_hist) {
//fill local addr with core identity instead of per message
LinphoneAddress* local_addr = linphone_address_new(linphone_core_get_identity(cr->lc));
bctbx_list_t* it = cr->messages_hist;
while (it) {
LinphoneChatMessage* msg = it->data;
if (msg->dir == LinphoneChatMessageOutgoing) {
msg->from = linphone_address_ref(local_addr);
} else {
msg->to = linphone_address_ref(local_addr);
}
it = it->next;
}
linphone_address_unref(local_addr);
}
ret=cr->messages_hist;
cr->messages_hist=NULL;
ms_free(peer);
......
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