Commit 0cda7bc3 authored by Sylvain Berfini's avatar Sylvain Berfini

Reworked some things like default values, customs, etc...

parent 3758a1b6
......@@ -89,7 +89,6 @@
<Compile Include="LinphoneForegroundLifeTimeAgent.cs" />
<Compile Include="LinphoneScheduledAgent.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PushManager.cs" />
<Compile Include="RegistrationHelper.cs" />
<Compile Include="TileManager.cs" />
<Compile Include="$(ProjectDir)..\submodules\mswp8vid\VideoRenderer.cs" />
......
......@@ -68,13 +68,6 @@ namespace Linphone.Agents
//Globals.Instance.BackgroundModeLogger.Configure(true, OutputTraceDest.TCPRemote, "192.168.0.217:38954");
//Globals.Instance.LinphoneCoreFactory.OutputTraceListener = Globals.Instance.BackgroundModeLogger;
/*
if (Globals.Instance.LinphoneCore.GetDefaultProxyConfig() != null)
{
LinphoneProxyConfig proxyCfg = OopServer.LinphoneCore.GetDefaultProxyConfig();
LinphoneAddress address = OopServer.LinphoneCoreFactory.CreateLinphoneAddress(proxyCfg.GetIdentity());
proxyCfg.SetContactParameters("pwd=" + address.GetDisplayName());
}*/
OopServer.LinphoneCore.SetNetworkReachable(true);
}
}
......
......@@ -48,16 +48,6 @@ namespace Linphone.Agents
server.LinphoneCore.SetRootCA("Assets/rootca.pem");
server.LinphoneCore.SetNetworkReachable(true);
Debug.WriteLine("[KeepAliveAgent] Linphone Core created");
PushManager pushManager = new PushManager();
if (server.LinphoneCore.GetDefaultProxyConfig() != null && pushManager.PushChannelUri != null)
{
string host, token;
host = pushManager.PushChannelUri.Host;
token = pushManager.PushChannelUri.AbsolutePath;
server.LinphoneCore.GetDefaultProxyConfig().SetContactParameters("app-id=" + host + ";pn-type=wp;pn-tok=" + token + ";pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-call-snd=ring.caf;pn-msg-snd=msg.caf");
Debug.WriteLine("[KeepAliveAgent] Added push parameters to contact");
}
}
else
{
......@@ -114,13 +104,9 @@ namespace Linphone.Agents
/// </summary>
public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
{
if (config == null)
return;
Debug.WriteLine("[KeepAliveAgent] Registration state changed: " + state.ToString() + ", message=" + message + " for identity " + config.GetIdentity());
if (state == Linphone.Core.RegistrationState.RegistrationOk)
if (state == Linphone.Core.RegistrationState.RegistrationOk || state == Linphone.Core.RegistrationState.RegistrationFailed)
{
Debug.WriteLine("[KeepAliveAgent] Notify complete");
Debug.WriteLine("[KeepAliveAgent] Notify complete (" + state.ToString() + ")");
base.NotifyComplete();
}
}
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Linphone.Agents
{
public class PushManager
{
public PushManager()
{
_settings = IsolatedStorageSettings.ApplicationSettings;
}
IsolatedStorageSettings _settings;
#region Constants settings names
private const string PushUriKeyName = "PushUri";
#endregion
#region methods
private bool AddOrUpdate(string key, object value)
{
bool valueChanged = false;
if (_settings.Contains(key))
{
if (!_settings[key].Equals(value))
{
_settings[key] = value;
valueChanged = true;
}
}
else
{
_settings.Add(key, value);
valueChanged = true;
}
return valueChanged;
}
private Uri GetValue(string key)
{
Uri value = null;
if (_settings.Contains(key))
value = (Uri)_settings[key];
return value;
}
private void Save()
{
_settings.Save();
}
#endregion
#region Accessors
/// <summary>
/// DTMFs using RFC2833 setting (bool).
/// </summary>
public Uri PushChannelUri
{
get
{
return GetValue(PushUriKeyName);
}
set
{
if (AddOrUpdate(PushUriKeyName, value))
{
Save();
}
}
}
#endregion
}
}
......@@ -180,8 +180,6 @@ namespace Linphone
// Store the push channel URI
this.PushChannelUri = e.ChannelUri;
PushManager pushManager = new PushManager();
pushManager.PushChannelUri = e.ChannelUri;
// Let listeners know that we have a push channel URI
if (this.PushChannelUriChanged != null)
......@@ -247,7 +245,7 @@ namespace Linphone
}
keepAliveTask = new VoipKeepAliveTask(keepAliveTaskName);
keepAliveTask.Interval = new TimeSpan(10000000 * 5);
keepAliveTask.Interval = new TimeSpan(1,0,0); // 1 hour
keepAliveTask.Description = "keep-alive task";
ScheduledActionService.Add(keepAliveTask);
}
......
......@@ -124,6 +124,7 @@
<Compile Include="Model\CallLog.cs" />
<Compile Include="Model\ContactManager.cs" />
<Compile Include="Model\ContactPictureConverter.cs" />
<Compile Include="Model\Customs.cs" />
<Compile Include="Model\EchoCalibratorListener.cs" />
<Compile Include="Model\Conversation.cs" />
<Compile Include="Model\DatabaseManager.cs" />
......@@ -140,11 +141,6 @@
<DesignTime>True</DesignTime>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
<Compile Include="Resources\DefaultValues.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>DefaultValues.resx</DependentUpon>
</Compile>
<Compile Include="Views\BasePage.cs" />
<Compile Include="Views\About.xaml.cs">
<DependentUpon>About.xaml</DependentUpon>
......@@ -402,10 +398,6 @@
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Resources\DefaultValues.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>DefaultValues.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Phone.Controls.Toolkit, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b772ad94eb9ca604, processorArchitecture=MSIL">
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Linphone.Model
{
/// <summary>
/// Booleans to enable/disable features and custom strings
/// </summary>
public class Customs
{
internal static bool IsTunnelEnabled = false;
internal static bool AddPasswordInContactsParams = false;
internal static bool UseCustomIncomingCallView = false;
internal static string PictureUploadScriptURL = "https://linphone.org:444/upload.php";
internal static string UserAgent = "LinphoneWP8";
internal static bool EnableG729 = false;
}
}
......@@ -251,7 +251,7 @@ namespace Linphone.Model
server.LinphoneCore.CoreListener = this;
isLinphoneRunning = true;
// Set user-agent because it is not set if coming back from background mode
server.LinphoneCore.SetUserAgent(DefaultValues.UserAgent, XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value);
server.LinphoneCore.SetUserAgent(Customs.UserAgent, XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value);
return;
}
......@@ -272,7 +272,7 @@ namespace Linphone.Model
DetectCameras();
}
server.LinphoneCore.SetUserAgent(DefaultValues.UserAgent, XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value);
server.LinphoneCore.SetUserAgent(Customs.UserAgent, XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value);
AddPushInformationsToContactParams();
lastNetworkState = DeviceNetworkInformation.IsNetworkAvailable;
......@@ -292,10 +292,16 @@ namespace Linphone.Model
string host, token;
host = ((App)App.Current).PushChannelUri.Host;
token = ((App)App.Current).PushChannelUri.AbsolutePath;
/*SIPAccountSettingsManager sip = new SIPAccountSettingsManager();
sip.Load();
server.LinphoneCore.GetDefaultProxyConfig().SetContactParameters("pwd=" + sip.DisplayName + ";app-id=" + host + ";pn-type=wp;pn-tok=" + token);*/
server.LinphoneCore.GetDefaultProxyConfig().SetContactParameters("app-id=" + host + ";pn-type=wp;pn-tok=" + token);
if (Customs.AddPasswordInContactsParams)
{
SIPAccountSettingsManager sip = new SIPAccountSettingsManager();
sip.Load();
server.LinphoneCore.GetDefaultProxyConfig().SetContactParameters("pwd=" + sip.DisplayName + ";app-id=" + host + ";pn-type=wp;pn-tok=" + token);
}
else
{
server.LinphoneCore.GetDefaultProxyConfig().SetContactParameters("app-id=" + host + ";pn-type=wp;pn-tok=" + token);
}
}
}
......
......@@ -1140,7 +1140,7 @@ namespace Linphone.Model
}
// Save tunnel configuration
if (LinphoneManager.Instance.LinphoneCore.IsTunnelAvailable() && false) // Disable tunnel for now
if (LinphoneManager.Instance.LinphoneCore.IsTunnelAvailable() && Customs.IsTunnelEnabled)
{
if (ValueChanged(TunnelServerKeyName) || ValueChanged(TunnelPortKeyName))
{
......
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18046
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Linphone.Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class DefaultValues {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal DefaultValues() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Linphone.Resources.DefaultValues", typeof(DefaultValues).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to false.
/// </summary>
internal static string CustomIncomingCallView {
get {
return ResourceManager.GetString("CustomIncomingCallView", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 3600.
/// </summary>
internal static string KeepAlive {
get {
return ResourceManager.GetString("KeepAlive", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to https://linphone.org:444/upload.php.
/// </summary>
internal static string PictureUploadScriptURL {
get {
return ResourceManager.GetString("PictureUploadScriptURL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to LinphoneWP8.
/// </summary>
internal static string UserAgent {
get {
return ResourceManager.GetString("UserAgent", resourceCulture);
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CustomIncomingCallView" xml:space="preserve">
<value>false</value>
</data>
<data name="KeepAlive" xml:space="preserve">
<value>3600</value>
<comment>Seconds for keep-alive task</comment>
</data>
<data name="PictureUploadScriptURL" xml:space="preserve">
<value>https://linphone.org:444/upload.php</value>
</data>
<data name="UserAgent" xml:space="preserve">
<value>LinphoneWP8</value>
<comment>User-agent to be sent in SIP messages</comment>
</data>
</root>
\ No newline at end of file
......@@ -54,7 +54,7 @@ namespace Linphone.Views
Transport.ItemsSource = transports;
Transport.SelectedItem = _networkSettings.Transport;
TunnelPanel.Visibility = LinphoneManager.Instance.LinphoneCore.IsTunnelAvailable() && false ? Visibility.Visible : Visibility.Collapsed; //Hidden properties for now
TunnelPanel.Visibility = LinphoneManager.Instance.LinphoneCore.IsTunnelAvailable() && Customs.IsTunnelEnabled ? Visibility.Visible : Visibility.Collapsed; //Hidden properties for now
}
/// <summary>
......
......@@ -30,7 +30,8 @@ namespace Linphone.Views
PCMU.IsChecked = _settings.PCMU;
PCMA.IsChecked = _settings.PCMA;
G722.IsChecked = _settings.G722;
G729.IsChecked = _settings.G729;
G729.IsChecked = _settings.G729 && Customs.EnableG729;
G729.IsEnabled = Customs.EnableG729;
ILBC.IsChecked = _settings.ILBC;
SILK16.IsChecked = _settings.SILK16;
GSM.IsChecked = _settings.GSM;
......@@ -68,7 +69,7 @@ namespace Linphone.Views
_settings.PCMU = ToBool(PCMU.IsChecked);
_settings.PCMA = ToBool(PCMA.IsChecked);
_settings.G722 = ToBool(G722.IsChecked);
_settings.G729 = ToBool(G729.IsChecked);
_settings.G729 = ToBool(G729.IsChecked) && Customs.EnableG729;
_settings.ILBC = ToBool(ILBC.IsChecked);
_settings.SILK16 = ToBool(SILK16.IsChecked);
_settings.GSM = ToBool(GSM.IsChecked);
......
......@@ -265,7 +265,7 @@ namespace Linphone.Views
streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
content.Add(streamContent);
using (var message = await client.PostAsync(DefaultValues.PictureUploadScriptURL, content))
using (var message = await client.PostAsync(Customs.PictureUploadScriptURL, content))
{
message.EnsureSuccessStatusCode();
response = await message.Content.ReadAsStringAsync();
......
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