From 89340008674a8027b763e58d295c1248594885d4 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Mon, 24 Nov 2014 11:49:44 +0100 Subject: [PATCH] Fix message tester when no storage is used --- coreapi/callbacks.c | 9 +++++---- coreapi/chat.c | 13 ++++++++++++- coreapi/message_storage.c | 11 ++--------- coreapi/private.h | 1 + 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 59ce4a9a6..363272324 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -303,9 +303,9 @@ static void call_received(SalOp *h){ linphone_address_destroy(to_addr); return; } - + call=linphone_call_new_incoming(lc,from_addr,to_addr,h); - + linphone_call_make_local_media_description(lc,call); sal_call_set_local_media_description(call->op,call->localdesc); md=sal_call_get_final_media_description(call->op); @@ -1170,14 +1170,15 @@ static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status){ } chat_msg->state=chatStatusSal2Linphone(status); - linphone_chat_message_store_state(chat_msg); + linphone_chat_message_update_state(chat_msg); + if (chat_msg && chat_msg->cb) { ms_message("Notifying text delivery with status %i",chat_msg->state); chat_msg->cb(chat_msg ,chat_msg->state ,chat_msg->cb_ud); } - if (status != SalTextDeliveryInProgress) { /*don't release op if progress*/ + if (status != SalTextDeliveryInProgress) { /*only release op if not in progress*/ linphone_chat_message_destroy(chat_msg); } } diff --git a/coreapi/chat.c b/coreapi/chat.c index 989350544..dc7598f03 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -494,6 +494,17 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM linphone_chat_message_unref(msg); } +void linphone_chat_message_update_state(LinphoneChatMessage* chat_msg ) { + linphone_chat_message_store_state(chat_msg); + + if( chat_msg->state == LinphoneChatMessageStateDelivered + || chat_msg->state == LinphoneChatMessageStateNotDelivered ){ + // message is not transient anymore, we can remove it from our transient list and unref it : + chat_msg->chat_room->transient_messages = ms_list_remove(chat_msg->chat_room->transient_messages, chat_msg); + linphone_chat_message_unref(chat_msg); + } +} + /** * Send a message to peer member of this chat room. * @deprecated linphone_chat_room_send_message2() gives more control on the message expedition. @@ -523,7 +534,7 @@ void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessag addr=linphone_address_new(sal_msg->from); linphone_address_clean(addr); cr=linphone_core_get_chat_room(lc,addr); - + if (sal_msg->content_type != NULL) { /* content_type field is, for now, used only for rcs file transfer but we shall strcmp it with "application/vnd.gsma.rcs-ft-http+xml" */ xmlChar *file_url = NULL; xmlDocPtr xmlMessageBody; diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 7e614ea95..55fc82685 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -202,7 +202,7 @@ static int linphone_chat_message_store_content(LinphoneChatMessage *msg) { linphone_content_get_encoding(content), linphone_content_get_size(content), NULL - ); + ); linphone_sql_request(lc->db, buf); sqlite3_free(buf); id = (unsigned int) sqlite3_last_insert_rowid (lc->db); @@ -237,7 +237,7 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){ (int64_t)msg->time, msg->appdata, content_id - ); + ); linphone_sql_request(lc->db,buf); sqlite3_free(buf); ms_free(local_contact); @@ -255,13 +255,6 @@ void linphone_chat_message_store_state(LinphoneChatMessage *msg){ linphone_sql_request(lc->db,buf); sqlite3_free(buf); } - - if( msg->state == LinphoneChatMessageStateDelivered - || msg->state == LinphoneChatMessageStateNotDelivered ){ - // message is not transient anymore, we can remove it from our transient list: - msg->chat_room->transient_messages = ms_list_remove(msg->chat_room->transient_messages, msg); - linphone_chat_message_unref(msg); - } } void linphone_chat_message_store_appdata(LinphoneChatMessage* msg){ diff --git a/coreapi/private.h b/coreapi/private.h index 808e1f57e..56f96fb2e 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -441,6 +441,7 @@ void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj); /*chat*/ void linphone_chat_room_release(LinphoneChatRoom *cr); void linphone_chat_message_destroy(LinphoneChatMessage* msg); +void linphone_chat_message_update_state(LinphoneChatMessage* chat_msg ); /**/ struct _LinphoneProxyConfig