diff --git a/src/services/inoreader/gui/formeditinoreaderaccount.cpp b/src/services/inoreader/gui/formeditinoreaderaccount.cpp index 0bb33d1c7..dec19baae 100755 --- a/src/services/inoreader/gui/formeditinoreaderaccount.cpp +++ b/src/services/inoreader/gui/formeditinoreaderaccount.cpp @@ -21,6 +21,7 @@ #include "gui/guiutilities.h" #include "miscellaneous/application.h" #include "miscellaneous/iconfactory.h" +#include "network-web/oauth2service.h" #include "services/inoreader/definitions.h" #include "services/inoreader/inoreaderserviceroot.h" @@ -60,17 +61,10 @@ FormEditInoreaderAccount::FormEditInoreaderAccount(QWidget* parent) : QDialog(pa FormEditInoreaderAccount::~FormEditInoreaderAccount() {} void FormEditInoreaderAccount::testSetup() { - if (m_network->isLoggedIn()) { - m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information, - tr("Access granted successfully."), - tr("Access granted successfully.")); - } - else { - m_network->login(); - m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Progress, - tr("Requested access approval. Respond to it, please."), - tr("Access approval was requested via OAuth 2.0 protocol.")); - } + m_network->login(); + m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Progress, + tr("Requested access approval. Respond to it, please."), + tr("Access approval was requested via OAuth 2.0 protocol.")); } void FormEditInoreaderAccount::onClickedOk() { @@ -108,14 +102,21 @@ void FormEditInoreaderAccount::checkUsername(const QString& username) { } void FormEditInoreaderAccount::hookNetwork() { - connect(m_network, &InoreaderNetworkFactory::accessGranted, [this]() { + connect(m_network->oauth(), &OAuth2Service::tokensReceived, [this]() { m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok, tr("Tested successfully. You may be prompted to login once more."), tr("Your access was approved.")); }); - connect(m_network, &InoreaderNetworkFactory::error, [this](const QString& err) { + connect(m_network->oauth(), &OAuth2Service::tokensRetrieveError, [this](QString error, QString error_description) { + Q_UNUSED(error) + m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error, - tr("There is error. %1").arg(err), + tr("There is error. %1").arg(error_description), + tr("There was error during testing.")); + }); + connect(m_network->oauth(), &OAuth2Service::authFailed, [this]() { + m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error, + tr("You did not grant access."), tr("There was error during testing.")); }); } diff --git a/src/services/inoreader/network/inoreadernetworkfactory.cpp b/src/services/inoreader/network/inoreadernetworkfactory.cpp index 13cff6044..0d313b529 100755 --- a/src/services/inoreader/network/inoreadernetworkfactory.cpp +++ b/src/services/inoreader/network/inoreadernetworkfactory.cpp @@ -67,6 +67,8 @@ void InoreaderNetworkFactory::login() { void InoreaderNetworkFactory::initializeOauth() { connect(m_oauth2, &OAuth2Service::tokensRetrieveError, [](QString error, QString error_description) { + Q_UNUSED(error) + qApp->showGuiMessage("Authentication error - Inoreader", error_description, QSystemTrayIcon::Critical); }); } diff --git a/src/services/inoreader/network/inoreadernetworkfactory.h b/src/services/inoreader/network/inoreadernetworkfactory.h index 785d7566e..4d9d44bfe 100755 --- a/src/services/inoreader/network/inoreadernetworkfactory.h +++ b/src/services/inoreader/network/inoreadernetworkfactory.h @@ -51,10 +51,6 @@ class InoreaderNetworkFactory : public QObject { public slots: void login(); - signals: - void accessGranted(); - void error(QString& description); - private: void initializeOauth();