Merge lp:~renatofilho/sync-monitor/re-authenticate into lp:sync-monitor

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: David Barth
Approved revision: 59
Merged at revision: 47
Proposed branch: lp:~renatofilho/sync-monitor/re-authenticate
Merge into: lp:sync-monitor
Diff against target: 816 lines (+480/-30)
16 files modified
CMakeLists.txt (+2/-0)
authenticator/CMakeLists.txt (+41/-0)
authenticator/main.cpp (+90/-0)
authenticator/main.qml (+196/-0)
authenticator/sync-monitor-helper.qrc (+5/-0)
authenticator/syncmonitorhelper.desktop.in (+7/-0)
authenticator/syncmonitorhelper.url-dispatcher (+5/-0)
debian/control (+15/-0)
debian/sync-monitor-helper.install (+3/-0)
po/CMakeLists.txt (+9/-2)
po/sync-monitor.pot (+50/-23)
src/CMakeLists.txt (+2/-0)
src/sync-account.cpp (+18/-1)
src/sync-account.h (+2/-3)
src/sync-daemon.cpp (+32/-1)
src/sync-daemon.h (+3/-0)
To merge this branch: bzr merge lp:~renatofilho/sync-monitor/re-authenticate
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+249254@code.launchpad.net

Commit message

Created sync-monitor-helper to re-authenticate accounts.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
48. By Renato Araujo Oliveira Filho

Added missing install file.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
49. By Renato Araujo Oliveira Filho

Renamed syncmonitor helper destkop file.
Updated code to use ulr_dispatcher library instead on QDesktopService.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
50. By Renato Araujo Oliveira Filho

Removed useless include.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
51. By Renato Araujo Oliveira Filho

Fixed install file for syncmonitorhelper.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
52. By Renato Araujo Oliveira Filho

Fixed qml missing '}'

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
53. By Renato Araujo Oliveira Filho

Fixed debian package for sync-monitor-helper.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
54. By Renato Araujo Oliveira Filho

Refactory authentication helper app designer.

55. By Renato Araujo Oliveira Filho

Added sync-monitor-helper as dependency for sync-monitor.

56. By Renato Araujo Oliveira Filho

Fixed button size.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
57. By Renato Araujo Oliveira Filho

Make sure that the synevolution helper app does not appear on unity application list.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
58. By Renato Araujo Oliveira Filho

Fixed desktop file.

59. By Renato Araujo Oliveira Filho

Translation of sync-monitor-help updated.

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

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-11-13 13:46:38 +0000
3+++ CMakeLists.txt 2015-03-23 19:58:46 +0000
4@@ -11,6 +11,7 @@
5 add_definitions(-DQT_NO_KEYWORDS)
6
7 pkg_check_modules(ACCOUNTS REQUIRED accounts-qt5>=1.10)
8+pkg_check_modules(URLDISPATCHER REQUIRED url-dispatcher-1)
9 pkg_check_modules(LIBNOTIFY libnotify)
10
11 find_program(INTLTOOL_MERGE_EXECUTABLE intltool-merge)
12@@ -28,6 +29,7 @@
13 enable_testing()
14 add_subdirectory(3rd_party)
15 add_subdirectory(src)
16+add_subdirectory(authenticator)
17 add_subdirectory(accounts)
18 add_subdirectory(templates)
19 add_subdirectory(tests)
20
21=== added directory 'authenticator'
22=== added file 'authenticator/CMakeLists.txt'
23--- authenticator/CMakeLists.txt 1970-01-01 00:00:00 +0000
24+++ authenticator/CMakeLists.txt 2015-03-23 19:58:46 +0000
25@@ -0,0 +1,41 @@
26+project(sync-monitor-helper)
27+
28+set(SYNC_MONITOR_HELPER_BIN sync-monitor-helper)
29+
30+QT5_ADD_RESOURCES(SYNC_MONITOR_HELPER_RC
31+ sync-monitor-helper.qrc
32+)
33+
34+include_directories(
35+ ${CMAKE_BINARY_DIR}
36+)
37+
38+add_executable(${SYNC_MONITOR_HELPER_BIN}
39+ main.cpp
40+ ${SYNC_MONITOR_HELPER_RC}
41+)
42+
43+qt5_use_modules(${SYNC_MONITOR_HELPER_BIN} Core Gui Quick)
44+
45+set(SYNC_MONITOR_HELPER_QMLS
46+ main.qml
47+)
48+
49+set(SYNC_MONITOR_HELPER_INSTALL_PATH
50+ ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/sync-monitor/
51+)
52+
53+install(FILES "syncmonitorhelper.url-dispatcher"
54+ DESTINATION ${CMAKE_INSTALL_DATADIR}/url-dispatcher/urls
55+)
56+
57+configure_file(syncmonitorhelper.desktop.in syncmonitorhelper.desktop)
58+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/syncmonitorhelper.desktop"
59+ DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
60+)
61+
62+install(TARGETS ${SYNC_MONITOR_HELPER_BIN}
63+ RUNTIME DESTINATION ${SYNC_MONITOR_HELPER_INSTALL_PATH})
64+
65+# make the files visible on qtcreator
66+add_custom_target(sync_monitor_helper_QMlFiles ALL SOURCES ${SYNC_MONITOR_HELPER_QMLS})
67
68=== added file 'authenticator/main.cpp'
69--- authenticator/main.cpp 1970-01-01 00:00:00 +0000
70+++ authenticator/main.cpp 2015-03-23 19:58:46 +0000
71@@ -0,0 +1,90 @@
72+/*
73+ * Copyright (C) 2015 Canonical, Ltd.
74+ *
75+ * This program is free software; you can redistribute it and/or modify
76+ * it under the terms of the GNU General Public License as published by
77+ * the Free Software Foundation; version 3.
78+ *
79+ * This program is distributed in the hope that it will be useful,
80+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
81+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82+ * GNU General Public License for more details.
83+ *
84+ * You should have received a copy of the GNU General Public License
85+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
86+ */
87+
88+#include "config.h"
89+
90+#include <QUrlQuery>
91+#include <QGuiApplication>
92+#include <QQuickView>
93+#include <QQmlEngine>
94+#include <QQmlContext>
95+#include <QDebug>
96+
97+QVariantMap parseAccountArg(QStringList args)
98+{
99+ //syncmonitor:///authenticate?id=%1&service=%2
100+ Q_FOREACH(const QString &arg, args) {
101+ if (arg.startsWith("syncmonitorhelper:///")) {
102+ QUrl url = QUrl::fromPercentEncoding(arg.toUtf8());
103+ QString methodName = url.path().right(url.path().length() -1);
104+ if (methodName != "authenticate") {
105+ return QVariantMap();
106+ }
107+
108+ //convert items to map
109+ QUrlQuery query(url);
110+ QList<QPair<QString, QString> > queryItemsPair = query.queryItems();
111+ QMap<QString, QString> queryItems;
112+ for(int i=0; i < queryItemsPair.count(); i++) {
113+ QPair<QString, QString> item = queryItemsPair[i];
114+ queryItems.insert(item.first, item.second);
115+ }
116+
117+ if (queryItems.contains("id") && queryItems.contains("service")) {
118+ QVariantMap info;
119+ info.insert("accountId", queryItems.value("id"));
120+ info.insert("serviceName", queryItems.value("service"));
121+ return info;
122+ } else {
123+ return QVariantMap();
124+ }
125+ }
126+ }
127+ return QVariantMap();
128+}
129+
130+int main(int argc, char **argv)
131+{
132+ QCoreApplication::setOrganizationName("Canonical");
133+ QCoreApplication::setOrganizationDomain("canonical.com");
134+ QCoreApplication::setApplicationName("Sync Monitor Helper");
135+
136+ QGuiApplication *app = new QGuiApplication(argc, argv);
137+ QVariantMap accountInfo = parseAccountArg(app->arguments());
138+ if (accountInfo.isEmpty()) {
139+ qWarning() << "Usage: sync-monitor-helper syncmonitorhelper:///authenticate?id=<accountId>&service=<serviceName";
140+ delete app;
141+ return -1;
142+ }
143+
144+ QQuickView *view = new QQuickView;
145+ app->connect(view->engine(), SIGNAL(quit()), SLOT(quit()));
146+
147+ view->setResizeMode(QQuickView::SizeRootObjectToView);
148+ view->setTitle("Sync Monitor");
149+ view->rootContext()->setContextProperty("ONLINE_ACCOUNT", accountInfo);
150+ view->rootContext()->setContextProperty("GETTEXT_PACKAGE", GETTEXT_PACKAGE);
151+ view->rootContext()->setContextProperty("GETTEXT_LOCALEDIR", GETTEXT_LOCALEDIR);
152+ view->rootContext()->setContextProperty("GETTEXT_PACKAGE", GETTEXT_PACKAGE);
153+ view->setSource(QUrl("qrc:/main.qml"));
154+
155+ qDebug() << accountInfo;
156+ view->show();
157+ app->exec();
158+ delete view;
159+ delete app;
160+ return 0;
161+}
162
163=== added file 'authenticator/main.qml'
164--- authenticator/main.qml 1970-01-01 00:00:00 +0000
165+++ authenticator/main.qml 2015-03-23 19:58:46 +0000
166@@ -0,0 +1,196 @@
167+import QtQuick 2.2
168+
169+import Ubuntu.Components 1.1
170+import Ubuntu.Components.ListItems 1.0 as ListItem
171+import Ubuntu.OnlineAccounts 0.1
172+
173+MainView {
174+ id: root
175+
176+ property bool accountFound: false
177+
178+ width: units.gu(40)
179+ height: units.gu(71)
180+ useDeprecatedToolbar: false
181+
182+ AccountServiceModel {
183+ id: accountServiceModel
184+
185+ accountId: ONLINE_ACCOUNT.accountId
186+ service: ONLINE_ACCOUNT.serviceName
187+ onCountChanged: {
188+ console.debug("Account count changed:" + count)
189+ if ((count == 1) && (pageStack.depth == 0)) {
190+ var _acc = {}
191+ _acc["displayName"] = accountServiceModel.get(0, "displayName")
192+ _acc["providerName"] = accountServiceModel.get(0, "providerName")
193+ _acc["serviceName"] = accountServiceModel.get(0, "serviceName")
194+ _acc["accountServiceHandle"] = accountServiceModel.get(0, "accountServiceHandle")
195+ _acc["accountId"] = accountServiceModel.get(0, "accountId")
196+ _acc["accountHandle"] = accountServiceModel.get(0, "accountHandle")
197+ root.accountFound = true
198+ pageStack.push(accountPageComponent, {"account" : _acc})
199+ }
200+ }
201+ }
202+
203+ PageStack {
204+ id: pageStack
205+
206+ Component.onCompleted: {
207+ if (!root.accountFound) {
208+ pageStack.push(loadingPageComponent)
209+ accountNotFoundTimeout.start()
210+ }
211+ }
212+ }
213+
214+ Timer {
215+ id: accountNotFoundTimeout
216+
217+ interval: 5000
218+ repeat: false
219+ onTriggered: {
220+ if (!root.accountFound) {
221+ pageStack.push(accountNotFoundPageComponent)
222+ }
223+ }
224+ }
225+
226+ Component {
227+ id: loadingPageComponent
228+
229+ Page {
230+ id: loadingPage
231+
232+ title: i18n.tr("Accounts")
233+
234+ ActivityIndicator {
235+ id: activity
236+
237+ anchors.centerIn : parent
238+ running: visible
239+ visible: loadingPage.active
240+ }
241+ }
242+ }
243+
244+ Component {
245+ id: accountNotFoundPageComponent
246+
247+ Page {
248+ id: accountNotFoundPage
249+
250+ title: i18n.tr("Accounts")
251+
252+ head.backAction: Action {
253+ iconName: "back"
254+ text: i18n.tr("Quit")
255+ onTriggered: Qt.quit()
256+ }
257+
258+ Label {
259+ anchors.centerIn: parent
260+ text: i18n.tr("Fail to load account information.")
261+ }
262+ }
263+ }
264+
265+ Component {
266+ id: accountPageComponent
267+
268+ Page {
269+ id: accountPage
270+
271+ property var account
272+ property bool loginInProcess: false
273+
274+ function getProviderIcon(providerName)
275+ {
276+ switch(providerName)
277+ {
278+ case "Google":
279+ return "google"
280+ default:
281+ return "contact-group"
282+ }
283+ }
284+
285+ title: i18n.tr("Fail to sync")
286+
287+ head.backAction: Action {
288+ iconName: "back"
289+ text: i18n.tr("Quit")
290+ onTriggered: Qt.quit()
291+ }
292+
293+ AccountService {
294+ id: accountService
295+
296+ objectHandle: accountPage.account.accountServiceHandle
297+ onAuthenticated: {
298+ accountPage.loginInProcess = false
299+ Qt.quit()
300+ }
301+ onAuthenticationError: {
302+ accountPage.loginInProcess = false
303+ console.log("Authentication failed, code " + error.code)
304+ }
305+ }
306+
307+ Column {
308+ anchors {
309+ verticalCenter: parent.verticalCenter
310+ left: parent.left
311+ right: parent.right
312+ margins: units.gu(2)
313+ }
314+ spacing: units.gu(4)
315+ width: parent.width
316+ visible: !accountPage.loginInProcess
317+
318+ Label {
319+ id: lblTitle
320+
321+ anchors {
322+ left: parent.left
323+ right: parent.right
324+ }
325+
326+ text: i18n.tr("Your account failed to authenticate while syncing. Please click below to re-authenticate.")
327+ wrapMode: Text.WordWrap
328+ horizontalAlignment: Text.AlignHCenter
329+ fontSize: "large"
330+ }
331+
332+ Button {
333+ anchors {
334+ left: parent.left
335+ right: parent.right
336+ }
337+ text: accountPage.account.displayName
338+ iconName: accountPage.getProviderIcon(accountPage.account.providerName)
339+ onClicked: {
340+ if (!accountPage.busy) {
341+ accountPage.loginInProcess = true
342+ accountService.authenticate(null)
343+ }
344+ }
345+ }
346+ }
347+
348+ ActivityIndicator {
349+ id: activity
350+
351+ anchors.centerIn: parent
352+ running: visible
353+ visible: accountPage.loginInProcess
354+ }
355+ }
356+ }
357+
358+ Component.onCompleted: {
359+ i18n.domain = GETTEXT_PACKAGE
360+ i18n.bindtextdomain(GETTEXT_PACKAGE, GETTEXT_LOCALEDIR)
361+ }
362+}
363
364=== added file 'authenticator/sync-monitor-helper.qrc'
365--- authenticator/sync-monitor-helper.qrc 1970-01-01 00:00:00 +0000
366+++ authenticator/sync-monitor-helper.qrc 2015-03-23 19:58:46 +0000
367@@ -0,0 +1,5 @@
368+<RCC>
369+ <qresource prefix="/">
370+ <file>main.qml</file>
371+ </qresource>
372+</RCC>
373
374=== added file 'authenticator/syncmonitorhelper.desktop.in'
375--- authenticator/syncmonitorhelper.desktop.in 1970-01-01 00:00:00 +0000
376+++ authenticator/syncmonitorhelper.desktop.in 2015-03-23 19:58:46 +0000
377@@ -0,0 +1,7 @@
378+[Desktop Entry]
379+Name=Sync Monitor
380+Comment=Ask for online account authentication if the token expires
381+Exec=@SYNC_MONITOR_HELPER_INSTALL_PATH@@SYNC_MONITOR_HELPER_BIN@ %u
382+Terminal=false
383+Type=Application
384+Version=1.0
385
386=== added file 'authenticator/syncmonitorhelper.url-dispatcher'
387--- authenticator/syncmonitorhelper.url-dispatcher 1970-01-01 00:00:00 +0000
388+++ authenticator/syncmonitorhelper.url-dispatcher 2015-03-23 19:58:46 +0000
389@@ -0,0 +1,5 @@
390+[
391+ {
392+ "protocol": "syncmonitorhelper"
393+ }
394+]
395
396=== modified file 'debian/control'
397--- debian/control 2014-09-26 21:08:46 +0000
398+++ debian/control 2015-03-23 19:58:46 +0000
399@@ -8,6 +8,7 @@
400 google-mock,
401 libaccounts-qt5-dev,
402 libnotify-dev,
403+ liburl-dispatcher1-dev,
404 pkg-config,
405 qt5-default,
406 qtbase5-dev,
407@@ -31,6 +32,7 @@
408 address-book-service,
409 syncevolution-dbus (>= 1.4),
410 syncevolution-provider-uoa (>= 1.4),
411+ sync-monitor-helper (>= ${binary:Version}),
412 qtcontact5-galera,
413 qtorganizer5-eds,
414 Description: Ubuntu online account sync monitor plugin
415@@ -64,3 +66,16 @@
416 .
417 This package contains the QML plugin providing the features from the sync
418 monitor to applications.
419+
420+Package: sync-monitor-helper
421+Architecture: any
422+Multi-Arch: foreign
423+Pre-Depends: ${misc:Pre-Depends},
424+Depends: ${misc:Depends}
425+Description: Ubuntu online account sync monitor plugin - helper to re-authenticate
426+ the online accounts.
427+ .
428+ With this package you can keep track of Ubuntu online accounts and sync
429+ with the cloud.
430+ .
431+ This package contains the ubuntu online accounts service files.
432
433=== added file 'debian/sync-monitor-helper.install'
434--- debian/sync-monitor-helper.install 1970-01-01 00:00:00 +0000
435+++ debian/sync-monitor-helper.install 2015-03-23 19:58:46 +0000
436@@ -0,0 +1,3 @@
437+usr/share/url-dispatcher/urls/syncmonitorhelper.url-dispatcher
438+usr/share/applications/syncmonitorhelper.desktop
439+usr/lib/*/sync-monitor/sync-monitor-helper
440
441=== modified file 'po/CMakeLists.txt'
442--- po/CMakeLists.txt 2014-11-13 13:46:38 +0000
443+++ po/CMakeLists.txt 2015-03-23 19:58:46 +0000
444@@ -15,6 +15,10 @@
445 file(GLOB_RECURSE I18N_XMLS RELATIVE ${CMAKE_CURRENT_BINARY_DIR}
446 ${CMAKE_SOURCE_DIR}/accounts/applications/*.in
447 )
448+file(GLOB_RECURSE I18N_QMLS RELATIVE ${CMAKE_SOURCE_DIR}
449+ ${sync-monitor-helper_SOURCE_DIR}/*.qml
450+)
451+
452 string(REPLACE "${CMAKE_SOURCE_DIR}/" "" RELATIVE_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
453 foreach(XML_FILE ${I18N_XMLS})
454 get_filename_component(XML_BASE_NAME ${XML_FILE} NAME)
455@@ -39,9 +43,12 @@
456 COMMAND ${XGETTEXT_EXECUTABLE} -o ${POT_FILE}
457 --c++ --qt --add-comments=TRANSLATORS
458 --keyword=_ --keyword=N_
459+ --keyword=tr --keyword=tr:1,2
460+ --keyword=dtr:2 --keyword=dtr:2,3
461 --package-name=${DOMAIN}
462 --copyright-holder='Canonical Ltd.'
463- -D ${CMAKE_SOURCE_DIR} -s
464- -p ${CMAKE_CURRENT_SOURCE_DIR} ${I18N_SRCS}
465+ -D ${CMAKE_SOURCE_DIR} ${I18N_QMLS}
466+ -D ${CMAKE_SOURCE_DIR} ${I18N_SRCS}
467+ -s -p ${CMAKE_CURRENT_SOURCE_DIR} ${I18N_SRCS}
468 )
469 endif()
470
471=== modified file 'po/sync-monitor.pot'
472--- po/sync-monitor.pot 2014-11-13 13:46:59 +0000
473+++ po/sync-monitor.pot 2015-03-23 19:58:46 +0000
474@@ -8,7 +8,7 @@
475 msgstr ""
476 "Project-Id-Version: sync-monitor\n"
477 "Report-Msgid-Bugs-To: \n"
478-"POT-Creation-Date: 2014-11-13 10:43-0300\n"
479+"POT-Creation-Date: 2015-03-23 16:48-0300\n"
480 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
481 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
482 "Language-Team: LANGUAGE <LL@li.org>\n"
483@@ -17,24 +17,28 @@
484 "Content-Type: text/plain; charset=CHARSET\n"
485 "Content-Transfer-Encoding: 8bit\n"
486
487-#: src/sync-daemon.cpp:378
488+#: src/sync-daemon.cpp:388
489 #, qt-format
490 msgid "Account %1 removed. Do you want to keep the account data?"
491 msgstr ""
492
493-#: src/sync-account.cpp:532
494+#: authenticator/main.qml:66 authenticator/main.qml:84
495+msgid "Accounts"
496+msgstr ""
497+
498+#: src/sync-account.cpp:551
499 msgid "Command not allowed"
500 msgstr ""
501
502-#: src/sync-account.cpp:552
503+#: src/sync-account.cpp:571
504 msgid "Connection certificate has expired"
505 msgstr ""
506
507-#: src/sync-account.cpp:554
508+#: src/sync-account.cpp:573
509 msgid "Connection certificate is invalid"
510 msgstr ""
511
512-#: src/sync-account.cpp:550
513+#: src/sync-account.cpp:569
514 msgid "Connection timeout"
515 msgstr ""
516
517@@ -42,34 +46,42 @@
518 msgid "Contacts"
519 msgstr ""
520
521-#: src/sync-account.cpp:537
522+#: src/sync-account.cpp:556
523 msgid "Disk full"
524 msgstr ""
525
526-#: src/sync-account.cpp:558
527+#: src/sync-account.cpp:577
528 msgid "Fail to connect with the server"
529 msgstr ""
530
531-#: src/sync-account.cpp:541
532+#: authenticator/main.qml:94
533+msgid "Fail to load account information."
534+msgstr ""
535+
536+#: src/sync-account.cpp:560
537 msgid "Fail to run \"two-way\" sync"
538 msgstr ""
539
540-#: src/sync-daemon.cpp:469
541+#: authenticator/main.qml:119
542+msgid "Fail to sync"
543+msgstr ""
544+
545+#: src/sync-daemon.cpp:507
546 #, qt-format
547 msgid ""
548 "Fail to sync %1 (%2).\n"
549 "%3"
550 msgstr ""
551
552-#: src/sync-account.cpp:539
553+#: src/sync-account.cpp:558
554 msgid "Fail to sync due some remote problem"
555 msgstr ""
556
557-#: src/sync-account.cpp:543
558+#: src/sync-account.cpp:562
559 msgid "Fail to sync some items"
560 msgstr ""
561
562-#: src/sync-account.cpp:528
563+#: src/sync-account.cpp:547
564 msgid "Forbidden / access denied"
565 msgstr ""
566
567@@ -77,38 +89,42 @@
568 msgid "No"
569 msgstr ""
570
571-#: src/sync-account.cpp:530
572+#: src/sync-account.cpp:549
573 msgid "Object not found / unassigned field"
574 msgstr ""
575
576-#: src/sync-account.cpp:545
577+#: src/sync-account.cpp:564
578 msgid "Process unexpected die."
579 msgstr ""
580
581-#: src/sync-account.cpp:535
582+#: src/sync-account.cpp:554
583 msgid "Proxy authentication required"
584 msgstr ""
585
586-#: src/sync-account.cpp:561
587+#: authenticator/main.qml:88 authenticator/main.qml:123
588+msgid "Quit"
589+msgstr ""
590+
591+#: src/sync-account.cpp:580
592 msgid "Server not found"
593 msgstr ""
594
595-#: src/sync-account.cpp:548
596+#: src/sync-account.cpp:567
597 msgid "Server sent bad content"
598 msgstr ""
599
600-#: src/sync-daemon.cpp:409
601+#: src/sync-daemon.cpp:442
602 #, qt-format
603 msgid "Start sync: %1 (%2)"
604 msgstr ""
605
606-#: src/sync-daemon.cpp:433
607+#: src/sync-daemon.cpp:467
608 #, qt-format
609 msgid "Sync done: %1 (%2)"
610 msgstr ""
611
612-#: src/sync-daemon.cpp:377 src/sync-daemon.cpp:408 src/sync-daemon.cpp:432
613-#: src/sync-daemon.cpp:468
614+#: src/sync-daemon.cpp:387 src/sync-daemon.cpp:419 src/sync-daemon.cpp:441
615+#: src/sync-daemon.cpp:466 src/sync-daemon.cpp:506
616 msgid "Synchronization"
617 msgstr ""
618
619@@ -116,10 +132,21 @@
620 msgid "Synchronize your contacts"
621 msgstr ""
622
623-#: src/sync-account.cpp:563
624+#: src/sync-account.cpp:582
625 msgid "Unknown status"
626 msgstr ""
627
628 #: src/notify-message.cpp:83
629 msgid "Yes"
630 msgstr ""
631+
632+#: src/sync-daemon.cpp:420
633+msgid ""
634+"Your access key is not valid anymore. Do you want to re-authenticate it?."
635+msgstr ""
636+
637+#: authenticator/main.qml:160
638+msgid ""
639+"Your account failed to authenticate while syncing. Please click below to re-"
640+"authenticate."
641+msgstr ""
642
643=== modified file 'src/CMakeLists.txt'
644--- src/CMakeLists.txt 2014-10-28 13:27:37 +0000
645+++ src/CMakeLists.txt 2015-03-23 19:58:46 +0000
646@@ -36,6 +36,7 @@
647 target_link_libraries(${SYNQ_LIB}
648 ${ACCOUNTS_LIBRARIES}
649 ${LIBNOTIFY_LIBRARIES}
650+ ${URLDISPATCHER_LIBRARIES}
651 syncevolution-qt
652 )
653
654@@ -60,6 +61,7 @@
655 ${CMAKE_BINARY_DIR}
656 ${ACCOUNTS_INCLUDE_DIRS}
657 ${LIBNOTIFY_INCLUDE_DIRS}
658+ ${URLDISPATCHER_INCLUDE_DIRS}
659 ${syncevolution-qt_SOURCE_DIR}
660 )
661
662
663=== modified file 'src/sync-account.cpp'
664--- src/sync-account.cpp 2014-11-19 18:15:59 +0000
665+++ src/sync-account.cpp 2015-03-23 19:58:46 +0000
666@@ -33,7 +33,8 @@
667 m_currentSession(0),
668 m_account(account),
669 m_state(SyncAccount::Idle),
670- m_settings(settings)
671+ m_settings(settings),
672+ m_lastError(0)
673 {
674 setup();
675 }
676@@ -352,6 +353,22 @@
677 return m_lastError;
678 }
679
680+void SyncAccount::setLastError(uint errorCode)
681+{
682+ m_lastError = errorCode;
683+}
684+
685+QString SyncAccount::serviceId(const QString &serviceName) const
686+{
687+ Q_FOREACH(Service service, m_account->services()) {
688+ qDebug() << service.serviceType() << service.name();
689+ if (service.serviceType() == serviceName) {
690+ return service.name();
691+ }
692+ }
693+ return QString();
694+}
695+
696 void SyncAccount::onAccountEnabledChanged(const QString &serviceName, bool enabled)
697 {
698 // empty service name means that the hole account has been enabled/disabled
699
700=== modified file 'src/sync-account.h'
701--- src/sync-account.h 2014-11-05 19:05:34 +0000
702+++ src/sync-account.h 2015-03-23 19:58:46 +0000
703@@ -34,9 +34,6 @@
704 {
705 Q_OBJECT
706 public:
707- static const QString GoogleCalendarService;
708- static const QString GoogleContactService;
709-
710 enum AccountState {
711 Configuring = 0,
712 Syncing,
713@@ -62,6 +59,8 @@
714 virtual QStringList availableServices() const;
715 QStringList enabledServices() const;
716 uint lastError() const;
717+ void setLastError(uint errorCode);
718+ QString serviceId(const QString &serviceName) const;
719
720 static QString statusDescription(const QString &status);
721
722
723=== modified file 'src/sync-daemon.cpp'
724--- src/sync-daemon.cpp 2015-01-21 13:38:06 +0000
725+++ src/sync-daemon.cpp 2015-03-23 19:58:46 +0000
726@@ -30,6 +30,8 @@
727 #include <QtCore/QDebug>
728 #include <QtCore/QTimer>
729
730+#include <url-dispatcher.h>
731+
732 using namespace Accounts;
733
734
735@@ -408,6 +410,29 @@
736 acc->deleteLater();
737 }
738
739+void SyncDaemon::authenticateAccount(const SyncAccount *account, const QString &serviceName)
740+{
741+ NotifyMessage *notify = new NotifyMessage(true, this);
742+ notify->setProperty("ACCOUNT", QVariant::fromValue<AccountId>(account->id()));
743+ notify->setProperty("SERVICE", QVariant::fromValue<QString>(account->serviceId(serviceName)));
744+ connect(notify, SIGNAL(questionAccepted()), SLOT(runAuthentication()));
745+ notify->askYesOrNo(_("Synchronization"),
746+ QString(_("Your access key is not valid anymore. Do you want to re-authenticate it?.")),
747+ account->iconName(serviceName));
748+
749+}
750+
751+void SyncDaemon::runAuthentication()
752+{
753+ QObject *sender = QObject::sender();
754+ AccountId accountId = sender->property("ACCOUNT").value<AccountId>();
755+ QString serviceName = sender->property("SERVICE").value<QString>();
756+
757+ QString appCommand = QString("syncmonitorhelper:///authenticate?id=%1&service=%2").arg(accountId).arg(serviceName);
758+ qDebug() << "Run" << appCommand;
759+ url_dispatch_send(appCommand.toUtf8().constData(), NULL, NULL);
760+}
761+
762 void SyncDaemon::onAccountSyncStarted(const QString &serviceName, bool firstSync)
763 {
764 SyncAccount *acc = qobject_cast<SyncAccount*>(QObject::sender());
765@@ -432,6 +457,7 @@
766 // error on that list will trigger a new sync
767 static QStringList whiteListStatus;
768
769+ uint errorCode = status.toUInt();
770 SyncAccount *acc = qobject_cast<SyncAccount*>(QObject::sender());
771 QString errorMessage = SyncAccount::statusDescription(status);
772
773@@ -455,6 +481,7 @@
774 .arg(QDateTime::currentDateTime().toString(Qt::SystemLocaleShortDate));
775
776
777+ // populate white list erros
778 if (whiteListStatus.isEmpty()) {
779 // "error code from SyncEvolution access denied (remote, status 403): could not obtain OAuth2 token:
780 // this can happen if the network goes off during the sync, or syc started before the network stabilished
781@@ -468,9 +495,12 @@
782 }
783
784 // only re-sync if sync mode != "slow", to avoid sync loops
785- if ((mode != "slow") && !errorMessage.isEmpty() && whiteListStatus.contains(status)) {
786+ if ((acc->lastError() == 0) && !errorMessage.isEmpty() && whiteListStatus.contains(status)) {
787 // white list error retry the sync
788 m_syncQueue->push(acc, serviceName, false);
789+ } else if (status.endsWith("403")){
790+ authenticateAccount(acc, serviceName);
791+ errorCode = 0;
792 } else if (!errorMessage.isEmpty()) {
793 NotifyMessage *notify = new NotifyMessage(true, this);
794 notify->show(_("Synchronization"),
795@@ -481,6 +511,7 @@
796 acc->iconName(serviceName));
797 }
798
799+ acc->setLastError(errorCode);
800 // sync next account
801 continueSync();
802 }
803
804=== modified file 'src/sync-daemon.h'
805--- src/sync-daemon.h 2015-01-21 13:38:06 +0000
806+++ src/sync-daemon.h 2015-03-23 19:58:46 +0000
807@@ -67,6 +67,9 @@
808 void removeAccount(const Accounts::AccountId &accountId);
809 void removeAccountSource();
810 void destroyAccount();
811+ void authenticateAccount(const SyncAccount *account,
812+ const QString &serviceName);
813+ void runAuthentication();
814
815 void onAccountSyncStarted(const QString &serviceName, bool firstSync);
816 void onAccountSyncFinished(const QString &serviceName, bool firstSync, const QString &status, const QString &syncMode);

Subscribers

People subscribed via source and target branches