diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml
index a7417a358..3de105cef 100644
--- a/resources/desktop/com.github.rssguard.appdata.xml
+++ b/resources/desktop/com.github.rssguard.appdata.xml
@@ -26,7 +26,7 @@
https://github.com/sponsors/martinrotter
-
+
none
diff --git a/src/librssguard/network-web/oauth2service.cpp b/src/librssguard/network-web/oauth2service.cpp
index 54ae163a3..b82c78ddb 100644
--- a/src/librssguard/network-web/oauth2service.cpp
+++ b/src/librssguard/network-web/oauth2service.cpp
@@ -42,12 +42,16 @@
#include
#include
-OAuth2Service::OAuth2Service(const QString& auth_url, const QString& token_url, const QString& client_id,
- const QString& client_secret, const QString& scope, QObject* parent)
- : QObject(parent),
- m_id(QString::number(QRandomGenerator::global()->generate())), m_timerId(-1),
- m_redirectionHandler(new OAuthHttpHandler(tr("You can close this window now. Go back to %1.").arg(QSL(APP_NAME)), this)),
- m_functorOnLogin(std::function()) {
+OAuth2Service::OAuth2Service(const QString& auth_url,
+ const QString& token_url,
+ const QString& client_id,
+ const QString& client_secret,
+ const QString& scope,
+ QObject* parent)
+ : QObject(parent), m_id(QString::number(QRandomGenerator::global()->generate())), m_timerId(-1),
+ m_redirectionHandler(new OAuthHttpHandler(tr("You can close this window now. Go back to %1.").arg(QSL(APP_NAME)),
+ this)),
+ m_functorOnLogin(std::function()) {
m_tokenGrantType = QSL("authorization_code");
m_tokenUrl = QUrl(token_url);
m_authUrl = auth_url;
@@ -65,14 +69,16 @@ OAuth2Service::OAuth2Service(const QString& auth_url, const QString& token_url,
retrieveAccessToken(auth_code);
}
});
- connect(m_redirectionHandler, &OAuthHttpHandler::authRejected, [this](const QString& error_description, const QString& id) {
- Q_UNUSED(error_description)
+ connect(m_redirectionHandler,
+ &OAuthHttpHandler::authRejected,
+ [this](const QString& error_description, const QString& id) {
+ Q_UNUSED(error_description)
- if (id.isEmpty() || id == m_id) {
- // We process this further only if handler (static singleton) responded to our original request.
- emit authFailed();
- }
- });
+ if (id.isEmpty() || id == m_id) {
+ // We process this further only if handler (static singleton) responded to our original request.
+ emit authFailed();
+ }
+ });
}
OAuth2Service::~OAuth2Service() {
@@ -81,15 +87,14 @@ OAuth2Service::~OAuth2Service() {
QString OAuth2Service::bearer() {
if (!isFullyLoggedIn()) {
- qApp->showGuiMessage(Notification::Event::LoginFailure, {
- tr("You have to login first"),
- tr("Click here to login."),
- QSystemTrayIcon::MessageIcon::Critical },
- {}, {
- tr("Login"),
- [this]() {
- login();
- } });
+ qApp->showGuiMessage(Notification::Event::LoginFailure,
+ {tr("You have to login first"),
+ tr("Click here to login."),
+ QSystemTrayIcon::MessageIcon::Critical},
+ {},
+ {tr("Login"), [this]() {
+ login();
+ }});
return {};
}
else {
@@ -179,11 +184,12 @@ void OAuth2Service::retrieveAccessToken(const QString& auth_code) {
"client_secret=%2&"
"code=%3&"
"redirect_uri=%5&"
- "grant_type=%4").arg(properClientId(),
- properClientSecret(),
- auth_code,
- m_tokenGrantType,
- m_redirectionHandler->listenAddressPort());
+ "grant_type=%4")
+ .arg(properClientId(),
+ properClientSecret(),
+ auth_code,
+ m_tokenGrantType,
+ m_redirectionHandler->listenAddressPort());
qDebugNN << LOGSEC_OAUTH << "Posting data for access token retrieval:" << QUOTE_W_SPACE_DOT(content);
m_networkManager.post(network_request, content.toUtf8());
@@ -205,16 +211,14 @@ void OAuth2Service::refreshAccessToken(const QString& refresh_token) {
QString content = QString("client_id=%1&"
"client_secret=%2&"
"refresh_token=%3&"
- "grant_type=%4").arg(properClientId(),
- properClientSecret(),
- real_refresh_token,
- QSL("refresh_token"));
+ "grant_type=%4")
+ .arg(properClientId(), properClientSecret(), real_refresh_token, QSL("refresh_token"));
- qApp->showGuiMessage(Notification::Event::LoginDataRefreshed, {
- tr("Logging in via OAuth 2.0..."),
- tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()),
- QSystemTrayIcon::MessageIcon::Information },
- { true, false, true });
+ qApp->showGuiMessage(Notification::Event::LoginDataRefreshed,
+ {tr("Logging in via OAuth 2.0..."),
+ tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()),
+ QSystemTrayIcon::MessageIcon::Information},
+ {true, false, true});
qDebugNN << LOGSEC_OAUTH << "Posting data for access token refreshing:" << QUOTE_W_SPACE_DOT(content);
m_networkManager.post(network_request, content.toUtf8());
@@ -229,8 +233,7 @@ void OAuth2Service::tokenRequestFinished(QNetworkReply* network_reply) {
if (network_reply->error() != QNetworkReply::NetworkError::NoError) {
qWarningNN << LOGSEC_OAUTH
- << "Network error when obtaining token response:"
- << QUOTE_W_SPACE_DOT(network_reply->error());
+ << "Network error when obtaining token response:" << QUOTE_W_SPACE_DOT(network_reply->error());
emit tokensRetrieveError(QString(), NetworkFactory::networkErrorText(network_reply->error()));
}
@@ -238,9 +241,7 @@ void OAuth2Service::tokenRequestFinished(QNetworkReply* network_reply) {
QString error = root_obj.value(QSL("error")).toString();
QString error_description = root_obj.value(QSL("error_description")).toString();
- qWarningNN << LOGSEC_OAUTH
- << "JSON error when obtaining token response:"
- << QUOTE_W_SPACE(error)
+ qWarningNN << LOGSEC_OAUTH << "JSON error when obtaining token response:" << QUOTE_W_SPACE(error)
<< QUOTE_W_SPACE_DOT(error_description);
logout();
@@ -259,11 +260,12 @@ void OAuth2Service::tokenRequestFinished(QNetworkReply* network_reply) {
setRefreshToken(refresh_token);
}
- qDebugNN << LOGSEC_OAUTH
- << "Obtained refresh token" << QUOTE_W_SPACE(refreshToken())
- << "- expires on date/time" << QUOTE_W_SPACE_DOT(tokensExpireIn());
+ qDebugNN << LOGSEC_OAUTH << "Obtained refresh token" << QUOTE_W_SPACE(refreshToken()) << "- expires on date/time"
+ << QUOTE_W_SPACE_DOT(tokensExpireIn());
if (m_functorOnLogin != nullptr) {
+ qDebugNN << LOGSEC_OAUTH << "Running custom after-login code.";
+
m_functorOnLogin();
}
@@ -274,15 +276,11 @@ void OAuth2Service::tokenRequestFinished(QNetworkReply* network_reply) {
}
QString OAuth2Service::properClientId() const {
- return m_clientId.simplified().isEmpty()
- ? m_clientSecretId
- : m_clientId;
+ return m_clientId.simplified().isEmpty() ? m_clientSecretId : m_clientId;
}
QString OAuth2Service::properClientSecret() const {
- return m_clientSecret.simplified().isEmpty()
- ? m_clientSecretSecret
- : m_clientSecret;
+ return m_clientSecret.simplified().isEmpty() ? m_clientSecretSecret : m_clientSecret;
}
QString OAuth2Service::accessToken() const {
@@ -339,12 +337,12 @@ bool OAuth2Service::login(const std::function& functor_when_logged_in) {
m_functorOnLogin = functor_when_logged_in;
if (!m_redirectionHandler->isListening()) {
- qCriticalNN << LOGSEC_OAUTH
- << "Cannot log-in because OAuth redirection handler is not listening.";
+ qCriticalNN << LOGSEC_OAUTH << "Cannot log-in because OAuth redirection handler is not listening.";
- emit tokensRetrieveError(QString(), tr("Failed to start OAuth "
- "redirection listener. Maybe your "
- "rights are not high enough."));
+ emit tokensRetrieveError(QString(),
+ tr("Failed to start OAuth "
+ "redirection listener. Maybe your "
+ "rights are not high enough."));
return false;
}
@@ -402,10 +400,8 @@ void OAuth2Service::retrieveAuthCode() {
"state=%4&"
"prompt=consent&"
"duration=permanent&"
- "access_type=offline").arg(properClientId(),
- m_scope,
- m_redirectionHandler->listenAddressPort(),
- m_id);
+ "access_type=offline")
+ .arg(properClientId(), m_scope, m_redirectionHandler->listenAddressPort(), m_id);
// We run login URL in external browser, response is caught by light HTTP server.
qApp->web()->openUrlInExternalBrowser(auth_url);
diff --git a/src/librssguard/services/abstract/serviceroot.cpp b/src/librssguard/services/abstract/serviceroot.cpp
index acf678398..9f5946cee 100644
--- a/src/librssguard/services/abstract/serviceroot.cpp
+++ b/src/librssguard/services/abstract/serviceroot.cpp
@@ -23,8 +23,8 @@
ServiceRoot::ServiceRoot(RootItem* parent)
: RootItem(parent), m_recycleBin(new RecycleBin(this)), m_importantNode(new ImportantNode(this)),
- m_labelsNode(new LabelsNode(this)), m_unreadNode(new UnreadNode(this)),
- m_accountId(NO_PARENT_CATEGORY), m_networkProxy(QNetworkProxy()) {
+ m_labelsNode(new LabelsNode(this)), m_unreadNode(new UnreadNode(this)), m_accountId(NO_PARENT_CATEGORY),
+ m_networkProxy(QNetworkProxy()) {
setKind(RootItem::Kind::ServiceRoot);
appendCommonNodes();
}
@@ -95,7 +95,8 @@ QList ServiceRoot::contextMenuMessagesList(const QList& messa
QList ServiceRoot::serviceMenu() {
if (m_serviceMenu.isEmpty()) {
if (isSyncable()) {
- auto* act_sync_tree = new QAction(qApp->icons()->fromTheme(QSL("view-refresh")), tr("Synchronize folders && other items"), this);
+ auto* act_sync_tree =
+ new QAction(qApp->icons()->fromTheme(QSL("view-refresh")), tr("Synchronize folders && other items"), this);
connect(act_sync_tree, &QAction::triggered, this, &ServiceRoot::syncIn);
m_serviceMenu.append(act_sync_tree);
@@ -103,7 +104,8 @@ QList ServiceRoot::serviceMenu() {
auto* cache = toCache();
if (cache != nullptr) {
- auto* act_sync_cache = new QAction(qApp->icons()->fromTheme(QSL("view-refresh")), tr("Synchronize article cache"), this);
+ auto* act_sync_cache =
+ new QAction(qApp->icons()->fromTheme(QSL("view-refresh")), tr("Synchronize article cache"), this);
connect(act_sync_cache, &QAction::triggered, this, [cache]() {
cache->saveAllCachedData(false);
@@ -139,8 +141,7 @@ void ServiceRoot::updateCounts(bool including_total_count) {
if (child->kind() == RootItem::Kind::Feed) {
feeds.append(child->toFeed());
}
- else if (child->kind() != RootItem::Kind::Labels &&
- child->kind() != RootItem::Kind::Category &&
+ else if (child->kind() != RootItem::Kind::Labels && child->kind() != RootItem::Kind::Category &&
child->kind() != RootItem::Kind::ServiceRoot) {
child->updateCounts(including_total_count);
}
@@ -152,7 +153,8 @@ void ServiceRoot::updateCounts(bool including_total_count) {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
bool ok;
- QMap> counts = DatabaseQueries::getMessageCountsForAccount(database, accountId(), including_total_count, &ok);
+ QMap> counts =
+ DatabaseQueries::getMessageCountsForAccount(database, accountId(), including_total_count, &ok);
if (ok) {
for (Feed* feed : feeds) {
@@ -183,7 +185,7 @@ void ServiceRoot::completelyRemoveAllData() {
cleanAllItemsFromModel(true);
removeOldAccountFromDatabase(true, true);
updateCounts(true);
- itemChanged({ this });
+ itemChanged({this});
requestReloadMessageList(true);
}
@@ -204,20 +206,15 @@ QIcon ServiceRoot::feedIconForMessage(const QString& feed_custom_id) const {
void ServiceRoot::removeOldAccountFromDatabase(bool delete_messages_too, bool delete_labels_too) {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
- DatabaseQueries::deleteAccountData(database,
- accountId(),
- delete_messages_too,
- delete_labels_too);
+ DatabaseQueries::deleteAccountData(database, accountId(), delete_messages_too, delete_labels_too);
}
void ServiceRoot::cleanAllItemsFromModel(bool clean_labels_too) {
auto chi = childItems();
for (RootItem* top_level_item : qAsConst(chi)) {
- if (top_level_item->kind() != RootItem::Kind::Bin &&
- top_level_item->kind() != RootItem::Kind::Important &&
- top_level_item->kind() != RootItem::Kind::Unread &&
- top_level_item->kind() != RootItem::Kind::Labels) {
+ if (top_level_item->kind() != RootItem::Kind::Bin && top_level_item->kind() != RootItem::Kind::Important &&
+ top_level_item->kind() != RootItem::Kind::Unread && top_level_item->kind() != RootItem::Kind::Labels) {
requestItemRemoval(top_level_item);
}
}
@@ -265,7 +262,9 @@ bool ServiceRoot::cleanFeeds(const QList& items, bool clean_read_only) {
void ServiceRoot::storeNewFeedTree(RootItem* root) {
try {
- DatabaseQueries::storeAccountTree(qApp->database()->driver()->connection(metaObject()->className()), root, accountId());
+ DatabaseQueries::storeAccountTree(qApp->database()->driver()->connection(metaObject()->className()),
+ root,
+ accountId());
}
catch (const ApplicationException& ex) {
qFatal("Cannot store account tree: '%s'.", qPrintable(ex.message()));
@@ -405,7 +404,8 @@ void ServiceRoot::restoreCustomFeedsData(const QMap& data,
QVariantMap feed_custom_data = i.value();
feed->setAutoUpdateInitialInterval(feed_custom_data.value(QSL("auto_update_interval")).toInt());
- feed->setAutoUpdateType(static_cast(feed_custom_data.value(QSL("auto_update_type")).toInt()));
+ feed
+ ->setAutoUpdateType(static_cast(feed_custom_data.value(QSL("auto_update_type")).toInt()));
feed->setMessageFilters(feed_custom_data.value(QSL("msg_filters")).value>>());
feed->setIsSwitchedOff(feed_custom_data.value(QSL("is_off")).toBool());
@@ -440,14 +440,20 @@ void ServiceRoot::syncIn() {
QIcon original_icon = icon();
setIcon(qApp->icons()->fromTheme(QSL("view-refresh")));
- itemChanged({ this });
+ itemChanged({this});
+
+ qDebugNN << LOGSEC_CORE << "Starting sync-in process.";
+
RootItem* new_tree = obtainNewTreeForSyncIn();
if (new_tree != nullptr) {
+ qDebugNN << LOGSEC_CORE << "New feed tree for sync-in obtained.";
+
auto feed_custom_data = storeCustomFeedsData();
// Remove from feeds model, then from SQL but leave messages intact.
- bool uses_remote_labels = (supportedLabelOperations() & LabelOperation::Synchronised) == LabelOperation::Synchronised;
+ bool uses_remote_labels =
+ (supportedLabelOperations() & LabelOperation::Synchronised) == LabelOperation::Synchronised;
// Remove stuff.
cleanAllItemsFromModel(uses_remote_labels);
@@ -492,6 +498,9 @@ void ServiceRoot::syncIn() {
updateCounts(true);
requestReloadMessageList(true);
}
+ else {
+ qCriticalNN << LOGSEC_CORE << "New feed tree for sync-in NOT obtained.";
+ }
setIcon(original_icon);
itemChanged(getSubTree());
@@ -609,7 +618,8 @@ QStringList ServiceRoot::textualFeedUrls(const QList& feeds) const {
}
QStringList ServiceRoot::textualFeedIds(const QList& feeds) const {
- QStringList stringy_ids; stringy_ids.reserve(feeds.size());
+ QStringList stringy_ids;
+ stringy_ids.reserve(feeds.size());
for (const Feed* feed : feeds) {
stringy_ids.append(QSL("'%1'").arg(feed->customId()));
@@ -619,7 +629,8 @@ QStringList ServiceRoot::textualFeedIds(const QList& feeds) const {
}
QStringList ServiceRoot::customIDsOfMessages(const QList& changes) {
- QStringList list; list.reserve(changes.size());
+ QStringList list;
+ list.reserve(changes.size());
for (const auto& change : changes) {
list.append(change.first.m_customId);
@@ -629,7 +640,8 @@ QStringList ServiceRoot::customIDsOfMessages(const QList& chan
}
QStringList ServiceRoot::customIDsOfMessages(const QList& messages) {
- QStringList list; list.reserve(messages.size());
+ QStringList list;
+ list.reserve(messages.size());
for (const Message& message : messages) {
list.append(message.m_customId);
@@ -655,32 +667,35 @@ void ServiceRoot::setAccountId(int account_id) {
bool ServiceRoot::loadMessagesForItem(RootItem* item, MessagesModel* model) {
if (item->kind() == RootItem::Kind::Bin) {
model->setFilter(QSL("Messages.is_deleted = 1 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
- .arg(QString::number(accountId())));
+ .arg(QString::number(accountId())));
}
else if (item->kind() == RootItem::Kind::Important) {
- model->setFilter(QSL("Messages.is_important = 1 AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
- .arg(QString::number(accountId())));
+ model->setFilter(QSL("Messages.is_important = 1 AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND "
+ "Messages.account_id = %1")
+ .arg(QString::number(accountId())));
}
else if (item->kind() == RootItem::Kind::Unread) {
- model->setFilter(QSL("Messages.is_read = 0 AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
- .arg(QString::number(accountId())));
+ model->setFilter(QSL("Messages.is_read = 0 AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND "
+ "Messages.account_id = %1")
+ .arg(QString::number(accountId())));
}
else if (item->kind() == RootItem::Kind::Label) {
// Show messages with particular label.
model->setFilter(QSL("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1 AND "
- "(SELECT COUNT(*) FROM LabelsInMessages WHERE account_id = %1 AND message = Messages.custom_id AND label = '%2') > 0")
- .arg(QString::number(accountId()), item->customId()));
+ "(SELECT COUNT(*) FROM LabelsInMessages WHERE account_id = %1 AND message = "
+ "Messages.custom_id AND label = '%2') > 0")
+ .arg(QString::number(accountId()), item->customId()));
}
else if (item->kind() == RootItem::Kind::Labels) {
// Show messages with any label.
model->setFilter(QSL("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1 AND "
- "(SELECT COUNT(*) FROM LabelsInMessages WHERE account_id = %1 AND message = Messages.custom_id) > 0")
- .arg(QString::number(accountId())));
+ "(SELECT COUNT(*) FROM LabelsInMessages WHERE account_id = %1 AND message = "
+ "Messages.custom_id) > 0")
+ .arg(QString::number(accountId())));
}
else if (item->kind() == RootItem::Kind::ServiceRoot) {
- model->setFilter(
- QSL("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1").arg(
- QString::number(accountId())));
+ model->setFilter(QSL("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
+ .arg(QString::number(accountId())));
qDebugNN << "Displaying messages from account:" << QUOTE_W_SPACE_DOT(accountId());
}
@@ -692,11 +707,9 @@ bool ServiceRoot::loadMessagesForItem(RootItem* item, MessagesModel* model) {
filter_clause = QSL("null");
}
- model->setFilter(
- QSL("Feeds.custom_id IN (%1) AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %2").arg(
- filter_clause,
- QString::
- number(accountId())));
+ model->setFilter(QSL("Feeds.custom_id IN (%1) AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND "
+ "Messages.account_id = %2")
+ .arg(filter_clause, QString::number(accountId())));
QString urls = textualFeedUrls(children).join(QSL(", "));
@@ -707,7 +720,9 @@ bool ServiceRoot::loadMessagesForItem(RootItem* item, MessagesModel* model) {
return true;
}
-bool ServiceRoot::onBeforeSetMessagesRead(RootItem* selected_item, const QList& messages, RootItem::ReadStatus read) {
+bool ServiceRoot::onBeforeSetMessagesRead(RootItem* selected_item,
+ const QList& messages,
+ RootItem::ReadStatus read) {
Q_UNUSED(selected_item)
auto cache = dynamic_cast(this);
@@ -719,7 +734,9 @@ bool ServiceRoot::onBeforeSetMessagesRead(RootItem* selected_item, const QList& messages, RootItem::ReadStatus read) {
+bool ServiceRoot::onAfterSetMessagesRead(RootItem* selected_item,
+ const QList& messages,
+ RootItem::ReadStatus read) {
Q_UNUSED(selected_item)
Q_UNUSED(messages)
Q_UNUSED(read)
@@ -808,9 +825,11 @@ bool ServiceRoot::onAfterLabelMessageAssignmentChanged(const QList