diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 9b30402546c418707dca4b665615fd02f29e597e..d2feab36e9c1338eeb727f56b8c2598d56664e4d 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 267fc237fcb3c299e21606f265c74f99b8688469..9dd19192460d7325de9d28f9e4a4c792a7f73271 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 4b276d9934fa39eca1da2fcae91a9f8a0cacf872..b17be5a97150ba511e14d173c40daa5e29dbf599 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 ad6f7b0efc8c22118faa50a7327f4110894e3029..3313a7d273316e0d4039c706a0919f2afe630118 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 24d881219f6d9e3da043f3d42ba9f89073a7a986..c04027b25c52dcc6530d560656abb670bae10f3a 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 88db4eb22759b99a723011dd3286506fbe525c7f..abd9eb5380fa8374ef6b7a54e8a255c3659f2392 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()); }