Status: | Work in progress | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~cszikszoy/do/proxy | ||||
Merge into: | lp:do | ||||
Diff against target: |
421 lines (+210/-18) 10 files modified
Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GConfPreferencesService.cs (+29/-4) Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/NetworkService.cs (+108/-4) Do.Platform/src/Do.Platform/Do.Platform.Common/DictionaryPreferencesService.cs (+15/-5) Do.Platform/src/Do.Platform/Do.Platform.Default/NetworkService.cs (+7/-0) Do.Platform/src/Do.Platform/Do.Platform.Default/PreferencesService.cs (+13/-1) Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs (+16/-3) Do.Platform/src/Do.Platform/INetworkService.cs (+2/-0) Do.Platform/src/Do.Platform/IPreferences.cs (+3/-0) Do.Platform/src/Do.Platform/IPreferencesService.cs (+3/-0) Do.Platform/src/Do.Platform/SecurePreferencesWrapper.cs (+14/-1) |
||||
To merge this branch: | bzr merge lp:~cszikszoy/do/proxy | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Halse Rogers | Needs Information | ||
Review via email: mp+22351@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Chris Halse Rogers (raof) wrote : | # |
Actually, make that “need info”
review:
Needs Information
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GConfPreferencesService.cs' | |||
2 | --- Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GConfPreferencesService.cs 2009-08-31 01:58:13 +0000 | |||
3 | +++ Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GConfPreferencesService.cs 2010-03-29 03:16:18 +0000 | |||
4 | @@ -43,8 +43,13 @@ | |||
5 | 43 | 43 | ||
6 | 44 | void HandleGConfChanged (object sender, GConf.NotifyEventArgs args) | 44 | void HandleGConfChanged (object sender, GConf.NotifyEventArgs args) |
7 | 45 | { | 45 | { |
8 | 46 | // if this key falls under the RootPath, strip away that part of the key, | ||
9 | 47 | // otherwise we leave the full path to the key. | ||
10 | 48 | string key = args.Key; | ||
11 | 49 | if (key.StartsWith (RootPath)) | ||
12 | 50 | key = args.Key.Substring (RootPath.Length + 1); | ||
13 | 46 | if (PreferencesChanged != null) | 51 | if (PreferencesChanged != null) |
15 | 47 | PreferencesChanged (this, new PreferencesChangedEventArgs (args.Key.Substring(RootPath.Length + 1), args.Value)); | 52 | PreferencesChanged (this, new PreferencesChangedEventArgs (key, args.Value)); |
16 | 48 | } | 53 | } |
17 | 49 | 54 | ||
18 | 50 | string AbsolutePathForKey (string key) | 55 | string AbsolutePathForKey (string key) |
19 | @@ -74,9 +79,9 @@ | |||
20 | 74 | public bool TryGet<T> (string key, out T val) | 79 | public bool TryGet<T> (string key, out T val) |
21 | 75 | { | 80 | { |
22 | 76 | bool success = true; | 81 | bool success = true; |
24 | 77 | val = default (T); | 82 | val = default(T); |
25 | 78 | try { | 83 | try { |
27 | 79 | val = (T) client.Get (AbsolutePathForKey (key)); | 84 | val = (T)client.Get (AbsolutePathForKey (key)); |
28 | 80 | } catch (GConf.NoSuchKeyException) { | 85 | } catch (GConf.NoSuchKeyException) { |
29 | 81 | // We don't need to log this, because many keys that do not | 86 | // We don't need to log this, because many keys that do not |
30 | 82 | // exist are asked for. | 87 | // exist are asked for. |
31 | @@ -88,7 +93,27 @@ | |||
32 | 88 | } | 93 | } |
33 | 89 | return success; | 94 | return success; |
34 | 90 | } | 95 | } |
35 | 96 | |||
36 | 97 | public void AddNotify (string path) | ||
37 | 98 | { | ||
38 | 99 | try { | ||
39 | 100 | client.AddNotify (path, HandleGConfChanged); | ||
40 | 101 | } catch (Exception e) { | ||
41 | 102 | Log.Error ("Error removing notification handler, {0}", e.Message); | ||
42 | 103 | Log.Debug (e.StackTrace); | ||
43 | 104 | } | ||
44 | 105 | } | ||
45 | 106 | |||
46 | 107 | public void RemoveNotify (string path) | ||
47 | 108 | { | ||
48 | 109 | try { | ||
49 | 110 | client.RemoveNotify (path, HandleGConfChanged); | ||
50 | 111 | } catch (Exception e) { | ||
51 | 112 | Log.Error ("Error removing notification handler, {0}", e.Message); | ||
52 | 113 | Log.Debug (e.StackTrace); | ||
53 | 114 | } | ||
54 | 115 | } | ||
55 | 91 | 116 | ||
56 | 92 | #endregion | 117 | #endregion |
57 | 93 | } | 118 | } |
59 | 94 | } | 119 | } |
60 | 95 | \ No newline at end of file | 120 | \ No newline at end of file |
61 | 96 | 121 | ||
62 | === modified file 'Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/NetworkService.cs' | |||
63 | --- Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/NetworkService.cs 2009-10-21 07:06:25 +0000 | |||
64 | +++ Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/NetworkService.cs 2010-03-29 03:16:18 +0000 | |||
65 | @@ -18,6 +18,7 @@ | |||
66 | 18 | // | 18 | // |
67 | 19 | 19 | ||
68 | 20 | using System; | 20 | using System; |
69 | 21 | using System.Net; | ||
70 | 21 | using System.Reflection; | 22 | using System.Reflection; |
71 | 22 | 23 | ||
72 | 23 | using NDesk.DBus; | 24 | using NDesk.DBus; |
73 | @@ -28,9 +29,65 @@ | |||
74 | 28 | 29 | ||
75 | 29 | namespace Do.Platform.Linux | 30 | namespace Do.Platform.Linux |
76 | 30 | { | 31 | { |
79 | 31 | 32 | ||
80 | 32 | public class NetworkService : INetworkService | 33 | public class NetworkService : INetworkService, IInitializedService |
81 | 33 | { | 34 | { |
82 | 35 | class NetworkPreferencesWrapper | ||
83 | 36 | { | ||
84 | 37 | const string PROXY = "/system/http_proxy"; | ||
85 | 38 | const string PROXY_USE_PROXY = PROXY + "/" + "use_http_proxy"; | ||
86 | 39 | const string PROXY_HOST = PROXY + "/" + "host"; | ||
87 | 40 | const string PROXY_PORT = PROXY + "/" + "port"; | ||
88 | 41 | const string PROXY_USER = PROXY + "/" + "authentication_user"; | ||
89 | 42 | const string PROXY_PASSWORD = PROXY + "/" + "authentication_password"; | ||
90 | 43 | const string PROXY_BYPASS_LIST = PROXY + "/" + "ignore_hosts"; | ||
91 | 44 | |||
92 | 45 | IPreferences Preferences { get; set; } | ||
93 | 46 | |||
94 | 47 | public event EventHandler ProxyChanged; | ||
95 | 48 | |||
96 | 49 | public bool UseProxy { | ||
97 | 50 | get { return Preferences.Get<bool> (PROXY_USE_PROXY, false); } | ||
98 | 51 | } | ||
99 | 52 | public string ProxyHost { | ||
100 | 53 | get { return Preferences.Get<string> (PROXY_HOST, ""); } | ||
101 | 54 | } | ||
102 | 55 | public int ProxyPort { | ||
103 | 56 | get { return Preferences.Get<int> (PROXY_PORT, 0); } | ||
104 | 57 | } | ||
105 | 58 | public string ProxyUser { | ||
106 | 59 | get { return Preferences.Get<string> (PROXY_USER, ""); } | ||
107 | 60 | } | ||
108 | 61 | public string ProxyPassword { | ||
109 | 62 | get { return Preferences.Get<string> (PROXY_PASSWORD, ""); } | ||
110 | 63 | } | ||
111 | 64 | public string[] ProxyBypassList { | ||
112 | 65 | get { return Preferences.Get<string[]> (PROXY_BYPASS_LIST, new[] { "" }); } | ||
113 | 66 | } | ||
114 | 67 | |||
115 | 68 | public NetworkPreferencesWrapper () | ||
116 | 69 | { | ||
117 | 70 | Preferences = Services.Preferences.Get<NetworkPreferencesWrapper> (); | ||
118 | 71 | Preferences.AddNotify (PROXY); | ||
119 | 72 | Preferences.PreferencesChanged += OnPrefsChanged; | ||
120 | 73 | } | ||
121 | 74 | |||
122 | 75 | void OnPrefsChanged (object sender, PreferencesChangedEventArgs e) | ||
123 | 76 | { | ||
124 | 77 | switch (e.Key) { | ||
125 | 78 | case PROXY_USE_PROXY: | ||
126 | 79 | case PROXY_HOST: | ||
127 | 80 | case PROXY_PORT: | ||
128 | 81 | case PROXY_USER: | ||
129 | 82 | case PROXY_PASSWORD: | ||
130 | 83 | case PROXY_BYPASS_LIST: | ||
131 | 84 | if (ProxyChanged != null) | ||
132 | 85 | ProxyChanged (this, EventArgs.Empty); | ||
133 | 86 | break; | ||
134 | 87 | } | ||
135 | 88 | } | ||
136 | 89 | } | ||
137 | 90 | |||
138 | 34 | const string NetworkManagerName = "org.freedesktop.NetworkManager"; | 91 | const string NetworkManagerName = "org.freedesktop.NetworkManager"; |
139 | 35 | const string NetworkManagerPath = "/org/freedesktop/NetworkManager"; | 92 | const string NetworkManagerPath = "/org/freedesktop/NetworkManager"; |
140 | 36 | 93 | ||
141 | @@ -43,6 +100,7 @@ | |||
142 | 43 | delegate void StateChangedHandler (uint state); | 100 | delegate void StateChangedHandler (uint state); |
143 | 44 | 101 | ||
144 | 45 | INetworkManager network; | 102 | INetworkManager network; |
145 | 103 | static NetworkPreferencesWrapper prefs; | ||
146 | 46 | 104 | ||
147 | 47 | public event EventHandler<NetworkStateChangedEventArgs> StateChanged; | 105 | public event EventHandler<NetworkStateChangedEventArgs> StateChanged; |
148 | 48 | 106 | ||
149 | @@ -62,6 +120,15 @@ | |||
150 | 62 | Log<NetworkService>.Debug (e.StackTrace); | 120 | Log<NetworkService>.Debug (e.StackTrace); |
151 | 63 | } | 121 | } |
152 | 64 | } | 122 | } |
153 | 123 | |||
154 | 124 | public void Initialize () | ||
155 | 125 | { | ||
156 | 126 | prefs = new NetworkPreferencesWrapper (); | ||
157 | 127 | UpdateProxySettings (); | ||
158 | 128 | prefs.ProxyChanged += delegate { | ||
159 | 129 | UpdateProxySettings (); | ||
160 | 130 | }; | ||
161 | 131 | } | ||
162 | 65 | 132 | ||
163 | 66 | void OnStateChanged (uint state) | 133 | void OnStateChanged (uint state) |
164 | 67 | { | 134 | { |
165 | @@ -81,18 +148,55 @@ | |||
166 | 81 | } | 148 | } |
167 | 82 | 149 | ||
168 | 83 | NetworkState State { | 150 | NetworkState State { |
170 | 84 | get { | 151 | get { |
171 | 85 | try { | 152 | try { |
173 | 86 | return (NetworkState) Enum.ToObject (typeof (NetworkState), network.Get (NetworkManagerName, "State")); | 153 | return (NetworkState)Enum.ToObject (typeof(NetworkState), network.Get (NetworkManagerName, "State")); |
174 | 87 | } catch (Exception) { | 154 | } catch (Exception) { |
175 | 88 | return NetworkState.Unknown; | 155 | return NetworkState.Unknown; |
176 | 89 | } | 156 | } |
177 | 90 | } | 157 | } |
178 | 91 | } | 158 | } |
179 | 92 | 159 | ||
180 | 160 | void UpdateProxySettings () | ||
181 | 161 | { | ||
182 | 162 | WebProxy proxy; | ||
183 | 163 | |||
184 | 164 | if (!prefs.UseProxy) { | ||
185 | 165 | WebRequest.DefaultWebProxy = null; | ||
186 | 166 | return; | ||
187 | 167 | } | ||
188 | 168 | |||
189 | 169 | try { | ||
190 | 170 | string proxyUri = string.Format ("http://{0}:{1}", prefs.ProxyHost, prefs.ProxyPort); | ||
191 | 171 | |||
192 | 172 | proxy = new WebProxy (proxyUri); | ||
193 | 173 | string[] bypassList = prefs.ProxyBypassList; | ||
194 | 174 | if (bypassList != null) { | ||
195 | 175 | foreach (string host in bypassList) { | ||
196 | 176 | if (host.Contains ("*.local")) { | ||
197 | 177 | proxy.BypassProxyOnLocal = true; | ||
198 | 178 | continue; | ||
199 | 179 | } | ||
200 | 180 | proxy.BypassArrayList.Add (string.Format ("http://{0}", host)); | ||
201 | 181 | } | ||
202 | 182 | } | ||
203 | 183 | proxy.Credentials = new NetworkCredential (prefs.ProxyUser, prefs.ProxyPassword); | ||
204 | 184 | } catch (Exception e) { | ||
205 | 185 | Log.Error ("Error creating web proxy, {0}", e.Message); | ||
206 | 186 | Log.Debug (e.StackTrace); | ||
207 | 187 | proxy = null; | ||
208 | 188 | } | ||
209 | 189 | |||
210 | 190 | WebRequest.DefaultWebProxy = proxy; | ||
211 | 191 | } | ||
212 | 192 | |||
213 | 93 | #region INetworkService | 193 | #region INetworkService |
214 | 94 | 194 | ||
215 | 95 | public bool IsConnected { get; private set; } | 195 | public bool IsConnected { get; private set; } |
216 | 196 | |||
217 | 197 | public string UserAgent { | ||
218 | 198 | get { return @"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2) Gecko/20100308 Ubuntu/10.04 (lucid) Firefox/3.6"; } | ||
219 | 199 | } | ||
220 | 96 | 200 | ||
221 | 97 | #endregion | 201 | #endregion |
222 | 98 | } | 202 | } |
223 | 99 | 203 | ||
224 | === modified file 'Do.Platform/src/Do.Platform/Do.Platform.Common/DictionaryPreferencesService.cs' | |||
225 | --- Do.Platform/src/Do.Platform/Do.Platform.Common/DictionaryPreferencesService.cs 2009-08-31 01:58:13 +0000 | |||
226 | +++ Do.Platform/src/Do.Platform/Do.Platform.Common/DictionaryPreferencesService.cs 2010-03-29 03:16:18 +0000 | |||
227 | @@ -57,15 +57,25 @@ | |||
228 | 57 | object val_object; | 57 | object val_object; |
229 | 58 | bool success = Store.TryGetValue (key, out val_object); | 58 | bool success = Store.TryGetValue (key, out val_object); |
230 | 59 | 59 | ||
232 | 60 | val = default (T); | 60 | val = default(T); |
233 | 61 | if (success) | 61 | if (success) |
235 | 62 | val = (T) val_object; | 62 | val = (T)val_object; |
236 | 63 | 63 | ||
237 | 64 | return success; | 64 | return success; |
238 | 65 | } | 65 | } |
239 | 66 | |||
240 | 67 | public void AddNotify (string path) | ||
241 | 68 | { | ||
242 | 69 | Log.Debug ("Dictionary preferences service cannot add notifications"); | ||
243 | 70 | return; | ||
244 | 71 | } | ||
245 | 72 | |||
246 | 73 | public void RemoveNotify (string path) | ||
247 | 74 | { | ||
248 | 75 | Log.Debug ("Dictionary preferences service cannot remove notifications"); | ||
249 | 76 | return; | ||
250 | 77 | } | ||
251 | 66 | 78 | ||
252 | 67 | #endregion | 79 | #endregion |
253 | 68 | |||
254 | 69 | } | 80 | } |
257 | 70 | 81 | } | |
256 | 71 | } | ||
258 | 72 | \ No newline at end of file | 82 | \ No newline at end of file |
259 | 73 | 83 | ||
260 | === modified file 'Do.Platform/src/Do.Platform/Do.Platform.Default/NetworkService.cs' | |||
261 | --- Do.Platform/src/Do.Platform/Do.Platform.Default/NetworkService.cs 2009-06-10 05:30:30 +0000 | |||
262 | +++ Do.Platform/src/Do.Platform/Do.Platform.Default/NetworkService.cs 2010-03-29 03:16:18 +0000 | |||
263 | @@ -19,6 +19,7 @@ | |||
264 | 19 | */ | 19 | */ |
265 | 20 | 20 | ||
266 | 21 | using System; | 21 | using System; |
267 | 22 | using System.Net; | ||
268 | 22 | 23 | ||
269 | 23 | using Do.Platform; | 24 | using Do.Platform; |
270 | 24 | 25 | ||
271 | @@ -43,6 +44,12 @@ | |||
272 | 43 | get { return connected; } | 44 | get { return connected; } |
273 | 44 | } | 45 | } |
274 | 45 | 46 | ||
275 | 47 | public string UserAgent { | ||
276 | 48 | get { | ||
277 | 49 | return @"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2) Gecko/20100308 Ubuntu/10.04 (lucid) Firefox/3.6"; | ||
278 | 50 | } | ||
279 | 51 | } | ||
280 | 52 | |||
281 | 46 | #endregion | 53 | #endregion |
282 | 47 | } | 54 | } |
283 | 48 | } | 55 | } |
284 | 49 | 56 | ||
285 | === modified file 'Do.Platform/src/Do.Platform/Do.Platform.Default/PreferencesService.cs' | |||
286 | --- Do.Platform/src/Do.Platform/Do.Platform.Default/PreferencesService.cs 2009-08-28 05:42:11 +0000 | |||
287 | +++ Do.Platform/src/Do.Platform/Do.Platform.Default/PreferencesService.cs 2010-03-29 03:16:18 +0000 | |||
288 | @@ -40,9 +40,21 @@ | |||
289 | 40 | public bool TryGet<T> (string key, out T val) | 40 | public bool TryGet<T> (string key, out T val) |
290 | 41 | { | 41 | { |
291 | 42 | Log.Debug ("Default IPreferencesService cannot get key \"{0}\".", key); | 42 | Log.Debug ("Default IPreferencesService cannot get key \"{0}\".", key); |
293 | 43 | val = default (T); | 43 | val = default(T); |
294 | 44 | return false; | 44 | return false; |
295 | 45 | } | 45 | } |
296 | 46 | |||
297 | 47 | public void AddNotify (string path) | ||
298 | 48 | { | ||
299 | 49 | Log.Debug ("Default IPreferencesService cannot add notifications"); | ||
300 | 50 | return; | ||
301 | 51 | } | ||
302 | 52 | |||
303 | 53 | public void RemoveNotify (string path) | ||
304 | 54 | { | ||
305 | 55 | Log.Debug ("Default IPreferencesService cannot remove notifications"); | ||
306 | 56 | return; | ||
307 | 57 | } | ||
308 | 46 | 58 | ||
309 | 47 | #endregion | 59 | #endregion |
310 | 48 | 60 | ||
311 | 49 | 61 | ||
312 | === modified file 'Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs' | |||
313 | --- Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs 2009-08-31 01:58:13 +0000 | |||
314 | +++ Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs 2010-03-29 03:16:18 +0000 | |||
315 | @@ -43,10 +43,13 @@ | |||
316 | 43 | 43 | ||
317 | 44 | void HandlePreferencesChanged (object o, PreferencesChangedEventArgs e) | 44 | void HandlePreferencesChanged (object o, PreferencesChangedEventArgs e) |
318 | 45 | { | 45 | { |
321 | 46 | if (e.Key.Length <= OwnerString.Length + 1 || e.Key.Substring(0, OwnerString.Length) != OwnerString) | 46 | // if the key starts with the OwnerString, just send the relative key |
322 | 47 | return; | 47 | // otherwise we send the full path to the key |
323 | 48 | string key = e.Key; | ||
324 | 49 | if (e.Key.StartsWith (OwnerString)) | ||
325 | 50 | key = e.Key.Substring (OwnerString.Length + 1); | ||
326 | 48 | if (PreferencesChanged != null) | 51 | if (PreferencesChanged != null) |
328 | 49 | PreferencesChanged (this, new PreferencesChangedEventArgs (e.Key.Substring(OwnerString.Length + 1), e.Value)); | 52 | PreferencesChanged (this, new PreferencesChangedEventArgs (key, e.Value)); |
329 | 50 | } | 53 | } |
330 | 51 | 54 | ||
331 | 52 | #region IPreferences | 55 | #region IPreferences |
332 | @@ -93,6 +96,16 @@ | |||
333 | 93 | { | 96 | { |
334 | 94 | return Set (SecureService, key, val); | 97 | return Set (SecureService, key, val); |
335 | 95 | } | 98 | } |
336 | 99 | |||
337 | 100 | public void AddNotify (string path) | ||
338 | 101 | { | ||
339 | 102 | Service.AddNotify (path); | ||
340 | 103 | } | ||
341 | 104 | |||
342 | 105 | public void RemoveNotify (string path) | ||
343 | 106 | { | ||
344 | 107 | Service.RemoveNotify (path); | ||
345 | 108 | } | ||
346 | 96 | 109 | ||
347 | 97 | #endregion | 110 | #endregion |
348 | 98 | 111 | ||
349 | 99 | 112 | ||
350 | === modified file 'Do.Platform/src/Do.Platform/INetworkService.cs' | |||
351 | --- Do.Platform/src/Do.Platform/INetworkService.cs 2009-06-10 05:30:30 +0000 | |||
352 | +++ Do.Platform/src/Do.Platform/INetworkService.cs 2010-03-29 03:16:18 +0000 | |||
353 | @@ -19,6 +19,7 @@ | |||
354 | 19 | */ | 19 | */ |
355 | 20 | 20 | ||
356 | 21 | using System; | 21 | using System; |
357 | 22 | using System.Net; | ||
358 | 22 | 23 | ||
359 | 23 | using Do.Platform.ServiceStack; | 24 | using Do.Platform.ServiceStack; |
360 | 24 | 25 | ||
361 | @@ -38,5 +39,6 @@ | |||
362 | 38 | event EventHandler<NetworkStateChangedEventArgs> StateChanged; | 39 | event EventHandler<NetworkStateChangedEventArgs> StateChanged; |
363 | 39 | 40 | ||
364 | 40 | bool IsConnected { get; } | 41 | bool IsConnected { get; } |
365 | 42 | string UserAgent { get; } | ||
366 | 41 | } | 43 | } |
367 | 42 | } | 44 | } |
368 | 43 | \ No newline at end of file | 45 | \ No newline at end of file |
369 | 44 | 46 | ||
370 | === modified file 'Do.Platform/src/Do.Platform/IPreferences.cs' | |||
371 | --- Do.Platform/src/Do.Platform/IPreferences.cs 2008-12-22 01:33:29 +0000 | |||
372 | +++ Do.Platform/src/Do.Platform/IPreferences.cs 2010-03-29 03:16:18 +0000 | |||
373 | @@ -33,5 +33,8 @@ | |||
374 | 33 | T Get<T> (string key, T def); | 33 | T Get<T> (string key, T def); |
375 | 34 | bool SetSecure<T> (string key, T def); | 34 | bool SetSecure<T> (string key, T def); |
376 | 35 | T GetSecure<T> (string key, T def); | 35 | T GetSecure<T> (string key, T def); |
377 | 36 | |||
378 | 37 | void AddNotify (string path); | ||
379 | 38 | void RemoveNotify (string path); | ||
380 | 36 | } | 39 | } |
381 | 37 | } | 40 | } |
382 | 38 | \ No newline at end of file | 41 | \ No newline at end of file |
383 | 39 | 42 | ||
384 | === modified file 'Do.Platform/src/Do.Platform/IPreferencesService.cs' | |||
385 | --- Do.Platform/src/Do.Platform/IPreferencesService.cs 2009-08-28 05:42:11 +0000 | |||
386 | +++ Do.Platform/src/Do.Platform/IPreferencesService.cs 2010-03-29 03:16:18 +0000 | |||
387 | @@ -32,5 +32,8 @@ | |||
388 | 32 | 32 | ||
389 | 33 | bool Set<T> (string key, T val); | 33 | bool Set<T> (string key, T val); |
390 | 34 | bool TryGet<T> (string key, out T val); | 34 | bool TryGet<T> (string key, out T val); |
391 | 35 | |||
392 | 36 | void AddNotify (string path); | ||
393 | 37 | void RemoveNotify (string path); | ||
394 | 35 | } | 38 | } |
395 | 36 | } | 39 | } |
396 | 37 | 40 | ||
397 | === modified file 'Do.Platform/src/Do.Platform/SecurePreferencesWrapper.cs' | |||
398 | --- Do.Platform/src/Do.Platform/SecurePreferencesWrapper.cs 2009-08-28 05:42:11 +0000 | |||
399 | +++ Do.Platform/src/Do.Platform/SecurePreferencesWrapper.cs 2010-03-29 03:16:18 +0000 | |||
400 | @@ -61,7 +61,20 @@ | |||
401 | 61 | 61 | ||
402 | 62 | void EnsureString<T> () | 62 | void EnsureString<T> () |
403 | 63 | { | 63 | { |
405 | 64 | if (typeof (T) != typeof (string)) throw new NotImplementedException ("Unimplemented for non string values"); | 64 | if (typeof(T) != typeof(string)) |
406 | 65 | throw new NotImplementedException ("Unimplemented for non string values"); | ||
407 | 66 | } | ||
408 | 67 | |||
409 | 68 | public void AddNotify (string path) | ||
410 | 69 | { | ||
411 | 70 | Log.Debug ("Secure preferences service cannot add notifications"); | ||
412 | 71 | return; | ||
413 | 72 | } | ||
414 | 73 | |||
415 | 74 | public void RemoveNotify (string path) | ||
416 | 75 | { | ||
417 | 76 | Log.Debug ("Secure preferences service cannot remove notifications"); | ||
418 | 77 | return; | ||
419 | 65 | } | 78 | } |
420 | 66 | } | 79 | } |
421 | 67 | } | 80 | } |
I'd prefer it if there weren't whitespace changes mixed in here, but I know that can be difficult to do.
If I understand this code correctly, you've extended the Preferences service to also handle system-wide preferences. I'm not sure how good an idea this is - could we instead have something like a SystemConfiguration service that would deal with this sort of system-wide configuration? An advantage I see from that is that the proxy configuration work could get factored out into a platform-neutral place - the proxy setting code is platform independent.
That would also remove the somewhat smelly AddNotify/ RemoveNotify addition to IPreferencesSer vice.