From 8283bccf220d24056ce34fedc7c3b5316fdbec71 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 10 Nov 2017 15:08:14 +0100 Subject: [PATCH] better use of API --- Classes/ChatConversationInfoView.m | 25 +++++++++++++++++++++---- submodules/linphone | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Classes/ChatConversationInfoView.m b/Classes/ChatConversationInfoView.m index c7b58bdfa..59825c50a 100644 --- a/Classes/ChatConversationInfoView.m +++ b/Classes/ChatConversationInfoView.m @@ -120,28 +120,45 @@ static UICompositeViewDescription *compositeDescription = nil; linphone_chat_room_set_subject(_room, _nameLabel.text.UTF8String); // Add participants if necessary + bctbx_list_t *addedPartipants = NULL; for (NSString *uri in _contacts.allKeys) { if ([_oldContacts objectForKey:uri]) continue; LinphoneAddress *addr = linphone_address_new(uri.UTF8String); - linphone_chat_room_add_participant(_room, addr); - linphone_address_unref(addr); + if (addedPartipants) + addedPartipants = bctbx_list_append(addedPartipants, addr); + else + addedPartipants = bctbx_list_new(addr); + } + if (addedPartipants) { + linphone_chat_room_add_participants(_room, addedPartipants); + bctbx_list_free_with_data(addedPartipants, (void (*)(void *))linphone_address_unref); } + // Remove participants if necessary + bctbx_list_t *removedPartipants = NULL; for (NSString *uri in _oldContacts.allKeys) { if ([_contacts objectForKey:uri]) continue; LinphoneAddress *addr = linphone_address_new(uri.UTF8String); - LinphoneParticipant *participant = linphone_chat_room_find_participant(_room, addr); + LinphoneParticipant *participant = linphone_participant_ref(linphone_chat_room_find_participant(_room, addr)); if (!participant) continue; - linphone_chat_room_remove_participant(_room, participant); + if (removedPartipants) + removedPartipants = bctbx_list_append(removedPartipants, participant); + else + removedPartipants = bctbx_list_new(participant); + linphone_address_unref(addr); } + if (removedPartipants) { + linphone_chat_room_remove_participants(_room, removedPartipants); + bctbx_list_free_with_data(removedPartipants, (void (*)(void *))linphone_participant_unref); + } // add admins if necessary for (NSString *admin in _admins) { diff --git a/submodules/linphone b/submodules/linphone index e536ded32..33edd95a1 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit e536ded32d85483e834f541ef3986a6ae13bf618 +Subproject commit 33edd95a159680c5ab1a1472dbbe508916dd49e9