An error occurred while loading the file. Please try again.
-
John Koleszar authored
Approximate the Google style guide[1] so that that there's a written document to follow and tools to check compliance[2]. [1]: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml [2]: http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py Change-Id: Idf40e3d8dddcc72150f6af127b13e5dab838685f
c6b9039f
/*
* Copyright (c) 2010-2022 Belledonne Communications SARL.
*
* This file is part of Liblinphone
* (see https://gitlab.linphone.org/BC/public/liblinphone).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "bctoolbox/crypto.h"
#include "liblinphone_tester.h"
#include "linphone/core.h"
#include "linphone/wrapper_utils.h"
#include "tester_utils.h"
#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic push
#endif
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#endif
void set_ephemeral_cbs(bctbx_list_t *history) {
for (bctbx_list_t *item = history; item; item = bctbx_list_next(item)) {
const LinphoneChatMessage *msg = (LinphoneChatMessage *)bctbx_list_get_data(item);
if (linphone_chat_message_is_ephemeral(msg)) {
LinphoneChatMessageCbs *msgCbs = linphone_chat_message_get_callbacks(msg);
linphone_chat_message_cbs_set_ephemeral_message_timer_started(
msgCbs, liblinphone_tester_chat_message_ephemeral_timer_started);
linphone_chat_message_cbs_set_ephemeral_message_deleted(msgCbs,
liblinphone_tester_chat_message_ephemeral_deleted);
}
}
}
static void ephemeral_message_test(bool_t encrypted, bool_t remained, bool_t expired, const int curveId) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc");
bctbx_list_t *coresManagerList = NULL;
bctbx_list_t *participantsAddresses = NULL;
coresManagerList = bctbx_list_append(coresManagerList, marie);
coresManagerList = bctbx_list_append(coresManagerList, pauline);
int size;
set_lime_server_and_curve_list(curveId, coresManagerList);
stats initialMarieStats = marie->stat;
stats initialPaulineStats = pauline->stat;
bctbx_list_t *coresList = init_core_for_conference(coresManagerList);
start_core_for_conference(coresManagerList);
participantsAddresses =
bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(pauline->lc)));
// Enable IMDN
linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(marie->lc));
linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(pauline->lc));
// 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));
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
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));
// Marie creates a new group chat room
const char *initialSubject = "Friends";
LinphoneChatRoom *marieCr =
create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, initialSubject,
encrypted, LinphoneChatRoomEphemeralModeDeviceManaged);
const LinphoneAddress *confAddr = linphone_chat_room_get_conference_address(marieCr);
// Check that the chat room is correctly created on Pauline's side and that the participants are added
LinphoneChatRoom *paulineCr =
check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, initialSubject, 1, 0);
if (!BC_ASSERT_PTR_NOT_NULL(marieCr) || !BC_ASSERT_PTR_NOT_NULL(paulineCr)) goto end;
BC_ASSERT_FALSE(linphone_chat_room_ephemeral_enabled(marieCr));
LinphoneChatMessage *message[10];
if (remained) {
linphone_chat_room_enable_ephemeral(marieCr, TRUE);
linphone_chat_room_set_ephemeral_lifetime(marieCr, 60);
// Marie sends messages
for (int i = 0; i < 10; i++) {
message[i] = _send_message_ephemeral(marieCr, "Hello", TRUE);
}
}
// Marie disable ephemeral in the group chat room
linphone_chat_room_enable_ephemeral(marieCr, FALSE);
LinphoneChatMessage *messageNormal = _send_message(marieCr, "See you later");
LinphoneChatMessage *messagef[10];
linphone_chat_room_enable_ephemeral(marieCr, TRUE);
linphone_chat_room_set_ephemeral_lifetime(marieCr, 1);
BC_ASSERT_TRUE(linphone_chat_room_ephemeral_enabled(marieCr));
// Marie sends messages
for (int i = 0; i < 10; i++) {
messagef[i] = _send_message_ephemeral(marieCr, "This is Marie", TRUE);
}
size = remained ? 20 : 10;
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived,
initialPaulineStats.number_of_LinphoneMessageReceived + size + 1, 60000));
bctbx_list_t *history = linphone_chat_room_get_history(paulineCr, 0);
set_ephemeral_cbs(history);
// Check that the message has been delivered to Pauline
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageDeliveredToUser,
initialMarieStats.number_of_LinphoneMessageDeliveredToUser + size + 1, 10000));
// Pauline marks the message as read, check that the state is now displayed on Marie's side
linphone_chat_room_mark_as_read(paulineCr);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageDisplayed,
initialMarieStats.number_of_LinphoneMessageDisplayed + size + 1, 10000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomEphemeralTimerStarted,
initialMarieStats.number_of_LinphoneChatRoomEphemeralTimerStarted + size, 10000));
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomEphemeralTimerStarted,
initialPaulineStats.number_of_LinphoneChatRoomEphemeralTimerStarted + size, 10000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageEphemeralTimerStarted,