X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/422c95986b3df62f19df5434f6480948813cfd43..81c5c3103c8046362017f216027eb56169ae3b33:/trunk/Pithos.Client.WPF/Configuration/PithosSettings.cs
diff --git a/trunk/Pithos.Client.WPF/Configuration/PithosSettings.cs b/trunk/Pithos.Client.WPF/Configuration/PithosSettings.cs
index aa59f66..01866a4 100644
--- a/trunk/Pithos.Client.WPF/Configuration/PithosSettings.cs
+++ b/trunk/Pithos.Client.WPF/Configuration/PithosSettings.cs
@@ -1,52 +1,57 @@
-// -----------------------------------------------------------------------
-//
-// Copyright 2011-2012 GRNET S.A. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or
-// without modification, are permitted provided that the following
-// conditions are met:
-//
-// 1. Redistributions of source code must retain the above
-// copyright notice, this list of conditions and the following
-// disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials
-// provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// The views and conclusions contained in the software and
-// documentation are those of the authors and should not be
-// interpreted as representing official policies, either expressed
-// or implied, of GRNET S.A.
-//
-// -----------------------------------------------------------------------
-
+#region
+/* -----------------------------------------------------------------------
+ *
+ *
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ *
+ * -----------------------------------------------------------------------
+ */
+#endregion
using System.ComponentModel.Composition;
-using System.Configuration;
-using System.Dynamic;
+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
{
using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
[Export(typeof(IPithosSettings))]
[Export]
@@ -56,7 +61,9 @@ namespace Pithos.Client.WPF.Configuration
public PithosSettings()
{
- _settings.Upgrade();
+ //Settings should already be upgraded by the time we reach this point
+ Debug.Assert(!_settings.MustUpgrade);
+ //_settings.Upgrade();
}
public bool UseDefaultProxy
@@ -88,10 +95,6 @@ namespace Pithos.Client.WPF.Configuration
get { return _settings.PithosSite; }
}*/
- public string PithosLoginUrl
- {
- get { return _settings.PithosLoginUrl; }
- }
public string IconsPath
{
@@ -113,12 +116,7 @@ namespace Pithos.Client.WPF.Configuration
public AccountsCollection Accounts
{
- get
- {
- if (_settings.Accounts==null)
- _settings.Accounts=new AccountsCollection();
- return _settings.Accounts;
- }
+ get { return _settings.Accounts ?? (_settings.Accounts = new AccountsCollection()); }
set { _settings.Accounts = value; }
}
@@ -187,6 +185,18 @@ namespace Pithos.Client.WPF.Configuration
}
}
+ public TimeSpan StartupDelay
+ {
+ get { return _settings.StartupDelay; }
+ set
+ {
+ if (value < TimeSpan.Zero)
+ throw new ArgumentOutOfRangeException();
+ _settings.StartupDelay = value;
+ }
+ }
+
+
public bool StartOnSystemStartup
{
get { return _settings.StartOnSystemStartup; }
@@ -201,37 +211,85 @@ namespace Pithos.Client.WPF.Configuration
get { return _settings.HashingParallelism; }
set { _settings.HashingParallelism = value; }
}
-/*
- public override IEnumerable GetDynamicMemberNames()
+
+ public string UpdateUrl
+ {
+ get { return _settings.UpdateUrl; }
+ }
+
+ public bool UpdateDiagnostics
+ {
+ get { return _settings.UpdateDiagnostics; }
+ }
+
+ public TimeSpan UpdateCheckInterval
+ {
+ get { return _settings.UpdateCheckInterval; }
+ }
+
+ public TimeSpan FileIdleTimeout
+ {
+ get { return _settings.FileIdleTimeout; }
+ }
+
+ public bool UpdateForceCheck
{
- return (from SettingsProperty property in _settings.Properties
- select property.Name);
+ get { return _settings.UpdateForceCheck; }
}
+ public bool DebugLoggingEnabled
+ {
+ get { return _settings.DebugLoggingEnabled; }
+ set
+ {
+ _settings.DebugLoggingEnabled = value;
- private Lazy> _propertyNames = new Lazy>(
- () => (from SettingsProperty property in
- _settings.Properties
- select property).ToLookup(property => property.Name));
+ SetDebugLevel();
+ }
+ }
- public override bool TryGetMember(GetMemberBinder binder, out object result)
+ private static void SetDebugLevel()
{
- result = null;
- if (!_propertyNames.Value.Contains(binder.Name))
- return false;
- result=_settings.Properties[binder.Name];
- return true;
+ var loggerRepository = (Hierarchy) log4net.LogManager.GetRepository();
+
+ var appenders = loggerRepository.GetAppenders();
+
+ var debugAppender = appenders.OfType()
+ .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();
+ Proxy.SetFromSettings(this);
}
public void Reload()
{
_settings.Reload();
}
+
+ public void Reset()
+ {
+ _settings.Reset();
+ _settings.Save();
+ }
}
}