Commit 01759692 authored by Sylvain Berfini's avatar Sylvain Berfini 🐮
Browse files

Added Core callback to notify when a chat room subject as changed

parent fe0b8028
......@@ -483,6 +483,14 @@ void linphone_core_cbs_set_chat_room_state_changed (LinphoneCoreCbs *cbs, Linpho
cbs->vtable->chat_room_state_changed = cb;
}
LinphoneCoreCbsChatRoomSubjectChangedCb linphone_core_cbs_get_chat_room_subject_changed (LinphoneCoreCbs *cbs) {
return cbs->vtable->chat_room_subject_changed;
}
void linphone_core_cbs_set_chat_room_subject_changed (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomSubjectChangedCb cb) {
cbs->vtable->chat_room_subject_changed = cb;
}
LinphoneCoreCbsQrcodeFoundCb linphone_core_cbs_get_qrcode_found(LinphoneCoreCbs *cbs) {
return cbs->vtable->qrcode_found;
}
......
......@@ -562,6 +562,7 @@ void linphone_core_notify_friend_list_removed(LinphoneCore *lc, LinphoneFriendLi
void linphone_core_notify_call_created(LinphoneCore *lc, LinphoneCall *call);
void linphone_core_notify_version_update_check_result_received(LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url);
void linphone_core_notify_chat_room_state_changed (LinphoneCore *lc, LinphoneChatRoom *cr, LinphoneChatRoomState state);
void linphone_core_notify_chat_room_subject_changed (LinphoneCore *lc, LinphoneChatRoom *cr);
void linphone_core_notify_qrcode_found(LinphoneCore *lc, const char *result);
void linphone_core_notify_ec_calibration_result(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms);
void linphone_core_notify_ec_calibration_audio_init(LinphoneCore *lc);
......
......@@ -319,6 +319,11 @@ void linphone_core_notify_chat_room_state_changed (LinphoneCore *lc, LinphoneCha
cleanup_dead_vtable_refs(lc);
}
void linphone_core_notify_chat_room_subject_changed (LinphoneCore *lc, LinphoneChatRoom *cr) {
NOTIFY_IF_EXIST(chat_room_subject_changed, lc, cr);
cleanup_dead_vtable_refs(lc);
}
void linphone_core_notify_qrcode_found(LinphoneCore *lc, const char *result) {
NOTIFY_IF_EXIST(qrcode_found, lc, result);
cleanup_dead_vtable_refs(lc);
......
......@@ -420,6 +420,13 @@ typedef void (*LinphoneCoreCbsVersionUpdateCheckResultReceivedCb) (LinphoneCore
*/
typedef void (*LinphoneCoreCbsChatRoomStateChangedCb) (LinphoneCore *lc, LinphoneChatRoom *cr, LinphoneChatRoomState state);
/**
* Callback prototype telling that a #LinphoneChatRoom subject has changed.
* @param[in] lc #LinphoneCore object
* @param[in] cr The #LinphoneChatRoom object for which the subject has changed
*/
typedef void (*LinphoneCoreCbsChatRoomSubjectChangedCb) (LinphoneCore *lc, LinphoneChatRoom *cr);
/**
* Callback prototype telling the result of decoded qrcode
* @param[in] lc LinphoneCore object
......
......@@ -231,6 +231,7 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreCbsEcCalibrationAudioUninitCb ec_calibration_audio_uninit;
LinphoneCoreCbsMessageReceivedCb message_sent;
LinphoneCoreCbsChatRoomReadCb chat_room_read;
LinphoneCoreCbsChatRoomSubjectChangedCb chat_room_subject_changed;
void *user_data; /**<User data associated with the above callbacks */
} LinphoneCoreVTable;
......@@ -763,6 +764,20 @@ LINPHONE_PUBLIC LinphoneCoreCbsChatRoomStateChangedCb linphone_core_cbs_get_chat
*/
LINPHONE_PUBLIC void linphone_core_cbs_set_chat_room_state_changed (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomStateChangedCb cb);
/**
* Get the chat room subject changed callback.
* @param[in] cbs #LinphoneCoreCbs object
* @return The current callback
*/
LINPHONE_PUBLIC LinphoneCoreCbsChatRoomSubjectChangedCb linphone_core_cbs_get_chat_room_subject_changed (LinphoneCoreCbs *cbs);
/**
* Set the chat room subject changed callback.
* @param[in] cbs #LinphoneCoreCbs object
* @param[in] cb The callback to use
*/
LINPHONE_PUBLIC void linphone_core_cbs_set_chat_room_subject_changed (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomSubjectChangedCb cb);
/**
* Get the qrcode found callback.
* @param[in] cbs LinphoneCoreCbs object
......
......@@ -854,6 +854,7 @@ void ClientGroupChatRoom::onSubjectChanged (const shared_ptr<ConferenceSubjectEv
LinphoneChatRoom *cr = d->getCChatRoom();
_linphone_chat_room_notify_subject_changed(cr, L_GET_C_BACK_PTR(event));
linphone_core_notify_chat_room_subject_changed(linphone_chat_room_get_core(cr), cr);
}
void ClientGroupChatRoom::onParticipantDeviceAdded (const shared_ptr<ConferenceParticipantDeviceEvent> &event, bool isFullState) {
......
......@@ -169,6 +169,11 @@ void core_chat_room_state_changed (LinphoneCore *core, LinphoneChatRoom *cr, Lin
}
}
void core_chat_room_subject_changed (LinphoneCore *core, LinphoneChatRoom *cr) {
LinphoneCoreManager *manager = (LinphoneCoreManager *)linphone_core_get_user_data(core);
manager->stat.number_of_core_chat_room_subject_changed++;
}
void configure_core_for_conference (LinphoneCore *core, const char* username, const LinphoneAddress *factoryAddr, bool_t server) {
const char *identity = linphone_core_get_identity(core);
const char *new_username;
......@@ -295,6 +300,7 @@ bctbx_list_t * init_core_for_conference(bctbx_list_t *coreManagerList) {
LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get());
linphone_core_cbs_set_chat_room_state_changed(cbs, core_chat_room_state_changed);
linphone_core_cbs_set_chat_room_subject_changed(cbs, core_chat_room_subject_changed);
bctbx_list_for_each2(coreManagerList, (void (*)(void *, void *))configure_core_for_callbacks, (void *) cbs);
linphone_core_cbs_unref(cbs);
......@@ -1370,6 +1376,9 @@ static void group_chat_room_change_subject (void) {
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_subject_changed, initialMarieStats.number_of_subject_changed + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_subject_changed, initialPaulineStats.number_of_subject_changed + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_subject_changed, initialLaureStats.number_of_subject_changed + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_core_chat_room_subject_changed, initialMarieStats.number_of_core_chat_room_subject_changed + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_core_chat_room_subject_changed, initialPaulineStats.number_of_core_chat_room_subject_changed + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_core_chat_room_subject_changed, initialLaureStats.number_of_core_chat_room_subject_changed + 1, 3000));
BC_ASSERT_STRING_EQUAL(linphone_chat_room_get_subject(marieCr), newSubject);
BC_ASSERT_STRING_EQUAL(linphone_chat_room_get_subject(paulineCr), newSubject);
BC_ASSERT_STRING_EQUAL(linphone_chat_room_get_subject(laureCr), newSubject);
......
......@@ -312,6 +312,7 @@ typedef struct _stats {
int number_of_participant_admin_statuses_changed;
int number_of_participants_removed;
int number_of_subject_changed;
int number_of_core_chat_room_subject_changed;
int number_of_participant_devices_added;
int number_of_participant_devices_removed;
......
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