From c9674c8a47515d0f9f01ce9143b7cd31ba246801 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 28 Jun 2021 10:08:39 +0200 Subject: [PATCH] strings --- src/librssguard/core/feeddownloader.cpp | 4 ++-- src/librssguard/miscellaneous/application.cpp | 6 +++--- src/librssguard/miscellaneous/notification.cpp | 6 +++--- src/librssguard/miscellaneous/notification.h | 2 +- src/librssguard/services/abstract/feed.cpp | 11 ++++++++--- src/librssguard/services/abstract/feed.h | 4 +++- .../services/gmail/gmailserviceroot.cpp | 1 - .../services/greader/greaderserviceroot.cpp | 1 - .../services/inoreader/inoreaderserviceroot.cpp | 1 - .../services/standard/standardfeed.cpp | 17 ++--------------- .../services/standard/standardfeed.h | 4 ---- .../services/standard/standardserviceroot.cpp | 11 ++++++----- 12 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/librssguard/core/feeddownloader.cpp b/src/librssguard/core/feeddownloader.cpp index f66380491..9ab44cee7 100644 --- a/src/librssguard/core/feeddownloader.cpp +++ b/src/librssguard/core/feeddownloader.cpp @@ -314,7 +314,7 @@ void FeedDownloader::updateOneFeed(Feed* feed) { << "message:" << QUOTE_W_SPACE_DOT(feed_ex.message()); - feed->setStatus(feed_ex.feedStatus()); + feed->setStatus(feed_ex.feedStatus(), feed_ex.message()); feed->getParentServiceRoot()->itemChanged({ feed }); } @@ -324,7 +324,7 @@ void FeedDownloader::updateOneFeed(Feed* feed) { << "message:" << QUOTE_W_SPACE_DOT(app_ex.message()); - feed->setStatus(Feed::Status::OtherError); + feed->setStatus(Feed::Status::OtherError, app_ex.message()); feed->getParentServiceRoot()->itemChanged({ feed }); } diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp index b29f82eb8..f8d877560 100755 --- a/src/librssguard/miscellaneous/application.cpp +++ b/src/librssguard/miscellaneous/application.cpp @@ -97,7 +97,7 @@ Application::Application(const QString& id, int& argc, char** argv) m_notifications->save({ Notification(Notification::Event::GeneralEvent, true), - Notification(Notification::Event::NewArticlesFetched, + Notification(Notification::Event::NewUnreadArticlesFetched, true, QSL("%1/rooster.wav").arg(SOUNDS_BUILTIN_DIRECTORY)), Notification(Notification::Event::NewAppVersionAvailable, @@ -582,8 +582,8 @@ void Application::downloadRequested(QWebEngineDownloadItem* download_item) { void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) { if (!results.updatedFeeds().isEmpty()) { // Now, inform about results via GUI message/notification. - qApp->showGuiMessage(Notification::Event::NewArticlesFetched, - tr("New articles fetched"), + qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched, + tr("Unread articles fetched"), results.overview(10), QSystemTrayIcon::MessageIcon::NoIcon); } diff --git a/src/librssguard/miscellaneous/notification.cpp b/src/librssguard/miscellaneous/notification.cpp index 42175cd59..45ff55d8a 100755 --- a/src/librssguard/miscellaneous/notification.cpp +++ b/src/librssguard/miscellaneous/notification.cpp @@ -35,7 +35,7 @@ void Notification::playSound(Application* app) const { QList Notification::allEvents() { return { Event::GeneralEvent, - Event::NewArticlesFetched, + Event::NewUnreadArticlesFetched, Event::ArticlesFetchingStarted, Event::LoginDataRefreshed, Event::NewAppVersionAvailable, @@ -44,8 +44,8 @@ QList Notification::allEvents() { QString Notification::nameForEvent(Notification::Event event) { switch (event) { - case Notification::Event::NewArticlesFetched: - return QObject::tr("New articles fetched"); + case Notification::Event::NewUnreadArticlesFetched: + return QObject::tr("New (unread) articles fetched"); case Notification::Event::ArticlesFetchingStarted: return QObject::tr("Fetching articles right now"); diff --git a/src/librssguard/miscellaneous/notification.h b/src/librssguard/miscellaneous/notification.h index 45dbef121..139dd32d2 100755 --- a/src/librssguard/miscellaneous/notification.h +++ b/src/librssguard/miscellaneous/notification.h @@ -18,7 +18,7 @@ class Notification { GeneralEvent = 1, // New (unread) messages were downloaded for some feed. - NewArticlesFetched = 2, + NewUnreadArticlesFetched = 2, // RSS Guard started downloading messages for some feed. ArticlesFetchingStarted = 3, diff --git a/src/librssguard/services/abstract/feed.cpp b/src/librssguard/services/abstract/feed.cpp index 2b44bde26..fde3c0e48 100755 --- a/src/librssguard/services/abstract/feed.cpp +++ b/src/librssguard/services/abstract/feed.cpp @@ -20,7 +20,7 @@ #include Feed::Feed(RootItem* parent) - : RootItem(parent), m_source(QString()), m_status(Status::Normal), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate), + : RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate), m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_messageFilters(QList>()) { setKind(RootItem::Kind::Feed); @@ -38,7 +38,7 @@ Feed::Feed(const Feed& other) : RootItem(other) { setCountOfAllMessages(other.countOfAllMessages()); setCountOfUnreadMessages(other.countOfUnreadMessages()); setSource(other.source()); - setStatus(other.status()); + setStatus(other.status(), other.statusString()); setAutoUpdateType(other.autoUpdateType()); setAutoUpdateInitialInterval(other.autoUpdateInitialInterval()); setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval()); @@ -143,8 +143,9 @@ Feed::Status Feed::status() const { return m_status; } -void Feed::setStatus(const Feed::Status& status) { +void Feed::setStatus(const Feed::Status& status, const QString& status_text) { m_status = status; + m_statusString = status_text; } QString Feed::source() const { @@ -297,6 +298,10 @@ QString Feed::getStatusDescription() const { } } +QString Feed::statusString() const { + return m_statusString; +} + QList> Feed::messageFilters() const { return m_messageFilters; } diff --git a/src/librssguard/services/abstract/feed.h b/src/librssguard/services/abstract/feed.h index 2c2cd9607..fab1a6d76 100644 --- a/src/librssguard/services/abstract/feed.h +++ b/src/librssguard/services/abstract/feed.h @@ -67,7 +67,8 @@ class Feed : public RootItem { void setAutoUpdateRemainingInterval(int auto_update_remaining_interval); Status status() const; - void setStatus(const Status& status); + QString statusString() const; + void setStatus(const Status& status, const QString& status_text = {}); QString source() const; void setSource(const QString& source); @@ -90,6 +91,7 @@ class Feed : public RootItem { private: QString m_source; Status m_status; + QString m_statusString; AutoUpdateType m_autoUpdateType; int m_autoUpdateInitialInterval{}; int m_autoUpdateRemainingInterval{}; diff --git a/src/librssguard/services/gmail/gmailserviceroot.cpp b/src/librssguard/services/gmail/gmailserviceroot.cpp index b329c4d4d..a47fb7374 100644 --- a/src/librssguard/services/gmail/gmailserviceroot.cpp +++ b/src/librssguard/services/gmail/gmailserviceroot.cpp @@ -81,7 +81,6 @@ QList GmailServiceRoot::obtainNewMessages(const QList& feeds) { Feed::Status error = Feed::Status::Normal; messages << network()->messages(feed->customId(), error, networkProxy()); - feed->setStatus(error); if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError || error == Feed::Status::ParsingError) { throw FeedFetchException(error); diff --git a/src/librssguard/services/greader/greaderserviceroot.cpp b/src/librssguard/services/greader/greaderserviceroot.cpp index a6f6c0739..b8b91d72b 100755 --- a/src/librssguard/services/greader/greaderserviceroot.cpp +++ b/src/librssguard/services/greader/greaderserviceroot.cpp @@ -64,7 +64,6 @@ QList GreaderServiceRoot::obtainNewMessages(const QList& feeds) Feed::Status error = Feed::Status::Normal; messages << network()->streamContents(this, feed->customId(), error, networkProxy()); - feed->setStatus(error); if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError) { throw FeedFetchException(error); diff --git a/src/librssguard/services/inoreader/inoreaderserviceroot.cpp b/src/librssguard/services/inoreader/inoreaderserviceroot.cpp index 47e932fbb..49b43a1e6 100644 --- a/src/librssguard/services/inoreader/inoreaderserviceroot.cpp +++ b/src/librssguard/services/inoreader/inoreaderserviceroot.cpp @@ -63,7 +63,6 @@ QList InoreaderServiceRoot::obtainNewMessages(const QList& feeds Feed::Status error = Feed::Status::Normal; messages << network()->messages(this, feed->customId(), error); - feed->setStatus(error); if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError) { throw FeedFetchException(error); diff --git a/src/librssguard/services/standard/standardfeed.cpp b/src/librssguard/services/standard/standardfeed.cpp index 70f5f1b30..62964c23b 100644 --- a/src/librssguard/services/standard/standardfeed.cpp +++ b/src/librssguard/services/standard/standardfeed.cpp @@ -39,7 +39,6 @@ StandardFeed::StandardFeed(RootItem* parent_item) : Feed(parent_item) { - m_networkError = QNetworkReply::NetworkError::NoError; m_type = Type::Rss0X; m_sourceType = SourceType::Url; m_encoding = m_postProcessScript = QString(); @@ -51,7 +50,6 @@ StandardFeed::StandardFeed(RootItem* parent_item) StandardFeed::StandardFeed(const StandardFeed& other) : Feed(other) { - m_networkError = other.networkError(); m_type = other.type(); m_postProcessScript = other.postProcessScript(); m_sourceType = other.sourceType(); @@ -66,11 +64,8 @@ QList StandardFeed::contextMenuFeedsList() { } QString StandardFeed::additionalTooltip() const { - return Feed::additionalTooltip() + tr("\nNetwork status: %1\n" - "Encoding: %2\n" - "Type: %3").arg(NetworkFactory::networkErrorText(m_networkError), - encoding(), - StandardFeed::typeToString(type())); + return Feed::additionalTooltip() + tr("\nEncoding: %2\n" + "Type: %3").arg(encoding(), StandardFeed::typeToString(type())); } bool StandardFeed::canBeDeleted() const { @@ -578,10 +573,6 @@ QString StandardFeed::runScriptProcess(const QStringList& cmd_args, const QStrin } } -void StandardFeed::setNetworkError(const QNetworkReply::NetworkError& network_error) { - m_networkError = network_error; -} - QString StandardFeed::generateFeedFileWithScript(const QString& execution_line, int run_timeout) { auto prepared_query = prepareExecutionLine(execution_line); @@ -595,7 +586,3 @@ QString StandardFeed::postProcessFeedFileWithScript(const QString& execution_lin return runScriptProcess(prepared_query, qApp->userDataFolder(), run_timeout, true, raw_feed_data); } - -QNetworkReply::NetworkError StandardFeed::networkError() const { - return m_networkError; -} diff --git a/src/librssguard/services/standard/standardfeed.h b/src/librssguard/services/standard/standardfeed.h index a14601e13..e2d21158b 100644 --- a/src/librssguard/services/standard/standardfeed.h +++ b/src/librssguard/services/standard/standardfeed.h @@ -71,9 +71,6 @@ class StandardFeed : public Feed { QString password() const; void setPassword(const QString& password); - QNetworkReply::NetworkError networkError() const; - void setNetworkError(const QNetworkReply::NetworkError& network_error); - // Tries to guess feed hidden under given URL // and uses given credentials. // Returns pointer to guessed feed (if at least partially @@ -110,7 +107,6 @@ class StandardFeed : public Feed { SourceType m_sourceType; Type m_type; QString m_postProcessScript; - QNetworkReply::NetworkError m_networkError; QString m_encoding; bool m_passwordProtected{}; QString m_username; diff --git a/src/librssguard/services/standard/standardserviceroot.cpp b/src/librssguard/services/standard/standardserviceroot.cpp index de54e4f06..5f86292d0 100644 --- a/src/librssguard/services/standard/standardserviceroot.cpp +++ b/src/librssguard/services/standard/standardserviceroot.cpp @@ -162,7 +162,8 @@ QList StandardServiceRoot::obtainNewMessages(const QList& feeds) QList> headers; headers << NetworkFactory::generateBasicAuthHeader(feed->username(), feed->password()); - feed->setNetworkError(NetworkFactory::performNetworkOperation(feed->source(), + + auto network_result = NetworkFactory::performNetworkOperation(feed->source(), download_timeout, {}, feed_contents, @@ -171,15 +172,15 @@ QList StandardServiceRoot::obtainNewMessages(const QList& feeds) false, {}, {}, - networkProxy()).first); + networkProxy()).first; - if (feed->networkError() != QNetworkReply::NetworkError::NoError) { + if (network_result != QNetworkReply::NetworkError::NoError) { qWarningNN << LOGSEC_CORE << "Error" - << QUOTE_W_SPACE(feed->networkError()) + << QUOTE_W_SPACE(network_result) << "during fetching of new messages for feed" << QUOTE_W_SPACE_DOT(feed->source()); - throw FeedFetchException(Feed::Status::NetworkError); + throw FeedFetchException(Feed::Status::NetworkError, NetworkFactory::networkErrorText(network_result)); } // Encode downloaded data for further parsing.