diff --git a/Classes/CallView.m b/Classes/CallView.m index 7fa271387..b78afd84d 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -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 { diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index e5bfa4f42..ebb32377b 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -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; } diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 9dd0454de..a986a04c7 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -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; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 517fc8aef..fa225a499 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -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 diff --git a/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib b/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib index 156520643..85125beff 100644 --- a/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib +++ b/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib @@ -56,7 +56,7 @@ - +