diff --git a/Classes/ChatConversationView.h b/Classes/ChatConversationView.h
index 921b41a9b..6d6cd4834 100644
--- a/Classes/ChatConversationView.h
+++ b/Classes/ChatConversationView.h
@@ -28,6 +28,7 @@
#import "UIBackToCallButton.h"
#import "Utils/HPGrowingTextView/HPGrowingTextView.h"
#import "UIImageViewDeletable.h"
+#import "UIConfirmationDialog.h"
#include "linphone/linphonecore.h"
@@ -37,6 +38,7 @@
OrderedDictionary *imageQualities;
BOOL scrollOnGrowingEnabled;
BOOL composingVisible;
+ UIConfirmationDialog *securityDialog;
}
@property(nonatomic) LinphoneChatRoom *chatRoom;
diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m
index 3c9a245b7..e5bfa4f42 100644
--- a/Classes/ChatConversationView.m
+++ b/Classes/ChatConversationView.m
@@ -37,6 +37,7 @@ static NSString* groupName = @"group.belledonne-communications.linphone";
scrollOnGrowingEnabled = TRUE;
_chatRoom = NULL;
_chatRoomCbs = NULL;
+ securityDialog = NULL;
imageQualities = [[OrderedDictionary alloc]
initWithObjectsAndKeys:[NSNumber numberWithFloat:0.9], NSLocalizedString(@"Maximum", nil),
[NSNumber numberWithFloat:0.5], NSLocalizedString(@"Average", nil),
@@ -572,10 +573,40 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (IBAction)onEncryptedDevicesClick:(id)sender {
- DevicesListView *view = VIEW(DevicesListView);
- view.room = _chatRoom;
+ 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);
- [PhoneMainView.instance popToView:view.compositeViewDescription];
+ 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 (securityDialog && securityDialog.notAskAgain) {
+ [LinphoneManager.instance doCall:addr];
+ } else {
+ securityDialog = [UIConfirmationDialog ShowWithMessage:message cancelMessage:NSLocalizedString(@"CANCELL", nil) confirmMessage:NSLocalizedString(@"CALL", nil) onCancelClick:^() {
+ } onConfirmationClick:^() {
+ [LinphoneManager.instance doCall:addr];
+ }];
+ securityDialog.authView.hidden = FALSE;
+ }
+ return;
+ }
+ }
+
+ if (securityDialog && securityDialog.notAskAgain) {
+ [self goToDeviceListView];
+ } else {
+ securityDialog = [UIConfirmationDialog ShowWithMessage:message cancelMessage:NSLocalizedString(@"CANCELL", nil) confirmMessage:NSLocalizedString(@"OK", nil) onCancelClick:^() {
+ } onConfirmationClick:^() {
+ DevicesListView *view = VIEW(DevicesListView);
+ view.room = _chatRoom;
+
+ [PhoneMainView.instance popToView:view.compositeViewDescription];
+ }];
+ securityDialog.authView.hidden = FALSE;
+ }
}
- (IBAction)onCallClick:(id)sender {
@@ -937,6 +968,12 @@ void on_chat_room_conference_left(LinphoneChatRoom *cr, const LinphoneEventLog *
[view.tableController scrollToBottom:true];
}
+- (void)goToDeviceListView {
+ DevicesListView *view = VIEW(DevicesListView);
+ view.room = _chatRoom;
+ [PhoneMainView.instance popToView:view.compositeViewDescription];
+}
+
- (void)openFile:(NSString *) filePath
{
// Open the controller.
diff --git a/Classes/DevicesListView.m b/Classes/DevicesListView.m
index 0b5b274b2..a08552251 100644
--- a/Classes/DevicesListView.m
+++ b/Classes/DevicesListView.m
@@ -95,8 +95,7 @@ static UICompositeViewDescription *compositeDescription = nil;
{
if (!_isOneToOne) {
DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row];
- return (entry->numberOfDevices + 1) * 56.0;
-
+ return entry->numberOfDevices > 1 ? (entry->numberOfDevices + 1) * 56.0 : 56.0;
}
return 56.0;
}
@@ -129,8 +128,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[ContactDisplay setDisplayNameLabel:cell.addressLabel forAddress:linphone_participant_get_address(entry->participant)];
cell.devices = linphone_participant_get_devices(entry->participant);
- UIImage *image = (entry->numberOfDevices != 0) ? [UIImage imageNamed:@"chevron_list_open"] : [UIImage imageNamed:@"chevron_list_close"];
- [cell.dropMenuButton setImage:image forState:UIControlStateNormal];
+ [cell update:(entry->numberOfDevices != 0)];
return cell;
}
diff --git a/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib b/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib
index 309f0201f..156520643 100644
--- a/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib
+++ b/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib
@@ -11,6 +11,8 @@
+
+
@@ -36,7 +38,7 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Classes/LinphoneUI/UIConfirmationDialog.h b/Classes/LinphoneUI/UIConfirmationDialog.h
index 3779d2bd8..89f52ff95 100644
--- a/Classes/LinphoneUI/UIConfirmationDialog.h
+++ b/Classes/LinphoneUI/UIConfirmationDialog.h
@@ -35,8 +35,13 @@ typedef void (^UIConfirmationBlock)(void);
@property(weak, nonatomic) IBOutlet UIRoundBorderedButton *cancelButton;
@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
@property(weak, nonatomic) IBOutlet UIRoundBorderedButton *confirmationButton;
+@property (weak, nonatomic) IBOutlet UIView *authView;
@property(weak, nonatomic) IBOutlet UILabel *titleLabel;
+@property (weak, nonatomic) IBOutlet UIButton *authButton;
+@property BOOL notAskAgain;
+
- (IBAction)onCancelClick:(id)sender;
- (IBAction)onConfirmationClick:(id)sender;
+- (IBAction)onAuthClick:(id)sender;
- (void)dismiss;
@end
diff --git a/Classes/LinphoneUI/UIConfirmationDialog.m b/Classes/LinphoneUI/UIConfirmationDialog.m
index d798e1242..909f605a5 100644
--- a/Classes/LinphoneUI/UIConfirmationDialog.m
+++ b/Classes/LinphoneUI/UIConfirmationDialog.m
@@ -24,6 +24,7 @@
dialog->onCancelCb = onCancel;
dialog->onConfirmCb = onConfirm;
+ dialog.notAskAgain = FALSE;
if (cancel) {
[dialog.cancelButton setTitle:cancel forState:UIControlStateNormal];
@@ -91,6 +92,12 @@
}
}
+- (IBAction)onAuthClick:(id)sender {
+ _notAskAgain = !_notAskAgain;
+ UIImage *image = _notAskAgain ? [UIImage imageNamed:@"checkbox_checked.png"] : [UIImage imageNamed:@"checkbox_unchecked.png"];
+ [_authButton setImage:image forState:UIControlStateNormal];
+}
+
- (void)dismiss {
[self onCancelClick:nil];
}
diff --git a/Classes/LinphoneUI/UIDeviceCell.h b/Classes/LinphoneUI/UIDeviceCell.h
index 96e58963e..bee4bafe4 100644
--- a/Classes/LinphoneUI/UIDeviceCell.h
+++ b/Classes/LinphoneUI/UIDeviceCell.h
@@ -10,10 +10,11 @@
@interface UIDeviceCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *deviceLabel;
-@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
+@property (weak, nonatomic) IBOutlet UIButton *securityButton;
@property LinphoneParticipantDevice *device;
@property BOOL isOneToOne;
+- (IBAction)onSecurityCallClick:(id)sender;
- (id)initWithIdentifier:(NSString *)identifier;
- (void)update;
@end
diff --git a/Classes/LinphoneUI/UIDeviceCell.m b/Classes/LinphoneUI/UIDeviceCell.m
index 03a987aca..c1ad88c97 100644
--- a/Classes/LinphoneUI/UIDeviceCell.m
+++ b/Classes/LinphoneUI/UIDeviceCell.m
@@ -24,7 +24,7 @@
}
- (void)update {
- [_securityImage setImage:[FastAddressBook imageForSecurityLevel:linphone_participant_device_get_security_level(_device)]];
+ [_securityButton setImage:[FastAddressBook imageForSecurityLevel:linphone_participant_device_get_security_level(_device)] forState:UIControlStateNormal];
_deviceLabel.text = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(linphone_participant_device_get_address(_device))];
if (_isOneToOne) {
@@ -36,5 +36,12 @@
self.selectionStyle =UITableViewCellSelectionStyleNone;
}
+- (IBAction)onSecurityCallClick:(id)sender {
+ const LinphoneAddress *addr = linphone_participant_device_get_address(_device);
+ if (addr)
+ [LinphoneManager.instance doCall:addr];
+ else
+ LOGE(@"CallKit : No call address");
+}
@end
diff --git a/Classes/LinphoneUI/UIDeviceCell.xib b/Classes/LinphoneUI/UIDeviceCell.xib
index cac996e45..01f730bf3 100644
--- a/Classes/LinphoneUI/UIDeviceCell.xib
+++ b/Classes/LinphoneUI/UIDeviceCell.xib
@@ -13,7 +13,7 @@
-
+
@@ -25,10 +25,6 @@
-
-
-
-
+
diff --git a/Classes/LinphoneUI/UIDevicesDetails.h b/Classes/LinphoneUI/UIDevicesDetails.h
index fef26874e..5d45c268b 100644
--- a/Classes/LinphoneUI/UIDevicesDetails.h
+++ b/Classes/LinphoneUI/UIDevicesDetails.h
@@ -13,8 +13,11 @@
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
+@property (weak, nonatomic) IBOutlet UIButton *securityButton;
@property (weak, nonatomic) IBOutlet UITableView *devicesTable;
@property bctbx_list_t *devices;
+- (IBAction)onSecurityCallClick:(id)sender;
- (id)initWithIdentifier:(NSString *)identifier;
+- (void)update:(BOOL)listOpen;
@end
diff --git a/Classes/LinphoneUI/UIDevicesDetails.m b/Classes/LinphoneUI/UIDevicesDetails.m
index 1b529ab22..84964d56d 100644
--- a/Classes/LinphoneUI/UIDevicesDetails.m
+++ b/Classes/LinphoneUI/UIDevicesDetails.m
@@ -26,6 +26,24 @@
return self;
}
+- (void)update:(BOOL)listOpen {
+ if (bctbx_list_size(_devices) == 1) {
+ _securityButton.hidden = FALSE;
+ _dropMenuButton.hidden = TRUE;
+ } else {
+ UIImage *image = listOpen ? [UIImage imageNamed:@"chevron_list_open"] : [UIImage imageNamed:@"chevron_list_close"];
+ [_dropMenuButton setImage:image forState:UIControlStateNormal];
+ }
+}
+
+- (IBAction)onSecurityCallClick:(id)sender {
+ LinphoneParticipantDevice *device = (LinphoneParticipantDevice *)bctbx_list_nth_data(_devices, 0);
+ const LinphoneAddress *addr = linphone_participant_device_get_address(device);
+ if (addr)
+ [LinphoneManager.instance doCall:addr];
+ else
+ LOGE(@"CallKit : No call address");
+}
#pragma mark - TableView
diff --git a/Classes/LinphoneUI/UIDevicesDetails.xib b/Classes/LinphoneUI/UIDevicesDetails.xib
index 49cd71cf4..165f8a872 100644
--- a/Classes/LinphoneUI/UIDevicesDetails.xib
+++ b/Classes/LinphoneUI/UIDevicesDetails.xib
@@ -16,6 +16,7 @@
+
@@ -49,6 +50,14 @@
+