From 6f18bd48985cc321c278560679e8187eb1daae28 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini <sylvain.berfini@belledonne-communications.com> Date: Thu, 12 Oct 2023 14:36:55 +0200 Subject: [PATCH] Added missing marked as read callback in ChatRoomListener --- coreapi/private_functions.h | 1 + include/linphone/api/c-callbacks.h | 6 ++++++ include/linphone/api/c-chat-room-cbs.h | 16 ++++++++++++++++ src/c-wrapper/api/c-chat-room-cbs.cpp | 9 +++++++++ src/c-wrapper/api/c-chat-room.cpp | 4 ++++ src/chat/chat-room/chat-room.cpp | 1 + 6 files changed, 37 insertions(+) diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 9b30402546..d2feab36e9 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -530,6 +530,7 @@ void _linphone_chat_room_notify_chat_message_should_be_stored(LinphoneChatRoom * void _linphone_chat_room_notify_chat_message_participant_imdn_state_changed(LinphoneChatRoom *cr, LinphoneChatMessage *msg, const LinphoneParticipantImdnState *state); +void _linphone_chat_room_notify_chat_room_read(LinphoneChatRoom *cr); void _linphone_chat_room_clear_callbacks(LinphoneChatRoom *cr); void _linphone_chat_message_notify_msg_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageState state); diff --git a/include/linphone/api/c-callbacks.h b/include/linphone/api/c-callbacks.h index 267fc237fc..9dd1919246 100644 --- a/include/linphone/api/c-callbacks.h +++ b/include/linphone/api/c-callbacks.h @@ -545,6 +545,12 @@ typedef void (*LinphoneChatRoomCbsChatMessageParticipantImdnStateChangedCb)(Linp LinphoneChatMessage *message, const LinphoneParticipantImdnState *state); +/** + * Callback used to notify a chat room was "marked as read". + * @param chat_room The #LinphoneChatRoom object that was marked as read @notnil + */ +typedef void (*LinphoneChatRoomCbsChatRoomReadCb)(LinphoneChatRoom *chat_room); + /** * @} **/ diff --git a/include/linphone/api/c-chat-room-cbs.h b/include/linphone/api/c-chat-room-cbs.h index 4b276d9934..b17be5a971 100644 --- a/include/linphone/api/c-chat-room-cbs.h +++ b/include/linphone/api/c-chat-room-cbs.h @@ -563,6 +563,22 @@ linphone_chat_room_cbs_get_chat_message_participant_imdn_state_changed(LinphoneC LINPHONE_PUBLIC void linphone_chat_room_cbs_set_chat_message_participant_imdn_state_changed( LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsChatMessageParticipantImdnStateChangedCb cb); +/** + * Get the "marked as read" callback. + * @param cbs #LinphoneChatRoomCbs object. @notnil + * @return The marked as read callback. + */ +LINPHONE_PUBLIC LinphoneChatRoomCbsChatRoomReadCb +linphone_chat_room_cbs_get_chat_room_read(const LinphoneChatRoomCbs *cbs); + +/** + * Set the "marked as read" callback. + * @param cbs #LinphoneChatRoomCbs object. @notnil + * @param cb The marked as read callback to be used. + */ +LINPHONE_PUBLIC void linphone_chat_room_cbs_set_chat_room_read(LinphoneChatRoomCbs *cbs, + LinphoneChatRoomCbsChatRoomReadCb cb); + /** * @} */ diff --git a/src/c-wrapper/api/c-chat-room-cbs.cpp b/src/c-wrapper/api/c-chat-room-cbs.cpp index ad6f7b0efc..3313a7d273 100644 --- a/src/c-wrapper/api/c-chat-room-cbs.cpp +++ b/src/c-wrapper/api/c-chat-room-cbs.cpp @@ -59,6 +59,7 @@ struct _LinphoneChatRoomCbs { LinphoneChatRoomCbsChatMessageParticipantImdnStateChangedCb chatMessageParticipantImdnStateChangedCb; LinphoneChatRoomCbsNewEventCb newEventCb; LinphoneChatRoomCbsNewEventsCb newEventsCb; + LinphoneChatRoomCbsChatRoomReadCb chatRoomReadCb; }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoomCbs); @@ -379,3 +380,11 @@ void linphone_chat_room_cbs_set_chat_message_participant_imdn_state_changed( LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsChatMessageParticipantImdnStateChangedCb cb) { cbs->chatMessageParticipantImdnStateChangedCb = cb; } + +LinphoneChatRoomCbsChatRoomReadCb linphone_chat_room_cbs_get_chat_room_read(const LinphoneChatRoomCbs *cbs) { + return cbs->chatRoomReadCb; +} + +void linphone_chat_room_cbs_set_chat_room_read(LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsChatRoomReadCb cb) { + cbs->chatRoomReadCb = cb; +} \ No newline at end of file diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index 24d881219f..c04027b25c 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -782,6 +782,10 @@ void _linphone_chat_room_notify_chat_message_participant_imdn_state_changed(Linp state); } +void _linphone_chat_room_notify_chat_room_read(LinphoneChatRoom *cr) { + NOTIFY_IF_EXIST(ChatRoomRead, chat_room_read, cr); +} + // ============================================================================= // Reference and user data handling functions. // ============================================================================= diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 88db4eb227..abd9eb5380 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -789,6 +789,7 @@ void ChatRoom::markAsRead() { } dCore->mainDb->markChatMessagesAsRead(getConferenceId()); + _linphone_chat_room_notify_chat_room_read(d->getCChatRoom()); linphone_core_notify_chat_room_read(getCore()->getCCore(), d->getCChatRoom()); } -- GitLab