root / trunk / Pithos.ShellExtensions / ShellSettings.cs @ 759bd3c4
History | View | Annotate | Download (6.3 kB)
1 |
#region |
---|---|
2 |
/* ----------------------------------------------------------------------- |
3 |
* <copyright file="ShellSettings.cs" company="GRNet"> |
4 |
* |
5 |
* Copyright 2011-2012 GRNET S.A. All rights reserved. |
6 |
* |
7 |
* Redistribution and use in source and binary forms, with or |
8 |
* without modification, are permitted provided that the following |
9 |
* conditions are met: |
10 |
* |
11 |
* 1. Redistributions of source code must retain the above |
12 |
* copyright notice, this list of conditions and the following |
13 |
* disclaimer. |
14 |
* |
15 |
* 2. Redistributions in binary form must reproduce the above |
16 |
* copyright notice, this list of conditions and the following |
17 |
* disclaimer in the documentation and/or other materials |
18 |
* provided with the distribution. |
19 |
* |
20 |
* |
21 |
* THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
22 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
23 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
24 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
25 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
26 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
27 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
28 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
29 |
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
31 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
32 |
* POSSIBILITY OF SUCH DAMAGE. |
33 |
* |
34 |
* The views and conclusions contained in the software and |
35 |
* documentation are those of the authors and should not be |
36 |
* interpreted as representing official policies, either expressed |
37 |
* or implied, of GRNET S.A. |
38 |
* </copyright> |
39 |
* ----------------------------------------------------------------------- |
40 |
*/ |
41 |
#endregion |
42 |
using System.ComponentModel.Composition; |
43 |
using System.Diagnostics; |
44 |
using System.ServiceModel; |
45 |
using Microsoft.Win32; |
46 |
using Pithos.Interfaces; |
47 |
|
48 |
namespace Pithos.ShellExtensions |
49 |
{ |
50 |
using System; |
51 |
using System.Collections.Generic; |
52 |
using System.Linq; |
53 |
using System.Text; |
54 |
|
55 |
/// <summary> |
56 |
/// TODO: Update summary. |
57 |
/// </summary> |
58 |
[Export(typeof(IPithosSettings))] |
59 |
public class ShellSettings:IPithosSettings |
60 |
{ |
61 |
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger("Pithos.ShellSettings"); |
62 |
|
63 |
private Lazy<IPithosSettings> _settings; |
64 |
public ShellSettings() |
65 |
{ |
66 |
_settings = new Lazy<IPithosSettings>(LoadSettings); |
67 |
} |
68 |
|
69 |
public bool UseDefaultProxy |
70 |
{ |
71 |
get { return _settings.Value.UseDefaultProxy; } |
72 |
set { _settings.Value.UseDefaultProxy = value; } |
73 |
} |
74 |
|
75 |
public bool UseManualProxy |
76 |
{ |
77 |
get { return _settings.Value.UseManualProxy; } |
78 |
set { _settings.Value.UseManualProxy = value; } |
79 |
} |
80 |
|
81 |
public bool UseNoProxy |
82 |
{ |
83 |
get { return _settings.Value.UseNoProxy; } |
84 |
set { _settings.Value.UseNoProxy = value; } |
85 |
} |
86 |
|
87 |
public string PithosPath |
88 |
{ |
89 |
get { return _settings.Value.PithosPath; } |
90 |
set { _settings.Value.PithosPath = value; } |
91 |
} |
92 |
|
93 |
/* |
94 |
public string PithosSite |
95 |
{ |
96 |
get { return _settings.Value.PithosSite; } |
97 |
} |
98 |
*/ |
99 |
|
100 |
public string IconsPath |
101 |
{ |
102 |
get { return _settings.Value.IconsPath; } |
103 |
set { _settings.Value.IconsPath = value; } |
104 |
} |
105 |
|
106 |
public string UserName |
107 |
{ |
108 |
get { return _settings.Value.UserName; } |
109 |
set { _settings.Value.UserName = value; } |
110 |
} |
111 |
|
112 |
public string ApiKey |
113 |
{ |
114 |
get { return _settings.Value.ApiKey; } |
115 |
set { _settings.Value.ApiKey = value; } |
116 |
} |
117 |
|
118 |
public AccountsCollection Accounts |
119 |
{ |
120 |
get { return _settings.Value.Accounts; } |
121 |
set { _settings.Value.Accounts = value; } |
122 |
} |
123 |
|
124 |
public string ProxyServer |
125 |
{ |
126 |
get { return _settings.Value.ProxyServer; } |
127 |
set { _settings.Value.ProxyServer = value; } |
128 |
} |
129 |
|
130 |
public int ProxyPort |
131 |
{ |
132 |
get { return _settings.Value.ProxyPort; } |
133 |
set { _settings.Value.ProxyPort = value; } |
134 |
} |
135 |
|
136 |
public string ProxyUsername |
137 |
{ |
138 |
get { return _settings.Value.ProxyUsername; } |
139 |
set { _settings.Value.ProxyUsername = value; } |
140 |
} |
141 |
|
142 |
|
143 |
public string ProxyPassword |
144 |
{ |
145 |
get { return _settings.Value.ProxyPassword; } |
146 |
set { _settings.Value.ProxyPassword = value; } |
147 |
} |
148 |
|
149 |
public string ProxyDomain |
150 |
{ |
151 |
get { return _settings.Value.ProxyDomain; } |
152 |
set { _settings.Value.ProxyDomain = value; } |
153 |
} |
154 |
|
155 |
public bool ProxyAuthentication |
156 |
{ |
157 |
|
158 |
get { return _settings.Value.ProxyAuthentication; } |
159 |
set { _settings.Value.ProxyAuthentication = value; } |
160 |
} |
161 |
|
162 |
public bool ExtensionsActivated |
163 |
{ |
164 |
|
165 |
get { return _settings.Value.ExtensionsActivated; } |
166 |
set { _settings.Value.ExtensionsActivated = value; } |
167 |
} |
168 |
|
169 |
public int PollingInterval |
170 |
{ |
171 |
get { return _settings.Value.PollingInterval; } |
172 |
set { _settings.Value.PollingInterval = value; } |
173 |
} |
174 |
|
175 |
public TimeSpan StartupDelay |
176 |
{ |
177 |
get { return _settings.Value.StartupDelay; } |
178 |
set { _settings.Value.StartupDelay = value; } |
179 |
} |
180 |
|
181 |
public byte HashingParallelism |
182 |
{ |
183 |
get { return _settings.Value.HashingParallelism; } |
184 |
set { _settings.Value.HashingParallelism = value; } |
185 |
} |
186 |
public void Save() |
187 |
{ |
188 |
|
189 |
} |
190 |
|
191 |
public void Reload() |
192 |
{ |
193 |
_settings=new Lazy<IPithosSettings>(LoadSettings); |
194 |
} |
195 |
|
196 |
private IPithosSettings LoadSettings() |
197 |
{ |
198 |
|
199 |
try |
200 |
{ |
201 |
using (var client = PithosHost.GetSettingsClient()) |
202 |
{ |
203 |
return client.GetSettings(); |
204 |
} |
205 |
} |
206 |
catch (Exception exc) |
207 |
{ |
208 |
Log.ErrorFormat("[ERROR] while loading settings:\r{0}",exc); |
209 |
_settings = new Lazy<IPithosSettings>(LoadSettings); |
210 |
} |
211 |
return null; |
212 |
} |
213 |
} |
214 |
} |