Bound batch size.
This commit is contained in:
parent
0fbe57b921
commit
e5e12c30c9
@ -1 +1 @@
|
||||
Subproject commit d44aacc99fdc997648c924f0d5444566164f142e
|
||||
Subproject commit e9833a2e45d8d3241f662d3a03ed19d3446386ce
|
@ -22,6 +22,7 @@
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "services/abstract/category.h"
|
||||
#include "services/inoreader/definitions.h"
|
||||
#include "services/owncloud/definitions.h"
|
||||
#include "services/owncloud/network/owncloudnetworkfactory.h"
|
||||
#include "services/owncloud/owncloudfeed.h"
|
||||
@ -1585,7 +1586,7 @@ bool DatabaseQueries::overwriteInoreaderAccount(QSqlDatabase db, const QString&
|
||||
query.bindValue(QSL(":access_token"), access_token);
|
||||
query.bindValue(QSL(":refresh_token"), refresh_token);
|
||||
query.bindValue(QSL(":id"), account_id);
|
||||
query.bindValue(QSL(":msg_limit"), batch_size <= 0 ? UNLIMITED_BATCH_SIZE : batch_size);
|
||||
query.bindValue(QSL(":msg_limit"), batch_size <= 0 ? INOREADER_DEFAULT_BATCH_SIZE : batch_size);
|
||||
|
||||
if (query.exec()) {
|
||||
return true;
|
||||
@ -1606,7 +1607,7 @@ bool DatabaseQueries::createInoreaderAccount(QSqlDatabase db, int id_to_assign,
|
||||
q.bindValue(QSL(":username"), username);
|
||||
q.bindValue(QSL(":access_token"), access_token);
|
||||
q.bindValue(QSL(":refresh_token"), refresh_token);
|
||||
q.bindValue(QSL(":msg_limit"), batch_size <= 0 ? UNLIMITED_BATCH_SIZE : batch_size);
|
||||
q.bindValue(QSL(":msg_limit"), batch_size <= 0 ? INOREADER_DEFAULT_BATCH_SIZE : batch_size);
|
||||
|
||||
if (q.exec()) {
|
||||
return true;
|
||||
|
@ -27,7 +27,8 @@
|
||||
#define INOREADER_REFRESH_TOKEN_KEY "refresh_token"
|
||||
#define INOREADER_ACCESS_TOKEN_KEY "access_token"
|
||||
#define INOREADER_DEFAULT_BATCH_SIZE 100
|
||||
#define INOREADER_UNLIMITED_BATCH_SIZE -1
|
||||
#define INOREADER_MAX_BATCH_SIZE 999
|
||||
#define INOREADER_MIN_BATCH_SIZE 20
|
||||
|
||||
#define INOREADER_API_FEED_CONTENTS "https://www.inoreader.com/reader/api/0/stream/contents"
|
||||
#define INOREADER_API_LIST_LABELS "https://www.inoreader.com/reader/api/0/tag/list"
|
||||
|
@ -39,21 +39,14 @@ FormEditInoreaderAccount::FormEditInoreaderAccount(QWidget* parent) : QDialog(pa
|
||||
setTabOrder(m_ui.m_spinLimitMessages, m_ui.m_btnTestSetup);
|
||||
setTabOrder(m_ui.m_btnTestSetup, m_ui.m_buttonBox);
|
||||
|
||||
connect(m_ui.m_spinLimitMessages, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int value) {
|
||||
if (value <= 0) {
|
||||
m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("= unlimited"));
|
||||
}
|
||||
else {
|
||||
m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("messages"));
|
||||
}
|
||||
});
|
||||
connect(m_ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &FormEditInoreaderAccount::checkUsername);
|
||||
connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditInoreaderAccount::testSetup);
|
||||
connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormEditInoreaderAccount::onClickedOk);
|
||||
connect(m_ui.m_buttonBox, &QDialogButtonBox::rejected, this, &FormEditInoreaderAccount::onClickedCancel);
|
||||
|
||||
m_ui.m_spinLimitMessages->setValue(INOREADER_DEFAULT_BATCH_SIZE);
|
||||
m_ui.m_spinLimitMessages->setMinimum(INOREADER_UNLIMITED_BATCH_SIZE);
|
||||
m_ui.m_spinLimitMessages->setMinimum(INOREADER_MIN_BATCH_SIZE);
|
||||
m_ui.m_spinLimitMessages->setMaximum(INOREADER_MAX_BATCH_SIZE);
|
||||
|
||||
checkUsername(m_ui.m_txtUsername->lineEdit()->text());
|
||||
}
|
||||
|
@ -39,16 +39,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> = unlimited</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>-1</number>
|
||||
<string> message(s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -101,7 +101,23 @@ RootItem* InoreaderNetworkFactory::feedsCategories(bool obtain_icons) {
|
||||
return decodeFeedCategoriesData(category_data, feed_data, obtain_icons);
|
||||
}
|
||||
|
||||
QList<Message> InoreaderNetworkFactory::messages(const QString& stream_id, bool* is_error) {}
|
||||
QList<Message> InoreaderNetworkFactory::messages(const QString& stream_id, bool* is_error) {
|
||||
QList<Message> messages;
|
||||
Downloader downloader;
|
||||
QEventLoop loop;
|
||||
QString target_url = INOREADER_API_FEED_CONTENTS;
|
||||
|
||||
target_url += QSL("/") + QUrl::toPercentEncoding(stream_id) + QString("/?n=").arg(batchSize());
|
||||
|
||||
downloader.appendRawHeader(QString("Authorization").toLocal8Bit(), m_oauth2->bearer().toLocal8Bit());
|
||||
|
||||
// We need to quit event loop when the download finishes.
|
||||
connect(&downloader, &Downloader::completed, &loop, &QEventLoop::quit);
|
||||
downloader.manipulateData(INOREADER_API_FEED_CONTENTS, QNetworkAccessManager::Operation::GetOperation);
|
||||
loop.exec();
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categories, const QString& feeds, bool obtain_icons) {
|
||||
RootItem* parent = new RootItem();
|
||||
|
Loading…
x
Reference in New Issue
Block a user