Merge lp:~mandel/ubuntuone-windows-installer/improve_u1sync_communication into lp:ubuntuone-windows-installer/beta
- improve_u1sync_communication
- Merge into beta
Proposed by
Manuel de la Peña
Status: | Merged |
---|---|
Approved by: | John Lenton |
Approved revision: | 165 |
Merged at revision: | 127 |
Proposed branch: | lp:~mandel/ubuntuone-windows-installer/improve_u1sync_communication |
Merge into: | lp:ubuntuone-windows-installer/beta |
Prerequisite: | lp:~mandel/ubuntuone-windows-installer/remove_recently_modifed_state_spaces |
Diff against target: |
391 lines (+136/-29) 9 files modified
src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs (+26/-1) src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj (+1/-0) src/Canonical.UbuntuOne.Client/Notification/Enums.cs (+40/-0) src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs (+19/-17) src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs (+9/-0) src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs (+7/-1) src/u1sync/main.py (+9/-1) src/u1sync/sync.py (+21/-5) src/u1sync/utils.py (+4/-4) |
To merge this branch: | bzr merge lp:~mandel/ubuntuone-windows-installer/improve_u1sync_communication |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Review via email: mp+39906@code.launchpad.net |
Commit message
Description of the change
Improve the u1sync communication.
To post a comment you must log in.
Revision history for this message
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.UbuntuOne.Client.Views/NotifyIcon.xaml.cs' |
2 | --- src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs 2010-11-02 22:21:27 +0000 |
3 | +++ src/Canonical.UbuntuOne.Client.Views/NotifyIcon.xaml.cs 2010-11-02 22:21:27 +0000 |
4 | @@ -86,7 +86,32 @@ |
5 | /// <param name="text">The text of the notification.</param> |
6 | public void ShowNotification(int timeout, string title, string text) |
7 | { |
8 | - NotifyIcon.ShowBalloonTip(timeout, title, text, NotifyBalloonIcon.Info); |
9 | + ShowNotification(timeout, title, text, NotificationType.INFO); |
10 | + } |
11 | + |
12 | + /// <summary> |
13 | + /// Shows a notification to the user. |
14 | + /// </summary> |
15 | + /// <param name="timeout">The amount of time the notification will be shown.</param> |
16 | + /// <param name="title">The title of the notification.</param> |
17 | + /// <param name="text">The text of the actual notification.</param> |
18 | + /// <param name="type">The type of notification sent.</param> |
19 | + public void ShowNotification(int timeout, string title, string text, NotificationType type) |
20 | + { |
21 | + var icon = NotifyBalloonIcon.None; |
22 | + switch (type) |
23 | + { |
24 | + case NotificationType.ERROR: |
25 | + icon = NotifyBalloonIcon.Error; |
26 | + break; |
27 | + case NotificationType.WARNING: |
28 | + icon = NotifyBalloonIcon.Warning; |
29 | + break; |
30 | + default: |
31 | + icon = NotifyBalloonIcon.Info; |
32 | + break; |
33 | + } |
34 | + NotifyIcon.ShowBalloonTip(timeout, title, text, icon); |
35 | } |
36 | |
37 | /// <summary> |
38 | |
39 | === modified file 'src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj' |
40 | --- src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj 2010-10-19 12:34:50 +0000 |
41 | +++ src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj 2010-11-02 22:21:27 +0000 |
42 | @@ -74,6 +74,7 @@ |
43 | <Compile Include="..\Version.cs"> |
44 | <Link>Properties\Version.cs</Link> |
45 | </Compile> |
46 | + <Compile Include="Notification\Enums.cs" /> |
47 | <Compile Include="Notification\INotificationIconView.cs" /> |
48 | <Compile Include="Notification\IStateMapper.cs" /> |
49 | <Compile Include="Notification\ISyncDaemonClientNotifier.cs" /> |
50 | |
51 | === added file 'src/Canonical.UbuntuOne.Client/Notification/Enums.cs' |
52 | --- src/Canonical.UbuntuOne.Client/Notification/Enums.cs 1970-01-01 00:00:00 +0000 |
53 | +++ src/Canonical.UbuntuOne.Client/Notification/Enums.cs 2010-11-02 22:21:27 +0000 |
54 | @@ -0,0 +1,40 @@ |
55 | +/* |
56 | + * Copyright 2010 Canonical Ltd. |
57 | + * |
58 | + * This file is part of UbuntuOne on Windows. |
59 | + * |
60 | + * UbuntuOne on Windows is free software: you can redistribute it and/or modify |
61 | + * it under the terms of the GNU Lesser General Public License version |
62 | + * as published by the Free Software Foundation. |
63 | + * |
64 | + * Ubuntu One on Windows is distributed in the hope that it will be useful, |
65 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
66 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
67 | + * GNU Lesser General Public License for more details. |
68 | + * |
69 | + * You should have received a copy of the GNU Lesser General Public License |
70 | + * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. |
71 | + * |
72 | + * Authors: Manuel de la Peña <manuel.delapena@canonical.com> |
73 | + */ |
74 | +namespace Canonical.UbuntuOne.Client.Notification |
75 | +{ |
76 | + /// <summary> |
77 | + /// Enum that contains the different types of notifications. |
78 | + /// </summary> |
79 | + public enum NotificationType |
80 | + { |
81 | + ///<summary> |
82 | + /// Enum that states that the notification provides information. |
83 | + ///</summary> |
84 | + INFO, |
85 | + /// <summary> |
86 | + /// Enum that states that the notification provides an error. |
87 | + /// </summary> |
88 | + ERROR, |
89 | + /// <summary> |
90 | + /// Enum that states that the notification provides a warning. |
91 | + /// </summary> |
92 | + WARNING |
93 | + } |
94 | +} |
95 | |
96 | === modified file 'src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs' |
97 | --- src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs 2010-08-30 17:30:31 +0000 |
98 | +++ src/Canonical.UbuntuOne.Client/Notification/INotificationIconPresenter.cs 2010-11-02 22:21:27 +0000 |
99 | @@ -1,20 +1,22 @@ |
100 | -// Copyright 2010 Canonical Ltd. |
101 | -// |
102 | -// This file is part of UbuntuOne on Windows. |
103 | -// |
104 | -// UbuntuOne on Windows is free software: you can redistribute it and/or modify |
105 | -// it under the terms of the GNU Lesser General Public License version |
106 | -// as published by the Free Software Foundation. |
107 | -// |
108 | -// Ubuntu One on Windows is distributed in the hope that it will be useful, |
109 | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
110 | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
111 | -// GNU Lesser General Public License for more details. |
112 | -// |
113 | -// You should have received a copy of the GNU Lesser General Public License |
114 | -// along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. |
115 | -// |
116 | -// Authors: Manuel de la Peña <manuel.delapena@canonical.com> |
117 | +/* |
118 | + * Copyright 2010 Canonical Ltd. |
119 | + * |
120 | + * This file is part of UbuntuOne on Windows. |
121 | + * |
122 | + * UbuntuOne on Windows is free software: you can redistribute it and/or modify |
123 | + * it under the terms of the GNU Lesser General Public License version |
124 | + * as published by the Free Software Foundation. |
125 | + * |
126 | + * Ubuntu One on Windows is distributed in the hope that it will be useful, |
127 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
128 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
129 | + * GNU Lesser General Public License for more details. |
130 | + * |
131 | + * You should have received a copy of the GNU Lesser General Public License |
132 | + * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. |
133 | + * |
134 | + * Authors: Manuel de la Peña <manuel.delapena@canonical.com> |
135 | + */ |
136 | namespace Canonical.UbuntuOne.Client.Notification |
137 | { |
138 | /// <summary> |
139 | |
140 | === modified file 'src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs' |
141 | --- src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs 2010-10-20 23:09:36 +0000 |
142 | +++ src/Canonical.UbuntuOne.Client/Notification/INotificationIconView.cs 2010-11-02 22:21:27 +0000 |
143 | @@ -41,6 +41,15 @@ |
144 | void ShowNotification(int timeout, string title, string text); |
145 | |
146 | /// <summary> |
147 | + /// Shows a notification to the user. |
148 | + /// </summary> |
149 | + /// <param name="timeout">The amount of time the notification will be shown.</param> |
150 | + /// <param name="title">The title of the notification.</param> |
151 | + /// <param name="text">The text of the actual notification.</param> |
152 | + /// <param name="type">The type of notification sent.</param> |
153 | + void ShowNotification(int timeout, string title, string text, NotificationType type); |
154 | + |
155 | + /// <summary> |
156 | /// Gets and sets the list of recently modified files. |
157 | /// </summary> |
158 | IList<string> RecentlyModifiedFiles { get; set; } |
159 | |
160 | === modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs' |
161 | --- src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs 2010-10-19 12:34:50 +0000 |
162 | +++ src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs 2010-11-02 22:21:27 +0000 |
163 | @@ -47,7 +47,13 @@ |
164 | var messageObject = (JObject) message; |
165 | if(string.Compare((string)messageObject["type"], "notify", StringComparison.CurrentCultureIgnoreCase) == 0) |
166 | { |
167 | - NotificationIconView.ShowNotification(10, (string)messageObject["title"], (string)messageObject["message"]); |
168 | + NotificationIconView.ShowNotification(5, (string)messageObject["title"], (string)messageObject["message"], |
169 | + NotificationType.INFO); |
170 | + } |
171 | + if(string.Compare((string)messageObject["type"], "error", StringComparison.CurrentCultureIgnoreCase) == 0) |
172 | + { |
173 | + NotificationIconView.ShowNotification(5, "Error", (string) messageObject["message"], |
174 | + NotificationType.ERROR); |
175 | } |
176 | } |
177 | } |
178 | |
179 | === modified file 'src/u1sync/main.py' |
180 | --- src/u1sync/main.py 2010-10-19 10:35:43 +0000 |
181 | +++ src/u1sync/main.py 2010-11-02 22:21:27 +0000 |
182 | @@ -43,7 +43,7 @@ |
183 | from u1sync.merge import ( |
184 | SyncMerge, ClobberServerMerge, ClobberLocalMerge, merge_trees) |
185 | from u1sync.sync import download_tree, upload_tree |
186 | -from u1sync.utils import safe_mkdir, send_bus_error, send_notification |
187 | +from u1sync.utils import safe_mkdir, send_error, send_notification |
188 | from u1sync import metadata |
189 | from u1sync.constants import METADATA_DIR_NAME |
190 | from u1sync.ubuntuone_optparse import UbuntuOneOptionsParser |
191 | @@ -335,21 +335,29 @@ |
192 | try: |
193 | do_main(argv, UbuntuOneOptionsParser()) |
194 | except AuthenticationError, e: |
195 | + send_error("Authentication failed: %s" % e, e) |
196 | print "Authentication failed: %s" % e |
197 | except ConnectionError, e: |
198 | + send_error("Connection failed: %s" % e, e) |
199 | print "Connection failed: %s" % e |
200 | except DirectoryNotInitializedError, e: |
201 | + send_error("Directory not initialized", e) |
202 | print "Directory not initialized; " \ |
203 | "use --init [DIRECTORY] to initialize it." |
204 | except DirectoryAlreadyInitializedError, e: |
205 | + send_error("Directory already initialized.", e) |
206 | print "Directory already initialized." |
207 | except NoSuchShareError, e: |
208 | + send_error("No matching share found.", e) |
209 | print "No matching share found." |
210 | except ReadOnlyShareError, e: |
211 | + send_error("The selected action isn't possible on a read-only share.", e) |
212 | print "The selected action isn't possible on a read-only share." |
213 | except (ForcedShutdown, KeyboardInterrupt), e: |
214 | + send_error("Interrupted!", e) |
215 | print "Interrupted!" |
216 | except TreesDiffer, e: |
217 | + send_error("Trees differ.", e) |
218 | if not e.quiet: |
219 | print "Trees differ." |
220 | else: |
221 | |
222 | === modified file 'src/u1sync/sync.py' |
223 | --- src/u1sync/sync.py 2010-10-20 08:42:42 +0000 |
224 | +++ src/u1sync/sync.py 2010-11-02 22:21:27 +0000 |
225 | @@ -35,7 +35,7 @@ |
226 | DIRECTORY, SYMLINK) |
227 | from u1sync.genericmerge import ( |
228 | MergeNode, generic_merge) |
229 | -from u1sync.utils import safe_mkdir, send_notification |
230 | +from u1sync.utils import safe_mkdir, send_notification, send_error |
231 | from u1sync.client import UnsupportedOperationError |
232 | |
233 | def get_conflict_path(path, conflict_info): |
234 | @@ -88,10 +88,6 @@ |
235 | else: |
236 | if not quiet: |
237 | print "%s %s" % (sync_mode.symbol, display_path) |
238 | - if(sync_mode.symbol == DOWNLOAD_SYMBOL): |
239 | - send_notification("Downloading", "Downloading file '%s'" % display_path, "info") |
240 | - elif(sync_mode.symbol == UPLOAD_SYMBOL): |
241 | - send_notification("Uploading", "Uploading file '%s'" % display_path, "info") |
242 | try: |
243 | create_dir = sync_mode.create_directory |
244 | node_uuid = create_dir(parent_uuid=parent_uuid, |
245 | @@ -241,6 +237,7 @@ |
246 | safe_mkdir(path) |
247 | send_notification("New dir", "Creating dir %s" % path, "info") |
248 | except OSError, e: |
249 | + send_error("Error creating local directory %s" % path, e) |
250 | raise NodeCreateError("Error creating local directory %s: %s" % \ |
251 | (path, e)) |
252 | return None |
253 | @@ -253,6 +250,7 @@ |
254 | path = get_conflict_path(path, conflict_info) |
255 | content_hash = conflict_info[1] |
256 | try: |
257 | + send_notification("Downloading", "Downloading '%s'" % path, "info") |
258 | if node_type == SYMLINK: |
259 | self.client.download_string(share_uuid= |
260 | self.share_uuid, |
261 | @@ -265,24 +263,30 @@ |
262 | filename=path) |
263 | except (request.StorageRequestError, UnsupportedOperationError), e: |
264 | if os.path.exists(path): |
265 | + send_error("Error downloading content for %s" % path, e) |
266 | raise NodeUpdateError("Error downloading content for %s: %s" %\ |
267 | (path, e)) |
268 | else: |
269 | + send_error("Error locally creating %s" % path, e) |
270 | raise NodeCreateError("Error locally creating %s: %s" % \ |
271 | (path, e)) |
272 | |
273 | def delete_directory(self, node_uuid, path): |
274 | """Deletes a directory.""" |
275 | + send_notification("Removing", "Removing directory '%s'" % path, "info") |
276 | try: |
277 | os.rmdir(path) |
278 | except OSError, e: |
279 | + send_error("Error locally deleting %s" % path, e) |
280 | raise NodeDeleteError("Error locally deleting %s: %s" % (path, e)) |
281 | |
282 | def delete_file(self, node_uuid, path): |
283 | """Deletes a file.""" |
284 | + send_notification("Removing", "Removing file '%s'" % path, "info") |
285 | try: |
286 | os.unlink(path) |
287 | except OSError, e: |
288 | + send_error("Error locally deleting %s" % path, e) |
289 | raise NodeDeleteError("Error locally deleting %s: %s" % (path, e)) |
290 | |
291 | |
292 | @@ -298,10 +302,12 @@ |
293 | """Creates a directory on the server.""" |
294 | name = name_from_path(path) |
295 | try: |
296 | + send_notification("Creating", "Creating directory '%s'" % path, "info") |
297 | return self.client.create_directory(share_uuid=self.share_uuid, |
298 | parent_uuid=parent_uuid, |
299 | name=name) |
300 | except (request.StorageRequestError, UnsupportedOperationError), e: |
301 | + send_error("Error remotely creating %s" % path, e) |
302 | raise NodeCreateError("Error remotely creating %s: %s" % \ |
303 | (path, e)) |
304 | |
305 | @@ -319,6 +325,7 @@ |
306 | name=conflict_name, |
307 | node_uuid=node_uuid) |
308 | except (request.StorageRequestError, UnsupportedOperationError), e: |
309 | + send_error("Error remotely renaming %s to %s" % (path, conflict_path), e) |
310 | raise NodeUpdateError("Error remotely renaming %s to %s: %s" %\ |
311 | (path, conflict_path, e)) |
312 | node_uuid = None |
313 | @@ -328,6 +335,7 @@ |
314 | try: |
315 | target = os.readlink(path) |
316 | except OSError, e: |
317 | + send_error("Error retrieving link target %s" % path, e) |
318 | raise NodeCreateError("Error retrieving link target " \ |
319 | "for %s: %s" % (path, e)) |
320 | else: |
321 | @@ -336,6 +344,7 @@ |
322 | name = name_from_path(path) |
323 | if node_uuid is None: |
324 | try: |
325 | + send_notification("Creating", "Remotely creating '%s'" % path, "info") |
326 | if node_type == SYMLINK: |
327 | node_uuid = self.client.create_symlink(share_uuid= |
328 | self.share_uuid, |
329 | @@ -351,11 +360,13 @@ |
330 | parent_uuid, |
331 | name=name) |
332 | except (request.StorageRequestError, UnsupportedOperationError), e: |
333 | + send_error("Error remotely creating for %s" % path, e) |
334 | raise NodeCreateError("Error remotely creating %s: %s" % \ |
335 | (path, e)) |
336 | |
337 | if old_content_hash != content_hash: |
338 | try: |
339 | + send_notification("Updating", "Uploading '%s'" % path, "info") |
340 | if node_type == SYMLINK: |
341 | self.client.upload_string(share_uuid=self.share_uuid, |
342 | node_uuid=node_uuid, |
343 | @@ -370,6 +381,7 @@ |
344 | old_content_hash=old_content_hash, |
345 | filename=path) |
346 | except (request.StorageRequestError, UnsupportedOperationError), e: |
347 | + send_error("Error uploading content for %s" % path, e) |
348 | raise NodeUpdateError("Error uploading content for %s: %s" % \ |
349 | (path, e)) |
350 | |
351 | @@ -377,12 +389,16 @@ |
352 | """Deletes a directory.""" |
353 | try: |
354 | self.client.unlink(share_uuid=self.share_uuid, node_uuid=node_uuid) |
355 | + send_notification("Deleting", "Remotely deleting directory '%s'" % path, "info") |
356 | except (request.StorageRequestError, UnsupportedOperationError), e: |
357 | + send_error("Error remotely deleting %s" % path, e) |
358 | raise NodeDeleteError("Error remotely deleting %s: %s" % (path, e)) |
359 | |
360 | def delete_file(self, node_uuid, path): |
361 | """Deletes a file.""" |
362 | try: |
363 | self.client.unlink(share_uuid=self.share_uuid, node_uuid=node_uuid) |
364 | + send_notification("Deleting", "Remotely deleting file '%s'" % path, "info") |
365 | except (request.StorageRequestError, UnsupportedOperationError), e: |
366 | + send_error("Error remotely deleting %s" % path, e) |
367 | raise NodeDeleteError("Error remotely deleting %s: %s" % (path, e)) |
368 | |
369 | === modified file 'src/u1sync/utils.py' |
370 | --- src/u1sync/utils.py 2010-10-19 10:35:43 +0000 |
371 | +++ src/u1sync/utils.py 2010-11-02 22:21:27 +0000 |
372 | @@ -81,14 +81,14 @@ |
373 | except Exception, e: |
374 | print "Error: C# client is not listening!! %s" % e.message |
375 | |
376 | -def send_bus_error(error_message, exception): |
377 | +def send_error(error_message, exception): |
378 | message = create_error_message(error_message, exception) |
379 | send_bus_message(message) |
380 | |
381 | def send_notification(title, message, type): |
382 | message = {'type':'notify', |
383 | - 'title':title, |
384 | - 'message':message, |
385 | - 'notification_type':type} |
386 | + 'title':title, |
387 | + 'message':message, |
388 | + 'notification_type':type} |
389 | send_bus_message(message) |
390 | |
391 | \ No newline at end of file |