Save.
This commit is contained in:
parent
fc28b3c6d2
commit
573c5c43fe
14 changed files with 72 additions and 136 deletions
|
@ -76,10 +76,9 @@ void FeedDownloader::synchronizeAccountCaches(const QList<CacheForServiceRoot*>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_isCacheSynchronizationRunning = false;
|
||||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "All caches synchronized.";
|
qDebugNN << LOGSEC_FEEDDOWNLOADER << "All caches synchronized.";
|
||||||
emit cachesSynchronized();
|
emit cachesSynchronized();
|
||||||
|
|
||||||
m_isCacheSynchronizationRunning = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedDownloader::updateFeeds(const QList<Feed*>& feeds) {
|
void FeedDownloader::updateFeeds(const QList<Feed*>& feeds) {
|
||||||
|
|
|
@ -34,6 +34,7 @@ FeedReader::FeedReader(QObject* parent)
|
||||||
|
|
||||||
connect(m_autoUpdateTimer, &QTimer::timeout, this, &FeedReader::executeNextAutoUpdate);
|
connect(m_autoUpdateTimer, &QTimer::timeout, this, &FeedReader::executeNextAutoUpdate);
|
||||||
updateAutoUpdateStatus();
|
updateAutoUpdateStatus();
|
||||||
|
initializeFeedDownloader();
|
||||||
|
|
||||||
if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()) {
|
if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()) {
|
||||||
qDebugNN << LOGSEC_CORE
|
qDebugNN << LOGSEC_CORE
|
||||||
|
@ -72,16 +73,12 @@ void FeedReader::updateFeeds(const QList<Feed*>& feeds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeFeedDownloader();
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(m_feedDownloader, "updateFeeds",
|
QMetaObject::invokeMethod(m_feedDownloader, "updateFeeds",
|
||||||
Qt::ConnectionType::QueuedConnection,
|
Qt::ConnectionType::QueuedConnection,
|
||||||
Q_ARG(QList<Feed*>, feeds));
|
Q_ARG(QList<Feed*>, feeds));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedReader::synchronizeMessageData(const QList<CacheForServiceRoot*>& caches) {
|
void FeedReader::synchronizeMessageData(const QList<CacheForServiceRoot*>& caches) {
|
||||||
initializeFeedDownloader();
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(m_feedDownloader, "synchronizeAccountCaches",
|
QMetaObject::invokeMethod(m_feedDownloader, "synchronizeAccountCaches",
|
||||||
Qt::ConnectionType::QueuedConnection,
|
Qt::ConnectionType::QueuedConnection,
|
||||||
Q_ARG(QList<CacheForServiceRoot*>, caches));
|
Q_ARG(QList<CacheForServiceRoot*>, caches));
|
||||||
|
@ -91,8 +88,8 @@ void FeedReader::initializeFeedDownloader() {
|
||||||
if (m_feedDownloader == nullptr) {
|
if (m_feedDownloader == nullptr) {
|
||||||
qDebugNN << LOGSEC_CORE << "Creating FeedDownloader singleton.";
|
qDebugNN << LOGSEC_CORE << "Creating FeedDownloader singleton.";
|
||||||
|
|
||||||
m_feedDownloaderThread = new QThread();
|
|
||||||
m_feedDownloader = new FeedDownloader();
|
m_feedDownloader = new FeedDownloader();
|
||||||
|
m_feedDownloaderThread = new QThread();
|
||||||
|
|
||||||
// Downloader setup.
|
// Downloader setup.
|
||||||
qRegisterMetaType<QList<Feed*>>("QList<Feed*>");
|
qRegisterMetaType<QList<Feed*>>("QList<Feed*>");
|
||||||
|
|
|
@ -216,7 +216,7 @@ void GmailServiceRoot::saveAllCachedData() {
|
||||||
QStringList ids = i.value();
|
QStringList ids = i.value();
|
||||||
|
|
||||||
if (!ids.isEmpty()) {
|
if (!ids.isEmpty()) {
|
||||||
network()->markMessagesRead(key, ids, false);
|
network()->markMessagesRead(key, ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ void GmailServiceRoot::saveAllCachedData() {
|
||||||
custom_ids.append(msg.m_customId);
|
custom_ids.append(msg.m_customId);
|
||||||
}
|
}
|
||||||
|
|
||||||
network()->markMessagesStarred(key, custom_ids, false);
|
network()->markMessagesStarred(key, custom_ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id, Feed::Sta
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids, bool async) {
|
void GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids) {
|
||||||
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
||||||
|
|
||||||
if (bearer.isEmpty()) {
|
if (bearer.isEmpty()) {
|
||||||
|
@ -252,28 +252,17 @@ void GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QS
|
||||||
param_obj["ids"] = QJsonArray::fromStringList(custom_ids);
|
param_obj["ids"] = QJsonArray::fromStringList(custom_ids);
|
||||||
|
|
||||||
QJsonDocument param_doc(param_obj);
|
QJsonDocument param_doc(param_obj);
|
||||||
|
QByteArray output;
|
||||||
|
|
||||||
// We send this batch.
|
NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
||||||
if (async) {
|
timeout,
|
||||||
NetworkFactory::performAsyncNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
||||||
timeout,
|
output,
|
||||||
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
QNetworkAccessManager::Operation::PostOperation,
|
||||||
QNetworkAccessManager::Operation::PostOperation,
|
headers);
|
||||||
headers);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QByteArray output;
|
|
||||||
|
|
||||||
NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
|
||||||
timeout,
|
|
||||||
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
|
||||||
output,
|
|
||||||
QNetworkAccessManager::Operation::PostOperation,
|
|
||||||
headers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GmailNetworkFactory::markMessagesStarred(RootItem::Importance importance, const QStringList& custom_ids, bool async) {
|
void GmailNetworkFactory::markMessagesStarred(RootItem::Importance importance, const QStringList& custom_ids) {
|
||||||
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
||||||
|
|
||||||
if (bearer.isEmpty()) {
|
if (bearer.isEmpty()) {
|
||||||
|
@ -305,25 +294,14 @@ void GmailNetworkFactory::markMessagesStarred(RootItem::Importance importance, c
|
||||||
param_obj["ids"] = QJsonArray::fromStringList(custom_ids);
|
param_obj["ids"] = QJsonArray::fromStringList(custom_ids);
|
||||||
|
|
||||||
QJsonDocument param_doc(param_obj);
|
QJsonDocument param_doc(param_obj);
|
||||||
|
QByteArray output;
|
||||||
|
|
||||||
// We send this batch.
|
NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
||||||
if (async) {
|
timeout,
|
||||||
NetworkFactory::performAsyncNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
||||||
timeout,
|
output,
|
||||||
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
QNetworkAccessManager::Operation::PostOperation,
|
||||||
QNetworkAccessManager::Operation::PostOperation,
|
headers);
|
||||||
headers);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QByteArray output;
|
|
||||||
|
|
||||||
NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
|
|
||||||
timeout,
|
|
||||||
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
|
|
||||||
output,
|
|
||||||
QNetworkAccessManager::Operation::PostOperation,
|
|
||||||
headers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GmailNetworkFactory::onTokensError(const QString& error, const QString& error_description) {
|
void GmailNetworkFactory::onTokensError(const QString& error, const QString& error_description) {
|
||||||
|
|
|
@ -41,8 +41,8 @@ class GmailNetworkFactory : public QObject {
|
||||||
Downloader* downloadAttachment(const QString& msg_id, const QString& attachment_id);
|
Downloader* downloadAttachment(const QString& msg_id, const QString& attachment_id);
|
||||||
|
|
||||||
QList<Message> messages(const QString& stream_id, Feed::Status& error);
|
QList<Message> messages(const QString& stream_id, Feed::Status& error);
|
||||||
void markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids, bool async = true);
|
void markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids);
|
||||||
void markMessagesStarred(RootItem::Importance importance, const QStringList& custom_ids, bool async = true);
|
void markMessagesStarred(RootItem::Importance importance, const QStringList& custom_ids);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTokensError(const QString& error, const QString& error_description);
|
void onTokensError(const QString& error, const QString& error_description);
|
||||||
|
|
|
@ -159,7 +159,7 @@ void InoreaderServiceRoot::saveAllCachedData() {
|
||||||
QStringList ids = i.value();
|
QStringList ids = i.value();
|
||||||
|
|
||||||
if (!ids.isEmpty()) {
|
if (!ids.isEmpty()) {
|
||||||
network()->markMessagesRead(key, ids, false);
|
network()->markMessagesRead(key, ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ void InoreaderServiceRoot::saveAllCachedData() {
|
||||||
custom_ids.append(msg.m_customId);
|
custom_ids.append(msg.m_customId);
|
||||||
}
|
}
|
||||||
|
|
||||||
network()->markMessagesStarred(key, custom_ids, false);
|
network()->markMessagesStarred(key, custom_ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ void InoreaderServiceRoot::saveAllCachedData() {
|
||||||
QStringList messages = k.value();
|
QStringList messages = k.value();
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
network()->editLabels(label_custom_id, true, messages, false);
|
network()->editLabels(label_custom_id, true, messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ void InoreaderServiceRoot::saveAllCachedData() {
|
||||||
QStringList messages = l.value();
|
QStringList messages = l.value();
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
network()->editLabels(label_custom_id, false, messages, false);
|
network()->editLabels(label_custom_id, false, messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ QList<Message> InoreaderNetworkFactory::messages(ServiceRoot* root, const QStrin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InoreaderNetworkFactory::editLabels(const QString& state, bool assign, const QStringList& msg_custom_ids, bool async) {
|
void InoreaderNetworkFactory::editLabels(const QString& state, bool assign, const QStringList& msg_custom_ids) {
|
||||||
QString target_url = INOREADER_API_EDIT_TAG;
|
QString target_url = INOREADER_API_EDIT_TAG;
|
||||||
|
|
||||||
if (assign) {
|
if (assign) {
|
||||||
|
@ -219,11 +219,7 @@ void InoreaderNetworkFactory::editLabels(const QString& state, bool assign, cons
|
||||||
QRegularExpression regex_short_id(QSL("[0-9a-zA-Z]+$"));
|
QRegularExpression regex_short_id(QSL("[0-9a-zA-Z]+$"));
|
||||||
|
|
||||||
for (const QString& id : msg_custom_ids) {
|
for (const QString& id : msg_custom_ids) {
|
||||||
QString simplified_id = regex_short_id.match(id).captured();
|
trimmed_ids.append(QString("i=") + id);
|
||||||
auto numeric_id = simplified_id.toLongLong(nullptr, 16);
|
|
||||||
QString decimal_id = QString::number(numeric_id);
|
|
||||||
|
|
||||||
trimmed_ids.append(QString("i=") + decimal_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList working_subset; working_subset.reserve(std::min(200, trimmed_ids.size()));
|
QStringList working_subset; working_subset.reserve(std::min(200, trimmed_ids.size()));
|
||||||
|
@ -231,7 +227,7 @@ void InoreaderNetworkFactory::editLabels(const QString& state, bool assign, cons
|
||||||
|
|
||||||
// Now, we perform messages update in batches (max 200 messages per batch).
|
// Now, we perform messages update in batches (max 200 messages per batch).
|
||||||
while (!trimmed_ids.isEmpty()) {
|
while (!trimmed_ids.isEmpty()) {
|
||||||
// We take 200 IDs.
|
// We take 50 IDs.
|
||||||
for (int i = 0; i < 50 && !trimmed_ids.isEmpty(); i++) {
|
for (int i = 0; i < 50 && !trimmed_ids.isEmpty(); i++) {
|
||||||
working_subset.append(trimmed_ids.takeFirst());
|
working_subset.append(trimmed_ids.takeFirst());
|
||||||
}
|
}
|
||||||
|
@ -239,35 +235,26 @@ void InoreaderNetworkFactory::editLabels(const QString& state, bool assign, cons
|
||||||
QString batch_final_url = target_url + working_subset.join(QL1C('&'));
|
QString batch_final_url = target_url + working_subset.join(QL1C('&'));
|
||||||
|
|
||||||
// We send this batch.
|
// We send this batch.
|
||||||
if (async) {
|
QByteArray output;
|
||||||
NetworkFactory::performAsyncNetworkOperation(batch_final_url,
|
|
||||||
timeout,
|
|
||||||
QByteArray(),
|
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
|
||||||
headers);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QByteArray output;
|
|
||||||
|
|
||||||
NetworkFactory::performNetworkOperation(batch_final_url,
|
NetworkFactory::performNetworkOperation(batch_final_url,
|
||||||
timeout,
|
timeout,
|
||||||
QByteArray(),
|
QByteArray(),
|
||||||
output,
|
output,
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
QNetworkAccessManager::Operation::GetOperation,
|
||||||
headers);
|
headers);
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup for next batch.
|
// Cleanup for next batch.
|
||||||
working_subset.clear();
|
working_subset.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InoreaderNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QStringList& msg_custom_ids, bool async) {
|
void InoreaderNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QStringList& msg_custom_ids) {
|
||||||
editLabels(INOREADER_FULL_STATE_READ, status == RootItem::ReadStatus::Read, msg_custom_ids, async);
|
editLabels(INOREADER_FULL_STATE_READ, status == RootItem::ReadStatus::Read, msg_custom_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InoreaderNetworkFactory::markMessagesStarred(RootItem::Importance importance, const QStringList& msg_custom_ids, bool async) {
|
void InoreaderNetworkFactory::markMessagesStarred(RootItem::Importance importance, const QStringList& msg_custom_ids) {
|
||||||
editLabels(INOREADER_FULL_STATE_IMPORTANT, importance == RootItem::Importance::Important, msg_custom_ids, async);
|
editLabels(INOREADER_FULL_STATE_IMPORTANT, importance == RootItem::Importance::Important, msg_custom_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InoreaderNetworkFactory::onTokensError(const QString& error, const QString& error_description) {
|
void InoreaderNetworkFactory::onTokensError(const QString& error, const QString& error_description) {
|
||||||
|
|
|
@ -42,10 +42,10 @@ class InoreaderNetworkFactory : public QObject {
|
||||||
|
|
||||||
QList<Message> messages(ServiceRoot* root, const QString& stream_id, Feed::Status& error);
|
QList<Message> messages(ServiceRoot* root, const QString& stream_id, Feed::Status& error);
|
||||||
|
|
||||||
void editLabels(const QString& state, bool assign, const QStringList& msg_custom_ids, bool async = true);
|
void editLabels(const QString& state, bool assign, const QStringList& msg_custom_ids);
|
||||||
|
|
||||||
void markMessagesRead(RootItem::ReadStatus status, const QStringList& msg_custom_ids, bool async = true);
|
void markMessagesRead(RootItem::ReadStatus status, const QStringList& msg_custom_ids);
|
||||||
void markMessagesStarred(RootItem::Importance importance, const QStringList& msg_custom_ids, bool async = true);
|
void markMessagesStarred(RootItem::Importance importance, const QStringList& msg_custom_ids);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTokensError(const QString& error, const QString& error_description);
|
void onTokensError(const QString& error, const QString& error_description);
|
||||||
|
|
|
@ -312,7 +312,7 @@ QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_i
|
||||||
return (m_lastError = network_reply.first);
|
return (m_lastError = network_reply.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids, bool async) {
|
void OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids) {
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
QJsonArray ids;
|
QJsonArray ids;
|
||||||
QString final_url;
|
QString final_url;
|
||||||
|
@ -335,30 +335,20 @@ void OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const
|
||||||
headers << QPair<QByteArray, QByteArray>(HTTP_HEADERS_CONTENT_TYPE, OWNCLOUD_CONTENT_TYPE_JSON);
|
headers << QPair<QByteArray, QByteArray>(HTTP_HEADERS_CONTENT_TYPE, OWNCLOUD_CONTENT_TYPE_JSON);
|
||||||
headers << NetworkFactory::generateBasicAuthHeader(m_authUsername, m_authPassword);
|
headers << NetworkFactory::generateBasicAuthHeader(m_authUsername, m_authPassword);
|
||||||
|
|
||||||
if (async) {
|
QByteArray output;
|
||||||
NetworkFactory::performAsyncNetworkOperation(final_url,
|
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
|
||||||
QJsonDocument(json).toJson(QJsonDocument::Compact),
|
|
||||||
QNetworkAccessManager::PutOperation,
|
|
||||||
headers);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QByteArray output;
|
|
||||||
|
|
||||||
NetworkFactory::performNetworkOperation(final_url,
|
NetworkFactory::performNetworkOperation(final_url,
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
qApp->settings()->value(GROUP(Feeds),
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||||
QJsonDocument(json).toJson(QJsonDocument::Compact),
|
QJsonDocument(json).toJson(QJsonDocument::Compact),
|
||||||
output,
|
output,
|
||||||
QNetworkAccessManager::PutOperation,
|
QNetworkAccessManager::PutOperation,
|
||||||
headers);
|
headers);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance,
|
void OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance,
|
||||||
const QStringList& feed_ids,
|
const QStringList& feed_ids,
|
||||||
const QStringList& guid_hashes, bool async) {
|
const QStringList& guid_hashes) {
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
QJsonArray ids;
|
QJsonArray ids;
|
||||||
QString final_url;
|
QString final_url;
|
||||||
|
@ -385,25 +375,15 @@ void OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance importance
|
||||||
headers << QPair<QByteArray, QByteArray>(HTTP_HEADERS_CONTENT_TYPE, OWNCLOUD_CONTENT_TYPE_JSON);
|
headers << QPair<QByteArray, QByteArray>(HTTP_HEADERS_CONTENT_TYPE, OWNCLOUD_CONTENT_TYPE_JSON);
|
||||||
headers << NetworkFactory::generateBasicAuthHeader(m_authUsername, m_authPassword);
|
headers << NetworkFactory::generateBasicAuthHeader(m_authUsername, m_authPassword);
|
||||||
|
|
||||||
if (async) {
|
QByteArray output;
|
||||||
NetworkFactory::performAsyncNetworkOperation(final_url,
|
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
|
||||||
QJsonDocument(json).toJson(QJsonDocument::Compact),
|
|
||||||
QNetworkAccessManager::PutOperation,
|
|
||||||
headers);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QByteArray output;
|
|
||||||
|
|
||||||
NetworkFactory::performNetworkOperation(final_url,
|
NetworkFactory::performNetworkOperation(final_url,
|
||||||
qApp->settings()->value(GROUP(Feeds),
|
qApp->settings()->value(GROUP(Feeds),
|
||||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||||
QJsonDocument(json).toJson(QJsonDocument::Compact),
|
QJsonDocument(json).toJson(QJsonDocument::Compact),
|
||||||
output,
|
output,
|
||||||
QNetworkAccessManager::PutOperation,
|
QNetworkAccessManager::PutOperation,
|
||||||
headers);
|
headers);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int OwnCloudNetworkFactory::batchSize() const {
|
int OwnCloudNetworkFactory::batchSize() const {
|
||||||
|
|
|
@ -96,9 +96,8 @@ class OwnCloudNetworkFactory {
|
||||||
|
|
||||||
// Misc methods.
|
// Misc methods.
|
||||||
QNetworkReply::NetworkError triggerFeedUpdate(int feed_id);
|
QNetworkReply::NetworkError triggerFeedUpdate(int feed_id);
|
||||||
void markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids, bool async = true);
|
void markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids);
|
||||||
void markMessagesStarred(RootItem::Importance importance, const QStringList& feed_ids,
|
void markMessagesStarred(RootItem::Importance importance, const QStringList& feed_ids, const QStringList& guid_hashes);
|
||||||
const QStringList& guid_hashes, bool async = true);
|
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
|
@ -91,7 +91,7 @@ void OwnCloudServiceRoot::saveAllCachedData() {
|
||||||
QStringList ids = i.value();
|
QStringList ids = i.value();
|
||||||
|
|
||||||
if (!ids.isEmpty()) {
|
if (!ids.isEmpty()) {
|
||||||
network()->markMessagesRead(key, ids, false);
|
network()->markMessagesRead(key, ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void OwnCloudServiceRoot::saveAllCachedData() {
|
||||||
guid_hashes.append(msg.m_customHash);
|
guid_hashes.append(msg.m_customHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
network()->markMessagesStarred(key, feed_ids, guid_hashes, false);
|
network()->markMessagesStarred(key, feed_ids, guid_hashes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,10 +332,7 @@ TtRssResponse TtRssNetworkFactory::setArticleLabel(const QStringList& article_id
|
||||||
|
|
||||||
TtRssUpdateArticleResponse TtRssNetworkFactory::updateArticles(const QStringList& ids,
|
TtRssUpdateArticleResponse TtRssNetworkFactory::updateArticles(const QStringList& ids,
|
||||||
UpdateArticle::OperatingField field,
|
UpdateArticle::OperatingField field,
|
||||||
UpdateArticle::Mode mode,
|
UpdateArticle::Mode mode) {
|
||||||
bool async) {
|
|
||||||
Q_UNUSED(async)
|
|
||||||
|
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
|
||||||
json["op"] = QSL("updateArticle");
|
json["op"] = QSL("updateArticle");
|
||||||
|
|
|
@ -161,8 +161,9 @@ class TtRssNetworkFactory {
|
||||||
|
|
||||||
TtRssResponse setArticleLabel(const QStringList& article_ids, const QString& label_custom_id, bool assign);
|
TtRssResponse setArticleLabel(const QStringList& article_ids, const QString& label_custom_id, bool assign);
|
||||||
|
|
||||||
TtRssUpdateArticleResponse updateArticles(const QStringList& ids, UpdateArticle::OperatingField field,
|
TtRssUpdateArticleResponse updateArticles(const QStringList& ids,
|
||||||
UpdateArticle::Mode mode, bool async = true);
|
UpdateArticle::OperatingField field,
|
||||||
|
UpdateArticle::Mode mode);
|
||||||
|
|
||||||
TtRssSubscribeToFeedResponse subscribeToFeed(const QString& url, int category_id, bool protectd = false,
|
TtRssSubscribeToFeedResponse subscribeToFeed(const QString& url, int category_id, bool protectd = false,
|
||||||
const QString& username = QString(), const QString& password = QString());
|
const QString& username = QString(), const QString& password = QString());
|
||||||
|
|
|
@ -132,8 +132,7 @@ void TtRssServiceRoot::saveAllCachedData() {
|
||||||
UpdateArticle::OperatingField::Unread,
|
UpdateArticle::OperatingField::Unread,
|
||||||
key == RootItem::ReadStatus::Unread
|
key == RootItem::ReadStatus::Unread
|
||||||
? UpdateArticle::Mode::SetToTrue
|
? UpdateArticle::Mode::SetToTrue
|
||||||
: UpdateArticle::Mode::SetToFalse,
|
: UpdateArticle::Mode::SetToFalse);
|
||||||
false);
|
|
||||||
|
|
||||||
if (network()->lastError() != QNetworkReply::NetworkError::NoError || res.hasError()) {
|
if (network()->lastError() != QNetworkReply::NetworkError::NoError || res.hasError()) {
|
||||||
addMessageStatesToCache(ids, key);
|
addMessageStatesToCache(ids, key);
|
||||||
|
@ -155,8 +154,7 @@ void TtRssServiceRoot::saveAllCachedData() {
|
||||||
UpdateArticle::OperatingField::Starred,
|
UpdateArticle::OperatingField::Starred,
|
||||||
key == RootItem::Importance::Important
|
key == RootItem::Importance::Important
|
||||||
? UpdateArticle::Mode::SetToTrue
|
? UpdateArticle::Mode::SetToTrue
|
||||||
: UpdateArticle::Mode::SetToFalse,
|
: UpdateArticle::Mode::SetToFalse);
|
||||||
false);
|
|
||||||
|
|
||||||
if (network()->lastError() != QNetworkReply::NetworkError::NoError || res.hasError()) {
|
if (network()->lastError() != QNetworkReply::NetworkError::NoError || res.hasError()) {
|
||||||
addMessageStatesToCache(messages, key);
|
addMessageStatesToCache(messages, key);
|
||||||
|
|
Loading…
Add table
Reference in a new issue