diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 8f78e107d..031e00eef 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -29,6 +29,7 @@ #include "private_types.h" #include "tester_utils.h" +#include "conference/participant-imdn-state.h" #include "sal/op.h" #include "sal/event-op.h" @@ -298,6 +299,7 @@ void _linphone_chat_room_notify_participant_registration_subscription_requested( void _linphone_chat_room_notify_participant_registration_unsubscription_requested(LinphoneChatRoom *cr, const LinphoneAddress *participantAddr); void _linphone_chat_room_notify_chat_message_should_be_stored(LinphoneChatRoom *cr, LinphoneChatMessage *msg); void _linphone_chat_room_clear_callbacks (LinphoneChatRoom *cr); +const LinphoneParticipantImdnState *_linphone_participant_imdn_state_from_cpp_obj (const LinphonePrivate::ParticipantImdnState &state); LinphoneToneDescription * linphone_tone_description_new(LinphoneReason reason, LinphoneToneID id, const char *audiofile); void linphone_tone_description_destroy(LinphoneToneDescription *obj); diff --git a/include/linphone/api/c-callbacks.h b/include/linphone/api/c-callbacks.h index 634e6a830..6a707e7b1 100644 --- a/include/linphone/api/c-callbacks.h +++ b/include/linphone/api/c-callbacks.h @@ -122,6 +122,13 @@ typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg, Linp */ typedef void (*LinphoneChatMessageCbsMsgStateChangedCb)(LinphoneChatMessage* msg, LinphoneChatMessageState state); +/** + * Call back used to notify participant IMDN state + * @param msg #LinphoneChatMessage object + * @param state #LinphoneParticipantImdnState + */ +typedef void (*LinphoneChatMessageCbsParticipantImdnStateChangedCb)(LinphoneChatMessage* msg, const LinphoneParticipantImdnState *state); + /** * File transfer receive callback prototype. This function is called by the core upon an incoming File transfer is started. This function may be call several time for the same file in case of large file. * @param message #LinphoneChatMessage message from which the body is received. diff --git a/include/linphone/api/c-chat-message-cbs.h b/include/linphone/api/c-chat-message-cbs.h index 632353f87..35dc2ff19 100644 --- a/include/linphone/api/c-chat-message-cbs.h +++ b/include/linphone/api/c-chat-message-cbs.h @@ -34,7 +34,7 @@ * @{ */ -LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void); +LinphoneChatMessageCbs *linphone_chat_message_cbs_new (void); /** * Acquire a reference to the chat room callbacks object. @@ -68,56 +68,70 @@ LINPHONE_PUBLIC void linphone_chat_message_cbs_set_user_data (LinphoneChatMessag * @param[in] cbs #LinphoneChatMessageCbs object. * @return The current message state changed callback. */ - LINPHONE_PUBLIC LinphoneChatMessageCbsMsgStateChangedCb linphone_chat_message_cbs_get_msg_state_changed(const LinphoneChatMessageCbs *cbs); +LINPHONE_PUBLIC LinphoneChatMessageCbsMsgStateChangedCb linphone_chat_message_cbs_get_msg_state_changed (const LinphoneChatMessageCbs *cbs); - /** - * Set the message state changed callback. - * @param[in] cbs LinphoneChatMessageCbs object. - * @param[in] cb The message state changed callback to be used. - */ - LINPHONE_PUBLIC void linphone_chat_message_cbs_set_msg_state_changed(LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsMsgStateChangedCb cb); +/** + * Set the message state changed callback. + * @param[in] cbs LinphoneChatMessageCbs object. + * @param[in] cb The message state changed callback to be used. + */ +LINPHONE_PUBLIC void linphone_chat_message_cbs_set_msg_state_changed (LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsMsgStateChangedCb cb); - /** - * Get the file transfer receive callback. - * @param[in] cbs LinphoneChatMessageCbs object. - * @return The current file transfer receive callback. - */ - LINPHONE_PUBLIC LinphoneChatMessageCbsFileTransferRecvCb linphone_chat_message_cbs_get_file_transfer_recv(const LinphoneChatMessageCbs *cbs); +/** + * Get the file transfer receive callback. + * @param[in] cbs LinphoneChatMessageCbs object. + * @return The current file transfer receive callback. + */ +LINPHONE_PUBLIC LinphoneChatMessageCbsFileTransferRecvCb linphone_chat_message_cbs_get_file_transfer_recv (const LinphoneChatMessageCbs *cbs); - /** - * Set the file transfer receive callback. - * @param[in] cbs LinphoneChatMessageCbs object. - * @param[in] cb The file transfer receive callback to be used. - */ - LINPHONE_PUBLIC void linphone_chat_message_cbs_set_file_transfer_recv(LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsFileTransferRecvCb cb); +/** + * Set the file transfer receive callback. + * @param[in] cbs LinphoneChatMessageCbs object. + * @param[in] cb The file transfer receive callback to be used. + */ +LINPHONE_PUBLIC void linphone_chat_message_cbs_set_file_transfer_recv (LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsFileTransferRecvCb cb); - /** +/** * Get the file transfer send callback. * @param[in] cbs LinphoneChatMessageCbs object. * @return The current file transfer send callback. */ - LINPHONE_PUBLIC LinphoneChatMessageCbsFileTransferSendCb linphone_chat_message_cbs_get_file_transfer_send(const LinphoneChatMessageCbs *cbs); +LINPHONE_PUBLIC LinphoneChatMessageCbsFileTransferSendCb linphone_chat_message_cbs_get_file_transfer_send (const LinphoneChatMessageCbs *cbs); - /** - * Set the file transfer send callback. - * @param[in] cbs LinphoneChatMessageCbs object. - * @param[in] cb The file transfer send callback to be used. - */ - LINPHONE_PUBLIC void linphone_chat_message_cbs_set_file_transfer_send(LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsFileTransferSendCb cb); +/** + * Set the file transfer send callback. + * @param[in] cbs LinphoneChatMessageCbs object. + * @param[in] cb The file transfer send callback to be used. + */ +LINPHONE_PUBLIC void linphone_chat_message_cbs_set_file_transfer_send (LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsFileTransferSendCb cb); - /** - * Get the file transfer progress indication callback. - * @param[in] cbs LinphoneChatMessageCbs object. - * @return The current file transfer progress indication callback. - */ - LINPHONE_PUBLIC LinphoneChatMessageCbsFileTransferProgressIndicationCb linphone_chat_message_cbs_get_file_transfer_progress_indication(const LinphoneChatMessageCbs *cbs); +/** + * Get the file transfer progress indication callback. + * @param[in] cbs LinphoneChatMessageCbs object. + * @return The current file transfer progress indication callback. + */ +LINPHONE_PUBLIC LinphoneChatMessageCbsFileTransferProgressIndicationCb linphone_chat_message_cbs_get_file_transfer_progress_indication (const LinphoneChatMessageCbs *cbs); - /** - * Set the file transfer progress indication callback. - * @param[in] cbs LinphoneChatMessageCbs object. - * @param[in] cb The file transfer progress indication callback to be used. - */ - LINPHONE_PUBLIC void linphone_chat_message_cbs_set_file_transfer_progress_indication(LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsFileTransferProgressIndicationCb cb); +/** + * Set the file transfer progress indication callback. + * @param[in] cbs LinphoneChatMessageCbs object. + * @param[in] cb The file transfer progress indication callback to be used. + */ +LINPHONE_PUBLIC void linphone_chat_message_cbs_set_file_transfer_progress_indication (LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsFileTransferProgressIndicationCb cb); + +/** + * Get the participant IMDN state changed callback. + * @param[in] cbs #LinphoneChatMessageCbs object. + * @return The current participant IMDN state changed callback. + */ +LINPHONE_PUBLIC LinphoneChatMessageCbsParticipantImdnStateChangedCb linphone_chat_message_cbs_get_participant_imdn_state_changed (const LinphoneChatMessageCbs *cbs); + +/** + * Set the participant IMDN state changed callback. + * @param[in] cbs LinphoneChatMessageCbs object. + * @param[in] cb The participant IMDN state changed callback to be used. + */ +LINPHONE_PUBLIC void linphone_chat_message_cbs_set_participant_imdn_state_changed (LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsParticipantImdnStateChangedCb cb); /** * @} diff --git a/src/c-wrapper/api/c-chat-message-cbs.cpp b/src/c-wrapper/api/c-chat-message-cbs.cpp index 16511eff6..aced7c8bb 100644 --- a/src/c-wrapper/api/c-chat-message-cbs.cpp +++ b/src/c-wrapper/api/c-chat-message-cbs.cpp @@ -30,6 +30,7 @@ struct _LinphoneChatMessageCbs { LinphoneChatMessageCbsFileTransferRecvCb file_transfer_recv; LinphoneChatMessageCbsFileTransferSendCb file_transfer_send; LinphoneChatMessageCbsFileTransferProgressIndicationCb file_transfer_progress_indication; + LinphoneChatMessageCbsParticipantImdnStateChangedCb participant_imdn_state_changed; }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessageCbs); @@ -66,40 +67,67 @@ void linphone_chat_message_cbs_set_user_data (LinphoneChatMessageCbs *cbs, void cbs->userData = ud; } -LinphoneChatMessageCbsMsgStateChangedCb -linphone_chat_message_cbs_get_msg_state_changed(const LinphoneChatMessageCbs *cbs) { +LinphoneChatMessageCbsMsgStateChangedCb linphone_chat_message_cbs_get_msg_state_changed ( + const LinphoneChatMessageCbs *cbs +) { return cbs->msg_state_changed; } -void linphone_chat_message_cbs_set_msg_state_changed(LinphoneChatMessageCbs *cbs, - LinphoneChatMessageCbsMsgStateChangedCb cb) { +void linphone_chat_message_cbs_set_msg_state_changed ( + LinphoneChatMessageCbs *cbs, + LinphoneChatMessageCbsMsgStateChangedCb cb +) { cbs->msg_state_changed = cb; } -LinphoneChatMessageCbsFileTransferRecvCb linphone_chat_message_cbs_get_file_transfer_recv(const LinphoneChatMessageCbs *cbs) { +LinphoneChatMessageCbsFileTransferRecvCb linphone_chat_message_cbs_get_file_transfer_recv ( + const LinphoneChatMessageCbs *cbs +) { return cbs->file_transfer_recv; } -void linphone_chat_message_cbs_set_file_transfer_recv(LinphoneChatMessageCbs *cbs, - LinphoneChatMessageCbsFileTransferRecvCb cb) { +void linphone_chat_message_cbs_set_file_transfer_recv ( + LinphoneChatMessageCbs *cbs, + LinphoneChatMessageCbsFileTransferRecvCb cb +) { cbs->file_transfer_recv = cb; } -LinphoneChatMessageCbsFileTransferSendCb linphone_chat_message_cbs_get_file_transfer_send(const LinphoneChatMessageCbs *cbs) { +LinphoneChatMessageCbsFileTransferSendCb linphone_chat_message_cbs_get_file_transfer_send ( + const LinphoneChatMessageCbs *cbs +) { return cbs->file_transfer_send; } -void linphone_chat_message_cbs_set_file_transfer_send(LinphoneChatMessageCbs *cbs, - LinphoneChatMessageCbsFileTransferSendCb cb) { +void linphone_chat_message_cbs_set_file_transfer_send ( + LinphoneChatMessageCbs *cbs, + LinphoneChatMessageCbsFileTransferSendCb cb +) { cbs->file_transfer_send = cb; } -LinphoneChatMessageCbsFileTransferProgressIndicationCb -linphone_chat_message_cbs_get_file_transfer_progress_indication(const LinphoneChatMessageCbs *cbs) { +LinphoneChatMessageCbsFileTransferProgressIndicationCb linphone_chat_message_cbs_get_file_transfer_progress_indication ( + const LinphoneChatMessageCbs *cbs +) { return cbs->file_transfer_progress_indication; } -void linphone_chat_message_cbs_set_file_transfer_progress_indication( - LinphoneChatMessageCbs *cbs, LinphoneChatMessageCbsFileTransferProgressIndicationCb cb) { +void linphone_chat_message_cbs_set_file_transfer_progress_indication ( + LinphoneChatMessageCbs *cbs, + LinphoneChatMessageCbsFileTransferProgressIndicationCb cb +) { cbs->file_transfer_progress_indication = cb; } + +LinphoneChatMessageCbsParticipantImdnStateChangedCb linphone_chat_message_cbs_get_participant_imdn_state_changed ( + const LinphoneChatMessageCbs *cbs +) { + return cbs->participant_imdn_state_changed; +} + +void linphone_chat_message_cbs_set_participant_imdn_state_changed ( + LinphoneChatMessageCbs *cbs, + LinphoneChatMessageCbsParticipantImdnStateChangedCb cb +) { + cbs->participant_imdn_state_changed = cb; +} diff --git a/src/c-wrapper/api/c-participant-imdn-state.cpp b/src/c-wrapper/api/c-participant-imdn-state.cpp index 2f3a906d2..85dc5e74a 100644 --- a/src/c-wrapper/api/c-participant-imdn-state.cpp +++ b/src/c-wrapper/api/c-participant-imdn-state.cpp @@ -57,3 +57,7 @@ LinphoneChatMessageState linphone_participant_imdn_state_get_state (const Linpho time_t linphone_participant_imdn_state_get_state_change_time (const LinphoneParticipantImdnState *state) { return L_GET_CPP_PTR_FROM_C_OBJECT(state)->getStateChangeTime(); } + +const LinphoneParticipantImdnState *_linphone_participant_imdn_state_from_cpp_obj (const LinphonePrivate::ParticipantImdnState &state) { + return L_GET_C_BACK_PTR(&state); +} \ No newline at end of file diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index bd3c20c8b..8c21e25c7 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -106,6 +106,16 @@ void ChatMessagePrivate::setParticipantState (const IdentityAddress &participant << Utils::toString(newState); mainDb->setChatMessageParticipantState(eventLog, participantAddress, newState, stateChangeTime); + LinphoneChatMessage *msg = L_GET_C_BACK_PTR(q); + LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg); + if (cbs && linphone_chat_message_cbs_get_participant_imdn_state_changed(cbs)) { + auto participant = q->getChatRoom()->findParticipant(participantAddress); + ParticipantImdnState imdnState(participant, newState, stateChangeTime); + linphone_chat_message_cbs_get_participant_imdn_state_changed(cbs)(msg, + _linphone_participant_imdn_state_from_cpp_obj(imdnState) + ); + } + if (linphone_config_get_bool(linphone_core_get_config(q->getChatRoom()->getCore()->getCCore()), "misc", "enable_simple_group_chat_message_state", FALSE )