diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 71f42f2d0..164ae6da0 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -650,29 +650,8 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onEncryptedDevicesClick:(id)sender { - BOOL isOneToOne = linphone_chat_room_get_capabilities(_chatRoom) & LinphoneChatRoomCapabilitiesOneToOne; NSString *message = NSLocalizedString(@"Instant messages are end-to-end encrypted in secured conversations. It is possible to upgrade the security level of a conversation by authenticating participants. To do so, call the contact and follow the authentification process.",nil); BOOL notAskAgain = [LinphoneManager.instance lpConfigBoolForKey:@"confirmation_dialog_before_sas_call_not_ask_again"]; - if (isOneToOne) { - bctbx_list_t *participants = linphone_chat_room_get_participants(_chatRoom); - - LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL; - const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_chatRoom); - if (bctbx_list_size(linphone_participant_get_devices(firstParticipant)) == 1) { - if (notAskAgain) { - [LinphoneManager.instance doCallWithSas:addr isSas:TRUE]; - } else { - securityDialog = [UIConfirmationDialog ShowWithMessage:message cancelMessage:NSLocalizedString(@"CANCEL", nil) confirmMessage:NSLocalizedString(@"CALL", nil) onCancelClick:^() { - } onConfirmationClick:^() { - [LinphoneManager.instance doCallWithSas:addr isSas:TRUE]; - }]; - [_messageField resignFirstResponder]; - securityDialog.authView.hidden = FALSE; - [securityDialog setSpecialColor]; - } - return; - } - } if (notAskAgain) { [self goToDeviceListView]; diff --git a/Classes/DevicesListView.h b/Classes/DevicesListView.h index c2a6776d8..c676beb0a 100644 --- a/Classes/DevicesListView.h +++ b/Classes/DevicesListView.h @@ -11,6 +11,7 @@ @public LinphoneParticipant *participant; NSInteger numberOfDevices; + BOOL myself; }; @end @@ -22,7 +23,6 @@ @property(nonatomic) LinphoneChatRoom *room; @property bctbx_list_t *devices; @property NSMutableArray *devicesMenuEntries; -@property BOOL isOneToOne; - (IBAction)onBackClick:(id)sender; diff --git a/Classes/DevicesListView.m b/Classes/DevicesListView.m index 615cb16e5..2bffcbf50 100644 --- a/Classes/DevicesListView.m +++ b/Classes/DevicesListView.m @@ -12,10 +12,11 @@ @implementation DevicesMenuEntry -- (id)initWithTitle:(LinphoneParticipant *)par number:(NSInteger)num { +- (id)initWithTitle:(LinphoneParticipant *)par number:(NSInteger)num isMe:(BOOL)isMe{ if ((self = [super init])) { participant = par; numberOfDevices = num; + myself = isMe; } return self; } @@ -49,27 +50,33 @@ static UICompositeViewDescription *compositeDescription = nil; [super viewWillAppear:animated]; _tableView.dataSource = self; _tableView.delegate = self; - _isOneToOne = linphone_chat_room_get_capabilities(_room) & LinphoneChatRoomCapabilitiesOneToOne; bctbx_list_t *participants = linphone_chat_room_get_participants(_room); _devicesMenuEntries = [NSMutableArray array]; - if (_isOneToOne) { + if (linphone_chat_room_get_capabilities(_room) & LinphoneChatRoomCapabilitiesOneToOne) { LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL; const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_room); [ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr]; _devices = linphone_participant_get_devices(firstParticipant); + _addressLabel.text = [NSString stringWithFormat:NSLocalizedString(@"devices", nil)]; + [_devicesMenuEntries + addObject:[[DevicesMenuEntry alloc] initWithTitle:firstParticipant number:0 isMe:FALSE]]; } else { LinphoneParticipant *participant; for (int i=0; inumberOfDevices > 1 ? (entry->numberOfDevices + 1) * 56.0 : 56.0; - } - return 56.0; + DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row]; + return entry->numberOfDevices > 1 ? (entry->numberOfDevices + 1) * 56.0 : 56.0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (_isOneToOne) { - NSString *kCellId = NSStringFromClass(UIDeviceCell.class); - UIDeviceCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; - - if (cell == nil) { - cell = [[UIDeviceCell alloc] initWithIdentifier:kCellId]; - } - LinphoneParticipantDevice *device = (LinphoneParticipantDevice *)bctbx_list_nth_data(_devices, (int)[indexPath row]); - cell.device = device; - cell.isOneToOne = TRUE; - [cell update]; - - return cell; - } - NSString *kCellId = NSStringFromClass(UIDevicesDetails.class); UIDevicesDetails *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; @@ -126,7 +115,7 @@ static UICompositeViewDescription *compositeDescription = nil; DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row]; - [ContactDisplay setDisplayNameLabel:cell.addressLabel forAddress:linphone_participant_get_address(entry->participant)]; + entry->myself ? cell.addressLabel.text = NSLocalizedString(@"Me", nil) : [ContactDisplay setDisplayNameLabel:cell.addressLabel forAddress:linphone_participant_get_address(entry->participant)]; cell.participant = entry->participant; [cell update:(entry->numberOfDevices != 0)]; @@ -134,12 +123,10 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - if (!_isOneToOne) { - DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row]; - NSInteger num = (entry->numberOfDevices != 0) ? 0: bctbx_list_size(linphone_participant_get_devices(entry->participant)); - [_devicesMenuEntries replaceObjectAtIndex:indexPath.row withObject:[[DevicesMenuEntry alloc] initWithTitle:entry->participant number:num]]; - [_tableView reloadData]; - } + DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row]; + NSInteger num = (entry->numberOfDevices != 0) ? 0: bctbx_list_size(linphone_participant_get_devices(entry->participant)); + [_devicesMenuEntries replaceObjectAtIndex:indexPath.row withObject:[[DevicesMenuEntry alloc] initWithTitle:entry->participant number:num isMe:entry->myself]]; + [_tableView reloadData]; } @end diff --git a/Classes/LinphoneUI/UIDeviceCell.h b/Classes/LinphoneUI/UIDeviceCell.h index 0d41bbd60..5a62e8222 100644 --- a/Classes/LinphoneUI/UIDeviceCell.h +++ b/Classes/LinphoneUI/UIDeviceCell.h @@ -1,9 +1,21 @@ -// -// UIDeviceCell.h -// linphone -// -// Created by Danmei Chen on 07/11/2018. -// +/* UIDeviceCell.h + * + * Copyright (C) 2019 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ #import diff --git a/Classes/LinphoneUI/UIDeviceCell.m b/Classes/LinphoneUI/UIDeviceCell.m index 0118c9807..ddeb51241 100644 --- a/Classes/LinphoneUI/UIDeviceCell.m +++ b/Classes/LinphoneUI/UIDeviceCell.m @@ -1,9 +1,21 @@ -// -// UIDeviceCell.m -// linphone -// -// Created by Danmei Chen on 07/11/2018. -// +/* UIDeviceCell.m + * + * Copyright (C) 2019 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ #import "UIDeviceCell.h" diff --git a/Classes/LinphoneUI/UIDevicesDetails.h b/Classes/LinphoneUI/UIDevicesDetails.h index f69c2d10b..aa556287d 100644 --- a/Classes/LinphoneUI/UIDevicesDetails.h +++ b/Classes/LinphoneUI/UIDevicesDetails.h @@ -1,10 +1,21 @@ -// -// UIDevicesDetails.h -// linphone -// -// Created by Danmei Chen on 06/11/2018. -// - +/* UIDevicesDetails.h + * + * Copyright (C) 2019 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ #import @interface UIDevicesDetails : UITableViewCell diff --git a/Classes/LinphoneUI/UIDevicesDetails.m b/Classes/LinphoneUI/UIDevicesDetails.m index 3f2abcad5..b5530cccd 100644 --- a/Classes/LinphoneUI/UIDevicesDetails.m +++ b/Classes/LinphoneUI/UIDevicesDetails.m @@ -1,10 +1,21 @@ -// -// UIDevicesDetails.m -// linphone -// -// Created by Danmei Chen on 06/11/2018. -// - +/* UIDevicesDetails.m + * + * Copyright (C) 2019 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ #import "UIDevicesDetails.h" #import "UIDeviceCell.h"