From: Michael Schuster Date: Sat, 21 Dec 2019 02:52:51 +0000 (+0100) Subject: Flow2: Poll for re-auth result upon WebFlowCredentialsDialog window activation X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~457 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e04aae94bc3f5c35c85e3c2482f4b32de2fc2f5b;p=nextcloud-desktop.git Flow2: Poll for re-auth result upon WebFlowCredentialsDialog window activation Since the default remote poll interval has been re-raised recently to 30 seconds, the delay between clicking "Grant access" in the browser and fetch and showing success in the dialog may seem erroneous to the users and tempt them to click "Re-open browser" again, causing the whole login process to restart. This commit implements an event handler to pass the dialog's window activation event down to the Login Flow v2 widget, in order to allow it to poll earlier. See previous commits for dependent implementation details. Signed-off-by: Michael Schuster --- diff --git a/src/gui/creds/webflowcredentialsdialog.cpp b/src/gui/creds/webflowcredentialsdialog.cpp index 7a1485bd1..6d8b9473f 100644 --- a/src/gui/creds/webflowcredentialsdialog.cpp +++ b/src/gui/creds/webflowcredentialsdialog.cpp @@ -32,6 +32,9 @@ WebFlowCredentialsDialog::WebFlowCredentialsDialog(Account *account, bool useFlo _layout->addWidget(_flow2AuthWidget); connect(_flow2AuthWidget, &Flow2AuthWidget::urlCatched, this, &WebFlowCredentialsDialog::urlCatched); + + // allow Flow2 page to poll on window activation + connect(this, &WebFlowCredentialsDialog::onActivate, _flow2AuthWidget, &Flow2AuthWidget::slotPollNow); } else { _webView = new WebView(); _layout->addWidget(_webView); @@ -87,6 +90,20 @@ void WebFlowCredentialsDialog::setError(const QString &error) { } } +void WebFlowCredentialsDialog::changeEvent(QEvent *e) +{ + switch (e->type()) { + case QEvent::ActivationChange: + if(isActiveWindow()) + emit onActivate(); + break; + default: + break; + } + + QDialog::changeEvent(e); +} + void WebFlowCredentialsDialog::slotShowSettingsDialog() { // bring window to top but slightly delay, to avoid being hidden behind the SettingsDialog diff --git a/src/gui/creds/webflowcredentialsdialog.h b/src/gui/creds/webflowcredentialsdialog.h index 9885eef29..67775ff7b 100644 --- a/src/gui/creds/webflowcredentialsdialog.h +++ b/src/gui/creds/webflowcredentialsdialog.h @@ -30,12 +30,14 @@ public: protected: void closeEvent(QCloseEvent * e) override; + void changeEvent(QEvent *) override; public slots: void slotShowSettingsDialog(); signals: void urlCatched(const QString user, const QString pass, const QString host); + void onActivate(); private: bool _useFlow2; diff --git a/src/gui/wizard/flow2authwidget.cpp b/src/gui/wizard/flow2authwidget.cpp index c050a54d0..c26def167 100644 --- a/src/gui/wizard/flow2authwidget.cpp +++ b/src/gui/wizard/flow2authwidget.cpp @@ -55,6 +55,7 @@ Flow2AuthWidget::Flow2AuthWidget(Account *account, QWidget *parent) _asyncAuth.reset(new Flow2Auth(_account, this)); connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::asyncAuthResult, Qt::QueuedConnection); + connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow); _asyncAuth->start(); } @@ -112,4 +113,9 @@ void Flow2AuthWidget::slotCopyLinkToClipboard() QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded)); } +void Flow2AuthWidget::slotPollNow() +{ + emit pollNow(); +} + } // namespace OCC diff --git a/src/gui/wizard/flow2authwidget.h b/src/gui/wizard/flow2authwidget.h index 7fe1844c1..c07805e60 100644 --- a/src/gui/wizard/flow2authwidget.h +++ b/src/gui/wizard/flow2authwidget.h @@ -35,9 +35,11 @@ public: public Q_SLOTS: void asyncAuthResult(Flow2Auth::Result, const QString &user, const QString &appPassword); + void slotPollNow(); signals: void urlCatched(const QString user, const QString pass, const QString host); + void pollNow(); private: Account *_account;