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

message_storage.c: do not rebuild peer address for each DB message since it is...

message_storage.c: do not rebuild peer address for each DB message since it is already available in chat room structure
parent 8032e027
...@@ -182,37 +182,31 @@ static int callback_all(void *data, int argc, char **argv, char **colName){ ...@@ -182,37 +182,31 @@ static int callback_all(void *data, int argc, char **argv, char **colName){
*/ */
static int create_chat_message(void *data, int argc, char **argv, char **colName){ static int create_chat_message(void *data, int argc, char **argv, char **colName){
LinphoneChatRoom *cr = (LinphoneChatRoom *)data; LinphoneChatRoom *cr = (LinphoneChatRoom *)data;
LinphoneAddress *from;
LinphoneAddress *to;
unsigned int storage_id = atoi(argv[0]); unsigned int storage_id = atoi(argv[0]);
// check if the message exists in the transient list, in which case we should return that one. // 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); LinphoneChatMessage* new_message = get_transient_message(cr, storage_id);
if( new_message == NULL ){ if( new_message == NULL ){
LinphoneAddress *local_addr=linphone_address_new(argv[1]);
new_message = linphone_chat_room_create_message(cr, argv[4]); new_message = linphone_chat_room_create_message(cr, argv[4]);
if(atoi(argv[3])==LinphoneChatMessageIncoming){ if(atoi(argv[3])==LinphoneChatMessageIncoming){
new_message->dir=LinphoneChatMessageIncoming; new_message->dir=LinphoneChatMessageIncoming;
from=linphone_address_new(argv[2]); linphone_chat_message_set_from(new_message,linphone_chat_room_get_peer_address(cr));
to=linphone_address_new(argv[1]); linphone_chat_message_set_to(new_message,local_addr);
} else { } else {
new_message->dir=LinphoneChatMessageOutgoing; new_message->dir=LinphoneChatMessageOutgoing;
from=linphone_address_new(argv[1]); linphone_chat_message_set_from(new_message,local_addr);
to=linphone_address_new(argv[2]); linphone_chat_message_set_to(new_message,linphone_chat_room_get_peer_address(cr));
}
linphone_chat_message_set_from(new_message,from);
linphone_address_destroy(from);
if (to){
linphone_chat_message_set_to(new_message,to);
linphone_address_destroy(to);
} }
linphone_address_destroy(local_addr);
new_message->time = (time_t)atol(argv[9]); new_message->time = (time_t)atol(argv[9]);
new_message->is_read=atoi(argv[6]); new_message->is_read=atoi(argv[6]);
new_message->state=atoi(argv[7]); new_message->state=atoi(argv[7]);
new_message->storage_id=storage_id; new_message->storage_id=storage_id;
new_message->external_body_url= ms_strdup(argv[8]); new_message->external_body_url= ms_strdup(argv[8]);
new_message->appdata = ms_strdup(argv[10]); new_message->appdata = ms_strdup(argv[10]);
if (argv[11] != NULL) { if (argv[11] != NULL) {
int id = atoi(argv[11]); int id = atoi(argv[11]);
......
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