mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
LinphoneManager: fix auth popup
This commit is contained in:
parent
3d3b12ebf9
commit
f33e91ced1
1 changed files with 29 additions and 21 deletions
|
|
@ -889,8 +889,8 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo
|
|||
|
||||
#pragma mark - Auth info Function
|
||||
|
||||
static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char *realm, const char *username,
|
||||
const char *domain) {
|
||||
static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char *realmC, const char *usernameC,
|
||||
const char *domainC) {
|
||||
// let the wizard handle its own errors
|
||||
if ([PhoneMainView.instance currentView] != WizardViewController.compositeViewDescription) {
|
||||
static DTAlertView *alertView = nil;
|
||||
|
|
@ -900,34 +900,42 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char
|
|||
[alertView dismissWithClickedButtonIndex:0 animated:NO];
|
||||
}
|
||||
|
||||
NSString *realm = [NSString stringWithUTF8String:realmC];
|
||||
NSString *username = [NSString stringWithUTF8String:usernameC];
|
||||
NSString *domain = [NSString stringWithUTF8String:domainC];
|
||||
alertView = [[DTAlertView alloc]
|
||||
initWithTitle:NSLocalizedString(@"Authentication needed.", nil)
|
||||
message:[NSString stringWithFormat:NSLocalizedString(@"Registration failed because authentication is "
|
||||
@"missing or invalid for %s@%s.\nYou can "
|
||||
@"missing or invalid for %@@%@.\nYou can "
|
||||
@"provide password again, or check your "
|
||||
@"account configuration in the settings.",
|
||||
nil),
|
||||
username, realm]];
|
||||
alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
|
||||
[alertView addCancelButtonWithTitle:NSLocalizedString(@"Cancel", nil) block:nil];
|
||||
__weak UITextField *passwordField = [alertView textFieldAtIndex:0];
|
||||
[alertView addCancelButtonWithTitle:NSLocalizedString(@"Go to settings", nil)
|
||||
block:^{
|
||||
[[PhoneMainView instance]
|
||||
changeCurrentView:[SettingsViewController compositeViewDescription]];
|
||||
}];
|
||||
|
||||
[alertView addButtonWithTitle:NSLocalizedString(@"Continue", nil)
|
||||
block:^{
|
||||
LinphoneAuthInfo *info = (LinphoneAuthInfo *)linphone_core_find_auth_info(
|
||||
[LinphoneManager getLc], realm, username, domain);
|
||||
if (info) {
|
||||
linphone_auth_info_set_passwd(info, passwordField.text.UTF8String);
|
||||
linphone_auth_info_set_ha1(info, NULL);
|
||||
linphone_proxy_config_refresh_register(
|
||||
linphone_core_get_default_proxy_config([LinphoneManager getLc]));
|
||||
} else {
|
||||
LOGE(@"Could not find auth info associated with %s@%s, going to settings!",
|
||||
username, domain);
|
||||
[[PhoneMainView instance]
|
||||
changeCurrentView:[SettingsViewController compositeViewDescription]];
|
||||
}
|
||||
}];
|
||||
[alertView
|
||||
addButtonWithTitle:NSLocalizedString(@"Continue", nil)
|
||||
block:^{
|
||||
NSString *password = [alertView textFieldAtIndex:0].text;
|
||||
LinphoneAuthInfo *info = (LinphoneAuthInfo *)linphone_core_find_auth_info(
|
||||
[LinphoneManager getLc], realm.UTF8String, username.UTF8String, domain.UTF8String);
|
||||
if (info) {
|
||||
linphone_auth_info_set_passwd(info, password.UTF8String);
|
||||
linphone_auth_info_set_ha1(info, NULL);
|
||||
} else {
|
||||
LOGW(@"Could not find auth info associated with %@@%@, creating it", username, domain);
|
||||
info = linphone_auth_info_new(username.UTF8String, NULL, password.UTF8String, NULL,
|
||||
realm.UTF8String, domain.UTF8String);
|
||||
linphone_core_add_auth_info([LinphoneManager getLc], info);
|
||||
}
|
||||
linphone_proxy_config_refresh_register(
|
||||
linphone_core_get_default_proxy_config([LinphoneManager getLc]));
|
||||
}];
|
||||
[alertView show];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue