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
1=== modified file 'libclickscope/click/preview.cpp'
2--- libclickscope/click/preview.cpp 2014-06-16 14:09:21 +0000
3+++ libclickscope/click/preview.cpp 2014-06-17 21:33:04 +0000
4@@ -703,16 +703,28 @@
5 scopes::PreviewWidgetList UninstalledPreview::uninstalledActionButtonWidgets(const PackageDetails &details)
6 {
7 scopes::PreviewWidgetList widgets;
8- scopes::PreviewWidget buttons("buttons", "actions");
9- scopes::VariantBuilder builder;
10- builder.add_tuple(
11- {
12- {"id", scopes::Variant(click::Preview::Actions::INSTALL_CLICK)},
13- {"label", scopes::Variant(_("Install"))},
14- {"download_url", scopes::Variant(details.download_url)}
15- });
16- buttons.add_attribute_value("actions", builder.end());
17- widgets.push_back(buttons);
18+ if (details.package.price > double(0.00)) {
19+ scopes::PreviewWidget payments("purchase", "payments");
20+ scopes::VariantMap tuple;
21+ tuple["currency"] = "$";
22+ qDebug() << "Price is" << details.package.price;
23+ tuple["price"] = scopes::Variant(details.package.price);
24+ tuple["store_item_id"] = details.package.name;
25+ tuple["download_url"] = details.download_url;
26+ payments.add_attribute_value("source", scopes::Variant(tuple));
27+ widgets.push_back(payments);
28+ } else {
29+ scopes::PreviewWidget buttons("buttons", "actions");
30+ scopes::VariantBuilder builder;
31+ builder.add_tuple(
32+ {
33+ {"id", scopes::Variant(click::Preview::Actions::INSTALL_CLICK)},
34+ {"label", scopes::Variant(_("Install"))},
35+ {"download_url", scopes::Variant(details.download_url)}
36+ });
37+ buttons.add_attribute_value("actions", builder.end());
38+ widgets.push_back(buttons);
39+ }
40
41 return widgets;
42 }
43
44=== modified file 'scope/clickstore/store-scope.cpp'
45--- scope/clickstore/store-scope.cpp 2014-06-12 13:59:29 +0000
46+++ scope/clickstore/store-scope.cpp 2014-06-17 21:33:04 +0000
47@@ -57,6 +57,8 @@
48 int click::Scope::start(std::string const&, scopes::RegistryProxy const&)
49 {
50 setlocale(LC_ALL, "");
51+ // FIXME: This is wrong, but needed for json-cpp workaround.
52+ setlocale(LC_MONETARY, "C");
53 bindtextdomain(GETTEXT_PACKAGE, GETTEXT_LOCALEDIR);
54 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
55
56@@ -91,13 +93,28 @@
57 return scopes::PreviewQueryBase::UPtr{new click::Preview(result, metadata, client, nam)};
58 }
59
60-unity::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)
61+unity::scopes::ActivationQueryBase::UPtr click::Scope::perform_action(unity::scopes::Result const& /* result */, unity::scopes::ActionMetadata const& metadata,
62+ std::string const& widget_id, std::string const& _action_id)
63 {
64+ std::string action_id = _action_id;
65 auto activation = new ScopeActivation();
66- qDebug() << "perform_action called with action_id" << QString().fromStdString(action_id);
67+ qDebug() << "perform_action called with widget_id" << QString::fromStdString(widget_id) << "and action_id:" << QString::fromStdString(action_id);
68
69- // note: OPEN_CLICK and OPEN_ACCOUNTS actions are handled directly by the Dash
70- if (action_id == click::Preview::Actions::INSTALL_CLICK) {
71+ // if the purchase is completed, do the install
72+ if (action_id == "purchaseCompleted") {
73+ qDebug() << "Yay, got finished signal";
74+ qDebug() << "about to get the download_url";
75+ std::string download_url = metadata.scope_data().get_dict()["download_url"].get_string();
76+ qDebug() << "the download url is: " << QString::fromStdString(download_url);
77+ activation->setHint("download_url", unity::scopes::Variant(download_url));
78+ activation->setHint("action_id", unity::scopes::Variant(click::Preview::Actions::INSTALL_CLICK));
79+ qDebug() << "returning ShowPreview";
80+ activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
81+ } else if (action_id == "purchaseError") {
82+ activation->setHint(click::Preview::Actions::DOWNLOAD_FAILED, unity::scopes::Variant(true));
83+ activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
84+ } else if (action_id == click::Preview::Actions::INSTALL_CLICK) {
85+ qDebug() << "about to get the download_url";
86 std::string download_url = metadata.scope_data().get_dict()["download_url"].get_string();
87 qDebug() << "the download url is: " << QString::fromStdString(download_url);
88 activation->setHint("download_url", unity::scopes::Variant(download_url));

Subscribers

People subscribed via source and target branches

to all changes: