Add the User ID specifier for advanced authentication.

Since the account setup was getting a bit big, I added a button to switch to advanced mode and hide the non-advanced settings by default.
This commit is contained in:
Guillaume BIENKOWSKI 2014-08-13 11:43:44 +02:00
parent 172691fc9c
commit 1766ebdfe7
6 changed files with 76 additions and 11 deletions

View file

@ -173,12 +173,12 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
if (elem && (ai=(LinphoneAuthInfo*)elem->data)){
[self setString: linphone_auth_info_get_passwd(ai) forKey:@"password_preference"];
[self setString: linphone_auth_info_get_ha1(ai) forKey:@"ha1_preference"]; // hidden but useful if provisioned
[self setString:linphone_auth_info_get_userid(ai) forKey:@"userid_preference"];
}
}
{
[self setString: linphone_core_get_stun_server(lc) forKey:@"stun_preference"];
[self
setBool:linphone_core_get_firewall_policy(lc)==LinphonePolicyUseIce forKey:@"ice_preference"];
[self setBool:linphone_core_get_firewall_policy(lc)==LinphonePolicyUseIce forKey:@"ice_preference"];
}
{
@ -188,7 +188,9 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
[self setInteger:lp_config_get_int(conf, "audio", "codec_bitrate_limit", kLinphoneAudioVbrCodecDefaultBitrate) forKey:@"audio_codec_bitrate_limit_preference"];
}
[self setBool:lp_config_get_int(conf, LINPHONERC_APPLICATION_KEY, "advanced_account_preference", 0) forKey:@"advanced_account_preference"];
{
LinphoneMediaEncryption menc=linphone_core_get_media_encryption(lc);
const char *val;
@ -345,6 +347,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
//mandatory parameters
NSString* username = [self stringForKey:@"username_preference"];
NSString* userID = [self stringForKey:@"userid_preference"];
NSString* domain = [self stringForKey:@"domain_preference"];
NSString* transport = [self stringForKey:@"transport_preference"];
NSString* accountHa1 = [self stringForKey:@"ha1_preference"];
@ -397,7 +400,8 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
// add username password
LinphoneAddress *from = linphone_address_new(identity);
if (from != 0){
info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,ha1,NULL,linphone_proxy_config_get_domain(proxyCfg));
const char* userid_str = (userID != nil)? [userID UTF8String] : NULL;
info=linphone_auth_info_new(linphone_address_get_username(from),userid_str,password,ha1,NULL,linphone_proxy_config_get_domain(proxyCfg));
linphone_address_destroy(from);
}
@ -656,7 +660,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "backgroundmode_preference", isbackgroundModeEnabled);
lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "start_at_boot_preference", [self boolForKey:@"start_at_boot_preference"]);
lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "autoanswer_notif_preference", [self boolForKey:@"autoanswer_notif_preference"]);
lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "advanced_account_preference", [self boolForKey:@"advanced_account_preference"]);
BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"];
lp_config_set_int(config, LINPHONERC_APPLICATION_KEY, "enable_first_login_view_preference", firstloginview);

View file

@ -540,7 +540,23 @@ static UICompositeViewDescription *compositeDescription = nil;
[hiddenKeys addObject:@"console_button"];
}
[settingsController setHiddenKeys:hiddenKeys animated:TRUE];
}
} else if( [@"advanced_account_preference" compare:notif.object] == NSOrderedSame) {
BOOL advanced = [[notif.userInfo objectForKey:@"advanced_account_preference"] boolValue];
NSMutableSet *hiddenKeys = [NSMutableSet setWithSet:[settingsController hiddenKeys]];
if( advanced ){
[hiddenKeys removeObject:@"userid_preference"];
[hiddenKeys removeObject:@"proxy_preference"];
[hiddenKeys removeObject:@"outbound_proxy_preference"];
[hiddenKeys removeObject:@"avpf_preference"];
} else {
[hiddenKeys addObject:@"userid_preference"];
[hiddenKeys addObject:@"proxy_preference"];
[hiddenKeys addObject:@"outbound_proxy_preference"];
[hiddenKeys addObject:@"avpf_preference"];
}
[settingsController setHiddenKeys:hiddenKeys animated:TRUE];
}
}
@ -616,6 +632,7 @@ static UICompositeViewDescription *compositeDescription = nil;
if(![LinphoneManager isLcReady]) {
[LinphoneLogger log:LinphoneLoggerWarning format:@"Can't filter settings: Linphone core not read"];
}
LinphoneManager* lm = [LinphoneManager instance];
NSMutableSet *hiddenKeys = [NSMutableSet set];
#ifndef DEBUG
@ -650,7 +667,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[hiddenKeys addObject:@"backgroundmode_preference"];
[hiddenKeys addObject:@"start_at_boot_preference"];
} else {
if(![[LinphoneManager instance] lpConfigBoolForKey:@"backgroundmode_preference"]) {
if(![lm lpConfigBoolForKey:@"backgroundmode_preference"]) {
[hiddenKeys addObject:@"start_at_boot_preference"];
}
}
@ -668,7 +685,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[hiddenKeys addObjectsFromArray:[[LinphoneManager unsupportedCodecs] allObjects]];
BOOL random_port = [[LinphoneManager instance] lpConfigBoolForKey:@"random_port_preference"];
BOOL random_port = [lm lpConfigBoolForKey:@"random_port_preference"];
if(random_port) {
[hiddenKeys addObject:@"port_preference"];
}
@ -677,21 +694,28 @@ static UICompositeViewDescription *compositeDescription = nil;
[hiddenKeys addObject:@"ice_preference"];
}
if(![[LinphoneManager instance] lpConfigBoolForKey:@"debugenable_preference"]) {
if(![lm lpConfigBoolForKey:@"debugenable_preference"]) {
[hiddenKeys addObject:@"console_button"];
}
if(![LinphoneManager runningOnIpad]) {
[hiddenKeys addObject:@"preview_preference"];
}
if([[LinphoneManager instance] lpConfigBoolForKey:@"hide_run_assistant_preference"]) {
if([lm lpConfigBoolForKey:@"hide_run_assistant_preference"]) {
[hiddenKeys addObject:@"wizard_button"];
}
if (!linphone_core_tunnel_available()){
[hiddenKeys addObject:@"tunnel_menu"];
}
if( ![lm lpConfigBoolForKey:@"advanced_account_preference"] ){
[hiddenKeys addObject:@"userid_preference"];
[hiddenKeys addObject:@"proxy_preference"];
[hiddenKeys addObject:@"outbound_proxy_preference"];
[hiddenKeys addObject:@"avpf_preference"];
}
return hiddenKeys;
}

View file

@ -36,6 +36,24 @@
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>userid_preference</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>Title</key>
<string>User ID</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
@ -132,6 +150,16 @@
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Advanced account</string>
<key>Key</key>
<string>advanced_account_preference</string>
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Title</key>
<string>Settings</string>

View file

@ -7,6 +7,9 @@
/* User name */
"User name" = "User name";
/* User ID */
"User ID" = "User ID";
/* Password */
"Password" = "Password";

View file

@ -7,6 +7,9 @@
/* User name */
"User name" = "Nom d'utilisateur";
/* User name */
"User ID" = "ID d'utilisateur";
/* Password */
"Password" = "Mot de passe";

View file

@ -7,6 +7,9 @@
/* User name */
"User name" = "Имя пользователя";
/* User name */
"User ID" = "ID пользователя";
/* Password */
"Password" = "Пароль";