Various fixes regarding callbacks of chat rooms.

This commit is contained in:
Ghislain MARY 2018-04-05 17:08:37 +02:00
parent 8ddd7ad309
commit 5290d59d76
8 changed files with 16 additions and 13 deletions

View file

@ -84,8 +84,8 @@ LinphoneChatRoom *linphone_core_get_chat_room (LinphoneCore *lc, const LinphoneA
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getOrCreateBasicChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(addr))); return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getOrCreateBasicChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(addr)));
} }
LinphoneChatRoom *linphone_core_create_client_group_chat_room (LinphoneCore *lc, const char *subject) { LinphoneChatRoom *linphone_core_create_client_group_chat_room (LinphoneCore *lc, const char *subject, bool_t fallback) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->createClientGroupChatRoom(L_C_TO_STRING(subject))); return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->createClientGroupChatRoom(L_C_TO_STRING(subject), !!fallback));
} }
LinphoneChatRoom *_linphone_core_create_server_group_chat_room (LinphoneCore *lc, LinphonePrivate::SalCallOp *op) { LinphoneChatRoom *_linphone_core_create_server_group_chat_room (LinphoneCore *lc, LinphonePrivate::SalCallOp *op) {

View file

@ -4976,13 +4976,14 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC const char *linphone_core_get_chat_database_
/** /**
* Create a client-side group chat room. When calling this function the chat room is only created * Create a client-side group chat room. When calling this function the chat room is only created
* at the client-side and is empty. Pou need to call linphone_chat_room_add_participants() to * at the client-side and is empty. You need to call linphone_chat_room_add_participants() to
* create at the server side and add participants to it. * create at the server side and add participants to it.
* @param[in] lc A #LinphoneCore object * @param[in] lc A #LinphoneCore object
* @param[in] subject The subject of the group chat room * @param[in] subject The subject of the group chat room
* @param[in] fallback Boolean value telling whether we should plan on being able to fallback to a basic chat room if the client-side group chat room creation fails
* @return The newly created client-side group chat room. * @return The newly created client-side group chat room.
*/ */
LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc, const char *subject); LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc, const char *subject, bool_t fallback);
/** /**
* Get a basic chat room whose peer is the supplied address. If it does not exist yet, it will be created. * Get a basic chat room whose peer is the supplied address. If it does not exist yet, it will be created.

View file

@ -442,6 +442,7 @@ const bctbx_list_t *linphone_chat_room_get_callbacks_list(const LinphoneChatRoom
if (cb) \ if (cb) \
cb(__VA_ARGS__); \ cb(__VA_ARGS__); \
} \ } \
linphone_chat_room_set_current_callbacks(cr, nullptr); \
bctbx_list_free(callbacksCopy); bctbx_list_free(callbacksCopy);
void _linphone_chat_room_notify_is_composing_received(LinphoneChatRoom *cr, const LinphoneAddress *remoteAddr, bool_t isComposing) { void _linphone_chat_room_notify_is_composing_received(LinphoneChatRoom *cr, const LinphoneAddress *remoteAddr, bool_t isComposing) {

View file

@ -500,7 +500,7 @@ static void forceUtf8Content (Content &content) {
void ChatMessagePrivate::notifyReceiving () { void ChatMessagePrivate::notifyReceiving () {
L_Q(); L_Q();
LinphoneChatRoom *chatRoom = L_GET_C_BACK_PTR(q->getChatRoom()); LinphoneChatRoom *chatRoom = static_pointer_cast<ChatRoom>(q->getChatRoom())->getPrivate()->getCChatRoom();
if ((getContentType() != ContentType::Imdn) && (getContentType() != ContentType::ImIsComposing)) { if ((getContentType() != ContentType::Imdn) && (getContentType() != ContentType::ImIsComposing)) {
_linphone_chat_room_notify_chat_message_should_be_stored(chatRoom, L_GET_C_BACK_PTR(q->getSharedFromThis())); _linphone_chat_room_notify_chat_message_should_be_stored(chatRoom, L_GET_C_BACK_PTR(q->getSharedFromThis()));
if (toBeStored) if (toBeStored)

View file

@ -30,6 +30,7 @@ class ChatRoomPrivate;
class LINPHONE_PUBLIC ChatRoom : public AbstractChatRoom { class LINPHONE_PUBLIC ChatRoom : public AbstractChatRoom {
public: public:
friend class ChatMessagePrivate;
friend class ProxyChatRoomPrivate; friend class ProxyChatRoomPrivate;
L_OVERRIDE_SHARED_FROM_THIS(ChatRoom); L_OVERRIDE_SHARED_FROM_THIS(ChatRoom);

View file

@ -265,9 +265,9 @@ shared_ptr<AbstractChatRoom> Core::findOneToOneChatRoom (
return nullptr; return nullptr;
} }
shared_ptr<AbstractChatRoom> Core::createClientGroupChatRoom (const string &subject) { shared_ptr<AbstractChatRoom> Core::createClientGroupChatRoom (const string &subject, bool fallback) {
L_D(); L_D();
return d->createClientGroupChatRoom(subject); return d->createClientGroupChatRoom(subject, "", Content(), fallback);
} }
shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt) { shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const ChatRoomId &chatRoomId, bool isRtt) {

View file

@ -101,7 +101,7 @@ public:
const IdentityAddress &participantAddress const IdentityAddress &participantAddress
) const; ) const;
std::shared_ptr<AbstractChatRoom> createClientGroupChatRoom (const std::string &subject); std::shared_ptr<AbstractChatRoom> createClientGroupChatRoom (const std::string &subject, bool fallback = true);
std::shared_ptr<AbstractChatRoom> createClientGroupChatRoom ( std::shared_ptr<AbstractChatRoom> createClientGroupChatRoom (
const std::string &subject, const std::string &subject,
const IdentityAddress &localAddress const IdentityAddress &localAddress

View file

@ -282,7 +282,7 @@ static LinphoneChatRoom * check_creation_chat_room_client_side(bctbx_list_t *lcs
} }
static LinphoneChatRoom * create_chat_room_client_side(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, bctbx_list_t *participantsAddresses, const char* initialSubject, int expectedParticipantSize) { static LinphoneChatRoom * create_chat_room_client_side(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, bctbx_list_t *participantsAddresses, const char* initialSubject, int expectedParticipantSize) {
LinphoneChatRoom *chatRoom = linphone_core_create_client_group_chat_room(lcm->lc, initialSubject); LinphoneChatRoom *chatRoom = linphone_core_create_client_group_chat_room(lcm->lc, initialSubject, FALSE);
if (!chatRoom) return NULL; if (!chatRoom) return NULL;
BC_ASSERT_TRUE(wait_for_list(lcs, &lcm->stat.number_of_LinphoneChatRoomStateInstantiated, initialStats->number_of_LinphoneChatRoomStateInstantiated + 1, 100)); BC_ASSERT_TRUE(wait_for_list(lcs, &lcm->stat.number_of_LinphoneChatRoomStateInstantiated, initialStats->number_of_LinphoneChatRoomStateInstantiated + 1, 100));
@ -2139,7 +2139,7 @@ static void group_chat_room_fallback_to_basic_chat_room (void) {
stats initialPaulineStats = pauline->stat; stats initialPaulineStats = pauline->stat;
// Marie creates a new group chat room // Marie creates a new group chat room
LinphoneChatRoom *marieCr = linphone_core_create_client_group_chat_room(marie->lc, "Fallback"); LinphoneChatRoom *marieCr = linphone_core_create_client_group_chat_room(marie->lc, "Fallback", TRUE);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateInstantiated, initialMarieStats.number_of_LinphoneChatRoomStateInstantiated + 1, 100)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateInstantiated, initialMarieStats.number_of_LinphoneChatRoomStateInstantiated + 1, 100));
// Add participants // Add participants
@ -2195,13 +2195,13 @@ static void group_chat_room_creation_fails_if_invited_participants_dont_support_
stats initialMarieStats = marie->stat; stats initialMarieStats = marie->stat;
// Marie creates a new group chat room // Marie creates a new group chat room
LinphoneChatRoom *marieCr = linphone_core_create_client_group_chat_room(marie->lc, "Hello there"); LinphoneChatRoom *marieCr = linphone_core_create_client_group_chat_room(marie->lc, "Hello there", FALSE);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateInstantiated, initialMarieStats.number_of_LinphoneChatRoomStateInstantiated + 1, 100)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateInstantiated, initialMarieStats.number_of_LinphoneChatRoomStateInstantiated + 1, 100));
// Add participants // Add participants
linphone_chat_room_add_participants(marieCr, participantsAddresses); linphone_chat_room_add_participants(marieCr, participantsAddresses);
// Check that the group chat room creation fails and that a fallback to a basic chat room is done // Check that the group chat room creation fails
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationPending, initialMarieStats.number_of_LinphoneChatRoomStateCreationPending + 1, 10000)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationPending, initialMarieStats.number_of_LinphoneChatRoomStateCreationPending + 1, 10000));
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationFailed, initialMarieStats.number_of_LinphoneChatRoomStateCreationFailed + 1, 10000)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationFailed, initialMarieStats.number_of_LinphoneChatRoomStateCreationFailed + 1, 10000));
bctbx_list_free_with_data(participantsAddresses, (bctbx_list_free_func)linphone_address_unref); bctbx_list_free_with_data(participantsAddresses, (bctbx_list_free_func)linphone_address_unref);
@ -2367,7 +2367,7 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) {
stats initialPaulineStats = pauline->stat; stats initialPaulineStats = pauline->stat;
// Marie creates a new group chat room // Marie creates a new group chat room
LinphoneChatRoom *marieCr = linphone_core_create_client_group_chat_room(marie->lc, "Fallback"); LinphoneChatRoom *marieCr = linphone_core_create_client_group_chat_room(marie->lc, "Fallback", TRUE);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateInstantiated, initialMarieStats.number_of_LinphoneChatRoomStateInstantiated + 1, 100)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateInstantiated, initialMarieStats.number_of_LinphoneChatRoomStateInstantiated + 1, 100));
// Add participants // Add participants