Do

Merge lp:~cszikszoy/do/sysprefs into lp:do

Proposed by Chris S.
Status: Rejected
Rejected by: Alex Launi
Proposed branch: lp:~cszikszoy/do/sysprefs
Merge into: lp:do
Diff against target: 125 lines (+38/-26)
4 files modified
Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/GConfPreferencesService.cs (+9/-12)
Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesFactory.cs (+7/-2)
Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs (+20/-11)
Do.Platform/src/Do.Platform/SecurePreferencesWrapper.cs (+2/-1)
To merge this branch: bzr merge lp:~cszikszoy/do/sysprefs
Reviewer Review Type Date Requested Status
Do Core Team Pending
Review via email: mp+23738@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

1318. By Chris S.

remove debug

1317. By Chris S.

implement prefs for root paths

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-04-20 04:11:12 +0000
4@@ -25,26 +25,23 @@
5 {
6 public class GConfPreferencesService : IPreferencesService
7 {
8- const string ApplicationRootPath = "/apps/gnome-do/preferences";
9+ const string RootPath = "/apps/gnome-do/preferences";
10
11 GConf.Client client;
12- string RootPath { get; set; }
13-
14- public GConfPreferencesService () : this (ApplicationRootPath)
15- {
16- }
17-
18- public GConfPreferencesService (string rootPath)
19- {
20- RootPath = rootPath;
21+
22+ public GConfPreferencesService ()
23+ {
24 client = new GConf.Client ();
25- client.AddNotify (RootPath, new GConf.NotifyEventHandler (HandleGConfChanged));
26+ client.AddNotify ("/", new GConf.NotifyEventHandler (HandleGConfChanged));
27 }
28
29 void HandleGConfChanged (object sender, GConf.NotifyEventArgs args)
30 {
31+ string key = args.Key;
32+ if (key.StartsWith (RootPath))
33+ key = key.Substring (RootPath.Length + 1);
34 if (PreferencesChanged != null)
35- PreferencesChanged (this, new PreferencesChangedEventArgs (args.Key.Substring(RootPath.Length + 1), args.Value));
36+ PreferencesChanged (this, new PreferencesChangedEventArgs (key, args.Value));
37 }
38
39 string AbsolutePathForKey (string key)
40
41=== modified file 'Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesFactory.cs'
42--- Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesFactory.cs 2008-12-16 04:22:23 +0000
43+++ Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesFactory.cs 2010-04-20 04:11:12 +0000
44@@ -48,7 +48,12 @@
45 /// </returns>
46 public IPreferences Get<TOwner> () where TOwner : class
47 {
48- return new PreferencesImplementation<TOwner> (Service, SecureService);
49+ return new PreferencesImplementation (Service, SecureService, typeof (TOwner));
50+ }
51+
52+ public IPreferences Get (string absolute_key)
53+ {
54+ return new PreferencesImplementation (Service, SecureService, absolute_key);
55 }
56 }
57-}
58+}
59\ No newline at end of file
60
61=== modified file 'Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs'
62--- Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs 2009-08-31 01:58:13 +0000
63+++ Do.Platform/src/Do.Platform/Do.Platform.Preferences/PreferencesImplementation.cs 2010-04-20 04:11:12 +0000
64@@ -26,27 +26,36 @@
65 namespace Do.Platform.Preferences
66 {
67
68- internal class PreferencesImplementation<TOwner> : IPreferences
69- where TOwner : class
70+ internal class PreferencesImplementation : IPreferences
71 {
72 IPreferencesService Service { get; set; }
73 IPreferencesService SecureService { get; set; }
74
75- readonly string OwnerString = typeof (TOwner).FullName.Replace (".", "/");
76-
77- public PreferencesImplementation (IPreferencesService service, ISecurePreferencesService secureService)
78- {
79- Service = service;
80- SecureService = new SecurePreferencesServiceWrapper (secureService);
81- Service.PreferencesChanged += HandlePreferencesChanged;
82+ readonly string OwnerString;
83+
84+ public PreferencesImplementation (IPreferencesService service, ISecurePreferencesService secureService, Type Owner)
85+ {
86+ Service = service;
87+ SecureService = new SecurePreferencesServiceWrapper (secureService);
88+ Service.PreferencesChanged += HandlePreferencesChanged;
89+ OwnerString = Owner.FullName.Replace (".", "/");
90+ }
91+
92+ public PreferencesImplementation (IPreferencesService service, ISecurePreferencesService secureService, string absolute_key)
93+ {
94+ Service = service;
95+ SecureService = new SecurePreferencesServiceWrapper (secureService);
96+ Service.PreferencesChanged += HandlePreferencesChanged;
97+ OwnerString = absolute_key;
98+
99 }
100
101 void HandlePreferencesChanged (object o, PreferencesChangedEventArgs e)
102 {
103- if (e.Key.Length <= OwnerString.Length + 1 || e.Key.Substring(0, OwnerString.Length) != OwnerString)
104+ if (!e.Key.StartsWith (OwnerString))
105 return;
106 if (PreferencesChanged != null)
107- PreferencesChanged (this, new PreferencesChangedEventArgs (e.Key.Substring(OwnerString.Length + 1), e.Value));
108+ PreferencesChanged (this, new PreferencesChangedEventArgs (e.Key.Substring (OwnerString.Length + 1), e.Value));
109 }
110
111 #region IPreferences
112
113=== modified file 'Do.Platform/src/Do.Platform/SecurePreferencesWrapper.cs'
114--- Do.Platform/src/Do.Platform/SecurePreferencesWrapper.cs 2009-08-28 05:42:11 +0000
115+++ Do.Platform/src/Do.Platform/SecurePreferencesWrapper.cs 2010-04-20 04:11:12 +0000
116@@ -61,7 +61,8 @@
117
118 void EnsureString<T> ()
119 {
120- if (typeof (T) != typeof (string)) throw new NotImplementedException ("Unimplemented for non string values");
121+ if (typeof (T) != typeof (string))
122+ throw new NotImplementedException ("Unimplemented for non string values");
123 }
124 }
125 }