download unread only for greader too

This commit is contained in:
Martin Rotter 2021-04-09 10:30:30 +02:00
parent f75d848548
commit 1415da7d96
5 changed files with 35 additions and 6 deletions

View file

@ -17,7 +17,7 @@
GreaderNetwork::GreaderNetwork(QObject* parent) GreaderNetwork::GreaderNetwork(QObject* parent)
: QObject(parent), m_service(GreaderServiceRoot::Service::FreshRss), m_username(QString()), m_password(QString()), : QObject(parent), m_service(GreaderServiceRoot::Service::FreshRss), m_username(QString()), m_password(QString()),
m_baseUrl(QString()), m_batchSize(GREADER_DEFAULT_BATCH_SIZE) { m_baseUrl(QString()), m_batchSize(GREADER_DEFAULT_BATCH_SIZE), m_downloadOnlyUnreadMessages(false) {
clearCredentials(); clearCredentials();
} }
@ -117,6 +117,10 @@ QList<Message> GreaderNetwork::streamContents(ServiceRoot* root, const QString&
return {}; return {};
} }
if (downloadOnlyUnreadMessages()) {
full_url += QSL("&xt=%1").arg(GREADER_API_FULL_STATE_READ);
}
QByteArray output_stream; QByteArray output_stream;
auto result_stream = NetworkFactory::performNetworkOperation(full_url, auto result_stream = NetworkFactory::performNetworkOperation(full_url,
timeout, timeout,
@ -617,3 +621,11 @@ QString GreaderNetwork::generateFullUrl(GreaderNetwork::Operations operation) co
return sanitizedBaseUrl(); return sanitizedBaseUrl();
} }
} }
bool GreaderNetwork::downloadOnlyUnreadMessages() const {
return m_downloadOnlyUnreadMessages;
}
void GreaderNetwork::setDownloadOnlyUnreadMessages(bool download_only_unread) {
m_downloadOnlyUnreadMessages = download_only_unread;
}

View file

@ -65,6 +65,9 @@ class GreaderNetwork : public QObject {
static QString serviceToString(GreaderServiceRoot::Service service); static QString serviceToString(GreaderServiceRoot::Service service);
bool downloadOnlyUnreadMessages() const;
void setDownloadOnlyUnreadMessages(bool download_only_unread);
private: private:
QPair<QByteArray, QByteArray> authHeader() const; QPair<QByteArray, QByteArray> authHeader() const;
@ -83,6 +86,7 @@ class GreaderNetwork : public QObject {
QString m_password; QString m_password;
QString m_baseUrl; QString m_baseUrl;
int m_batchSize; int m_batchSize;
bool m_downloadOnlyUnreadMessages;
QString m_authSid; QString m_authSid;
QString m_authAuth; QString m_authAuth;
QString m_authToken; QString m_authToken;

View file

@ -42,6 +42,7 @@ QVariantHash GreaderServiceRoot::customDatabaseData() const {
data["password"] = TextFactory::encrypt(m_network->password()); data["password"] = TextFactory::encrypt(m_network->password());
data["url"] = m_network->baseUrl(); data["url"] = m_network->baseUrl();
data["batch_size"] = m_network->batchSize(); data["batch_size"] = m_network->batchSize();
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
return data; return data;
} }
@ -52,6 +53,7 @@ void GreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
m_network->setPassword(TextFactory::decrypt(data["password"].toString())); m_network->setPassword(TextFactory::decrypt(data["password"].toString()));
m_network->setBaseUrl(data["url"].toString()); m_network->setBaseUrl(data["url"].toString());
m_network->setBatchSize(data["batch_size"].toInt()); m_network->setBatchSize(data["batch_size"].toInt());
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
} }
QList<Message> GreaderServiceRoot::obtainNewMessages(const QList<Feed*>& feeds, bool* error_during_obtaining) { QList<Message> GreaderServiceRoot::obtainNewMessages(const QList<Feed*>& feeds, bool* error_during_obtaining) {

View file

@ -27,6 +27,7 @@ void FormEditGreaderAccount::apply() {
account<GreaderServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text()); account<GreaderServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
account<GreaderServiceRoot>()->network()->setPassword(m_details->m_ui.m_txtPassword->lineEdit()->text()); account<GreaderServiceRoot>()->network()->setPassword(m_details->m_ui.m_txtPassword->lineEdit()->text());
account<GreaderServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value()); account<GreaderServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
account<GreaderServiceRoot>()->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_cbDownloadOnlyUnreadMessages->isChecked());
account<GreaderServiceRoot>()->network()->setService(m_details->service()); account<GreaderServiceRoot>()->network()->setService(m_details->service());
account<GreaderServiceRoot>()->saveAccountDataToDatabase(); account<GreaderServiceRoot>()->saveAccountDataToDatabase();
@ -48,6 +49,7 @@ void FormEditGreaderAccount::loadAccountData() {
m_details->m_ui.m_txtPassword->lineEdit()->setText(existing_root->network()->password()); m_details->m_ui.m_txtPassword->lineEdit()->setText(existing_root->network()->password());
m_details->m_ui.m_txtUrl->lineEdit()->setText(existing_root->network()->baseUrl()); m_details->m_ui.m_txtUrl->lineEdit()->setText(existing_root->network()->baseUrl());
m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize()); m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize());
m_details->m_ui.m_cbDownloadOnlyUnreadMessages->setChecked(existing_root->network()->downloadOnlyUnreadMessages());
} }
void FormEditGreaderAccount::performTest() { void FormEditGreaderAccount::performTest() {

View file

@ -34,7 +34,7 @@
<item row="2" column="1"> <item row="2" column="1">
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/> <widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
@ -51,7 +51,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="7" column="0" colspan="2">
<widget class="QLabel" name="m_lblLimitMessages"> <widget class="QLabel" name="m_lblLimitMessages">
<property name="text"> <property name="text">
<string/> <string/>
@ -61,7 +61,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0" colspan="2"> <item row="8" column="0" colspan="2">
<widget class="QGroupBox" name="m_gbAuthentication"> <widget class="QGroupBox" name="m_gbAuthentication">
<property name="toolTip"> <property name="toolTip">
<string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string> <string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string>
@ -112,7 +112,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="2"> <item row="9" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QPushButton" name="m_btnTestSetup"> <widget class="QPushButton" name="m_btnTestSetup">
@ -136,7 +136,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="9" column="0" colspan="2"> <item row="10" column="0" colspan="2">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -149,6 +149,13 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbDownloadOnlyUnreadMessages">
<property name="text">
<string>Download only unread messages</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
@ -171,9 +178,11 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>m_cbDownloadOnlyUnreadMessages</tabstop>
<tabstop>m_spinLimitMessages</tabstop> <tabstop>m_spinLimitMessages</tabstop>
<tabstop>m_checkShowPassword</tabstop> <tabstop>m_checkShowPassword</tabstop>
<tabstop>m_btnTestSetup</tabstop> <tabstop>m_btnTestSetup</tabstop>
<tabstop>m_cmbService</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>