diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml index 7c0cd22d3..4279baeb1 100644 --- a/resources/desktop/com.github.rssguard.appdata.xml +++ b/resources/desktop/com.github.rssguard.appdata.xml @@ -30,7 +30,7 @@ https://martinrotter.github.io/donate/ - + none diff --git a/src/librssguard/core/messagesmodel.cpp b/src/librssguard/core/messagesmodel.cpp index bfb8b481b..8c2697a95 100644 --- a/src/librssguard/core/messagesmodel.cpp +++ b/src/librssguard/core/messagesmodel.cpp @@ -339,7 +339,12 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const { QString feed_custom_id = dta.toString(); auto acc = m_selectedItem->getParentServiceRoot()->feedIconForMessage(feed_custom_id); - return acc; + if (acc.isNull()) { + return qApp->icons()->fromTheme(QSL("application-rss+xml")); + } + else { + return acc; + } } else { QModelIndex idx_read = index(idx.row(), MSG_DB_READ_INDEX); diff --git a/src/librssguard/network-web/networkfactory.cpp b/src/librssguard/network-web/networkfactory.cpp index a3b7e03cf..57a6221d4 100644 --- a/src/librssguard/network-web/networkfactory.cpp +++ b/src/librssguard/network-web/networkfactory.cpp @@ -14,8 +14,6 @@ #include #include -NetworkFactory::NetworkFactory() = default; - QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html) { QStringList feeds; QRegularExpression rx(FEED_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption); diff --git a/src/librssguard/network-web/networkfactory.h b/src/librssguard/network-web/networkfactory.h index 357000b9e..3de6cfd2b 100644 --- a/src/librssguard/network-web/networkfactory.h +++ b/src/librssguard/network-web/networkfactory.h @@ -20,9 +20,7 @@ class NetworkFactory { Q_DECLARE_TR_FUNCTIONS(NetworkFactory) private: - - // Constructor. - explicit NetworkFactory(); + explicit NetworkFactory() = default; public: static QStringList extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html); diff --git a/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp b/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp index 027570ff7..c4fef1fda 100644 --- a/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp +++ b/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp @@ -15,6 +15,8 @@ FormEditOwnCloudAccount::FormEditOwnCloudAccount(QWidget* parent) insertCustomTab(m_details, tr("Server setup"), 0); activateTab(0); + connect(m_details->m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditOwnCloudAccount::performTest); + m_details->m_ui.m_txtUrl->setFocus(); } @@ -49,3 +51,7 @@ void FormEditOwnCloudAccount::setEditableAccount(ServiceRoot* editable_account) m_details->m_ui.m_checkServerSideUpdate->setChecked(existing_root->network()->forceServerSideUpdate()); m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize()); } + +void FormEditOwnCloudAccount::performTest() { + m_details->performTest(m_proxyDetails->proxy()); +} diff --git a/src/librssguard/services/owncloud/gui/formeditowncloudaccount.h b/src/librssguard/services/owncloud/gui/formeditowncloudaccount.h index afbfc96e6..74aaec176 100644 --- a/src/librssguard/services/owncloud/gui/formeditowncloudaccount.h +++ b/src/librssguard/services/owncloud/gui/formeditowncloudaccount.h @@ -20,6 +20,9 @@ class FormEditOwnCloudAccount : public FormAccountDetails { protected: virtual void setEditableAccount(ServiceRoot* editable_account); + private slots: + void performTest(); + private: OwnCloudAccountDetails* m_details; }; diff --git a/src/librssguard/services/owncloud/gui/owncloudaccountdetails.cpp b/src/librssguard/services/owncloud/gui/owncloudaccountdetails.cpp index 3f6e29783..1afc3050c 100755 --- a/src/librssguard/services/owncloud/gui/owncloudaccountdetails.cpp +++ b/src/librssguard/services/owncloud/gui/owncloudaccountdetails.cpp @@ -40,7 +40,6 @@ OwnCloudAccountDetails::OwnCloudAccountDetails(QWidget* parent) : QWidget(parent connect(m_ui.m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &OwnCloudAccountDetails::onPasswordChanged); connect(m_ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &OwnCloudAccountDetails::onUsernameChanged); connect(m_ui.m_txtUrl->lineEdit(), &BaseLineEdit::textChanged, this, &OwnCloudAccountDetails::onUrlChanged); - connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &OwnCloudAccountDetails::performTest); setTabOrder(m_ui.m_txtUrl->lineEdit(), m_ui.m_checkDownloadOnlyUnreadMessages); setTabOrder(m_ui.m_checkDownloadOnlyUnreadMessages, m_ui.m_checkServerSideUpdate); @@ -60,7 +59,7 @@ void OwnCloudAccountDetails::displayPassword(bool display) { m_ui.m_txtPassword->lineEdit()->setEchoMode(display ? QLineEdit::Normal : QLineEdit::Password); } -void OwnCloudAccountDetails::performTest() { +void OwnCloudAccountDetails::performTest(const QNetworkProxy& custom_proxy) { OwnCloudNetworkFactory factory; factory.setAuthUsername(m_ui.m_txtUsername->lineEdit()->text()); @@ -68,7 +67,7 @@ void OwnCloudAccountDetails::performTest() { factory.setUrl(m_ui.m_txtUrl->lineEdit()->text()); factory.setForceServerSideUpdate(m_ui.m_checkServerSideUpdate->isChecked()); - OwnCloudStatusResponse result = factory.status(); + OwnCloudStatusResponse result = factory.status(custom_proxy); if (result.networkError() != QNetworkReply::NetworkError::NoError) { m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error, diff --git a/src/librssguard/services/owncloud/gui/owncloudaccountdetails.h b/src/librssguard/services/owncloud/gui/owncloudaccountdetails.h index 2e8acdb66..ae2ebfd98 100755 --- a/src/librssguard/services/owncloud/gui/owncloudaccountdetails.h +++ b/src/librssguard/services/owncloud/gui/owncloudaccountdetails.h @@ -7,6 +7,8 @@ #include "ui_owncloudaccountdetails.h" +#include + class OwnCloudAccountDetails : public QWidget { Q_OBJECT @@ -17,7 +19,7 @@ class OwnCloudAccountDetails : public QWidget { private slots: void displayPassword(bool display); - void performTest(); + void performTest(const QNetworkProxy& custom_proxy); void onUsernameChanged(); void onPasswordChanged(); void onUrlChanged(); diff --git a/src/librssguard/services/owncloud/network/owncloudnetworkfactory.cpp b/src/librssguard/services/owncloud/network/owncloudnetworkfactory.cpp index d32180cf5..1d02e92a9 100644 --- a/src/librssguard/services/owncloud/network/owncloudnetworkfactory.cpp +++ b/src/librssguard/services/owncloud/network/owncloudnetworkfactory.cpp @@ -19,10 +19,9 @@ OwnCloudNetworkFactory::OwnCloudNetworkFactory() : m_url(QString()), m_fixedUrl(QString()), m_downloadOnlyUnreadMessages(false), m_forceServerSideUpdate(false), - m_authUsername(QString()), m_authPassword(QString()), m_batchSize(OWNCLOUD_UNLIMITED_BATCH_SIZE), m_urlUser(QString()), m_urlStatus( - QString()), - m_urlFolders(QString()), m_urlFeeds(QString()), m_urlMessages(QString()), m_urlFeedsUpdate(QString()), - m_urlDeleteFeed(QString()), m_urlRenameFeed(QString()) {} + m_authUsername(QString()), m_authPassword(QString()), m_batchSize(OWNCLOUD_UNLIMITED_BATCH_SIZE), m_urlUser(QString()), + m_urlStatus(QString()), m_urlFolders(QString()), m_urlFeeds(QString()), m_urlMessages(QString()), + m_urlFeedsUpdate(QString()), m_urlDeleteFeed(QString()), m_urlRenameFeed(QString()) {} OwnCloudNetworkFactory::~OwnCloudNetworkFactory() = default; @@ -75,7 +74,7 @@ void OwnCloudNetworkFactory::setAuthPassword(const QString& auth_password) { m_authPassword = auth_password; } -OwnCloudStatusResponse OwnCloudNetworkFactory::status() { +OwnCloudStatusResponse OwnCloudNetworkFactory::status(const QNetworkProxy& custom_proxy) { QByteArray result_raw; QList> headers; @@ -85,9 +84,14 @@ OwnCloudStatusResponse OwnCloudNetworkFactory::status() { NetworkResult network_reply = NetworkFactory::performNetworkOperation(m_urlStatus, qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(), - QByteArray(), result_raw, + QByteArray(), + result_raw, QNetworkAccessManager::Operation::GetOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); OwnCloudStatusResponse status_response(network_reply.first, QString::fromUtf8(result_raw)); qDebugNN << LOGSEC_NEXTCLOUD @@ -102,7 +106,7 @@ OwnCloudStatusResponse OwnCloudNetworkFactory::status() { return status_response; } -OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() { +OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories(const QNetworkProxy& custom_proxy) { QByteArray result_raw; QList> headers; @@ -112,9 +116,14 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() { NetworkResult network_reply = NetworkFactory::performNetworkOperation(m_urlFolders, qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(), - QByteArray(), result_raw, + QByteArray(), + result_raw, QNetworkAccessManager::Operation::GetOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); if (network_reply.first != QNetworkReply::NoError) { qCriticalNN << LOGSEC_NEXTCLOUD @@ -129,9 +138,14 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() { network_reply = NetworkFactory::performNetworkOperation(m_urlFeeds, qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(), - QByteArray(), result_raw, + QByteArray(), + result_raw, QNetworkAccessManager::Operation::GetOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); if (network_reply.first != QNetworkReply::NoError) { qCriticalNN << LOGSEC_NEXTCLOUD @@ -145,7 +159,7 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() { return OwnCloudGetFeedsCategoriesResponse(network_reply.first, content_categories, content_feeds); } -bool OwnCloudNetworkFactory::deleteFeed(const QString& feed_id) { +bool OwnCloudNetworkFactory::deleteFeed(const QString& feed_id, const QNetworkProxy& custom_proxy) { QString final_url = m_urlDeleteFeed.arg(feed_id); QByteArray raw_output; QList> headers; @@ -159,7 +173,11 @@ bool OwnCloudNetworkFactory::deleteFeed(const QString& feed_id) { QByteArray(), raw_output, QNetworkAccessManager::Operation::DeleteOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); if (network_reply.first != QNetworkReply::NoError) { qCriticalNN << LOGSEC_NEXTCLOUD @@ -172,12 +190,12 @@ bool OwnCloudNetworkFactory::deleteFeed(const QString& feed_id) { } } -bool OwnCloudNetworkFactory::createFeed(const QString& url, int parent_id) { +bool OwnCloudNetworkFactory::createFeed(const QString& url, int parent_id, const QNetworkProxy& custom_proxy) { QJsonObject json; json["url"] = url; - auto nextcloud_version = status().version(); + auto nextcloud_version = status(custom_proxy).version(); if (SystemFactory::isVersionEqualOrNewer(nextcloud_version, QSL("15.1.0"))) { json["folderId"] = parent_id == 0 ? QJsonValue(QJsonValue::Type::Null) : parent_id; @@ -198,7 +216,11 @@ bool OwnCloudNetworkFactory::createFeed(const QString& url, int parent_id) { QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact), result_raw, QNetworkAccessManager::Operation::PostOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); if (network_reply.first != QNetworkReply::NoError) { qCriticalNN << LOGSEC_NEXTCLOUD @@ -211,7 +233,9 @@ bool OwnCloudNetworkFactory::createFeed(const QString& url, int parent_id) { } } -bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, const QString& custom_feed_id) { +bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, + const QString& custom_feed_id, + const QNetworkProxy& custom_proxy) { QString final_url = m_urlRenameFeed.arg(custom_feed_id); QByteArray result_raw; QJsonObject json; @@ -229,7 +253,11 @@ bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, const QString& QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact), result_raw, QNetworkAccessManager::PutOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); if (network_reply.first != QNetworkReply::NetworkError::NoError) { qCriticalNN << LOGSEC_NEXTCLOUD @@ -242,9 +270,9 @@ bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, const QString& } } -OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id) { +OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id, const QNetworkProxy& custom_proxy) { if (forceServerSideUpdate()) { - triggerFeedUpdate(feed_id); + triggerFeedUpdate(feed_id, custom_proxy); } QString final_url = m_urlMessages.arg(QString::number(feed_id), @@ -260,9 +288,14 @@ OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id) { NetworkResult network_reply = NetworkFactory::performNetworkOperation(final_url, qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(), - QByteArray(), result_raw, + QByteArray(), + result_raw, QNetworkAccessManager::Operation::GetOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); OwnCloudGetMessagesResponse msgs_response(network_reply.first, QString::fromUtf8(result_raw)); if (network_reply.first != QNetworkReply::NoError) { @@ -274,7 +307,7 @@ OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id) { return msgs_response; } -QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_id) { +QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_id, const QNetworkProxy& custom_proxy) { // Now, we can trigger the update. QByteArray raw_output; QList> headers; @@ -286,9 +319,14 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_i QString::number(feed_id)), qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(), - QByteArray(), raw_output, + QByteArray(), + raw_output, QNetworkAccessManager::Operation::GetOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); if (network_reply.first != QNetworkReply::NetworkError::NoError) { qCriticalNN << LOGSEC_NEXTCLOUD @@ -299,7 +337,9 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_i return network_reply.first; } -NetworkResult OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids) { +NetworkResult OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus status, + const QStringList& custom_ids, + const QNetworkProxy& custom_proxy) { QJsonObject json; QJsonArray ids; QString final_url; @@ -330,12 +370,17 @@ NetworkResult OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus stat QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact), output, QNetworkAccessManager::Operation::PutOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); } NetworkResult OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance, const QStringList& feed_ids, - const QStringList& guid_hashes) { + const QStringList& guid_hashes, + const QNetworkProxy& custom_proxy) { QJsonObject json; QJsonArray ids; QString final_url; @@ -370,7 +415,11 @@ NetworkResult OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance i QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact), output, QNetworkAccessManager::Operation::PutOperation, - headers); + headers, + false, + {}, + {}, + custom_proxy); } int OwnCloudNetworkFactory::batchSize() const { diff --git a/src/librssguard/services/owncloud/network/owncloudnetworkfactory.h b/src/librssguard/services/owncloud/network/owncloudnetworkfactory.h index fd6c183bc..9f1006819 100644 --- a/src/librssguard/services/owncloud/network/owncloudnetworkfactory.h +++ b/src/librssguard/services/owncloud/network/owncloudnetworkfactory.h @@ -79,27 +79,6 @@ class OwnCloudNetworkFactory { QString authPassword() const; void setAuthPassword(const QString& auth_password); - // Operations. - - // Get version info. - OwnCloudStatusResponse status(); - - // Get feeds & categories (used for sync-in). - OwnCloudGetFeedsCategoriesResponse feedsCategories(); - - // Feed operations. - bool deleteFeed(const QString& feed_id); - bool createFeed(const QString& url, int parent_id); - bool renameFeed(const QString& new_name, const QString& custom_feed_id); - - // Get messages for given feed. - OwnCloudGetMessagesResponse getMessages(int feed_id); - - // Misc methods. - QNetworkReply::NetworkError triggerFeedUpdate(int feed_id); - NetworkResult markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids); - NetworkResult markMessagesStarred(RootItem::Importance importance, const QStringList& feed_ids, const QStringList& guid_hashes); - // Gets/sets the amount of messages to obtain during single feed update. int batchSize() const; void setBatchSize(int batch_size); @@ -107,6 +86,34 @@ class OwnCloudNetworkFactory { bool downloadOnlyUnreadMessages() const; void setDownloadOnlyUnreadMessages(bool dowload_only_unread_messages); + // Operations. + + // Get version info. + OwnCloudStatusResponse status(const QNetworkProxy& custom_proxy); + + // Get feeds & categories (used for sync-in). + OwnCloudGetFeedsCategoriesResponse feedsCategories(const QNetworkProxy& custom_proxy); + + // Feed operations. + bool deleteFeed(const QString& feed_id, const QNetworkProxy& custom_proxy); + bool createFeed(const QString& url, int parent_id, const QNetworkProxy& custom_proxy); + bool renameFeed(const QString& new_name, const QString& custom_feed_id, const QNetworkProxy& custom_proxy); + + // Get messages for given feed. + OwnCloudGetMessagesResponse getMessages(int feed_id, const QNetworkProxy& custom_proxy); + + // Misc methods. + QNetworkReply::NetworkError triggerFeedUpdate(int feed_id, const QNetworkProxy& custom_proxy); + + NetworkResult markMessagesRead(RootItem::ReadStatus status, + const QStringList& custom_ids, + const QNetworkProxy& custom_proxy); + + NetworkResult markMessagesStarred(RootItem::Importance importance, + const QStringList& feed_ids, + const QStringList& guid_hashes, + const QNetworkProxy& custom_proxy); + private: QString m_url; QString m_fixedUrl; diff --git a/src/librssguard/services/owncloud/owncloudfeed.cpp b/src/librssguard/services/owncloud/owncloudfeed.cpp index 3fce41f16..5891d9714 100644 --- a/src/librssguard/services/owncloud/owncloudfeed.cpp +++ b/src/librssguard/services/owncloud/owncloudfeed.cpp @@ -20,7 +20,7 @@ bool OwnCloudFeed::canBeDeleted() const { } bool OwnCloudFeed::deleteViaGui() { - if (serviceRoot()->network()->deleteFeed(customId()) && removeItself()) { + if (serviceRoot()->network()->deleteFeed(customId(), getParentServiceRoot()->networkProxy()) && removeItself()) { serviceRoot()->requestItemRemoval(this); return true; } @@ -40,7 +40,8 @@ OwnCloudServiceRoot* OwnCloudFeed::serviceRoot() const { } QList OwnCloudFeed::obtainNewMessages(bool* error_during_obtaining) { - OwnCloudGetMessagesResponse messages = serviceRoot()->network()->getMessages(customNumericId()); + OwnCloudGetMessagesResponse messages = serviceRoot()->network()->getMessages(customNumericId(), + getParentServiceRoot()->networkProxy()); if (messages.networkError() != QNetworkReply::NetworkError::NoError) { setStatus(Feed::Status::NetworkError); diff --git a/src/librssguard/services/owncloud/owncloudserviceroot.cpp b/src/librssguard/services/owncloud/owncloudserviceroot.cpp index 6f4b53d11..d4c8d5378 100644 --- a/src/librssguard/services/owncloud/owncloudserviceroot.cpp +++ b/src/librssguard/services/owncloud/owncloudserviceroot.cpp @@ -91,7 +91,7 @@ void OwnCloudServiceRoot::saveAllCachedData(bool ignore_errors) { QStringList ids = i.value(); if (!ids.isEmpty()) { - auto res = network()->markMessagesRead(key, ids); + auto res = network()->markMessagesRead(key, ids, networkProxy()); if (!ignore_errors && res.first != QNetworkReply::NetworkError::NoError) { addMessageStatesToCache(ids, key); @@ -115,7 +115,7 @@ void OwnCloudServiceRoot::saveAllCachedData(bool ignore_errors) { guid_hashes.append(msg.m_customHash); } - auto res = network()->markMessagesStarred(key, feed_ids, guid_hashes); + auto res = network()->markMessagesStarred(key, feed_ids, guid_hashes, networkProxy()); if (!ignore_errors && res.first != QNetworkReply::NetworkError::NoError) { addMessageStatesToCache(messages, key); @@ -152,7 +152,7 @@ void OwnCloudServiceRoot::saveAccountDataToDatabase(bool creating_new) { } RootItem* OwnCloudServiceRoot::obtainNewTreeForSyncIn() const { - OwnCloudGetFeedsCategoriesResponse feed_cats_response = m_network->feedsCategories(); + OwnCloudGetFeedsCategoriesResponse feed_cats_response = m_network->feedsCategories(networkProxy()); if (feed_cats_response.networkError() == QNetworkReply::NetworkError::NoError) { return feed_cats_response.feedsCategories(true);