Commit 2588effa authored by Sylvain Berfini's avatar Sylvain Berfini 🐮
Browse files

Fixed issue with previously created linphone_core_search_chat_room

parent b7d0c708
......@@ -147,14 +147,15 @@ LinphoneChatRoom *linphone_core_create_chat_room_6(LinphoneCore *lc, const Linph
return L_GET_C_BACK_PTR(room);
}
LinphoneChatRoom *linphone_core_search_chat_room(const LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const bctbx_list_t *participants) {
LinphoneChatRoom *linphone_core_search_chat_room(const LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const LinphoneAddress *remoteAddr, const bctbx_list_t *participants) {
shared_ptr<LinphonePrivate::ChatRoomParams> chatRoomParams = params ? LinphonePrivate::ChatRoomParams::toCpp(params)->clone()->toSharedPtr() : nullptr;
const list<LinphonePrivate::IdentityAddress> participantsList = 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));
});
bool withGruu = chatRoomParams ? chatRoomParams->getChatRoomBackend() == LinphonePrivate::ChatRoomParams::ChatRoomBackend::FlexisipChat : false;
LinphonePrivate::IdentityAddress identityAddress = localAddr ? LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)) : L_GET_PRIVATE_FROM_C_OBJECT(lc)->getDefaultLocalAddress(nullptr, withGruu);
shared_ptr<LinphonePrivate::AbstractChatRoom> room = L_GET_PRIVATE_FROM_C_OBJECT(lc)->searchChatRoom(chatRoomParams, identityAddress, participantsList);
LinphonePrivate::IdentityAddress remoteAddress = remoteAddr ? LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(remoteAddr)) : LinphonePrivate::IdentityAddress();
shared_ptr<LinphonePrivate::AbstractChatRoom> room = L_GET_PRIVATE_FROM_C_OBJECT(lc)->searchChatRoom(chatRoomParams, identityAddress, remoteAddress, participantsList);
return L_GET_C_BACK_PTR(room);
}
......@@ -192,13 +193,13 @@ LinphoneChatRoom *linphone_core_get_chat_room_2 (
LinphoneChatRoomParams *params = linphone_core_create_default_chat_room_params(lc);
linphone_chat_room_params_set_backend(params, LinphoneChatRoomBackendBasic);
linphone_chat_room_params_enable_group(params, FALSE);
bctbx_list_t *paricipants = bctbx_list_prepend(NULL, (LinphoneAddress *)peer_addr);
LinphoneChatRoom *result = linphone_core_search_chat_room(lc, params, local_addr, paricipants);
LinphoneChatRoom *result = linphone_core_search_chat_room(lc, params, local_addr, peer_addr, NULL);
if (result == NULL) {
bctbx_list_t *paricipants = bctbx_list_prepend(NULL, (LinphoneAddress *)peer_addr);
result = linphone_core_create_chat_room_6(lc, params, local_addr, paricipants);
bctbx_list_free(paricipants);
}
linphone_chat_room_params_unref(params);
bctbx_list_free(paricipants);
return result;
}
......@@ -216,9 +217,7 @@ LinphoneChatRoom *linphone_core_find_chat_room(
const LinphoneAddress *peer_addr,
const LinphoneAddress *local_addr
) {
bctbx_list_t *paricipants = bctbx_list_prepend(NULL, (LinphoneAddress *)peer_addr);
LinphoneChatRoom *result = linphone_core_search_chat_room(lc, NULL, local_addr, paricipants);
bctbx_list_free(paricipants);
LinphoneChatRoom *result = linphone_core_search_chat_room(lc, NULL, local_addr, peer_addr, NULL);
return result;
}
......@@ -231,7 +230,7 @@ LinphoneChatRoom *linphone_core_find_one_to_one_chat_room (
bctbx_list_t *paricipants = bctbx_list_prepend(NULL, (LinphoneAddress *)participant_addr);
LinphoneChatRoomParams *params = _linphone_core_create_default_chat_room_params();
linphone_chat_room_params_enable_group(params, FALSE);
LinphoneChatRoom *result = linphone_core_search_chat_room(lc, params, local_addr, paricipants);
LinphoneChatRoom *result = linphone_core_search_chat_room(lc, params, local_addr, NULL, paricipants);
linphone_chat_room_params_unref(params);
bctbx_list_free(paricipants);
return result;
......@@ -248,7 +247,7 @@ LinphoneChatRoom *linphone_core_find_one_to_one_chat_room_2 (
LinphoneChatRoomParams *params = _linphone_core_create_default_chat_room_params();
linphone_chat_room_params_enable_group(params, FALSE);
linphone_chat_room_params_enable_encryption(params, encrypted);
LinphoneChatRoom *result = linphone_core_search_chat_room(lc, params, local_addr, paricipants);
LinphoneChatRoom *result = linphone_core_search_chat_room(lc, params, local_addr, NULL, paricipants);
linphone_chat_room_params_unref(params);
bctbx_list_free(paricipants);
return result;
......
......@@ -5745,11 +5745,12 @@ LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_create_chat_room_6(LinphoneCore
* @param[in] lc A #LinphoneCore object
* @param[in] params The chat room parameters to match #LinphoneChatRoomParams or NULL @maybenil
* @param[in] localAddr #LinphoneAddress representing the local proxy configuration or NULL @maybenil
* @param[in] remoteAddr #LinphoneAddress to search for or NULL @maybenil
* @param[in] participants \bctbx_list{LinphoneAddress} The participants that must be present in the chat room to find
* @return A matching chat room or NULL if none matches.
* @maybenil
*/
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_search_chat_room(const LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const bctbx_list_t *participants);
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_search_chat_room(const LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const LinphoneAddress *remoteAddr, const bctbx_list_t *participants);
/**
* Get a basic chat room whose peer is the supplied address. If it does not exist yet, it will be created.
......
......@@ -19,6 +19,7 @@
#include "chat-room-params.h"
#include "chat-room.h"
#include "logger/logger.h"
using namespace std;
......@@ -145,18 +146,23 @@ ChatRoom::CapabilitiesMask ChatRoomParams::toCapabilities(const std::shared_ptr<
//Returns false if there are any inconsistencies between parameters
bool ChatRoomParams::isValid() const {
if (mEncrypted && mChatRoomEncryptionBackend != ChatRoomEncryptionBackend::Lime) {
lError() << "Currently only Lime encryption backend is supported";
return false;
}
if (mEncrypted && mChatRoomBackend == ChatRoomBackend::Basic) {
lError() << "Encryption isn't supported with Basic backend";
return false;
}
if (mGroup && mChatRoomBackend != ChatRoomBackend::FlexisipChat) {
lError() << "FlexisipChat backend must be used when group is enabled";
return false;
}
if (mRtt && mChatRoomBackend == ChatRoomBackend::FlexisipChat) {
lError() << "Real time text chat room isn't compatible with FlexisipChat backend";
return false;
}
if (mSubject.empty() && mChatRoomBackend == ChatRoomBackend::FlexisipChat) {
lError() << "You must set a non empty subject when using the FlexisipChat backend";
return false;
}
return true;
......
......@@ -230,10 +230,11 @@ shared_ptr<AbstractChatRoom> CorePrivate::createBasicChatRoom (
return chatRoom;
}
shared_ptr<AbstractChatRoom> CorePrivate::searchChatRoom (const shared_ptr<ChatRoomParams> &params, const IdentityAddress &localAddress, const std::list<IdentityAddress> &participants) const {
shared_ptr<AbstractChatRoom> CorePrivate::searchChatRoom (const shared_ptr<ChatRoomParams> &params, const IdentityAddress &localAddress, const IdentityAddress &remoteAddress, const std::list<IdentityAddress> &participants) const {
for (auto it = chatRoomsById.begin(); it != chatRoomsById.end(); it++) {
const auto &chatRoom = it->second;
const IdentityAddress &curLocalAddress = chatRoom->getLocalAddress();
const IdentityAddress &curRemoteAddress = chatRoom->getPeerAddress();
ChatRoom::CapabilitiesMask capabilities = chatRoom->getCapabilities();
if (params) {
......@@ -253,10 +254,8 @@ shared_ptr<AbstractChatRoom> CorePrivate::searchChatRoom (const shared_ptr<ChatR
if (localAddress.getAddressWithoutGruu() != curLocalAddress.getAddressWithoutGruu())
continue;
if (participants.size() == 1) {
auto remote = participants.front();
if (chatRoom->getPeerAddress() == remote) return chatRoom;
}
if (remoteAddress.isValid() && remoteAddress.getAddressWithoutGruu() != curRemoteAddress.getAddressWithoutGruu())
continue;
bool allFound = true;
for (const auto &participant : participants) {
......
......@@ -129,6 +129,7 @@ public:
std::shared_ptr<AbstractChatRoom> searchChatRoom(const std::shared_ptr<ChatRoomParams> &params,
const IdentityAddress &localAddr,
const IdentityAddress &remoteAddr,
const std::list<IdentityAddress> &participants) const;
IdentityAddress getDefaultLocalAddress(const IdentityAddress *peerAddress, bool withGruu) const;
......
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