save work
This commit is contained in:
parent
aa4921229b
commit
2cf7797ce0
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#define ARGUMENTS_LIST_SEPARATOR "\n"
|
#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_HOWTO_FILTERS "https://help.eyeo.com/en/adblockplus/how-to-write-filters"
|
||||||
#define ADBLOCK_UPDATE_DAYS_INTERVAL 14
|
#define ADBLOCK_UPDATE_DAYS_INTERVAL 14
|
||||||
#define ADBLOCK_ICON_ACTIVE "adblock"
|
#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);
|
return QDateTime::fromMSecsSinceEpoch(milis_from_epoch, Qt::TimeSpec::UTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextFactory::encrypt(const QString& text) {
|
QString TextFactory::encrypt(const QString& text, quint64 key) {
|
||||||
return SimpleCrypt(initializeSecretEncryptionKey()).encryptToString(text);
|
return SimpleCrypt(key == 0 ? initializeSecretEncryptionKey() : key).encryptToString(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextFactory::decrypt(const QString& text) {
|
QString TextFactory::decrypt(const QString& text, quint64 key) {
|
||||||
return SimpleCrypt(initializeSecretEncryptionKey()).decryptToString(text);
|
return SimpleCrypt(key == 0 ? initializeSecretEncryptionKey() : key).decryptToString(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextFactory::newline() {
|
QString TextFactory::newline() {
|
||||||
|
@ -28,8 +28,8 @@ class TextFactory {
|
|||||||
// Converts 1970-epoch miliseconds to date/time.
|
// Converts 1970-epoch miliseconds to date/time.
|
||||||
// NOTE: This method tries to always return time in UTC.
|
// NOTE: This method tries to always return time in UTC.
|
||||||
static QDateTime parseDateTime(qint64 milis_from_epoch);
|
static QDateTime parseDateTime(qint64 milis_from_epoch);
|
||||||
static QString encrypt(const QString& text);
|
static QString encrypt(const QString& text, quint64 key = 0);
|
||||||
static QString decrypt(const QString& text);
|
static QString decrypt(const QString& text, quint64 key = 0);
|
||||||
static QString newline();
|
static QString newline();
|
||||||
|
|
||||||
// Shortens input string according to given length limit.
|
// Shortens input string according to given length limit.
|
||||||
|
@ -16,8 +16,15 @@ GmailAccountDetails::GmailAccountDetails(QWidget* parent)
|
|||||||
|
|
||||||
GuiUtilities::setLabelAsNotice(*m_ui.m_lblInfo, true);
|
GuiUtilities::setLabelAsNotice(*m_ui.m_lblInfo, true);
|
||||||
|
|
||||||
m_ui.m_lblInfo->setText(tr("Specified redirect URL must start with \"http://localhost\" and "
|
#if defined(GMAIL_OFFICIAL_SUPPORT)
|
||||||
"must be configured in your OAuth \"application\"."));
|
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,
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
|
||||||
tr("Not tested yet."),
|
tr("Not tested yet."),
|
||||||
@ -55,8 +62,21 @@ GmailAccountDetails::GmailAccountDetails(QWidget* parent)
|
|||||||
|
|
||||||
void GmailAccountDetails::testSetup() {
|
void GmailAccountDetails::testSetup() {
|
||||||
m_oauth->logout();
|
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->setClientId(m_ui.m_txtAppId->lineEdit()->text());
|
||||||
m_oauth->setClientSecret(m_ui.m_txtAppKey->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());
|
m_oauth->setRedirectUrl(m_ui.m_txtRedirectUrl->lineEdit()->text());
|
||||||
|
|
||||||
if (m_oauth->login()) {
|
if (m_oauth->login()) {
|
||||||
@ -85,7 +105,7 @@ void GmailAccountDetails::onAuthError(const QString& error, const QString& detai
|
|||||||
Q_UNUSED(error)
|
Q_UNUSED(error)
|
||||||
|
|
||||||
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::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."));
|
tr("There was error during testing."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +130,11 @@ void GmailAccountDetails::checkOAuthValue(const QString& value) {
|
|||||||
|
|
||||||
if (line_edit != nullptr) {
|
if (line_edit != nullptr) {
|
||||||
if (value.isEmpty()) {
|
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."));
|
line_edit->setStatus(WidgetWithStatus::StatusType::Error, tr("Empty value is entered."));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
line_edit->setStatus(WidgetWithStatus::StatusType::Ok, tr("Some value is entered."));
|
line_edit->setStatus(WidgetWithStatus::StatusType::Ok, tr("Some value is entered."));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user