Added fixes for v.0.7.20311
[pithos-ms-client] / trunk / Pithos.Client.WPF / Configuration / PithosSettings.cs
index 2d6d677..01866a4 100644 (file)
 #endregion
 using System.ComponentModel.Composition;
 using System.Diagnostics;
+using System.IO;
+using System.Linq;
 using Pithos.Client.WPF.Properties;
 using Pithos.Interfaces;
+using log4net.Appender;
+using log4net.Core;
+using log4net.Repository.Hierarchy;
 
 namespace Pithos.Client.WPF.Configuration
 {
@@ -90,10 +95,6 @@ namespace Pithos.Client.WPF.Configuration
             get { return _settings.PithosSite; }
         }*/
 
-        public string PithosLoginUrl
-        {
-            get { return _settings.PithosLoginUrl; }
-        }
 
         public string IconsPath
         {
@@ -231,6 +232,49 @@ namespace Pithos.Client.WPF.Configuration
             get { return _settings.FileIdleTimeout; }
         }
 
+        public bool UpdateForceCheck
+        {
+            get { return _settings.UpdateForceCheck; }
+        }
+
+        public bool DebugLoggingEnabled
+        {
+            get { return _settings.DebugLoggingEnabled; }
+            set
+            {
+                _settings.DebugLoggingEnabled = value;
+
+                SetDebugLevel();
+            }
+        }
+
+        private static void SetDebugLevel()
+        {
+            var loggerRepository = (Hierarchy) log4net.LogManager.GetRepository();
+
+            var appenders = loggerRepository.GetAppenders();
+
+            var debugAppender = appenders.OfType<RollingFileAppender>()
+                .FirstOrDefault(a => a.Name == "DebugFileAppender");
+            if (debugAppender != null)
+            {
+                var pithosDataPath = PithosDataPath;
+                debugAppender.File = Path.Combine(pithosDataPath, "debuglog.xml");
+                debugAppender.Threshold = !Settings.Default.DebugLoggingEnabled ? Level.Off : Level.All;
+                debugAppender.ActivateOptions();
+            }
+        }
+
+        public static string PithosDataPath
+        {
+            get
+            {
+                var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
+                var pithosDataPath = Path.Combine(appDataPath, "GRNET\\PITHOS");
+                return pithosDataPath;
+            }
+        }
+
         public void Save()
         {
             _settings.Save();