Commit c8ccaeca authored by Benjamin REIS's avatar Benjamin REIS Committed by Ronan

fix crash when conference subscription is denied

parent 79f25ea8
...@@ -61,6 +61,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -61,6 +61,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "chat/chat-room/server-group-chat-room-p.h" #include "chat/chat-room/server-group-chat-room-p.h"
#include "conference/handlers/local-conference-list-event-handler.h" #include "conference/handlers/local-conference-list-event-handler.h"
#include "conference/handlers/remote-conference-event-handler.h" #include "conference/handlers/remote-conference-event-handler.h"
#include "conference/handlers/remote-conference-event-handler-p.h"
#include "conference/handlers/remote-conference-list-event-handler.h" #include "conference/handlers/remote-conference-list-event-handler.h"
#include "content/content-manager.h" #include "content/content-manager.h"
#include "content/content-type.h" #include "content/content-type.h"
...@@ -2181,9 +2182,10 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve ...@@ -2181,9 +2182,10 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
if (strcmp(notified_event, "Presence") == 0) { if (strcmp(notified_event, "Presence") == 0) {
for (const bctbx_list_t *it = linphone_core_get_friends_lists(lc); it; it = bctbx_list_next(it)) { for (const bctbx_list_t *it = linphone_core_get_friends_lists(lc); it; it = bctbx_list_next(it)) {
LinphoneFriendList *list = reinterpret_cast<LinphoneFriendList *>(bctbx_list_get_data(it)); LinphoneFriendList *list = reinterpret_cast<LinphoneFriendList *>(bctbx_list_get_data(it));
if (list->event != lev) continue;
ms_message("Notify presence for list %p", list); ms_message("Notify presence for list %p", list);
if (list->event == lev) linphone_friend_list_notify_presence_received(list, lev, body);
linphone_friend_list_notify_presence_received(list, lev, body);
} }
} else if (strcmp(notified_event, "conference") == 0) { } else if (strcmp(notified_event, "conference") == 0) {
const LinphoneAddress *resource = linphone_event_get_resource(lev); const LinphoneAddress *resource = linphone_event_get_resource(lev);
...@@ -2250,8 +2252,13 @@ static void linphone_core_internal_subscribe_received(LinphoneCore *lc, Linphone ...@@ -2250,8 +2252,13 @@ static void linphone_core_internal_subscribe_received(LinphoneCore *lc, Linphone
} }
static void _linphone_core_conference_subscription_state_changed (LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) { static void _linphone_core_conference_subscription_state_changed (LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
if (!linphone_core_conference_server_enabled(lc)) if (!linphone_core_conference_server_enabled(lc)) {
RemoteConferenceEventHandlerPrivate *thiz = static_cast<RemoteConferenceEventHandlerPrivate *>(linphone_event_get_user_data(lev));
if (state == LinphoneSubscriptionError)
thiz->invalidateSubscription();
return; return;
}
const LinphoneAddress *resource = linphone_event_get_resource(lev); const LinphoneAddress *resource = linphone_event_get_resource(lev);
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ConferenceId( shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ConferenceId(
......
...@@ -32,11 +32,11 @@ ...@@ -32,11 +32,11 @@
LINPHONE_BEGIN_NAMESPACE LINPHONE_BEGIN_NAMESPACE
class RemoteConferenceEventHandlerPrivate : public ObjectPrivate, public CoreListener { class RemoteConferenceEventHandlerPrivate : public ObjectPrivate, public CoreListener {
friend class ClientGroupChatRoom; public:
private:
void simpleNotifyReceived (const std::string &xmlBody); void simpleNotifyReceived (const std::string &xmlBody);
void subscribe (); void subscribe ();
void unsubscribe (); void unsubscribe ();
void invalidateSubscription ();
// CoreListener // CoreListener
void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override; void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override;
......
...@@ -247,6 +247,10 @@ void RemoteConferenceEventHandlerPrivate::onEnteringForeground () { ...@@ -247,6 +247,10 @@ void RemoteConferenceEventHandlerPrivate::onEnteringForeground () {
subscribe(); subscribe();
} }
void RemoteConferenceEventHandlerPrivate::invalidateSubscription () {
lev = nullptr;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
RemoteConferenceEventHandler::RemoteConferenceEventHandler (RemoteConference *remoteConference) : RemoteConferenceEventHandler::RemoteConferenceEventHandler (RemoteConference *remoteConference) :
......
...@@ -6164,6 +6164,64 @@ end: ...@@ -6164,6 +6164,64 @@ end:
linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline);
} }
static void group_chat_room_subscription_denied (void) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc");
LinphoneCoreManager *laure = linphone_core_manager_create("laure_tcp_rc");
bctbx_list_t *coresManagerList = NULL;
bctbx_list_t *participantsAddresses = NULL;
coresManagerList = bctbx_list_append(coresManagerList, marie);
coresManagerList = bctbx_list_append(coresManagerList, pauline);
coresManagerList = bctbx_list_append(coresManagerList, laure);
bctbx_list_t *coresList = init_core_for_conference(coresManagerList);
LinphoneAddress *paulineAddress = linphone_address_new(linphone_core_get_identity(pauline->lc));
start_core_for_conference(coresManagerList);
participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_ref(paulineAddress));
participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(laure->lc)));
stats initialMarieStats = marie->stat;
stats initialPaulineStats = pauline->stat;
stats initialLaureStats = laure->stat;
// Marie creates a new group chat room
const char *initialSubject = "Colleagues";
LinphoneChatRoom *marieCr = create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, initialSubject, FALSE);
const LinphoneAddress *confAddr = linphone_chat_room_get_conference_address(marieCr);
// Check that the chat room is correctly created on Laure's side and that the participants are added
LinphoneChatRoom *paulineCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, initialSubject, 2, FALSE);
// Check that the chat room is correctly created on Laure's side and that the participants are added
LinphoneChatRoom *laureCr = check_creation_chat_room_client_side(coresList, laure, &initialLaureStats, confAddr, initialSubject, 2, FALSE);
// Simulate pauline has disconnected
linphone_core_set_network_reachable(pauline->lc, FALSE);
LinphoneParticipant *paulineParticipant = linphone_chat_room_find_participant(marieCr, paulineAddress);
BC_ASSERT_PTR_NOT_NULL(paulineParticipant);
linphone_chat_room_remove_participant(marieCr, paulineParticipant);
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_participants_removed, initialMarieStats.number_of_participants_removed + 1, 1000));
BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_participants_removed, initialPaulineStats.number_of_participants_removed + 1, 1000));
// Reconnect pauline
linphone_core_set_network_reachable(pauline->lc, TRUE);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomStateTerminated, initialPaulineStats.number_of_LinphoneChatRoomStateTerminated + 1, 1000));
// Clean db from chat room
linphone_core_manager_delete_chat_room(marie, marieCr, coresList);
linphone_core_manager_delete_chat_room(laure, laureCr, coresList);
linphone_core_manager_delete_chat_room(pauline, paulineCr, coresList);
linphone_address_unref(paulineAddress);
bctbx_list_free(coresList);
bctbx_list_free(coresManagerList);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
linphone_core_manager_destroy(laure);
}
test_t group_chat_tests[] = { test_t group_chat_tests[] = {
TEST_NO_TAG("Group chat room creation server", group_chat_room_creation_server), TEST_NO_TAG("Group chat room creation server", group_chat_room_creation_server),
TEST_ONE_TAG("Add participant", group_chat_room_add_participant, "LeaksMemory"), TEST_ONE_TAG("Add participant", group_chat_room_add_participant, "LeaksMemory"),
...@@ -6239,6 +6297,7 @@ test_t group_chat_tests[] = { ...@@ -6239,6 +6297,7 @@ test_t group_chat_tests[] = {
TEST_TWO_TAGS("LIME X3DH message to multidevice participants", group_chat_lime_x3dh_send_encrypted_message_to_multidevice_participants, "LimeX3DH", "LeaksMemory"), TEST_TWO_TAGS("LIME X3DH message to multidevice participants", group_chat_lime_x3dh_send_encrypted_message_to_multidevice_participants, "LimeX3DH", "LeaksMemory"),
TEST_TWO_TAGS("LIME X3DH messages while network unreachable", group_chat_lime_x3dh_message_while_network_unreachable, "LimeX3DH", "LeaksMemory"), TEST_TWO_TAGS("LIME X3DH messages while network unreachable", group_chat_lime_x3dh_message_while_network_unreachable, "LimeX3DH", "LeaksMemory"),
TEST_TWO_TAGS("LIME X3DH update keys", group_chat_lime_x3dh_update_keys, "LimeX3DH", "LeaksMemory"), TEST_TWO_TAGS("LIME X3DH update keys", group_chat_lime_x3dh_update_keys, "LimeX3DH", "LeaksMemory"),
TEST_ONE_TAG("Group chat room subscription denied", group_chat_room_subscription_denied, "LeaksMemory"),
}; };
test_suite_t group_chat_test_suite = { test_suite_t group_chat_test_suite = {
......
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