Merge lp:~mardy/ubuntu-system-settings-online-accounts/handle-errors-1349975 into lp:ubuntu-system-settings-online-accounts

Proposed by Alberto Mardegan on 2015-09-29
Status: Merged
Approved by: David Barth on 2015-10-16
Approved revision: 302
Merged at revision: 306
Proposed branch: lp:~mardy/ubuntu-system-settings-online-accounts/handle-errors-1349975
Merge into: lp:ubuntu-system-settings-online-accounts
Diff against target: 208 lines (+81/-10)
8 files modified
debian/control (+2/-2)
online-accounts-ui/browser-request.cpp (+8/-2)
online-accounts-ui/qml/ProviderRequest.qml (+0/-2)
plugins/module/ErrorItem.qml (+48/-0)
plugins/module/OAuth.qml (+20/-2)
plugins/module/WebView.qml (+1/-1)
plugins/module/module.pro (+1/-0)
tests/online-accounts-ui/tst_browser_request.cpp (+1/-1)
To merge this branch: bzr merge lp:~mardy/ubuntu-system-settings-online-accounts/handle-errors-1349975
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing on 2015-10-09
Online Accounts 2015-09-29 Pending
Review via email: mp+272736@code.launchpad.net

Commit message

Retry authentication on network errors

If the authentication fails because of a network error, show an error screen
and let the user retry the authentication from within the plugin.

This requires the BrowserRequest to emit the proper error code, and not cancel
the tiemout failure timer if the current page URL is visited again.

Description of the change

Retry authentication on network errors

If the authentication fails because of a network error, show an error screen
and let the user retry the authentication from within the plugin.

This requires the BrowserRequest to emit the proper error code, and not cancel
the tiemout failure timer if the current page URL is visited again.

To post a comment you must log in.
299. By Alberto Mardegan on 2015-10-01

Expect an error code

300. By Alberto Mardegan on 2015-10-09

Don't stop fail timer on URL change, just restart it.

301. By Alberto Mardegan on 2015-10-09

fix build

302. By Alberto Mardegan on 2015-10-09

Layout adjustments

303. By Alberto Mardegan on 2015-10-29

Merge trunk

[ Alberto Mardegan ]
* Regenerate hooks whenever file time changes (LP: #1510640)
[ CI Train Bot ]
* Resync trunk. added: po/hi.po
[ Alberto Mardegan ]
* Simplify hooks, load v2api library added: click-hooks/accounts.cpp
  click-hooks/accounts.hook.in click-hooks/acl-updater.cpp click-
  hooks/acl-updater.h click-hooks/click-hooks.pro click-hooks/online-
  accounts-hooks2.pro online-accounts-
  service/com.ubuntu.OnlineAccounts.Manager.service.in tests/click-
  hooks/click-hooks.pro tests/click-hooks/fake_signond.h tests/click-
  hooks/signond.py tests/click-hooks/tst_online_accounts_hooks2.cpp
  tests/click-hooks/tst_online_accounts_hooks2.pro renamed: click-
  hooks/click-hooks.pro => click-hooks/online-accounts-hooks.pro
  tests/click-hooks/click-hooks.pro => tests/click-
  hooks/tst_online_accounts_hooks.pro
[ CI Train Bot ]
* Resync trunk. added: po/mr.po po/th.po

304. By Alberto Mardegan on 2015-11-02

merge trunk

[ Alberto Mardegan ]
* Use version 1.3 of Ubuntu.Components (LP: #1508363, #1511055)
[ CI Train Bot ]
* Resync trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-10-30 15:41:20 +0000
3+++ debian/control 2015-11-02 07:28:58 +0000
4@@ -21,7 +21,7 @@
5 qtdeclarative5-qtquick2-plugin,
6 qtdeclarative5-test-plugin,
7 qtdeclarative5-ubuntu-ui-toolkit-plugin,
8- signon-plugins-dev,
9+ signon-plugins-dev (>= 8.58),
10 dbus-test-runner,
11 xmldiff,
12 xvfb,
13@@ -42,7 +42,7 @@
14 libonline-accounts-daemon1,
15 liboxideqt-qmlplugin (>= 1.2.0),
16 qml-module-ubuntu-onlineaccounts2,
17- qtdeclarative5-accounts-plugin (>= 0.3),
18+ qtdeclarative5-accounts-plugin (>= 0.6),
19 qtdeclarative5-ubuntu-ui-toolkit-plugin | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles,
20 signon-ui-service,
21 ubuntu-system-settings
22
23=== modified file 'online-accounts-ui/browser-request.cpp'
24--- online-accounts-ui/browser-request.cpp 2015-04-03 11:37:41 +0000
25+++ online-accounts-ui/browser-request.cpp 2015-11-02 07:28:58 +0000
26@@ -36,6 +36,7 @@
27 #include <QStandardPaths>
28 #include <QTimer>
29 #include <QVariant>
30+#include <SignOn/uisessiondata.h>
31 #include <SignOn/uisessiondata_priv.h>
32
33 using namespace SignOnUi;
34@@ -179,8 +180,11 @@
35 void BrowserRequestPrivate::setCurrentUrl(const QUrl &url)
36 {
37 DEBUG() << "Url changed:" << url;
38- m_failTimer.stop();
39+ if (m_failTimer.isActive()) {
40+ m_failTimer.start();
41+ }
42
43+ m_currentUrl = url;
44 if (url.host() == m_finalUrl.host() &&
45 url.path() == m_finalUrl.path()) {
46 m_responseUrl = url;
47@@ -258,7 +262,9 @@
48
49 DEBUG() << "Page loading failed";
50 closeView();
51- q->setResult(QVariantMap());
52+ QVariantMap result;
53+ result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_NETWORK;
54+ q->setResult(result);
55 }
56
57 void BrowserRequestPrivate::onFinished()
58
59=== modified file 'online-accounts-ui/qml/ProviderRequest.qml'
60--- online-accounts-ui/qml/ProviderRequest.qml 2015-10-29 13:44:51 +0000
61+++ online-accounts-ui/qml/ProviderRequest.qml 2015-11-02 07:28:58 +0000
62@@ -145,8 +145,6 @@
63 Item {
64 ActivityIndicator {
65 anchors.centerIn: parent
66- width: units.gu(5)
67- height: width
68 running: true
69 }
70 }
71
72=== added file 'plugins/module/ErrorItem.qml'
73--- plugins/module/ErrorItem.qml 1970-01-01 00:00:00 +0000
74+++ plugins/module/ErrorItem.qml 2015-11-02 07:28:58 +0000
75@@ -0,0 +1,48 @@
76+/*
77+ * Copyright (C) 2015 Canonical Ltd.
78+ *
79+ * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
80+ *
81+ * This program is free software: you can redistribute it and/or modify it
82+ * under the terms of the GNU General Public License version 3, as published
83+ * by the Free Software Foundation.
84+ *
85+ * This program is distributed in the hope that it will be useful, but
86+ * WITHOUT ANY WARRANTY; without even the implied warranties of
87+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
88+ * PURPOSE. See the GNU General Public License for more details.
89+ *
90+ * You should have received a copy of the GNU General Public License along
91+ * with this program. If not, see <http://www.gnu.org/licenses/>.
92+ */
93+
94+import QtQuick 2.0
95+import Ubuntu.Components 0.1
96+import Ubuntu.Components.ListItems 0.1 as ListItem
97+
98+Item {
99+ id: root
100+
101+ signal retryRequested()
102+
103+ Column {
104+ anchors {
105+ verticalCenter: parent.verticalCenter
106+ left: parent.left; right: parent.right
107+ }
108+ spacing: units.gu(2)
109+
110+ Label {
111+ anchors { left: parent.left; right: parent.right }
112+ text: i18n.dtr("ubuntu-system-settings-online-accounts", "This service is not available right now. Try again later.")
113+ wrapMode: Text.WordWrap
114+ horizontalAlignment: Text.AlignHCenter
115+ }
116+
117+ Button {
118+ anchors.horizontalCenter: parent.horizontalCenter
119+ text: i18n.dtr("ubuntu-system-settings-online-accounts", "Try Again")
120+ onClicked: root.retryRequested()
121+ }
122+ }
123+}
124
125=== modified file 'plugins/module/OAuth.qml'
126--- plugins/module/OAuth.qml 2015-10-22 08:33:20 +0000
127+++ plugins/module/OAuth.qml 2015-11-02 07:28:58 +0000
128@@ -95,7 +95,7 @@
129 }
130
131 ListItem.Base {
132- visible: loading
133+ visible: loading && !errorItem.visible
134 height: units.gu(7)
135 showDivider: false
136 anchors.top: parent.top
137@@ -136,6 +136,16 @@
138 visible: !loading
139 }
140
141+ ErrorItem {
142+ id: errorItem
143+ anchors { fill: parent; margins: units.gu(4) }
144+ visible: false
145+ onRetryRequested: {
146+ root.credentialsStored()
147+ visible = false
148+ }
149+ }
150+
151 KeyboardRectangle {
152 id: osk
153 }
154@@ -217,7 +227,15 @@
155
156 onAuthenticated: completeCreation(reply)
157
158- onAuthenticationError: root.cancel()
159+ onAuthenticationError: {
160+ console.log("Authentication error, code " + error.code)
161+ if (error.code == AccountService.NetworkError) {
162+ console.log("Network error")
163+ errorItem.visible = true
164+ return
165+ }
166+ root.cancel()
167+ }
168
169 onFinished: loading = false
170 }
171
172=== modified file 'plugins/module/WebView.qml'
173--- plugins/module/WebView.qml 2015-10-22 08:28:26 +0000
174+++ plugins/module/WebView.qml 2015-11-02 07:28:58 +0000
175@@ -14,7 +14,7 @@
176
177 onLoadingChanged: {
178 console.log("Loading changed")
179- if (loading) {
180+ if (loading && !lastLoadFailed) {
181 signonRequest.onLoadStarted()
182 } else if (lastLoadSucceeded) {
183 signonRequest.onLoadFinished(true)
184
185=== modified file 'plugins/module/module.pro'
186--- plugins/module/module.pro 2014-10-03 14:56:11 +0000
187+++ plugins/module/module.pro 2015-11-02 07:28:58 +0000
188@@ -34,6 +34,7 @@
189 LIBS += -lonline-accounts-plugin
190
191 QML_SOURCES = \
192+ ErrorItem.qml \
193 KeyboardRectangle.qml \
194 OAuthMain.qml \
195 OAuth.qml \
196
197=== modified file 'tests/online-accounts-ui/tst_browser_request.cpp'
198--- tests/online-accounts-ui/tst_browser_request.cpp 2015-01-09 10:12:03 +0000
199+++ tests/online-accounts-ui/tst_browser_request.cpp 2015-11-02 07:28:58 +0000
200@@ -259,7 +259,7 @@
201
202 QCOMPARE(setResultCalled.count(), 1);
203 QVariantMap results = setResultCalled.at(0).at(0).toMap();
204- QVERIFY(results.isEmpty());
205+ QVERIFY(results.contains(SSOUI_KEY_ERROR));
206 }
207
208 void BrowserRequestTest::testCancelWithHandler()

Subscribers

People subscribed via source and target branches