forked from mirrors/linphone-iphone
ZRTP: add confirmation popup on call start
This commit is contained in:
parent
43e3d7ef4e
commit
620200be2f
12 changed files with 75 additions and 43 deletions
|
|
@ -452,6 +452,8 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
|
|||
[NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d messages?", nil),
|
||||
_tableController.selectedItems.count];
|
||||
[UIConfirmationDialog ShowWithMessage:msg
|
||||
cancelMessage:nil
|
||||
confirmMessage:nil
|
||||
onCancelClick:^() {
|
||||
[self onEditionChangeClick:nil];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d conversations?", nil),
|
||||
_tableController.selectedItems.count];
|
||||
[UIConfirmationDialog ShowWithMessage:msg
|
||||
cancelMessage:nil
|
||||
confirmMessage:nil
|
||||
onCancelClick:^() {
|
||||
[self onEditionChangeClick:nil];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,6 +260,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
- (IBAction)onDeleteClick:(id)sender {
|
||||
NSString *msg = NSLocalizedString(@"Are you sure that you want to delete your contact?", nil);
|
||||
[UIConfirmationDialog ShowWithMessage:msg
|
||||
cancelMessage:nil
|
||||
confirmMessage:nil
|
||||
onCancelClick:nil
|
||||
onConfirmationClick:^() {
|
||||
[self setEditing:FALSE];
|
||||
|
|
|
|||
|
|
@ -205,6 +205,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d contacts?", nil),
|
||||
tableController.selectedItems.count];
|
||||
[UIConfirmationDialog ShowWithMessage:msg
|
||||
cancelMessage:nil
|
||||
confirmMessage:nil
|
||||
onCancelClick:^() {
|
||||
[self onEditionChangeClick:nil];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d history?", nil),
|
||||
_tableController.selectedItems.count];
|
||||
[UIConfirmationDialog ShowWithMessage:msg
|
||||
cancelMessage:nil
|
||||
confirmMessage:nil
|
||||
onCancelClick:^() {
|
||||
[self onEditionChangeClick:nil];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
@ -86,6 +87,9 @@
|
|||
<state key="normal" title="Registered" image="led_disconnected.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onRegistrationStateClick:" destination="-1" eventType="touchUpInside" id="erb-GT-Zef"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
|
|
@ -94,12 +98,12 @@
|
|||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="call_quality_indicator_4.png" width="20" height="20"/>
|
||||
<image name="color_A.png" width="1" height="1"/>
|
||||
<image name="led_disconnected.png" width="12" height="12"/>
|
||||
<image name="menu.png" width="19" height="19"/>
|
||||
<image name="security_ok.png" width="13" height="17"/>
|
||||
<image name="voicemail.png" width="26" height="12"/>
|
||||
<image name="call_quality_indicator_4.png" width="19" height="19"/>
|
||||
<image name="color_A.png" width="2" height="2"/>
|
||||
<image name="led_disconnected.png" width="11" height="11"/>
|
||||
<image name="menu.png" width="19" height="18"/>
|
||||
<image name="security_ok.png" width="13" height="18"/>
|
||||
<image name="voicemail.png" width="25" height="12"/>
|
||||
</resources>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TPMultiLayoutViewController.h"
|
||||
#import "DTActionSheet.h"
|
||||
#import "UIConfirmationDialog.h"
|
||||
|
||||
@interface StatusBarView : TPMultiLayoutViewController <UIActionSheetDelegate> {
|
||||
DTActionSheet *securitySheet;
|
||||
@interface StatusBarView : TPMultiLayoutViewController {
|
||||
UIConfirmationDialog *securityDialog;
|
||||
}
|
||||
|
||||
@property(weak, nonatomic) IBOutlet UIButton *registrationState;
|
||||
|
|
@ -35,5 +35,6 @@
|
|||
|
||||
- (IBAction)onSecurityClick:(id)sender;
|
||||
- (IBAction)onSideMenuClick:(id)sender;
|
||||
- (IBAction)onRegistrationStateClick:(id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -139,6 +139,12 @@
|
|||
// show voice mail only when there is no call
|
||||
[self updateUI:linphone_core_get_calls([LinphoneManager getLc]) != NULL];
|
||||
[self updateVoicemail];
|
||||
|
||||
LinphoneCall *currentCall = linphone_core_get_current_call([LinphoneManager getLc]);
|
||||
if (currentCall && !linphone_call_get_authentication_token_verified(currentCall) &&
|
||||
linphone_call_get_state(currentCall) == LinphoneCallStreamsRunning) {
|
||||
[self onSecurityClick:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
|
@ -242,8 +248,8 @@
|
|||
|
||||
const MSList *list = linphone_core_get_calls([LinphoneManager getLc]);
|
||||
if (list == NULL) {
|
||||
if (securitySheet) {
|
||||
[securitySheet dismissWithClickedButtonIndex:securitySheet.destructiveButtonIndex animated:TRUE];
|
||||
if (securityDialog) {
|
||||
[securityDialog dismiss];
|
||||
}
|
||||
} else {
|
||||
callSecurityButton.hidden = NO;
|
||||
|
|
@ -291,29 +297,22 @@
|
|||
linphone_call_params_get_media_encryption(linphone_call_get_current_params(call));
|
||||
if (enc == LinphoneMediaEncryptionZRTP) {
|
||||
bool valid = linphone_call_get_authentication_token_verified(call);
|
||||
NSString *message = nil;
|
||||
if (valid) {
|
||||
message = NSLocalizedString(@"Remove trust in the peer?", nil);
|
||||
} else {
|
||||
message = [NSString
|
||||
stringWithFormat:NSLocalizedString(@"Confirm the following SAS with the peer:\n%s", nil),
|
||||
linphone_call_get_authentication_token(call)];
|
||||
}
|
||||
if (securitySheet == nil) {
|
||||
NSString *message =
|
||||
[NSString stringWithFormat:NSLocalizedString(@"Confirm the following SAS with peer:\n%s", nil),
|
||||
linphone_call_get_authentication_token(call)];
|
||||
if (securityDialog == nil) {
|
||||
__block __strong StatusBarView *weakSelf = self;
|
||||
securitySheet = [[DTActionSheet alloc] initWithTitle:message];
|
||||
[securitySheet setDelegate:self];
|
||||
[securitySheet addButtonWithTitle:NSLocalizedString(@"Ok", nil)
|
||||
block:^() {
|
||||
linphone_call_set_authentication_token_verified(call, !valid);
|
||||
weakSelf->securitySheet = nil;
|
||||
}];
|
||||
|
||||
[securitySheet addDestructiveButtonWithTitle:NSLocalizedString(@"Cancel", nil)
|
||||
block:^() {
|
||||
weakSelf->securitySheet = nil;
|
||||
}];
|
||||
[securitySheet showInView:PhoneMainView.instance.view];
|
||||
[UIConfirmationDialog ShowWithMessage:message
|
||||
cancelMessage:NSLocalizedString(@"DENY", nil)
|
||||
confirmMessage:NSLocalizedString(@"ACCEPT", nil)
|
||||
onCancelClick:^() {
|
||||
linphone_call_set_authentication_token_verified(call, NO);
|
||||
weakSelf->securityDialog = nil;
|
||||
}
|
||||
onConfirmationClick:^() {
|
||||
linphone_call_set_authentication_token_verified(call, !valid);
|
||||
weakSelf->securityDialog = nil;
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -329,8 +328,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||
securitySheet = nil;
|
||||
- (IBAction)onRegistrationStateClick:(id)sender {
|
||||
linphone_core_refresh_registers([LinphoneManager getLc]);
|
||||
}
|
||||
|
||||
#pragma mark - TPMultiLayoutViewController Functions
|
||||
|
|
|
|||
|
|
@ -11,12 +11,13 @@
|
|||
typedef void (^UIConfirmationBlock)(void);
|
||||
|
||||
@interface UIConfirmationDialog : UIViewController {
|
||||
|
||||
UIConfirmationBlock onCancelCb;
|
||||
UIConfirmationBlock onConfirmCb;
|
||||
}
|
||||
|
||||
+ (void)ShowWithMessage:(NSString *)message
|
||||
cancelMessage:(NSString *)cancel
|
||||
confirmMessage:(NSString *)confirm
|
||||
onCancelClick:(UIConfirmationBlock)onCancel
|
||||
onConfirmationClick:(UIConfirmationBlock)onConfirm;
|
||||
|
||||
|
|
@ -25,5 +26,5 @@ typedef void (^UIConfirmationBlock)(void);
|
|||
@property(weak, nonatomic) IBOutlet UILabel *titleLabel;
|
||||
- (IBAction)onCancelClick:(id)sender;
|
||||
- (IBAction)onConfirmationClick:(id)sender;
|
||||
|
||||
- (void)dismiss;
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
@implementation UIConfirmationDialog
|
||||
|
||||
+ (void)ShowWithMessage:(NSString *)message
|
||||
cancelMessage:(NSString *)cancel
|
||||
confirmMessage:(NSString *)confirm
|
||||
onCancelClick:(UIConfirmationBlock)onCancel
|
||||
onConfirmationClick:(UIConfirmationBlock)onConfirm {
|
||||
UIConfirmationDialog *dialog =
|
||||
|
|
@ -24,6 +26,13 @@
|
|||
dialog->onConfirmCb = onConfirm;
|
||||
|
||||
[dialog.titleLabel setText:message];
|
||||
if (cancel) {
|
||||
[dialog.cancelButton setTitle:cancel forState:UIControlStateNormal];
|
||||
}
|
||||
if (confirm) {
|
||||
[dialog.confirmationButton setTitle:confirm forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
dialog.confirmationButton.layer.borderColor =
|
||||
[[UIColor colorWithPatternImage:[UIImage imageNamed:@"color_A.png"]] CGColor];
|
||||
dialog.cancelButton.layer.borderColor =
|
||||
|
|
@ -45,4 +54,8 @@
|
|||
onConfirmCb();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dismiss {
|
||||
[self onCancelClick:nil];
|
||||
}
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
@ -58,9 +59,9 @@
|
|||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="color_A.png" width="1" height="1"/>
|
||||
<image name="color_C.png" width="1" height="1"/>
|
||||
<image name="color_F.png" width="1" height="1"/>
|
||||
<image name="color_A.png" width="2" height="2"/>
|
||||
<image name="color_C.png" width="2" height="2"/>
|
||||
<image name="color_F.png" width="2" height="2"/>
|
||||
</resources>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@
|
|||
UIControlStateSelected | UIControlStateHighlighted,
|
||||
UIControlStateSelected | UIControlStateDisabled};
|
||||
for (int i = 0; i < sizeof(states) / sizeof(UIControlState); i++) {
|
||||
[self setTitle:[[self titleForState:states[i]] uppercaseString] forState:states[i]];
|
||||
if (![[self titleForState:UIControlStateNormal]
|
||||
.uppercaseString isEqualToString:[self titleForState:states[i]]]) {
|
||||
[self setTitle:[[self titleForState:states[i]] uppercaseString] forState:states[i]];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue