diff --git a/include/linphone/api/c-callbacks.h b/include/linphone/api/c-callbacks.h index a88a6ed3f..f31219d14 100644 --- a/include/linphone/api/c-callbacks.h +++ b/include/linphone/api/c-callbacks.h @@ -163,6 +163,13 @@ typedef void (*LinphoneChatRoomCbsMessageReceivedCb) (LinphoneChatRoom *cr, Linp */ typedef void (*LinphoneChatRoomCbsChatMessageReceivedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); +/** + * Callback used to notify a chat room that a chat message is being sent. + * @param[in] cr #LinphoneChatRoom object + * @param[in] event_log The #LinphoneChatMessage event log that is being sent + */ +typedef void (*LinphoneChatRoomCbsChatMessageSentCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); + /** * Callback used to notify a chat room that a participant has been added. * @param[in] cr #LinphoneChatRoom object diff --git a/include/linphone/api/c-chat-room-cbs.h b/include/linphone/api/c-chat-room-cbs.h index 746d25444..ae515cc9d 100644 --- a/include/linphone/api/c-chat-room-cbs.h +++ b/include/linphone/api/c-chat-room-cbs.h @@ -103,6 +103,20 @@ LINPHONE_PUBLIC LinphoneChatRoomCbsChatMessageReceivedCb linphone_chat_room_cbs_ */ LINPHONE_PUBLIC void linphone_chat_room_cbs_set_chat_message_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsChatMessageReceivedCb cb); +/** + * Get the chat message sent callback. + * @param[in] cbs LinphoneChatRoomCbs object. + * @return The current chat message sent callback. + */ +LINPHONE_PUBLIC LinphoneChatRoomCbsChatMessageSentCb linphone_chat_room_cbs_get_chat_message_sent (const LinphoneChatRoomCbs *cbs); + +/** + * Set the chat message sent callback. + * @param[in] cbs LinphoneChatRoomCbs object. + * @param[in] cb The chat message sent callback to be used. + */ +LINPHONE_PUBLIC void linphone_chat_room_cbs_set_chat_message_sent (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsChatMessageSentCb cb); + /** * Get the participant added callback. * @param[in] cbs LinphoneChatRoomCbs object. diff --git a/src/c-wrapper/api/c-chat-room-cbs.cpp b/src/c-wrapper/api/c-chat-room-cbs.cpp index e6e38114a..9bcb058d7 100644 --- a/src/c-wrapper/api/c-chat-room-cbs.cpp +++ b/src/c-wrapper/api/c-chat-room-cbs.cpp @@ -37,6 +37,7 @@ struct _LinphoneChatRoomCbs { LinphoneChatRoomCbsSubjectChangedCb subjectChangedCb; LinphoneChatRoomCbsUndecryptableMessageReceivedCb undecryptableMessageReceivedCb; LinphoneChatRoomCbsChatMessageReceivedCb chatMessageReceivedCb; + LinphoneChatRoomCbsChatMessageSentCb chatMessageSentCb; }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoomCbs); @@ -97,6 +98,14 @@ void linphone_chat_room_cbs_set_chat_message_received (LinphoneChatRoomCbs *cbs, cbs->chatMessageReceivedCb = cb; } +LinphoneChatRoomCbsChatMessageSentCb linphone_chat_room_cbs_get_chat_message_sent (const LinphoneChatRoomCbs *cbs) { + return cbs->chatMessageSentCb; +} + +void linphone_chat_room_cbs_set_chat_message_sent (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsChatMessageSentCb cb) { + cbs->chatMessageSentCb = cb; +} + LinphoneChatRoomCbsParticipantAddedCb linphone_chat_room_cbs_get_participant_added (const LinphoneChatRoomCbs *cbs) { return cbs->participantAddedCb; } diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 0386a1016..4553bff2f 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -347,6 +347,8 @@ void ChatRoomPrivate::storeOrUpdateMessage (const shared_ptr &msg) } void ChatRoomPrivate::sendMessage (const shared_ptr &msg) { + L_Q(); + msg->getPrivate()->setDirection(ChatMessage::Direction::Outgoing); /* Add to transient list */ @@ -355,6 +357,14 @@ void ChatRoomPrivate::sendMessage (const shared_ptr &msg) { msg->getPrivate()->setTime(ms_time(0)); msg->getPrivate()->send(); + LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q); + LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); + LinphoneChatRoomCbsParticipantAddedCb cb = linphone_chat_room_cbs_get_chat_message_sent(cbs); + shared_ptr event = make_shared(msg->getTime(), msg); + if (cb) { + cb(cr, L_GET_C_BACK_PTR(event)); + } + storeOrUpdateMessage(msg); if (isComposing)