Do not store access token, prepare DB for Inoreader multi acc.
This commit is contained in:
parent
4dab74c13c
commit
11e816bdf6
@ -43,6 +43,7 @@
|
||||
#include "definitions/definitions.h"
|
||||
#include "gui/dialogs/oauthlogin.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "services/inoreader/definitions.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
@ -53,7 +54,7 @@
|
||||
OAuth2Service::OAuth2Service(QString authUrl, QString tokenUrl, QString clientId,
|
||||
QString clientSecret, QString scope, QObject* parent)
|
||||
: QObject(parent), m_tokensExpireIn(QDateTime()) {
|
||||
m_redirectUri = QSL("http://localhost");
|
||||
m_redirectUri = QSL(INOREADER_OAUTH_CLI_REDIRECT);
|
||||
m_tokenGrantType = QSL("authorization_code");
|
||||
m_tokenUrl = QUrl(tokenUrl);
|
||||
m_authUrl = authUrl;
|
||||
|
@ -22,6 +22,8 @@
|
||||
#define INOREADER_OAUTH_SCOPE "read write"
|
||||
#define INOREADER_OAUTH_TOKEN_URL "https://www.inoreader.com/oauth2/token"
|
||||
#define INOREADER_OAUTH_AUTH_URL "https://www.inoreader.com/oauth2/auth"
|
||||
|
||||
#define INOREADER_OAUTH_CLI_REDIRECT "http://localhost"
|
||||
#define INOREADER_OAUTH_CLI_ID "1000000604"
|
||||
#define INOREADER_OAUTH_CLI_KEY "gsStoZ3aAoQJCgQxoFSuXkWI7Sly87yK"
|
||||
|
||||
|
@ -28,17 +28,26 @@
|
||||
FormEditInoreaderAccount::FormEditInoreaderAccount(QWidget* parent) : QDialog(parent),
|
||||
m_network(nullptr), m_editableRoot(nullptr) {
|
||||
m_ui.setupUi(this);
|
||||
|
||||
GuiUtilities::setLabelAsNotice(*m_ui.m_lblAuthInfo, true);
|
||||
GuiUtilities::applyDialogProperties(*this, qApp->icons()->miscIcon(QSL("inoreader")));
|
||||
|
||||
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
|
||||
tr("Not tested yet."),
|
||||
tr("Not tested yet."));
|
||||
m_ui.m_lblTestResult->label()->setWordWrap(true);
|
||||
m_ui.m_txtUsername->lineEdit()->setPlaceholderText(tr("User-visible username"));
|
||||
|
||||
setTabOrder(m_ui.m_txtUsername->lineEdit(), m_ui.m_spinLimitMessages);
|
||||
setTabOrder(m_ui.m_txtUsername->lineEdit(), m_ui.m_txtAppId);
|
||||
setTabOrder(m_ui.m_txtAppId, m_ui.m_txtAppKey);
|
||||
setTabOrder(m_ui.m_txtAppKey, m_ui.m_txtRedirectUrl);
|
||||
setTabOrder(m_ui.m_txtRedirectUrl, m_ui.m_spinLimitMessages);
|
||||
setTabOrder(m_ui.m_spinLimitMessages, m_ui.m_btnTestSetup);
|
||||
setTabOrder(m_ui.m_btnTestSetup, m_ui.m_buttonBox);
|
||||
|
||||
connect(m_ui.m_txtAppId->lineEdit(), &BaseLineEdit::textChanged, this, &FormEditInoreaderAccount::checkOAuthValue);
|
||||
connect(m_ui.m_txtAppKey->lineEdit(), &BaseLineEdit::textChanged, this, &FormEditInoreaderAccount::checkOAuthValue);
|
||||
connect(m_ui.m_txtRedirectUrl->lineEdit(), &BaseLineEdit::textChanged, this, &FormEditInoreaderAccount::checkOAuthValue);
|
||||
connect(m_ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &FormEditInoreaderAccount::checkUsername);
|
||||
connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditInoreaderAccount::testSetup);
|
||||
connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormEditInoreaderAccount::onClickedOk);
|
||||
@ -130,9 +139,15 @@ void FormEditInoreaderAccount::unhookNetwork() {
|
||||
InoreaderServiceRoot* FormEditInoreaderAccount::execForCreate() {
|
||||
setWindowTitle(tr("Add new Inoreader account"));
|
||||
m_network = new InoreaderNetworkFactory(this);
|
||||
|
||||
m_ui.m_txtAppId->lineEdit()->setText(INOREADER_OAUTH_CLI_ID);
|
||||
m_ui.m_txtAppKey->lineEdit()->setText(INOREADER_OAUTH_CLI_KEY);
|
||||
m_ui.m_txtRedirectUrl->lineEdit()->setText(INOREADER_OAUTH_CLI_REDIRECT);
|
||||
|
||||
hookNetwork();
|
||||
exec();
|
||||
unhookNetwork();
|
||||
|
||||
return m_editableRoot;
|
||||
}
|
||||
|
||||
@ -147,3 +162,16 @@ void FormEditInoreaderAccount::execForEdit(InoreaderServiceRoot* existing_root)
|
||||
exec();
|
||||
unhookNetwork();
|
||||
}
|
||||
|
||||
void FormEditInoreaderAccount::checkOAuthValue(const QString& value) {
|
||||
LineEditWithStatus* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());
|
||||
|
||||
if (line_edit != nullptr) {
|
||||
if (value.isEmpty()) {
|
||||
line_edit->setStatus(WidgetWithStatus::Error, tr("Empty value is entered."));
|
||||
}
|
||||
else {
|
||||
line_edit->setStatus(WidgetWithStatus::Ok, tr("Some value is entered."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class FormEditInoreaderAccount : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FormEditInoreaderAccount(QWidget* parent = 0);
|
||||
explicit FormEditInoreaderAccount(QWidget* parent = nullptr);
|
||||
virtual ~FormEditInoreaderAccount();
|
||||
|
||||
InoreaderServiceRoot* execForCreate();
|
||||
@ -46,6 +46,7 @@ class FormEditInoreaderAccount : public QDialog {
|
||||
void testSetup();
|
||||
void onClickedOk();
|
||||
void onClickedCancel();
|
||||
void checkOAuthValue(const QString& value);
|
||||
void checkUsername(const QString& username);
|
||||
void onAuthFailed();
|
||||
void onAuthError(const QString& error, const QString& detailed_description);
|
||||
|
@ -2,9 +2,19 @@
|
||||
<ui version="4.0">
|
||||
<class>FormEditInoreaderAccount</class>
|
||||
<widget class="QDialog" name="FormEditInoreaderAccount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>542</width>
|
||||
<height>363</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblUsername">
|
||||
@ -13,7 +23,59 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtUsername" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>OAuth 2.0 settings</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblUsername_2">
|
||||
<property name="text">
|
||||
<string>Application ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtAppId" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="m_lblUsername_3">
|
||||
<property name="text">
|
||||
<string>Application key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtAppKey" native="true"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="m_lblUsername_4">
|
||||
<property name="text">
|
||||
<string>Redirect URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtRedirectUrl" native="true"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="m_lblAuthInfo">
|
||||
<property name="text">
|
||||
<string>These settings DO NOT have to be changed from their default values. Change these values only of you are advanced user and you know what you are doing!</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
@ -38,19 +100,6 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="m_btnTestSetup">
|
||||
@ -74,7 +123,9 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -84,9 +135,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtUsername" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -40,7 +40,7 @@ QList<ServiceRoot*> InoreaderEntryPoint::initializeSubtree() const {
|
||||
}
|
||||
|
||||
bool InoreaderEntryPoint::isSingleInstanceService() const {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString InoreaderEntryPoint::name() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user