fix sas call and popup view

This commit is contained in:
Danmei Chen 2018-11-09 15:15:55 +01:00
parent 122cbcfbb7
commit 6a66c97f97
10 changed files with 82 additions and 60 deletions

View file

@ -232,6 +232,23 @@ static UICompositeViewDescription *compositeDescription = nil;
// reseting speaker button because no more call
_speakerButton.selected = FALSE;
}
NSString *address = [LinphoneManager.instance lpConfigStringForKey:@"sas_dialog_denied"];
if (address) {
UIConfirmationDialog *securityDialog = [UIConfirmationDialog ShowWithMessage:NSLocalizedString(@"Trust has been denied. Make a call to start the authentication process again.", nil)
cancelMessage:NSLocalizedString(@"CANCELL", nil)
confirmMessage:NSLocalizedString(@"CALL", nil)
onCancelClick:^() {
}
onConfirmationClick:^() {
LinphoneAddress *addr = linphone_address_new(address.UTF8String);
[LinphoneManager.instance doCallWithSas:addr isSas:TRUE];
linphone_address_unref(addr);
} ];
[securityDialog.securityImage setImage:[UIImage imageNamed:@"security_alert_indicator.png"]];
securityDialog.securityImage.hidden = FALSE;
[LinphoneManager.instance lpConfigSetString:nil forKey:@"sas_dialog_denied"];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {

View file

@ -575,19 +575,19 @@ 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 (securityDialog && securityDialog.notAskAgain) {
[LinphoneManager.instance doCall:addr];
if (notAskAgain) {
[LinphoneManager.instance doCallWithSas:addr isSas:TRUE];
} else {
securityDialog = [UIConfirmationDialog ShowWithMessage:message cancelMessage:NSLocalizedString(@"CANCELL", nil) confirmMessage:NSLocalizedString(@"CALL", nil) onCancelClick:^() {
} onConfirmationClick:^() {
[LinphoneManager.instance doCall:addr];
[LinphoneManager.instance doCallWithSas:addr isSas:TRUE];
}];
securityDialog.authView.hidden = FALSE;
}
@ -595,15 +595,12 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
if (securityDialog && securityDialog.notAskAgain) {
if (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];
[self goToDeviceListView];
}];
securityDialog.authView.hidden = FALSE;
}

View file

@ -165,6 +165,7 @@ typedef struct _LinphoneManagerSounds {
- (void)send:(NSString *)replyText toChatRoom:(LinphoneChatRoom *)room;
- (void)call:(const LinphoneAddress *)address;
- (BOOL)doCall:(const LinphoneAddress *)iaddr;
- (BOOL)doCallWithSas:(const LinphoneAddress *)iaddr isSas:(BOOL)isSas;
+(id)getMessageAppDataForKey:(NSString*)key inMessage:(LinphoneChatMessage*)msg;
+(void)setValueInMessageAppData:(id)value forKey:(NSString*)key inMessage:(LinphoneChatMessage*)msg;

View file

@ -2717,54 +2717,60 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
}
- (BOOL)doCall:(const LinphoneAddress *)iaddr {
LinphoneAddress *addr = linphone_address_clone(iaddr);
NSString *displayName = [FastAddressBook displayNameForAddress:addr];
return [self doCallWithSas:iaddr isSas:false];
}
// Finally we can make the call
LinphoneCallParams *lcallParams = linphone_core_create_call_params(theLinphoneCore, NULL);
if ([self lpConfigBoolForKey:@"edge_opt_preference"] && (self.network == network_2g)) {
LOGI(@"Enabling low bandwidth mode");
linphone_call_params_enable_low_bandwidth(lcallParams, YES);
}
if (displayName != nil) {
linphone_address_set_display_name(addr, displayName.UTF8String);
}
if ([LinphoneManager.instance lpConfigBoolForKey:@"override_domain_with_default_one"]) {
linphone_address_set_domain(
addr, [[LinphoneManager.instance lpConfigStringForKey:@"domain" inSection:@"assistant"] UTF8String]);
}
LinphoneCall *call;
if (LinphoneManager.instance.nextCallIsTransfer) {
char *caddr = linphone_address_as_string(addr);
call = linphone_core_get_current_call(theLinphoneCore);
linphone_call_transfer(call, caddr);
LinphoneManager.instance.nextCallIsTransfer = NO;
ms_free(caddr);
} else {
- (BOOL)doCallWithSas:(const LinphoneAddress *)iaddr isSas:(BOOL)isSas {
LinphoneAddress *addr = linphone_address_clone(iaddr);
NSString *displayName = [FastAddressBook displayNameForAddress:addr];
// Finally we can make the call
LinphoneCallParams *lcallParams = linphone_core_create_call_params(theLinphoneCore, NULL);
if ([self lpConfigBoolForKey:@"edge_opt_preference"] && (self.network == network_2g)) {
LOGI(@"Enabling low bandwidth mode");
linphone_call_params_enable_low_bandwidth(lcallParams, YES);
}
if (displayName != nil) {
linphone_address_set_display_name(addr, displayName.UTF8String);
}
if ([LinphoneManager.instance lpConfigBoolForKey:@"override_domain_with_default_one"]) {
linphone_address_set_domain(
addr, [[LinphoneManager.instance lpConfigStringForKey:@"domain" inSection:@"assistant"] UTF8String]);
}
LinphoneCall *call;
if (LinphoneManager.instance.nextCallIsTransfer) {
char *caddr = linphone_address_as_string(addr);
call = linphone_core_get_current_call(theLinphoneCore);
linphone_call_transfer(call, caddr);
LinphoneManager.instance.nextCallIsTransfer = NO;
ms_free(caddr);
} else {
//We set the record file name here because we can't do it after the call is started.
NSString *writablePath = [LinphoneUtils recordingFilePathFromCall:addr];
LOGD(@"record file path: %@\n", writablePath);
linphone_call_params_set_record_file(lcallParams, [writablePath cStringUsingEncoding:NSUTF8StringEncoding]);
call = linphone_core_invite_address_with_params(theLinphoneCore, addr, lcallParams);
if (call) {
// The LinphoneCallAppData object should be set on call creation with callback
// - (void)onCall:StateChanged:withMessage:. If not, we are in big trouble and expect it to crash
// We are NOT responsible for creating the AppData.
LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call);
if (data == nil) {
LOGE(@"New call instanciated but app data was not set. Expect it to crash.");
/* will be used later to notify user if video was not activated because of the linphone core*/
} else {
data->videoRequested = linphone_call_params_video_enabled(lcallParams);
}
}
}
linphone_address_destroy(addr);
linphone_call_params_destroy(lcallParams);
return TRUE;
if (isSas)
linphone_call_params_set_media_encryption(lcallParams, LinphoneMediaEncryptionZRTP);
call = linphone_core_invite_address_with_params(theLinphoneCore, addr, lcallParams);
if (call) {
// The LinphoneCallAppData object should be set on call creation with callback
// - (void)onCall:StateChanged:withMessage:. If not, we are in big trouble and expect it to crash
// We are NOT responsible for creating the AppData.
LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call);
if (data == nil) {
LOGE(@"New call instanciated but app data was not set. Expect it to crash.");
/* will be used later to notify user if video was not activated because of the linphone core*/
} else {
data->videoRequested = linphone_call_params_video_enabled(lcallParams);
}
}
}
linphone_address_destroy(addr);
linphone_call_params_destroy(lcallParams);
return TRUE;
}
#pragma mark - Property Functions

View file

@ -56,7 +56,7 @@
<action selector="onCancelClick:" destination="-1" eventType="touchUpInside" id="LvF-N2-56g"/>
</connections>
</button>
<view contentMode="scaleToFill" id="CCn-Oz-I0M" userLabel="authView">
<view hidden="YES" contentMode="scaleToFill" id="CCn-Oz-I0M" userLabel="authView">
<rect key="frame" x="61" y="273" width="240" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>

View file

@ -330,7 +330,7 @@
myCode = [code substringFromIndex:2];
}
NSString *message =
[NSString stringWithFormat:NSLocalizedString(@"Confirmation security\n\n"
[NSString stringWithFormat:NSLocalizedString(@"\nConfirmation security\n\n"
@"Say: %@\n"
@"Confirm that your interlocutor\n"
@"says: %@",
@ -381,12 +381,14 @@
linphone_call_set_authentication_token_verified(call, NO);
}
weakSelf->securityDialog = nil;
[LinphoneManager.instance lpConfigSetString:[NSString stringWithUTF8String:linphone_call_get_remote_address_as_string(call)] forKey:@"sas_dialog_denied"];
}
onConfirmationClick:^() {
if (linphone_core_get_current_call(LC) == call) {
linphone_call_set_authentication_token_verified(call, YES);
}
weakSelf->securityDialog = nil;
[LinphoneManager.instance lpConfigSetString:nil forKey:@"sas_dialog_denied"];
} ];
securityDialog.securityImage.hidden = FALSE;

View file

@ -38,7 +38,6 @@ typedef void (^UIConfirmationBlock)(void);
@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;

View file

@ -24,7 +24,6 @@
dialog->onCancelCb = onCancel;
dialog->onConfirmCb = onConfirm;
dialog.notAskAgain = FALSE;
if (cancel) {
[dialog.cancelButton setTitle:cancel forState:UIControlStateNormal];
@ -93,9 +92,10 @@
}
- (IBAction)onAuthClick:(id)sender {
_notAskAgain = !_notAskAgain;
UIImage *image = _notAskAgain ? [UIImage imageNamed:@"checkbox_checked.png"] : [UIImage imageNamed:@"checkbox_unchecked.png"];
BOOL notAskAgain = ![LinphoneManager.instance lpConfigBoolForKey:@"confirmation_dialog_before_sas_call_not_ask_again"];
UIImage *image = notAskAgain ? [UIImage imageNamed:@"checkbox_checked.png"] : [UIImage imageNamed:@"checkbox_unchecked.png"];
[_authButton setImage:image forState:UIControlStateNormal];
[LinphoneManager.instance lpConfigSetBool:notAskAgain forKey:@"confirmation_dialog_before_sas_call_not_ask_again"];
}
- (void)dismiss {

View file

@ -39,7 +39,7 @@
- (IBAction)onSecurityCallClick:(id)sender {
const LinphoneAddress *addr = linphone_participant_device_get_address(_device);
if (addr)
[LinphoneManager.instance doCall:addr];
[LinphoneManager.instance doCallWithSas:addr isSas:TRUE];
else
LOGE(@"CallKit : No call address");
}

View file

@ -40,7 +40,7 @@
LinphoneParticipantDevice *device = (LinphoneParticipantDevice *)bctbx_list_nth_data(_devices, 0);
const LinphoneAddress *addr = linphone_participant_device_get_address(device);
if (addr)
[LinphoneManager.instance doCall:addr];
[LinphoneManager.instance doCallWithSas:addr isSas:TRUE];
else
LOGE(@"CallKit : No call address");
}