Commit d9073bdc authored by Erwan Croze's avatar Erwan Croze 👋🏻

Changing debug option

parent 40f77a0a
......@@ -55,12 +55,9 @@ namespace Linphone.Model {
get {
if (_core == null) {
ConfigurePaths();
EnableLogCollection(true);
_coreListener = Factory.Instance.CreateCoreListener();
coreListenerInit();
_core = Factory.Instance.CreateCore(_coreListener, GetConfigPath(), GetFactoryConfigPath());
Linphone.Core.EnableLogCollection(LogCollectionState.Enabled);
Linphone.Core.SetLogLevelMask(0xFF);
}
return _core;
}
......@@ -109,7 +106,7 @@ namespace Linphone.Model {
}
}
public String GetChatDatabasePath() {
return Path.Combine(ApplicationData.Current.LocalFolder.Path, "chat.db");
return (ApplicationData.Current.LocalFolder.Path + "chat.db");
}
public String GetDefaultConfigPath() {
......@@ -134,7 +131,6 @@ namespace Linphone.Model {
}
public void InitLinphoneCore() {
LinphoneManager.Instance.Core.ChatDatabasePath = GetChatDatabasePath();
LinphoneManager.Instance.Core.RootCa = GetRootCaPath();
......@@ -147,6 +143,10 @@ namespace Linphone.Model {
}
LinphoneManager.Instance.Core.UsePreviewWindow(true);
LinphoneManager.Instance.Core.SetUserAgent("LinphoneW10", Core.Version);
if (LinphoneManager.Instance.Core.Config != null) {
EnableLogCollection(
(LinphoneManager.Instance.Core.Config.GetInt("app", "LogLevel", (int)LogCollectionState.Disabled) == 1) ? true : false);
}
InitPushNotifications();
isLinphoneRunning = true;
TimeSpan period = TimeSpan.FromMilliseconds(20);
......@@ -170,6 +170,7 @@ namespace Linphone.Model {
public void EnableLogCollection(bool enable) {
Linphone.Core.EnableLogCollection(enable ? LogCollectionState.EnabledWithoutPreviousLogHandler : LogCollectionState.Disabled);
if (enable) Linphone.Core.SetLogLevelMask(0xFF);
Linphone.Core.SetLogCollectionPath(ApplicationData.Current.LocalFolder.Path);
}
......
......@@ -127,9 +127,9 @@ namespace Linphone.Model {
/// </summary>
public class ApplicationSettingsManager : SettingsManager, ISettingsManager {
private Config Config;
private LogCollectionState LogLevel;
#region Constants settings names
private const string LogLevelKeyName = "LogLevel";
private const String LogLevelKeyName = "LogLevel";
private const string VideoActiveWhenGoingToBackgroundKeyName = "VideoActiveWhenGoingToBackground";
private const string VideoAutoAcceptWhenGoingToBackgroundKeyName = "VideoAutoAcceptWhenGoingToBackground";
#endregion
......@@ -150,7 +150,7 @@ namespace Linphone.Model {
/// Load the application settings.
/// </summary>
public void Load() {
//dict[LogLevelKeyName] = Config.GetInt(ApplicationSection, LogLevelKeyName, (int)OutputTraceLevel.Message).ToString();
LogLevelSetting = (LogCollectionState)(Config.GetInt(ApplicationSection, LogLevelKeyName, (int)LogCollectionState.Disabled));
dict[VideoActiveWhenGoingToBackgroundKeyName] = Config.GetInt(ApplicationSection, VideoActiveWhenGoingToBackgroundKeyName, 0).ToString();
dict[VideoAutoAcceptWhenGoingToBackgroundKeyName] = Config.GetInt(ApplicationSection, VideoAutoAcceptWhenGoingToBackgroundKeyName, 1).ToString();
}
......@@ -161,7 +161,10 @@ namespace Linphone.Model {
public async void Save() {
if (ValueChanged(LogLevelKeyName)) {
try {
//Config.SetInt(ApplicationSection, LogLevelKeyName, Convert.ToInt32(GetNew(LogLevelKeyName)));
Config.SetInt(ApplicationSection, LogLevelKeyName, (int)LogLevel);
LinphoneManager.Instance.EnableLogCollection((LogLevelSetting == LogCollectionState.Enabled) ? true: false);
Linphone.Core.EnableLogCollection(LogLevelSetting);
Linphone.Core.SetLogLevelMask((LogLevelSetting == LogCollectionState.Enabled) ? (uint)0xFF: 0x0);
//LinphoneManager.Instance.ConfigureLog(LogLevel);
} catch {
// Core.LogLevel.Warn("Failed setting the log level name {0}", Get(LogLevelKeyName));
......@@ -182,29 +185,29 @@ namespace Linphone.Model {
/// </summary>
public bool DebugEnabled {
get {
return false;
//return Convert.ToInt32(Get(LogLevelKeyName)) == (int)OutputTraceLevel.Message;
return LogLevelSetting == LogCollectionState.Enabled;
}
set {
/*if (value) {
Set(LogLevelKeyName, ((int)OutputTraceLevel.Message).ToString());
if (value) {
LogLevelSetting = LogCollectionState.Enabled;
} else {
Set(LogLevelKeyName, ((int)OutputTraceLevel.None).ToString());
}*/
LogLevelSetting = LogCollectionState.Disabled;
}
}
}
/// <summary>
/// Log level (OutputTraceLevel).
/// </summary>
/*public OutputTraceLevel LogLevel {
public LogCollectionState LogLevelSetting {
get {
return (OutputTraceLevel)Convert.ToInt32(Get(LogLevelKeyName));
return LogLevel;
}
set {
LogLevel = value;
Set(LogLevelKeyName, ((int)value).ToString());
}
}*/
}
/// <summary>
/// Save if the video was active when going to background.
......
......@@ -130,7 +130,8 @@
<ToggleSwitch
x:Name="Debug"
x:Uid="DebugSetting"
Header="DebugSetting">
Header="DebugSetting"
Toggled="Debug_Toggled">
</ToggleSwitch>
<Grid>
......
......@@ -77,8 +77,8 @@ namespace Linphone.Views {
TunnelPanel.Visibility = LinphoneManager.Instance.Core.Tunnel != null ? Visibility.Visible : Visibility.Collapsed; //Hidden properties for now
Debug.IsOn = _settings.DebugEnabled;
SendLogs.IsEnabled = true;//_settings.DebugEnabled;
ResetLogs.IsEnabled = true;//_settings.DebugEnabled;
SendLogs.IsEnabled = _settings.DebugEnabled;
ResetLogs.IsEnabled = _settings.DebugEnabled;
}
private void Save() {
......@@ -160,13 +160,15 @@ namespace Linphone.Views {
}
private void Debug_Checked(object sender, RoutedEventArgs e) {
//_settings.LogLevel = OutputTraceLevel.Message;
_settings.DebugEnabled = true;
_settings.LogLevelSetting = LogCollectionState.Enabled;
SendLogs.IsEnabled = true;
ResetLogs.IsEnabled = true;
}
private void Debug_Unchecked(object sender, RoutedEventArgs e) {
//_settings.LogLevel = OutputTraceLevel.None;
_settings.DebugEnabled = false;
_settings.LogLevelSetting = LogCollectionState.Disabled;
SendLogs.IsEnabled = false;
ResetLogs.IsEnabled = false;
}
......@@ -181,5 +183,13 @@ namespace Linphone.Views {
Frame.GoBack();
}
}
private void Debug_Toggled(object sender, RoutedEventArgs e) {
if (Debug.IsOn) {
Debug_Checked(sender, e);
} else {
Debug_Unchecked(sender, e);
}
}
}
}
\ No newline at end of file
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