msgs limitting for ttrss

This commit is contained in:
Martin Rotter 2021-04-09 21:31:46 +02:00 committed by Martin Rotter
parent 642690c844
commit c762f7bf4f
7 changed files with 23 additions and 7 deletions

@ -1 +1 @@
Subproject commit 47f4125753452eff8800dbd6600c5a05540b15d9
Subproject commit 9c10723bfbaf6cb85107d6ee16e0324e9e487749

View File

@ -14,6 +14,7 @@
#define TTRSS_INCORRECT_USAGE "INCORRECT_USAGE" // Given "op" was used with bad parameters.
// Limitations
#define TTRSS_DEFAULT_MESSAGES 100
#define TTRSS_MAX_MESSAGES 200
// General return status codes.

View File

@ -27,6 +27,7 @@ void FormEditTtRssAccount::apply() {
account<TtRssServiceRoot>()->network()->setAuthIsUsed(m_details->m_ui.m_gbHttpAuthentication->isChecked());
account<TtRssServiceRoot>()->network()->setAuthUsername(m_details->m_ui.m_txtHttpUsername->lineEdit()->text());
account<TtRssServiceRoot>()->network()->setAuthPassword(m_details->m_ui.m_txtHttpPassword->lineEdit()->text());
account<TtRssServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
account<TtRssServiceRoot>()->network()->setForceServerSideUpdate(m_details->m_ui.m_checkServerSideUpdate->isChecked());
account<TtRssServiceRoot>()->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_checkDownloadOnlyUnreadMessages->isChecked());
@ -50,6 +51,7 @@ void FormEditTtRssAccount::loadAccountData() {
m_details->m_ui.m_txtUsername->lineEdit()->setText(existing_root->network()->username());
m_details->m_ui.m_txtPassword->lineEdit()->setText(existing_root->network()->password());
m_details->m_ui.m_txtUrl->lineEdit()->setText(existing_root->network()->url());
m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize());
m_details->m_ui.m_checkServerSideUpdate->setChecked(existing_root->network()->forceServerSideUpdate());
m_details->m_ui.m_checkDownloadOnlyUnreadMessages->setChecked(existing_root->network()->downloadOnlyUnreadMessages());
}

View File

@ -73,6 +73,7 @@ void TtRssAccountDetails::performTest(const QNetworkProxy& proxy) {
factory.setAuthUsername(m_ui.m_txtHttpUsername->lineEdit()->text());
factory.setAuthPassword(m_ui.m_txtHttpPassword->lineEdit()->text());
factory.setForceServerSideUpdate(m_ui.m_checkServerSideUpdate->isChecked());
factory.setBatchSize(m_ui.m_spinLimitMessages->value());
TtRssLoginResponse result = factory.login(proxy);

View File

@ -22,8 +22,8 @@
#include <QVariant>
TtRssNetworkFactory::TtRssNetworkFactory()
: m_bareUrl(QString()), m_fullUrl(QString()), m_username(QString()), m_password(QString()), m_forceServerSideUpdate(false),
m_authIsUsed(false), m_authUsername(QString()), m_authPassword(QString()), m_sessionId(QString()),
: m_bareUrl(QString()), m_fullUrl(QString()), m_username(QString()), m_password(QString()), m_batchSize(TTRSS_DEFAULT_MESSAGES),
m_forceServerSideUpdate(false), m_authIsUsed(false), m_authUsername(QString()), m_authPassword(QString()), m_sessionId(QString()),
m_lastError(QNetworkReply::NoError) {}
QString TtRssNetworkFactory::url() const {
@ -550,6 +550,14 @@ TtRssUnsubscribeFeedResponse TtRssNetworkFactory::unsubscribeFeed(int feed_id, c
return result;
}
int TtRssNetworkFactory::batchSize() const {
return m_batchSize;
}
void TtRssNetworkFactory::setBatchSize(int batch_size) {
m_batchSize = batch_size;
}
bool TtRssNetworkFactory::downloadOnlyUnreadMessages() const {
return m_downloadOnlyUnreadMessages;
}

View File

@ -175,11 +175,15 @@ class TtRssNetworkFactory {
TtRssUnsubscribeFeedResponse unsubscribeFeed(int feed_id, const QNetworkProxy& proxy);
int batchSize() const;
void setBatchSize(int batch_size);
private:
QString m_bareUrl;
QString m_fullUrl;
QString m_username;
QString m_password;
int m_batchSize;
bool m_forceServerSideUpdate;
bool m_downloadOnlyUnreadMessages;
bool m_authIsUsed;

View File

@ -195,6 +195,7 @@ QVariantHash TtRssServiceRoot::customDatabaseData() const {
data["auth_password"] = TextFactory::encrypt(m_network->authPassword());
data["url"] = m_network->url();
data["force_update"] = m_network->forceServerSideUpdate();
data["batch_size"] = m_network->batchSize();
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
return data;
@ -208,6 +209,7 @@ void TtRssServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
m_network->setAuthPassword(TextFactory::decrypt(data["auth_password"].toString()));
m_network->setUrl(data["url"].toString());
m_network->setForceServerSideUpdate(data["force_update"].toBool());
m_network->setBatchSize(data["batch_size"].toInt());
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
}
@ -216,9 +218,7 @@ QList<Message> TtRssServiceRoot::obtainNewMessages(const QList<Feed*>& feeds, bo
for (Feed* feed : feeds) {
int newly_added_messages = 0;
// TODO: pokračovat, přidat batchSize() a řešit misto limit.
int limit = TTRSS_MAX_MESSAGES;
int limit = network()->batchSize() <= 0 ? TTRSS_MAX_MESSAGES : network()->batchSize();
int skip = 0;
do {
@ -241,7 +241,7 @@ QList<Message> TtRssServiceRoot::obtainNewMessages(const QList<Feed*>& feeds, bo
skip += newly_added_messages;
}
}
while (newly_added_messages > 0);
while (newly_added_messages > 0 && (network()->batchSize() <= 0 || messages.size() < network()->batchSize()));
}
return messages;