diff --git a/include/linphone/api/c-chat-room.h b/include/linphone/api/c-chat-room.h index 2175d0f06..529cca44a 100644 --- a/include/linphone/api/c-chat-room.h +++ b/include/linphone/api/c-chat-room.h @@ -299,7 +299,7 @@ LINPHONE_PUBLIC void linphone_chat_room_remove_callbacks(LinphoneChatRoom *cr, L * @return The LinphoneChatRoomCbs that has called the last callback */ LINPHONE_PUBLIC LinphoneChatRoomCbs *linphone_chat_room_get_current_callbacks(const LinphoneChatRoom *cr); - + /** * Get the state of the chat room. * @param[in] cr LinphoneChatRoom object diff --git a/include/linphone/wrapper_utils.h b/include/linphone/wrapper_utils.h index 5ab052604..ee7978269 100644 --- a/include/linphone/wrapper_utils.h +++ b/include/linphone/wrapper_utils.h @@ -56,12 +56,19 @@ LINPHONE_PUBLIC const bctbx_list_t *linphone_call_get_callbacks_list(const Linph /** * @brief Gets the list of listener in the chat room. - * @param[in] call #LinphoneChatRoom object. + * @param[in] cr #LinphoneChatRoom object. * @return The list of #LinphoneChatRoomCbs. * @donotwrap */ LINPHONE_PUBLIC const bctbx_list_t *linphone_chat_room_get_callbacks_list(const LinphoneChatRoom *cr); +/** + * Sets the current LinphoneChatRoomCbs. + * @param[in] cr LinphoneChatRoom object + * @param[in] cbs LinphoneChatRoomCbs object + */ +LINPHONE_PUBLIC void linphone_chat_room_set_current_callbacks(LinphoneChatRoom *cr, LinphoneChatRoomCbs *cbs); + /** * Send a message to peer member of this chat room. * diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index 2f1b935e7..9682489ea 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -419,19 +419,23 @@ LinphoneChatRoomCbs *linphone_chat_room_get_current_callbacks (const LinphoneCha return cr->currentCbs; } +void linphone_chat_room_set_current_callbacks(LinphoneChatRoom *cr, LinphoneChatRoomCbs *cbs) { + cr->currentCbs = cbs; +} + const bctbx_list_t *linphone_chat_room_get_callbacks_list(const LinphoneChatRoom *cr) { return cr->callbacks; } #define NOTIFY_IF_EXIST(cbName, functionName, ...) \ - bctbx_list_t *callbacks_copy = bctbx_list_copy(cr->callbacks); \ - for (bctbx_list_t *it = callbacks_copy; it; it = bctbx_list_next(it)) { \ - cr->currentCbs = reinterpret_cast(bctbx_list_get_data(it)); \ - LinphoneChatRoomCbs ## cbName ## Cb cb = linphone_chat_room_cbs_get_ ## functionName (cr->currentCbs); \ + bctbx_list_t *callbacksCopy = bctbx_list_copy(linphone_chat_room_get_callbacks_list(cr)); \ + for (bctbx_list_t *it = callbacksCopy; it; it = bctbx_list_next(it)) { \ + linphone_chat_room_set_current_callbacks(cr, reinterpret_cast(bctbx_list_get_data(it))); \ + LinphoneChatRoomCbs ## cbName ## Cb cb = linphone_chat_room_cbs_get_ ## functionName (linphone_chat_room_get_current_callbacks(cr)); \ if (cb) \ cb(__VA_ARGS__); \ } \ - bctbx_free(callbacks_copy); + bctbx_free(callbacksCopy); void _linphone_chat_room_notify_is_composing_received(LinphoneChatRoom *cr, const LinphoneAddress *remoteAddr, bool_t isComposing) { NOTIFY_IF_EXIST(IsComposingReceived, is_composing_received, cr, remoteAddr, isComposing)