mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-11 07:33:49 +01:00
save work
This commit is contained in:
parent
aa4921229b
commit
2cf7797ce0
@ -19,6 +19,7 @@
|
||||
|
||||
#define ARGUMENTS_LIST_SEPARATOR "\n"
|
||||
|
||||
#define OAUTH_DECRYPTION_KEY 11451167756100761335ul
|
||||
#define ADBLOCK_HOWTO_FILTERS "https://help.eyeo.com/en/adblockplus/how-to-write-filters"
|
||||
#define ADBLOCK_UPDATE_DAYS_INTERVAL 14
|
||||
#define ADBLOCK_ICON_ACTIVE "adblock"
|
||||
|
@ -133,12 +133,12 @@ QDateTime TextFactory::parseDateTime(qint64 milis_from_epoch) {
|
||||
return QDateTime::fromMSecsSinceEpoch(milis_from_epoch, Qt::TimeSpec::UTC);
|
||||
}
|
||||
|
||||
QString TextFactory::encrypt(const QString& text) {
|
||||
return SimpleCrypt(initializeSecretEncryptionKey()).encryptToString(text);
|
||||
QString TextFactory::encrypt(const QString& text, quint64 key) {
|
||||
return SimpleCrypt(key == 0 ? initializeSecretEncryptionKey() : key).encryptToString(text);
|
||||
}
|
||||
|
||||
QString TextFactory::decrypt(const QString& text) {
|
||||
return SimpleCrypt(initializeSecretEncryptionKey()).decryptToString(text);
|
||||
QString TextFactory::decrypt(const QString& text, quint64 key) {
|
||||
return SimpleCrypt(key == 0 ? initializeSecretEncryptionKey() : key).decryptToString(text);
|
||||
}
|
||||
|
||||
QString TextFactory::newline() {
|
||||
|
@ -28,8 +28,8 @@ class TextFactory {
|
||||
// Converts 1970-epoch miliseconds to date/time.
|
||||
// NOTE: This method tries to always return time in UTC.
|
||||
static QDateTime parseDateTime(qint64 milis_from_epoch);
|
||||
static QString encrypt(const QString& text);
|
||||
static QString decrypt(const QString& text);
|
||||
static QString encrypt(const QString& text, quint64 key = 0);
|
||||
static QString decrypt(const QString& text, quint64 key = 0);
|
||||
static QString newline();
|
||||
|
||||
// Shortens input string according to given length limit.
|
||||
|
@ -11,14 +11,14 @@
|
||||
#include "services/feedly/definitions.h"
|
||||
#include "services/feedly/feedlynetwork.h"
|
||||
|
||||
#if defined (FEEDLY_OFFICIAL_SUPPORT)
|
||||
#if defined(FEEDLY_OFFICIAL_SUPPORT)
|
||||
#include "network-web/oauth2service.h"
|
||||
#endif
|
||||
|
||||
#include <QVariantHash>
|
||||
|
||||
FeedlyAccountDetails::FeedlyAccountDetails(QWidget* parent) : QWidget(parent) {
|
||||
#if defined (FEEDLY_OFFICIAL_SUPPORT)
|
||||
#if defined(FEEDLY_OFFICIAL_SUPPORT)
|
||||
m_oauth = new OAuth2Service(QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_AUTH,
|
||||
QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_TOKEN,
|
||||
FEEDLY_CLIENT_ID,
|
||||
@ -37,7 +37,7 @@ FeedlyAccountDetails::FeedlyAccountDetails(QWidget* parent) : QWidget(parent) {
|
||||
tr("No test done yet."),
|
||||
tr("Here, results of connection test are shown."));
|
||||
|
||||
#if defined (FEEDLY_OFFICIAL_SUPPORT)
|
||||
#if defined(FEEDLY_OFFICIAL_SUPPORT)
|
||||
m_ui.m_lblInfo->setText(tr("Your %1 build has official Feedly support. You do not have to use \"developer acess "
|
||||
"token\". You can therefore leave corresponding field empty.").arg(APP_NAME));
|
||||
#else
|
||||
|
@ -16,8 +16,15 @@ GmailAccountDetails::GmailAccountDetails(QWidget* parent)
|
||||
|
||||
GuiUtilities::setLabelAsNotice(*m_ui.m_lblInfo, true);
|
||||
|
||||
m_ui.m_lblInfo->setText(tr("Specified redirect URL must start with \"http://localhost\" and "
|
||||
"must be configured in your OAuth \"application\"."));
|
||||
#if defined(GMAIL_OFFICIAL_SUPPORT)
|
||||
m_ui.m_lblInfo->setText(tr("There are some preconfigured OAuth tokens so you do not have to fill in your "
|
||||
"client ID/secret, but it is strongly recommended to obtain your "
|
||||
"own as it preconfigured tokens have limited global usage quota. If you wash "
|
||||
"to use preconfigured tokens, simply leave those fields empty and make sure "
|
||||
"to leave default value of redirect URL."));
|
||||
#else
|
||||
m_ui.m_lblInfo->setText(tr("You have to fill in your client ID/secret and also fill in correct redirect URL."));
|
||||
#endif
|
||||
|
||||
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
|
||||
tr("Not tested yet."),
|
||||
@ -55,8 +62,21 @@ GmailAccountDetails::GmailAccountDetails(QWidget* parent)
|
||||
|
||||
void GmailAccountDetails::testSetup() {
|
||||
m_oauth->logout();
|
||||
|
||||
#if defined(GMAIL_OFFICIAL_SUPPORT)
|
||||
if (m_ui.m_txtAppId->lineEdit()->text().isEmpty() || m_ui.m_txtAppKey->lineEdit()->text().isEmpty()) {
|
||||
m_oauth->setClientId(TextFactory::decrypt(GMAIL_CLIENT_ID, OAUTH_DECRYPTION_KEY));
|
||||
m_oauth->setClientSecret(TextFactory::decrypt(GMAIL_CLIENT_ID, OAUTH_DECRYPTION_KEY));
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
m_oauth->setClientId(m_ui.m_txtAppId->lineEdit()->text());
|
||||
m_oauth->setClientSecret(m_ui.m_txtAppKey->lineEdit()->text());
|
||||
|
||||
#if defined(GMAIL_OFFICIAL_SUPPORT)
|
||||
}
|
||||
#endif
|
||||
|
||||
m_oauth->setRedirectUrl(m_ui.m_txtRedirectUrl->lineEdit()->text());
|
||||
|
||||
if (m_oauth->login()) {
|
||||
@ -85,7 +105,7 @@ void GmailAccountDetails::onAuthError(const QString& error, const QString& detai
|
||||
Q_UNUSED(error)
|
||||
|
||||
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||
tr("There is error. %1 ").arg(detailed_description),
|
||||
tr("There is error: %1").arg(detailed_description),
|
||||
tr("There was error during testing."));
|
||||
}
|
||||
|
||||
@ -110,7 +130,11 @@ void GmailAccountDetails::checkOAuthValue(const QString& value) {
|
||||
|
||||
if (line_edit != nullptr) {
|
||||
if (value.isEmpty()) {
|
||||
#if defined(GMAIL_OFFICIAL_SUPPORT)
|
||||
line_edit->setStatus(WidgetWithStatus::StatusType::Ok, tr("Preconfigured client ID/secret will be used."));
|
||||
#else
|
||||
line_edit->setStatus(WidgetWithStatus::StatusType::Error, tr("Empty value is entered."));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
line_edit->setStatus(WidgetWithStatus::StatusType::Ok, tr("Some value is entered."));
|
||||
|
Loading…
Reference in New Issue
Block a user