Merge lp:~mandel/ubuntuone-windows-installer/smart_context_menu into lp:ubuntuone-windows-installer/beta
- smart_context_menu
- Merge into beta
Proposed by
Manuel de la Peña
Status: | Merged |
---|---|
Approved by: | John Lenton |
Approved revision: | 178 |
Merged at revision: | 134 |
Proposed branch: | lp:~mandel/ubuntuone-windows-installer/smart_context_menu |
Merge into: | lp:ubuntuone-windows-installer/beta |
Prerequisite: | lp:~mandel/ubuntuone-windows-installer/manual_sync_does_nothing |
Diff against target: |
438 lines (+149/-44) (has conflicts) 11 files modified
src/Canonical.Ubuntu.SSO/ISSOCredentialsProvider.cs (+7/-0) src/Canonical.Ubuntu.SSO/SSOCredentialsProvider.cs (+19/-4) src/Canonical.UbuntuOne.Client.Views.Tests/NotifyIconFixture.cs (+2/-1) src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml (+9/-5) src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs (+47/-20) src/Canonical.UbuntuOne.Client.Views/Resources/Resources.resx (+3/-0) src/Canonical.UbuntuOne.Client.Views/Resources/Resources1.Designer.cs (+9/-0) src/Canonical.UbuntuOne.Client.Views/objects.xml (+2/-3) src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs (+10/-0) src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs (+6/-0) src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs (+35/-11) Text conflict in src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs |
To merge this branch: | bzr merge lp:~mandel/ubuntuone-windows-installer/smart_context_menu |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Made the context menu smarter to show diff content according to the status of the user credentials.
To post a comment you must log in.
- 178. By Manuel de la Peña
-
Ensures that method is executed in the correct thread.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
John Lenton (chipaca) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/Canonical.Ubuntu.SSO/ISSOCredentialsProvider.cs' | |||
2 | --- src/Canonical.Ubuntu.SSO/ISSOCredentialsProvider.cs 2010-10-18 10:53:55 +0000 | |||
3 | +++ src/Canonical.Ubuntu.SSO/ISSOCredentialsProvider.cs 2010-11-12 14:29:04 +0000 | |||
4 | @@ -72,6 +72,13 @@ | |||
5 | 72 | /// </summary> | 72 | /// </summary> |
6 | 73 | void LoginOrRegisterToGetCredentials(); | 73 | void LoginOrRegisterToGetCredentials(); |
7 | 74 | 74 | ||
8 | 75 | /// <summary> | ||
9 | 76 | /// Gets if the credentials are present in the system. | ||
10 | 77 | /// </summary> | ||
11 | 78 | /// <param name="applicationName">The name of the applications whose credentials we want to | ||
12 | 79 | /// get.</param> | ||
13 | 80 | bool CredentialsArePresent(string applicationName); | ||
14 | 81 | |||
15 | 75 | #endregion | 82 | #endregion |
16 | 76 | 83 | ||
17 | 77 | } | 84 | } |
18 | 78 | 85 | ||
19 | === modified file 'src/Canonical.Ubuntu.SSO/SSOCredentialsProvider.cs' | |||
20 | --- src/Canonical.Ubuntu.SSO/SSOCredentialsProvider.cs 2010-10-20 11:32:24 +0000 | |||
21 | +++ src/Canonical.Ubuntu.SSO/SSOCredentialsProvider.cs 2010-11-12 14:29:04 +0000 | |||
22 | @@ -82,12 +82,12 @@ | |||
23 | 82 | if (LoginView.ViewDispatcher.Dispatch(() => LoginView.IsShown)) | 82 | if (LoginView.ViewDispatcher.Dispatch(() => LoginView.IsShown)) |
24 | 83 | return; | 83 | return; |
25 | 84 | 84 | ||
27 | 85 | if (LoginView.ViewDispatcher.Dispatch( () => LoginView.ShowDialog() != MessageBoxResult.Cancel)) | 85 | if (LoginView.ViewDispatcher.Dispatch(() => LoginView.ShowDialog() != MessageBoxResult.Cancel)) |
28 | 86 | { | 86 | { |
29 | 87 | var tokenName = string.Format(ApplicationTokenName, Environment.MachineName); | 87 | var tokenName = string.Format(ApplicationTokenName, Environment.MachineName); |
30 | 88 | secret = SSOLoginProcessor.Login( | 88 | secret = SSOLoginProcessor.Login( |
31 | 89 | LoginView.ViewDispatcher.Dispatch(() => LoginView.EmailAddress), | 89 | LoginView.ViewDispatcher.Dispatch(() => LoginView.EmailAddress), |
33 | 90 | LoginView.ViewDispatcher.Dispatch(() => LoginView.Password), | 90 | LoginView.ViewDispatcher.Dispatch(() => LoginView.Password), |
34 | 91 | tokenName); | 91 | tokenName); |
35 | 92 | // save the credentials in the keyring | 92 | // save the credentials in the keyring |
36 | 93 | // TODO: We have an issue here since we have more than one listening for the same credntials of Ubuntu One | 93 | // TODO: We have an issue here since we have more than one listening for the same credntials of Ubuntu One |
37 | @@ -101,10 +101,10 @@ | |||
38 | 101 | } | 101 | } |
39 | 102 | return; | 102 | return; |
40 | 103 | } | 103 | } |
42 | 104 | 104 | ||
43 | 105 | } | 105 | } |
44 | 106 | // we execute the credentials found event | 106 | // we execute the credentials found event |
46 | 107 | if(!string.IsNullOrEmpty(secret) && OnCredentialsFound != null) | 107 | if (!string.IsNullOrEmpty(secret) && OnCredentialsFound != null) |
47 | 108 | { | 108 | { |
48 | 109 | string token; | 109 | string token; |
49 | 110 | string tokenSecret; | 110 | string tokenSecret; |
50 | @@ -157,6 +157,21 @@ | |||
51 | 157 | throw new NotImplementedException(); | 157 | throw new NotImplementedException(); |
52 | 158 | } | 158 | } |
53 | 159 | 159 | ||
54 | 160 | /// <summary> | ||
55 | 161 | /// Returns if the credentials of a given application are present. | ||
56 | 162 | /// </summary> | ||
57 | 163 | /// <param name="applicationName">The name of the application whose credentials we want | ||
58 | 164 | /// to get.</param> | ||
59 | 165 | /// <returns>A bool value stating if the credentials are present.</returns> | ||
60 | 166 | public bool CredentialsArePresent(string applicationName) | ||
61 | 167 | { | ||
62 | 168 | //TODO: Currently application name is hardcoded!!!! | ||
63 | 169 | // try to get the credentials from the keyring | ||
64 | 170 | var secret = Keyring.GetSecretByName(KeyringName, ApplicationName); | ||
65 | 171 | return secret != null; | ||
66 | 172 | |||
67 | 173 | } | ||
68 | 174 | |||
69 | 160 | #endregion | 175 | #endregion |
70 | 161 | } | 176 | } |
71 | 162 | } | 177 | } |
72 | 163 | 178 | ||
73 | === modified file 'src/Canonical.UbuntuOne.Client.Views.Tests/NotifyIconFixture.cs' | |||
74 | --- src/Canonical.UbuntuOne.Client.Views.Tests/NotifyIconFixture.cs 2010-10-20 23:27:32 +0000 | |||
75 | +++ src/Canonical.UbuntuOne.Client.Views.Tests/NotifyIconFixture.cs 2010-11-12 14:29:04 +0000 | |||
76 | @@ -43,7 +43,8 @@ | |||
77 | 43 | { | 43 | { |
78 | 44 | _moks = new MockRepository(); | 44 | _moks = new MockRepository(); |
79 | 45 | _presenter = _moks.StrictMock<INotificationIconPresenter>(); | 45 | _presenter = _moks.StrictMock<INotificationIconPresenter>(); |
81 | 46 | _icon = new UbuntuOneNotifyIcon {NotificationIconPresenter = _presenter}; | 46 | _icon = new UbuntuOneNotifyIcon (_presenter); |
82 | 47 | _moks.BackToRecordAll(); | ||
83 | 47 | } | 48 | } |
84 | 48 | 49 | ||
85 | 49 | #endregion | 50 | #endregion |
86 | 50 | 51 | ||
87 | === modified file 'src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml' | |||
88 | --- src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml 2010-10-21 11:41:25 +0000 | |||
89 | +++ src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml 2010-11-12 14:29:04 +0000 | |||
90 | @@ -70,7 +70,11 @@ | |||
91 | 70 | <av:NotifyIcon Name="NotifyIcon" Icon="/Canonical.UbuntuOne.Client.Views;component/Resources/ubuntu-logo-22x22.png" | 70 | <av:NotifyIcon Name="NotifyIcon" Icon="/Canonical.UbuntuOne.Client.Views;component/Resources/ubuntu-logo-22x22.png" |
92 | 71 | Text="Ubuntu One"> <!-- TODO: Add icon Icon="/AvalonLibraryTestPages;component/Properties/App.ico" Open preferences when click --> | 71 | Text="Ubuntu One"> <!-- TODO: Add icon Icon="/AvalonLibraryTestPages;component/Properties/App.ico" Open preferences when click --> |
93 | 72 | <FrameworkElement.ContextMenu > | 72 | <FrameworkElement.ContextMenu > |
95 | 73 | <ContextMenu StaysOpen="False"> | 73 | <ContextMenu StaysOpen="False" > |
96 | 74 | <MenuItem x:Uid="AddComputer" | ||
97 | 75 | Name="AddComputer" | ||
98 | 76 | Header="{x:Static resx:Resources.NotificationIconAddComputerLabel}" | ||
99 | 77 | Click="OnAddComputerClick"/> | ||
100 | 74 | <MenuItem x:Uid="UbuntuOneManualSync" | 78 | <MenuItem x:Uid="UbuntuOneManualSync" |
101 | 75 | Name="UbuntuOneManualSync" | 79 | Name="UbuntuOneManualSync" |
102 | 76 | Header="{x:Static resx:Resources.NotificationIconUbuntuOneManualSyncLabel}" | 80 | Header="{x:Static resx:Resources.NotificationIconUbuntuOneManualSyncLabel}" |
103 | @@ -87,10 +91,10 @@ | |||
104 | 87 | Name="OpenSyncMenuItem" | 91 | Name="OpenSyncMenuItem" |
105 | 88 | Header="{x:Static resx:Resources.NotificationIconOpenSyncLabel}" | 92 | Header="{x:Static resx:Resources.NotificationIconOpenSyncLabel}" |
106 | 89 | Click="OnOpenSyncMenuItemClick"/> | 93 | Click="OnOpenSyncMenuItemClick"/> |
111 | 90 | <Separator /> | 94 | <Separator Name="OptionsSeparator" /> |
112 | 91 | <MenuItem Name="StateMenuItem" | 95 | <Label Name="StateMenuItem" |
113 | 92 | Header="State"/> | 96 | Content="State: Idle"/> |
114 | 93 | <Separator /> | 97 | <Separator Name="HelpSeparator" /> |
115 | 94 | <MenuItem x:Uid="HelpMenuItem" | 98 | <MenuItem x:Uid="HelpMenuItem" |
116 | 95 | Name="HelpMenuItem" | 99 | Name="HelpMenuItem" |
117 | 96 | Header="{x:Static resx:Resources.NotificationIconHelpLabel}" | 100 | Header="{x:Static resx:Resources.NotificationIconHelpLabel}" |
118 | 97 | 101 | ||
119 | === modified file 'src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs' | |||
120 | --- src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs 2010-10-21 13:11:36 +0000 | |||
121 | +++ src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs 2010-11-12 14:29:04 +0000 | |||
122 | @@ -36,25 +36,18 @@ | |||
123 | 36 | private IDispatcher _dispatcher; | 36 | private IDispatcher _dispatcher; |
124 | 37 | private readonly object _dispatcherLock = new object(); | 37 | private readonly object _dispatcherLock = new object(); |
125 | 38 | private Storyboard _iconAnimation; | 38 | private Storyboard _iconAnimation; |
136 | 39 | 39 | private INotificationIconPresenter _presenter; | |
127 | 40 | #endregion | ||
128 | 41 | |||
129 | 42 | #region DI Properties | ||
130 | 43 | |||
131 | 44 | /// <summary> | ||
132 | 45 | /// Gets and sets the presenter that contains the logic that is used by the notification icon. | ||
133 | 46 | /// </summary> | ||
134 | 47 | public INotificationIconPresenter NotificationIconPresenter { get; set; } | ||
135 | 48 | |||
137 | 49 | #endregion | 40 | #endregion |
138 | 50 | 41 | ||
139 | 51 | /// <summary> | 42 | /// <summary> |
140 | 52 | /// Initializes a new instance of the UbuntuOneNotifyIcon class. | 43 | /// Initializes a new instance of the UbuntuOneNotifyIcon class. |
141 | 53 | /// </summary> | 44 | /// </summary> |
143 | 54 | public UbuntuOneNotifyIcon() | 45 | public UbuntuOneNotifyIcon(INotificationIconPresenter presenter) |
144 | 55 | { | 46 | { |
145 | 56 | InitializeComponent(); | 47 | InitializeComponent(); |
146 | 57 | _iconAnimation = Resources["IconAnimation"] as Storyboard; | 48 | _iconAnimation = Resources["IconAnimation"] as Storyboard; |
147 | 49 | _presenter = presenter; | ||
148 | 50 | _presenter.InitializeView(); | ||
149 | 58 | } | 51 | } |
150 | 59 | 52 | ||
151 | 60 | #region Implementation of INotificationIconView | 53 | #region Implementation of INotificationIconView |
152 | @@ -114,6 +107,34 @@ | |||
153 | 114 | NotifyIcon.ShowBalloonTip(timeout, title, text, icon); | 107 | NotifyIcon.ShowBalloonTip(timeout, title, text, icon); |
154 | 115 | } | 108 | } |
155 | 116 | 109 | ||
156 | 110 | public void ShowAsAddedComputer(bool isAddedComputer) | ||
157 | 111 | { | ||
158 | 112 | if(isAddedComputer) | ||
159 | 113 | { | ||
160 | 114 | // show all the menu items | ||
161 | 115 | UbuntuOneManualSync.Visibility = System.Windows.Visibility.Visible; | ||
162 | 116 | UbuntuOnePreferencesMenuItem.Visibility = System.Windows.Visibility.Visible; | ||
163 | 117 | OpenShareManueItem.Visibility = System.Windows.Visibility.Visible; | ||
164 | 118 | OpenSyncMenuItem.Visibility = System.Windows.Visibility.Visible; | ||
165 | 119 | OptionsSeparator.Visibility = System.Windows.Visibility.Visible; | ||
166 | 120 | HelpSeparator.Visibility = System.Windows.Visibility.Visible; | ||
167 | 121 | // we do not need to add the computer | ||
168 | 122 | AddComputer.Visibility = System.Windows.Visibility.Collapsed; | ||
169 | 123 | } | ||
170 | 124 | else | ||
171 | 125 | { | ||
172 | 126 | // Hide all the diff menu items | ||
173 | 127 | UbuntuOneManualSync.Visibility = System.Windows.Visibility.Collapsed; | ||
174 | 128 | UbuntuOnePreferencesMenuItem.Visibility = System.Windows.Visibility.Collapsed; | ||
175 | 129 | OpenShareManueItem.Visibility = System.Windows.Visibility.Collapsed; | ||
176 | 130 | OpenSyncMenuItem.Visibility = System.Windows.Visibility.Collapsed; | ||
177 | 131 | OptionsSeparator.Visibility = System.Windows.Visibility.Collapsed; | ||
178 | 132 | HelpSeparator.Visibility = System.Windows.Visibility.Collapsed; | ||
179 | 133 | // provide the user a way to add the computer | ||
180 | 134 | AddComputer.Visibility = System.Windows.Visibility.Visible; | ||
181 | 135 | } | ||
182 | 136 | } | ||
183 | 137 | |||
184 | 117 | /// <summary> | 138 | /// <summary> |
185 | 118 | /// Gets and sets the list of recently modified files. | 139 | /// Gets and sets the list of recently modified files. |
186 | 119 | /// </summary> | 140 | /// </summary> |
187 | @@ -128,10 +149,10 @@ | |||
188 | 128 | /// </summary> | 149 | /// </summary> |
189 | 129 | public string State | 150 | public string State |
190 | 130 | { | 151 | { |
192 | 131 | get { return (string)StateMenuItem.Header; } | 152 | get { return (string)StateMenuItem.Content; } |
193 | 132 | set | 153 | set |
194 | 133 | { | 154 | { |
196 | 134 | StateMenuItem.Header = value; | 155 | StateMenuItem.Content = value; |
197 | 135 | Title = value; | 156 | Title = value; |
198 | 136 | } | 157 | } |
199 | 137 | } | 158 | } |
200 | @@ -169,34 +190,40 @@ | |||
201 | 169 | 190 | ||
202 | 170 | internal void OnUbuntuOneManualSyncClick(object sender, System.Windows.RoutedEventArgs e) | 191 | internal void OnUbuntuOneManualSyncClick(object sender, System.Windows.RoutedEventArgs e) |
203 | 171 | { | 192 | { |
205 | 172 | var thread = new Thread(NotificationIconPresenter.ManualSync); | 193 | var thread = new Thread(_presenter.ManualSync); |
206 | 173 | thread.Start(); | 194 | thread.Start(); |
207 | 174 | } | 195 | } |
208 | 175 | 196 | ||
209 | 176 | internal void OnExitMenuItemClick(object sender, System.Windows.RoutedEventArgs e) | 197 | internal void OnExitMenuItemClick(object sender, System.Windows.RoutedEventArgs e) |
210 | 177 | { | 198 | { |
212 | 178 | NotificationIconPresenter.Exit(); | 199 | _presenter.Exit(); |
213 | 179 | } | 200 | } |
214 | 180 | 201 | ||
215 | 181 | internal void OnHelpMenuItemClick(object sender, System.Windows.RoutedEventArgs e) | 202 | internal void OnHelpMenuItemClick(object sender, System.Windows.RoutedEventArgs e) |
216 | 182 | { | 203 | { |
218 | 183 | NotificationIconPresenter.OpenHelp(); | 204 | _presenter.OpenHelp(); |
219 | 184 | } | 205 | } |
220 | 185 | 206 | ||
221 | 186 | internal void OnMoreSpaceMenuItemClick(object sender, System.Windows.RoutedEventArgs e) | 207 | internal void OnMoreSpaceMenuItemClick(object sender, System.Windows.RoutedEventArgs e) |
222 | 187 | { | 208 | { |
224 | 188 | NotificationIconPresenter.OpenUpgradeOption(); | 209 | _presenter.OpenUpgradeOption(); |
225 | 189 | } | 210 | } |
226 | 190 | 211 | ||
227 | 191 | internal void OnOpenSyncMenuItemClick(object sender, System.Windows.RoutedEventArgs e) | 212 | internal void OnOpenSyncMenuItemClick(object sender, System.Windows.RoutedEventArgs e) |
228 | 192 | { | 213 | { |
230 | 193 | NotificationIconPresenter.OpenSyncsLocation(); | 214 | _presenter.OpenSyncsLocation(); |
231 | 194 | } | 215 | } |
232 | 195 | 216 | ||
233 | 196 | internal void OnUbuntuOnePreferencesMenuItemClick(object sender, System.Windows.RoutedEventArgs e) | 217 | internal void OnUbuntuOnePreferencesMenuItemClick(object sender, System.Windows.RoutedEventArgs e) |
234 | 197 | { | 218 | { |
237 | 198 | NotificationIconPresenter.OpenUbuntuOnePreferences(); | 219 | _presenter.OpenUbuntuOnePreferences(); |
238 | 199 | } | 220 | } |
239 | 221 | |||
240 | 222 | private void OnAddComputerClick(object sender, System.Windows.RoutedEventArgs e) | ||
241 | 223 | { | ||
242 | 224 | _presenter.AddComputer(); | ||
243 | 225 | } | ||
244 | 226 | |||
245 | 200 | 227 | ||
246 | 201 | } | 228 | } |
247 | 202 | } | 229 | } |
248 | 203 | 230 | ||
249 | === modified file 'src/Canonical.UbuntuOne.Client.Views/Resources/Resources.resx' | |||
250 | --- src/Canonical.UbuntuOne.Client.Views/Resources/Resources.resx 2010-10-13 09:56:20 +0000 | |||
251 | +++ src/Canonical.UbuntuOne.Client.Views/Resources/Resources.resx 2010-11-12 14:29:04 +0000 | |||
252 | @@ -155,6 +155,9 @@ | |||
253 | 155 | <value>Downloading updates...</value> | 155 | <value>Downloading updates...</value> |
254 | 156 | <comment>The title of the downloading dialog.</comment> | 156 | <comment>The title of the downloading dialog.</comment> |
255 | 157 | </data> | 157 | </data> |
256 | 158 | <data name="NotificationIconAddComputerLabel" xml:space="preserve"> | ||
257 | 159 | <value>Add this computer</value> | ||
258 | 160 | </data> | ||
259 | 158 | <data name="NotificationIconExitLabel" xml:space="preserve"> | 161 | <data name="NotificationIconExitLabel" xml:space="preserve"> |
260 | 159 | <value>Exit</value> | 162 | <value>Exit</value> |
261 | 160 | <comment>The title of the exit menu item.</comment> | 163 | <comment>The title of the exit menu item.</comment> |
262 | 161 | 164 | ||
263 | === modified file 'src/Canonical.UbuntuOne.Client.Views/Resources/Resources1.Designer.cs' | |||
264 | --- src/Canonical.UbuntuOne.Client.Views/Resources/Resources1.Designer.cs 2010-10-13 09:56:20 +0000 | |||
265 | +++ src/Canonical.UbuntuOne.Client.Views/Resources/Resources1.Designer.cs 2010-11-12 14:29:04 +0000 | |||
266 | @@ -151,6 +151,15 @@ | |||
267 | 151 | } | 151 | } |
268 | 152 | 152 | ||
269 | 153 | /// <summary> | 153 | /// <summary> |
270 | 154 | /// Looks up a localized string similar to Add this computer. | ||
271 | 155 | /// </summary> | ||
272 | 156 | public static string NotificationIconAddComputerLabel { | ||
273 | 157 | get { | ||
274 | 158 | return ResourceManager.GetString("NotificationIconAddComputerLabel", resourceCulture); | ||
275 | 159 | } | ||
276 | 160 | } | ||
277 | 161 | |||
278 | 162 | /// <summary> | ||
279 | 154 | /// Looks up a localized string similar to Exit. | 163 | /// Looks up a localized string similar to Exit. |
280 | 155 | /// </summary> | 164 | /// </summary> |
281 | 156 | public static string NotificationIconExitLabel { | 165 | public static string NotificationIconExitLabel { |
282 | 157 | 166 | ||
283 | === modified file 'src/Canonical.UbuntuOne.Client.Views/objects.xml' | |||
284 | --- src/Canonical.UbuntuOne.Client.Views/objects.xml 2010-10-13 10:38:57 +0000 | |||
285 | +++ src/Canonical.UbuntuOne.Client.Views/objects.xml 2010-11-12 14:29:04 +0000 | |||
286 | @@ -8,9 +8,8 @@ | |||
287 | 8 | type="Canonical.UbuntuOne.Client.Views.Update.UpdatingView, Canonical.UbuntuOne.Client.Views" /> | 8 | type="Canonical.UbuntuOne.Client.Views.Update.UpdatingView, Canonical.UbuntuOne.Client.Views" /> |
288 | 9 | 9 | ||
289 | 10 | <object id="UbuntuOneNotifyIcon" | 10 | <object id="UbuntuOneNotifyIcon" |
293 | 11 | type="Canonical.UbuntuOne.Client.Views.UbuntuOneNotifyIcon, Canonical.UbuntuOne.Client.Views" > | 11 | type="Canonical.UbuntuOne.Client.Views.UbuntuOneNotifyIcon, Canonical.UbuntuOne.Client.Views" depends-on="NotificationIconPresenter"> |
294 | 12 | <property name="NotificationIconPresenter" | 12 | <constructor-arg name="presenter" ref="NotificationIconPresenter"/> |
292 | 13 | ref="NotificationIconPresenter" /> | ||
295 | 14 | </object> | 13 | </object> |
296 | 15 | 14 | ||
297 | 16 | <object id="PreferencesView" | 15 | <object id="PreferencesView" |
298 | 17 | 16 | ||
299 | === modified file 'src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs' | |||
300 | --- src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs 2010-10-21 13:11:36 +0000 | |||
301 | +++ src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs 2010-11-12 14:29:04 +0000 | |||
302 | @@ -26,6 +26,16 @@ | |||
303 | 26 | public interface INotificationIconPresenter | 26 | public interface INotificationIconPresenter |
304 | 27 | { | 27 | { |
305 | 28 | /// <summary> | 28 | /// <summary> |
306 | 29 | /// Initializes the view to ensure that shows the correct data. | ||
307 | 30 | /// </summary> | ||
308 | 31 | void InitializeView(); | ||
309 | 32 | |||
310 | 33 | /// <summary> | ||
311 | 34 | /// Action taken when the user wants to add the current computer to his machine. | ||
312 | 35 | /// </summary> | ||
313 | 36 | void AddComputer(); | ||
314 | 37 | |||
315 | 38 | /// <summary> | ||
316 | 29 | /// When implemented this method should for the sync of the ubuntu one folder. | 39 | /// When implemented this method should for the sync of the ubuntu one folder. |
317 | 30 | /// </summary> | 40 | /// </summary> |
318 | 31 | void ManualSync(); | 41 | void ManualSync(); |
319 | 32 | 42 | ||
320 | === modified file 'src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs' | |||
321 | --- src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs 2010-10-21 13:11:36 +0000 | |||
322 | +++ src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs 2010-11-12 14:29:04 +0000 | |||
323 | @@ -50,6 +50,12 @@ | |||
324 | 50 | void ShowNotification(int timeout, string title, string text, NotificationType type); | 50 | void ShowNotification(int timeout, string title, string text, NotificationType type); |
325 | 51 | 51 | ||
326 | 52 | /// <summary> | 52 | /// <summary> |
327 | 53 | /// Tells the view to display as if the computer was already added to the service. | ||
328 | 54 | /// </summary> | ||
329 | 55 | /// <param name="isAddedComputer">States if the computer was added.</param> | ||
330 | 56 | void ShowAsAddedComputer(bool isAddedComputer); | ||
331 | 57 | |||
332 | 58 | /// <summary> | ||
333 | 53 | /// Gets and sets the list of recently modified files. | 59 | /// Gets and sets the list of recently modified files. |
334 | 54 | /// </summary> | 60 | /// </summary> |
335 | 55 | IList<string> RecentlyModifiedFiles { get; set; } | 61 | IList<string> RecentlyModifiedFiles { get; set; } |
336 | 56 | 62 | ||
337 | === modified file 'src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs' | |||
338 | --- src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs 2010-11-11 11:43:38 +0000 | |||
339 | +++ src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs 2010-11-12 14:29:04 +0000 | |||
340 | @@ -51,9 +51,16 @@ | |||
341 | 51 | private ISSOCredentialsProvider _ssoProvider; | 51 | private ISSOCredentialsProvider _ssoProvider; |
342 | 52 | private ILog _logger; | 52 | private ILog _logger; |
343 | 53 | private readonly object _loggerLock = new object(); | 53 | private readonly object _loggerLock = new object(); |
344 | 54 | <<<<<<< TREE | ||
345 | 54 | private const string EventName = "UbuntuOneNotificationIconPresenter"; | 55 | private const string EventName = "UbuntuOneNotificationIconPresenter"; |
346 | 55 | private const string ApplicationName = "UbuntuOne"; | 56 | private const string ApplicationName = "UbuntuOne"; |
347 | 56 | 57 | ||
348 | 58 | ======= | ||
349 | 59 | private static string ManualSyncEvent = "UbuntuOneNotificationIconPresenter.ManualSync"; | ||
350 | 60 | private static string AddComputerEvent = "UbuntuOneNotificationIconPresenter.AddComputer"; | ||
351 | 61 | private static string ApplicationName = "UbuntuOne"; | ||
352 | 62 | private INotificationIconView _view; | ||
353 | 63 | >>>>>>> MERGE-SOURCE | ||
354 | 57 | #endregion | 64 | #endregion |
355 | 58 | 65 | ||
356 | 59 | #region Di properties | 66 | #region Di properties |
357 | @@ -107,6 +114,7 @@ | |||
358 | 107 | _ssoProvider.OnCredentialsFound += OnCredentialsFound; | 114 | _ssoProvider.OnCredentialsFound += OnCredentialsFound; |
359 | 108 | _ssoProvider.OnCredentialsError += OnCredentialsError; | 115 | _ssoProvider.OnCredentialsError += OnCredentialsError; |
360 | 109 | _ssoProvider.OnCredetialsDenied += OnCredentialsDenied; | 116 | _ssoProvider.OnCredetialsDenied += OnCredentialsDenied; |
361 | 117 | InitializeView(); | ||
362 | 110 | } | 118 | } |
363 | 111 | } | 119 | } |
364 | 112 | 120 | ||
365 | @@ -229,16 +237,18 @@ | |||
366 | 229 | [DebugLogged] | 237 | [DebugLogged] |
367 | 230 | private void OnCredentialsFound(object sender, CredentialsFoundEventArgs args) | 238 | private void OnCredentialsFound(object sender, CredentialsFoundEventArgs args) |
368 | 231 | { | 239 | { |
371 | 232 | // check if the credentials are for us | 240 | // we got credentials, no matter what we tell the ui to be ready |
372 | 233 | if (args.ApplicationName != EventName) return; | 241 | NotificationIconView.ViewDispatcher.Dispatch(() => NotificationIconView.ShowAsAddedComputer(true)); |
373 | 242 | // check if the credentials are for us); | ||
374 | 243 | if (args.ApplicationName != ManualSyncEvent) return; | ||
375 | 234 | NotificationIconView.ViewDispatcher.Dispatch( | 244 | NotificationIconView.ViewDispatcher.Dispatch( |
376 | 235 | () => | 245 | () => |
381 | 236 | { | 246 | { |
382 | 237 | NotificationIconView.IsManualSyncEnabled = false; | 247 | NotificationIconView.IsManualSyncEnabled = false; |
383 | 238 | NotificationIconView.State = "Syncing"; | 248 | NotificationIconView.State = "Syncing"; |
384 | 239 | } | 249 | } |
385 | 240 | ); | 250 | ); |
387 | 241 | 251 | ||
388 | 242 | Logger.Info("Got the UbuntuOne credentials!"); | 252 | Logger.Info("Got the UbuntuOne credentials!"); |
389 | 243 | var oneDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), | 253 | var oneDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), |
390 | 244 | Resources.DefaulDirectoryName); | 254 | Resources.DefaulDirectoryName); |
391 | @@ -262,14 +272,14 @@ | |||
392 | 262 | [DebugLogged] | 272 | [DebugLogged] |
393 | 263 | private void OnCredentialsDenied(object sender, CredentialsDeniedEventArgs args) | 273 | private void OnCredentialsDenied(object sender, CredentialsDeniedEventArgs args) |
394 | 264 | { | 274 | { |
396 | 265 | if (args.ApplicationName != EventName) return; | 275 | if (args.ApplicationName != ManualSyncEvent) return; |
397 | 266 | MessageBox.ShowWarning("You need to login to be able to sync your files."); | 276 | MessageBox.ShowWarning("You need to login to be able to sync your files."); |
398 | 267 | } | 277 | } |
399 | 268 | 278 | ||
400 | 269 | [DebugLogged] | 279 | [DebugLogged] |
401 | 270 | private void OnCredentialsError(object sender, CredentialsErrorEventArgs args) | 280 | private void OnCredentialsError(object sender, CredentialsErrorEventArgs args) |
402 | 271 | { | 281 | { |
404 | 272 | if (args.ApplicationName != EventName) return; | 282 | if (args.ApplicationName != ManualSyncEvent) return; |
405 | 273 | MessageBox.ShowError(string.Format("An error courred when trying to retrieve your credentials: {0}", args.ErrorMessage)); | 283 | MessageBox.ShowError(string.Format("An error courred when trying to retrieve your credentials: {0}", args.ErrorMessage)); |
406 | 274 | Logger.ErrorFormat("The error was {0}, {1}", args.ErrorMessage, args.DetailedErrorMessage); | 284 | Logger.ErrorFormat("The error was {0}, {1}", args.ErrorMessage, args.DetailedErrorMessage); |
407 | 275 | } | 285 | } |
408 | @@ -278,14 +288,28 @@ | |||
409 | 278 | 288 | ||
410 | 279 | #region Implementation of INotificationIconPresenter | 289 | #region Implementation of INotificationIconPresenter |
411 | 280 | 290 | ||
412 | 291 | public void InitializeView() | ||
413 | 292 | { | ||
414 | 293 | if (SSOCredentialsProvider != null) | ||
415 | 294 | if (SSOCredentialsProvider.CredentialsArePresent(ApplicationName)) | ||
416 | 295 | NotificationIconView.ShowAsAddedComputer(true); | ||
417 | 296 | else | ||
418 | 297 | NotificationIconView.ShowAsAddedComputer(false); | ||
419 | 298 | } | ||
420 | 299 | |||
421 | 300 | public void AddComputer() | ||
422 | 301 | { | ||
423 | 302 | // call the sso credentials provider but with a diff event so that we do not perform a manual sync | ||
424 | 303 | SSOCredentialsProvider.LoginToGetCredentials(AddComputerEvent, ApplicationName); | ||
425 | 304 | } | ||
426 | 305 | |||
427 | 281 | /// <summary> | 306 | /// <summary> |
428 | 282 | /// When implemented this method should for the sync of the ubuntu one folder. | 307 | /// When implemented this method should for the sync of the ubuntu one folder. |
429 | 283 | /// </summary> | 308 | /// </summary> |
430 | 284 | public void ManualSync() | 309 | public void ManualSync() |
431 | 285 | { | 310 | { |
432 | 286 | |||
433 | 287 | // we get the credentials, because we have register an action to the credetials aquired, we do nothing besides this | 311 | // we get the credentials, because we have register an action to the credetials aquired, we do nothing besides this |
435 | 288 | SSOCredentialsProvider.LoginToGetCredentials(EventName, ApplicationName); | 312 | SSOCredentialsProvider.LoginToGetCredentials(ManualSyncEvent, ApplicationName); |
436 | 289 | } | 313 | } |
437 | 290 | 314 | ||
438 | 291 | /// <summary> | 315 | /// <summary> |