From 4b12b53133d91794ae29a0b96d56948bca8e0d1b Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Thu, 4 Mar 2021 19:11:08 -0500 Subject: [PATCH] Fix linting --- src/Cache.cpp | 30 +++--- src/CallDevices.cpp | 1 - src/CallManager.cpp | 1 - src/ChatPage.cpp | 22 ++-- src/CompletionProxyModel.cpp | 21 ++-- src/DeviceVerificationFlow.cpp | 3 +- src/WebRTCSession.cpp | 1 - src/WebRTCSession.h | 1 - src/timeline/EventStore.cpp | 177 ++++++++++++++++----------------- src/timeline/TimelineModel.cpp | 33 +++--- src/ui/UserProfile.cpp | 7 +- 11 files changed, 144 insertions(+), 153 deletions(-) diff --git a/src/Cache.cpp b/src/Cache.cpp index 5ec3f32c..d54f8f6e 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -3566,23 +3566,23 @@ Cache::query_keys(const std::string &user_id, last_changed = cache_->last_changed; req.token = last_changed; - http::client()->query_keys(req, - [cb, user_id, last_changed](const mtx::responses::QueryKeys &res, - mtx::http::RequestErr err) { - if (err) { - nhlog::net()->warn( - "failed to query device keys: {},{}", - mtx::errors::to_string(err->matrix_error.errcode), - static_cast(err->status_code)); - cb({}, err); - return; - } + http::client()->query_keys( + req, + [cb, user_id, last_changed](const mtx::responses::QueryKeys &res, + mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn("failed to query device keys: {},{}", + mtx::errors::to_string(err->matrix_error.errcode), + static_cast(err->status_code)); + cb({}, err); + return; + } - cache::updateUserKeys(last_changed, res); + cache::updateUserKeys(last_changed, res); - auto keys = cache::userKeys(user_id); - cb(keys.value_or(UserKeyCache{}), err); - }); + auto keys = cache::userKeys(user_id); + cb(keys.value_or(UserKeyCache{}), err); + }); } void diff --git a/src/CallDevices.cpp b/src/CallDevices.cpp index f182c133..0e1a2a23 100644 --- a/src/CallDevices.cpp +++ b/src/CallDevices.cpp @@ -249,7 +249,6 @@ tokenise(std::string_view str, char delim) ret.second = std::atoi(str.data() + pos + 1); return ret; } - } void diff --git a/src/CallManager.cpp b/src/CallManager.cpp index eec5922e..5a36c077 100644 --- a/src/CallManager.cpp +++ b/src/CallManager.cpp @@ -599,7 +599,6 @@ newBusMessage(GstBus *bus G_GNUC_UNUSED, GstMessage *msg, gpointer G_GNUC_UNUSED } return TRUE; } - } #endif diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index c21c3571..370f5f92 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -320,12 +320,11 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) &ChatPage::setGroupViewState); connect(this, &ChatPage::initializeRoomList, room_list_, &RoomList::initialize); - connect( - this, - &ChatPage::initializeViews, - view_manager_, - [this](const mtx::responses::Rooms &rooms) { view_manager_->sync(rooms); }, - Qt::QueuedConnection); + connect(this, + &ChatPage::initializeViews, + view_manager_, + [this](const mtx::responses::Rooms &rooms) { view_manager_->sync(rooms); }, + Qt::QueuedConnection); connect(this, &ChatPage::initializeEmptyViews, view_manager_, @@ -390,12 +389,11 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) connect( this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync, Qt::QueuedConnection); connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync, Qt::QueuedConnection); - connect( - this, - &ChatPage::tryDelayedSyncCb, - this, - [this]() { QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); }, - Qt::QueuedConnection); + connect(this, + &ChatPage::tryDelayedSyncCb, + this, + [this]() { QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); }, + Qt::QueuedConnection); connect(this, &ChatPage::newSyncResponse, diff --git a/src/CompletionProxyModel.cpp b/src/CompletionProxyModel.cpp index fa5b3c2d..95c057f0 100644 --- a/src/CompletionProxyModel.cpp +++ b/src/CompletionProxyModel.cpp @@ -41,17 +41,16 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, QObject *p } } - connect( - this, - &CompletionProxyModel::newSearchString, - this, - [this](QString s) { - s.remove(":"); - s.remove("@"); - searchString = s.toLower(); - invalidate(); - }, - Qt::QueuedConnection); + connect(this, + &CompletionProxyModel::newSearchString, + this, + [this](QString s) { + s.remove(":"); + s.remove("@"); + searchString = s.toLower(); + invalidate(); + }, + Qt::QueuedConnection); } void diff --git a/src/DeviceVerificationFlow.cpp b/src/DeviceVerificationFlow.cpp index 0f0de5a6..f0be661a 100644 --- a/src/DeviceVerificationFlow.cpp +++ b/src/DeviceVerificationFlow.cpp @@ -345,7 +345,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, if (err) { nhlog::net()->error( "failed to upload signatures: {},{}", - mtx::errors::to_string(err->matrix_error.errcode), + mtx::errors::to_string( + err->matrix_error.errcode), static_cast(err->status_code)); } diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index 74855835..c10c5fb9 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -570,7 +570,6 @@ getMediaAttributes(const GstSDPMessage *sdp, } return false; } - } bool diff --git a/src/WebRTCSession.h b/src/WebRTCSession.h index 7c77a94d..3d3e9a69 100644 --- a/src/WebRTCSession.h +++ b/src/WebRTCSession.h @@ -35,7 +35,6 @@ enum class State }; Q_ENUM_NS(State) - } class WebRTCSession : public QObject diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index 94d43a83..31cf799b 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -35,60 +35,59 @@ EventStore::EventStore(std::string room_id, QObject *) this->last = range->last; } - connect( - this, - &EventStore::eventFetched, - this, - [this](std::string id, - std::string relatedTo, - mtx::events::collections::TimelineEvents timeline) { - cache::client()->storeEvent(room_id_, id, {timeline}); + connect(this, + &EventStore::eventFetched, + this, + [this](std::string id, + std::string relatedTo, + mtx::events::collections::TimelineEvents timeline) { + cache::client()->storeEvent(room_id_, id, {timeline}); - if (!relatedTo.empty()) { - auto idx = idToIndex(relatedTo); - if (idx) - emit dataChanged(*idx, *idx); - } - }, - Qt::QueuedConnection); + if (!relatedTo.empty()) { + auto idx = idToIndex(relatedTo); + if (idx) + emit dataChanged(*idx, *idx); + } + }, + Qt::QueuedConnection); - connect( - this, - &EventStore::oldMessagesRetrieved, - this, - [this](const mtx::responses::Messages &res) { - if (cache::client()->previousBatchToken(room_id_) == res.end) { - noMoreMessages = true; - emit fetchedMore(); - return; - } + connect(this, + &EventStore::oldMessagesRetrieved, + this, + [this](const mtx::responses::Messages &res) { + if (cache::client()->previousBatchToken(room_id_) == res.end) { + noMoreMessages = true; + emit fetchedMore(); + return; + } - uint64_t newFirst = cache::client()->saveOldMessages(room_id_, res); - if (newFirst == first) - fetchMore(); - else { - if (this->last != std::numeric_limits::max()) { - emit beginInsertRows(toExternalIdx(newFirst), - toExternalIdx(this->first - 1)); - this->first = newFirst; - emit endInsertRows(); - emit fetchedMore(); - } else { - auto range = cache::client()->getTimelineRange(room_id_); + uint64_t newFirst = cache::client()->saveOldMessages(room_id_, res); + if (newFirst == first) + fetchMore(); + else { + if (this->last != std::numeric_limits::max()) { + emit beginInsertRows(toExternalIdx(newFirst), + toExternalIdx(this->first - 1)); + this->first = newFirst; + emit endInsertRows(); + emit fetchedMore(); + } else { + auto range = cache::client()->getTimelineRange(room_id_); - if (range && range->last - range->first != 0) { - emit beginInsertRows(0, int(range->last - range->first)); - this->first = range->first; - this->last = range->last; - emit endInsertRows(); - emit fetchedMore(); - } else { - fetchMore(); - } - } - } - }, - Qt::QueuedConnection); + if (range && range->last - range->first != 0) { + emit beginInsertRows( + 0, int(range->last - range->first)); + this->first = range->first; + this->last = range->last; + emit endInsertRows(); + emit fetchedMore(); + } else { + fetchMore(); + } + } + } + }, + Qt::QueuedConnection); connect(this, &EventStore::processPending, this, [this]() { if (!current_txn.empty()) { @@ -153,48 +152,46 @@ EventStore::EventStore(std::string room_id, QObject *) event->data); }); - connect( - this, - &EventStore::messageFailed, - this, - [this](std::string txn_id) { - if (current_txn == txn_id) { - current_txn_error_count++; - if (current_txn_error_count > 10) { - nhlog::ui()->debug("failing txn id '{}'", txn_id); - cache::client()->removePendingStatus(room_id_, txn_id); - current_txn_error_count = 0; - } - } - QTimer::singleShot(1000, this, [this]() { - nhlog::ui()->debug("timeout"); - this->current_txn = ""; - emit processPending(); - }); - }, - Qt::QueuedConnection); + connect(this, + &EventStore::messageFailed, + this, + [this](std::string txn_id) { + if (current_txn == txn_id) { + current_txn_error_count++; + if (current_txn_error_count > 10) { + nhlog::ui()->debug("failing txn id '{}'", txn_id); + cache::client()->removePendingStatus(room_id_, txn_id); + current_txn_error_count = 0; + } + } + QTimer::singleShot(1000, this, [this]() { + nhlog::ui()->debug("timeout"); + this->current_txn = ""; + emit processPending(); + }); + }, + Qt::QueuedConnection); - connect( - this, - &EventStore::messageSent, - this, - [this](std::string txn_id, std::string event_id) { - nhlog::ui()->debug("sent {}", txn_id); + connect(this, + &EventStore::messageSent, + this, + [this](std::string txn_id, std::string event_id) { + nhlog::ui()->debug("sent {}", txn_id); - http::client()->read_event( - room_id_, event_id, [this, event_id](mtx::http::RequestErr err) { - if (err) { - nhlog::net()->warn( - "failed to read_event ({}, {})", room_id_, event_id); - } - }); + http::client()->read_event( + room_id_, event_id, [this, event_id](mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn( + "failed to read_event ({}, {})", room_id_, event_id); + } + }); - cache::client()->removePendingStatus(room_id_, txn_id); - this->current_txn = ""; - this->current_txn_error_count = 0; - emit processPending(); - }, - Qt::QueuedConnection); + cache::client()->removePendingStatus(room_id_, txn_id); + this->current_txn = ""; + this->current_txn_error_count = 0; + emit processPending(); + }, + Qt::QueuedConnection); } void @@ -360,7 +357,7 @@ struct overloaded : Ts... using Ts::operator()...; }; template -overloaded(Ts...) -> overloaded; +overloaded(Ts...)->overloaded; } void diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 3b1bbd6c..3d1a7767 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -205,12 +205,11 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj , room_id_(room_id) , manager_(manager) { - connect( - this, - &TimelineModel::redactionFailed, - this, - [](const QString &msg) { emit ChatPage::instance()->showNotification(msg); }, - Qt::QueuedConnection); + connect(this, + &TimelineModel::redactionFailed, + this, + [](const QString &msg) { emit ChatPage::instance()->showNotification(msg); }, + Qt::QueuedConnection); connect(this, &TimelineModel::newMessageToSend, @@ -219,17 +218,17 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj Qt::QueuedConnection); connect(this, &TimelineModel::addPendingMessageToStore, &events, &EventStore::addPending); - connect( - &events, - &EventStore::dataChanged, - this, - [this](int from, int to) { - nhlog::ui()->debug( - "data changed {} to {}", events.size() - to - 1, events.size() - from - 1); - emit dataChanged(index(events.size() - to - 1, 0), - index(events.size() - from - 1, 0)); - }, - Qt::QueuedConnection); + connect(&events, + &EventStore::dataChanged, + this, + [this](int from, int to) { + nhlog::ui()->debug("data changed {} to {}", + events.size() - to - 1, + events.size() - from - 1); + emit dataChanged(index(events.size() - to - 1, 0), + index(events.size() - from - 1, 0)); + }, + Qt::QueuedConnection); connect(&events, &EventStore::beginInsertRows, this, [this](int from, int to) { int first = events.size() - to; diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp index 311c1314..a9e013c2 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp @@ -173,9 +173,10 @@ UserProfile::fetchDeviceList(const QString &userID) std::string local_user_id = utils::localUser().toStdString(); if (err) { - nhlog::net()->warn("failed to query device keys: {},{}", - mtx::errors::to_string(err->matrix_error.errcode), - static_cast(err->status_code)); + nhlog::net()->warn( + "failed to query device keys: {},{}", + mtx::errors::to_string(err->matrix_error.errcode), + static_cast(err->status_code)); return; }