From 9f2b9df16a2f6537196a7f2ec8db792d63287a9d Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 3 Sep 2015 21:29:44 +0200 Subject: [PATCH] Revert "chat: fix crash when receiving message status notification AFTER having deleted the chat room" This reverts commit 08e923a41c73ce78826c3ef93e9107e89222ce40. This commit breaks compilation. --- coreapi/chat.c | 10 ++++------ coreapi/message_storage.c | 10 ++++++---- coreapi/private.h | 6 +++--- tester/message_tester.c | 12 ------------ 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index 2f4199547..0c8217733 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -621,15 +621,13 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM linphone_chat_message_unref(msg); } -void linphone_chat_message_update_state(LinphoneChatMessage* chat_msg, LinphoneCore* lc) { - linphone_chat_message_store_state(chat_msg, lc); +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 : - if (chat_msg->chat_room) { - chat_msg->chat_room->transient_messages = ms_list_remove(chat_msg->chat_room->transient_messages, chat_msg); - } + chat_msg->chat_room->transient_messages = ms_list_remove(chat_msg->chat_room->transient_messages, chat_msg); linphone_chat_message_unref(chat_msg); } } @@ -1089,7 +1087,7 @@ void linphone_chat_message_set_appdata(LinphoneChatMessage* message, const char* ms_free(message->appdata); } message->appdata = data? ms_strdup(data) : NULL; - linphone_chat_message_store_appdata(message, message->chat_room->lc); + linphone_chat_message_store_appdata(message); } diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 2b58ffe1b..ed9f6be34 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -253,7 +253,8 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){ return id; } -void linphone_chat_message_store_state(LinphoneChatMessage *msg, LinphoneCore *lc){ +void linphone_chat_message_store_state(LinphoneChatMessage *msg){ + LinphoneCore *lc=msg->chat_room->lc; if (lc->db){ char *buf=sqlite3_mprintf("UPDATE history SET status=%i WHERE (id = %i);", msg->state,msg->storage_id); @@ -262,7 +263,8 @@ void linphone_chat_message_store_state(LinphoneChatMessage *msg, LinphoneCore *l } } -void linphone_chat_message_store_appdata(LinphoneChatMessage* msg, LinphoneCore *lc){ +void linphone_chat_message_store_appdata(LinphoneChatMessage* msg){ + LinphoneCore *lc=msg->chat_room->lc; if (lc->db){ char *buf=sqlite3_mprintf("UPDATE history SET appdata=%Q WHERE id=%i;", msg->appdata,msg->storage_id); @@ -669,10 +671,10 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *cr){ return 0; } -void linphone_chat_message_store_state(LinphoneChatMessage *cr, LinphoneCore* lc)){ +void linphone_chat_message_store_state(LinphoneChatMessage *cr){ } -void linphone_chat_message_store_appdata(LinphoneChatMessage *msg, LinphoneCore *lc){ +void linphone_chat_message_store_appdata(LinphoneChatMessage *msg){ } void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr){ diff --git a/coreapi/private.h b/coreapi/private.h index b6d0c7de1..12fd5b4c4 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -79,7 +79,7 @@ extern "C" { #endif #include - + #ifndef _ #define _(String) dgettext(GETTEXT_PACKAGE,String) #endif @@ -962,8 +962,8 @@ void linphone_upnp_destroy(LinphoneCore *lc); sqlite3 * linphone_message_storage_init(); void linphone_message_storage_init_chat_rooms(LinphoneCore *lc); #endif -void linphone_chat_message_store_state(LinphoneChatMessage *msg, LinphoneCore* lc); -void linphone_chat_message_store_appdata(LinphoneChatMessage* msg, LinphoneCore *lc); +void linphone_chat_message_store_state(LinphoneChatMessage *msg); +void linphone_chat_message_store_appdata(LinphoneChatMessage* msg); void linphone_core_message_storage_init(LinphoneCore *lc); void linphone_core_message_storage_close(LinphoneCore *lc); void linphone_core_message_storage_set_debug(LinphoneCore *lc, bool_t debug); diff --git a/tester/message_tester.c b/tester/message_tester.c index 326cbde16..6ffaab17d 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1692,17 +1692,7 @@ static void history_messages_count() { } - #endif -static void text_status_after_destroying_chat_room() { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneChatRoom *chatroom = linphone_core_get_chat_room_from_uri(marie->lc, ""); - LinphoneChatMessage *message = linphone_chat_room_create_message(chatroom, "hello"); - linphone_chat_room_send_chat_message(chatroom, message); - linphone_chat_room_unref(chatroom); - wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000); - linphone_core_manager_destroy(marie); -} test_t message_tests[] = { { "Text message", text_message }, @@ -1736,7 +1726,6 @@ test_t message_tests[] = { ,{ "History count", history_messages_count } ,{ "History range", history_range_full_test } #endif - ,{ "Text status after destroying chat room", text_status_after_destroying_chat_room }, }; test_suite_t message_test_suite = { @@ -1747,4 +1736,3 @@ test_suite_t message_test_suite = { message_tests }; -