mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-29 00:30:12 +01:00
nextcloud proxy support, provide fallback icon in msg list if no feed icon is available
This commit is contained in:
parent
4082ce7469
commit
5131881c3f
@ -30,7 +30,7 @@
|
|||||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="3.8.4" date="2021-01-25"/>
|
<release version="3.8.4" date="2021-01-26"/>
|
||||||
</releases>
|
</releases>
|
||||||
<content_rating type="oars-1.0">
|
<content_rating type="oars-1.0">
|
||||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||||
|
@ -339,7 +339,12 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
|
|||||||
QString feed_custom_id = dta.toString();
|
QString feed_custom_id = dta.toString();
|
||||||
auto acc = m_selectedItem->getParentServiceRoot()->feedIconForMessage(feed_custom_id);
|
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 {
|
else {
|
||||||
QModelIndex idx_read = index(idx.row(), MSG_DB_READ_INDEX);
|
QModelIndex idx_read = index(idx.row(), MSG_DB_READ_INDEX);
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
NetworkFactory::NetworkFactory() = default;
|
|
||||||
|
|
||||||
QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html) {
|
QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html) {
|
||||||
QStringList feeds;
|
QStringList feeds;
|
||||||
QRegularExpression rx(FEED_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption);
|
QRegularExpression rx(FEED_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption);
|
||||||
|
@ -20,9 +20,7 @@ class NetworkFactory {
|
|||||||
Q_DECLARE_TR_FUNCTIONS(NetworkFactory)
|
Q_DECLARE_TR_FUNCTIONS(NetworkFactory)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit NetworkFactory() = default;
|
||||||
// Constructor.
|
|
||||||
explicit NetworkFactory();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QStringList extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html);
|
static QStringList extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html);
|
||||||
|
@ -15,6 +15,8 @@ FormEditOwnCloudAccount::FormEditOwnCloudAccount(QWidget* parent)
|
|||||||
insertCustomTab(m_details, tr("Server setup"), 0);
|
insertCustomTab(m_details, tr("Server setup"), 0);
|
||||||
activateTab(0);
|
activateTab(0);
|
||||||
|
|
||||||
|
connect(m_details->m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditOwnCloudAccount::performTest);
|
||||||
|
|
||||||
m_details->m_ui.m_txtUrl->setFocus();
|
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_checkServerSideUpdate->setChecked(existing_root->network()->forceServerSideUpdate());
|
||||||
m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize());
|
m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormEditOwnCloudAccount::performTest() {
|
||||||
|
m_details->performTest(m_proxyDetails->proxy());
|
||||||
|
}
|
||||||
|
@ -20,6 +20,9 @@ class FormEditOwnCloudAccount : public FormAccountDetails {
|
|||||||
protected:
|
protected:
|
||||||
virtual void setEditableAccount(ServiceRoot* editable_account);
|
virtual void setEditableAccount(ServiceRoot* editable_account);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void performTest();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OwnCloudAccountDetails* m_details;
|
OwnCloudAccountDetails* m_details;
|
||||||
};
|
};
|
||||||
|
@ -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_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &OwnCloudAccountDetails::onPasswordChanged);
|
||||||
connect(m_ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &OwnCloudAccountDetails::onUsernameChanged);
|
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_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_txtUrl->lineEdit(), m_ui.m_checkDownloadOnlyUnreadMessages);
|
||||||
setTabOrder(m_ui.m_checkDownloadOnlyUnreadMessages, m_ui.m_checkServerSideUpdate);
|
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);
|
m_ui.m_txtPassword->lineEdit()->setEchoMode(display ? QLineEdit::Normal : QLineEdit::Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OwnCloudAccountDetails::performTest() {
|
void OwnCloudAccountDetails::performTest(const QNetworkProxy& custom_proxy) {
|
||||||
OwnCloudNetworkFactory factory;
|
OwnCloudNetworkFactory factory;
|
||||||
|
|
||||||
factory.setAuthUsername(m_ui.m_txtUsername->lineEdit()->text());
|
factory.setAuthUsername(m_ui.m_txtUsername->lineEdit()->text());
|
||||||
@ -68,7 +67,7 @@ void OwnCloudAccountDetails::performTest() {
|
|||||||
factory.setUrl(m_ui.m_txtUrl->lineEdit()->text());
|
factory.setUrl(m_ui.m_txtUrl->lineEdit()->text());
|
||||||
factory.setForceServerSideUpdate(m_ui.m_checkServerSideUpdate->isChecked());
|
factory.setForceServerSideUpdate(m_ui.m_checkServerSideUpdate->isChecked());
|
||||||
|
|
||||||
OwnCloudStatusResponse result = factory.status();
|
OwnCloudStatusResponse result = factory.status(custom_proxy);
|
||||||
|
|
||||||
if (result.networkError() != QNetworkReply::NetworkError::NoError) {
|
if (result.networkError() != QNetworkReply::NetworkError::NoError) {
|
||||||
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "ui_owncloudaccountdetails.h"
|
#include "ui_owncloudaccountdetails.h"
|
||||||
|
|
||||||
|
#include <QNetworkProxy>
|
||||||
|
|
||||||
class OwnCloudAccountDetails : public QWidget {
|
class OwnCloudAccountDetails : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ class OwnCloudAccountDetails : public QWidget {
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void displayPassword(bool display);
|
void displayPassword(bool display);
|
||||||
void performTest();
|
void performTest(const QNetworkProxy& custom_proxy);
|
||||||
void onUsernameChanged();
|
void onUsernameChanged();
|
||||||
void onPasswordChanged();
|
void onPasswordChanged();
|
||||||
void onUrlChanged();
|
void onUrlChanged();
|
||||||
|
@ -19,10 +19,9 @@
|
|||||||
|
|
||||||
OwnCloudNetworkFactory::OwnCloudNetworkFactory()
|
OwnCloudNetworkFactory::OwnCloudNetworkFactory()
|
||||||
: m_url(QString()), m_fixedUrl(QString()), m_downloadOnlyUnreadMessages(false), m_forceServerSideUpdate(false),
|
: 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(
|
m_authUsername(QString()), m_authPassword(QString()), m_batchSize(OWNCLOUD_UNLIMITED_BATCH_SIZE), m_urlUser(QString()),
|
||||||
QString()),
|
m_urlStatus(QString()), m_urlFolders(QString()), m_urlFeeds(QString()), m_urlMessages(QString()),
|
||||||
m_urlFolders(QString()), m_urlFeeds(QString()), m_urlMessages(QString()), m_urlFeedsUpdate(QString()),
|
m_urlFeedsUpdate(QString()), m_urlDeleteFeed(QString()), m_urlRenameFeed(QString()) {}
|
||||||
m_urlDeleteFeed(QString()), m_urlRenameFeed(QString()) {}
|
|
||||||
|
|
||||||
OwnCloudNetworkFactory::~OwnCloudNetworkFactory() = default;
|
OwnCloudNetworkFactory::~OwnCloudNetworkFactory() = default;
|
||||||
|
|
||||||
@ -75,7 +74,7 @@ void OwnCloudNetworkFactory::setAuthPassword(const QString& auth_password) {
|
|||||||
m_authPassword = auth_password;
|
m_authPassword = auth_password;
|
||||||
}
|
}
|
||||||
|
|
||||||
OwnCloudStatusResponse OwnCloudNetworkFactory::status() {
|
OwnCloudStatusResponse OwnCloudNetworkFactory::status(const QNetworkProxy& custom_proxy) {
|
||||||
QByteArray result_raw;
|
QByteArray result_raw;
|
||||||
QList<QPair<QByteArray, QByteArray>> headers;
|
QList<QPair<QByteArray, QByteArray>> headers;
|
||||||
|
|
||||||
@ -85,9 +84,14 @@ OwnCloudStatusResponse OwnCloudNetworkFactory::status() {
|
|||||||
NetworkResult network_reply = NetworkFactory::performNetworkOperation(m_urlStatus,
|
NetworkResult network_reply = NetworkFactory::performNetworkOperation(m_urlStatus,
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
qApp->settings()->value(GROUP(Feeds),
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||||
QByteArray(), result_raw,
|
QByteArray(),
|
||||||
|
result_raw,
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
QNetworkAccessManager::Operation::GetOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
OwnCloudStatusResponse status_response(network_reply.first, QString::fromUtf8(result_raw));
|
OwnCloudStatusResponse status_response(network_reply.first, QString::fromUtf8(result_raw));
|
||||||
|
|
||||||
qDebugNN << LOGSEC_NEXTCLOUD
|
qDebugNN << LOGSEC_NEXTCLOUD
|
||||||
@ -102,7 +106,7 @@ OwnCloudStatusResponse OwnCloudNetworkFactory::status() {
|
|||||||
return status_response;
|
return status_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() {
|
OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories(const QNetworkProxy& custom_proxy) {
|
||||||
QByteArray result_raw;
|
QByteArray result_raw;
|
||||||
QList<QPair<QByteArray, QByteArray>> headers;
|
QList<QPair<QByteArray, QByteArray>> headers;
|
||||||
|
|
||||||
@ -112,9 +116,14 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() {
|
|||||||
NetworkResult network_reply = NetworkFactory::performNetworkOperation(m_urlFolders,
|
NetworkResult network_reply = NetworkFactory::performNetworkOperation(m_urlFolders,
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
qApp->settings()->value(GROUP(Feeds),
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||||
QByteArray(), result_raw,
|
QByteArray(),
|
||||||
|
result_raw,
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
QNetworkAccessManager::Operation::GetOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
|
|
||||||
if (network_reply.first != QNetworkReply::NoError) {
|
if (network_reply.first != QNetworkReply::NoError) {
|
||||||
qCriticalNN << LOGSEC_NEXTCLOUD
|
qCriticalNN << LOGSEC_NEXTCLOUD
|
||||||
@ -129,9 +138,14 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() {
|
|||||||
network_reply = NetworkFactory::performNetworkOperation(m_urlFeeds,
|
network_reply = NetworkFactory::performNetworkOperation(m_urlFeeds,
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
qApp->settings()->value(GROUP(Feeds),
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||||
QByteArray(), result_raw,
|
QByteArray(),
|
||||||
|
result_raw,
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
QNetworkAccessManager::Operation::GetOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
|
|
||||||
if (network_reply.first != QNetworkReply::NoError) {
|
if (network_reply.first != QNetworkReply::NoError) {
|
||||||
qCriticalNN << LOGSEC_NEXTCLOUD
|
qCriticalNN << LOGSEC_NEXTCLOUD
|
||||||
@ -145,7 +159,7 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() {
|
|||||||
return OwnCloudGetFeedsCategoriesResponse(network_reply.first, content_categories, content_feeds);
|
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);
|
QString final_url = m_urlDeleteFeed.arg(feed_id);
|
||||||
QByteArray raw_output;
|
QByteArray raw_output;
|
||||||
QList<QPair<QByteArray, QByteArray>> headers;
|
QList<QPair<QByteArray, QByteArray>> headers;
|
||||||
@ -159,7 +173,11 @@ bool OwnCloudNetworkFactory::deleteFeed(const QString& feed_id) {
|
|||||||
QByteArray(),
|
QByteArray(),
|
||||||
raw_output,
|
raw_output,
|
||||||
QNetworkAccessManager::Operation::DeleteOperation,
|
QNetworkAccessManager::Operation::DeleteOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
|
|
||||||
if (network_reply.first != QNetworkReply::NoError) {
|
if (network_reply.first != QNetworkReply::NoError) {
|
||||||
qCriticalNN << LOGSEC_NEXTCLOUD
|
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;
|
QJsonObject json;
|
||||||
|
|
||||||
json["url"] = url;
|
json["url"] = url;
|
||||||
|
|
||||||
auto nextcloud_version = status().version();
|
auto nextcloud_version = status(custom_proxy).version();
|
||||||
|
|
||||||
if (SystemFactory::isVersionEqualOrNewer(nextcloud_version, QSL("15.1.0"))) {
|
if (SystemFactory::isVersionEqualOrNewer(nextcloud_version, QSL("15.1.0"))) {
|
||||||
json["folderId"] = parent_id == 0 ? QJsonValue(QJsonValue::Type::Null) : parent_id;
|
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),
|
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
|
||||||
result_raw,
|
result_raw,
|
||||||
QNetworkAccessManager::Operation::PostOperation,
|
QNetworkAccessManager::Operation::PostOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
|
|
||||||
if (network_reply.first != QNetworkReply::NoError) {
|
if (network_reply.first != QNetworkReply::NoError) {
|
||||||
qCriticalNN << LOGSEC_NEXTCLOUD
|
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);
|
QString final_url = m_urlRenameFeed.arg(custom_feed_id);
|
||||||
QByteArray result_raw;
|
QByteArray result_raw;
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
@ -229,7 +253,11 @@ bool OwnCloudNetworkFactory::renameFeed(const QString& new_name, const QString&
|
|||||||
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
|
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
|
||||||
result_raw,
|
result_raw,
|
||||||
QNetworkAccessManager::PutOperation,
|
QNetworkAccessManager::PutOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
|
|
||||||
if (network_reply.first != QNetworkReply::NetworkError::NoError) {
|
if (network_reply.first != QNetworkReply::NetworkError::NoError) {
|
||||||
qCriticalNN << LOGSEC_NEXTCLOUD
|
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()) {
|
if (forceServerSideUpdate()) {
|
||||||
triggerFeedUpdate(feed_id);
|
triggerFeedUpdate(feed_id, custom_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString final_url = m_urlMessages.arg(QString::number(feed_id),
|
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,
|
NetworkResult network_reply = NetworkFactory::performNetworkOperation(final_url,
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
qApp->settings()->value(GROUP(Feeds),
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||||
QByteArray(), result_raw,
|
QByteArray(),
|
||||||
|
result_raw,
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
QNetworkAccessManager::Operation::GetOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
OwnCloudGetMessagesResponse msgs_response(network_reply.first, QString::fromUtf8(result_raw));
|
OwnCloudGetMessagesResponse msgs_response(network_reply.first, QString::fromUtf8(result_raw));
|
||||||
|
|
||||||
if (network_reply.first != QNetworkReply::NoError) {
|
if (network_reply.first != QNetworkReply::NoError) {
|
||||||
@ -274,7 +307,7 @@ OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id) {
|
|||||||
return msgs_response;
|
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.
|
// Now, we can trigger the update.
|
||||||
QByteArray raw_output;
|
QByteArray raw_output;
|
||||||
QList<QPair<QByteArray, QByteArray>> headers;
|
QList<QPair<QByteArray, QByteArray>> headers;
|
||||||
@ -286,9 +319,14 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_i
|
|||||||
QString::number(feed_id)),
|
QString::number(feed_id)),
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
qApp->settings()->value(GROUP(Feeds),
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||||
QByteArray(), raw_output,
|
QByteArray(),
|
||||||
|
raw_output,
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
QNetworkAccessManager::Operation::GetOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
|
|
||||||
if (network_reply.first != QNetworkReply::NetworkError::NoError) {
|
if (network_reply.first != QNetworkReply::NetworkError::NoError) {
|
||||||
qCriticalNN << LOGSEC_NEXTCLOUD
|
qCriticalNN << LOGSEC_NEXTCLOUD
|
||||||
@ -299,7 +337,9 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_i
|
|||||||
return network_reply.first;
|
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;
|
QJsonObject json;
|
||||||
QJsonArray ids;
|
QJsonArray ids;
|
||||||
QString final_url;
|
QString final_url;
|
||||||
@ -330,12 +370,17 @@ NetworkResult OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus stat
|
|||||||
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
|
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
|
||||||
output,
|
output,
|
||||||
QNetworkAccessManager::Operation::PutOperation,
|
QNetworkAccessManager::Operation::PutOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkResult OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance,
|
NetworkResult OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance,
|
||||||
const QStringList& feed_ids,
|
const QStringList& feed_ids,
|
||||||
const QStringList& guid_hashes) {
|
const QStringList& guid_hashes,
|
||||||
|
const QNetworkProxy& custom_proxy) {
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
QJsonArray ids;
|
QJsonArray ids;
|
||||||
QString final_url;
|
QString final_url;
|
||||||
@ -370,7 +415,11 @@ NetworkResult OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance i
|
|||||||
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
|
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
|
||||||
output,
|
output,
|
||||||
QNetworkAccessManager::Operation::PutOperation,
|
QNetworkAccessManager::Operation::PutOperation,
|
||||||
headers);
|
headers,
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
custom_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OwnCloudNetworkFactory::batchSize() const {
|
int OwnCloudNetworkFactory::batchSize() const {
|
||||||
|
@ -79,27 +79,6 @@ class OwnCloudNetworkFactory {
|
|||||||
QString authPassword() const;
|
QString authPassword() const;
|
||||||
void setAuthPassword(const QString& auth_password);
|
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.
|
// Gets/sets the amount of messages to obtain during single feed update.
|
||||||
int batchSize() const;
|
int batchSize() const;
|
||||||
void setBatchSize(int batch_size);
|
void setBatchSize(int batch_size);
|
||||||
@ -107,6 +86,34 @@ class OwnCloudNetworkFactory {
|
|||||||
bool downloadOnlyUnreadMessages() const;
|
bool downloadOnlyUnreadMessages() const;
|
||||||
void setDownloadOnlyUnreadMessages(bool dowload_only_unread_messages);
|
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:
|
private:
|
||||||
QString m_url;
|
QString m_url;
|
||||||
QString m_fixedUrl;
|
QString m_fixedUrl;
|
||||||
|
@ -20,7 +20,7 @@ bool OwnCloudFeed::canBeDeleted() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OwnCloudFeed::deleteViaGui() {
|
bool OwnCloudFeed::deleteViaGui() {
|
||||||
if (serviceRoot()->network()->deleteFeed(customId()) && removeItself()) {
|
if (serviceRoot()->network()->deleteFeed(customId(), getParentServiceRoot()->networkProxy()) && removeItself()) {
|
||||||
serviceRoot()->requestItemRemoval(this);
|
serviceRoot()->requestItemRemoval(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,8 @@ OwnCloudServiceRoot* OwnCloudFeed::serviceRoot() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<Message> OwnCloudFeed::obtainNewMessages(bool* error_during_obtaining) {
|
QList<Message> 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) {
|
if (messages.networkError() != QNetworkReply::NetworkError::NoError) {
|
||||||
setStatus(Feed::Status::NetworkError);
|
setStatus(Feed::Status::NetworkError);
|
||||||
|
@ -91,7 +91,7 @@ void OwnCloudServiceRoot::saveAllCachedData(bool ignore_errors) {
|
|||||||
QStringList ids = i.value();
|
QStringList ids = i.value();
|
||||||
|
|
||||||
if (!ids.isEmpty()) {
|
if (!ids.isEmpty()) {
|
||||||
auto res = network()->markMessagesRead(key, ids);
|
auto res = network()->markMessagesRead(key, ids, networkProxy());
|
||||||
|
|
||||||
if (!ignore_errors && res.first != QNetworkReply::NetworkError::NoError) {
|
if (!ignore_errors && res.first != QNetworkReply::NetworkError::NoError) {
|
||||||
addMessageStatesToCache(ids, key);
|
addMessageStatesToCache(ids, key);
|
||||||
@ -115,7 +115,7 @@ void OwnCloudServiceRoot::saveAllCachedData(bool ignore_errors) {
|
|||||||
guid_hashes.append(msg.m_customHash);
|
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) {
|
if (!ignore_errors && res.first != QNetworkReply::NetworkError::NoError) {
|
||||||
addMessageStatesToCache(messages, key);
|
addMessageStatesToCache(messages, key);
|
||||||
@ -152,7 +152,7 @@ void OwnCloudServiceRoot::saveAccountDataToDatabase(bool creating_new) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RootItem* OwnCloudServiceRoot::obtainNewTreeForSyncIn() const {
|
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) {
|
if (feed_cats_response.networkError() == QNetworkReply::NetworkError::NoError) {
|
||||||
return feed_cats_response.feedsCategories(true);
|
return feed_cats_response.feedsCategories(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user