diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m
index 2882b4e70..0f00cebab 100644
--- a/Classes/LinphoneCoreSettingsStore.m
+++ b/Classes/LinphoneCoreSettingsStore.m
@@ -306,6 +306,9 @@
[self setCString:linphone_core_get_stun_server(LC) forKey:@"stun_preference"];
[self setBool:linphone_nat_policy_ice_enabled(linphone_core_get_nat_policy(LC)) forKey:@"ice_preference"];
[self setBool:linphone_nat_policy_turn_enabled(linphone_core_get_nat_policy(LC)) forKey:@"turn_preference"];
+ [self setCString:linphone_nat_policy_get_stun_server_username(linphone_core_get_nat_policy(LC))
+ forKey:@"turn_username"];
+
int random_port_preference = [lm lpConfigIntForKey:@"random_port_preference" withDefault:1];
[self setInteger:random_port_preference forKey:@"random_port_preference"];
int port = [lm lpConfigIntForKey:@"port_preference" withDefault:5060];
@@ -717,21 +720,31 @@
LinphoneNatPolicy *LNP = linphone_core_get_nat_policy(LC);
NSString *stun_server = [self stringForKey:@"stun_preference"];
if ([stun_server length] > 0) {
-
linphone_core_set_stun_server(LC, [stun_server UTF8String]);
+ linphone_nat_policy_set_stun_server(LNP, [stun_server UTF8String]);
BOOL ice_preference = [self boolForKey:@"ice_preference"];
linphone_nat_policy_enable_ice(LNP, ice_preference);
+ linphone_nat_policy_enable_turn(LNP, [self boolForKey:@"turn_preference"]);
+ NSString *turn_username = [self stringForKey:@"turn_username"];
+ NSString *turn_password = [self stringForKey:@"turn_password"];
- BOOL turn_preference = [self boolForKey:@"turn_preference"];
- linphone_nat_policy_enable_turn(LNP, turn_preference);
+ if ([turn_username length] > 0) {
+ const LinphoneAuthInfo *turnAuthInfo = nil;
+ if ([turn_password length] > 0)
+ turnAuthInfo = linphone_auth_info_new([turn_username UTF8String], NULL,
+ [turn_password UTF8String], NULL, NULL, NULL);
+ else
+ turnAuthInfo = linphone_core_find_auth_info(LC, NULL, [turn_username UTF8String], NULL);
+ if (turnAuthInfo != NULL)
+ linphone_core_add_auth_info(LC, turnAuthInfo);
+ linphone_nat_policy_set_stun_server_username(LNP, linphone_auth_info_get_username(turnAuthInfo));
+ }
} else {
linphone_nat_policy_enable_stun(LNP, FALSE);
+ linphone_nat_policy_set_stun_server(LNP, NULL);
linphone_core_set_stun_server(LC, NULL);
- // TODO :
- // Do ice and turn should be off too ?
}
linphone_core_set_nat_policy(LC, LNP);
-
{
NSString *audio_port_preference = [self stringForKey:@"audio_port_preference"];
int minPort, maxPort;
diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m
index 03b861339..7f47280fd 100644
--- a/Classes/SettingsView.m
+++ b/Classes/SettingsView.m
@@ -413,7 +413,9 @@ static UICompositeViewDescription *compositeDescription = nil;
NSString *stun_server = [notif.userInfo objectForKey:@"stun_preference"];
removeFromHiddenKeys = (stun_server && ([stun_server length] > 0));
[keys addObject:@"ice_preference"];
- removeFromHiddenKeys = [[notif.userInfo objectForKey:@"turn_preference"] boolValue];
+ } else if ([@"turn_preference" compare:notif.object] == NSOrderedSame) {
+ LinphoneNatPolicy *LNP = linphone_core_get_nat_policy(LC);
+ linphone_nat_policy_enable_turn(LNP, !linphone_nat_policy_turn_enabled(LNP));
[keys addObject:@"turn_preference"];
} else if ([@"debugenable_preference" compare:notif.object] == NSOrderedSame) {
int debugLevel = [[notif.userInfo objectForKey:@"debugenable_preference"] intValue];
@@ -598,7 +600,6 @@ static UICompositeViewDescription *compositeDescription = nil;
if (linphone_core_get_stun_server(LC) == NULL) {
[hiddenKeys addObject:@"ice_preference"];
- [hiddenKeys addObject:@"turn_preference"];
}
if (![lm lpConfigBoolForKey:@"debugenable_preference"]) {
diff --git a/Settings/InAppSettings.bundle/Network.plist b/Settings/InAppSettings.bundle/Network.plist
index fa9364ec5..290ffd3bf 100644
--- a/Settings/InAppSettings.bundle/Network.plist
+++ b/Settings/InAppSettings.bundle/Network.plist
@@ -60,6 +60,40 @@
DefaultValue
+
+ Key
+ turn_username
+ Title
+ TURN's Username
+ Type
+ PSTextFieldSpecifier
+ AutocapitalizationType
+ None
+ AutocorrectionType
+ No
+ DefaultValue
+
+ IASKTextAlignment
+ IASKUITextAlignmentRight
+
+
+ Key
+ turn_password
+ Title
+ TURN's Password
+ Type
+ PSTextFieldSpecifier
+ IsSecure
+
+ AutocapitalizationType
+ None
+ AutocorrectionType
+ No
+ DefaultValue
+
+ IASKTextAlignment
+ IASKUITextAlignmentRight
+
Type
PSToggleSwitchSpecifier