Commit 09e65afa authored by Sylvain Berfini's avatar Sylvain Berfini

Added firewall policy setting

parent 19cd8561
......@@ -1018,11 +1018,14 @@ namespace Linphone.Model
{
private LpConfig Config;
private Dictionary<string, string> TunnelModeToString;
private Dictionary<string, FirewallPolicy> FirewallPolicyToEnum;
private Dictionary<string, string> StringToTunnelMode;
private Dictionary<string, string> StringToFirewallPolicy;
#region Constants settings names
private const string SIPTransportSettingKeyName = "SIPTransport";
private const string SIPPortKeyName = "SIPPort";
private const string FirewallPolicyKeyName = "FirewallPolicy";
private const string StunServerKeyName = "StunServer";
private const string TunnelServerKeyName = "TunnelServer";
private const string TunnelPortKeyName = "TunnelPort";
......@@ -1056,6 +1059,20 @@ namespace Linphone.Model
{ "auto", AppResources.TunnelModeAuto },
{ "disabled", AppResources.TunnelModeDisabled }
};
FirewallPolicyToEnum = new Dictionary<string, FirewallPolicy>()
{
{ AppResources.FirewallPolicyNone, FirewallPolicy.NoFirewall },
{ AppResources.FirewallPolicyNat, FirewallPolicy.UseNatAddress },
{ AppResources.FirewallPolicyStun, FirewallPolicy.UseStun },
{ AppResources.FirewallPolicyIce, FirewallPolicy.UseIce }
};
StringToFirewallPolicy = new Dictionary<string, string>()
{
{ "NoFirewall", AppResources.FirewallPolicyNone },
{ "UseNatAddress", AppResources.FirewallPolicyNat },
{ "UseStun", AppResources.FirewallPolicyStun },
{ "UseIce", AppResources.FirewallPolicyIce }
};
}
#region Implementation of the ISettingsManager interface
......@@ -1086,6 +1103,7 @@ namespace Linphone.Model
dict[SIPPortKeyName] = port.ToString();
dict[StunServerKeyName] = LinphoneManager.Instance.LinphoneCore.GetStunServer();
dict[FirewallPolicyKeyName] = StringToFirewallPolicy[LinphoneManager.Instance.LinphoneCore.GetFirewallPolicy().ToString()];
// Load tunnel configuration
dict[TunnelModeKeyName] = AppResources.TunnelModeDisabled;
......@@ -1157,6 +1175,12 @@ namespace Linphone.Model
if (ValueChanged(StunServerKeyName))
LinphoneManager.Instance.LinphoneCore.SetStunServer(GetNew(StunServerKeyName));
if (ValueChanged(FirewallPolicyKeyName))
{
string firewallPolicy = GetNew(FirewallPolicyKeyName);
LinphoneManager.Instance.LinphoneCore.SetFirewallPolicy(FirewallPolicyToEnum[firewallPolicy]);
}
// Save tunnel configuration
if (LinphoneManager.Instance.LinphoneCore.IsTunnelAvailable() && Customs.IsTunnelEnabled)
{
......@@ -1209,6 +1233,21 @@ namespace Linphone.Model
}
}
/// <summary>
/// Firewall policy setting (String).
/// </summary>
public string FWPolicy
{
get
{
return Get(FirewallPolicyKeyName);
}
set
{
Set(FirewallPolicyKeyName, value);
}
}
/// <summary>
/// Stun server setting (String).
/// </summary>
......
......@@ -543,6 +543,51 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à ICE.
/// </summary>
public static string FirewallPolicyIce {
get {
return ResourceManager.GetString("FirewallPolicyIce", resourceCulture);
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à NAT.
/// </summary>
public static string FirewallPolicyNat {
get {
return ResourceManager.GetString("FirewallPolicyNat", resourceCulture);
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à None.
/// </summary>
public static string FirewallPolicyNone {
get {
return ResourceManager.GetString("FirewallPolicyNone", resourceCulture);
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à Firewall policy.
/// </summary>
public static string FirewallPolicySetting {
get {
return ResourceManager.GetString("FirewallPolicySetting", resourceCulture);
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à STUN.
/// </summary>
public static string FirewallPolicyStun {
get {
return ResourceManager.GetString("FirewallPolicyStun", resourceCulture);
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à G722.
/// </summary>
......
......@@ -537,6 +537,21 @@ Do you want to report it to the developpers ? It will help fix it faster.</value
<data name="SIPUserId" xml:space="preserve">
<value>Auth userid</value>
</data>
<data name="FirewallPolicyIce" xml:space="preserve">
<value>ICE</value>
</data>
<data name="FirewallPolicyNat" xml:space="preserve">
<value>NAT</value>
</data>
<data name="FirewallPolicyNone" xml:space="preserve">
<value>None</value>
</data>
<data name="FirewallPolicySetting" xml:space="preserve">
<value>Firewall policy</value>
</data>
<data name="FirewallPolicyStun" xml:space="preserve">
<value>STUN</value>
</data>
<data name="StunServer" xml:space="preserve">
<value>Stun server</value>
</data>
......
......@@ -26,7 +26,12 @@
x:Name="Transport"
Header="{Binding Path=LocalizedResources.TransportSetting, Source={StaticResource LocalizedStrings}}">
</toolkit:ListPicker>
<toolkit:ListPicker
x:Name="FirewallPolicy"
Header="{Binding Path=LocalizedResources.FirewallPolicySetting, Source={StaticResource LocalizedStrings}}">
</toolkit:ListPicker>
<StackPanel Orientation="Vertical">
<TextBlock
Margin="12,20,0,0"
......
......@@ -33,6 +33,15 @@ namespace Linphone.Views
vibrator.IsChecked = _chatSettings.VibrateOnIncomingMessage;
resizeDown.IsChecked = _chatSettings.ScaleDownSentPictures;
List<string> firewallPolicies = new List<string>
{
AppResources.FirewallPolicyNone,
AppResources.FirewallPolicyStun,
AppResources.FirewallPolicyIce
};
FirewallPolicy.ItemsSource = firewallPolicies;
FirewallPolicy.SelectedItem = _networkSettings.FWPolicy;
Stun.Text = _networkSettings.StunServer;
List<string> tunnelModes = new List<string>
......@@ -80,6 +89,7 @@ namespace Linphone.Views
_callSettings.SendDTFMsSIPInfo = sipInfo.IsChecked;
_callSettings.Save();
_networkSettings.FWPolicy = FirewallPolicy.SelectedItem.ToString();
_networkSettings.StunServer = Stun.Text;
_networkSettings.TunnelMode = tunnelMode.SelectedItem.ToString();
_networkSettings.TunnelServer = tunnelServer.Text;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment