1 // -----------------------------------------------------------------------
2 // <copyright file="ShellSettings.cs" company="GRNet">
3 // Copyright 2011 GRNET S.A. All rights reserved.
5 // Redistribution and use in source and binary forms, with or
6 // without modification, are permitted provided that the following
9 // 1. Redistributions of source code must retain the above
10 // copyright notice, this list of conditions and the following
13 // 2. Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials
16 // provided with the distribution.
18 // THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
19 // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
22 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
31 // The views and conclusions contained in the software and
32 // documentation are those of the authors and should not be
33 // interpreted as representing official policies, either expressed
34 // or implied, of GRNET S.A.
36 // -----------------------------------------------------------------------
38 using System.ComponentModel.Composition;
39 using System.Diagnostics;
40 using System.ServiceModel;
41 using Microsoft.Win32;
42 using Pithos.Interfaces;
44 namespace Pithos.ShellExtensions
47 using System.Collections.Generic;
52 /// TODO: Update summary.
54 [Export(typeof(IPithosSettings))]
55 public class ShellSettings:IPithosSettings
57 private static readonly log4net.ILog Log = log4net.LogManager.GetLogger("Pithos.ShellSettings");
59 private Lazy<IPithosSettings> _settings;
60 public ShellSettings()
62 _settings = new Lazy<IPithosSettings>(LoadSettings);
65 public bool UseDefaultProxy
67 get { return _settings.Value.UseDefaultProxy; }
68 set { _settings.Value.UseDefaultProxy = value; }
71 public bool UseManualProxy
73 get { return _settings.Value.UseManualProxy; }
74 set { _settings.Value.UseManualProxy = value; }
77 public bool UseNoProxy
79 get { return _settings.Value.UseNoProxy; }
80 set { _settings.Value.UseNoProxy = value; }
83 public string PithosPath
85 get { return _settings.Value.PithosPath; }
86 set { _settings.Value.PithosPath = value; }
90 public string PithosSite
92 get { return _settings.Value.PithosSite; }
96 public string IconsPath
98 get { return _settings.Value.IconsPath; }
99 set { _settings.Value.IconsPath = value; }
102 public string UserName
104 get { return _settings.Value.UserName; }
105 set { _settings.Value.UserName = value; }
110 get { return _settings.Value.ApiKey; }
111 set { _settings.Value.ApiKey = value; }
114 public AccountsCollection Accounts
116 get { return _settings.Value.Accounts; }
117 set { _settings.Value.Accounts = value; }
120 public string ProxyServer
122 get { return _settings.Value.ProxyServer; }
123 set { _settings.Value.ProxyServer = value; }
128 get { return _settings.Value.ProxyPort; }
129 set { _settings.Value.ProxyPort = value; }
132 public string ProxyUsername
134 get { return _settings.Value.ProxyUsername; }
135 set { _settings.Value.ProxyUsername = value; }
139 public string ProxyPassword
141 get { return _settings.Value.ProxyPassword; }
142 set { _settings.Value.ProxyPassword = value; }
145 public string ProxyDomain
147 get { return _settings.Value.ProxyDomain; }
148 set { _settings.Value.ProxyDomain = value; }
151 public bool ProxyAuthentication
154 get { return _settings.Value.ProxyAuthentication; }
155 set { _settings.Value.ProxyAuthentication = value; }
158 public bool ExtensionsActivated
161 get { return _settings.Value.ExtensionsActivated; }
162 set { _settings.Value.ExtensionsActivated = value; }
165 public int PollingInterval
167 get { return _settings.Value.PollingInterval; }
168 set { _settings.Value.PollingInterval = value; }
177 _settings=new Lazy<IPithosSettings>(LoadSettings);
180 private IPithosSettings LoadSettings()
185 using (var client = PithosHost.GetSettingsClient())
187 return client.GetSettings();
190 catch (Exception exc)
192 Log.ErrorFormat("[ERROR] while loading settings:\r{0}",exc);
193 _settings = new Lazy<IPithosSettings>(LoadSettings);