Commit 2e329b74 authored by Sylvain Berfini's avatar Sylvain Berfini 🐮
Browse files

Added more 1-1 chat room related exhume tests

parent b1ccf896
......@@ -167,6 +167,8 @@ static void call_received(SalCallOp *h) {
if (chatRoom) {
lInfo() << "Found exhumable chat room [" << chatRoom->getConferenceId() << "]";
L_GET_PRIVATE(static_pointer_cast<ClientGroupChatRoom>(chatRoom))->onRemotelyExhumedConference(h);
// For tests purposes
linphone_core_notify_chat_room_exhumed(lc, L_GET_C_BACK_PTR(chatRoom));
linphone_address_unref(toAddr);
linphone_address_unref(fromAddr);
......
......@@ -577,6 +577,13 @@ void linphone_core_cbs_set_ec_calibration_audio_uninit(LinphoneCoreCbs *cbs, Lin
cbs->vtable->ec_calibration_audio_uninit = cb;
}
LinphoneCoreCbsChatRoomExhumedCb linphone_core_cbs_get_chat_room_exhumed(LinphoneCoreCbs *cbs) {
return cbs->vtable->chat_room_exhumed;
}
void linphone_core_cbs_set_chat_room_exhumed(LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomExhumedCb cb) {
cbs->vtable->chat_room_exhumed = cb;
}
void lc_callback_obj_init(LCCallbackObj *obj,LinphoneCoreCbFunc func,void* ud) {
obj->_func=func;
......
......@@ -607,6 +607,7 @@ 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);
void linphone_core_notify_ec_calibration_audio_uninit(LinphoneCore *lc);
void linphone_core_notify_chat_room_exhumed(LinphoneCore *lc, LinphoneChatRoom *chat_room);
void set_playback_gain_db(AudioStream *st, float gain);
......
......@@ -22,6 +22,7 @@
#include "call/call.h"
#include "chat/chat-room/chat-room-p.h"
#include "chat/chat-room/client-group-chat-room-p.h"
#include "core/core-p.h"
#include "c-wrapper/c-wrapper.h"
#include "conference/session/media-session-p.h"
......@@ -222,4 +223,10 @@ void linphone_shared_core_helpers_on_msg_written_in_user_defaults(LinphoneCore *
char * linphone_core_get_download_path(LinphoneCore *lc) {
return bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getDownloadPath().c_str());
}
size_t linphone_chat_room_get_previouses_conference_ids_count(LinphoneChatRoom *cr) {
auto abstract = L_GET_CPP_PTR_FROM_C_OBJECT(cr);
return L_GET_PRIVATE(static_pointer_cast<ClientGroupChatRoom>(abstract))->getPreviousConferenceIds().size();
}
\ No newline at end of file
......@@ -225,6 +225,7 @@ LINPHONE_PUBLIC char *linphone_core_get_download_path(LinphoneCore *lc);
LINPHONE_PUBLIC const char *linphone_core_get_groupchat_version(void);
LINPHONE_PUBLIC size_t linphone_chat_room_get_previouses_conference_ids_count(LinphoneChatRoom *cr);
#ifndef __cplusplus
LINPHONE_PUBLIC Sal *linphone_core_get_sal(const LinphoneCore *lc);
LINPHONE_PUBLIC SalOp *linphone_proxy_config_get_sal_op(const LinphoneProxyConfig *cfg);
......
......@@ -380,6 +380,11 @@ void linphone_core_notify_ec_calibration_audio_uninit(LinphoneCore *lc) {
cleanup_dead_vtable_refs(lc);
}
void linphone_core_notify_chat_room_exhumed(LinphoneCore *lc, LinphoneChatRoom *chat_room) {
NOTIFY_IF_EXIST(chat_room_exhumed, lc, chat_room);
cleanup_dead_vtable_refs(lc);
}
static VTableReference * v_table_reference_new(LinphoneCoreCbs *cbs, bool_t internal){
VTableReference *ref=ms_new0(VTableReference,1);
ref->valid=TRUE;
......
......@@ -700,6 +700,14 @@ typedef int (*LinphoneImEncryptionEngineCbsUploadingFileCb)(LinphoneImEncryption
**/
typedef void (*LinphoneXmlRpcRequestCbsResponseCb)(LinphoneXmlRpcRequest *request);
/**
* Callback used to notify a chat room has been exhumed. Internal use only!
* @param core #LinphoneCore object @notnil
* @param chat_room #LinphoneChatRoom object @notnil
* @donotwrap
**/
typedef void (*LinphoneCoreCbsChatRoomExhumedCb)(LinphoneCore *core, LinphoneChatRoom *chat_room);
/**
* @}
**/
......
......@@ -238,6 +238,7 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreCbsAudioDeviceChangedCb audio_device_changed;
LinphoneCoreCbsAudioDevicesListUpdatedCb audio_devices_list_updated;
LinphoneCoreCbsImeeUserRegistrationCb imee_user_registration;
LinphoneCoreCbsChatRoomExhumedCb chat_room_exhumed;
void *user_data; /**<User data associated with the above callbacks */
} LinphoneCoreVTable;
......@@ -924,6 +925,22 @@ LINPHONE_PUBLIC void linphone_core_cbs_set_ec_calibration_audio_init(LinphoneCor
*/
LINPHONE_PUBLIC void linphone_core_cbs_set_ec_calibration_audio_uninit(LinphoneCoreCbs *cbs, LinphoneCoreCbsEcCalibrationAudioUninitCb cb);
/**
* @brief Sets a callback to call when a chat room is exhumed. Internal use only!
* @param cbs LinphoneCoreCbs object @notnil
* @return The callback to use
* @donotwrap
*/
LINPHONE_PUBLIC LinphoneCoreCbsChatRoomExhumedCb linphone_core_cbs_get_chat_room_exhumed(LinphoneCoreCbs *cbs);
/**
* @brief Sets a callback to call when a chat room is exhumed. Internal use only!
* @param cbs LinphoneCoreCbs object @notnil
* @param cb The callback to use
* @donotwrap
*/
LINPHONE_PUBLIC void linphone_core_cbs_set_chat_room_exhumed(LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomExhumedCb cb);
/**
* @}
**/
......
......@@ -148,7 +148,17 @@ void ClientGroupChatRoomPrivate::confirmJoining (SalCallOp *op) {
session->configure(LinphoneCallIncoming, nullptr, op, Address(op->getFrom()), Address(op->getTo()));
session->startIncomingNotification(false);
if (!previousSession) {
bool found = false;
for (auto it = previousConferenceIds.begin(); it != previousConferenceIds.end(); it++) {
ConferenceId confId = static_cast<ConferenceId>(*it);
if (confId.getPeerAddress() == op->getRemoteContact()) {
found = true;
break;
}
}
// If INVITE is for a previous conference ID, only accept the session to acknowledge the BYE
if (!previousSession && !found) {
q->setState(ConferenceInterface::State::CreationPending);
// Handle participants addition
list<IdentityAddress> identAddresses = ClientGroupChatRoom::parseResourceLists(op->getRemoteBody());
......
......@@ -2455,7 +2455,7 @@ static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_1(const int cu
confAddr = linphone_address_ref((LinphoneAddress *)linphone_chat_room_get_conference_address(marieOneToOneCr));
paulineOneToOneCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, "one to one", 1, TRUE);
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Hello !");
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Do. Or do not. There is no try.");
linphone_chat_message_send(message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, 1, 5000));
......@@ -2471,7 +2471,7 @@ static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_1(const int cu
BC_ASSERT_EQUAL(bctbx_list_size(participants), 1, int , "%d");
bctbx_list_free_with_data(participants, (bctbx_list_free_func)linphone_participant_unref);
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Lich king !");
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "No. I am your father.");
linphone_chat_message_send(exhume_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 2, 5000));
......@@ -2551,7 +2551,7 @@ static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_2(const int cu
confAddr = linphone_address_ref((LinphoneAddress *)linphone_chat_room_get_conference_address(marieOneToOneCr));
paulineOneToOneCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, "one to one", 1, TRUE);
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Hello again !");
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Help me, Obi-Wan Kenobi. You’re my only hope.");
linphone_chat_message_send(message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, 1, 5000));
......@@ -2584,7 +2584,7 @@ static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_2(const int cu
BC_ASSERT_TRUE(linphone_address_weak_equal(exhumedConfAddr, paulineNewConfAddr));
if (paulineNewConfAddr) linphone_address_unref(paulineNewConfAddr);
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(marieOneToOneCr, "Lich king 2 !");
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(marieOneToOneCr, "I find your lack of faith disturbing.");
linphone_chat_message_send(exhume_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 1, 5000));
......@@ -2637,6 +2637,249 @@ static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_2(void) {
exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_2(448);
}
static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_3(const int curveId) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_lime_x3dh_rc");
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_lime_x3dh_rc");
LinphoneChatRoom *marieOneToOneCr = NULL, *paulineOneToOneCr = NULL;
LinphoneAddress *confAddr = NULL, *exhumedConfAddr = NULL;
bctbx_list_t *coresManagerList = NULL;
bctbx_list_t *participantsAddresses = NULL;
stats initialMarieStats = marie->stat;
stats initialPaulineStats = pauline->stat;
coresManagerList = bctbx_list_append(coresManagerList, marie);
coresManagerList = bctbx_list_append(coresManagerList, pauline);
set_lime_curve_list(curveId, coresManagerList);
bctbx_list_t *coresList = init_core_for_conference(coresManagerList);
start_core_for_conference(coresManagerList);
// Wait for lime users to be created on X3DH server
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_X3dhUserCreationSuccess, initialMarieStats.number_of_X3dhUserCreationSuccess+1, x3dhServer_creationTimeout));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_X3dhUserCreationSuccess, initialPaulineStats.number_of_X3dhUserCreationSuccess+1, x3dhServer_creationTimeout));
// Check encryption status for both participants
BC_ASSERT_TRUE(linphone_core_lime_x3dh_enabled(marie->lc));
BC_ASSERT_TRUE(linphone_core_lime_x3dh_enabled(pauline->lc));
participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(pauline->lc)));
initialMarieStats = marie->stat;
initialPaulineStats = pauline->stat;
marieOneToOneCr = create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, "one to one", FALSE);
if (!BC_ASSERT_PTR_NOT_NULL(marieOneToOneCr)) goto end;
confAddr = linphone_address_ref((LinphoneAddress *)linphone_chat_room_get_conference_address(marieOneToOneCr));
paulineOneToOneCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, "one to one", 1, FALSE);
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Hasta la vista, baby.");
linphone_chat_message_send(message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, 1, 5000));
linphone_chat_message_unref(message);
// Pauline goes offline
int dummy = 0;
linphone_core_set_network_reachable(pauline->lc, FALSE);
wait_for_list(coresList, &dummy, 1, 2000);
if (marieOneToOneCr) {
LinphoneChatMessage *offline_message = linphone_chat_room_create_message_from_utf8(marieOneToOneCr, "I'll be back.");
linphone_chat_message_send(offline_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 1, 5000));
linphone_chat_message_unref(offline_message);
linphone_core_manager_delete_chat_room(marie, marieOneToOneCr, coresList);
BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneConferenceStateTerminated, 1, 5000));
/* The chatroom from Pauline won't be terminated as it is offline */
BC_ASSERT_FALSE(wait_for_until(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneConferenceStateTerminated, 1, 5000));
participantsAddresses = NULL;
initialMarieStats = marie->stat;
participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(pauline->lc)));
marieOneToOneCr = create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, "one to one", FALSE);
wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneConferenceStateCreated, 2, 5000);
if (!BC_ASSERT_PTR_NOT_NULL(marieOneToOneCr)) goto end;
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomConferenceJoined, 2, 5000));
exhumedConfAddr = linphone_address_ref((LinphoneAddress *)linphone_chat_room_get_conference_address(marieOneToOneCr));
BC_ASSERT_PTR_NOT_NULL(exhumedConfAddr);
if (exhumedConfAddr) {
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(marieOneToOneCr, "I'm back.");
linphone_chat_message_send(exhume_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageSent, 2, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 2, 5000));
linphone_chat_message_unref(exhume_message);
// Pauline goes back online
linphone_core_set_network_reachable(pauline->lc, TRUE);
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomConferenceJoined, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 2, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateTerminated, 1, 5000));
int pauline_messages = linphone_chat_room_get_history_size(paulineOneToOneCr);
BC_ASSERT_EQUAL(pauline_messages, 3, int , "%d");
int marie_messages = linphone_chat_room_get_history_size(marieOneToOneCr);
BC_ASSERT_EQUAL(marie_messages, 1, int , "%d");
LinphoneChatMessage *post_exhume_message = linphone_chat_room_create_message_from_utf8(marieOneToOneCr, "Sarah Connor ?");
linphone_chat_message_send(post_exhume_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageSent, 3, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 3, 5000));
linphone_chat_message_unref(post_exhume_message);
pauline_messages = linphone_chat_room_get_history_size(paulineOneToOneCr);
BC_ASSERT_EQUAL(pauline_messages, 4, int , "%d");
marie_messages = linphone_chat_room_get_history_size(marieOneToOneCr);
BC_ASSERT_EQUAL(marie_messages, 2, int , "%d");
}
linphone_config_set_int(linphone_core_get_config(pauline->lc), "misc", "hide_empty_chat_rooms", 0);
linphone_config_set_int(linphone_core_get_config(pauline->lc), "misc", "hide_chat_rooms_from_removed_proxies", 0);
const bctbx_list_t *pauline_chat_rooms = linphone_core_get_chat_rooms(pauline->lc);
BC_ASSERT_EQUAL(bctbx_list_size(pauline_chat_rooms), 1, int , "%d");
linphone_config_set_int(linphone_core_get_config(marie->lc), "misc", "hide_empty_chat_rooms", 0);
linphone_config_set_int(linphone_core_get_config(pauline->lc), "misc", "hide_chat_rooms_from_removed_proxies", 0);
const bctbx_list_t *marie_chat_rooms = linphone_core_get_chat_rooms(marie->lc);
BC_ASSERT_EQUAL(bctbx_list_size(marie_chat_rooms), 1, int , "%d");
}
end:
if (confAddr) linphone_address_unref(confAddr);
if (exhumedConfAddr) linphone_address_unref(exhumedConfAddr);
if (marieOneToOneCr) linphone_core_manager_delete_chat_room(marie, marieOneToOneCr, coresList);
if (paulineOneToOneCr) linphone_core_manager_delete_chat_room(pauline, paulineOneToOneCr, coresList);
bctbx_list_free(coresList);
bctbx_list_free(coresManagerList);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_3(void) {
exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_3(25519);
exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_3(448);
}
static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_4(const int curveId) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_lime_x3dh_rc");
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_lime_x3dh_rc");
LinphoneChatRoom *marieOneToOneCr = NULL, *paulineOneToOneCr = NULL;
LinphoneAddress *confAddr = NULL, *exhumedConfAddr = NULL;
bctbx_list_t *coresManagerList = NULL;
bctbx_list_t *participantsAddresses = NULL;
stats initialMarieStats = marie->stat;
stats initialPaulineStats = pauline->stat;
coresManagerList = bctbx_list_append(coresManagerList, marie);
coresManagerList = bctbx_list_append(coresManagerList, pauline);
set_lime_curve_list(curveId, coresManagerList);
bctbx_list_t *coresList = init_core_for_conference(coresManagerList);
start_core_for_conference(coresManagerList);
// Wait for lime users to be created on X3DH server
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_X3dhUserCreationSuccess, initialMarieStats.number_of_X3dhUserCreationSuccess+1, x3dhServer_creationTimeout));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_X3dhUserCreationSuccess, initialPaulineStats.number_of_X3dhUserCreationSuccess+1, x3dhServer_creationTimeout));
// Check encryption status for both participants
BC_ASSERT_TRUE(linphone_core_lime_x3dh_enabled(marie->lc));
BC_ASSERT_TRUE(linphone_core_lime_x3dh_enabled(pauline->lc));
participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(pauline->lc)));
initialMarieStats = marie->stat;
initialPaulineStats = pauline->stat;
marieOneToOneCr = create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, "one to one", FALSE);
if (!BC_ASSERT_PTR_NOT_NULL(marieOneToOneCr)) goto end;
confAddr = linphone_address_ref((LinphoneAddress *)linphone_chat_room_get_conference_address(marieOneToOneCr));
paulineOneToOneCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, "one to one", 1, FALSE);
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "There is only one Lord of the Ring, only one who can bend it to his will. And he does not share power.");
linphone_chat_message_send(message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, 1, 5000));
linphone_chat_message_unref(message);
if (marieOneToOneCr) {
linphone_core_manager_delete_chat_room(marie, marieOneToOneCr, coresList);
BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneConferenceStateTerminated, 1, 5000));
/* The chatroom from Pauline is expected to terminate as well */
BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneConferenceStateTerminated, 1, 5000));
bctbx_list_t *participants = linphone_chat_room_get_participants(paulineOneToOneCr);
BC_ASSERT_EQUAL(bctbx_list_size(participants), 1, int , "%d");
bctbx_list_free_with_data(participants, (bctbx_list_free_func)linphone_participant_unref);
// Marie goes offline
int dummy = 0;
linphone_core_set_network_reachable(marie->lc, FALSE);
wait_for_list(coresList, &dummy, 1, 2000);
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "I am Gandalf the White. And I come back to you now... at the turn of the tide.");
linphone_chat_message_send(exhume_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 2, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &marie->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, 2, 5000));
linphone_chat_message_unref(exhume_message);
exhumedConfAddr = linphone_address_ref((LinphoneAddress *)linphone_chat_room_get_conference_address(paulineOneToOneCr));
BC_ASSERT_PTR_NOT_NULL(exhumedConfAddr);
int pauline_messages = linphone_chat_room_get_history_size(paulineOneToOneCr);
BC_ASSERT_EQUAL(pauline_messages, 2, int , "%d");
// Marie goes back online
linphone_core_set_network_reachable(marie->lc, TRUE);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomConferenceJoined, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, 2, 5000));
if (exhumedConfAddr) {
BC_ASSERT_FALSE(linphone_address_weak_equal(confAddr, exhumedConfAddr));
marieOneToOneCr = check_creation_chat_room_client_side(coresList, marie, &initialMarieStats, exhumedConfAddr, "one to one", 1, FALSE);
BC_ASSERT_PTR_NOT_NULL(marieOneToOneCr);
if (marieOneToOneCr) {
int marie_messages = linphone_chat_room_get_history_size(marieOneToOneCr);
BC_ASSERT_EQUAL(marie_messages, 1, int , "%d");
}
}
linphone_config_set_int(linphone_core_get_config(pauline->lc), "misc", "hide_empty_chat_rooms", 0);
linphone_config_set_int(linphone_core_get_config(pauline->lc), "misc", "hide_chat_rooms_from_removed_proxies", 0);
const bctbx_list_t *pauline_chat_rooms = linphone_core_get_chat_rooms(pauline->lc);
BC_ASSERT_EQUAL(bctbx_list_size(pauline_chat_rooms), 1, int , "%d");
linphone_config_set_int(linphone_core_get_config(marie->lc), "misc", "hide_empty_chat_rooms", 0);
linphone_config_set_int(linphone_core_get_config(pauline->lc), "misc", "hide_chat_rooms_from_removed_proxies", 0);
const bctbx_list_t *marie_chat_rooms = linphone_core_get_chat_rooms(marie->lc);
BC_ASSERT_EQUAL(bctbx_list_size(marie_chat_rooms), 1, int , "%d");
}
end:
if (confAddr) linphone_address_unref(confAddr);
if (exhumedConfAddr) linphone_address_unref(exhumedConfAddr);
if (marieOneToOneCr) linphone_core_manager_delete_chat_room(marie, marieOneToOneCr, coresList);
if (paulineOneToOneCr) linphone_core_manager_delete_chat_room(pauline, paulineOneToOneCr, coresList);
bctbx_list_free(coresList);
bctbx_list_free(coresManagerList);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void exhume_group_chat_lime_x3dh_one_to_one_chat_room_4(void) {
exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_4(25519);
exhume_group_chat_lime_x3dh_one_to_one_chat_room_base_4(448);
}
static void group_chat_lime_x3dh_call_security_alert(void) {
group_chat_lime_x3dh_call_security_alert_curve(25519);
group_chat_lime_x3dh_call_security_alert_curve(448);
......@@ -3600,6 +3843,8 @@ test_t secure_group_chat_tests[] = {
TEST_ONE_TAG("LIME X3DH chatroom security alert", group_chat_lime_x3dh_chatroom_security_alert, "LimeX3DH"),
TEST_ONE_TAG("LIME X3DH exhumed one-to-one chat room 1", exhume_group_chat_lime_x3dh_one_to_one_chat_room_1, "LimeX3DH"),
TEST_ONE_TAG("LIME X3DH exhumed one-to-one chat room 2", exhume_group_chat_lime_x3dh_one_to_one_chat_room_2, "LimeX3DH"),
TEST_ONE_TAG("LIME X3DH exhumed one-to-one chat room 3", exhume_group_chat_lime_x3dh_one_to_one_chat_room_3, "LimeX3DH"),
TEST_ONE_TAG("LIME X3DH exhumed one-to-one chat room 4", exhume_group_chat_lime_x3dh_one_to_one_chat_room_4, "LimeX3DH"),
TEST_ONE_TAG("LIME X3DH call security alert", group_chat_lime_x3dh_call_security_alert, "LimeX3DH"),
TEST_ONE_TAG("LIME X3DH multiple successive messages", group_chat_lime_x3dh_send_multiple_successive_encrypted_messages, "LimeX3DH"),
TEST_ONE_TAG("LIME X3DH encrypted message to disabled LIME X3DH", group_chat_lime_x3dh_send_encrypted_message_to_disabled_lime_x3dh, "LimeX3DH"),
......
......@@ -4219,7 +4219,7 @@ static void exhume_one_to_one_chat_room_1(void) {
confAddr = linphone_address_ref((LinphoneAddress *)linphone_chat_room_get_conference_address(marieOneToOneCr));
paulineOneToOneCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, "one to one", 1, FALSE);
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Hello !");
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Do. Or do not. There is no try.");
linphone_chat_message_send(message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, 1, 5000));
......@@ -4235,7 +4235,7 @@ static void exhume_one_to_one_chat_room_1(void) {
BC_ASSERT_EQUAL(bctbx_list_size(participants), 1, int , "%d");
bctbx_list_free_with_data(participants, (bctbx_list_free_func)linphone_participant_unref);
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Lich king !");
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "No. I am your father.");
linphone_chat_message_send(exhume_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 2, 5000));
......@@ -4274,7 +4274,6 @@ end:
if (confAddr) linphone_address_unref(confAddr);
if (exhumedConfAddr) linphone_address_unref(exhumedConfAddr);
if (marieOneToOneCr) linphone_core_manager_delete_chat_room(marie, marieOneToOneCr, coresList);
if (paulineOneToOneCr) linphone_core_manager_delete_chat_room(pauline, paulineOneToOneCr, coresList);
bctbx_list_free(coresList);
bctbx_list_free(coresManagerList);
......@@ -4306,7 +4305,7 @@ static void exhume_one_to_one_chat_room_2(void) {
confAddr = linphone_address_ref((LinphoneAddress *)linphone_chat_room_get_conference_address(marieOneToOneCr));
paulineOneToOneCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, "one to one", 1, FALSE);
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Hello again !");
LinphoneChatMessage *message = linphone_chat_room_create_message_from_utf8(paulineOneToOneCr, "Help me, Obi-Wan Kenobi. You’re my only hope.");
linphone_chat_message_send(message);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, 1, 5000));
......@@ -4339,7 +4338,7 @@ static void exhume_one_to_one_chat_room_2(void) {
BC_ASSERT_TRUE(linphone_address_weak_equal(exhumedConfAddr, paulineNewConfAddr));
if (paulineNewConfAddr) linphone_address_unref(paulineNewConfAddr);
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(marieOneToOneCr, "Lich king 2 !");
LinphoneChatMessage *exhume_message = linphone_chat_room_create_message_from_utf8(marieOneToOneCr, "I find your lack of faith disturbing.");
linphone_chat_message_send(exhume_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageSent, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 1, 5000));
......@@ -4374,7 +4373,6 @@ end:
if (confAddr) linphone_address_unref(confAddr);
if (exhumedConfAddr) linphone_address_unref(exhumedConfAddr);
if (marieOneToOneCr) linphone_core_manager_delete_chat_room(marie, marieOneToOneCr, coresList);
if (paulineOneToOneCr) linphone_core_manager_delete_chat_room(pauline, paulineOneToOneCr, coresList);
bctbx_list_free(coresList);
bctbx_list_free(coresManagerList);
......@@ -4382,7 +4380,13 @@ end:
linphone_core_manager_destroy(pauline);
}
static void exhume_one_to_one_chat_room_3(void) {
static void linphone_tester_chat_room_exhumed(LinphoneCore *core, LinphoneChatRoom *room) {
stats* counters;
counters = get_stats(core);
counters->number_of_LinphoneChatRoomExhumed++;
}
static void exhume_one_to_one_chat_room_3_base(bool_t core_restart) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc");
LinphoneChatRoom *marieOneToOneCr = NULL, *paulineOneToOneCr = NULL;
......@@ -4452,10 +4456,40 @@ static void exhume_one_to_one_chat_room_3(void) {
// Pauline goes back online
linphone_core_set_network_reachable(pauline->lc, TRUE);
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomConferenceJoined, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 2, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateTerminated, 1, 5000));
if (core_restart) {
LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get());
linphone_core_cbs_set_chat_room_exhumed(cbs, linphone_tester_chat_room_exhumed);
linphone_core_add_callbacks(pauline->lc, cbs);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomExhumed, 1, 5000));
BC_ASSERT_EQUAL(linphone_chat_room_get_previouses_conference_ids_count(paulineOneToOneCr), 1, int, "%d");
linphone_core_cbs_unref(cbs);
coresList = bctbx_list_remove(coresList, pauline->lc);
linphone_core_manager_reinit(pauline);
// Make sure conference factory URI is preserved
LinphoneProxyConfig *lpc = linphone_core_get_default_proxy_config(pauline->lc);
linphone_proxy_config_set_conference_factory_uri(lpc, sFactoryUri);
linphone_core_manager_start(pauline, TRUE);
bctbx_list_t *tmpCoresManagerList = bctbx_list_append(NULL, pauline);
init_core_for_conference(tmpCoresManagerList);
bctbx_list_free(tmpCoresManagerList);
coresList = bctbx_list_append(coresList, pauline->lc);
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateCreated, 1, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomConferenceJoined, 1, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 1, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateTerminated, 1, 5000));
paulineOneToOneCr = linphone_core_get_chat_room(pauline->lc, exhumedConfAddr);
BC_ASSERT_EQUAL(linphone_chat_room_get_previouses_conference_ids_count(paulineOneToOneCr), 0, int, "%d");
} else {
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateCreated, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomConferenceJoined, 2, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 2, 5000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneConferenceStateTerminated, 1, 5000));
}
int pauline_messages = linphone_chat_room_get_history_size(paulineOneToOneCr);
BC_ASSERT_EQUAL(pauline_messages, 3, int , "%d");
......@@ -4466,7 +4500,11 @@ static void exhume_one_to_one_chat_room_3(void) {
LinphoneChatMessage *post_exhume_message = linphone_chat_room_create_message_from_utf8(marieOneToOneCr, "Sarah Connor ?");
linphone_chat_message_send(post_exhume_message);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageSent, 3, 5000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 3, 5000));
if (core_restart) {
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 2, 5000));
} else {
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, 3, 5000));
}
linphone_chat_message_unref(post_exhume_message);
pauline_messages = linphone_chat_room_get_history_size(paulineOneToOneCr);
......@@ -4491,7 +4529,111 @@ end:
if (confAddr) linphone_address_unref(confAddr);
if (exhumedConfAddr) linphone_address_unref(exhumedConfAddr);
if (marieOneToOneCr) linphone_core_manager_delete_chat_room(marie, marieOneToOneCr, coresList);
if (paulineOneToOneCr) linphone_core_manager_delete_chat_room(pauline, paulineOneToOneCr, coresList);
bctbx_list_free(coresList);
bctbx_list_free(coresManagerList);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void exhume_one_to_one_chat_room_3(void) {
e