Commit 519079f4 authored by Matthieu Tanon's avatar Matthieu Tanon
Browse files

Add chatroom security event callbacks and use it in multidevice test

parent 8780df8b
......@@ -311,6 +311,7 @@ void _linphone_chat_room_notify_participant_device_added(LinphoneChatRoom *cr, c
void _linphone_chat_room_notify_participant_device_removed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
void _linphone_chat_room_notify_participant_admin_status_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
void _linphone_chat_room_notify_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState);
void _linphone_chat_room_notify_security_alert(LinphoneChatRoom *cr, LinphoneEventLog *event_log);
void _linphone_chat_room_notify_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
void _linphone_chat_room_notify_conference_joined(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
void _linphone_chat_room_notify_conference_left(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
......
......@@ -227,6 +227,13 @@ typedef void (*LinphoneChatRoomCbsParticipantAdminStatusChangedCb) (LinphoneChat
*/
typedef void (*LinphoneChatRoomCbsStateChangedCb) (LinphoneChatRoom *cr, LinphoneChatRoomState newState);
/**
* Callback used to notify a security alert in the chat room.
* @param[in] cr #LinphoneChatRoom object
* @param[in] securityAlert the security alert
*/
typedef void (*LinphoneChatRoomCbsSecurityAlertCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify that the subject of a chat room has changed.
* @param[in] cr #LinphoneChatRoom object
......
......@@ -173,6 +173,20 @@ LINPHONE_PUBLIC LinphoneChatRoomCbsStateChangedCb linphone_chat_room_cbs_get_sta
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_state_changed (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsStateChangedCb cb);
/**
* Get the security alert callback.
* @param[in] cbs #LinphoneChatRoomCbs object.
* @return The security alert callback to be used.
*/
LINPHONE_PUBLIC LinphoneChatRoomCbsSecurityAlertCb linphone_chat_room_cbs_get_security_alert (const LinphoneChatRoomCbs *cbs);
/**
* Set the security alert callback.
* @param[in] cbs #LinphoneChatRoomCbs object.
* @param[in] cb The current security alert callback to be used.
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_security_alert (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsSecurityAlertCb cb);
/**
* Get the subject changed callback.
* @param[in] cbs #LinphoneChatRoomCbs object.
......
......@@ -34,6 +34,7 @@ struct _LinphoneChatRoomCbs {
LinphoneChatRoomCbsParticipantDeviceRemovedCb participantDeviceRemovedCb;
LinphoneChatRoomCbsParticipantAdminStatusChangedCb participantAdminStatusChangedCb;
LinphoneChatRoomCbsStateChangedCb stateChangedCb;
LinphoneChatRoomCbsSecurityAlertCb securityAlertCb;
LinphoneChatRoomCbsSubjectChangedCb subjectChangedCb;
LinphoneChatRoomCbsConferenceJoinedCb conferenceJoinedCb;
LinphoneChatRoomCbsConferenceLeftCb conferenceLeftCb;
......@@ -146,6 +147,14 @@ void linphone_chat_room_cbs_set_state_changed (LinphoneChatRoomCbs *cbs, Linphon
cbs->stateChangedCb = cb;
}
LinphoneChatRoomCbsSecurityAlertCb linphone_chat_room_cbs_get_security_alert (const LinphoneChatRoomCbs *cbs) {
return cbs->securityAlertCb;
}
void linphone_chat_room_cbs_set_security_alert (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsSecurityAlertCb cb) {
cbs->securityAlertCb = cb;
}
LinphoneChatRoomCbsSubjectChangedCb linphone_chat_room_cbs_get_subject_changed (const LinphoneChatRoomCbs *cbs) {
return cbs->subjectChangedCb;
}
......
......@@ -487,6 +487,10 @@ void _linphone_chat_room_notify_state_changed(LinphoneChatRoom *cr, LinphoneChat
NOTIFY_IF_EXIST(StateChanged, state_changed, cr, newState)
}
void _linphone_chat_room_notify_security_alert(LinphoneChatRoom *cr, LinphoneEventLog *event_log) {
NOTIFY_IF_EXIST(SecurityAlert, security_alert, cr, event_log)
}
void _linphone_chat_room_notify_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
NOTIFY_IF_EXIST(SubjectChanged, subject_changed, cr, event_log)
}
......
......@@ -720,6 +720,10 @@ void ClientGroupChatRoom::onSecurityAlert (const shared_ptr<ConferenceSecurityEv
cout << "onSecurityAlert() securityAlert = " << event->getSecurityAlert() << endl;
d->addEvent(event);
// TODO notify the application for UI alert
LinphoneChatRoom *cr = d->getCChatRoom();
_linphone_chat_room_notify_security_alert(cr, L_GET_C_BACK_PTR(event));
}
void ClientGroupChatRoom::onSubjectChanged (const shared_ptr<ConferenceSubjectEvent> &event, bool isFullState) {
......
......@@ -104,6 +104,10 @@ static void chat_room_state_changed (LinphoneChatRoom *cr, LinphoneChatRoomState
}
}
static void chat_room_security_alert (LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
printf("Chatroom security alert detected\n");
}
static void chat_room_subject_changed (LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
LinphoneCore *core = linphone_chat_room_get_core(cr);
LinphoneCoreManager *manager = (LinphoneCoreManager *)linphone_core_get_user_data(core);
......@@ -124,6 +128,7 @@ static void core_chat_room_state_changed (LinphoneCore *core, LinphoneChatRoom *
linphone_chat_room_cbs_set_participant_admin_status_changed(cbs, chat_room_participant_admin_status_changed);
linphone_chat_room_cbs_set_participant_removed(cbs, chat_room_participant_removed);
linphone_chat_room_cbs_set_state_changed(cbs, chat_room_state_changed);
linphone_chat_room_cbs_set_security_alert(cbs, chat_room_security_alert);
linphone_chat_room_cbs_set_subject_changed(cbs, chat_room_subject_changed);
linphone_chat_room_cbs_set_participant_device_added(cbs, chat_room_participant_device_added);
linphone_chat_room_cbs_set_undecryptable_message_received(cbs, undecryptable_message_received);
......
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