Merge lp:~alecu/unity-lens-music/silence-notifications into lp:unity-lens-music

Proposed by Alejandro J. Cura
Status: Needs review
Proposed branch: lp:~alecu/unity-lens-music/silence-notifications
Merge into: lp:unity-lens-music
Diff against target: 157 lines (+75/-15)
3 files modified
src/musicstore-scope.vala (+38/-15)
src/ubuntuone-webservices.vala (+14/-0)
tests/unit/test-ubuntuone-purchases.vala (+23/-0)
To merge this branch: bzr merge lp:~alecu/unity-lens-music/silence-notifications
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity Team Pending
Review via email: mp+167874@code.launchpad.net

Commit message

Update the text of the notifications on error

Description of the change

Update the text of the notifications on error

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

This branch changes the text of the "performing purchase" notification, right at the moment any error happens:

When the purchase fails:
http://ubuntuone.com/5n1T5viEW9ttNOCwcFG4Lx

When the password is wrong:
http://ubuntuone.com/0eF2usg4CRunxko5SCcfcI

141. By Alejandro J. Cura

merged with trunk

142. By Alejandro J. Cura

merge lp:~alecu/unity-lens-music/sign-opened-urls

143. By Alejandro J. Cura

merged from sign-open-urls

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

143. By Alejandro J. Cura

merged from sign-open-urls

142. By Alejandro J. Cura

merge lp:~alecu/unity-lens-music/sign-opened-urls

141. By Alejandro J. Cura

merged with trunk

140. By Alejandro J. Cura

update notifications on error

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/musicstore-scope.vala'
--- src/musicstore-scope.vala 2013-06-20 13:23:37 +0000
+++ src/musicstore-scope.vala 2013-07-11 01:18:29 +0000
@@ -28,6 +28,9 @@
28 private const string ERROR_MESSAGE_NOT_LOGGED_IN = _("It seems you don't have an Ubuntu One account, or you are not logged in. To continue, please login and visit the Ubuntu One online store.");28 private const string ERROR_MESSAGE_NOT_LOGGED_IN = _("It seems you don't have an Ubuntu One account, or you are not logged in. To continue, please login and visit the Ubuntu One online store.");
29 private const string ERROR_MESSAGE_NO_PAYMENT_METHOD = _("It seems you haven't set yet your preferred Ubuntu One payment method. To add a payment method, please visit the Ubuntu One online store.");29 private const string ERROR_MESSAGE_NO_PAYMENT_METHOD = _("It seems you haven't set yet your preferred Ubuntu One payment method. To add a payment method, please visit the Ubuntu One online store.");
30 private const string ERROR_MESSAGE_TECHNICAL_PROBLEM = _("Sorry, we have encountered a technical problem. No money has been taken from your account. To try your purchase again, please visit the Ubuntu One online store.");30 private const string ERROR_MESSAGE_TECHNICAL_PROBLEM = _("Sorry, we have encountered a technical problem. No money has been taken from your account. To try your purchase again, please visit the Ubuntu One online store.");
31 private const string ERROR_MESSAGE_SHORT_TECHNICAL_PROBLEM = _("To try your purchase again, please visit the Ubuntu One online store.");
32 private const string ERROR_MESSAGE_WRONG_PASSWORD = _("Wrong password");
33 private const string NOTIFICATION_TITLE_PURCHASE_FAILED = _("Purchase failed");
31 private const string UBUNTUONE_MUSIC_LOGIN = Config.LIBEXECDIR + "/ubuntuone-credentials/ubuntuone-music-login";34 private const string UBUNTUONE_MUSIC_LOGIN = Config.LIBEXECDIR + "/ubuntuone-credentials/ubuntuone-music-login";
3235
33 public class MusicStoreScopeProxy : SimpleScope36 public class MusicStoreScopeProxy : SimpleScope
@@ -89,11 +92,19 @@
89 public Unity.ActivationResponse open_uri (string uri)92 public Unity.ActivationResponse open_uri (string uri)
90 {93 {
91 /* launch the music store streaming client or the webstore or whatevz */94 /* launch the music store streaming client or the webstore or whatevz */
92 try {95 purchase_service.build_logged_url.begin(uri, (obj, res) => {
93 AppInfo.launch_default_for_uri (uri, null);96 try {
94 } catch (GLib.Error e) {97 var full_url = purchase_service.build_logged_url.end (res);
95 warning ("Failed to open uri %s. %s", uri, e.message);98 if (uri.has_prefix ("https://one.ubuntu.com/") || uri.has_prefix ("http://musicsearch.ubuntu.com/")) {
96 }99 AppInfo.launch_default_for_uri (full_url, null);
100 } else {
101 AppInfo.launch_default_for_uri (uri, null);
102 }
103 } catch (PurchaseError e) {
104 debug ("Can't fetch credentials: %s to open url: %s", e.message, uri);
105 AppInfo.launch_default_for_uri (uri, null);
106 }
107 });
97 return new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);108 return new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);
98 }109 }
99110
@@ -133,7 +144,7 @@
133 else if (album.price == 0)144 else if (album.price == 0)
134 download_action.extra_text = _("Free");145 download_action.extra_text = _("Free");
135146
136 download_action.activated.connect (open_uri);147 download_action.activated.connect (show_purchase_preview);
137148
138 music_preview.add_action (download_action);149 music_preview.add_action (download_action);
139 }150 }
@@ -344,25 +355,37 @@
344 debug ("Error while showing notification: %s", e.message);355 debug ("Error while showing notification: %s", e.message);
345 }356 }
346357
358 Unity.ActivationResponse response;
359 string reason;
360
347 try {361 try {
348 purchase_service.purchase (album.purchase_sku, password);362 purchase_service.purchase (album.purchase_sku, password);
349 debug ("purchase completed.");363 debug ("purchase completed.");
350 notification.update (album.title, _("Purchase completed"), "");364 notification.update (album.title, _("Purchase completed"), "");
351 try {365 reason = "purchase completed";
352 notification.show ();366 response = new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);
353 } catch (GLib.Error e) {367
354 debug ("Error while showing notification: %s", e.message);
355 }
356 return new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);
357 } catch (PurchaseError e) {368 } catch (PurchaseError e) {
369
358 if (e is PurchaseError.WRONG_PASSWORD_ERROR) {370 if (e is PurchaseError.WRONG_PASSWORD_ERROR) {
359 debug ("wrong password error: %s", e.message);371 debug ("wrong password error: %s", e.message);
360 return new Unity.ActivationResponse.with_preview (purchase_preview (uri, _("Wrong password")));372 reason = ERROR_MESSAGE_WRONG_PASSWORD;
373 response = new Unity.ActivationResponse.with_preview (purchase_preview (uri, ERROR_MESSAGE_WRONG_PASSWORD));
361 } else {374 } else {
362 debug ("got purchase error: %s", e.message);375 debug ("got purchase error: %s", e.message);
363 return build_error_preview (uri, ERROR_MESSAGE_TECHNICAL_PROBLEM, album.formatted_price, _("Continue"), open_uri);376 reason = ERROR_MESSAGE_SHORT_TECHNICAL_PROBLEM;
377 response = build_error_preview (uri, ERROR_MESSAGE_TECHNICAL_PROBLEM, album.formatted_price, _("Continue"), open_uri);
364 }378 }
365 }379 notification.update (NOTIFICATION_TITLE_PURCHASE_FAILED, reason, "");
380 }
381
382 try {
383 notification.show ();
384 debug ("Showing updated notification: %s", reason);
385 } catch (GLib.Error e) {
386 debug ("Error while updating notification: %s", e.message);
387 }
388 return response;
366 }389 }
367390
368 public Unity.Preview purchase_preview (string uri, string? error_message)391 public Unity.Preview purchase_preview (string uri, string? error_message)
369392
=== modified file 'src/ubuntuone-webservices.vala'
--- src/ubuntuone-webservices.vala 2013-05-29 15:04:08 +0000
+++ src/ubuntuone-webservices.vala 2013-07-11 01:18:29 +0000
@@ -336,5 +336,19 @@
336 purchase_with_default_payment (album_id, purchase_token);336 purchase_with_default_payment (album_id, purchase_token);
337 debug ("purchase completed.");337 debug ("purchase completed.");
338 }338 }
339
340 public virtual async string build_logged_url (string dest_url) throws PurchaseError
341 {
342 const string U1_OAUTH_LOGIN = "https://one.ubuntu.com/api/1.0/from_oauth/?next=";
343 if (!got_credentials ()) {
344 yield fetch_credentials();
345 }
346 if (got_credentials ()) {
347 var full_url = U1_OAUTH_LOGIN + Soup.URI.encode(dest_url, null);
348 return oauth_sign(full_url);
349 } else {
350 return dest_url;
351 }
352 }
339 }353 }
340}354}
341355
=== modified file 'tests/unit/test-ubuntuone-purchases.vala'
--- tests/unit/test-ubuntuone-purchases.vala 2013-05-29 15:04:08 +0000
+++ tests/unit/test-ubuntuone-purchases.vala 2013-07-11 01:18:29 +0000
@@ -128,6 +128,7 @@
128 Test.add_data_func ("/Unit/PurchaseChecker/PurchaseDefaultPaymentBroken", test_purchase_with_default_payment_broken_json);128 Test.add_data_func ("/Unit/PurchaseChecker/PurchaseDefaultPaymentBroken", test_purchase_with_default_payment_broken_json);
129 Test.add_data_func ("/Unit/PurchaseChecker/PurchaseConnectionFails", test_purchase_with_default_payment_connection_fails);129 Test.add_data_func ("/Unit/PurchaseChecker/PurchaseConnectionFails", test_purchase_with_default_payment_connection_fails);
130 Test.add_data_func ("/Unit/PurchaseChecker/PurchaseDefaultPaymentFails", test_purchase_with_default_payment_fails);130 Test.add_data_func ("/Unit/PurchaseChecker/PurchaseDefaultPaymentFails", test_purchase_with_default_payment_fails);
131 Test.add_data_func ("/Unit/PurchaseChecker/SignUbuntuoneUrls", test_sign_ubuntuone_urls);
131132
132 return Test.run ();133 return Test.run ();
133 }134 }
@@ -716,4 +717,26 @@
716 assert (e is PurchaseError.PURCHASE_ERROR);717 assert (e is PurchaseError.PURCHASE_ERROR);
717 }718 }
718 }719 }
720
721 private static void test_sign_ubuntuone_urls ()
722 {
723 string dest = "https://one.ubuntu.com/contacts/";
724 var purchase_service = new BaseTestPurchaseService ();
725
726 MainLoop mainloop = new MainLoop ();
727 purchase_service.build_logged_url.begin(dest, (obj, res) => {
728 mainloop.quit ();
729 try {
730 var full_url = purchase_service.build_logged_url.end (res);
731 debug (full_url);
732 assert (full_url.contains("oauth_consumer_key"));
733 //GLib.Process.spawn_command_line_sync ("chromium-browser --incognito " + full_url);
734 } catch (PurchaseError e) {
735 warning ("Can't fetch credentials: %s", e.message);
736 assert_not_reached ();
737 }
738 });
739 assert (run_with_timeout (mainloop, 1000));
740 //assert (purchase_service._ubuntuone_credentials != null);
741 }
719}742}

Subscribers

People subscribed via source and target branches

to all changes: