Different redirect URI ports for each service to avoid some problems, some simplifications of sync-in process.
This commit is contained in:
parent
c97a1dd2e7
commit
7fa57bd6ac
@ -23,7 +23,6 @@
|
||||
#define ADBLOCK_EASYLIST_URL "https://easylist.to/easylist/easylist.txt"
|
||||
|
||||
#define OAUTH_DECRYPTION_KEY 11451167756100761335ul
|
||||
#define OAUTH_REDIRECT_URI_PORT 14488
|
||||
#define OAUTH_REDIRECT_URI "http://localhost"
|
||||
|
||||
#define ENCLOSURES_OUTER_SEPARATOR '#'
|
||||
|
@ -2187,6 +2187,9 @@ bool DatabaseQueries::storeNewOauthTokens(const QSqlDatabase& db,
|
||||
query.bindValue(QSL(":id"), account_id);
|
||||
|
||||
if (!query.exec() || !query.next()) {
|
||||
qWarningNN << LOGSEC_OAUTH
|
||||
<< "Cannot fetch custom data column for storing of OAuth tokens, because of error:"
|
||||
<< QUOTE_W_SPACE_DOT(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2200,6 +2203,9 @@ bool DatabaseQueries::storeNewOauthTokens(const QSqlDatabase& db,
|
||||
query.bindValue(QSL(":id"), account_id);
|
||||
|
||||
if (!query.exec()) {
|
||||
qWarningNN << LOGSEC_OAUTH
|
||||
<< "Cannot store OAuth tokens, because of error:"
|
||||
<< QUOTE_W_SPACE_DOT(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
@ -21,6 +21,8 @@ ServiceRoot::ServiceRoot(RootItem* parent)
|
||||
m_labelsNode(new LabelsNode(this)), m_accountId(NO_PARENT_CATEGORY), m_networkProxy(QNetworkProxy()) {
|
||||
setKind(RootItem::Kind::ServiceRoot);
|
||||
setCreationDate(QDateTime::currentDateTime());
|
||||
|
||||
appendCommonNodes();
|
||||
}
|
||||
|
||||
ServiceRoot::~ServiceRoot() = default;
|
||||
@ -206,6 +208,22 @@ void ServiceRoot::cleanAllItemsFromModel() {
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceRoot::appendCommonNodes() {
|
||||
if (recycleBin() != nullptr && !childItems().contains(recycleBin())) {
|
||||
appendChild(recycleBin());
|
||||
}
|
||||
|
||||
if (importantNode() != nullptr && !childItems().contains(importantNode())) {
|
||||
appendChild(importantNode());
|
||||
}
|
||||
|
||||
if (labelsNode() != nullptr) {
|
||||
if (!childItems().contains(labelsNode())) {
|
||||
appendChild(labelsNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ServiceRoot::cleanFeeds(QList<Feed*> items, bool clean_read_only) {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
|
||||
@ -408,26 +426,15 @@ void ServiceRoot::syncIn() {
|
||||
|
||||
setIcon(original_icon);
|
||||
itemChanged(getSubTree());
|
||||
requestItemExpand({ this }, true);
|
||||
requestItemExpand(getSubTree(), true);
|
||||
}
|
||||
|
||||
void ServiceRoot::performInitialAssembly(const Assignment& categories,
|
||||
const Assignment& feeds,
|
||||
const QList<Label*>& labels) {
|
||||
// All data are now obtained, lets create the hierarchy.
|
||||
assembleCategories(categories);
|
||||
assembleFeeds(feeds);
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(recycleBin());
|
||||
appendChild(importantNode());
|
||||
|
||||
if (labelsNode() != nullptr) {
|
||||
appendChild(labelsNode());
|
||||
labelsNode()->loadLabels(labels);
|
||||
requestItemExpand({ labelsNode() }, true);
|
||||
}
|
||||
|
||||
labelsNode()->loadLabels(labels);
|
||||
updateCounts(true);
|
||||
}
|
||||
|
||||
|
@ -209,6 +209,7 @@ class ServiceRoot : public RootItem {
|
||||
void removeOldAccountFromDatabase(bool including_messages);
|
||||
void storeNewFeedTree(RootItem* root);
|
||||
void cleanAllItemsFromModel();
|
||||
void appendCommonNodes();
|
||||
|
||||
// Removes messages which do not belong to any
|
||||
// existing feed.
|
||||
|
@ -3,9 +3,10 @@
|
||||
#ifndef GMAIL_DEFINITIONS_H
|
||||
#define GMAIL_DEFINITIONS_H
|
||||
|
||||
#define GMAIL_OAUTH_AUTH_URL "https://accounts.google.com/o/oauth2/auth"
|
||||
#define GMAIL_OAUTH_TOKEN_URL "https://accounts.google.com/o/oauth2/token"
|
||||
#define GMAIL_OAUTH_SCOPE "https://mail.google.com/"
|
||||
#define GMAIL_OAUTH_REDIRECT_URI_PORT 14499
|
||||
#define GMAIL_OAUTH_AUTH_URL "https://accounts.google.com/o/oauth2/auth"
|
||||
#define GMAIL_OAUTH_TOKEN_URL "https://accounts.google.com/o/oauth2/token"
|
||||
#define GMAIL_OAUTH_SCOPE "https://mail.google.com/"
|
||||
|
||||
#define GMAIL_REG_API_URL "https://console.developers.google.com/apis/credentials"
|
||||
|
||||
|
@ -125,7 +125,7 @@ void GmailNetworkFactory::initializeOauth() {
|
||||
|
||||
m_oauth2->setRedirectUrl(QString(OAUTH_REDIRECT_URI) +
|
||||
QL1C(':') +
|
||||
QString::number(OAUTH_REDIRECT_URI_PORT));
|
||||
QString::number(GMAIL_OAUTH_REDIRECT_URI_PORT));
|
||||
|
||||
connect(m_oauth2, &OAuth2Service::tokensRetrieveError, this, &GmailNetworkFactory::onTokensError);
|
||||
connect(m_oauth2, &OAuth2Service::authFailed, this, &GmailNetworkFactory::onAuthFailed);
|
||||
|
@ -3,10 +3,11 @@
|
||||
#ifndef INOREADER_DEFINITIONS_H
|
||||
#define INOREADER_DEFINITIONS_H
|
||||
|
||||
#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_REG_API_URL "https://www.inoreader.com/developers/register-app"
|
||||
#define INOREADER_OAUTH_REDIRECT_URI_PORT 14488
|
||||
#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_REG_API_URL "https://www.inoreader.com/developers/register-app"
|
||||
|
||||
#define INOREADER_REFRESH_TOKEN_KEY "refresh_token"
|
||||
#define INOREADER_ACCESS_TOKEN_KEY "access_token"
|
||||
|
@ -60,7 +60,7 @@ void InoreaderNetworkFactory::initializeOauth() {
|
||||
|
||||
m_oauth2->setRedirectUrl(QString(OAUTH_REDIRECT_URI) +
|
||||
QL1C(':') +
|
||||
QString::number(OAUTH_REDIRECT_URI_PORT));
|
||||
QString::number(INOREADER_OAUTH_REDIRECT_URI_PORT));
|
||||
|
||||
connect(m_oauth2, &OAuth2Service::tokensRetrieveError, this, &InoreaderNetworkFactory::onTokensError);
|
||||
connect(m_oauth2, &OAuth2Service::authFailed, this, &InoreaderNetworkFactory::onAuthFailed);
|
||||
@ -68,7 +68,7 @@ void InoreaderNetworkFactory::initializeOauth() {
|
||||
Q_UNUSED(expires_in)
|
||||
Q_UNUSED(access_token)
|
||||
|
||||
if (m_service != nullptr && !refresh_token.isEmpty()) {
|
||||
if (m_service != nullptr && m_service->accountId() > 0 && !refresh_token.isEmpty()) {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
|
||||
DatabaseQueries::storeNewOauthTokens(database, refresh_token, m_service->accountId());
|
||||
|
Loading…
x
Reference in New Issue
Block a user