From 7024dd3a5a6b581a83290c27ebb8caa75ccb0732 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Mon, 30 Oct 2017 15:41:43 +0100 Subject: [PATCH] fix UI crashes concerning group chat --- Classes/ChatConversationInfoView.m | 6 ++++++ Classes/ChatConversationTableView.h | 3 +++ Classes/ChatConversationView.m | 15 ++++++++++----- Classes/LinphoneUI/UIChatCell.m | 4 ++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Classes/ChatConversationInfoView.m b/Classes/ChatConversationInfoView.m index 4ad75178d..13bbd03d5 100644 --- a/Classes/ChatConversationInfoView.m +++ b/Classes/ChatConversationInfoView.m @@ -73,6 +73,9 @@ static UICompositeViewDescription *compositeDescription = nil; bctbx_list_t *addresses = NULL; for(NSString *addr in _contacts.allKeys) { LinphoneAddress *linphoneAddress = linphone_address_new(addr.UTF8String); + if (!linphoneAddress) + continue; + if (!addresses) { addresses = bctbx_list_new((void *)linphoneAddress); continue; @@ -105,6 +108,9 @@ static UICompositeViewDescription *compositeDescription = nil; view.tableController.contactsGroup = [[_contacts allKeys] mutableCopy]; view.tableController.notFirstTime = TRUE; [PhoneMainView.instance popToView:view.compositeViewDescription]; + } else { + ChatConversationView *view = VIEW(ChatConversationView); + [PhoneMainView.instance popToView:view.compositeViewDescription]; } } diff --git a/Classes/ChatConversationTableView.h b/Classes/ChatConversationTableView.h index 57e37929b..04a0b081d 100644 --- a/Classes/ChatConversationTableView.h +++ b/Classes/ChatConversationTableView.h @@ -20,6 +20,9 @@ #import #include "linphone/linphonecore.h" +#import "linphone/c-event-log.h" +#import "linphone/c-chat-room.h" + #import "UICheckBoxTableView.h" @protocol ChatConversationDelegate diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index b5f6f09c1..49686ccb4 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -129,9 +129,10 @@ static UICompositeViewDescription *compositeDescription = nil; [self callUpdateEvent:nil]; PhoneMainView.instance.currentRoom = self.chatRoom; - _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom)]; + if (linphone_chat_room_get_subject(_chatRoom)) + _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom)]; - if (linphone_chat_room_get_nb_participants(_chatRoom) == 1) { + if (!linphone_chat_room_can_handle_participants(_chatRoom)) { _particpantsLabel.hidden = TRUE; } else { _particpantsLabel.hidden = FALSE; @@ -142,7 +143,9 @@ static UICompositeViewDescription *compositeDescription = nil; if (![_particpantsLabel.text isEqualToString:@""]) _particpantsLabel.text = [_particpantsLabel.text stringByAppendingString:@", "]; - _particpantsLabel.text = [_particpantsLabel.text stringByAppendingString:[NSString stringWithUTF8String:linphone_address_get_display_name(linphone_participant_get_address(participant))]]; + _particpantsLabel.text = [_particpantsLabel.text stringByAppendingString:[NSString stringWithUTF8String:linphone_address_get_display_name(linphone_participant_get_address(participant)) + ? linphone_address_get_display_name(linphone_participant_get_address(participant)) + : linphone_address_get_username(linphone_participant_get_address(participant))]]; participants = participants->next; } } @@ -356,7 +359,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)updateSuperposedButtons { [_backToCallButton update]; - _infoButton.hidden = (linphone_chat_room_get_nb_participants(_chatRoom) == 1) || !_backToCallButton.hidden; + _infoButton.hidden = !linphone_chat_room_can_handle_participants(_chatRoom) || !_backToCallButton.hidden; _callButton.hidden = !_backToCallButton.hidden && !_infoButton.hidden; } @@ -523,7 +526,9 @@ static UICompositeViewDescription *compositeDescription = nil; bctbx_list_t *participants = linphone_chat_room_get_participants(_chatRoom); while (participants) { LinphoneParticipant *participant = (LinphoneParticipant *)participants->data; - NSString *name = [NSString stringWithUTF8String:linphone_address_get_display_name(linphone_participant_get_address(participant))]; + NSString *name = [NSString stringWithUTF8String:linphone_address_get_display_name(linphone_participant_get_address(participant)) + ? linphone_address_get_display_name(linphone_participant_get_address(participant)) + : linphone_address_get_username(linphone_participant_get_address(participant))]; NSString *uri = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(linphone_participant_get_address(participant))]; [contactsDict setObject:name forKey:uri]; diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index 225761f06..9304ac2d2 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -64,8 +64,8 @@ return; } - if(linphone_chat_room_get_nb_participants(chatRoom) > 1) { - _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(chatRoom)]; + if(linphone_chat_room_can_handle_participants(chatRoom)) { + _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(chatRoom) ? linphone_chat_room_get_subject(chatRoom) : "No subject"]; [_avatarImage setImage:[UIImage imageNamed:@"chat_group_avatar.png"] bordered:NO withRoundedRadius:YES]; } else { const LinphoneAddress *addr = linphone_chat_room_get_peer_address(chatRoom);