Merge lp:~marcustomlinson/unity-scopes-shell/oa_ui_policy-rtm into lp:unity-scopes-shell/rtm-14.09

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 134
Merged at revision: 142
Proposed branch: lp:~marcustomlinson/unity-scopes-shell/oa_ui_policy-rtm
Merge into: lp:unity-scopes-shell/rtm-14.09
Diff against target: 66 lines (+24/-5)
2 files modified
src/Unity/CMakeLists.txt (+1/-1)
src/Unity/scope.cpp (+23/-4)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-shell/oa_ui_policy-rtm
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
Review via email: mp+244388@code.launchpad.net

Commit message

* Set UNITY_SCOPES_OA_UI_POLICY on entry to Scope::loginToAccount()
* Animate the loading bar on the scope while OA retrieves a token.

To post a comment you must log in.
Revision history for this message
Paweł Stołowski (stolowski) wrote :

+1

review: Approve
Revision history for this message
Paweł Stołowski (stolowski) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Unity/CMakeLists.txt'
2--- src/Unity/CMakeLists.txt 2014-10-22 15:48:29 +0000
3+++ src/Unity/CMakeLists.txt 2014-12-12 16:38:14 +0000
4@@ -61,7 +61,7 @@
5 ${ONLINE_ACCOUNTS_CLIENT_LDFLAGS}
6 )
7
8-qt5_use_modules(Unity-qml Qml Gui DBus)
9+qt5_use_modules(Unity-qml Qml Gui DBus Concurrent)
10
11 # export the qmldir qmltypes and plugin files
12 export_qmlfiles(Unity Unity)
13
14=== modified file 'src/Unity/scope.cpp'
15--- src/Unity/scope.cpp 2014-10-15 09:59:13 +0000
16+++ src/Unity/scope.cpp 2014-12-12 16:38:14 +0000
17@@ -43,6 +43,7 @@
18 #include <QFileInfo>
19 #include <QDir>
20 #include <QLocale>
21+#include <QtConcurrent>
22
23 #include <libintl.h>
24
25@@ -1242,7 +1243,11 @@
26
27 bool Scope::loginToAccount(QString const& service_name, QString const& service_type, QString const& provider_name)
28 {
29- bool service_enabled = false;
30+ // Set the UNITY_SCOPES_OA_UI_POLICY environment variable here so that OnlineAccountClient knows we're
31+ // calling it from the shell (hence it will use the default UI policy when talking to libsignon).
32+ setenv("UNITY_SCOPES_OA_UI_POLICY", "1", 0);
33+
34+ QFuture<bool> service_enabled_future = QtConcurrent::run([&]
35 {
36 // Check if at least one account has the specified service enabled
37 scopes::OnlineAccountClient oa_client(service_name.toStdString(), service_type.toStdString(), provider_name.toStdString());
38@@ -1251,11 +1256,25 @@
39 {
40 if (status.service_enabled)
41 {
42- service_enabled = true;
43- break;
44+ return true;
45 }
46 }
47- }
48+ return false;
49+ });
50+ QFutureWatcher<bool> future_watcher;
51+ future_watcher.setFuture(service_enabled_future);
52+
53+ // Set SearchInProgress so that the loading bar animates while we waiting for the token to be issued.
54+ setSearchInProgress(true);
55+
56+ QEventLoop loop;
57+ connect(&future_watcher, &QFutureWatcher<void>::finished, &loop, &QEventLoop::quit);
58+ loop.exec(QEventLoop::ProcessEventsFlag::ExcludeUserInputEvents);
59+
60+ // Unset SearchInProgress to stop the loading bar animation.
61+ setSearchInProgress(false);
62+
63+ bool service_enabled = service_enabled_future.result();
64
65 // Start the signon UI if no enabled services were found
66 if (!service_enabled)

Subscribers

People subscribed via source and target branches

to all changes: