From d0154ca85996ffcc35a67f1b97b35f48db540b3c Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 27 Oct 2017 20:38:01 +0200 Subject: [PATCH] Fixed some clazy warning, gmail plugin now can mark msgs starred/read/unread. --- src/core/feeddownloader.cpp | 2 +- src/gui/dialogs/formmain.cpp | 8 +- src/gui/dialogs/formsettings.cpp | 2 +- src/gui/dialogs/formupdate.cpp | 2 +- src/gui/messagesview.cpp | 2 +- src/gui/searchtextwidget.cpp | 6 +- src/gui/settings/settingsbrowsermail.cpp | 2 +- src/gui/systemtrayicon.cpp | 2 +- src/gui/systemtrayicon.h | 6 +- src/miscellaneous/systemfactory.cpp | 2 +- src/network-web/downloadmanager.cpp | 2 + src/network-web/downloadmanager.h | 3 +- src/network-web/oauth2service.cpp | 15 +- src/services/gmail/definitions.h | 10 +- src/services/gmail/gmailserviceroot.cpp | 6 +- .../gmail/gui/formdownloadattachment.cpp | 7 +- .../gmail/network/gmailnetworkfactory.cpp | 166 +++++++----------- .../network/inoreadernetworkfactory.cpp | 2 +- .../owncloud/gui/formeditowncloudaccount.cpp | 2 +- 19 files changed, 103 insertions(+), 144 deletions(-) diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp index 3f08bb18a..49f1b592e 100755 --- a/src/core/feeddownloader.cpp +++ b/src/core/feeddownloader.cpp @@ -19,7 +19,7 @@ FeedDownloader::FeedDownloader(QObject* parent) m_results(FeedDownloadResults()), m_feedsUpdated(0), m_feedsUpdating(0), m_feedsOriginalCount(0) { qRegisterMetaType("FeedDownloadResults"); - m_threadPool->setMaxThreadCount(FEED_DOWNLOADER_MAX_THREADS); + m_threadPool->setMaxThreadCount(2); } FeedDownloader::~FeedDownloader() { diff --git a/src/gui/dialogs/formmain.cpp b/src/gui/dialogs/formmain.cpp index 1fb3ceeb6..472450bd3 100755 --- a/src/gui/dialogs/formmain.cpp +++ b/src/gui/dialogs/formmain.cpp @@ -615,24 +615,24 @@ void FormMain::createConnections() { connect(m_ui->m_actionSwitchStatusBar, &QAction::toggled, statusBar(), &StatusBar::setVisible); // Menu "Tools" connections. - connect(m_ui->m_actionSettings, &QAction::triggered, [this]() { + connect(m_ui->m_actionSettings, &QAction::triggered, this, [this]() { FormSettings(*this).exec(); }); connect(m_ui->m_actionDownloadManager, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::showDownloadManager); connect(m_ui->m_actionCleanupDatabase, &QAction::triggered, this, &FormMain::showDbCleanupAssistant); // Menu "Help" connections. - connect(m_ui->m_actionAboutGuard, &QAction::triggered, [this]() { + connect(m_ui->m_actionAboutGuard, &QAction::triggered, this, [this]() { FormAbout(this).exec(); }); - connect(m_ui->m_actionCheckForUpdates, &QAction::triggered, [this]() { + connect(m_ui->m_actionCheckForUpdates, &QAction::triggered, this, [this]() { FormUpdate(this).exec(); }); connect(m_ui->m_actionReportBug, &QAction::triggered, this, &FormMain::reportABug); connect(m_ui->m_actionDonate, &QAction::triggered, this, &FormMain::donate); connect(m_ui->m_actionDisplayWiki, &QAction::triggered, this, &FormMain::showWiki); - connect(m_ui->m_actionMessagePreviewEnabled, &QAction::toggled, [](bool enabled) { + connect(m_ui->m_actionMessagePreviewEnabled, &QAction::toggled, this, [](bool enabled) { qApp->settings()->setValue(GROUP(Messages), Messages::EnableMessagePreview, enabled); }); diff --git a/src/gui/dialogs/formsettings.cpp b/src/gui/dialogs/formsettings.cpp index 10ba14269..f580a241b 100755 --- a/src/gui/dialogs/formsettings.cpp +++ b/src/gui/dialogs/formsettings.cpp @@ -121,7 +121,7 @@ void FormSettings::addSettingsPanel(SettingsPanel* panel) { m_panels.append(panel); m_ui.m_stackedSettings->addWidget(panel); panel->loadSettings(); - connect(panel, &SettingsPanel::settingsChanged, [this]() { + connect(panel, &SettingsPanel::settingsChanged, this, [this]() { m_btnApply->setEnabled(true); }); } diff --git a/src/gui/dialogs/formupdate.cpp b/src/gui/dialogs/formupdate.cpp index 5015d0973..92ec1e115 100755 --- a/src/gui/dialogs/formupdate.cpp +++ b/src/gui/dialogs/formupdate.cpp @@ -54,7 +54,7 @@ bool FormUpdate::isSelfUpdateSupported() const { } void FormUpdate::checkForUpdates() { - connect(qApp->system(), &SystemFactory::updatesChecked, [this](QPair, QNetworkReply::NetworkError> update) { + connect(qApp->system(), &SystemFactory::updatesChecked, this, [this](QPair, QNetworkReply::NetworkError> update) { m_ui.m_buttonBox->setEnabled(true); disconnect(qApp->system(), &SystemFactory::updatesChecked, nullptr, nullptr); diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index db80754f8..53b1bf82b 100755 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -45,7 +45,7 @@ MessagesView::MessagesView(QWidget* parent) : QTreeView(parent), m_contextMenu(n setModel(m_proxyModel); setupAppearance(); header()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(header(), &QHeaderView::customContextMenuRequested, [=](const QPoint& point) { + connect(header(), &QHeaderView::customContextMenuRequested, this, [=](const QPoint& point) { TreeViewColumnsMenu mm(header()); mm.exec(header()->mapToGlobal(point)); }); diff --git a/src/gui/searchtextwidget.cpp b/src/gui/searchtextwidget.cpp index e0397e680..69c596842 100755 --- a/src/gui/searchtextwidget.cpp +++ b/src/gui/searchtextwidget.cpp @@ -15,13 +15,13 @@ SearchTextWidget::SearchTextWidget(QWidget* parent) : QWidget(parent) { connect(m_ui.m_btnClear, &QToolButton::clicked, m_ui.m_txtSearch, &QLineEdit::clear); connect(m_ui.m_txtSearch, &BaseLineEdit::textChanged, this, &SearchTextWidget::onTextChanged); - connect(m_ui.m_txtSearch, &BaseLineEdit::submitted, [this]() { + connect(m_ui.m_txtSearch, &BaseLineEdit::submitted, this, [this]() { emit searchForText(m_ui.m_txtSearch->text(), false); }); - connect(m_ui.m_btnSearchForward, &QToolButton::clicked, [this]() { + connect(m_ui.m_btnSearchForward, &QToolButton::clicked, this, [this]() { emit searchForText(m_ui.m_txtSearch->text(), false); }); - connect(m_ui.m_btnSearchBackward, &QToolButton::clicked, [this]() { + connect(m_ui.m_btnSearchBackward, &QToolButton::clicked, this, [this]() { emit searchForText(m_ui.m_txtSearch->text(), true); }); } diff --git a/src/gui/settings/settingsbrowsermail.cpp b/src/gui/settings/settingsbrowsermail.cpp index 00927f2b2..bc5660df3 100755 --- a/src/gui/settings/settingsbrowsermail.cpp +++ b/src/gui/settings/settingsbrowsermail.cpp @@ -56,7 +56,7 @@ SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent) connect(m_ui->m_btnDeleteTool, &QPushButton::clicked, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_btnAddTool, &QPushButton::clicked, this, &SettingsBrowserMail::addExternalTool); connect(m_ui->m_btnDeleteTool, &QPushButton::clicked, this, &SettingsBrowserMail::deleteSelectedExternalTool); - connect(m_ui->m_listTools, &QTreeWidget::currentItemChanged, [this](QTreeWidgetItem* current, QTreeWidgetItem* previous) { + connect(m_ui->m_listTools, &QTreeWidget::currentItemChanged, this, [this](QTreeWidgetItem* current, QTreeWidgetItem* previous) { Q_UNUSED(previous) m_ui->m_btnDeleteTool->setEnabled(current != nullptr); diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index 0d1dfa99a..29bb1b697 100755 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -49,7 +49,7 @@ SystemTrayIcon::~SystemTrayIcon() { hide(); } -void SystemTrayIcon::onActivated(const QSystemTrayIcon::ActivationReason& reason) { +void SystemTrayIcon::onActivated(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case SystemTrayIcon::Trigger: case SystemTrayIcon::DoubleClick: diff --git a/src/gui/systemtrayicon.h b/src/gui/systemtrayicon.h index 459fda531..0c194b343 100755 --- a/src/gui/systemtrayicon.h +++ b/src/gui/systemtrayicon.h @@ -38,9 +38,7 @@ class SystemTrayIcon : public QSystemTrayIcon { public: // Constructors and destructors. - explicit SystemTrayIcon(const QString& normal_icon, - const QString& plain_icon, - FormMain* parent = 0); + explicit SystemTrayIcon(const QString& normal_icon, const QString& plain_icon, FormMain* parent = nullptr); virtual ~SystemTrayIcon(); // Sets the number to be visible in the tray icon, number <= 0 removes it. @@ -64,7 +62,7 @@ class SystemTrayIcon : public QSystemTrayIcon { private slots: void showPrivate(); - void onActivated(const QSystemTrayIcon::ActivationReason& reason); + void onActivated(QSystemTrayIcon::ActivationReason reason); signals: void shown(); diff --git a/src/miscellaneous/systemfactory.cpp b/src/miscellaneous/systemfactory.cpp index 625b6e253..00c92c016 100755 --- a/src/miscellaneous/systemfactory.cpp +++ b/src/miscellaneous/systemfactory.cpp @@ -204,7 +204,7 @@ QString SystemFactory::loggedInUser() const { void SystemFactory::checkForUpdates() const { Downloader* downloader = new Downloader(); - connect(downloader, &Downloader::completed, [this, downloader]() { + connect(downloader, &Downloader::completed, this, [this, downloader]() { QPair, QNetworkReply::NetworkError> result; result.second = downloader->lastOutputError(); diff --git a/src/network-web/downloadmanager.cpp b/src/network-web/downloadmanager.cpp index a2242a79c..72971d908 100755 --- a/src/network-web/downloadmanager.cpp +++ b/src/network-web/downloadmanager.cpp @@ -596,6 +596,8 @@ void DownloadManager::setRemovePolicy(RemovePolicy policy) { if (policy != m_removePolicy) { m_removePolicy = policy; m_autoSaver->changeOccurred(); + + emit removePolicyChanged(); } } diff --git a/src/network-web/downloadmanager.h b/src/network-web/downloadmanager.h index 3711713d1..6d0222f24 100755 --- a/src/network-web/downloadmanager.h +++ b/src/network-web/downloadmanager.h @@ -82,7 +82,7 @@ class WebBrowser; class DownloadManager : public TabContent { Q_OBJECT - Q_PROPERTY(RemovePolicy removePolicy READ removePolicy WRITE setRemovePolicy) + Q_PROPERTY(RemovePolicy removePolicy READ removePolicy WRITE setRemovePolicy NOTIFY removePolicyChanged) friend class DownloadModel; @@ -135,6 +135,7 @@ class DownloadManager : public TabContent { void itemFinished(); signals: + void removePolicyChanged(); void downloadProgressed(int progress, const QString& description); void downloadFinished(); diff --git a/src/network-web/oauth2service.cpp b/src/network-web/oauth2service.cpp index 75ae97917..251d643c6 100755 --- a/src/network-web/oauth2service.cpp +++ b/src/network-web/oauth2service.cpp @@ -150,12 +150,7 @@ void OAuth2Service::retrieveAccessToken(QString auth_code) { "client_secret=%2&" "code=%3&" "redirect_uri=%5&" - "grant_type=%4") - .arg(m_clientId) - .arg(m_clientSecret) - .arg(auth_code) - .arg(m_tokenGrantType) - .arg(m_redirectUrl); + "grant_type=%4").arg(m_clientId, m_clientSecret, auth_code, m_tokenGrantType, m_redirectUrl); m_networkManager.post(networkRequest, content.toUtf8()); } @@ -173,11 +168,7 @@ void OAuth2Service::refreshAccessToken(QString refresh_token) { QString content = QString("client_id=%1&" "client_secret=%2&" "refresh_token=%3&" - "grant_type=%4") - .arg(m_clientId) - .arg(m_clientSecret) - .arg(refresh_token) - .arg("refresh_token"); + "grant_type=%4").arg(m_clientId, m_clientSecret, refresh_token, QSL("refresh_token")); qApp->showGuiMessage(tr("Logging in via OAuth 2.0..."), tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()), @@ -322,7 +313,7 @@ void OAuth2Service::retrieveAuthCode() { OAuthLogin login_page(qApp->mainFormWidget()); connect(&login_page, &OAuthLogin::authGranted, this, &OAuth2Service::retrieveAccessToken); - connect(&login_page, &OAuthLogin::authRejected, [this]() { + connect(&login_page, &OAuthLogin::authRejected, this, [this]() { logout(); emit authFailed(); }); diff --git a/src/services/gmail/definitions.h b/src/services/gmail/definitions.h index 668f3728c..8ddf31067 100755 --- a/src/services/gmail/definitions.h +++ b/src/services/gmail/definitions.h @@ -7,10 +7,11 @@ #define GMAIL_OAUTH_TOKEN_URL "https://accounts.google.com/o/oauth2/token" #define GMAIL_OAUTH_SCOPE "https://mail.google.com/" -#define GMAIL_API_GET_ATTACHMENT "https://www.googleapis.com/gmail/v1/users/me/messages/%20/attachments/" -#define GMAIL_API_LABELS_LIST "https://www.googleapis.com/gmail/v1/users/me/labels" -#define GMAIL_API_MSGS_LIST "https://www.googleapis.com/gmail/v1/users/me/messages" -#define GMAIL_API_BATCH "https://www.googleapis.com/batch" +#define GMAIL_API_BATCH_UPD_LABELS "https://www.googleapis.com/gmail/v1/users/me/messages/batchModify" +#define GMAIL_API_GET_ATTACHMENT "https://www.googleapis.com/gmail/v1/users/me/messages/%20/attachments/" +#define GMAIL_API_LABELS_LIST "https://www.googleapis.com/gmail/v1/users/me/labels" +#define GMAIL_API_MSGS_LIST "https://www.googleapis.com/gmail/v1/users/me/messages" +#define GMAIL_API_BATCH "https://www.googleapis.com/batch" #define GMAIL_ATTACHMENT_SEP "####" @@ -27,5 +28,6 @@ #define GMAIL_SYSTEM_LABEL_TRASH "TRASH" #define GMAIL_CONTENT_TYPE_HTTP "application/http" +#define GMAIL_CONTENT_TYPE_JSON "application/json" #endif // GMAIL_DEFINITIONS_H diff --git a/src/services/gmail/gmailserviceroot.cpp b/src/services/gmail/gmailserviceroot.cpp index 4a8ced25d..2c732e07d 100755 --- a/src/services/gmail/gmailserviceroot.cpp +++ b/src/services/gmail/gmailserviceroot.cpp @@ -197,8 +197,7 @@ void GmailServiceRoot::saveAllCachedData(bool async) { QStringList ids = i.value(); if (!ids.isEmpty()) { - // TODO: dodělat - //network()->markMessagesRead(key, ids, async); + network()->markMessagesRead(key, ids, async); } } @@ -218,8 +217,7 @@ void GmailServiceRoot::saveAllCachedData(bool async) { custom_ids.append(msg.m_customId); } - // TODO: dodělat - //network()->markMessagesStarred(key, custom_ids, async); + network()->markMessagesStarred(key, custom_ids, async); } } } diff --git a/src/services/gmail/gui/formdownloadattachment.cpp b/src/services/gmail/gui/formdownloadattachment.cpp index f1863562a..a9cbe44e6 100755 --- a/src/services/gmail/gui/formdownloadattachment.cpp +++ b/src/services/gmail/gui/formdownloadattachment.cpp @@ -18,7 +18,10 @@ FormDownloadAttachment::FormDownloadAttachment(const QString& target_file, Downl GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("mail-attachment")), tr("Downloading attachment...")); connect(m_ui.m_btnBox->button(QDialogButtonBox::StandardButton::Abort), &QPushButton::clicked, downloader, &Downloader::cancel); - connect(downloader, &Downloader::completed, [this, downloader, target_file](QNetworkReply::NetworkError status, QByteArray contents) { + connect(downloader, + &Downloader::completed, + this, + [this, downloader, target_file](QNetworkReply::NetworkError status, QByteArray contents) { if (status == QNetworkReply::NetworkError::NoError) { QString data = QJsonDocument::fromJson(contents).object()["data"].toString(); @@ -31,7 +34,7 @@ FormDownloadAttachment::FormDownloadAttachment(const QString& target_file, Downl downloader->deleteLater(); close(); }); - connect(downloader, &Downloader::progress, [this](qint64 bytes_received, qint64 bytes_total) { + connect(downloader, &Downloader::progress, this, [this](qint64 bytes_received, qint64 bytes_total) { m_ui.m_lblInfo->setText(tr("Downloaded: %1 kB").arg(bytes_received / 1000.0)); if (m_ui.m_progressBar->maximum() == 0) { diff --git a/src/services/gmail/network/gmailnetworkfactory.cpp b/src/services/gmail/network/gmailnetworkfactory.cpp index 7fbae14fd..7dc5d752e 100755 --- a/src/services/gmail/network/gmailnetworkfactory.cpp +++ b/src/services/gmail/network/gmailnetworkfactory.cpp @@ -54,7 +54,7 @@ void GmailNetworkFactory::setBatchSize(int batch_size) { void GmailNetworkFactory::initializeOauth() { connect(m_oauth2, &OAuth2Service::tokensRetrieveError, this, &GmailNetworkFactory::onTokensError); connect(m_oauth2, &OAuth2Service::authFailed, this, &GmailNetworkFactory::onAuthFailed); - connect(m_oauth2, &OAuth2Service::tokensReceived, [this](QString access_token, QString refresh_token, int expires_in) { + connect(m_oauth2, &OAuth2Service::tokensReceived, this, [this](QString access_token, QString refresh_token, int expires_in) { Q_UNUSED(expires_in) if (m_service != nullptr && !access_token.isEmpty() && !refresh_token.isEmpty()) { @@ -186,18 +186,6 @@ QList GmailNetworkFactory::messages(const QString& stream_id, Feed::Sta } void GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QStringList& custom_ids, bool async) { - QString target_url;// TODO: dodělat - // = INOREADER_API_EDIT_TAG; - // TODO: dodělat - // - - /* - if (status == RootItem::ReadStatus::Read) { - target_url += QString("?a=user/-/") + INOREADER_STATE_READ + "&"; - } - else { - target_url += QString("?r=user/-/") + INOREADER_STATE_READ + "&"; - }*/ QString bearer = m_oauth2->bearer().toLocal8Bit(); if (bearer.isEmpty()) { @@ -207,66 +195,49 @@ void GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const QS QList> headers; headers.append(QPair(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), m_oauth2->bearer().toLocal8Bit())); + headers.append(QPair(QString(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(), + QString(GMAIL_CONTENT_TYPE_JSON).toLocal8Bit())); - QStringList trimmed_ids; - QRegularExpression regex_short_id(QSL("[0-9a-zA-Z]+$")); + int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(); + QJsonObject param_obj; + QJsonArray param_add, param_remove; - foreach (const QString& id, custom_ids) { - QString simplified_id = regex_short_id.match(id).captured(); - - trimmed_ids.append(QString("i=") + simplified_id); + if (status == RootItem::ReadStatus::Read) { + // We remove label UNREAD. + param_remove.append(GMAIL_SYSTEM_LABEL_UNREAD); + } + else { + // We add label UNREAD. + param_add.append(GMAIL_SYSTEM_LABEL_UNREAD); } - QStringList working_subset; - int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(); + param_obj["addLabelIds"] = param_add; + param_obj["removeLabelIds"] = param_remove; + param_obj["ids"] = QJsonArray::fromStringList(custom_ids); - working_subset.reserve(trimmed_ids.size() > 200 ? 200 : trimmed_ids.size()); + QJsonDocument param_doc(param_obj); - // Now, we perform messages update in batches (max 200 messages per batch). - while (!trimmed_ids.isEmpty()) { - // We take 200 IDs. - for (int i = 0; i < 200 && !trimmed_ids.isEmpty(); i++) { - working_subset.append(trimmed_ids.takeFirst()); - } + // We send this batch. + if (async) { + NetworkFactory::performAsyncNetworkOperation(GMAIL_API_BATCH_UPD_LABELS, + timeout, + param_doc.toJson(QJsonDocument::JsonFormat::Compact), + QNetworkAccessManager::Operation::PostOperation, + headers); + } + else { + QByteArray output; - QString batch_final_url = target_url + working_subset.join(QL1C('&')); - - // We send this batch. - if (async) { - - NetworkFactory::performAsyncNetworkOperation(batch_final_url, - timeout, - QByteArray(), - QNetworkAccessManager::Operation::GetOperation, - headers); - } - else { - QByteArray output; - - NetworkFactory::performNetworkOperation(batch_final_url, - timeout, - QByteArray(), - output, - QNetworkAccessManager::Operation::GetOperation, - headers); - } - - // Cleanup for next batch. - working_subset.clear(); + 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) { - QString target_url; // TODO: dodělat - //= INOREADER_API_EDIT_TAG; - -/* - if (importance == RootItem::Importance::Important) { - target_url += QString("?a=user/-/") + INOREADER_STATE_IMPORTANT + "&"; - } - else { - target_url += QString("?r=user/-/") + INOREADER_STATE_IMPORTANT + "&"; - }*/ QString bearer = m_oauth2->bearer().toLocal8Bit(); if (bearer.isEmpty()) { @@ -276,52 +247,45 @@ void GmailNetworkFactory::markMessagesStarred(RootItem::Importance importance, c QList> headers; headers.append(QPair(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), m_oauth2->bearer().toLocal8Bit())); + headers.append(QPair(QString(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(), + QString(GMAIL_CONTENT_TYPE_JSON).toLocal8Bit())); - QStringList trimmed_ids; - QRegularExpression regex_short_id(QSL("[0-9a-zA-Z]+$")); + int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(); + QJsonObject param_obj; + QJsonArray param_add, param_remove; - foreach (const QString& id, custom_ids) { - QString simplified_id = regex_short_id.match(id).captured(); - - trimmed_ids.append(QString("i=") + simplified_id); + if (importance == RootItem::Importance::Important) { + // We add label UNREAD. + param_add.append(GMAIL_SYSTEM_LABEL_STARRED); + } + else { + // We remove label UNREAD. + param_remove.append(GMAIL_SYSTEM_LABEL_STARRED); } - QStringList working_subset; - int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(); + param_obj["addLabelIds"] = param_add; + param_obj["removeLabelIds"] = param_remove; + param_obj["ids"] = QJsonArray::fromStringList(custom_ids); - working_subset.reserve(trimmed_ids.size() > 200 ? 200 : trimmed_ids.size()); + QJsonDocument param_doc(param_obj); - // Now, we perform messages update in batches (max 200 messages per batch). - while (!trimmed_ids.isEmpty()) { - // We take 200 IDs. - for (int i = 0; i < 200 && !trimmed_ids.isEmpty(); i++) { - working_subset.append(trimmed_ids.takeFirst()); - } + // We send this batch. + if (async) { + NetworkFactory::performAsyncNetworkOperation(GMAIL_API_BATCH_UPD_LABELS, + timeout, + param_doc.toJson(QJsonDocument::JsonFormat::Compact), + QNetworkAccessManager::Operation::PostOperation, + headers); + } + else { + QByteArray output; - QString batch_final_url = target_url + working_subset.join(QL1C('&')); - - // We send this batch. - if (async) { - - NetworkFactory::performAsyncNetworkOperation(batch_final_url, - timeout, - QByteArray(), - QNetworkAccessManager::Operation::GetOperation, - headers); - } - else { - QByteArray output; - - NetworkFactory::performNetworkOperation(batch_final_url, - timeout, - QByteArray(), - output, - QNetworkAccessManager::Operation::GetOperation, - headers); - } - - // Cleanup for next batch. - working_subset.clear(); + NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS, + timeout, + param_doc.toJson(QJsonDocument::JsonFormat::Compact), + output, + QNetworkAccessManager::Operation::PostOperation, + headers); } } diff --git a/src/services/inoreader/network/inoreadernetworkfactory.cpp b/src/services/inoreader/network/inoreadernetworkfactory.cpp index ff567e353..ab8172e11 100755 --- a/src/services/inoreader/network/inoreadernetworkfactory.cpp +++ b/src/services/inoreader/network/inoreadernetworkfactory.cpp @@ -52,7 +52,7 @@ void InoreaderNetworkFactory::setBatchSize(int batch_size) { void InoreaderNetworkFactory::initializeOauth() { connect(m_oauth2, &OAuth2Service::tokensRetrieveError, this, &InoreaderNetworkFactory::onTokensError); connect(m_oauth2, &OAuth2Service::authFailed, this, &InoreaderNetworkFactory::onAuthFailed); - connect(m_oauth2, &OAuth2Service::tokensReceived, [this](QString access_token, QString refresh_token, int expires_in) { + connect(m_oauth2, &OAuth2Service::tokensReceived, this, [this](QString access_token, QString refresh_token, int expires_in) { Q_UNUSED(expires_in) if (m_service != nullptr && !access_token.isEmpty() && !refresh_token.isEmpty()) { diff --git a/src/services/owncloud/gui/formeditowncloudaccount.cpp b/src/services/owncloud/gui/formeditowncloudaccount.cpp index 992c56161..aeda3b114 100755 --- a/src/services/owncloud/gui/formeditowncloudaccount.cpp +++ b/src/services/owncloud/gui/formeditowncloudaccount.cpp @@ -30,7 +30,7 @@ FormEditOwnCloudAccount::FormEditOwnCloudAccount(QWidget* parent) tr("Limiting number of downloaded messages per feed makes updating of feeds faster but if your feed contains " "bigger number of messages than specified limit, then some messages might not be downloaded during feed update.")); - connect(m_ui->m_spinLimitMessages, static_cast(&QSpinBox::valueChanged), [=](int value) { + connect(m_ui->m_spinLimitMessages, static_cast(&QSpinBox::valueChanged), this, [=](int value) { if (value <= 0) { m_ui->m_spinLimitMessages->setSuffix(QSL(" ") + tr("= unlimited")); }