From b10ab978b873775c179cc0aa3fc2823e37d842d6 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 25 Sep 2017 16:46:20 +0200 Subject: [PATCH] Simplify the chat room instantiation notification. --- src/c-wrapper/api/c-chat-room.cpp | 6 ++---- src/chat/chat-room.cpp | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index 6ae4f109f..547f96705 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -267,12 +267,11 @@ void linphone_chat_room_set_user_data (LinphoneChatRoom *cr, void *ud) { // ============================================================================= LinphoneChatRoom *linphone_chat_room_new (LinphoneCore *core, const LinphoneAddress *addr) { - LinphoneChatRoom *cr = _linphone_ChatRoom_init(); + LinphoneChatRoom *cr = L_INIT(ChatRoom); if (linphone_core_realtime_text_enabled(core)) L_SET_CPP_PTR_FROM_C_OBJECT(cr, std::make_shared(core, *L_GET_CPP_PTR_FROM_C_OBJECT(addr))); else L_SET_CPP_PTR_FROM_C_OBJECT(cr, std::make_shared(core, *L_GET_CPP_PTR_FROM_C_OBJECT(addr))); - linphone_core_notify_chat_room_instantiated(core, cr); L_GET_PRIVATE_FROM_C_OBJECT(cr)->setState(LinphonePrivate::ChatRoom::State::Instantiated); L_GET_PRIVATE_FROM_C_OBJECT(cr)->setState(LinphonePrivate::ChatRoom::State::Created); return cr; @@ -291,9 +290,8 @@ LinphoneChatRoom *_linphone_client_group_chat_room_new (LinphoneCore *core) { if (from.empty()) from = linphone_core_get_primary_contact(core); LinphonePrivate::Address me(from); - LinphoneChatRoom *cr = _linphone_ChatRoom_init(); + LinphoneChatRoom *cr = L_INIT(ChatRoom); L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared(core, me)); - linphone_core_notify_chat_room_instantiated(core, cr); L_GET_PRIVATE_FROM_C_OBJECT(cr)->setState(LinphonePrivate::ChatRoom::State::Instantiated); return cr; } diff --git a/src/chat/chat-room.cpp b/src/chat/chat-room.cpp index 239d28403..19774db04 100644 --- a/src/chat/chat-room.cpp +++ b/src/chat/chat-room.cpp @@ -182,8 +182,11 @@ int ChatRoomPrivate::getMessagesCount (bool unreadOnly) { } void ChatRoomPrivate::setState (ChatRoom::State newState) { + L_Q(ChatRoom); if (newState != state) { state = newState; + if (state == ChatRoom::State::Instantiated) + linphone_core_notify_chat_room_instantiated(core, L_GET_C_BACK_PTR(q)); notifyStateChanged(); } }