diff --git a/Classes/Contact.m b/Classes/Contact.m index d93ee3edc..6938b0989 100644 --- a/Classes/Contact.m +++ b/Classes/Contact.m @@ -57,7 +57,8 @@ linphone_friend_add_phone_number(_friend, phone.UTF8String); #endif } - linphone_core_add_friend(LC, _friend); + if (_friend) + linphone_core_add_friend(LC, _friend); } linphone_friend_ref(_friend); } else if (_friend) { diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index b303652e3..89ee16740 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -1,21 +1,21 @@ /* ContactDetailsViewController.m - * - * Copyright (C) 2012 Belledonne Comunications, Grenoble, France - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ +* +* Copyright (C) 2012 Belledonne Comunications, Grenoble, France +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ #import "ContactDetailsView.h" #import "PhoneMainView.h" diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 0ec48aa3a..2882b4e70 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -304,7 +304,8 @@ [self setBool:[lm lpConfigBoolForKey:@"edge_opt_preference" withDefault:NO] forKey:@"edge_opt_preference"]; [self setBool:[lm lpConfigBoolForKey:@"wifi_only_preference" withDefault:NO] forKey:@"wifi_only_preference"]; [self setCString:linphone_core_get_stun_server(LC) forKey:@"stun_preference"]; - [self setBool:linphone_core_get_firewall_policy(LC) == LinphonePolicyUseIce forKey:@"ice_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"]; 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]; @@ -713,19 +714,23 @@ [LinphoneManager.instance setupNetworkReachabilityCallback]; } + 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]); BOOL ice_preference = [self boolForKey:@"ice_preference"]; - if (ice_preference) { - linphone_core_set_firewall_policy(LC, LinphonePolicyUseIce); - } else { - linphone_core_set_firewall_policy(LC, LinphonePolicyUseStun); - } + linphone_nat_policy_enable_ice(LNP, ice_preference); + + BOOL turn_preference = [self boolForKey:@"turn_preference"]; + linphone_nat_policy_enable_turn(LNP, turn_preference); } else { + linphone_nat_policy_enable_stun(LNP, FALSE); linphone_core_set_stun_server(LC, NULL); - linphone_core_set_firewall_policy(LC, LinphonePolicyNoFirewall); + // 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"]; diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index 5230448f5..03b861339 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -413,6 +413,8 @@ 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]; + [keys addObject:@"turn_preference"]; } else if ([@"debugenable_preference" compare:notif.object] == NSOrderedSame) { int debugLevel = [[notif.userInfo objectForKey:@"debugenable_preference"] intValue]; BOOL debugEnabled = (debugLevel >= ORTP_DEBUG && debugLevel < ORTP_ERROR); @@ -596,6 +598,7 @@ 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/Resources/linphonerc b/Resources/linphonerc index a8563c011..ff3ef32ff 100644 --- a/Resources/linphonerc +++ b/Resources/linphonerc @@ -6,6 +6,7 @@ edge_opt_preference=0 enable_log_collect=0 file_transfer_migration_done=1 ice_preference=1 +turn_preference=1 preview_preference=0 random_port_preference=1 start_at_boot_preference=1 diff --git a/Resources/linphonerc~ipad b/Resources/linphonerc~ipad index 49b6d9ad7..4874aafd6 100644 --- a/Resources/linphonerc~ipad +++ b/Resources/linphonerc~ipad @@ -6,6 +6,7 @@ edge_opt_preference=0 enable_log_collect=0 file_transfer_migration_done=1 ice_preference=1 +turn_preference=1 preview_preference=1 random_port_preference=1 start_at_boot_preference=1 diff --git a/Settings/InAppSettings.bundle/Network.plist b/Settings/InAppSettings.bundle/Network.plist index 10c5fe294..fa9364ec5 100644 --- a/Settings/InAppSettings.bundle/Network.plist +++ b/Settings/InAppSettings.bundle/Network.plist @@ -50,6 +50,16 @@ DefaultValue + + Title + TURN + Key + turn_preference + Type + PSToggleSwitchSpecifier + DefaultValue + + Type PSToggleSwitchSpecifier diff --git a/submodules/linphone b/submodules/linphone index 2aa8e4693..9cbccee8d 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 2aa8e46934e7df2e5ac06bbdaf1e0ce4bcc913bc +Subproject commit 9cbccee8de5686fcfed41717429c4130d13d7ee8