From d14a0d3c109469064340d5614f33264234632d58 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Fri, 8 Jul 2022 17:21:31 +0200 Subject: [PATCH] =?UTF-8?q?In=20group=20chatrooms,=20added=20the=20?= =?UTF-8?q?=E2=80=9Cadd=20to=20contact=E2=80=9D=20contextual=20action=20wh?= =?UTF-8?q?en=20interacting=20with=20a=20message=20coming=20from=20someone?= =?UTF-8?q?=20that=20is=20not=20registered=20in=20your=20phone=20contacts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/LinphoneUI/UIChatBubbleTextCell.m | 29 ++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 425aff9cb..487a2bb37 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -897,7 +897,9 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18; [VIEW(ChatConversationView) initiateReplyViewForMessage:message]; }]; - if (linphone_chat_room_get_nb_participants(linphone_chat_message_get_chat_room(self.message)) > 1) { + LinphoneChatRoom *chatroom = linphone_chat_message_get_chat_room(self.message); + + if (linphone_chat_room_get_nb_participants(chatroom) > 1) { [_messageActionsTitles addObject:NSLocalizedString(@"Infos", nil)]; [_messageActionsIcons addObject:@"menu_info"]; [_messageActionsBlocks addObject:^{ @@ -907,6 +909,31 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; }]; } + + if (!linphone_chat_message_is_outgoing(self.message) + && [FastAddressBook getContactWithAddress:linphone_chat_message_get_from_address(self.message)] == nil + && !(linphone_chat_room_get_capabilities(chatroom) & LinphoneChatRoomCapabilitiesOneToOne) ) { + + LinphoneAddress *fromAddress = linphone_address_clone(linphone_chat_message_get_from_address(self.message)); + [_messageActionsTitles addObject:NSLocalizedString(@"Add to contact", nil)]; + [_messageActionsIcons addObject:@"contact_add_default"]; + [_messageActionsBlocks addObject:^{ + [thiz dismissPopup]; + linphone_address_clean(fromAddress); + char *lAddress = linphone_address_as_string_uri_only(fromAddress); + if (lAddress != NULL) { + NSString *normSip = [NSString stringWithUTF8String:lAddress]; + normSip = [normSip hasPrefix:@"sip:"] ? [normSip substringFromIndex:4] : normSip; + normSip = [normSip hasPrefix:@"sips:"] ? [normSip substringFromIndex:5] : normSip; + [ContactSelection setAddAddress:normSip]; + [ContactSelection setSelectionMode:ContactSelectionModeEdit]; + [ContactSelection enableSipFilter:FALSE]; + [PhoneMainView.instance changeCurrentView:ContactsListView.compositeViewDescription]; + ms_free(lAddress); + } + linphone_address_unref(fromAddress); + }]; + } [_messageActionsTitles addObject:NSLocalizedString(@"Delete", nil)]; [_messageActionsIcons addObject:@"menu_delete"];