root / trunk / Pithos.ShellExtensions / ShellSettings.cs @ 422c9598
History | View | Annotate | Download (6.1 kB)
1 |
// ----------------------------------------------------------------------- |
---|---|
2 |
// <copyright file="ShellSettings.cs" company="GRNet"> |
3 |
// Copyright 2011-2012 GRNET S.A. All rights reserved. |
4 |
// |
5 |
// Redistribution and use in source and binary forms, with or |
6 |
// without modification, are permitted provided that the following |
7 |
// conditions are met: |
8 |
// |
9 |
// 1. Redistributions of source code must retain the above |
10 |
// copyright notice, this list of conditions and the following |
11 |
// disclaimer. |
12 |
// |
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. |
17 |
// |
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. |
30 |
// |
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. |
35 |
// </copyright> |
36 |
// ----------------------------------------------------------------------- |
37 |
|
38 |
using System.ComponentModel.Composition; |
39 |
using System.Diagnostics; |
40 |
using System.ServiceModel; |
41 |
using Microsoft.Win32; |
42 |
using Pithos.Interfaces; |
43 |
|
44 |
namespace Pithos.ShellExtensions |
45 |
{ |
46 |
using System; |
47 |
using System.Collections.Generic; |
48 |
using System.Linq; |
49 |
using System.Text; |
50 |
|
51 |
/// <summary> |
52 |
/// TODO: Update summary. |
53 |
/// </summary> |
54 |
[Export(typeof(IPithosSettings))] |
55 |
public class ShellSettings:IPithosSettings |
56 |
{ |
57 |
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger("Pithos.ShellSettings"); |
58 |
|
59 |
private Lazy<IPithosSettings> _settings; |
60 |
public ShellSettings() |
61 |
{ |
62 |
_settings = new Lazy<IPithosSettings>(LoadSettings); |
63 |
} |
64 |
|
65 |
public bool UseDefaultProxy |
66 |
{ |
67 |
get { return _settings.Value.UseDefaultProxy; } |
68 |
set { _settings.Value.UseDefaultProxy = value; } |
69 |
} |
70 |
|
71 |
public bool UseManualProxy |
72 |
{ |
73 |
get { return _settings.Value.UseManualProxy; } |
74 |
set { _settings.Value.UseManualProxy = value; } |
75 |
} |
76 |
|
77 |
public bool UseNoProxy |
78 |
{ |
79 |
get { return _settings.Value.UseNoProxy; } |
80 |
set { _settings.Value.UseNoProxy = value; } |
81 |
} |
82 |
|
83 |
public string PithosPath |
84 |
{ |
85 |
get { return _settings.Value.PithosPath; } |
86 |
set { _settings.Value.PithosPath = value; } |
87 |
} |
88 |
|
89 |
/* |
90 |
public string PithosSite |
91 |
{ |
92 |
get { return _settings.Value.PithosSite; } |
93 |
} |
94 |
*/ |
95 |
|
96 |
public string IconsPath |
97 |
{ |
98 |
get { return _settings.Value.IconsPath; } |
99 |
set { _settings.Value.IconsPath = value; } |
100 |
} |
101 |
|
102 |
public string UserName |
103 |
{ |
104 |
get { return _settings.Value.UserName; } |
105 |
set { _settings.Value.UserName = value; } |
106 |
} |
107 |
|
108 |
public string ApiKey |
109 |
{ |
110 |
get { return _settings.Value.ApiKey; } |
111 |
set { _settings.Value.ApiKey = value; } |
112 |
} |
113 |
|
114 |
public AccountsCollection Accounts |
115 |
{ |
116 |
get { return _settings.Value.Accounts; } |
117 |
set { _settings.Value.Accounts = value; } |
118 |
} |
119 |
|
120 |
public string ProxyServer |
121 |
{ |
122 |
get { return _settings.Value.ProxyServer; } |
123 |
set { _settings.Value.ProxyServer = value; } |
124 |
} |
125 |
|
126 |
public int ProxyPort |
127 |
{ |
128 |
get { return _settings.Value.ProxyPort; } |
129 |
set { _settings.Value.ProxyPort = value; } |
130 |
} |
131 |
|
132 |
public string ProxyUsername |
133 |
{ |
134 |
get { return _settings.Value.ProxyUsername; } |
135 |
set { _settings.Value.ProxyUsername = value; } |
136 |
} |
137 |
|
138 |
|
139 |
public string ProxyPassword |
140 |
{ |
141 |
get { return _settings.Value.ProxyPassword; } |
142 |
set { _settings.Value.ProxyPassword = value; } |
143 |
} |
144 |
|
145 |
public string ProxyDomain |
146 |
{ |
147 |
get { return _settings.Value.ProxyDomain; } |
148 |
set { _settings.Value.ProxyDomain = value; } |
149 |
} |
150 |
|
151 |
public bool ProxyAuthentication |
152 |
{ |
153 |
|
154 |
get { return _settings.Value.ProxyAuthentication; } |
155 |
set { _settings.Value.ProxyAuthentication = value; } |
156 |
} |
157 |
|
158 |
public bool ExtensionsActivated |
159 |
{ |
160 |
|
161 |
get { return _settings.Value.ExtensionsActivated; } |
162 |
set { _settings.Value.ExtensionsActivated = value; } |
163 |
} |
164 |
|
165 |
public int PollingInterval |
166 |
{ |
167 |
get { return _settings.Value.PollingInterval; } |
168 |
set { _settings.Value.PollingInterval = value; } |
169 |
} |
170 |
|
171 |
public byte HashingParallelism |
172 |
{ |
173 |
get { return _settings.Value.HashingParallelism; } |
174 |
set { _settings.Value.HashingParallelism = value; } |
175 |
} |
176 |
public void Save() |
177 |
{ |
178 |
|
179 |
} |
180 |
|
181 |
public void Reload() |
182 |
{ |
183 |
_settings=new Lazy<IPithosSettings>(LoadSettings); |
184 |
} |
185 |
|
186 |
private IPithosSettings LoadSettings() |
187 |
{ |
188 |
|
189 |
try |
190 |
{ |
191 |
using (var client = PithosHost.GetSettingsClient()) |
192 |
{ |
193 |
return client.GetSettings(); |
194 |
} |
195 |
} |
196 |
catch (Exception exc) |
197 |
{ |
198 |
Log.ErrorFormat("[ERROR] while loading settings:\r{0}",exc); |
199 |
_settings = new Lazy<IPithosSettings>(LoadSettings); |
200 |
} |
201 |
return null; |
202 |
} |
203 |
} |
204 |
} |