Commit 27b92db8 authored by Sylvain Berfini's avatar Sylvain Berfini

Fix crash on some devices + added button to delete linphone log

parent 76f5238a
......@@ -68,13 +68,13 @@ 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)
//{
// string host, token;
// host = ((App)App.Current).PushChannelUri.Host;
// token = ((App)App.Current).PushChannelUri.AbsolutePath;
// Globals.Instance.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");
//}
/*
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);
}
}
......
......@@ -62,9 +62,11 @@ namespace Linphone.Model
foreach (T item in items)
{
int index = 0;
if (!slg.SupportsPhonetics)
if (slg != null && !slg.SupportsPhonetics)
{
index = slg.GetGroupIndex(getKey(item));
string key = getKey(item);
if (key != null && key.Length > 0)
index = slg.GetGroupIndex(key);
}
if (index >= 0 && index < list.Count)
{
......
......@@ -42,6 +42,23 @@ namespace Linphone.Model
catch (Exception) { }
}
internal static void LogMessage(string message)
{
try
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
using (TextWriter output = new StreamWriter(store.OpenFile(exceptionsFileName, FileMode.Append)))
{
output.WriteLine("Custom message: {0}", message);
output.Flush();
output.Close();
}
}
}
catch (Exception) { }
}
internal static bool HasExceptionToReport()
{
try
......@@ -56,6 +73,20 @@ namespace Linphone.Model
return false;
}
internal static bool HasLinphoneLogFile()
{
try
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
return store.FileExists(logFileName);
}
}
catch (Exception) { }
return false;
}
internal static async void ReportExceptions()
{
try
......@@ -121,5 +152,17 @@ namespace Linphone.Model
}
catch (Exception) { }
}
internal static void DeleteLinphoneLogFile()
{
try
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
store.DeleteFile(logFileName);
}
}
catch (Exception) { }
}
}
}
......@@ -141,7 +141,7 @@ namespace Linphone.Model
private Server server = null;
// A timespan representing fifteen seconds
private static readonly TimeSpan fifteenSecs = new TimeSpan(0, 0, 15);
private static readonly TimeSpan twentySecs = new TimeSpan(0, 0, 20);
// A timespan representing an indefinite wait
private static readonly TimeSpan indefiniteWait = new TimeSpan(0, 0, 0, 0, -1);
......@@ -177,11 +177,11 @@ namespace Linphone.Model
string backgroundProcessReadyEventName = Globals.GetBackgroundProcessReadyEventName((uint)backgroundProcessID);
using (EventWaitHandle backgroundProcessReadyEvent = new EventWaitHandle(initialState: false, mode: EventResetMode.ManualReset, name: backgroundProcessReadyEventName))
{
TimeSpan timeout = Debugger.IsAttached ? indefiniteWait : fifteenSecs;
TimeSpan timeout = twentySecs;
if (!backgroundProcessReadyEvent.WaitOne(timeout))
{
// We timed out - something is wrong
throw new InvalidOperationException(string.Format("The background process did not become ready in {0} milliseconds", timeout.Milliseconds));
throw new InvalidOperationException(string.Format("The background process ({0}) did not become ready in {1} seconds", backgroundProcessID, timeout.Seconds));
}
else
{
......@@ -292,6 +292,9 @@ 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);
}
}
......
......@@ -372,6 +372,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Delete logs file.
/// </summary>
public static string DeleteLogs {
get {
return ResourceManager.GetString("DeleteLogs", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete Selection.
/// </summary>
......
......@@ -519,4 +519,7 @@ Do you want to report it to the developpers ? It will help fix it faster.</value
<data name="G729Codec" xml:space="preserve">
<value>G729</value>
</data>
<data name="DeleteLogs" xml:space="preserve">
<value>Delete logs file</value>
</data>
</root>
\ No newline at end of file
......@@ -38,6 +38,7 @@
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<toolkit:ToggleSwitch
......@@ -48,34 +49,41 @@
<Button
Grid.Row="1"
x:Name="DeleteLogs"
Click="deleteLogs_Click_1"
Margin="0,0,0,20"
Content="{Binding Path=LocalizedResources.DeleteLogs, Source={StaticResource LocalizedStrings}}" />
<Button
Grid.Row="2"
x:Name="Account"
Click="account_Click_1"
Margin="0,0,0,20"
Content="{Binding Path=LocalizedResources.AccountMenu, Source={StaticResource LocalizedStrings}}" />
<Button
Grid.Row="2"
Grid.Row="3"
x:Name="Audio"
Click="audio_Click_1"
Margin="0,0,0,20"
Content="{Binding Path=LocalizedResources.AudioSettingsMenu, Source={StaticResource LocalizedStrings}}" />
<Button
Grid.Row="3"
Grid.Row="4"
x:Name="Video"
Click="video_Click_1"
Margin="0,0,0,20"
Content="{Binding Path=LocalizedResources.VideoSettingsMenu, Source={StaticResource LocalizedStrings}}" />
<Button
Grid.Row="4"
Grid.Row="5"
x:Name="Advanced"
Click="advanced_Click_1"
Margin="0,0,0,20"
Content="{Binding Path=LocalizedResources.AdvancedSettingsMenu, Source={StaticResource LocalizedStrings}}" />
<Button
Grid.Row="5"
Grid.Row="6"
Click="LockScreenSettings_Click_1"
x:Name="LockScreenSettings"
Margin="0,0,0,20"
......
......@@ -32,6 +32,12 @@ namespace Linphone.Views
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (BugCollector.HasLinphoneLogFile())
DeleteLogs.Visibility = (bool)Debug.IsChecked ? Visibility.Visible : Visibility.Collapsed;
else
DeleteLogs.Visibility = Visibility.Collapsed;
// Create LinphoneCore if not created yet, otherwise do nothing
await LinphoneManager.Instance.InitLinphoneCore();
}
......@@ -42,6 +48,12 @@ namespace Linphone.Views
NavigationService.GoBack();
}
private void deleteLogs_Click_1(object sender, EventArgs e)
{
BugCollector.DeleteLinphoneLogFile();
DeleteLogs.Visibility = Visibility.Collapsed;
}
private void save_Click_1(object sender, EventArgs e)
{
bool? enabled = Debug.IsChecked;
......
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