diff --git a/coreapi/chat.c b/coreapi/chat.c index a62bdd03b..ba45d60b2 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -41,7 +41,7 @@ #include "chat/chat-room/real-time-text-chat-room-p.h" #include "chat/chat-room/real-time-text-chat-room.h" #include "content/content-type.h" -#include "core/core.h" +#include "core/core-p.h" using namespace std; @@ -82,14 +82,13 @@ LinphoneChatRoom *linphone_core_create_client_group_chat_room (LinphoneCore *lc, LinphoneChatRoom *_linphone_core_join_client_group_chat_room (LinphoneCore *lc, const LinphonePrivate::Address &addr) { LinphoneChatRoom *cr = _linphone_client_group_chat_room_new(lc, addr.asString().c_str(), nullptr); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->join(); - lc->chatrooms = bctbx_list_append(lc->chatrooms, cr); + L_GET_PRIVATE(lc->cppCore)->insertChatRoomWithDb(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); return cr; } LinphoneChatRoom *_linphone_core_create_server_group_chat_room (LinphoneCore *lc, LinphonePrivate::SalCallOp *op) { LinphoneChatRoom *cr = _linphone_server_group_chat_room_new(lc, op); - _linphone_core_add_group_chat_room(lc, L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getConferenceAddress(), cr); - lc->chatrooms = bctbx_list_append(lc->chatrooms, cr); + L_GET_PRIVATE(lc->cppCore)->insertChatRoomWithDb(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); return cr; } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 7fa996cd2..4b5611301 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2140,11 +2140,12 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve } static void _linphone_core_conference_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) { - if ((linphone_event_get_subscription_dir(lev) == LinphoneSubscriptionIncoming) && (state == LinphoneSubscriptionIncomingReceived)) { + if ( + linphone_event_get_subscription_dir(lev) == LinphoneSubscriptionIncoming && + state == LinphoneSubscriptionIncomingReceived + ) { const LinphoneAddress *resource = linphone_event_get_resource(lev); - char *resourceUri = linphone_address_as_string_uri_only(resource); - LinphoneChatRoom *cr = _linphone_core_find_group_chat_room(lc, resourceUri); - bctbx_free(resourceUri); + LinphoneChatRoom *cr = L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(resource))); if (cr) { linphone_event_accept_subscription(lev); L_GET_PRIVATE_FROM_C_OBJECT(cr, ServerGroupChatRoom)->subscribeReceived(lev); @@ -7165,39 +7166,6 @@ const char * linphone_core_get_conference_factory_uri(const LinphoneCore *lc) { return lp_config_get_string(linphone_core_get_config(lc), "misc", "conference_factory_uri", "sip:"); } -bool_t _linphone_core_has_group_chat_room(const LinphoneCore *lc, const char *id) { - bool_t result; - bctbx_iterator_t *it = bctbx_map_cchar_find_key(lc->group_chat_rooms, id); - bctbx_iterator_t *endit = bctbx_map_cchar_end(lc->group_chat_rooms); - result = !bctbx_iterator_cchar_equals(it, endit); - bctbx_iterator_cchar_delete(endit); - bctbx_iterator_cchar_delete(it); - return result; -} - -void _linphone_core_add_group_chat_room(LinphoneCore *lc, const LinphonePrivate::Address &addr, LinphoneChatRoom *cr) { - Address cleanedAddr(addr); - cleanedAddr.clean(); - cleanedAddr.setPort(0); - bctbx_pair_t *pair = reinterpret_cast(bctbx_pair_cchar_new(cleanedAddr.asStringUriOnly().c_str(), linphone_chat_room_ref(cr))); - bctbx_map_cchar_insert_and_delete(lc->group_chat_rooms, pair); -} - -void _linphone_core_remove_group_chat_room(LinphoneCore *lc, LinphoneChatRoom *cr) { - const LinphoneAddress *confAddr = linphone_chat_room_get_conference_address(cr); - Address cleanedAddr(*L_GET_CPP_PTR_FROM_C_OBJECT(confAddr)); - cleanedAddr.clean(); - cleanedAddr.setPort(0); - bctbx_iterator_t *it = bctbx_map_cchar_find_key(lc->group_chat_rooms, cleanedAddr.asStringUriOnly().c_str()); - bctbx_iterator_t *endit = bctbx_map_cchar_end(lc->group_chat_rooms); - if (!bctbx_iterator_cchar_equals(it, endit)) { - bctbx_map_cchar_erase(lc->group_chat_rooms, it); - linphone_chat_room_unref(cr); - } - bctbx_iterator_cchar_delete(endit); - bctbx_iterator_cchar_delete(it); -} - void linphone_core_enable_conference_server (LinphoneCore *lc, bool_t enable) { lp_config_set_int(linphone_core_get_config(lc), "misc", "conference_server_enabled", enable); } diff --git a/coreapi/private.h b/coreapi/private.h index 7186c546d..b28e80d05 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -457,9 +457,6 @@ bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription extern LinphonePrivate::Sal::Callbacks linphone_sal_callbacks; LINPHONE_PUBLIC bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc); LINPHONE_PUBLIC bool_t linphone_core_symmetric_rtp_enabled(LinphoneCore*lc); -bool_t _linphone_core_has_group_chat_room (const LinphoneCore *lc, const char *id); -void _linphone_core_add_group_chat_room (LinphoneCore *lc, const LinphonePrivate::Address &addr, LinphoneChatRoom *cr); -void _linphone_core_remove_group_chat_room(LinphoneCore *lc, LinphoneChatRoom *cr); bool_t _linphone_core_is_conference_creation (const LinphoneCore *lc, const LinphoneAddress *addr); LinphoneChatRoom *_linphone_core_create_server_group_chat_room (LinphoneCore *lc, LinphonePrivate::SalCallOp *op);