Merge lp:~dobey/unity-scope-click/payments-button into lp:unity-scope-click/devel

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 287
Merged at revision: 295
Proposed branch: lp:~dobey/unity-scope-click/payments-button
Merge into: lp:unity-scope-click/devel
Diff against target: 88 lines (+43/-14)
2 files modified
libclickscope/click/preview.cpp (+22/-10)
scope/clickstore/store-scope.cpp (+21/-4)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/payments-button
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alejandro J. Cura (community) Approve
Review via email: mp+223478@code.launchpad.net

Commit message

Add support for using a new custom widget from Unity8 to handle payment process of purchasable apps.

To post a comment you must log in.
287. By dobey

Remove obsolete FIXME comment.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

The branch looks ok, but I think it would be safer to keep this feature behind an environ variable, so it does not break when the index starts having prices.
Please add such a check in the "if (details.package.price > double(0.00)) {".

review: Needs Fixing
Revision history for this message
dobey (dobey) wrote :

> The branch looks ok, but I think it would be safer to keep this feature behind
> an environ variable, so it does not break when the index starts having prices.
> Please add such a check in the "if (details.package.price > double(0.00)) {".

Can you approve without this, as we discussed in the standup? Given the timeframe of getting this feature landed in the archive, I don't see a good reason to do this. We'd have to remove such a check very soon, and if anything does break, it's better for us to know about it earlier, rather than only finding out if someone discovers how to enable the magic environment variable on their phone.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

As discussed, let's land without the flag, since it will only work if the app has price in the store.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libclickscope/click/preview.cpp'
--- libclickscope/click/preview.cpp 2014-06-16 14:09:21 +0000
+++ libclickscope/click/preview.cpp 2014-06-17 21:33:04 +0000
@@ -703,16 +703,28 @@
703scopes::PreviewWidgetList UninstalledPreview::uninstalledActionButtonWidgets(const PackageDetails &details)703scopes::PreviewWidgetList UninstalledPreview::uninstalledActionButtonWidgets(const PackageDetails &details)
704{704{
705 scopes::PreviewWidgetList widgets;705 scopes::PreviewWidgetList widgets;
706 scopes::PreviewWidget buttons("buttons", "actions");706 if (details.package.price > double(0.00)) {
707 scopes::VariantBuilder builder;707 scopes::PreviewWidget payments("purchase", "payments");
708 builder.add_tuple(708 scopes::VariantMap tuple;
709 {709 tuple["currency"] = "$";
710 {"id", scopes::Variant(click::Preview::Actions::INSTALL_CLICK)},710 qDebug() << "Price is" << details.package.price;
711 {"label", scopes::Variant(_("Install"))},711 tuple["price"] = scopes::Variant(details.package.price);
712 {"download_url", scopes::Variant(details.download_url)}712 tuple["store_item_id"] = details.package.name;
713 });713 tuple["download_url"] = details.download_url;
714 buttons.add_attribute_value("actions", builder.end());714 payments.add_attribute_value("source", scopes::Variant(tuple));
715 widgets.push_back(buttons);715 widgets.push_back(payments);
716 } else {
717 scopes::PreviewWidget buttons("buttons", "actions");
718 scopes::VariantBuilder builder;
719 builder.add_tuple(
720 {
721 {"id", scopes::Variant(click::Preview::Actions::INSTALL_CLICK)},
722 {"label", scopes::Variant(_("Install"))},
723 {"download_url", scopes::Variant(details.download_url)}
724 });
725 buttons.add_attribute_value("actions", builder.end());
726 widgets.push_back(buttons);
727 }
716728
717 return widgets;729 return widgets;
718}730}
719731
=== modified file 'scope/clickstore/store-scope.cpp'
--- scope/clickstore/store-scope.cpp 2014-06-12 13:59:29 +0000
+++ scope/clickstore/store-scope.cpp 2014-06-17 21:33:04 +0000
@@ -57,6 +57,8 @@
57int click::Scope::start(std::string const&, scopes::RegistryProxy const&)57int click::Scope::start(std::string const&, scopes::RegistryProxy const&)
58{58{
59 setlocale(LC_ALL, "");59 setlocale(LC_ALL, "");
60 // FIXME: This is wrong, but needed for json-cpp workaround.
61 setlocale(LC_MONETARY, "C");
60 bindtextdomain(GETTEXT_PACKAGE, GETTEXT_LOCALEDIR);62 bindtextdomain(GETTEXT_PACKAGE, GETTEXT_LOCALEDIR);
61 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");63 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
6264
@@ -91,13 +93,28 @@
91 return scopes::PreviewQueryBase::UPtr{new click::Preview(result, metadata, client, nam)};93 return scopes::PreviewQueryBase::UPtr{new click::Preview(result, metadata, client, nam)};
92}94}
9395
94unity::scopes::ActivationQueryBase::UPtr click::Scope::perform_action(unity::scopes::Result const& /* result */, unity::scopes::ActionMetadata const& metadata, std::string const& /* widget_id */, std::string const& action_id)96unity::scopes::ActivationQueryBase::UPtr click::Scope::perform_action(unity::scopes::Result const& /* result */, unity::scopes::ActionMetadata const& metadata,
97 std::string const& widget_id, std::string const& _action_id)
95{98{
99 std::string action_id = _action_id;
96 auto activation = new ScopeActivation();100 auto activation = new ScopeActivation();
97 qDebug() << "perform_action called with action_id" << QString().fromStdString(action_id);101 qDebug() << "perform_action called with widget_id" << QString::fromStdString(widget_id) << "and action_id:" << QString::fromStdString(action_id);
98102
99 // note: OPEN_CLICK and OPEN_ACCOUNTS actions are handled directly by the Dash103 // if the purchase is completed, do the install
100 if (action_id == click::Preview::Actions::INSTALL_CLICK) {104 if (action_id == "purchaseCompleted") {
105 qDebug() << "Yay, got finished signal";
106 qDebug() << "about to get the download_url";
107 std::string download_url = metadata.scope_data().get_dict()["download_url"].get_string();
108 qDebug() << "the download url is: " << QString::fromStdString(download_url);
109 activation->setHint("download_url", unity::scopes::Variant(download_url));
110 activation->setHint("action_id", unity::scopes::Variant(click::Preview::Actions::INSTALL_CLICK));
111 qDebug() << "returning ShowPreview";
112 activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
113 } else if (action_id == "purchaseError") {
114 activation->setHint(click::Preview::Actions::DOWNLOAD_FAILED, unity::scopes::Variant(true));
115 activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
116 } else if (action_id == click::Preview::Actions::INSTALL_CLICK) {
117 qDebug() << "about to get the download_url";
101 std::string download_url = metadata.scope_data().get_dict()["download_url"].get_string();118 std::string download_url = metadata.scope_data().get_dict()["download_url"].get_string();
102 qDebug() << "the download url is: " << QString::fromStdString(download_url);119 qDebug() << "the download url is: " << QString::fromStdString(download_url);
103 activation->setHint("download_url", unity::scopes::Variant(download_url));120 activation->setHint("download_url", unity::scopes::Variant(download_url));

Subscribers

People subscribed via source and target branches

to all changes: