Commit 63759557 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Added callback on message being sent

parent edf85afa
......@@ -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
......
......@@ -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.
......
......@@ -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;
}
......
......@@ -347,6 +347,8 @@ void ChatRoomPrivate::storeOrUpdateMessage (const shared_ptr<ChatMessage> &msg)
}
void ChatRoomPrivate::sendMessage (const shared_ptr<ChatMessage> &msg) {
L_Q();
msg->getPrivate()->setDirection(ChatMessage::Direction::Outgoing);
/* Add to transient list */
......@@ -355,6 +357,14 @@ void ChatRoomPrivate::sendMessage (const shared_ptr<ChatMessage> &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<ConferenceChatMessageEvent> event = make_shared<ConferenceChatMessageEvent>(msg->getTime(), msg);
if (cb) {
cb(cr, L_GET_C_BACK_PTR(event));
}
storeOrUpdateMessage(msg);
if (isComposing)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment