Commit 423beca3 authored by Nicolas Michon's avatar Nicolas Michon

Fix ChatRoomParams refs

parent c2706c77
......@@ -108,13 +108,13 @@ LinphoneChatRoom *linphone_core_create_client_group_chat_room_2(LinphoneCore *lc
}
LinphoneChatRoom *linphone_core_create_chat_room(LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const char *subject, const bctbx_list_t *participants) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toSharedPtr(params), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)), L_C_TO_STRING(subject), L_GET_CPP_LIST_FROM_C_LIST_2(participants, LinphoneAddress *, LinphonePrivate::IdentityAddress, [] (LinphoneAddress *addr) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toCpp(params)->clone()->toSharedPtr(), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)), L_C_TO_STRING(subject), L_GET_CPP_LIST_FROM_C_LIST_2(participants, LinphoneAddress *, LinphonePrivate::IdentityAddress, [] (LinphoneAddress *addr) {
return LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr));
})));
}
LinphoneChatRoom *linphone_core_create_chat_room_2(LinphoneCore *lc, const LinphoneChatRoomParams *params, const char *subject, const bctbx_list_t *participants) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toSharedPtr(params), L_C_TO_STRING(subject), L_GET_CPP_LIST_FROM_C_LIST_2(participants, LinphoneAddress *, LinphonePrivate::IdentityAddress, [] (LinphoneAddress *addr) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toCpp(params)->clone()->toSharedPtr(), L_C_TO_STRING(subject), L_GET_CPP_LIST_FROM_C_LIST_2(participants, LinphoneAddress *, LinphonePrivate::IdentityAddress, [] (LinphoneAddress *addr) {
return LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr));
})));
}
......@@ -126,7 +126,7 @@ LinphoneChatRoom *linphone_core_create_chat_room_3(LinphoneCore *lc, const char
}
LinphoneChatRoom *linphone_core_create_chat_room_4(LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const LinphoneAddress *participant) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toSharedPtr(params), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(participant))));
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toCpp(params)->clone()->toSharedPtr(), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(participant))));
}
LinphoneChatRoom *linphone_core_create_chat_room_5(LinphoneCore *lc, const LinphoneAddress *participant) {
......@@ -134,7 +134,9 @@ LinphoneChatRoom *linphone_core_create_chat_room_5(LinphoneCore *lc, const Linph
}
LinphoneChatRoomParams *linphone_core_create_default_chat_room_params(LinphoneCore *lc) {
return LinphonePrivate::ChatRoomParams::createCObject();
auto params = LinphonePrivate::ChatRoomParams::getDefaults(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getSharedFromThis());
params->ref();
return params->toC();
}
LinphoneChatRoom *_linphone_core_create_server_group_chat_room (LinphoneCore *lc, LinphonePrivate::SalCallOp *op) {
......
......@@ -39,6 +39,14 @@ ChatRoomParams::ChatRoomParams(bool encrypted, bool group, ChatRoomBackend backe
}
}
ChatRoomParams::ChatRoomParams(const ChatRoomParams &other) : HybridObject(other) {
mChatRoomBackend = other.mChatRoomBackend;
mChatRoomEncryptionBackend = other.mChatRoomEncryptionBackend;
mEncrypted = other.mEncrypted;
mGroup = other.mGroup;
mRtt = other.mRtt;
}
ChatRoomParams::ChatRoomBackend ChatRoomParams::getChatRoomBackend() const { return mChatRoomBackend; }
ChatRoomParams::ChatRoomEncryptionBackend ChatRoomParams::getChatRoomEncryptionBackend() const { return mChatRoomEncryptionBackend; }
......@@ -155,8 +163,6 @@ std::string ChatRoomParams::toString() const {
else
ss << "FlexisipChat];";
ss << "EncryptionBackend[" << ((mChatRoomEncryptionBackend == ChatRoomEncryptionBackend::None) ? "None" : "Lime X3DH") << "];";
ss << std::endl;
return ss.str();
}
......
......@@ -42,12 +42,14 @@ public:
//Derived HybridObject constructors have to be public to allow construction from factory-like `bellesip::HybridObject::create` method
//Base constructor is protected anyways to prevent unmanaged creation.
ChatRoomParams();
ChatRoomParams(const ChatRoomParams &params) = default;
ChatRoomParams(const ChatRoomParams &other);
//Convenience constructor
ChatRoomParams(bool encrypted, bool group, ChatRoomBackend backend);
ChatRoomParams *clone() const override { return new ChatRoomParams(*this); }
bool isValid() const;
std::string toString() const;
std::string toString() const override;
ChatRoomBackend getChatRoomBackend() const;
ChatRoomEncryptionBackend getChatRoomEncryptionBackend() const;
......
......@@ -16,8 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linphone/core.h"
#include "linphone/api/c-types.h"
#include "linphone/api/c-chat-room-params.h"
......@@ -421,7 +419,6 @@ static void group_chat_room_params (void) {
linphone_chat_room_params_enable_encryption(params, FALSE);
linphone_chat_room_params_set_backend(params, LinphoneChatRoomBackendBasic);
linphone_chat_room_params_enable_group(params, FALSE);
linphone_chat_room_params_ref(params); //Ref params instead of re-creating them
marieCr = linphone_core_create_chat_room_2(marie->lc, params, "Basic chat room subject", participantsAddresses);
BC_ASSERT_PTR_NOT_NULL(marieCr);
if (marieCr) {
......@@ -434,8 +431,7 @@ static void group_chat_room_params (void) {
//Should create a one-to-one flexisip chat
linphone_chat_room_params_set_backend(params, LinphoneChatRoomBackendFlexisipChat);
linphone_chat_room_params_enable_group(params, FALSE);
linphone_chat_room_params_ref(params); //Ref params instead of re-creating them
marieCr = linphone_core_create_chat_room_2(marie->lc, params, "One to one client group chat room subject", participantsAddresses);//create_chat_room_with_params(coresList, marie, &initialMarieStats, participantsAddresses, "One to one client group chat room subject", params);
marieCr = linphone_core_create_chat_room_2(marie->lc, params, "One to one client group chat room subject", participantsAddresses);
BC_ASSERT_PTR_NOT_NULL(marieCr);
if (marieCr) {
BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(marieCr) & LinphoneChatRoomCapabilitiesConference);
......@@ -447,9 +443,8 @@ static void group_chat_room_params (void) {
//Should create a group flexisip chat
linphone_chat_room_params_set_backend(params, LinphoneChatRoomBackendFlexisipChat);
linphone_chat_room_params_enable_group(params, TRUE);
linphone_chat_room_params_ref(params); //Ref params instead of re-creating them
participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(chloe->lc)));
marieCr = linphone_core_create_chat_room_2(marie->lc, params, "Group chat room subject", participantsAddresses);//create_chat_room_with_params(coresList, marie, &initialMarieStats, participantsAddresses, "Group chat room subject", params);
marieCr = linphone_core_create_chat_room_2(marie->lc, params, "Group chat room subject", participantsAddresses);
BC_ASSERT_PTR_NOT_NULL(marieCr);
if (marieCr) {
BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(marieCr) & LinphoneChatRoomCapabilitiesConference);
......@@ -464,8 +459,7 @@ static void group_chat_room_params (void) {
linphone_chat_room_params_enable_encryption(params, TRUE);
//Check that enabling encryption also defines a valid encryptionBackend
BC_ASSERT_EQUAL(linphone_chat_room_params_get_encryption_backend(params), LinphoneChatRoomEncryptionBackendLime, int, "%d");
linphone_chat_room_params_ref(params); //Ref params instead of re-creating them
marieCr = linphone_core_create_chat_room_2(marie->lc, params, "Encrypted group chat room subject", participantsAddresses);//create_chat_room_with_params(coresList, marie, &initialMarieStats, participantsAddresses, "Encrypted group chat room subject", params);
marieCr = linphone_core_create_chat_room_2(marie->lc, params, "Encrypted group chat room subject", participantsAddresses);
BC_ASSERT_PTR_NOT_NULL(marieCr);
if (marieCr) {
BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(marieCr) & LinphoneChatRoomCapabilitiesConference);
......@@ -527,7 +521,6 @@ static void group_chat_room_creation_with_given_identity(void) {
const LinphoneAddress *localAddr = linphone_chat_room_get_local_address(marieCr);
BC_ASSERT_TRUE(linphone_address_weak_equal(localAddr, marieAddr));
linphone_chat_room_params_ref(params);
LinphoneChatRoom *secondMarieCr = linphone_core_create_chat_room(marie->lc, params, marieSecondAddr, "second chat room", participantsAddresses);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreated, initialMarieStats.number_of_LinphoneChatRoomStateCreated + 1, 5000));
......
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