This commit is contained in:
Martin Rotter 2021-06-28 10:08:39 +02:00
parent 04a493b7ba
commit c9674c8a47
12 changed files with 28 additions and 40 deletions

View File

@ -314,7 +314,7 @@ void FeedDownloader::updateOneFeed(Feed* feed) {
<< "message:" << "message:"
<< QUOTE_W_SPACE_DOT(feed_ex.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 }); feed->getParentServiceRoot()->itemChanged({ feed });
} }
@ -324,7 +324,7 @@ void FeedDownloader::updateOneFeed(Feed* feed) {
<< "message:" << "message:"
<< QUOTE_W_SPACE_DOT(app_ex.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 }); feed->getParentServiceRoot()->itemChanged({ feed });
} }

View File

@ -97,7 +97,7 @@ Application::Application(const QString& id, int& argc, char** argv)
m_notifications->save({ m_notifications->save({
Notification(Notification::Event::GeneralEvent, Notification(Notification::Event::GeneralEvent,
true), true),
Notification(Notification::Event::NewArticlesFetched, Notification(Notification::Event::NewUnreadArticlesFetched,
true, true,
QSL("%1/rooster.wav").arg(SOUNDS_BUILTIN_DIRECTORY)), QSL("%1/rooster.wav").arg(SOUNDS_BUILTIN_DIRECTORY)),
Notification(Notification::Event::NewAppVersionAvailable, Notification(Notification::Event::NewAppVersionAvailable,
@ -582,8 +582,8 @@ void Application::downloadRequested(QWebEngineDownloadItem* download_item) {
void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) { void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) {
if (!results.updatedFeeds().isEmpty()) { if (!results.updatedFeeds().isEmpty()) {
// Now, inform about results via GUI message/notification. // Now, inform about results via GUI message/notification.
qApp->showGuiMessage(Notification::Event::NewArticlesFetched, qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched,
tr("New articles fetched"), tr("Unread articles fetched"),
results.overview(10), results.overview(10),
QSystemTrayIcon::MessageIcon::NoIcon); QSystemTrayIcon::MessageIcon::NoIcon);
} }

View File

@ -35,7 +35,7 @@ void Notification::playSound(Application* app) const {
QList<Notification::Event> Notification::allEvents() { QList<Notification::Event> Notification::allEvents() {
return { return {
Event::GeneralEvent, Event::GeneralEvent,
Event::NewArticlesFetched, Event::NewUnreadArticlesFetched,
Event::ArticlesFetchingStarted, Event::ArticlesFetchingStarted,
Event::LoginDataRefreshed, Event::LoginDataRefreshed,
Event::NewAppVersionAvailable, Event::NewAppVersionAvailable,
@ -44,8 +44,8 @@ QList<Notification::Event> Notification::allEvents() {
QString Notification::nameForEvent(Notification::Event event) { QString Notification::nameForEvent(Notification::Event event) {
switch (event) { switch (event) {
case Notification::Event::NewArticlesFetched: case Notification::Event::NewUnreadArticlesFetched:
return QObject::tr("New articles fetched"); return QObject::tr("New (unread) articles fetched");
case Notification::Event::ArticlesFetchingStarted: case Notification::Event::ArticlesFetchingStarted:
return QObject::tr("Fetching articles right now"); return QObject::tr("Fetching articles right now");

View File

@ -18,7 +18,7 @@ class Notification {
GeneralEvent = 1, GeneralEvent = 1,
// New (unread) messages were downloaded for some feed. // New (unread) messages were downloaded for some feed.
NewArticlesFetched = 2, NewUnreadArticlesFetched = 2,
// RSS Guard started downloading messages for some feed. // RSS Guard started downloading messages for some feed.
ArticlesFetchingStarted = 3, ArticlesFetchingStarted = 3,

View File

@ -20,7 +20,7 @@
#include <QThread> #include <QThread>
Feed::Feed(RootItem* parent) 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_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
m_messageFilters(QList<QPointer<MessageFilter>>()) { m_messageFilters(QList<QPointer<MessageFilter>>()) {
setKind(RootItem::Kind::Feed); setKind(RootItem::Kind::Feed);
@ -38,7 +38,7 @@ Feed::Feed(const Feed& other) : RootItem(other) {
setCountOfAllMessages(other.countOfAllMessages()); setCountOfAllMessages(other.countOfAllMessages());
setCountOfUnreadMessages(other.countOfUnreadMessages()); setCountOfUnreadMessages(other.countOfUnreadMessages());
setSource(other.source()); setSource(other.source());
setStatus(other.status()); setStatus(other.status(), other.statusString());
setAutoUpdateType(other.autoUpdateType()); setAutoUpdateType(other.autoUpdateType());
setAutoUpdateInitialInterval(other.autoUpdateInitialInterval()); setAutoUpdateInitialInterval(other.autoUpdateInitialInterval());
setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval()); setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval());
@ -143,8 +143,9 @@ Feed::Status Feed::status() const {
return m_status; 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_status = status;
m_statusString = status_text;
} }
QString Feed::source() const { QString Feed::source() const {
@ -297,6 +298,10 @@ QString Feed::getStatusDescription() const {
} }
} }
QString Feed::statusString() const {
return m_statusString;
}
QList<QPointer<MessageFilter>> Feed::messageFilters() const { QList<QPointer<MessageFilter>> Feed::messageFilters() const {
return m_messageFilters; return m_messageFilters;
} }

View File

@ -67,7 +67,8 @@ class Feed : public RootItem {
void setAutoUpdateRemainingInterval(int auto_update_remaining_interval); void setAutoUpdateRemainingInterval(int auto_update_remaining_interval);
Status status() const; Status status() const;
void setStatus(const Status& status); QString statusString() const;
void setStatus(const Status& status, const QString& status_text = {});
QString source() const; QString source() const;
void setSource(const QString& source); void setSource(const QString& source);
@ -90,6 +91,7 @@ class Feed : public RootItem {
private: private:
QString m_source; QString m_source;
Status m_status; Status m_status;
QString m_statusString;
AutoUpdateType m_autoUpdateType; AutoUpdateType m_autoUpdateType;
int m_autoUpdateInitialInterval{}; int m_autoUpdateInitialInterval{};
int m_autoUpdateRemainingInterval{}; int m_autoUpdateRemainingInterval{};

View File

@ -81,7 +81,6 @@ QList<Message> GmailServiceRoot::obtainNewMessages(const QList<Feed*>& feeds) {
Feed::Status error = Feed::Status::Normal; Feed::Status error = Feed::Status::Normal;
messages << network()->messages(feed->customId(), error, networkProxy()); messages << network()->messages(feed->customId(), error, networkProxy());
feed->setStatus(error);
if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError || error == Feed::Status::ParsingError) { if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError || error == Feed::Status::ParsingError) {
throw FeedFetchException(error); throw FeedFetchException(error);

View File

@ -64,7 +64,6 @@ QList<Message> GreaderServiceRoot::obtainNewMessages(const QList<Feed*>& feeds)
Feed::Status error = Feed::Status::Normal; Feed::Status error = Feed::Status::Normal;
messages << network()->streamContents(this, feed->customId(), error, networkProxy()); messages << network()->streamContents(this, feed->customId(), error, networkProxy());
feed->setStatus(error);
if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError) { if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError) {
throw FeedFetchException(error); throw FeedFetchException(error);

View File

@ -63,7 +63,6 @@ QList<Message> InoreaderServiceRoot::obtainNewMessages(const QList<Feed*>& feeds
Feed::Status error = Feed::Status::Normal; Feed::Status error = Feed::Status::Normal;
messages << network()->messages(this, feed->customId(), error); messages << network()->messages(this, feed->customId(), error);
feed->setStatus(error);
if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError) { if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError) {
throw FeedFetchException(error); throw FeedFetchException(error);

View File

@ -39,7 +39,6 @@
StandardFeed::StandardFeed(RootItem* parent_item) StandardFeed::StandardFeed(RootItem* parent_item)
: Feed(parent_item) { : Feed(parent_item) {
m_networkError = QNetworkReply::NetworkError::NoError;
m_type = Type::Rss0X; m_type = Type::Rss0X;
m_sourceType = SourceType::Url; m_sourceType = SourceType::Url;
m_encoding = m_postProcessScript = QString(); m_encoding = m_postProcessScript = QString();
@ -51,7 +50,6 @@ StandardFeed::StandardFeed(RootItem* parent_item)
StandardFeed::StandardFeed(const StandardFeed& other) StandardFeed::StandardFeed(const StandardFeed& other)
: Feed(other) { : Feed(other) {
m_networkError = other.networkError();
m_type = other.type(); m_type = other.type();
m_postProcessScript = other.postProcessScript(); m_postProcessScript = other.postProcessScript();
m_sourceType = other.sourceType(); m_sourceType = other.sourceType();
@ -66,11 +64,8 @@ QList<QAction*> StandardFeed::contextMenuFeedsList() {
} }
QString StandardFeed::additionalTooltip() const { QString StandardFeed::additionalTooltip() const {
return Feed::additionalTooltip() + tr("\nNetwork status: %1\n" return Feed::additionalTooltip() + tr("\nEncoding: %2\n"
"Encoding: %2\n" "Type: %3").arg(encoding(), StandardFeed::typeToString(type()));
"Type: %3").arg(NetworkFactory::networkErrorText(m_networkError),
encoding(),
StandardFeed::typeToString(type()));
} }
bool StandardFeed::canBeDeleted() const { 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) { QString StandardFeed::generateFeedFileWithScript(const QString& execution_line, int run_timeout) {
auto prepared_query = prepareExecutionLine(execution_line); 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); return runScriptProcess(prepared_query, qApp->userDataFolder(), run_timeout, true, raw_feed_data);
} }
QNetworkReply::NetworkError StandardFeed::networkError() const {
return m_networkError;
}

View File

@ -71,9 +71,6 @@ class StandardFeed : public Feed {
QString password() const; QString password() const;
void setPassword(const QString& password); void setPassword(const QString& password);
QNetworkReply::NetworkError networkError() const;
void setNetworkError(const QNetworkReply::NetworkError& network_error);
// Tries to guess feed hidden under given URL // Tries to guess feed hidden under given URL
// and uses given credentials. // and uses given credentials.
// Returns pointer to guessed feed (if at least partially // Returns pointer to guessed feed (if at least partially
@ -110,7 +107,6 @@ class StandardFeed : public Feed {
SourceType m_sourceType; SourceType m_sourceType;
Type m_type; Type m_type;
QString m_postProcessScript; QString m_postProcessScript;
QNetworkReply::NetworkError m_networkError;
QString m_encoding; QString m_encoding;
bool m_passwordProtected{}; bool m_passwordProtected{};
QString m_username; QString m_username;

View File

@ -162,7 +162,8 @@ QList<Message> StandardServiceRoot::obtainNewMessages(const QList<Feed*>& feeds)
QList<QPair<QByteArray, QByteArray>> headers; QList<QPair<QByteArray, QByteArray>> headers;
headers << NetworkFactory::generateBasicAuthHeader(feed->username(), feed->password()); headers << NetworkFactory::generateBasicAuthHeader(feed->username(), feed->password());
feed->setNetworkError(NetworkFactory::performNetworkOperation(feed->source(),
auto network_result = NetworkFactory::performNetworkOperation(feed->source(),
download_timeout, download_timeout,
{}, {},
feed_contents, feed_contents,
@ -171,15 +172,15 @@ QList<Message> StandardServiceRoot::obtainNewMessages(const QList<Feed*>& feeds)
false, false,
{}, {},
{}, {},
networkProxy()).first); networkProxy()).first;
if (feed->networkError() != QNetworkReply::NetworkError::NoError) { if (network_result != QNetworkReply::NetworkError::NoError) {
qWarningNN << LOGSEC_CORE qWarningNN << LOGSEC_CORE
<< "Error" << "Error"
<< QUOTE_W_SPACE(feed->networkError()) << QUOTE_W_SPACE(network_result)
<< "during fetching of new messages for feed" << "during fetching of new messages for feed"
<< QUOTE_W_SPACE_DOT(feed->source()); << 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. // Encode downloaded data for further parsing.