From 181bfa2ec9c36e54d0cfa78f1350e8ae6096abb1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 4 Dec 2017 15:12:25 +0100 Subject: [PATCH] Change the chat room instantiated callback to chat room state changed. --- coreapi/linphonecore.c | 8 ++++---- coreapi/private_functions.h | 2 +- coreapi/vtables.c | 4 ++-- include/linphone/callbacks.h | 6 +++--- include/linphone/core.h | 10 +++++----- src/chat/chat-room/chat-room.cpp | 5 +---- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 93b6adcc7..f4cc4c85a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -434,12 +434,12 @@ void linphone_core_cbs_set_version_update_check_result_received(LinphoneCoreCbs cbs->vtable->version_update_check_result_received = cb; } -LinphoneCoreCbsChatRoomInstantiatedCb linphone_core_cbs_get_chat_room_instantiated (LinphoneCoreCbs *cbs) { - return cbs->vtable->chat_room_instantiated; +LinphoneCoreCbsChatRoomStateChangedCb linphone_core_cbs_get_chat_room_state_changed (LinphoneCoreCbs *cbs) { + return cbs->vtable->chat_room_state_changed; } -void linphone_core_cbs_set_chat_room_instantiated (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomInstantiatedCb cb) { - cbs->vtable->chat_room_instantiated = cb; +void linphone_core_cbs_set_chat_room_state_changed (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomStateChangedCb cb) { + cbs->vtable->chat_room_state_changed = cb; } void linphone_core_cbs_set_ec_calibration_result(LinphoneCoreCbs *cbs, LinphoneCoreCbsEcCalibrationResultCb cb) { diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 71a2b38db..fcc3c6911 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -536,7 +536,7 @@ void linphone_core_notify_friend_list_created(LinphoneCore *lc, LinphoneFriendLi void linphone_core_notify_friend_list_removed(LinphoneCore *lc, LinphoneFriendList *list); void linphone_core_notify_call_created(LinphoneCore *lc, LinphoneCall *call); void linphone_core_notify_version_update_check_result_received(LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url); -void linphone_core_notify_chat_room_instantiated (LinphoneCore *lc, LinphoneChatRoom *cr); +void linphone_core_notify_chat_room_state_changed (LinphoneCore *lc, LinphoneChatRoom *cr, LinphoneChatRoomState state); void linphone_core_notify_ec_calibration_result(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms); void linphone_core_notify_ec_calibration_audio_init(LinphoneCore *lc); diff --git a/coreapi/vtables.c b/coreapi/vtables.c index 33eab6ccb..aef7785d9 100644 --- a/coreapi/vtables.c +++ b/coreapi/vtables.c @@ -288,8 +288,8 @@ void linphone_core_notify_version_update_check_result_received(LinphoneCore *lc, cleanup_dead_vtable_refs(lc); } -void linphone_core_notify_chat_room_instantiated (LinphoneCore *lc, LinphoneChatRoom *cr) { - NOTIFY_IF_EXIST(chat_room_instantiated, lc, cr); +void linphone_core_notify_chat_room_state_changed (LinphoneCore *lc, LinphoneChatRoom *cr, LinphoneChatRoomState state) { + NOTIFY_IF_EXIST(chat_room_state_changed, lc, cr, state); cleanup_dead_vtable_refs(lc); } diff --git a/include/linphone/callbacks.h b/include/linphone/callbacks.h index b70febf8b..7da93b9f7 100644 --- a/include/linphone/callbacks.h +++ b/include/linphone/callbacks.h @@ -399,11 +399,11 @@ typedef LinphoneCoreCbsFriendListRemovedCb LinphoneCoreFriendListRemovedCb; typedef void (*LinphoneCoreCbsVersionUpdateCheckResultReceivedCb) (LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url); /** - * Callback prototype telling that a LinphoneChatRoom object has been instantiated. This is useful to set the callbacks on the LinphoneChatRoom object. + * Callback prototype telling that a LinphoneChatRoom state has changed. * @param[in] lc LinphoneCore object - * @param[in] cr The LinphoneChatRoom object that has been instantiated + * @param[in] cr The LinphoneChatRoom object for which the state has changed */ -typedef void (*LinphoneCoreCbsChatRoomInstantiatedCb) (LinphoneCore *lc, LinphoneChatRoom *cr); +typedef void (*LinphoneCoreCbsChatRoomStateChangedCb) (LinphoneCore *lc, LinphoneChatRoom *cr, LinphoneChatRoomState state); /** * @} diff --git a/include/linphone/core.h b/include/linphone/core.h index ded1e3156..e6382eb8b 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -185,7 +185,7 @@ typedef struct _LinphoneCoreVTable{ LinphoneCoreFriendListRemovedCb friend_list_removed; LinphoneCoreCbsCallCreatedCb call_created; LinphoneCoreCbsVersionUpdateCheckResultReceivedCb version_update_check_result_received; - LinphoneCoreCbsChatRoomInstantiatedCb chat_room_instantiated; + LinphoneCoreCbsChatRoomStateChangedCb chat_room_state_changed; LinphoneCoreCbsEcCalibrationResultCb ec_calibration_result; LinphoneCoreCbsEcCalibrationAudioInitCb ec_calibration_audio_init; LinphoneCoreCbsEcCalibrationAudioUninitCb ec_calibration_audio_uninit; @@ -666,18 +666,18 @@ LINPHONE_PUBLIC void linphone_core_cbs_set_version_update_check_result_received( LINPHONE_PUBLIC LinphoneCoreCbsVersionUpdateCheckResultReceivedCb linphone_core_cbs_get_version_update_check_result_received(LinphoneCoreCbs *cbs); /** - * Get the chat room instantiated callback. + * Get the chat room state changed callback. * @param[in] cbs LinphoneCoreCbs object * @return The current callback */ -LINPHONE_PUBLIC LinphoneCoreCbsChatRoomInstantiatedCb linphone_core_cbs_get_chat_room_instantiated (LinphoneCoreCbs *cbs); +LINPHONE_PUBLIC LinphoneCoreCbsChatRoomStateChangedCb linphone_core_cbs_get_chat_room_state_changed (LinphoneCoreCbs *cbs); /** - * Set the chat room instantiated callback. + * Set the chat room state changed callback. * @param[in] cbs LinphoneCoreCbs object * @param[in] cb The callback to use */ -LINPHONE_PUBLIC void linphone_core_cbs_set_chat_room_instantiated (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomInstantiatedCb cb); +LINPHONE_PUBLIC void linphone_core_cbs_set_chat_room_state_changed (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomStateChangedCb cb); /** * @brief Sets a callback to call each time the echo-canceler calibration is completed. diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 35a8f31cc..98a0959cb 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -57,12 +57,8 @@ void ChatRoomPrivate::release () { // ----------------------------------------------------------------------------- void ChatRoomPrivate::setState (ChatRoom::State newState) { - L_Q(); if (newState != state) { state = newState; - if (state == ChatRoom::State::Created) - // TODO : Rename from instatiated to created. - linphone_core_notify_chat_room_instantiated(q->getCore()->getCCore(), L_GET_C_BACK_PTR(q)); notifyStateChanged(); } } @@ -272,6 +268,7 @@ void ChatRoomPrivate::notifyIsComposingReceived (const Address &remoteAddr, bool void ChatRoomPrivate::notifyStateChanged () { L_Q(); + linphone_core_notify_chat_room_state_changed(q->getCore()->getCCore(), L_GET_C_BACK_PTR(q), (LinphoneChatRoomState)state); LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); LinphoneChatRoomCbsStateChangedCb cb = linphone_chat_room_cbs_get_state_changed(cbs);