Merge lp:~dobey/unity-scope-click/oa-direct into lp:unity-scope-click

Proposed by dobey
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 284
Merged at revision: 285
Proposed branch: lp:~dobey/unity-scope-click/oa-direct
Merge into: lp:unity-scope-click
Diff against target: 184 lines (+56/-23)
4 files modified
CMakeLists.txt (+1/-1)
debian/control (+1/-1)
libclickscope/click/preview.cpp (+51/-20)
libclickscope/click/preview.h (+3/-1)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/oa-direct
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+238019@code.launchpad.net

Commit message

Bump dependency on libunity-scopes-api for fixes to OnlineAccountClient API.
Use online accounts API to open login UI directly.

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

Drop OA connection for pay button as pay-ui will take care of login issues.

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 :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-08-01 15:04:19 +0000
3+++ CMakeLists.txt 2014-10-10 17:53:56 +0000
4@@ -22,7 +22,7 @@
5 include(UseGSettings)
6 find_package (PkgConfig REQUIRED)
7
8-pkg_check_modules(UNITY_SCOPES REQUIRED libunity-scopes>=0.6.0 libunity-api>=0.1.3)
9+pkg_check_modules(UNITY_SCOPES REQUIRED libunity-scopes>=0.6.7 libunity-api>=0.1.3)
10 add_definitions(${UNITY_SCOPES_CFLAGS} ${UNITY_SCOPES_CFLAGS_OTHER})
11
12 pkg_check_modules(UBUNTUONE REQUIRED ubuntuoneauth-2.0)
13
14=== modified file 'debian/control'
15--- debian/control 2014-08-28 18:27:23 +0000
16+++ debian/control 2014-10-10 17:53:56 +0000
17@@ -17,7 +17,7 @@
18 libubuntu-download-manager-common-dev (>= 0.3+14.10.20140430-0ubuntu1),
19 libubuntuoneauth-2.0-dev,
20 libunity-api-dev (>= 7.80.7),
21- libunity-scopes-dev (>= 0.6.0),
22+ libunity-scopes-dev (>= 0.6.7~),
23 libgsettings-qt-dev,
24 pkg-config,
25 python3-all:native,
26
27=== modified file 'libclickscope/click/preview.cpp'
28--- libclickscope/click/preview.cpp 2014-10-01 02:49:21 +0000
29+++ libclickscope/click/preview.cpp 2014-10-10 17:53:56 +0000
30@@ -184,7 +184,9 @@
31 }
32
33 PreviewStrategy::PreviewStrategy(const unity::scopes::Result& result)
34- : result(result)
35+ : result(result),
36+ oa_client("ubuntuone", "ubuntuone", "ubuntuone",
37+ scopes::OnlineAccountClient::MainLoopSelect::CreateInternalMainLoop)
38 {
39 }
40
41@@ -193,7 +195,9 @@
42 result(result),
43 client(client),
44 index(new click::Index(client)),
45- reviews(new click::Reviews(client))
46+ reviews(new click::Reviews(client)),
47+ oa_client("ubuntuone", "ubuntuone", "ubuntuone",
48+ scopes::OnlineAccountClient::MainLoopSelect::CreateInternalMainLoop)
49 {
50 }
51
52@@ -404,13 +408,29 @@
53 scopes::Variant(_("Close")));
54 }
55
56-scopes::PreviewWidgetList PreviewStrategy::loginErrorWidgets()
57+scopes::PreviewWidgetList PreviewStrategy::loginErrorWidgets(const PackageDetails& details)
58 {
59- return errorWidgets(scopes::Variant(_("Login Error")),
60- scopes::Variant(_("Please log in to your Ubuntu One account.")),
61- scopes::Variant(click::Preview::Actions::OPEN_ACCOUNTS),
62- scopes::Variant(_("Go to Accounts")),
63- scopes::Variant("settings:///system/online-accounts"));
64+ auto widgets = errorWidgets(scopes::Variant(_("Login Error")),
65+ scopes::Variant(_("Please log in to your Ubuntu One account.")),
66+ scopes::Variant(click::Preview::Actions::INSTALL_CLICK),
67+ scopes::Variant(_("Go to Accounts")));
68+ auto buttons = widgets.back();
69+ widgets.pop_back();
70+
71+ scopes::VariantBuilder builder;
72+ builder.add_tuple(
73+ {
74+ {"id", scopes::Variant(click::Preview::Actions::INSTALL_CLICK)},
75+ {"label", scopes::Variant(_("Go to Accounts"))},
76+ {"download_url", scopes::Variant(details.download_url)},
77+ {"download_sha512", scopes::Variant(details.download_sha512)},
78+ });
79+ buttons.add_attribute_value("actions", builder.end());
80+ oa_client.register_account_login_item(buttons,
81+ scopes::OnlineAccountClient::PostLoginAction::ContinueActivation,
82+ scopes::OnlineAccountClient::PostLoginAction::DoNothing);
83+ widgets.push_back(buttons);
84+ return widgets;
85 }
86
87 scopes::PreviewWidgetList PreviewStrategy::errorWidgets(const scopes::Variant& title,
88@@ -497,30 +517,36 @@
89 downloader->startDownload(download_url, download_sha512, result["name"].get_string(),
90 [this, reply] (std::pair<std::string, click::InstallError> rc){
91 // NOTE: details not needed by fooErrorWidgets, so no need to populateDetails():
92+ bool login_error = false;
93 switch (rc.second)
94 {
95- case InstallError::CredentialsError:
96- qWarning() << "InstallingPreview got error in getting credentials during startDownload";
97- reply->push(loginErrorWidgets());
98- return;
99 case InstallError::DownloadInstallError:
100 qWarning() << "Error received from UDM during startDownload:" << rc.first.c_str();
101 reply->push(downloadErrorWidgets());
102 return;
103+ case InstallError::CredentialsError:
104+ qWarning() << "InstallingPreview got error in getting credentials during startDownload";
105+ login_error = true;
106 default:
107 std::string object_path = rc.first;
108 qDebug() << "Successfully created UDM Download.";
109- populateDetails([this, reply, object_path](const PackageDetails &details) {
110+ populateDetails([this, reply, object_path, login_error](const PackageDetails &details) {
111 store_department(details);
112- pushPackagePreviewWidgets(reply, details, progressBarWidget(object_path));
113- startLauncherAnimation(details);
114+ if (login_error) {
115+ reply->push(loginErrorWidgets(details));
116+ } else {
117+ pushPackagePreviewWidgets(reply, details, progressBarWidget(object_path));
118+ startLauncherAnimation(details);
119+ }
120 },
121- [this, reply](const ReviewList& reviewlist,
122+ [this, reply, login_error](const ReviewList& reviewlist,
123 click::Reviews::Error error) {
124- if (error == click::Reviews::Error::NoError) {
125- reply->push(reviewsWidgets(reviewlist));
126- } else {
127- qDebug() << "There was an error getting reviews for:" << result["name"].get_string().c_str();
128+ if (!login_error) {
129+ if (error == click::Reviews::Error::NoError) {
130+ reply->push(reviewsWidgets(reviewlist));
131+ } else {
132+ qDebug() << "There was an error getting reviews for:" << result["name"].get_string().c_str();
133+ }
134 }
135 reply->finished();
136 });
137@@ -876,6 +902,8 @@
138 tuple["download_url"] = details.download_url;
139 tuple["download_sha512"] = details.download_sha512;
140 payments.add_attribute_value("source", scopes::Variant(tuple));
141+ // NOTE: No need to connect payments button to online-accounts API
142+ // here, as pay-ui will take care of any login needs.
143 widgets.push_back(payments);
144 } else {
145 scopes::PreviewWidget buttons("buttons", "actions");
146@@ -888,6 +916,9 @@
147 {"download_sha512", scopes::Variant(details.download_sha512)},
148 });
149 buttons.add_attribute_value("actions", builder.end());
150+ oa_client.register_account_login_item(buttons,
151+ scopes::OnlineAccountClient::PostLoginAction::ContinueActivation,
152+ scopes::OnlineAccountClient::PostLoginAction::DoNothing);
153 widgets.push_back(buttons);
154 }
155
156
157=== modified file 'libclickscope/click/preview.h'
158--- libclickscope/click/preview.h 2014-08-26 14:21:42 +0000
159+++ libclickscope/click/preview.h 2014-10-10 17:53:56 +0000
160@@ -38,6 +38,7 @@
161 #include <click/network_access_manager.h>
162
163 #include <unity/scopes/ActionMetadata.h>
164+#include <unity/scopes/OnlineAccountClient.h>
165 #include <unity/scopes/PreviewQueryBase.h>
166 #include <unity/scopes/PreviewWidget.h>
167 #include <unity/scopes/Result.h>
168@@ -136,7 +137,7 @@
169 virtual scopes::PreviewWidgetList progressBarWidget(const std::string& object_path);
170 virtual scopes::PreviewWidgetList reviewsWidgets(const click::ReviewList &reviewlist);
171 virtual scopes::PreviewWidgetList downloadErrorWidgets();
172- virtual scopes::PreviewWidgetList loginErrorWidgets();
173+ virtual scopes::PreviewWidgetList loginErrorWidgets(const PackageDetails& details);
174 virtual scopes::PreviewWidgetList errorWidgets(const scopes::Variant& title,
175 const scopes::Variant& subtitle,
176 const scopes::Variant& action_id,
177@@ -156,6 +157,7 @@
178 QSharedPointer<click::Reviews> reviews;
179 click::web::Cancellable reviews_operation;
180 click::web::Cancellable submit_operation;
181+ scopes::OnlineAccountClient oa_client;
182 };
183
184 class DownloadErrorPreview : public PreviewStrategy

Subscribers

People subscribed via source and target branches

to all changes: