From aacc4bcb4a487871daae6717f77605aaba444341 Mon Sep 17 00:00:00 2001 From: Marc Deop Date: Sat, 2 Mar 2019 12:26:57 +0100 Subject: style: apply .clang-format to all .cpp and .h files --- lib/events/accountdataevents.h | 67 ++++---- lib/events/callanswerevent.cpp | 26 +-- lib/events/callanswerevent.h | 23 ++- lib/events/callcandidatesevent.cpp | 7 +- lib/events/callcandidatesevent.h | 35 ++-- lib/events/callhangupevent.cpp | 6 +- lib/events/callhangupevent.h | 11 +- lib/events/callinviteevent.cpp | 15 +- lib/events/callinviteevent.h | 25 +-- lib/events/directchatevent.cpp | 7 +- lib/events/directchatevent.h | 15 +- lib/events/event.cpp | 30 ++-- lib/events/event.h | 330 ++++++++++++++++++------------------- lib/events/eventcontent.cpp | 35 ++-- lib/events/eventcontent.h | 196 +++++++++++----------- lib/events/eventloader.h | 35 ++-- lib/events/receiptevent.cpp | 29 ++-- lib/events/receiptevent.h | 29 ++-- lib/events/redactionevent.h | 23 +-- lib/events/roomavatarevent.h | 30 ++-- lib/events/roomcreateevent.cpp | 38 ++--- lib/events/roomcreateevent.h | 65 ++++---- lib/events/roomevent.cpp | 59 ++++--- lib/events/roomevent.h | 148 ++++++++--------- lib/events/roommemberevent.cpp | 44 +++-- lib/events/roommemberevent.h | 124 +++++++------- lib/events/roommessageevent.cpp | 144 ++++++++-------- lib/events/roommessageevent.h | 183 ++++++++++---------- lib/events/roomtombstoneevent.cpp | 32 ++-- lib/events/roomtombstoneevent.h | 54 +++--- lib/events/simplestateevents.h | 93 ++++++----- lib/events/stateevent.cpp | 41 ++--- lib/events/stateevent.h | 158 +++++++++--------- lib/events/typingevent.cpp | 8 +- lib/events/typingevent.h | 17 +- 35 files changed, 1094 insertions(+), 1088 deletions(-) (limited to 'lib/events') diff --git a/lib/events/accountdataevents.h b/lib/events/accountdataevents.h index a99d85ac..0cf2dc60 100644 --- a/lib/events/accountdataevents.h +++ b/lib/events/accountdataevents.h @@ -15,38 +15,37 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once +#include "converters.h" #include "event.h" #include "eventcontent.h" -#include "converters.h" -namespace QMatrixClient -{ +namespace QMatrixClient { constexpr const char* FavouriteTag = "m.favourite"; constexpr const char* LowPriorityTag = "m.lowpriority"; - struct TagRecord - { + struct TagRecord { using order_type = Omittable; order_type order; - TagRecord (order_type order = none) : order(order) { } + TagRecord(order_type order = none) : order(order) {} bool operator<(const TagRecord& other) const { - // Per The Spec, rooms with no order should be after those with order - return !order.omitted() && - (other.order.omitted() || order.value() < other.order.value()); + // Per The Spec, rooms with no order should be after those with + // order + return !order.omitted() + && (other.order.omitted() + || order.value() < other.order.value()); } }; - template <> struct JsonObjectConverter - { + template <> struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, TagRecord& rec) { // Parse a float both from JSON double and JSON string because @@ -54,8 +53,7 @@ namespace QMatrixClient const auto orderJv = jo.value("order"_ls); if (orderJv.isDouble()) rec.order = fromJson(orderJv); - if (orderJv.isString()) - { + if (orderJv.isString()) { bool ok; rec.order = orderJv.toString().toFloat(&ok); if (!ok) @@ -70,30 +68,31 @@ namespace QMatrixClient using TagsMap = QHash; -#define DEFINE_SIMPLE_EVENT(_Name, _TypeId, _ContentType, _ContentKey) \ - class _Name : public Event \ - { \ - public: \ - using content_type = _ContentType; \ - DEFINE_EVENT_TYPEID(_TypeId, _Name) \ - explicit _Name(QJsonObject obj) \ - : Event(typeId(), std::move(obj)) \ - { } \ - explicit _Name(_ContentType content) \ - : Event(typeId(), matrixTypeId(), \ - QJsonObject { { QStringLiteral(#_ContentKey), \ - toJson(std::move(content)) } }) \ - { } \ - auto _ContentKey() const \ - { return fromJson(contentJson()[#_ContentKey##_ls]); } \ - }; \ - REGISTER_EVENT_TYPE(_Name) \ +#define DEFINE_SIMPLE_EVENT(_Name, _TypeId, _ContentType, _ContentKey) \ + class _Name : public Event \ + { \ + public: \ + using content_type = _ContentType; \ + DEFINE_EVENT_TYPEID(_TypeId, _Name) \ + explicit _Name(QJsonObject obj) : Event(typeId(), std::move(obj)) {} \ + explicit _Name(_ContentType content) \ + : Event(typeId(), matrixTypeId(), \ + QJsonObject { { QStringLiteral(#_ContentKey), \ + toJson(std::move(content)) } }) \ + { \ + } \ + auto _ContentKey() const \ + { \ + return fromJson(contentJson()[#_ContentKey##_ls]); \ + } \ + }; \ + REGISTER_EVENT_TYPE(_Name) \ // End of macro DEFINE_SIMPLE_EVENT(TagEvent, "m.tag", TagsMap, tags) DEFINE_SIMPLE_EVENT(ReadMarkerEvent, "m.fully_read", QString, event_id) - DEFINE_SIMPLE_EVENT(IgnoredUsersEvent, "m.ignored_user_list", - QSet, ignored_users) + DEFINE_SIMPLE_EVENT(IgnoredUsersEvent, "m.ignored_user_list", QSet, + ignored_users) DEFINE_EVENTTYPE_ALIAS(Tag, TagEvent) DEFINE_EVENTTYPE_ALIAS(ReadMarker, ReadMarkerEvent) diff --git a/lib/events/callanswerevent.cpp b/lib/events/callanswerevent.cpp index d2862241..91e164ad 100644 --- a/lib/events/callanswerevent.cpp +++ b/lib/events/callanswerevent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "callanswerevent.h" @@ -56,17 +56,19 @@ CallAnswerEvent::CallAnswerEvent(const QJsonObject& obj) CallAnswerEvent::CallAnswerEvent(const QString& callId, const int lifetime, const QString& sdp) : CallEventBase(typeId(), matrixTypeId(), callId, 0, - { { QStringLiteral("lifetime"), lifetime } - , { QStringLiteral("answer"), QJsonObject { - { QStringLiteral("type"), QStringLiteral("answer") }, - { QStringLiteral("sdp"), sdp } } } - }) -{ } + { { QStringLiteral("lifetime"), lifetime }, + { QStringLiteral("answer"), + QJsonObject { { QStringLiteral("type"), + QStringLiteral("answer") }, + { QStringLiteral("sdp"), sdp } } } }) +{ +} CallAnswerEvent::CallAnswerEvent(const QString& callId, const QString& sdp) : CallEventBase(typeId(), matrixTypeId(), callId, 0, - { { QStringLiteral("answer"), QJsonObject { - { QStringLiteral("type"), QStringLiteral("answer") }, - { QStringLiteral("sdp"), sdp } } } - }) -{ } + { { QStringLiteral("answer"), + QJsonObject { { QStringLiteral("type"), + QStringLiteral("answer") }, + { QStringLiteral("sdp"), sdp } } } }) +{ +} diff --git a/lib/events/callanswerevent.h b/lib/events/callanswerevent.h index 2d9e5bb0..f222803b 100644 --- a/lib/events/callanswerevent.h +++ b/lib/events/callanswerevent.h @@ -13,18 +13,17 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "roomevent.h" -namespace QMatrixClient -{ - class CallAnswerEvent: public CallEventBase +namespace QMatrixClient { + class CallAnswerEvent : public CallEventBase { - public: + public: DEFINE_EVENT_TYPEID("m.call.answer", CallAnswerEvent) explicit CallAnswerEvent(const QJsonObject& obj); @@ -33,10 +32,16 @@ namespace QMatrixClient const QString& sdp); explicit CallAnswerEvent(const QString& callId, const QString& sdp); - int lifetime() const { return content("lifetime"_ls); } // FIXME: Omittable<>? - QString sdp() const { - return contentJson()["answer"_ls].toObject() - .value("sdp"_ls).toString(); + int lifetime() const + { + return content("lifetime"_ls); + } // FIXME: Omittable<>? + QString sdp() const + { + return contentJson()["answer"_ls] + .toObject() + .value("sdp"_ls) + .toString(); } }; diff --git a/lib/events/callcandidatesevent.cpp b/lib/events/callcandidatesevent.cpp index 52cd1856..24f0dd46 100644 --- a/lib/events/callcandidatesevent.cpp +++ b/lib/events/callcandidatesevent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "callcandidatesevent.h" @@ -26,9 +26,8 @@ m.call.candidates "call_id": "12345", "candidates": [ { - "candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0", - "sdpMLineIndex": 0, - "sdpMid": "audio" + "candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 +43670 typ host generation 0", "sdpMLineIndex": 0, "sdpMid": "audio" } ], "version": 0 diff --git a/lib/events/callcandidatesevent.h b/lib/events/callcandidatesevent.h index 4618832c..e66e0c09 100644 --- a/lib/events/callcandidatesevent.h +++ b/lib/events/callcandidatesevent.h @@ -13,34 +13,35 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "roomevent.h" -namespace QMatrixClient -{ - class CallCandidatesEvent: public CallEventBase +namespace QMatrixClient { + class CallCandidatesEvent : public CallEventBase { public: - DEFINE_EVENT_TYPEID("m.call.candidates", CallCandidatesEvent) + DEFINE_EVENT_TYPEID("m.call.candidates", CallCandidatesEvent) - explicit CallCandidatesEvent(const QJsonObject& obj) - : CallEventBase(typeId(), obj) - { } + explicit CallCandidatesEvent(const QJsonObject& obj) + : CallEventBase(typeId(), obj) + { + } - explicit CallCandidatesEvent(const QString& callId, - const QJsonArray& candidates) - : CallEventBase(typeId(), matrixTypeId(), callId, 0, - {{ QStringLiteral("candidates"), candidates }}) - { } + explicit CallCandidatesEvent(const QString& callId, + const QJsonArray& candidates) + : CallEventBase(typeId(), matrixTypeId(), callId, 0, + { { QStringLiteral("candidates"), candidates } }) + { + } - QJsonArray candidates() const - { - return content("candidates"_ls); - } + QJsonArray candidates() const + { + return content("candidates"_ls); + } }; REGISTER_EVENT_TYPE(CallCandidatesEvent) diff --git a/lib/events/callhangupevent.cpp b/lib/events/callhangupevent.cpp index b1154806..80844f2d 100644 --- a/lib/events/callhangupevent.cpp +++ b/lib/events/callhangupevent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "callhangupevent.h" @@ -42,7 +42,6 @@ m.call.hangup using namespace QMatrixClient; - CallHangupEvent::CallHangupEvent(const QJsonObject& obj) : CallEventBase(typeId(), obj) { @@ -51,4 +50,5 @@ CallHangupEvent::CallHangupEvent(const QJsonObject& obj) CallHangupEvent::CallHangupEvent(const QString& callId) : CallEventBase(typeId(), matrixTypeId(), callId, 0) -{ } +{ +} diff --git a/lib/events/callhangupevent.h b/lib/events/callhangupevent.h index c74e20d5..3c3910be 100644 --- a/lib/events/callhangupevent.h +++ b/lib/events/callhangupevent.h @@ -13,20 +13,19 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "roomevent.h" -namespace QMatrixClient -{ - class CallHangupEvent: public CallEventBase +namespace QMatrixClient { + class CallHangupEvent : public CallEventBase { - public: + public: DEFINE_EVENT_TYPEID("m.call.hangup", CallHangupEvent) - + explicit CallHangupEvent(const QJsonObject& obj); explicit CallHangupEvent(const QString& callId); }; diff --git a/lib/events/callinviteevent.cpp b/lib/events/callinviteevent.cpp index bca3f296..2459c093 100644 --- a/lib/events/callinviteevent.cpp +++ b/lib/events/callinviteevent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "callinviteevent.h" @@ -56,9 +56,10 @@ CallInviteEvent::CallInviteEvent(const QJsonObject& obj) CallInviteEvent::CallInviteEvent(const QString& callId, const int lifetime, const QString& sdp) : CallEventBase(typeId(), matrixTypeId(), callId, lifetime, - { { QStringLiteral("lifetime"), lifetime } - , { QStringLiteral("offer"), QJsonObject { - { QStringLiteral("type"), QStringLiteral("offer") }, - { QStringLiteral("sdp"), sdp } } - }}) -{ } + { { QStringLiteral("lifetime"), lifetime }, + { QStringLiteral("offer"), + QJsonObject { { QStringLiteral("type"), + QStringLiteral("offer") }, + { QStringLiteral("sdp"), sdp } } } }) +{ +} diff --git a/lib/events/callinviteevent.h b/lib/events/callinviteevent.h index d5315309..911ccf96 100644 --- a/lib/events/callinviteevent.h +++ b/lib/events/callinviteevent.h @@ -13,29 +13,34 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "roomevent.h" -namespace QMatrixClient -{ - class CallInviteEvent: public CallEventBase +namespace QMatrixClient { + class CallInviteEvent : public CallEventBase { - public: + public: DEFINE_EVENT_TYPEID("m.call.invite", CallInviteEvent) - + explicit CallInviteEvent(const QJsonObject& obj); explicit CallInviteEvent(const QString& callId, const int lifetime, const QString& sdp); - int lifetime() const { return content("lifetime"_ls); } // FIXME: Omittable<>? - QString sdp() const { - return contentJson()["offer"_ls].toObject() - .value("sdp"_ls).toString(); + int lifetime() const + { + return content("lifetime"_ls); + } // FIXME: Omittable<>? + QString sdp() const + { + return contentJson()["offer"_ls] + .toObject() + .value("sdp"_ls) + .toString(); } }; diff --git a/lib/events/directchatevent.cpp b/lib/events/directchatevent.cpp index 266d60d8..4ba098c2 100644 --- a/lib/events/directchatevent.cpp +++ b/lib/events/directchatevent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "directchatevent.h" @@ -26,13 +26,12 @@ QMultiHash DirectChatEvent::usersToDirectChats() const { QMultiHash result; const auto& json = contentJson(); - for (auto it = json.begin(); it != json.end(); ++it) - { + for (auto it = json.begin(); it != json.end(); ++it) { // Beware of range-for's over temporary returned from temporary // (see the bottom of // http://en.cppreference.com/w/cpp/language/range-for#Explanation) const auto roomIds = it.value().toArray(); - for (const auto& roomIdValue: roomIds) + for (const auto& roomIdValue : roomIds) result.insert(it.key(), roomIdValue.toString()); } return result; diff --git a/lib/events/directchatevent.h b/lib/events/directchatevent.h index 7559796b..0d8b8f74 100644 --- a/lib/events/directchatevent.h +++ b/lib/events/directchatevent.h @@ -13,25 +13,24 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "event.h" -namespace QMatrixClient -{ +namespace QMatrixClient { class DirectChatEvent : public Event { public: - DEFINE_EVENT_TYPEID("m.direct", DirectChatEvent) + DEFINE_EVENT_TYPEID("m.direct", DirectChatEvent) - explicit DirectChatEvent(const QJsonObject& obj) - : Event(typeId(), obj) - { } + explicit DirectChatEvent(const QJsonObject& obj) : Event(typeId(), obj) + { + } - QMultiHash usersToDirectChats() const; + QMultiHash usersToDirectChats() const; }; REGISTER_EVENT_TYPE(DirectChatEvent) DEFINE_EVENTTYPE_ALIAS(DirectChat, DirectChatEvent) diff --git a/lib/events/event.cpp b/lib/events/event.cpp index c98dfbb6..f44b1e5d 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "event.h" @@ -31,8 +31,8 @@ event_type_t EventTypeRegistry::initializeTypeId(event_mtype_t matrixTypeId) if (strncmp(matrixTypeId, "", 1) == 0) qDebug(EVENTS) << "Initialized unknown event type with id" << id; else - qDebug(EVENTS) << "Initialized event type" << matrixTypeId - << "with id" << id; + qDebug(EVENTS) << "Initialized event type" << matrixTypeId << "with id" + << id; return id; } @@ -41,32 +41,26 @@ QString EventTypeRegistry::getMatrixType(event_type_t typeId) return typeId < get().eventTypes.size() ? get().eventTypes[typeId] : ""; } -Event::Event(Type type, const QJsonObject& json) - : _type(type), _json(json) +Event::Event(Type type, const QJsonObject& json) : _type(type), _json(json) { - if (!json.contains(ContentKeyL) && - !json.value(UnsignedKeyL).toObject().contains(RedactedCauseKeyL)) - { + if (!json.contains(ContentKeyL) + && !json.value(UnsignedKeyL).toObject().contains(RedactedCauseKeyL)) { qCWarning(EVENTS) << "Event without 'content' node"; qCWarning(EVENTS) << formatJson << json; } } -Event::Event(Type type, event_mtype_t matrixType, const QJsonObject& contentJson) +Event::Event(Type type, event_mtype_t matrixType, + const QJsonObject& contentJson) : Event(type, basicEventJson(matrixType, contentJson)) -{ } +{ +} Event::~Event() = default; -QString Event::matrixType() const -{ - return fullJson()[TypeKeyL].toString(); -} +QString Event::matrixType() const { return fullJson()[TypeKeyL].toString(); } -QByteArray Event::originalJson() const -{ - return QJsonDocument(_json).toJson(); -} +QByteArray Event::originalJson() const { return QJsonDocument(_json).toJson(); } const QJsonObject Event::contentJson() const { diff --git a/lib/events/event.h b/lib/events/event.h index d7ac4292..a0f12b75 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once @@ -25,12 +25,10 @@ #define USE_EVENTTYPE_ALIAS 1 #endif -namespace QMatrixClient -{ +namespace QMatrixClient { // === event_ptr_tt<> and type casting facilities === - template - using event_ptr_tt = std::unique_ptr; + template using event_ptr_tt = std::unique_ptr; template inline EventT* rawPtr(const event_ptr_tt& ptr) // unwrap @@ -80,50 +78,46 @@ namespace QMatrixClient class EventTypeRegistry { public: - ~EventTypeRegistry() = default; + ~EventTypeRegistry() = default; - static event_type_t initializeTypeId(event_mtype_t matrixTypeId); + static event_type_t initializeTypeId(event_mtype_t matrixTypeId); - template - static inline event_type_t initializeTypeId() - { - return initializeTypeId(EventT::matrixTypeId()); - } + template static inline event_type_t initializeTypeId() + { + return initializeTypeId(EventT::matrixTypeId()); + } - static QString getMatrixType(event_type_t typeId); + static QString getMatrixType(event_type_t typeId); private: - EventTypeRegistry() = default; - Q_DISABLE_COPY(EventTypeRegistry) - DISABLE_MOVE(EventTypeRegistry) + EventTypeRegistry() = default; + Q_DISABLE_COPY(EventTypeRegistry) + DISABLE_MOVE(EventTypeRegistry) - static EventTypeRegistry& get() - { - static EventTypeRegistry etr; - return etr; - } + static EventTypeRegistry& get() + { + static EventTypeRegistry etr; + return etr; + } - std::vector eventTypes; + std::vector eventTypes; }; - template <> - inline event_type_t EventTypeRegistry::initializeTypeId() + template <> inline event_type_t EventTypeRegistry::initializeTypeId() { return initializeTypeId(""); } - template - struct EventTypeTraits - { + template struct EventTypeTraits { static event_type_t id() { - static const auto id = EventTypeRegistry::initializeTypeId(); + static const auto id = + EventTypeRegistry::initializeTypeId(); return id; } }; - template - inline event_type_t typeId() + template inline event_type_t typeId() { return EventTypeTraits>::id(); } @@ -139,49 +133,45 @@ namespace QMatrixClient return std::make_unique(std::forward(args)...); } - template - class EventFactory + template class EventFactory { public: - template - static auto addMethod(FnT&& method) - { - factories().emplace_back(std::forward(method)); - return 0; - } - - /** Chain two type factories - * Adds the factory class of EventT2 (EventT2::factory_t) to - * the list in factory class of EventT1 (EventT1::factory_t) so - * that when EventT1::factory_t::make() is invoked, types of - * EventT2 factory are looked through as well. This is used - * to include RoomEvent types into the more general Event factory, - * and state event types into the RoomEvent factory. - */ - template - static auto chainFactory() - { - return addMethod(&EventT::factory_t::make); - } - - static event_ptr_tt make(const QJsonObject& json, - const QString& matrixType) - { - for (const auto& f: factories()) - if (auto e = f(json, matrixType)) - return e; - return nullptr; - } + template static auto addMethod(FnT&& method) + { + factories().emplace_back(std::forward(method)); + return 0; + } + + /** Chain two type factories + * Adds the factory class of EventT2 (EventT2::factory_t) to + * the list in factory class of EventT1 (EventT1::factory_t) so + * that when EventT1::factory_t::make() is invoked, types of + * EventT2 factory are looked through as well. This is used + * to include RoomEvent types into the more general Event factory, + * and state event types into the RoomEvent factory. + */ + template static auto chainFactory() + { + return addMethod(&EventT::factory_t::make); + } + + static event_ptr_tt make(const QJsonObject& json, + const QString& matrixType) + { + for (const auto& f : factories()) + if (auto e = f(json, matrixType)) + return e; + return nullptr; + } private: - static auto& factories() - { - using inner_factory_tt = - std::function(const QJsonObject&, - const QString&)>; - static std::vector _factories {}; - return _factories; - } + static auto& factories() + { + using inner_factory_tt = std::function( + const QJsonObject&, const QString&)>; + static std::vector _factories {}; + return _factories; + } }; /** Add a type to its default factory @@ -193,20 +183,18 @@ namespace QMatrixClient * \return the registered type id * \sa loadEvent, Event::type */ - template - inline auto setupFactory() + template inline auto setupFactory() { qDebug(EVENTS) << "Adding factory method for" << EventT::matrixTypeId(); return EventT::factory_t::addMethod( - [] (const QJsonObject& json, const QString& jsonMatrixType) - { - return EventT::matrixTypeId() == jsonMatrixType - ? makeEvent(json) : nullptr; - }); + [](const QJsonObject& json, const QString& jsonMatrixType) { + return EventT::matrixTypeId() == jsonMatrixType + ? makeEvent(json) + : nullptr; + }); } - template - inline auto registerEventType() + template inline auto registerEventType() { // Initialise exactly once, even if this function is called twice for // the same type (for whatever reason - you never know the ways of @@ -219,66 +207,64 @@ namespace QMatrixClient class Event { - Q_GADGET - Q_PROPERTY(Type type READ type CONSTANT) - Q_PROPERTY(QJsonObject contentJson READ contentJson CONSTANT) + Q_GADGET + Q_PROPERTY(Type type READ type CONSTANT) + Q_PROPERTY(QJsonObject contentJson READ contentJson CONSTANT) public: - using Type = event_type_t; - using factory_t = EventFactory; - - explicit Event(Type type, const QJsonObject& json); - explicit Event(Type type, event_mtype_t matrixType, - const QJsonObject& contentJson = {}); - Q_DISABLE_COPY(Event) - Event(Event&&) = default; - Event& operator=(Event&&) = delete; - virtual ~Event(); - - Type type() const { return _type; } - QString matrixType() const; - QByteArray originalJson() const; - QJsonObject originalJsonObject() const { return fullJson(); } - - const QJsonObject& fullJson() const { return _json; } - - // According to the CS API spec, every event also has - // a "content" object; but since its structure is different for - // different types, we're implementing it per-event type. - - const QJsonObject contentJson() const; - const QJsonObject unsignedJson() const; - - template - T content(const QString& key) const - { - return fromJson(contentJson()[key]); - } - - template - T content(const QLatin1String& key) const - { - return fromJson(contentJson()[key]); - } - - friend QDebug operator<<(QDebug dbg, const Event& e) - { - QDebugStateSaver _dss { dbg }; - dbg.noquote().nospace() - << e.matrixType() << '(' << e.type() << "): "; - e.dumpTo(dbg); - return dbg; - } - - virtual bool isStateEvent() const { return false; } - virtual bool isCallEvent() const { return false; } - virtual void dumpTo(QDebug dbg) const; + using Type = event_type_t; + using factory_t = EventFactory; + + explicit Event(Type type, const QJsonObject& json); + explicit Event(Type type, event_mtype_t matrixType, + const QJsonObject& contentJson = {}); + Q_DISABLE_COPY(Event) + Event(Event&&) = default; + Event& operator=(Event&&) = delete; + virtual ~Event(); + + Type type() const { return _type; } + QString matrixType() const; + QByteArray originalJson() const; + QJsonObject originalJsonObject() const { return fullJson(); } + + const QJsonObject& fullJson() const { return _json; } + + // According to the CS API spec, every event also has + // a "content" object; but since its structure is different for + // different types, we're implementing it per-event type. + + const QJsonObject contentJson() const; + const QJsonObject unsignedJson() const; + + template T content(const QString& key) const + { + return fromJson(contentJson()[key]); + } + + template T content(const QLatin1String& key) const + { + return fromJson(contentJson()[key]); + } + + friend QDebug operator<<(QDebug dbg, const Event& e) + { + QDebugStateSaver _dss { dbg }; + dbg.noquote().nospace() + << e.matrixType() << '(' << e.type() << "): "; + e.dumpTo(dbg); + return dbg; + } + + virtual bool isStateEvent() const { return false; } + virtual bool isCallEvent() const { return false; } + virtual void dumpTo(QDebug dbg) const; protected: - QJsonObject& editJson() { return _json; } + QJsonObject& editJson() { return _json; } private: - Type _type; - QJsonObject _json; + Type _type; + QJsonObject _json; }; using EventPtr = event_ptr_tt; @@ -290,24 +276,23 @@ namespace QMatrixClient // This macro should be used in a public section of an event class to // provide matrixTypeId() and typeId(). -#define DEFINE_EVENT_TYPEID(_Id, _Type) \ - static constexpr event_mtype_t matrixTypeId() { return _Id; } \ - static auto typeId() { return QMatrixClient::typeId<_Type>(); } \ +#define DEFINE_EVENT_TYPEID(_Id, _Type) \ + static constexpr event_mtype_t matrixTypeId() { return _Id; } \ + static auto typeId() { return QMatrixClient::typeId<_Type>(); } \ // End of macro // This macro should be put after an event class definition (in .h or .cpp) // to enable its deserialisation from a /sync and other // polymorphic event arrays -#define REGISTER_EVENT_TYPE(_Type) \ - namespace { \ - [[gnu::unused]] \ - static const auto _factoryAdded##_Type = registerEventType<_Type>(); \ - } \ +#define REGISTER_EVENT_TYPE(_Type) \ + namespace { \ + [[gnu::unused]] static const auto _factoryAdded##_Type = \ + registerEventType<_Type>(); \ + } \ // End of macro #ifdef USE_EVENTTYPE_ALIAS - namespace EventType - { + namespace EventType { inline event_type_t logEventType(event_type_t id, const char* idName) { qDebug(EVENTS) << "Using id" << id << "for" << idName; @@ -317,12 +302,12 @@ namespace QMatrixClient // This macro provides constants in EventType:: namespace for // back-compatibility with libQMatrixClient 0.3 event type system. -#define DEFINE_EVENTTYPE_ALIAS(_Id, _Type) \ - namespace EventType \ - { \ - [[deprecated("Use is<>(), eventCast<>() or visit<>()")]] \ - static const auto _Id = logEventType(typeId<_Type>(), #_Id); \ - } \ +#define DEFINE_EVENTTYPE_ALIAS(_Id, _Type) \ + namespace EventType { \ + [[deprecated( \ + "Use is<>(), eventCast<>() or visit<>()")]] static const auto \ + _Id = logEventType(typeId<_Type>(), #_Id); \ + } \ // End of macro #else #define DEFINE_EVENTTYPE_ALIAS(_Id, _Type) // Nothing @@ -330,46 +315,48 @@ namespace QMatrixClient // === is<>(), eventCast<>() and visit<>() === - template - inline bool is(const Event& e) { return e.type() == typeId(); } + template inline bool is(const Event& e) + { + return e.type() == typeId(); + } - inline bool isUnknown(const Event& e) { return e.type() == unknownEventTypeId(); } + inline bool isUnknown(const Event& e) + { + return e.type() == unknownEventTypeId(); + } template inline auto eventCast(const BasePtrT& eptr) - -> decltype(static_cast(&*eptr)) + -> decltype(static_cast(&*eptr)) { Q_ASSERT(eptr); - return is>(*eptr) - ? static_cast(&*eptr) : nullptr; + return is>(*eptr) ? static_cast(&*eptr) + : nullptr; } // A single generic catch-all visitor template inline auto visit(const BaseEventT& event, FnT&& visitor) - -> decltype(visitor(event)) + -> decltype(visitor(event)) { return visitor(event); } - template - constexpr auto is_event() + template constexpr auto is_event() { return std::is_base_of>::value; } - template - constexpr auto needs_cast() + template constexpr auto needs_cast() { return !std::is_convertible>::value; } // A single type-specific void visitor template - inline - std::enable_if_t< - is_event() && needs_cast() && - std::is_void>::value> + inline std::enable_if_t() + && needs_cast() + && std::is_void>::value> visit(const BaseEventT& event, FnT&& visitor) { using event_type = fn_arg_t; @@ -379,10 +366,9 @@ namespace QMatrixClient // A single type-specific non-void visitor with an optional default value template - inline - std::enable_if_t< - is_event() && needs_cast(), - fn_return_t> // non-voidness is guarded by defaultValue type + inline std::enable_if_t< + is_event() && needs_cast(), + fn_return_t> // non-voidness is guarded by defaultValue type visit(const BaseEventT& event, FnT&& visitor, fn_return_t&& defaultValue = {}) { @@ -393,9 +379,9 @@ namespace QMatrixClient } // A chain of 2 or more visitors - template - inline - std::enable_if_t(), fn_return_t> + template + inline std::enable_if_t(), fn_return_t> visit(const BaseEventT& event, FnT1&& visitor1, FnT2&& visitor2, FnTs&&... visitors) { @@ -405,6 +391,6 @@ namespace QMatrixClient return visit(event, std::forward(visitor2), std::forward(visitors)...); } -} // namespace QMatrixClient +} // namespace QMatrixClient Q_DECLARE_METATYPE(QMatrixClient::Event*) Q_DECLARE_METATYPE(const QMatrixClient::Event*) diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp index 9a5e872c..cc31fea5 100644 --- a/lib/events/eventcontent.cpp +++ b/lib/events/eventcontent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "eventcontent.h" @@ -34,17 +34,21 @@ QJsonObject Base::toJson() const FileInfo::FileInfo(const QUrl& u, qint64 payloadSize, const QMimeType& mimeType, const QString& originalFilename) - : mimeType(mimeType), url(u), payloadSize(payloadSize) - , originalName(originalFilename) -{ } + : mimeType(mimeType), + url(u), + payloadSize(payloadSize), + originalName(originalFilename) +{ +} FileInfo::FileInfo(const QUrl& u, const QJsonObject& infoJson, const QString& originalFilename) - : originalInfoJson(infoJson) - , mimeType(QMimeDatabase().mimeTypeForName(infoJson["mimetype"_ls].toString())) - , url(u) - , payloadSize(fromJson(infoJson["size"_ls])) - , originalName(originalFilename) + : originalInfoJson(infoJson), + mimeType(QMimeDatabase().mimeTypeForName( + infoJson["mimetype"_ls].toString())), + url(u), + payloadSize(fromJson(infoJson["size"_ls])), + originalName(originalFilename) { if (!mimeType.isValid()) mimeType = QMimeDatabase().mimeTypeForData(QByteArray()); @@ -62,13 +66,15 @@ void FileInfo::fillInfoJson(QJsonObject* infoJson) const ImageInfo::ImageInfo(const QUrl& u, qint64 fileSize, QMimeType mimeType, const QSize& imageSize, const QString& originalFilename) : FileInfo(u, fileSize, mimeType, originalFilename), imageSize(imageSize) -{ } +{ +} ImageInfo::ImageInfo(const QUrl& u, const QJsonObject& infoJson, const QString& originalFilename) - : FileInfo(u, infoJson, originalFilename) - , imageSize(infoJson["w"_ls].toInt(), infoJson["h"_ls].toInt()) -{ } + : FileInfo(u, infoJson, originalFilename), + imageSize(infoJson["w"_ls].toInt(), infoJson["h"_ls].toInt()) +{ +} void ImageInfo::fillInfoJson(QJsonObject* infoJson) const { @@ -82,7 +88,8 @@ void ImageInfo::fillInfoJson(QJsonObject* infoJson) const Thumbnail::Thumbnail(const QJsonObject& infoJson) : ImageInfo(infoJson["thumbnail_url"_ls].toString(), infoJson["thumbnail_info"_ls].toObject()) -{ } +{ +} void Thumbnail::fillInfoJson(QJsonObject* infoJson) const { diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 0588c0e2..857e7369 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once @@ -23,13 +23,11 @@ #include #include -#include #include +#include -namespace QMatrixClient -{ - namespace EventContent - { +namespace QMatrixClient { + namespace EventContent { /** * A base class for all content types that can be stored * in a RoomMessageEvent @@ -43,17 +41,17 @@ namespace QMatrixClient class Base { public: - explicit Base (QJsonObject o = {}) : originalJson(std::move(o)) { } - virtual ~Base() = default; + explicit Base(QJsonObject o = {}) : originalJson(std::move(o)) {} + virtual ~Base() = default; - // FIXME: make toJson() from converters.* work on base classes - QJsonObject toJson() const; + // FIXME: make toJson() from converters.* work on base classes + QJsonObject toJson() const; public: - QJsonObject originalJson; + QJsonObject originalJson; protected: - virtual void fillJson(QJsonObject* o) const = 0; + virtual void fillJson(QJsonObject* o) const = 0; }; // The below structures fairly follow CS spec 11.2.1.6. The overall @@ -81,40 +79,40 @@ namespace QMatrixClient * JSON content, as well as contents of "url" (or a similar key) and * optionally "filename" node from the main JSON content. Assuming you * don't do unusual things, you should use \p UrlBasedContent<> instead - * of doing multiple inheritance and overriding Base::fillJson() by hand. + * of doing multiple inheritance and overriding Base::fillJson() by + * hand. * * This class is not polymorphic. */ class FileInfo { public: - explicit FileInfo(const QUrl& u, qint64 payloadSize = -1, - const QMimeType& mimeType = {}, - const QString& originalFilename = {}); - FileInfo(const QUrl& u, const QJsonObject& infoJson, - const QString& originalFilename = {}); + explicit FileInfo(const QUrl& u, qint64 payloadSize = -1, + const QMimeType& mimeType = {}, + const QString& originalFilename = {}); + FileInfo(const QUrl& u, const QJsonObject& infoJson, + const QString& originalFilename = {}); - void fillInfoJson(QJsonObject* infoJson) const; + void fillInfoJson(QJsonObject* infoJson) const; - /** - * \brief Extract media id from the URL - * - * This can be used, e.g., to construct a QML-facing image:// - * URI as follows: - * \code "image://provider/" + info.mediaId() \endcode - */ - QString mediaId() const { return url.authority() + url.path(); } + /** + * \brief Extract media id from the URL + * + * This can be used, e.g., to construct a QML-facing image:// + * URI as follows: + * \code "image://provider/" + info.mediaId() \endcode + */ + QString mediaId() const { return url.authority() + url.path(); } public: - QJsonObject originalInfoJson; - QMimeType mimeType; - QUrl url; - qint64 payloadSize; - QString originalName; + QJsonObject originalInfoJson; + QMimeType mimeType; + QUrl url; + qint64 payloadSize; + QString originalName; }; - template - QJsonObject toInfoJson(const InfoT& info) + template QJsonObject toInfoJson(const InfoT& info) { QJsonObject infoJson; info.fillInfoJson(&infoJson); @@ -127,17 +125,17 @@ namespace QMatrixClient class ImageInfo : public FileInfo { public: - explicit ImageInfo(const QUrl& u, qint64 fileSize = -1, - QMimeType mimeType = {}, - const QSize& imageSize = {}, - const QString& originalFilename = {}); - ImageInfo(const QUrl& u, const QJsonObject& infoJson, - const QString& originalFilename = {}); + explicit ImageInfo(const QUrl& u, qint64 fileSize = -1, + QMimeType mimeType = {}, + const QSize& imageSize = {}, + const QString& originalFilename = {}); + ImageInfo(const QUrl& u, const QJsonObject& infoJson, + const QString& originalFilename = {}); - void fillInfoJson(QJsonObject* infoJson) const; + void fillInfoJson(QJsonObject* infoJson) const; public: - QSize imageSize; + QSize imageSize; }; /** @@ -150,26 +148,26 @@ namespace QMatrixClient class Thumbnail : public ImageInfo { public: - Thumbnail() : ImageInfo(QUrl()) { } // To allow empty thumbnails - Thumbnail(const QJsonObject& infoJson); - Thumbnail(const ImageInfo& info) : ImageInfo(info) { } - using ImageInfo::ImageInfo; + Thumbnail() : ImageInfo(QUrl()) {} // To allow empty thumbnails + Thumbnail(const QJsonObject& infoJson); + Thumbnail(const ImageInfo& info) : ImageInfo(info) {} + using ImageInfo::ImageInfo; - /** - * Writes thumbnail information to "thumbnail_info" subobject - * and thumbnail URL to "thumbnail_url" node inside "info". - */ - void fillInfoJson(QJsonObject* infoJson) const; + /** + * Writes thumbnail information to "thumbnail_info" subobject + * and thumbnail URL to "thumbnail_url" node inside "info". + */ + void fillInfoJson(QJsonObject* infoJson) const; }; - class TypedBase: public Base + class TypedBase : public Base { public: - explicit TypedBase(const QJsonObject& o = {}) : Base(o) { } - virtual QMimeType type() const = 0; - virtual const FileInfo* fileInfo() const { return nullptr; } - virtual FileInfo* fileInfo() { return nullptr; } - virtual const Thumbnail* thumbnailInfo() const { return nullptr; } + explicit TypedBase(const QJsonObject& o = {}) : Base(o) {} + virtual QMimeType type() const = 0; + virtual const FileInfo* fileInfo() const { return nullptr; } + virtual FileInfo* fileInfo() { return nullptr; } + virtual const Thumbnail* thumbnailInfo() const { return nullptr; } }; /** @@ -186,59 +184,61 @@ namespace QMatrixClient class UrlBasedContent : public TypedBase, public InfoT { public: - using InfoT::InfoT; - explicit UrlBasedContent(const QJsonObject& json) - : TypedBase(json) - , InfoT(json["url"].toString(), json["info"].toObject(), - json["filename"].toString()) - { - // A small hack to facilitate links creation in QML. - originalJson.insert("mediaId", InfoT::mediaId()); - } + using InfoT::InfoT; + explicit UrlBasedContent(const QJsonObject& json) + : TypedBase(json), + InfoT(json["url"].toString(), json["info"].toObject(), + json["filename"].toString()) + { + // A small hack to facilitate links creation in QML. + originalJson.insert("mediaId", InfoT::mediaId()); + } - QMimeType type() const override { return InfoT::mimeType; } - const FileInfo* fileInfo() const override { return this; } - FileInfo* fileInfo() override { return this; } + QMimeType type() const override { return InfoT::mimeType; } + const FileInfo* fileInfo() const override { return this; } + FileInfo* fileInfo() override { return this; } protected: - void fillJson(QJsonObject* json) const override - { - Q_ASSERT(json); - json->insert("url", InfoT::url.toString()); - if (!InfoT::originalName.isEmpty()) - json->insert("filename", InfoT::originalName); - json->insert("info", toInfoJson(*this)); - } + void fillJson(QJsonObject* json) const override + { + Q_ASSERT(json); + json->insert("url", InfoT::url.toString()); + if (!InfoT::originalName.isEmpty()) + json->insert("filename", InfoT::originalName); + json->insert("info", toInfoJson(*this)); + } }; template class UrlWithThumbnailContent : public UrlBasedContent { public: - using UrlBasedContent::UrlBasedContent; - explicit UrlWithThumbnailContent(const QJsonObject& json) - : UrlBasedContent(json) - , thumbnail(InfoT::originalInfoJson) - { - // Another small hack, to simplify making a thumbnail link - UrlBasedContent::originalJson.insert( - "thumbnailMediaId", thumbnail.mediaId()); - } + using UrlBasedContent::UrlBasedContent; + explicit UrlWithThumbnailContent(const QJsonObject& json) + : UrlBasedContent(json), + thumbnail(InfoT::originalInfoJson) + { + // Another small hack, to simplify making a thumbnail link + UrlBasedContent::originalJson.insert( + "thumbnailMediaId", thumbnail.mediaId()); + } - const Thumbnail* thumbnailInfo() const override - { return &thumbnail; } + const Thumbnail* thumbnailInfo() const override + { + return &thumbnail; + } public: - Thumbnail thumbnail; + Thumbnail thumbnail; protected: - void fillJson(QJsonObject* json) const override - { - UrlBasedContent::fillJson(json); - auto infoJson = json->take("info").toObject(); - thumbnail.fillInfoJson(&infoJson); - json->insert("info", infoJson); - } + void fillJson(QJsonObject* json) const override + { + UrlBasedContent::fillJson(json); + auto infoJson = json->take("info").toObject(); + thumbnail.fillInfoJson(&infoJson); + json->insert("info", infoJson); + } }; /** @@ -278,5 +278,5 @@ namespace QMatrixClient * - thumbnail.imageSize (QSize for "h" and "w" in JSON) */ using FileContent = UrlWithThumbnailContent; - } // namespace EventContent -} // namespace QMatrixClient + } // namespace EventContent +} // namespace QMatrixClient diff --git a/lib/events/eventloader.h b/lib/events/eventloader.h index da663392..a19a83b6 100644 --- a/lib/events/eventloader.h +++ b/lib/events/eventloader.h @@ -1,20 +1,20 @@ /****************************************************************************** -* Copyright (C) 2018 Kitsune Ral -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2018 Kitsune Ral + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #pragma once @@ -57,8 +57,7 @@ namespace QMatrixClient { matrixType); } - template struct JsonConverter> - { + template struct JsonConverter> { static auto load(const QJsonValue& jv) { return loadEvent(jv.toObject()); diff --git a/lib/events/receiptevent.cpp b/lib/events/receiptevent.cpp index 47e1398c..76c7b6e4 100644 --- a/lib/events/receiptevent.cpp +++ b/lib/events/receiptevent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* @@ -40,30 +40,27 @@ Example of a Receipt Event: using namespace QMatrixClient; -ReceiptEvent::ReceiptEvent(const QJsonObject& obj) - : Event(typeId(), obj) +ReceiptEvent::ReceiptEvent(const QJsonObject& obj) : Event(typeId(), obj) { const auto& contents = contentJson(); _eventsWithReceipts.reserve(contents.size()); - for( auto eventIt = contents.begin(); eventIt != contents.end(); ++eventIt ) - { - if (eventIt.key().isEmpty()) - { - qCWarning(EPHEMERAL) << "ReceiptEvent has an empty event id, skipping"; + for (auto eventIt = contents.begin(); eventIt != contents.end(); + ++eventIt) { + if (eventIt.key().isEmpty()) { + qCWarning(EPHEMERAL) + << "ReceiptEvent has an empty event id, skipping"; qCDebug(EPHEMERAL) << "ReceiptEvent content follows:\n" << contents; continue; } - const QJsonObject reads = eventIt.value().toObject() - .value("m.read"_ls).toObject(); + const QJsonObject reads = + eventIt.value().toObject().value("m.read"_ls).toObject(); QVector receipts; receipts.reserve(reads.size()); - for( auto userIt = reads.begin(); userIt != reads.end(); ++userIt ) - { + for (auto userIt = reads.begin(); userIt != reads.end(); ++userIt) { const QJsonObject user = userIt.value().toObject(); - receipts.push_back({userIt.key(), - fromJson(user["ts"_ls])}); + receipts.push_back( + { userIt.key(), fromJson(user["ts"_ls]) }); } - _eventsWithReceipts.push_back({eventIt.key(), std::move(receipts)}); + _eventsWithReceipts.push_back({ eventIt.key(), std::move(receipts) }); } } - diff --git a/lib/events/receiptevent.h b/lib/events/receiptevent.h index c15a01c2..fca38bba 100644 --- a/lib/events/receiptevent.h +++ b/lib/events/receiptevent.h @@ -13,42 +13,41 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "event.h" -#include #include +#include -namespace QMatrixClient -{ - struct Receipt - { +namespace QMatrixClient { + struct Receipt { QString userId; QDateTime timestamp; }; - struct ReceiptsForEvent - { + struct ReceiptsForEvent { QString evtId; QVector receipts; }; using EventsWithReceipts = QVector; - class ReceiptEvent: public Event + class ReceiptEvent : public Event { public: - DEFINE_EVENT_TYPEID("m.receipt", ReceiptEvent) - explicit ReceiptEvent(const QJsonObject& obj); + DEFINE_EVENT_TYPEID("m.receipt", ReceiptEvent) + explicit ReceiptEvent(const QJsonObject& obj); - const EventsWithReceipts& eventsWithReceipts() const - { return _eventsWithReceipts; } + const EventsWithReceipts& eventsWithReceipts() const + { + return _eventsWithReceipts; + } private: - EventsWithReceipts _eventsWithReceipts; + EventsWithReceipts _eventsWithReceipts; }; REGISTER_EVENT_TYPE(ReceiptEvent) DEFINE_EVENTTYPE_ALIAS(Receipt, ReceiptEvent) -} // namespace QMatrixClient +} // namespace QMatrixClient diff --git a/lib/events/redactionevent.h b/lib/events/redactionevent.h index a72a8ff9..4187291c 100644 --- a/lib/events/redactionevent.h +++ b/lib/events/redactionevent.h @@ -13,28 +13,29 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "roomevent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { class RedactionEvent : public RoomEvent { public: - DEFINE_EVENT_TYPEID("m.room.redaction", RedactionEvent) + DEFINE_EVENT_TYPEID("m.room.redaction", RedactionEvent) - explicit RedactionEvent(const QJsonObject& obj) - : RoomEvent(typeId(), obj) - { } + explicit RedactionEvent(const QJsonObject& obj) + : RoomEvent(typeId(), obj) + { + } - QString redactedEvent() const - { return fullJson()["redacts"_ls].toString(); } - QString reason() const - { return contentJson()["reason"_ls].toString(); } + QString redactedEvent() const + { + return fullJson()["redacts"_ls].toString(); + } + QString reason() const { return contentJson()["reason"_ls].toString(); } }; REGISTER_EVENT_TYPE(RedactionEvent) DEFINE_EVENTTYPE_ALIAS(Redaction, RedactionEvent) diff --git a/lib/events/roomavatarevent.h b/lib/events/roomavatarevent.h index a43d3a85..69cd1f9d 100644 --- a/lib/events/roomavatarevent.h +++ b/lib/events/roomavatarevent.h @@ -13,29 +13,29 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once -#include "stateevent.h" #include "eventcontent.h" +#include "stateevent.h" -namespace QMatrixClient -{ - class RoomAvatarEvent: public StateEvent +namespace QMatrixClient { + class RoomAvatarEvent : public StateEvent { - // It's a bit of an overkill to use a full-fledged ImageContent - // because in reality m.room.avatar usually only has a single URL, - // without a thumbnail. But The Spec says there be thumbnails, and - // we follow The Spec. + // It's a bit of an overkill to use a full-fledged ImageContent + // because in reality m.room.avatar usually only has a single URL, + // without a thumbnail. But The Spec says there be thumbnails, and + // we follow The Spec. public: - DEFINE_EVENT_TYPEID("m.room.avatar", RoomAvatarEvent) - explicit RoomAvatarEvent(const QJsonObject& obj) - : StateEvent(typeId(), obj) - { } - QUrl url() const { return content().url; } + DEFINE_EVENT_TYPEID("m.room.avatar", RoomAvatarEvent) + explicit RoomAvatarEvent(const QJsonObject& obj) + : StateEvent(typeId(), obj) + { + } + QUrl url() const { return content().url; } }; REGISTER_EVENT_TYPE(RoomAvatarEvent) DEFINE_EVENTTYPE_ALIAS(RoomAvatar, RoomAvatarEvent) -} // namespace QMatrixClient +} // namespace QMatrixClient diff --git a/lib/events/roomcreateevent.cpp b/lib/events/roomcreateevent.cpp index 8fd0f1de..cb575f24 100644 --- a/lib/events/roomcreateevent.cpp +++ b/lib/events/roomcreateevent.cpp @@ -1,20 +1,20 @@ /****************************************************************************** -* Copyright (C) 2019 QMatrixClient project -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2019 QMatrixClient project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "roomcreateevent.h" @@ -33,10 +33,8 @@ QString RoomCreateEvent::version() const RoomCreateEvent::Predecessor RoomCreateEvent::predecessor() const { const auto predJson = contentJson()["predecessor"_ls].toObject(); - return { - fromJson(predJson["room_id"_ls]), - fromJson(predJson["event_id"_ls]) - }; + return { fromJson(predJson["room_id"_ls]), + fromJson(predJson["event_id"_ls]) }; } bool RoomCreateEvent::isUpgrade() const diff --git a/lib/events/roomcreateevent.h b/lib/events/roomcreateevent.h index 0a8f27cc..fbfb33ca 100644 --- a/lib/events/roomcreateevent.h +++ b/lib/events/roomcreateevent.h @@ -1,49 +1,46 @@ /****************************************************************************** -* Copyright (C) 2019 QMatrixClient project -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2019 QMatrixClient project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #pragma once #include "stateevent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { class RoomCreateEvent : public StateEventBase { public: - DEFINE_EVENT_TYPEID("m.room.create", RoomCreateEvent) + DEFINE_EVENT_TYPEID("m.room.create", RoomCreateEvent) - explicit RoomCreateEvent() - : StateEventBase(typeId(), matrixTypeId()) - { } - explicit RoomCreateEvent(const QJsonObject& obj) - : StateEventBase(typeId(), obj) - { } + explicit RoomCreateEvent() : StateEventBase(typeId(), matrixTypeId()) {} + explicit RoomCreateEvent(const QJsonObject& obj) + : StateEventBase(typeId(), obj) + { + } - struct Predecessor - { - QString roomId; - QString eventId; - }; + struct Predecessor { + QString roomId; + QString eventId; + }; - bool isFederated() const; - QString version() const; - Predecessor predecessor() const; - bool isUpgrade() const; + bool isFederated() const; + QString version() const; + Predecessor predecessor() const; + bool isUpgrade() const; }; REGISTER_EVENT_TYPE(RoomCreateEvent) } diff --git a/lib/events/roomevent.cpp b/lib/events/roomevent.cpp index 3d03509f..221a3a61 100644 --- a/lib/events/roomevent.cpp +++ b/lib/events/roomevent.cpp @@ -1,26 +1,26 @@ /****************************************************************************** -* Copyright (C) 2018 Kitsune Ral -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2018 Kitsune Ral + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "roomevent.h" -#include "redactionevent.h" #include "converters.h" #include "logging.h" +#include "redactionevent.h" using namespace QMatrixClient; @@ -30,15 +30,14 @@ using namespace QMatrixClient; RoomEvent::RoomEvent(Type type, event_mtype_t matrixType, const QJsonObject& contentJson) : Event(type, matrixType, contentJson) -{ } +{ +} -RoomEvent::RoomEvent(Type type, const QJsonObject& json) - : Event(type, json) +RoomEvent::RoomEvent(Type type, const QJsonObject& json) : Event(type, json) { const auto unsignedData = json[UnsignedKeyL].toObject(); const auto redaction = unsignedData[RedactedCauseKeyL]; - if (redaction.isObject()) - { + if (redaction.isObject()) { _redactedBecause = makeEvent(redaction.toObject()); return; } @@ -46,14 +45,12 @@ RoomEvent::RoomEvent(Type type, const QJsonObject& json) RoomEvent::~RoomEvent() = default; // Let the smart pointer do its job -QString RoomEvent::id() const -{ - return fullJson()[EventIdKeyL].toString(); -} +QString RoomEvent::id() const { return fullJson()[EventIdKeyL].toString(); } QDateTime RoomEvent::timestamp() const { - return QMatrixClient::fromJson(fullJson()["origin_server_ts"_ls]); + return QMatrixClient::fromJson( + fullJson()["origin_server_ts"_ls]); } QString RoomEvent::roomId() const @@ -68,7 +65,7 @@ QString RoomEvent::senderId() const QString RoomEvent::redactionReason() const { - return isRedacted() ? _redactedBecause->reason() : QString{}; + return isRedacted() ? _redactedBecause->reason() : QString {}; } QString RoomEvent::transactionId() const @@ -91,7 +88,8 @@ void RoomEvent::setTransactionId(const QString& txnId) void RoomEvent::addId(const QString& newId) { - Q_ASSERT(id().isEmpty()); Q_ASSERT(!newId.isEmpty()); + Q_ASSERT(id().isEmpty()); + Q_ASSERT(!newId.isEmpty()); editJson().insert(EventIdKey, newId); qCDebug(EVENTS) << "Event txnId -> id:" << transactionId() << "->" << id(); Q_ASSERT(id() == newId); @@ -110,7 +108,8 @@ CallEventBase::CallEventBase(Type type, event_mtype_t matrixType, const QJsonObject& contentJson) : RoomEvent(type, matrixType, makeCallContentJson(callId, version, contentJson)) -{ } +{ +} CallEventBase::CallEventBase(Event::Type type, const QJsonObject& json) : RoomEvent(type, json) diff --git a/lib/events/roomevent.h b/lib/events/roomevent.h index ce96174e..746e9173 100644 --- a/lib/events/roomevent.h +++ b/lib/events/roomevent.h @@ -1,20 +1,20 @@ /****************************************************************************** -* Copyright (C) 2018 Kitsune Ral -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2018 Kitsune Ral + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #pragma once @@ -22,84 +22,84 @@ #include -namespace QMatrixClient -{ +namespace QMatrixClient { class RedactionEvent; /** This class corresponds to m.room.* events */ class RoomEvent : public Event { - Q_GADGET - Q_PROPERTY(QString id READ id) - Q_PROPERTY(QDateTime timestamp READ timestamp CONSTANT) - Q_PROPERTY(QString roomId READ roomId CONSTANT) - Q_PROPERTY(QString senderId READ senderId CONSTANT) - Q_PROPERTY(QString redactionReason READ redactionReason) - Q_PROPERTY(bool isRedacted READ isRedacted) - Q_PROPERTY(QString transactionId READ transactionId WRITE setTransactionId) + Q_GADGET + Q_PROPERTY(QString id READ id) + Q_PROPERTY(QDateTime timestamp READ timestamp CONSTANT) + Q_PROPERTY(QString roomId READ roomId CONSTANT) + Q_PROPERTY(QString senderId READ senderId CONSTANT) + Q_PROPERTY(QString redactionReason READ redactionReason) + Q_PROPERTY(bool isRedacted READ isRedacted) + Q_PROPERTY( + QString transactionId READ transactionId WRITE setTransactionId) public: - using factory_t = EventFactory; + using factory_t = EventFactory; - // RedactionEvent is an incomplete type here so we cannot inline - // constructors and destructors and we cannot use 'using'. - RoomEvent(Type type, event_mtype_t matrixType, - const QJsonObject& contentJson = {}); - RoomEvent(Type type, const QJsonObject& json); - ~RoomEvent() override; + // RedactionEvent is an incomplete type here so we cannot inline + // constructors and destructors and we cannot use 'using'. + RoomEvent(Type type, event_mtype_t matrixType, + const QJsonObject& contentJson = {}); + RoomEvent(Type type, const QJsonObject& json); + ~RoomEvent() override; - QString id() const; - QDateTime timestamp() const; - QString roomId() const; - QString senderId() const; - bool isRedacted() const { return bool(_redactedBecause); } - const event_ptr_tt& redactedBecause() const - { - return _redactedBecause; - } - QString redactionReason() const; - QString transactionId() const; - QString stateKey() const; + QString id() const; + QDateTime timestamp() const; + QString roomId() const; + QString senderId() const; + bool isRedacted() const { return bool(_redactedBecause); } + const event_ptr_tt& redactedBecause() const + { + return _redactedBecause; + } + QString redactionReason() const; + QString transactionId() const; + QString stateKey() const; - /** - * Sets the transaction id for locally created events. This should be - * done before the event is exposed to any code using the respective - * Q_PROPERTY. - * - * \param txnId - transaction id, normally obtained from - * Connection::generateTxnId() - */ - void setTransactionId(const QString& txnId); + /** + * Sets the transaction id for locally created events. This should be + * done before the event is exposed to any code using the respective + * Q_PROPERTY. + * + * \param txnId - transaction id, normally obtained from + * Connection::generateTxnId() + */ + void setTransactionId(const QString& txnId); - /** - * Sets event id for locally created events - * - * When a new event is created locally, it has no server id yet. - * This function allows to add the id once the confirmation from - * the server is received. There should be no id set previously - * in the event. It's the responsibility of the code calling addId() - * to notify clients that use Q_PROPERTY(id) about its change - */ - void addId(const QString& newId); + /** + * Sets event id for locally created events + * + * When a new event is created locally, it has no server id yet. + * This function allows to add the id once the confirmation from + * the server is received. There should be no id set previously + * in the event. It's the responsibility of the code calling addId() + * to notify clients that use Q_PROPERTY(id) about its change + */ + void addId(const QString& newId); private: - event_ptr_tt _redactedBecause; + event_ptr_tt _redactedBecause; }; using RoomEventPtr = event_ptr_tt; using RoomEvents = EventsArray; using RoomEventsRange = Range; - class CallEventBase: public RoomEvent + class CallEventBase : public RoomEvent { public: - CallEventBase(Type type, event_mtype_t matrixType, - const QString& callId, int version, - const QJsonObject& contentJson = {}); - CallEventBase(Type type, const QJsonObject& json); - ~CallEventBase() override = default; - bool isCallEvent() const override { return true; } + CallEventBase(Type type, event_mtype_t matrixType, + const QString& callId, int version, + const QJsonObject& contentJson = {}); + CallEventBase(Type type, const QJsonObject& json); + ~CallEventBase() override = default; + bool isCallEvent() const override { return true; } - QString callId() const { return content("call_id"_ls); } - int version() const { return content("version"_ls); } + QString callId() const { return content("call_id"_ls); } + int version() const { return content("version"_ls); } }; } // namespace QMatrixClient Q_DECLARE_METATYPE(QMatrixClient::RoomEvent*) diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp index a5ac3c5f..53203873 100644 --- a/lib/events/roommemberevent.cpp +++ b/lib/events/roommemberevent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "roommemberevent.h" @@ -23,21 +23,18 @@ #include -static const std::array membershipStrings = { { - QStringLiteral("invite"), QStringLiteral("join"), - QStringLiteral("knock"), QStringLiteral("leave"), - QStringLiteral("ban") -} }; +static const std::array membershipStrings = { + { QStringLiteral("invite"), QStringLiteral("join"), QStringLiteral("knock"), + QStringLiteral("leave"), QStringLiteral("ban") } +}; namespace QMatrixClient { - template <> - struct JsonConverter - { + template <> struct JsonConverter { static MembershipType load(const QJsonValue& jv) { const auto& membershipString = jv.toString(); for (auto it = membershipStrings.begin(); - it != membershipStrings.end(); ++it) + it != membershipStrings.end(); ++it) if (membershipString == *it) return MembershipType(it - membershipStrings.begin()); @@ -50,17 +47,18 @@ namespace QMatrixClient { using namespace QMatrixClient; MemberEventContent::MemberEventContent(const QJsonObject& json) - : membership(fromJson(json["membership"_ls])) - , isDirect(json["is_direct"_ls].toBool()) - , displayName(json["displayname"_ls].toString()) - , avatarUrl(json["avatar_url"_ls].toString()) -{ } + : membership(fromJson(json["membership"_ls])), + isDirect(json["is_direct"_ls].toBool()), + displayName(json["displayname"_ls].toString()), + avatarUrl(json["avatar_url"_ls].toString()) +{ +} void MemberEventContent::fillJson(QJsonObject* o) const { Q_ASSERT(o); Q_ASSERT_X(membership != MembershipType::Undefined, __FUNCTION__, - "The key 'membership' must be explicit in MemberEventContent"); + "The key 'membership' must be explicit in MemberEventContent"); if (membership != MembershipType::Undefined) o->insert(QStringLiteral("membership"), membershipStrings[membership]); o->insert(QStringLiteral("displayname"), displayName); @@ -70,21 +68,21 @@ void MemberEventContent::fillJson(QJsonObject* o) const bool RoomMemberEvent::isInvite() const { - return membership() == MembershipType::Invite && - (!prevContent() || prevContent()->membership != membership()); + return membership() == MembershipType::Invite + && (!prevContent() || prevContent()->membership != membership()); } bool RoomMemberEvent::isJoin() const { - return membership() == MembershipType::Join && - (!prevContent() || prevContent()->membership != membership()); + return membership() == MembershipType::Join + && (!prevContent() || prevContent()->membership != membership()); } bool RoomMemberEvent::isLeave() const { - return membership() == MembershipType::Leave && - prevContent() && prevContent()->membership != membership() && - prevContent()->membership != MembershipType::Ban; + return membership() == MembershipType::Leave && prevContent() + && prevContent()->membership != membership() + && prevContent()->membership != MembershipType::Ban; } bool RoomMemberEvent::isRename() const diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h index b8224033..55f419d8 100644 --- a/lib/events/roommemberevent.h +++ b/lib/events/roommemberevent.h @@ -13,94 +13,100 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once -#include "stateevent.h" #include "eventcontent.h" +#include "stateevent.h" -namespace QMatrixClient -{ - class MemberEventContent: public EventContent::Base +namespace QMatrixClient { + class MemberEventContent : public EventContent::Base { public: - enum MembershipType : size_t { Invite = 0, Join, Knock, Leave, Ban, - Undefined }; + enum MembershipType : size_t { + Invite = 0, + Join, + Knock, + Leave, + Ban, + Undefined + }; - explicit MemberEventContent(MembershipType mt = Join) - : membership(mt) - { } - explicit MemberEventContent(const QJsonObject& json); + explicit MemberEventContent(MembershipType mt = Join) : membership(mt) + { + } + explicit MemberEventContent(const QJsonObject& json); - MembershipType membership; - bool isDirect = false; - QString displayName; - QUrl avatarUrl; + MembershipType membership; + bool isDirect = false; + QString displayName; + QUrl avatarUrl; protected: - void fillJson(QJsonObject* o) const override; + void fillJson(QJsonObject* o) const override; }; using MembershipType = MemberEventContent::MembershipType; - class RoomMemberEvent: public StateEvent + class RoomMemberEvent : public StateEvent { - Q_GADGET + Q_GADGET public: - DEFINE_EVENT_TYPEID("m.room.member", RoomMemberEvent) + DEFINE_EVENT_TYPEID("m.room.member", RoomMemberEvent) - using MembershipType = MemberEventContent::MembershipType; + using MembershipType = MemberEventContent::MembershipType; - explicit RoomMemberEvent(const QJsonObject& obj) - : StateEvent(typeId(), obj) - { } - RoomMemberEvent(MemberEventContent&& c) - : StateEvent(typeId(), matrixTypeId(), c) - { } + explicit RoomMemberEvent(const QJsonObject& obj) + : StateEvent(typeId(), obj) + { + } + RoomMemberEvent(MemberEventContent&& c) + : StateEvent(typeId(), matrixTypeId(), c) + { + } - /// A special constructor to create unknown RoomMemberEvents - /** - * This is needed in order to use RoomMemberEvent as a "base event - * class" in cases like GetMembersByRoomJob when RoomMemberEvents - * (rather than RoomEvents or StateEvents) are resolved from JSON. - * For such cases loadEvent<> requires an underlying class to be - * constructible with unknownTypeId() instead of its genuine id. - * Don't use it directly. - * \sa GetMembersByRoomJob, loadEvent, unknownTypeId - */ - RoomMemberEvent(Type type, const QJsonObject& fullJson) - : StateEvent(type, fullJson) - { } + /// A special constructor to create unknown RoomMemberEvents + /** + * This is needed in order to use RoomMemberEvent as a "base event + * class" in cases like GetMembersByRoomJob when RoomMemberEvents + * (rather than RoomEvents or StateEvents) are resolved from JSON. + * For such cases loadEvent<> requires an underlying class to be + * constructible with unknownTypeId() instead of its genuine id. + * Don't use it directly. + * \sa GetMembersByRoomJob, loadEvent, unknownTypeId + */ + RoomMemberEvent(Type type, const QJsonObject& fullJson) + : StateEvent(type, fullJson) + { + } - MembershipType membership() const { return content().membership; } - QString userId() const - { return fullJson()["state_key"_ls].toString(); } - bool isDirect() const { return content().isDirect; } - QString displayName() const { return content().displayName; } - QUrl avatarUrl() const { return content().avatarUrl; } - bool isInvite() const; - bool isJoin() const; - bool isLeave() const; - bool isRename() const; - bool isAvatarUpdate() const; + MembershipType membership() const { return content().membership; } + QString userId() const { return fullJson()["state_key"_ls].toString(); } + bool isDirect() const { return content().isDirect; } + QString displayName() const { return content().displayName; } + QUrl avatarUrl() const { return content().avatarUrl; } + bool isInvite() const; + bool isJoin() const; + bool isLeave() const; + bool isRename() const; + bool isAvatarUpdate() const; private: - REGISTER_ENUM(MembershipType) + REGISTER_ENUM(MembershipType) }; - template <> - class EventFactory + template <> class EventFactory { public: - static event_ptr_tt make(const QJsonObject& json, - const QString&) - { - return makeEvent(json); - } + static event_ptr_tt make(const QJsonObject& json, + const QString&) + { + return makeEvent(json); + } }; REGISTER_EVENT_TYPE(RoomMemberEvent) DEFINE_EVENTTYPE_ALIAS(RoomMember, RoomMemberEvent) -} // namespace QMatrixClient +} // namespace QMatrixClient diff --git a/lib/events/roommessageevent.cpp b/lib/events/roommessageevent.cpp index 8f4e0ebc..0af02eb0 100644 --- a/lib/events/roommessageevent.cpp +++ b/lib/events/roommessageevent.cpp @@ -13,15 +13,15 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "roommessageevent.h" #include "logging.h" -#include #include +#include #include #include @@ -40,41 +40,40 @@ static const auto NoticeTypeKey = "m.notice"; static const auto HtmlContentTypeId = QStringLiteral("org.matrix.custom.html"); -template -TypedBase* make(const QJsonObject& json) +template TypedBase* make(const QJsonObject& json) { return new ContentT(json); } -template <> -TypedBase* make(const QJsonObject& json) +template <> TypedBase* make(const QJsonObject& json) { return json.contains(FormattedBodyKey) || json.contains(RelatesToKey) - ? new TextContent(json) : nullptr; + ? new TextContent(json) + : nullptr; } -struct MsgTypeDesc -{ +struct MsgTypeDesc { QString matrixType; MsgType enumType; TypedBase* (*maker)(const QJsonObject&); }; -const std::vector msgTypes = - { { TextTypeKey, MsgType::Text, make } - , { QStringLiteral("m.emote"), MsgType::Emote, make } - , { NoticeTypeKey, MsgType::Notice, make } - , { QStringLiteral("m.image"), MsgType::Image, make } - , { QStringLiteral("m.file"), MsgType::File, make } - , { QStringLiteral("m.location"), MsgType::Location, make } - , { QStringLiteral("m.video"), MsgType::Video, make } - , { QStringLiteral("m.audio"), MsgType::Audio, make } - }; +const std::vector msgTypes = { + { TextTypeKey, MsgType::Text, make }, + { QStringLiteral("m.emote"), MsgType::Emote, make }, + { NoticeTypeKey, MsgType::Notice, make }, + { QStringLiteral("m.image"), MsgType::Image, make }, + { QStringLiteral("m.file"), MsgType::File, make }, + { QStringLiteral("m.location"), MsgType::Location, make }, + { QStringLiteral("m.video"), MsgType::Video, make }, + { QStringLiteral("m.audio"), MsgType::Audio, make } +}; QString msgTypeToJson(MsgType enumType) { - auto it = std::find_if(msgTypes.begin(), msgTypes.end(), - [=](const MsgTypeDesc& mtd) { return mtd.enumType == enumType; }); + auto it = std::find_if( + msgTypes.begin(), msgTypes.end(), + [=](const MsgTypeDesc& mtd) { return mtd.enumType == enumType; }); if (it != msgTypes.end()) return it->matrixType; @@ -84,7 +83,9 @@ QString msgTypeToJson(MsgType enumType) MsgType jsonToMsgType(const QString& matrixType) { auto it = std::find_if(msgTypes.begin(), msgTypes.end(), - [=](const MsgTypeDesc& mtd) { return mtd.matrixType == matrixType; }); + [=](const MsgTypeDesc& mtd) { + return mtd.matrixType == matrixType; + }); if (it != msgTypes.end()) return it->enumType; @@ -92,12 +93,12 @@ MsgType jsonToMsgType(const QString& matrixType) } QJsonObject RoomMessageEvent::assembleContentJson(const QString& plainBody, - const QString& jsonMsgType, TypedBase* content) + const QString& jsonMsgType, + TypedBase* content) { auto json = content ? content->toJson() : QJsonObject(); - if (jsonMsgType != TextTypeKey && jsonMsgType != NoticeTypeKey && - json.contains(RelatesToKey)) - { + if (jsonMsgType != TextTypeKey && jsonMsgType != NoticeTypeKey + && json.contains(RelatesToKey)) { json.remove(RelatesToKey); qCWarning(EVENTS) << RelatesToKey << "cannot be used in" << jsonMsgType << "messages; the relation has been stripped off"; @@ -108,24 +109,26 @@ QJsonObject RoomMessageEvent::assembleContentJson(const QString& plainBody, } RoomMessageEvent::RoomMessageEvent(const QString& plainBody, - const QString& jsonMsgType, TypedBase* content) + const QString& jsonMsgType, + TypedBase* content) : RoomEvent(typeId(), matrixTypeId(), - assembleContentJson(plainBody, jsonMsgType, content)) - , _content(content) -{ } + assembleContentJson(plainBody, jsonMsgType, content)), + _content(content) +{ +} -RoomMessageEvent::RoomMessageEvent(const QString& plainBody, - MsgType msgType, TypedBase* content) +RoomMessageEvent::RoomMessageEvent(const QString& plainBody, MsgType msgType, + TypedBase* content) : RoomMessageEvent(plainBody, msgTypeToJson(msgType), content) -{ } +{ +} TypedBase* contentFromFile(const QFileInfo& file, bool asGenericFile) { auto filePath = file.absoluteFilePath(); auto localUrl = QUrl::fromLocalFile(filePath); auto mimeType = QMimeDatabase().mimeTypeForFile(file); - if (!asGenericFile) - { + if (!asGenericFile) { auto mimeTypeName = mimeType.name(); if (mimeTypeName.startsWith("image/")) return new ImageContent(localUrl, file.size(), mimeType, @@ -147,11 +150,13 @@ TypedBase* contentFromFile(const QFileInfo& file, bool asGenericFile) } RoomMessageEvent::RoomMessageEvent(const QString& plainBody, - const QFileInfo& file, bool asGenericFile) + const QFileInfo& file, bool asGenericFile) : RoomMessageEvent(plainBody, - asGenericFile ? QStringLiteral("m.file") : rawMsgTypeForFile(file), - contentFromFile(file, asGenericFile)) -{ } + asGenericFile ? QStringLiteral("m.file") + : rawMsgTypeForFile(file), + contentFromFile(file, asGenericFile)) +{ +} RoomMessageEvent::RoomMessageEvent(const QJsonObject& obj) : RoomEvent(typeId(), obj), _content(nullptr) @@ -159,26 +164,21 @@ RoomMessageEvent::RoomMessageEvent(const QJsonObject& obj) if (isRedacted()) return; const QJsonObject content = contentJson(); - if ( content.contains(MsgTypeKey) && content.contains(BodyKey) ) - { + if (content.contains(MsgTypeKey) && content.contains(BodyKey)) { auto msgtype = content[MsgTypeKey].toString(); bool msgTypeFound = false; - for (const auto& mt: msgTypes) - if (mt.matrixType == msgtype) - { + for (const auto& mt : msgTypes) + if (mt.matrixType == msgtype) { _content.reset(mt.maker(content)); msgTypeFound = true; } - if (!msgTypeFound) - { + if (!msgTypeFound) { qCWarning(EVENTS) << "RoomMessageEvent: unknown msg_type," << " full content dump follows"; qCWarning(EVENTS) << formatJson << content; } - } - else - { + } else { qCWarning(EVENTS) << "No body or msgtype in room message event"; qCWarning(EVENTS) << formatJson << obj; } @@ -208,9 +208,9 @@ QMimeType RoomMessageEvent::mimeType() const bool RoomMessageEvent::hasTextContent() const { - return !content() || - (msgtype() == MsgType::Text || msgtype() == MsgType::Emote || - msgtype() == MsgType::Notice); + return !content() + || (msgtype() == MsgType::Text || msgtype() == MsgType::Emote + || msgtype() == MsgType::Notice); } bool RoomMessageEvent::hasFileContent() const @@ -226,10 +226,11 @@ bool RoomMessageEvent::hasThumbnail() const QString rawMsgTypeForMimeType(const QMimeType& mimeType) { auto name = mimeType.name(); - return name.startsWith("image/") ? QStringLiteral("m.image") : - name.startsWith("video/") ? QStringLiteral("m.video") : - name.startsWith("audio/") ? QStringLiteral("m.audio") : - QStringLiteral("m.file"); + return name.startsWith("image/") ? QStringLiteral("m.image") + : name.startsWith("video/") + ? QStringLiteral("m.video") + : name.startsWith("audio/") ? QStringLiteral("m.audio") + : QStringLiteral("m.file"); } QString RoomMessageEvent::rawMsgTypeForUrl(const QUrl& url) @@ -244,8 +245,9 @@ QString RoomMessageEvent::rawMsgTypeForFile(const QFileInfo& fi) TextContent::TextContent(const QString& text, const QString& contentType, Omittable relatesTo) - : mimeType(QMimeDatabase().mimeTypeForName(contentType)), body(text) - , relatesTo(std::move(relatesTo)) + : mimeType(QMimeDatabase().mimeTypeForName(contentType)), + body(text), + relatesTo(std::move(relatesTo)) { if (contentType == HtmlContentTypeId) mimeType = QMimeDatabase().mimeTypeForName("text/html"); @@ -259,8 +261,7 @@ TextContent::TextContent(const QJsonObject& json) // Special-casing the custom matrix.org's (actually, Riot's) way // of sending HTML messages. - if (json["format"_ls].toString() == HtmlContentTypeId) - { + if (json["format"_ls].toString() == HtmlContentTypeId) { mimeType = HtmlMimeType; body = json[FormattedBodyKey].toString(); } else { @@ -269,8 +270,10 @@ TextContent::TextContent(const QJsonObject& json) mimeType = PlainTextMimeType; body = json[BodyKey].toString(); } - const auto replyJson = json[RelatesToKey].toObject() - .value(RelatesTo::ReplyTypeId()).toObject(); + const auto replyJson = json[RelatesToKey] + .toObject() + .value(RelatesTo::ReplyTypeId()) + .toObject(); if (!replyJson.isEmpty()) relatesTo = replyTo(fromJson(replyJson[EventIdKeyL])); } @@ -278,26 +281,27 @@ TextContent::TextContent(const QJsonObject& json) void TextContent::fillJson(QJsonObject* json) const { Q_ASSERT(json); - if (mimeType.inherits("text/html")) - { + if (mimeType.inherits("text/html")) { json->insert(QStringLiteral("format"), HtmlContentTypeId); json->insert(QStringLiteral("formatted_body"), body); } if (!relatesTo.omitted()) json->insert(QStringLiteral("m.relates_to"), - QJsonObject { { relatesTo->type, relatesTo->eventId } }); + QJsonObject { { relatesTo->type, relatesTo->eventId } }); } LocationContent::LocationContent(const QString& geoUri, const Thumbnail& thumbnail) : geoUri(geoUri), thumbnail(thumbnail) -{ } +{ +} LocationContent::LocationContent(const QJsonObject& json) - : TypedBase(json) - , geoUri(json["geo_uri"_ls].toString()) - , thumbnail(json["info"_ls].toObject()) -{ } + : TypedBase(json), + geoUri(json["geo_uri"_ls].toString()), + thumbnail(json["info"_ls].toObject()) +{ +} QMimeType LocationContent::type() const { diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index c2e075eb..bd1b7c83 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -13,88 +13,94 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once -#include "roomevent.h" #include "eventcontent.h" +#include "roomevent.h" class QFileInfo; -namespace QMatrixClient -{ +namespace QMatrixClient { namespace MessageEventContent = EventContent; // Back-compatibility /** * The event class corresponding to m.room.message events */ - class RoomMessageEvent: public RoomEvent + class RoomMessageEvent : public RoomEvent { - Q_GADGET - Q_PROPERTY(QString msgType READ rawMsgtype CONSTANT) - Q_PROPERTY(QString plainBody READ plainBody CONSTANT) - Q_PROPERTY(QMimeType mimeType READ mimeType STORED false CONSTANT) - Q_PROPERTY(EventContent::TypedBase* content READ content CONSTANT) + Q_GADGET + Q_PROPERTY(QString msgType READ rawMsgtype CONSTANT) + Q_PROPERTY(QString plainBody READ plainBody CONSTANT) + Q_PROPERTY(QMimeType mimeType READ mimeType STORED false CONSTANT) + Q_PROPERTY(EventContent::TypedBase* content READ content CONSTANT) public: - DEFINE_EVENT_TYPEID("m.room.message", RoomMessageEvent) + DEFINE_EVENT_TYPEID("m.room.message", RoomMessageEvent) + + enum class MsgType { + Text, + Emote, + Notice, + Image, + File, + Location, + Video, + Audio, + Unknown + }; - enum class MsgType - { - Text, Emote, Notice, Image, File, Location, Video, Audio, Unknown - }; - - RoomMessageEvent(const QString& plainBody, - const QString& jsonMsgType, - EventContent::TypedBase* content = nullptr); - explicit RoomMessageEvent(const QString& plainBody, - MsgType msgType = MsgType::Text, - EventContent::TypedBase* content = nullptr); - explicit RoomMessageEvent(const QString& plainBody, - const QFileInfo& file, - bool asGenericFile = false); - explicit RoomMessageEvent(const QJsonObject& obj); - - MsgType msgtype() const; - QString rawMsgtype() const; - QString plainBody() const; - EventContent::TypedBase* content() const - { return _content.data(); } - template - void editContent(VisitorT visitor) - { - visitor(*_content); - editJson()[ContentKeyL] = + RoomMessageEvent(const QString& plainBody, const QString& jsonMsgType, + EventContent::TypedBase* content = nullptr); + explicit RoomMessageEvent(const QString& plainBody, + MsgType msgType = MsgType::Text, + EventContent::TypedBase* content = nullptr); + explicit RoomMessageEvent(const QString& plainBody, + const QFileInfo& file, + bool asGenericFile = false); + explicit RoomMessageEvent(const QJsonObject& obj); + + MsgType msgtype() const; + QString rawMsgtype() const; + QString plainBody() const; + EventContent::TypedBase* content() const { return _content.data(); } + template void editContent(VisitorT visitor) + { + visitor(*_content); + editJson()[ContentKeyL] = assembleContentJson(plainBody(), rawMsgtype(), content()); - } - QMimeType mimeType() const; - bool hasTextContent() const; - bool hasFileContent() const; - bool hasThumbnail() const; + } + QMimeType mimeType() const; + bool hasTextContent() const; + bool hasFileContent() const; + bool hasThumbnail() const; - static QString rawMsgTypeForUrl(const QUrl& url); - static QString rawMsgTypeForFile(const QFileInfo& fi); + static QString rawMsgTypeForUrl(const QUrl& url); + static QString rawMsgTypeForFile(const QFileInfo& fi); private: - QScopedPointer _content; + QScopedPointer _content; - static QJsonObject assembleContentJson(const QString& plainBody, - const QString& jsonMsgType, EventContent::TypedBase* content); + static QJsonObject + assembleContentJson(const QString& plainBody, + const QString& jsonMsgType, + EventContent::TypedBase* content); - REGISTER_ENUM(MsgType) + REGISTER_ENUM(MsgType) }; REGISTER_EVENT_TYPE(RoomMessageEvent) DEFINE_EVENTTYPE_ALIAS(RoomMessage, RoomMessageEvent) using MessageEventType = RoomMessageEvent::MsgType; - namespace EventContent - { + namespace EventContent { // Additional event content types - struct RelatesTo - { - static constexpr const char* ReplyTypeId() { return "m.in_reply_to"; } + struct RelatesTo { + static constexpr const char* ReplyTypeId() + { + return "m.in_reply_to"; + } QString type; // The only supported relation so far QString eventId; }; @@ -109,21 +115,21 @@ namespace QMatrixClient * Available fields: mimeType, body. The body can be either rich text * or plain text, depending on what mimeType specifies. */ - class TextContent: public TypedBase + class TextContent : public TypedBase { public: - TextContent(const QString& text, const QString& contentType, - Omittable relatesTo = none); - explicit TextContent(const QJsonObject& json); + TextContent(const QString& text, const QString& contentType, + Omittable relatesTo = none); + explicit TextContent(const QJsonObject& json); - QMimeType type() const override { return mimeType; } + QMimeType type() const override { return mimeType; } - QMimeType mimeType; - QString body; - Omittable relatesTo; + QMimeType mimeType; + QString body; + Omittable relatesTo; protected: - void fillJson(QJsonObject* json) const override; + void fillJson(QJsonObject* json) const override; }; /** @@ -139,47 +145,47 @@ namespace QMatrixClient * - thumbnail.mimeType * - thumbnail.imageSize */ - class LocationContent: public TypedBase + class LocationContent : public TypedBase { public: - LocationContent(const QString& geoUri, - const Thumbnail& thumbnail = {}); - explicit LocationContent(const QJsonObject& json); + LocationContent(const QString& geoUri, + const Thumbnail& thumbnail = {}); + explicit LocationContent(const QJsonObject& json); - QMimeType type() const override; + QMimeType type() const override; public: - QString geoUri; - Thumbnail thumbnail; + QString geoUri; + Thumbnail thumbnail; protected: - void fillJson(QJsonObject* o) const override; + void fillJson(QJsonObject* o) const override; }; /** * A base class for info types that include duration: audio and video */ - template - class PlayableContent : public ContentT + template class PlayableContent : public ContentT { public: - using ContentT::ContentT; - PlayableContent(const QJsonObject& json) - : ContentT(json) - , duration(ContentT::originalInfoJson["duration"_ls].toInt()) - { } + using ContentT::ContentT; + PlayableContent(const QJsonObject& json) + : ContentT(json), + duration(ContentT::originalInfoJson["duration"_ls].toInt()) + { + } protected: - void fillJson(QJsonObject* json) const override - { - ContentT::fillJson(json); - auto infoJson = json->take("info"_ls).toObject(); - infoJson.insert(QStringLiteral("duration"), duration); - json->insert(QStringLiteral("info"), infoJson); - } + void fillJson(QJsonObject* json) const override + { + ContentT::fillJson(json); + auto infoJson = json->take("info"_ls).toObject(); + infoJson.insert(QStringLiteral("duration"), duration); + json->insert(QStringLiteral("info"), infoJson); + } public: - int duration; + int duration; }; /** @@ -201,7 +207,8 @@ namespace QMatrixClient * - mimeType * - imageSize */ - using VideoContent = PlayableContent>; + using VideoContent = + PlayableContent>; /** * Content class for m.audio @@ -216,5 +223,5 @@ namespace QMatrixClient * - duration */ using AudioContent = PlayableContent>; - } // namespace EventContent -} // namespace QMatrixClient + } // namespace EventContent +} // namespace QMatrixClient diff --git a/lib/events/roomtombstoneevent.cpp b/lib/events/roomtombstoneevent.cpp index 9c3bafd4..a74bb367 100644 --- a/lib/events/roomtombstoneevent.cpp +++ b/lib/events/roomtombstoneevent.cpp @@ -1,20 +1,20 @@ /****************************************************************************** -* Copyright (C) 2019 QMatrixClient project -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2019 QMatrixClient project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "roomtombstoneevent.h" diff --git a/lib/events/roomtombstoneevent.h b/lib/events/roomtombstoneevent.h index c7008ec4..5b7ade76 100644 --- a/lib/events/roomtombstoneevent.h +++ b/lib/events/roomtombstoneevent.h @@ -1,41 +1,41 @@ /****************************************************************************** -* Copyright (C) 2019 QMatrixClient project -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2019 QMatrixClient project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #pragma once #include "stateevent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { class RoomTombstoneEvent : public StateEventBase { public: - DEFINE_EVENT_TYPEID("m.room.tombstone", RoomTombstoneEvent) + DEFINE_EVENT_TYPEID("m.room.tombstone", RoomTombstoneEvent) - explicit RoomTombstoneEvent() - : StateEventBase(typeId(), matrixTypeId()) - { } - explicit RoomTombstoneEvent(const QJsonObject& obj) - : StateEventBase(typeId(), obj) - { } + explicit RoomTombstoneEvent() : StateEventBase(typeId(), matrixTypeId()) + { + } + explicit RoomTombstoneEvent(const QJsonObject& obj) + : StateEventBase(typeId(), obj) + { + } - QString serverMessage() const; - QString successorRoomId() const; + QString serverMessage() const; + QString successorRoomId() const; }; REGISTER_EVENT_TYPE(RoomTombstoneEvent) } diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index 2c23d9ca..430eacb0 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once @@ -22,71 +22,70 @@ #include "converters.h" -namespace QMatrixClient -{ - namespace EventContent - { - template - class SimpleContent +namespace QMatrixClient { + namespace EventContent { + template class SimpleContent { public: - using value_type = T; + using value_type = T; - // The constructor is templated to enable perfect forwarding - template - SimpleContent(QString keyName, TT&& value) - : value(std::forward(value)), key(std::move(keyName)) - { } - SimpleContent(const QJsonObject& json, QString keyName) - : value(fromJson(json[keyName])) - , key(std::move(keyName)) - { } - QJsonObject toJson() const - { - return { { key, QMatrixClient::toJson(value) } }; - } + // The constructor is templated to enable perfect forwarding + template + SimpleContent(QString keyName, TT&& value) + : value(std::forward(value)), key(std::move(keyName)) + { + } + SimpleContent(const QJsonObject& json, QString keyName) + : value(fromJson(json[keyName])), key(std::move(keyName)) + { + } + QJsonObject toJson() const + { + return { { key, QMatrixClient::toJson(value) } }; + } public: - T value; + T value; protected: - QString key; + QString key; }; } // namespace EventContent -#define DEFINE_SIMPLE_STATE_EVENT(_Name, _TypeId, _ValueType, _ContentKey) \ - class _Name : public StateEvent> \ - { \ - public: \ - using value_type = content_type::value_type; \ - DEFINE_EVENT_TYPEID(_TypeId, _Name) \ - explicit _Name() : _Name(value_type()) { } \ - template \ - explicit _Name(T&& value) \ - : StateEvent(typeId(), matrixTypeId(), \ - QStringLiteral(#_ContentKey), \ - std::forward(value)) \ - { } \ - explicit _Name(QJsonObject obj) \ - : StateEvent(typeId(), std::move(obj), \ - QStringLiteral(#_ContentKey)) \ - { } \ - auto _ContentKey() const { return content().value; } \ - }; \ - REGISTER_EVENT_TYPE(_Name) \ +#define DEFINE_SIMPLE_STATE_EVENT(_Name, _TypeId, _ValueType, _ContentKey) \ + class _Name : public StateEvent> \ + { \ + public: \ + using value_type = content_type::value_type; \ + DEFINE_EVENT_TYPEID(_TypeId, _Name) \ + explicit _Name() : _Name(value_type()) {} \ + template \ + explicit _Name(T&& value) \ + : StateEvent(typeId(), matrixTypeId(), \ + QStringLiteral(#_ContentKey), std::forward(value)) \ + { \ + } \ + explicit _Name(QJsonObject obj) \ + : StateEvent(typeId(), std::move(obj), \ + QStringLiteral(#_ContentKey)) \ + { \ + } \ + auto _ContentKey() const { return content().value; } \ + }; \ + REGISTER_EVENT_TYPE(_Name) \ // End of macro DEFINE_SIMPLE_STATE_EVENT(RoomNameEvent, "m.room.name", QString, name) DEFINE_EVENTTYPE_ALIAS(RoomName, RoomNameEvent) - DEFINE_SIMPLE_STATE_EVENT(RoomAliasesEvent, "m.room.aliases", - QStringList, aliases) + DEFINE_SIMPLE_STATE_EVENT(RoomAliasesEvent, "m.room.aliases", QStringList, + aliases) DEFINE_EVENTTYPE_ALIAS(RoomAliases, RoomAliasesEvent) DEFINE_SIMPLE_STATE_EVENT(RoomCanonicalAliasEvent, "m.room.canonical_alias", QString, alias) DEFINE_EVENTTYPE_ALIAS(RoomCanonicalAlias, RoomCanonicalAliasEvent) DEFINE_SIMPLE_STATE_EVENT(RoomTopicEvent, "m.room.topic", QString, topic) DEFINE_EVENTTYPE_ALIAS(RoomTopic, RoomTopicEvent) - DEFINE_SIMPLE_STATE_EVENT(EncryptionEvent, "m.room.encryption", - QString, algorithm) + DEFINE_SIMPLE_STATE_EVENT(EncryptionEvent, "m.room.encryption", QString, + algorithm) DEFINE_EVENTTYPE_ALIAS(RoomEncryption, EncryptionEvent) } // namespace QMatrixClient diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp index e96614d2..f172edb6 100644 --- a/lib/events/stateevent.cpp +++ b/lib/events/stateevent.cpp @@ -1,20 +1,20 @@ /****************************************************************************** -* Copyright (C) 2018 Kitsune Ral -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2018 Kitsune Ral + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "stateevent.h" @@ -24,9 +24,9 @@ using namespace QMatrixClient; // StateEventBase itself can be instantiated if there's a state_key JSON key // but the event type is unknown. [[gnu::unused]] static auto stateEventTypeInitialised = - RoomEvent::factory_t::addMethod( - [] (const QJsonObject& json, const QString& matrixType) -> StateEventPtr - { + RoomEvent::factory_t::addMethod([](const QJsonObject& json, + const QString& matrixType) + -> StateEventPtr { if (!json.contains("state_key")) return nullptr; @@ -53,6 +53,7 @@ void StateEventBase::dumpTo(QDebug dbg) const dbg << '<' << stateKey() << "> "; if (unsignedJson().contains(PrevContentKeyL)) dbg << QJsonDocument(unsignedJson()[PrevContentKeyL].toObject()) - .toJson(QJsonDocument::Compact) << " -> "; + .toJson(QJsonDocument::Compact) + << " -> "; RoomEvent::dumpTo(dbg); } diff --git a/lib/events/stateevent.h b/lib/events/stateevent.h index 3f54f7bf..1a02646b 100644 --- a/lib/events/stateevent.h +++ b/lib/events/stateevent.h @@ -1,119 +1,127 @@ /****************************************************************************** -* Copyright (C) 2018 Kitsune Ral -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * Copyright (C) 2018 Kitsune Ral + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #pragma once #include "roomevent.h" namespace QMatrixClient { - class StateEventBase: public RoomEvent + class StateEventBase : public RoomEvent { public: - using factory_t = EventFactory; + using factory_t = EventFactory; - using RoomEvent::RoomEvent; - ~StateEventBase() override = default; + using RoomEvent::RoomEvent; + ~StateEventBase() override = default; - bool isStateEvent() const override { return true; } - QString replacedState() const; - void dumpTo(QDebug dbg) const override; + bool isStateEvent() const override { return true; } + QString replacedState() const; + void dumpTo(QDebug dbg) const override; - virtual bool repeatsState() const; + virtual bool repeatsState() const; }; using StateEventPtr = event_ptr_tt; using StateEvents = EventsArray; - template <> - inline bool is(const Event& e) { return e.isStateEvent(); } + template <> inline bool is(const Event& e) + { + return e.isStateEvent(); + } /** * A combination of event type and state key uniquely identifies a piece * of state in Matrix. - * \sa https://matrix.org/docs/spec/client_server/unstable.html#types-of-room-events + * \sa + * https://matrix.org/docs/spec/client_server/unstable.html#types-of-room-events */ using StateEventKey = QPair; - template - struct Prev - { + template struct Prev { template explicit Prev(const QJsonObject& unsignedJson, ContentParamTs&&... contentParams) - : senderId(unsignedJson.value("prev_sender"_ls).toString()) - , content(unsignedJson.value(PrevContentKeyL).toObject(), - std::forward(contentParams)...) - { } + : senderId(unsignedJson.value("prev_sender"_ls).toString()), + content(unsignedJson.value(PrevContentKeyL).toObject(), + std::forward(contentParams)...) + { + } QString senderId; ContentT content; }; - template - class StateEvent: public StateEventBase + template class StateEvent : public StateEventBase { public: - using content_type = ContentT; + using content_type = ContentT; - template - explicit StateEvent(Type type, const QJsonObject& fullJson, - ContentParamTs&&... contentParams) - : StateEventBase(type, fullJson) - , _content(contentJson(), - std::forward(contentParams)...) - { - const auto& unsignedData = unsignedJson(); - if (unsignedData.contains(PrevContentKeyL)) - _prev = std::make_unique>(unsignedData, - std::forward(contentParams)...); - } - template - explicit StateEvent(Type type, event_mtype_t matrixType, - ContentParamTs&&... contentParams) - : StateEventBase(type, matrixType) - , _content(std::forward(contentParams)...) - { - editJson().insert(ContentKey, _content.toJson()); - } + template + explicit StateEvent(Type type, const QJsonObject& fullJson, + ContentParamTs&&... contentParams) + : StateEventBase(type, fullJson), + _content(contentJson(), + std::forward(contentParams)...) + { + const auto& unsignedData = unsignedJson(); + if (unsignedData.contains(PrevContentKeyL)) + _prev = std::make_unique>( + unsignedData, + std::forward(contentParams)...); + } + template + explicit StateEvent(Type type, event_mtype_t matrixType, + ContentParamTs&&... contentParams) + : StateEventBase(type, matrixType), + _content(std::forward(contentParams)...) + { + editJson().insert(ContentKey, _content.toJson()); + } - const ContentT& content() const { return _content; } - template - void editContent(VisitorT&& visitor) - { - visitor(_content); - editJson()[ContentKeyL] = _content.toJson(); - } - [[deprecated("Use prevContent instead")]] - const ContentT* prev_content() const { return prevContent(); } - const ContentT* prevContent() const - { return _prev ? &_prev->content : nullptr; } - QString prevSenderId() const - { return _prev ? _prev->senderId : QString(); } + const ContentT& content() const { return _content; } + template void editContent(VisitorT&& visitor) + { + visitor(_content); + editJson()[ContentKeyL] = _content.toJson(); + } + [[deprecated("Use prevContent instead")]] const ContentT* + prev_content() const + { + return prevContent(); + } + const ContentT* prevContent() const + { + return _prev ? &_prev->content : nullptr; + } + QString prevSenderId() const + { + return _prev ? _prev->senderId : QString(); + } private: - ContentT _content; - std::unique_ptr> _prev; + ContentT _content; + std::unique_ptr> _prev; }; } // namespace QMatrixClient namespace std { - template <> struct hash - { - size_t operator()(const QMatrixClient::StateEventKey& k) const Q_DECL_NOEXCEPT + template <> struct hash { + size_t + operator()(const QMatrixClient::StateEventKey& k) const Q_DECL_NOEXCEPT { return qHash(k); } diff --git a/lib/events/typingevent.cpp b/lib/events/typingevent.cpp index 0d39d1be..ee3d6b67 100644 --- a/lib/events/typingevent.cpp +++ b/lib/events/typingevent.cpp @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "typingevent.h" @@ -22,11 +22,9 @@ using namespace QMatrixClient; -TypingEvent::TypingEvent(const QJsonObject& obj) - : Event(typeId(), obj) +TypingEvent::TypingEvent(const QJsonObject& obj) : Event(typeId(), obj) { const auto& array = contentJson()["user_ids"_ls].toArray(); - for(const auto& user: array ) + for (const auto& user : array) _users.push_back(user.toString()); } - diff --git a/lib/events/typingevent.h b/lib/events/typingevent.h index 27b668b4..f66a1fbc 100644 --- a/lib/events/typingevent.h +++ b/lib/events/typingevent.h @@ -13,27 +13,26 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once #include "event.h" -namespace QMatrixClient -{ - class TypingEvent: public Event +namespace QMatrixClient { + class TypingEvent : public Event { public: - DEFINE_EVENT_TYPEID("m.typing", TypingEvent) + DEFINE_EVENT_TYPEID("m.typing", TypingEvent) - TypingEvent(const QJsonObject& obj); + TypingEvent(const QJsonObject& obj); - const QStringList& users() const { return _users; } + const QStringList& users() const { return _users; } private: - QStringList _users; + QStringList _users; }; REGISTER_EVENT_TYPE(TypingEvent) DEFINE_EVENTTYPE_ALIAS(Typing, TypingEvent) -} // namespace QMatrixClient +} // namespace QMatrixClient -- cgit v1.2.3 From c05ade838f0fce81f2bbe80a3295618a8a26ff52 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 2 Aug 2019 19:59:40 +0900 Subject: Apply the new brace wrapping to source files --- examples/qmc-example.cpp | 7 +-- lib/avatar.cpp | 15 ++----- lib/avatar.h | 6 +-- lib/connection.cpp | 79 ++++++++++++++++---------------- lib/connection.h | 21 +++------ lib/connectiondata.cpp | 7 +-- lib/connectiondata.h | 6 +-- lib/converters.h | 97 ++++++++++++++-------------------------- lib/e2ee.h | 3 +- lib/encryptionmanager.cpp | 3 +- lib/encryptionmanager.h | 9 ++-- lib/eventitem.h | 24 ++++------ lib/events/accountdataevents.h | 50 +++++++++------------ lib/events/callanswerevent.h | 6 +-- lib/events/callcandidatesevent.h | 6 +-- lib/events/callhangupevent.h | 6 +-- lib/events/callinviteevent.h | 6 +-- lib/events/directchatevent.h | 10 ++--- lib/events/encryptedevent.h | 6 +-- lib/events/encryptionevent.cpp | 6 +-- lib/events/encryptionevent.h | 15 ++----- lib/events/event.cpp | 4 +- lib/events/event.h | 24 ++++------ lib/events/eventcontent.cpp | 3 +- lib/events/eventcontent.h | 46 ++++++------------- lib/events/eventloader.h | 9 ++-- lib/events/reactionevent.h | 16 +++---- lib/events/receiptevent.cpp | 3 +- lib/events/receiptevent.h | 12 ++--- lib/events/redactionevent.h | 9 ++-- lib/events/roomavatarevent.h | 9 ++-- lib/events/roomcreateevent.h | 13 ++---- lib/events/roomevent.cpp | 3 +- lib/events/roomevent.h | 9 ++-- lib/events/roommemberevent.cpp | 6 +-- lib/events/roommemberevent.h | 22 +++------ lib/events/roommessageevent.cpp | 12 ++--- lib/events/roommessageevent.h | 24 ++++------ lib/events/roomtombstoneevent.h | 10 ++--- lib/events/simplestateevents.h | 25 ++++------- lib/events/stateevent.h | 21 +++------ lib/events/typingevent.cpp | 3 +- lib/events/typingevent.h | 6 +-- lib/jobs/basejob.cpp | 6 +-- lib/jobs/basejob.h | 35 ++++----------- lib/jobs/downloadfilejob.cpp | 7 +-- lib/jobs/downloadfilejob.h | 11 ++--- lib/jobs/mediathumbnailjob.h | 6 +-- lib/jobs/postreadmarkersjob.h | 3 +- lib/jobs/requestdata.cpp | 12 ++--- lib/jobs/requestdata.h | 9 ++-- lib/jobs/syncjob.h | 6 +-- lib/joinstate.h | 6 +-- lib/logging.h | 3 +- lib/networkaccessmanager.cpp | 6 +-- lib/networkaccessmanager.h | 6 +-- lib/networksettings.h | 6 +-- lib/qt_connection_util.h | 12 ++--- lib/room.cpp | 35 ++++++--------- lib/room.h | 28 +++--------- lib/settings.h | 16 +++---- lib/syncdata.h | 15 +++---- lib/user.cpp | 6 +-- lib/user.h | 6 +-- lib/util.cpp | 18 +++----- lib/util.h | 64 ++++++++------------------ 66 files changed, 335 insertions(+), 664 deletions(-) (limited to 'lib/events') diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index d6cba76a..f4067009 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -24,8 +24,7 @@ using std::cout; using std::endl; using namespace std::placeholders; -class QMCTest : public QObject -{ +class QMCTest : public QObject { public: QMCTest(Connection* conn, QString testRoomName, QString source); @@ -92,9 +91,7 @@ bool QMCTest::validatePendingEvent(const QString& txnId) } QMCTest::QMCTest(Connection* conn, QString testRoomName, QString source) - : c(conn) - , origin(std::move(source)) - , targetRoomName(std::move(testRoomName)) + : c(conn), origin(std::move(source)), targetRoomName(std::move(testRoomName)) { if (!origin.isEmpty()) cout << "Origin for the test message: " << origin.toStdString() << endl; diff --git a/lib/avatar.cpp b/lib/avatar.cpp index 0e58a1ce..614f008d 100644 --- a/lib/avatar.cpp +++ b/lib/avatar.cpp @@ -32,12 +32,9 @@ using namespace QMatrixClient; using std::move; -class Avatar::Private -{ +class Avatar::Private { public: - explicit Private(QUrl url = {}) - : _url(move(url)) - {} + explicit Private(QUrl url = {}) : _url(move(url)) {} ~Private() { if (isJobRunning(_thumbnailRequest)) @@ -65,13 +62,9 @@ public: mutable std::vector callbacks; }; -Avatar::Avatar() - : d(std::make_unique()) -{} +Avatar::Avatar() : d(std::make_unique()) {} -Avatar::Avatar(QUrl url) - : d(std::make_unique(std::move(url))) -{} +Avatar::Avatar(QUrl url) : d(std::make_unique(std::move(url))) {} Avatar::Avatar(Avatar&&) = default; diff --git a/lib/avatar.h b/lib/avatar.h index 37991192..c33e1982 100644 --- a/lib/avatar.h +++ b/lib/avatar.h @@ -24,12 +24,10 @@ #include #include -namespace QMatrixClient -{ +namespace QMatrixClient { class Connection; -class Avatar -{ +class Avatar { public: explicit Avatar(); explicit Avatar(QUrl url); diff --git a/lib/connection.cpp b/lib/connection.cpp index 6ebe05dc..6cd6ad0b 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -70,8 +70,7 @@ HashT erase_if(HashT& hashMap, Pred pred) return removals; } -class Connection::Private -{ +class Connection::Private { public: explicit Private(std::unique_ptr&& connection) : data(move(connection)) @@ -151,15 +150,12 @@ public: }; Connection::Connection(const QUrl& server, QObject* parent) - : QObject(parent) - , d(new Private(std::make_unique(server))) + : QObject(parent), d(new Private(std::make_unique(server))) { d->q = this; // All d initialization should occur before this line } -Connection::Connection(QObject* parent) - : Connection({}, parent) -{} +Connection::Connection(QObject* parent) : Connection({}, parent) {} Connection::~Connection() { @@ -183,45 +179,47 @@ void Connection::resolveServer(const QString& mxid) qCDebug(MAIN) << "Finding the server" << domain; auto getWellKnownJob = callApi(); - connect(getWellKnownJob, &BaseJob::finished, - [this, getWellKnownJob, maybeBaseUrl] { - if (getWellKnownJob->status() == BaseJob::NotFoundError) { - qCDebug(MAIN) << "No .well-known file, IGNORE"; - } else if (getWellKnownJob->status() != BaseJob::Success) { + connect( + getWellKnownJob, &BaseJob::finished, + [this, getWellKnownJob, maybeBaseUrl] { + if (getWellKnownJob->status() == BaseJob::NotFoundError) + qCDebug(MAIN) << "No .well-known file, IGNORE"; + else { + if (getWellKnownJob->status() != BaseJob::Success) { qCDebug(MAIN) << "Fetching .well-known file failed, FAIL_PROMPT"; emit resolveError(tr("Fetching .well-known file failed")); return; - } else if (getWellKnownJob->data().homeserver.baseUrl.isEmpty()) { + } + QUrl baseUrl(getWellKnownJob->data().homeserver.baseUrl); + if (baseUrl.isEmpty()) { qCDebug(MAIN) << "base_url not provided, FAIL_PROMPT"; emit resolveError(tr("base_url not provided")); return; - } else if (!QUrl(getWellKnownJob->data().homeserver.baseUrl) - .isValid()) { + } + if (!baseUrl.isValid()) { qCDebug(MAIN) << "base_url invalid, FAIL_ERROR"; emit resolveError(tr("base_url invalid")); return; - } else { - QUrl baseUrl(getWellKnownJob->data().homeserver.baseUrl); - - qCDebug(MAIN) << ".well-known for" << maybeBaseUrl.host() - << "is" << baseUrl.toString(); - setHomeserver(baseUrl); } - auto getVersionsJob = callApi(); - - connect(getVersionsJob, &BaseJob::finished, - [this, getVersionsJob] { - if (getVersionsJob->status() == BaseJob::Success) { - qCDebug(MAIN) << "homeserver url is valid"; - emit resolved(); - } else { - qCDebug(MAIN) << "homeserver url invalid"; - emit resolveError(tr("homeserver url invalid")); - } - }); + qCDebug(MAIN) << ".well-known for" << maybeBaseUrl.host() + << "is" << baseUrl.toString(); + setHomeserver(baseUrl); + } + + auto getVersionsJob = callApi(); + + connect(getVersionsJob, &BaseJob::finished, [this, getVersionsJob] { + if (getVersionsJob->status() == BaseJob::Success) { + qCDebug(MAIN) << "homeserver url is valid"; + emit resolved(); + } else { + qCDebug(MAIN) << "homeserver url invalid"; + emit resolveError(tr("homeserver url invalid")); + } }); + }); } void Connection::connectToServer(const QString& user, const QString& password, @@ -372,8 +370,8 @@ void Connection::sync(int timeout) connect(job, &SyncJob::failure, this, [this, job] { d->syncJob = nullptr; if (job->error() == BaseJob::ContentAccessError) { - qCWarning(SYNCJOB) - << "Sync job failed with ContentAccessError - login expired?"; + qCWarning(SYNCJOB) << "Sync job failed with ContentAccessError - " + "login expired?"; emit loginError(job->errorString(), job->rawDataSample()); } else emit syncError(job->errorString(), job->rawDataSample()); @@ -437,7 +435,6 @@ void Connection::onSyncSuccess(SyncData&& data, bool fromCache) visit( *eventPtr, [this](const DirectChatEvent& dce) { - // See // https://github.com/QMatrixClient/libqmatrixclient/wiki/Handling-direct-chat-events const auto& usersToDCs = dce.usersToDirectChats(); DirectChatsMap remoteRemovals = @@ -492,8 +489,8 @@ void Connection::onSyncSuccess(SyncData&& data, bool fromCache) << QStringList::fromSet(ignoredUsers()).join(','); auto& currentData = d->accountData[accountEvent.matrixType()]; - // A polymorphic event-specific comparison might be a bit more - // efficient; maaybe do it another day + // A polymorphic event-specific comparison might be a bit + // more efficient; maaybe do it another day if (!currentData || currentData->contentJson() != accountEvent.contentJson()) { currentData = std::move(eventPtr); @@ -678,9 +675,9 @@ void Connection::requestDirectChat(const QString& userId) if (auto* u = user(userId)) requestDirectChat(u); else - qCCritical(MAIN) - << "Connection::requestDirectChat: Couldn't get a user object for" - << userId; + qCCritical(MAIN) << "Connection::requestDirectChat: Couldn't get a " + "user object for" + << userId; } void Connection::requestDirectChat(User* u) diff --git a/lib/connection.h b/lib/connection.h index 8d65f0e7..b89c0c65 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -32,13 +32,11 @@ #include -namespace QtOlm -{ +namespace QtOlm { class Account; } -namespace QMatrixClient -{ +namespace QMatrixClient { class Room; class User; class ConnectionData; @@ -93,14 +91,9 @@ static inline user_factory_t defaultUserFactory() * * \sa Connection::callApi */ -enum RunningPolicy -{ - ForegroundRequest = 0x0, - BackgroundRequest = 0x1 -}; +enum RunningPolicy { ForegroundRequest = 0x0, BackgroundRequest = 0x1 }; -class Connection : public QObject -{ +class Connection : public QObject { Q_OBJECT Q_PROPERTY(User* localUser READ user NOTIFY stateChanged) @@ -129,8 +122,7 @@ public: using UsersToDevicesToEvents = std::unordered_map>; - enum RoomVisibility - { + enum RoomVisibility { PublishRoom, UnpublishRoom }; // FIXME: Should go inside CreateRoomJob @@ -285,8 +277,7 @@ public: Q_INVOKABLE void getTurnServers(); - struct SupportedRoomVersion - { + struct SupportedRoomVersion { QString id; QString status; diff --git a/lib/connectiondata.cpp b/lib/connectiondata.cpp index c157565f..df4cece2 100644 --- a/lib/connectiondata.cpp +++ b/lib/connectiondata.cpp @@ -23,11 +23,8 @@ using namespace QMatrixClient; -struct ConnectionData::Private -{ - explicit Private(QUrl url) - : baseUrl(std::move(url)) - {} +struct ConnectionData::Private { + explicit Private(QUrl url) : baseUrl(std::move(url)) {} QUrl baseUrl; QByteArray accessToken; diff --git a/lib/connectiondata.h b/lib/connectiondata.h index 6f9f090c..9b579b1c 100644 --- a/lib/connectiondata.h +++ b/lib/connectiondata.h @@ -24,10 +24,8 @@ class QNetworkAccessManager; -namespace QMatrixClient -{ -class ConnectionData -{ +namespace QMatrixClient { +class ConnectionData { public: explicit ConnectionData(QUrl baseUrl); virtual ~ConnectionData(); diff --git a/lib/converters.h b/lib/converters.h index aa07261d..0085fa4b 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -38,11 +38,9 @@ using optional = std::experimental::optional; #endif // Enable std::unordered_map -namespace std -{ +namespace std { template <> -struct hash -{ +struct hash { size_t operator()(const QString& s) const Q_DECL_NOEXCEPT { return qHash(s @@ -57,18 +55,15 @@ struct hash class QVariant; -namespace QMatrixClient -{ +namespace QMatrixClient { template -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const T& pod) { jo = pod.toJson(); } static void fillFrom(const QJsonObject& jo, T& pod) { pod = T(jo); } }; template -struct JsonConverter -{ +struct JsonConverter { static QJsonObject dump(const T& pod) { QJsonObject jo; @@ -139,52 +134,44 @@ inline void fillFromJson(const QJsonValue& jv, T& pod) // JsonConverter<> specialisations template -struct TrivialJsonDumper -{ +struct TrivialJsonDumper { // Works for: QJsonValue (and all things it can consume), // QJsonObject, QJsonArray static auto dump(const T& val) { return val; } }; template <> -struct JsonConverter : public TrivialJsonDumper -{ +struct JsonConverter : public TrivialJsonDumper { static auto load(const QJsonValue& jv) { return jv.toBool(); } }; template <> -struct JsonConverter : public TrivialJsonDumper -{ +struct JsonConverter : public TrivialJsonDumper { static auto load(const QJsonValue& jv) { return jv.toInt(); } }; template <> -struct JsonConverter : public TrivialJsonDumper -{ +struct JsonConverter : public TrivialJsonDumper { static auto load(const QJsonValue& jv) { return jv.toDouble(); } }; template <> -struct JsonConverter : public TrivialJsonDumper -{ +struct JsonConverter : public TrivialJsonDumper { static auto load(const QJsonValue& jv) { return float(jv.toDouble()); } }; template <> -struct JsonConverter : public TrivialJsonDumper -{ +struct JsonConverter : public TrivialJsonDumper { static auto load(const QJsonValue& jv) { return qint64(jv.toDouble()); } }; template <> -struct JsonConverter : public TrivialJsonDumper -{ +struct JsonConverter : public TrivialJsonDumper { static auto load(const QJsonValue& jv) { return jv.toString(); } }; template <> -struct JsonConverter -{ +struct JsonConverter { static auto dump(const QDateTime& val) = delete; // not provided yet static auto load(const QJsonValue& jv) { @@ -193,8 +180,7 @@ struct JsonConverter }; template <> -struct JsonConverter -{ +struct JsonConverter { static auto dump(const QDate& val) = delete; // not provided yet static auto load(const QJsonValue& jv) { @@ -203,14 +189,12 @@ struct JsonConverter }; template <> -struct JsonConverter : public TrivialJsonDumper -{ +struct JsonConverter : public TrivialJsonDumper { static auto load(const QJsonValue& jv) { return jv.toArray(); } }; template <> -struct JsonConverter -{ +struct JsonConverter { static QString dump(const QByteArray& ba) { return ba.constData(); } static auto load(const QJsonValue& jv) { @@ -219,15 +203,13 @@ struct JsonConverter }; template <> -struct JsonConverter -{ +struct JsonConverter { static QJsonValue dump(const QVariant& v); static QVariant load(const QJsonValue& jv); }; template -struct JsonConverter> -{ +struct JsonConverter> { static QJsonValue dump(const Omittable& from) { return from.omitted() ? QJsonValue() : toJson(from.value()); @@ -241,8 +223,7 @@ struct JsonConverter> }; template -struct JsonArrayConverter -{ +struct JsonArrayConverter { static void dumpTo(QJsonArray& ar, const VectorT& vals) { for (const auto& v : vals) @@ -267,20 +248,17 @@ struct JsonArrayConverter }; template -struct JsonConverter> : public JsonArrayConverter> -{}; +struct JsonConverter> + : public JsonArrayConverter> {}; template -struct JsonConverter> : public JsonArrayConverter> -{}; +struct JsonConverter> : public JsonArrayConverter> {}; template -struct JsonConverter> : public JsonArrayConverter> -{}; +struct JsonConverter> : public JsonArrayConverter> {}; template <> -struct JsonConverter : public JsonConverter> -{ +struct JsonConverter : public JsonConverter> { static auto dump(const QStringList& sl) { return QJsonArray::fromStringList(sl); @@ -288,8 +266,7 @@ struct JsonConverter : public JsonConverter> }; template <> -struct JsonObjectConverter> -{ +struct JsonObjectConverter> { static void dumpTo(QJsonObject& json, const QSet& s) { for (const auto& e : s) @@ -305,8 +282,7 @@ struct JsonObjectConverter> }; template -struct HashMapFromJson -{ +struct HashMapFromJson { static void dumpTo(QJsonObject& json, const HashMapT& hashMap) { for (auto it = hashMap.begin(); it != hashMap.end(); ++it) @@ -322,13 +298,11 @@ struct HashMapFromJson template struct JsonObjectConverter> - : public HashMapFromJson> -{}; + : public HashMapFromJson> {}; template struct JsonObjectConverter> - : public HashMapFromJson> -{}; + : public HashMapFromJson> {}; // We could use std::conditional<> below but QT_VERSION* macros in C++ code // cause (kinda valid but useless and noisy) compiler warnings about @@ -340,16 +314,14 @@ using variant_map_t = QVariantMap; #endif template <> -struct JsonConverter -{ +struct JsonConverter { static QJsonObject dump(const variant_map_t& vh); static QVariantHash load(const QJsonValue& jv); }; // Conditional insertion into a QJsonObject -namespace _impl -{ +namespace _impl { template inline void addTo(QJsonObject& o, const QString& k, ValT&& v) { @@ -384,8 +356,7 @@ namespace _impl // This one is for types that don't have isEmpty() and for all types // when Force is true template - struct AddNode - { + struct AddNode { template static void impl(ContT& container, const QString& key, ForwardedT&& value) @@ -396,8 +367,7 @@ namespace _impl // This one is for types that have isEmpty() when Force is false template - struct AddNode().isEmpty())> - { + struct AddNode().isEmpty())> { template static void impl(ContT& container, const QString& key, ForwardedT&& value) @@ -409,8 +379,7 @@ namespace _impl // This one unfolds Omittable<> (also only when Force is false) template - struct AddNode, false> - { + struct AddNode, false> { template static void impl(ContT& container, const QString& key, const OmittableT& value) diff --git a/lib/e2ee.h b/lib/e2ee.h index d3329def..c85211be 100644 --- a/lib/e2ee.h +++ b/lib/e2ee.h @@ -4,8 +4,7 @@ #include -namespace QMatrixClient -{ +namespace QMatrixClient { static const auto CiphertextKeyL = "ciphertext"_ls; static const auto SenderKeyKeyL = "sender_key"_ls; static const auto DeviceIdKeyL = "device_id"_ls; diff --git a/lib/encryptionmanager.cpp b/lib/encryptionmanager.cpp index 46d937b8..15723688 100644 --- a/lib/encryptionmanager.cpp +++ b/lib/encryptionmanager.cpp @@ -16,8 +16,7 @@ using namespace QMatrixClient; using namespace QtOlm; using std::move; -class EncryptionManager::Private -{ +class EncryptionManager::Private { public: explicit Private(const QByteArray& encryptionAccountPickle, float signedKeysProportion, float oneTimeKeyThreshold) diff --git a/lib/encryptionmanager.h b/lib/encryptionmanager.h index 02bb882f..79c25a00 100644 --- a/lib/encryptionmanager.h +++ b/lib/encryptionmanager.h @@ -5,17 +5,14 @@ #include #include -namespace QtOlm -{ +namespace QtOlm { class Account; } -namespace QMatrixClient -{ +namespace QMatrixClient { class Connection; -class EncryptionManager : public QObject -{ +class EncryptionManager : public QObject { Q_OBJECT public: diff --git a/lib/eventitem.h b/lib/eventitem.h index 58f5479c..68d1ae06 100644 --- a/lib/eventitem.h +++ b/lib/eventitem.h @@ -22,12 +22,10 @@ #include -namespace QMatrixClient -{ +namespace QMatrixClient { class StateEventBase; -class EventStatus -{ +class EventStatus { Q_GADGET public: /** Special marks an event can assume @@ -35,8 +33,7 @@ public: * This is used to hint at a special status of some events in UI. * All values except Redacted and Hidden are mutually exclusive. */ - enum Code - { + enum Code { Normal = 0x0, //< No special designation Submitted = 0x01, //< The event has just been submitted for sending FileUploaded = 0x02, //< The file attached to the event has been @@ -51,11 +48,9 @@ public: Q_FLAG(Status) }; -class EventItemBase -{ +class EventItemBase { public: - explicit EventItemBase(RoomEventPtr&& e) - : evt(std::move(e)) + explicit EventItemBase(RoomEventPtr&& e) : evt(std::move(e)) { Q_ASSERT(evt); } @@ -87,16 +82,14 @@ private: RoomEventPtr evt; }; -class TimelineItem : public EventItemBase -{ +class TimelineItem : public EventItemBase { public: // For compatibility with Qt containers, even though we use // a std:: container now for the room timeline using index_t = int; TimelineItem(RoomEventPtr&& e, index_t number) - : EventItemBase(std::move(e)) - , idx(number) + : EventItemBase(std::move(e)), idx(number) {} index_t index() const { return idx; } @@ -118,8 +111,7 @@ inline const CallEventBase* EventItemBase::viewAs() const return evt->isCallEvent() ? weakPtrCast(evt) : nullptr; } -class PendingEventItem : public EventItemBase -{ +class PendingEventItem : public EventItemBase { Q_GADGET public: using EventItemBase::EventItemBase; diff --git a/lib/events/accountdataevents.h b/lib/events/accountdataevents.h index abab9867..3f519668 100644 --- a/lib/events/accountdataevents.h +++ b/lib/events/accountdataevents.h @@ -24,20 +24,16 @@ #include "event.h" #include "eventcontent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { constexpr const char* FavouriteTag = "m.favourite"; constexpr const char* LowPriorityTag = "m.lowpriority"; -struct TagRecord -{ +struct TagRecord { using order_type = Omittable; order_type order; - TagRecord(order_type order = none) - : order(order) - {} + TagRecord(order_type order = none) : order(order) {} bool operator<(const TagRecord& other) const { @@ -48,8 +44,7 @@ struct TagRecord }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, TagRecord& rec) { // Parse a float both from JSON double and JSON string because @@ -72,26 +67,23 @@ struct JsonObjectConverter using TagsMap = QHash; -#define DEFINE_SIMPLE_EVENT(_Name, _TypeId, _ContentType, _ContentKey) \ - class _Name : public Event \ - { \ - public: \ - using content_type = _ContentType; \ - DEFINE_EVENT_TYPEID(_TypeId, _Name) \ - explicit _Name(QJsonObject obj) \ - : Event(typeId(), std::move(obj)) \ - {} \ - explicit _Name(_ContentType content) \ - : Event(typeId(), matrixTypeId(), \ - QJsonObject { { QStringLiteral(#_ContentKey), \ - toJson(std::move(content)) } }) \ - {} \ - auto _ContentKey() const \ - { \ - return content(#_ContentKey##_ls); \ - } \ - }; \ - REGISTER_EVENT_TYPE(_Name) \ +#define DEFINE_SIMPLE_EVENT(_Name, _TypeId, _ContentType, _ContentKey) \ + class _Name : public Event { \ + public: \ + using content_type = _ContentType; \ + DEFINE_EVENT_TYPEID(_TypeId, _Name) \ + explicit _Name(QJsonObject obj) : Event(typeId(), std::move(obj)) {} \ + explicit _Name(_ContentType content) \ + : Event(typeId(), matrixTypeId(), \ + QJsonObject { { QStringLiteral(#_ContentKey), \ + toJson(std::move(content)) } }) \ + {} \ + auto _ContentKey() const \ + { \ + return content(#_ContentKey##_ls); \ + } \ + }; \ + REGISTER_EVENT_TYPE(_Name) \ // End of macro DEFINE_SIMPLE_EVENT(TagEvent, "m.tag", TagsMap, tags) diff --git a/lib/events/callanswerevent.h b/lib/events/callanswerevent.h index 69662eb9..052f732d 100644 --- a/lib/events/callanswerevent.h +++ b/lib/events/callanswerevent.h @@ -20,10 +20,8 @@ #include "roomevent.h" -namespace QMatrixClient -{ -class CallAnswerEvent : public CallEventBase -{ +namespace QMatrixClient { +class CallAnswerEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.answer", CallAnswerEvent) diff --git a/lib/events/callcandidatesevent.h b/lib/events/callcandidatesevent.h index 1c12b800..2a915a43 100644 --- a/lib/events/callcandidatesevent.h +++ b/lib/events/callcandidatesevent.h @@ -20,10 +20,8 @@ #include "roomevent.h" -namespace QMatrixClient -{ -class CallCandidatesEvent : public CallEventBase -{ +namespace QMatrixClient { +class CallCandidatesEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.candidates", CallCandidatesEvent) diff --git a/lib/events/callhangupevent.h b/lib/events/callhangupevent.h index 0a5a3283..97fa2f52 100644 --- a/lib/events/callhangupevent.h +++ b/lib/events/callhangupevent.h @@ -20,10 +20,8 @@ #include "roomevent.h" -namespace QMatrixClient -{ -class CallHangupEvent : public CallEventBase -{ +namespace QMatrixClient { +class CallHangupEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.hangup", CallHangupEvent) diff --git a/lib/events/callinviteevent.h b/lib/events/callinviteevent.h index 4334ca5b..9b9d0ae5 100644 --- a/lib/events/callinviteevent.h +++ b/lib/events/callinviteevent.h @@ -20,10 +20,8 @@ #include "roomevent.h" -namespace QMatrixClient -{ -class CallInviteEvent : public CallEventBase -{ +namespace QMatrixClient { +class CallInviteEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.invite", CallInviteEvent) diff --git a/lib/events/directchatevent.h b/lib/events/directchatevent.h index 6b4a08ee..94857a93 100644 --- a/lib/events/directchatevent.h +++ b/lib/events/directchatevent.h @@ -20,16 +20,12 @@ #include "event.h" -namespace QMatrixClient -{ -class DirectChatEvent : public Event -{ +namespace QMatrixClient { +class DirectChatEvent : public Event { public: DEFINE_EVENT_TYPEID("m.direct", DirectChatEvent) - explicit DirectChatEvent(const QJsonObject& obj) - : Event(typeId(), obj) - {} + explicit DirectChatEvent(const QJsonObject& obj) : Event(typeId(), obj) {} QMultiHash usersToDirectChats() const; }; diff --git a/lib/events/encryptedevent.h b/lib/events/encryptedevent.h index 0dbce25c..67298a27 100644 --- a/lib/events/encryptedevent.h +++ b/lib/events/encryptedevent.h @@ -3,8 +3,7 @@ #include "e2ee.h" #include "roomevent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { class Room; /* * While the specification states: @@ -24,8 +23,7 @@ class Room; * in general. It's possible, because RoomEvent interface is similar to Event's * one and doesn't add new restrictions, just provides additional features. */ -class EncryptedEvent : public RoomEvent -{ +class EncryptedEvent : public RoomEvent { Q_GADGET public: DEFINE_EVENT_TYPEID("m.room.encrypted", EncryptedEvent) diff --git a/lib/events/encryptionevent.cpp b/lib/events/encryptionevent.cpp index 995c8dad..0c732a51 100644 --- a/lib/events/encryptionevent.cpp +++ b/lib/events/encryptionevent.cpp @@ -15,11 +15,9 @@ static const std::array encryptionStrings = { { QMatrixClient::MegolmV1AesSha2AlgoKey } }; -namespace QMatrixClient -{ +namespace QMatrixClient { template <> -struct JsonConverter -{ +struct JsonConverter { static EncryptionType load(const QJsonValue& jv) { const auto& encryptionString = jv.toString(); diff --git a/lib/events/encryptionevent.h b/lib/events/encryptionevent.h index 97119c8d..debabcae 100644 --- a/lib/events/encryptionevent.h +++ b/lib/events/encryptionevent.h @@ -21,16 +21,10 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient -{ -class EncryptionEventContent : public EventContent::Base -{ +namespace QMatrixClient { +class EncryptionEventContent : public EventContent::Base { public: - enum EncryptionType : size_t - { - MegolmV1AesSha2 = 0, - Undefined - }; + enum EncryptionType : size_t { MegolmV1AesSha2 = 0, Undefined }; explicit EncryptionEventContent(EncryptionType et = Undefined) : encryption(et) @@ -48,8 +42,7 @@ protected: using EncryptionType = EncryptionEventContent::EncryptionType; -class EncryptionEvent : public StateEvent -{ +class EncryptionEvent : public StateEvent { Q_GADGET public: DEFINE_EVENT_TYPEID("m.room.encryption", EncryptionEvent) diff --git a/lib/events/event.cpp b/lib/events/event.cpp index 718a6602..694254fe 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -42,9 +42,7 @@ QString EventTypeRegistry::getMatrixType(event_type_t typeId) : QString(); } -Event::Event(Type type, const QJsonObject& json) - : _type(type) - , _json(json) +Event::Event(Type type, const QJsonObject& json) : _type(type), _json(json) { if (!json.contains(ContentKeyL) && !json.value(UnsignedKeyL).toObject().contains(RedactedCauseKeyL)) { diff --git a/lib/events/event.h b/lib/events/event.h index d6525281..686bd8e0 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -25,8 +25,7 @@ # define USE_EVENTTYPE_ALIAS 1 #endif -namespace QMatrixClient -{ +namespace QMatrixClient { // === event_ptr_tt<> and type casting facilities === template @@ -85,8 +84,7 @@ inline QJsonObject basicEventJson(StrT matrixType, const QJsonObject& content) using event_type_t = size_t; using event_mtype_t = const char*; -class EventTypeRegistry -{ +class EventTypeRegistry { public: ~EventTypeRegistry() = default; @@ -121,8 +119,7 @@ inline event_type_t EventTypeRegistry::initializeTypeId() } template -struct EventTypeTraits -{ +struct EventTypeTraits { static event_type_t id() { static const auto id = EventTypeRegistry::initializeTypeId(); @@ -148,8 +145,7 @@ inline event_ptr_tt makeEvent(ArgTs&&... args) } template -class EventFactory -{ +class EventFactory { public: template static auto addMethod(FnT&& method) @@ -223,8 +219,7 @@ inline auto registerEventType() // === Event === -class Event -{ +class Event { Q_GADGET Q_PROPERTY(Type type READ type CONSTANT) Q_PROPERTY(QJsonObject contentJson READ contentJson CONSTANT) @@ -304,16 +299,14 @@ using Events = EventsArray; // to enable its deserialisation from a /sync and other // polymorphic event arrays #define REGISTER_EVENT_TYPE(_Type) \ - namespace \ - { \ + namespace { \ [[gnu::unused]] static const auto _factoryAdded##_Type = \ registerEventType<_Type>(); \ } \ // End of macro #ifdef USE_EVENTTYPE_ALIAS -namespace EventType -{ +namespace EventType { inline event_type_t logEventType(event_type_t id, const char* idName) { qDebug(EVENTS) << "Using id" << id << "for" << idName; @@ -324,8 +317,7 @@ namespace EventType // This macro provides constants in EventType:: namespace for // back-compatibility with libQMatrixClient 0.3 event type system. # define DEFINE_EVENTTYPE_ALIAS(_Id, _Type) \ - namespace EventType \ - { \ + namespace EventType { \ [[deprecated("Use is<>(), eventCast<>() or " \ "visit<>()")]] static const auto _Id = \ logEventType(typeId<_Type>(), #_Id); \ diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp index 2b84c2b7..814f2787 100644 --- a/lib/events/eventcontent.cpp +++ b/lib/events/eventcontent.cpp @@ -70,8 +70,7 @@ void FileInfo::fillInfoJson(QJsonObject* infoJson) const ImageInfo::ImageInfo(const QUrl& u, qint64 fileSize, QMimeType mimeType, const QSize& imageSize, const QString& originalFilename) - : FileInfo(u, fileSize, mimeType, originalFilename) - , imageSize(imageSize) + : FileInfo(u, fileSize, mimeType, originalFilename), imageSize(imageSize) {} ImageInfo::ImageInfo(const QUrl& u, const QJsonObject& infoJson, diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 7a3db1fc..5c0f92d1 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -26,10 +26,8 @@ #include #include -namespace QMatrixClient -{ -namespace EventContent -{ +namespace QMatrixClient { +namespace EventContent { /** * A base class for all content types that can be stored * in a RoomMessageEvent @@ -40,12 +38,9 @@ namespace EventContent * assumed but not required that a content object can also be created * from plain data. */ - class Base - { + class Base { public: - explicit Base(QJsonObject o = {}) - : originalJson(std::move(o)) - {} + explicit Base(QJsonObject o = {}) : originalJson(std::move(o)) {} virtual ~Base() = default; // FIXME: make toJson() from converters.* work on base classes @@ -90,8 +85,7 @@ namespace EventContent * * This class is not polymorphic. */ - class FileInfo - { + class FileInfo { public: explicit FileInfo(const QUrl& u, qint64 payloadSize = -1, const QMimeType& mimeType = {}, @@ -131,8 +125,7 @@ namespace EventContent /** * A content info class for image content types: image, thumbnail, video */ - class ImageInfo : public FileInfo - { + class ImageInfo : public FileInfo { public: explicit ImageInfo(const QUrl& u, qint64 fileSize = -1, QMimeType mimeType = {}, const QSize& imageSize = {}, @@ -153,16 +146,11 @@ namespace EventContent * the JSON representation of event content; namely, * "info/thumbnail_url" and "info/thumbnail_info" fields are used. */ - class Thumbnail : public ImageInfo - { + class Thumbnail : public ImageInfo { public: - Thumbnail() - : ImageInfo(QUrl()) - {} // To allow empty thumbnails + Thumbnail() : ImageInfo(QUrl()) {} // To allow empty thumbnails Thumbnail(const QJsonObject& infoJson); - Thumbnail(const ImageInfo& info) - : ImageInfo(info) - {} + Thumbnail(const ImageInfo& info) : ImageInfo(info) {} using ImageInfo::ImageInfo; /** @@ -172,12 +160,9 @@ namespace EventContent void fillInfoJson(QJsonObject* infoJson) const; }; - class TypedBase : public Base - { + class TypedBase : public Base { public: - explicit TypedBase(QJsonObject o = {}) - : Base(std::move(o)) - {} + explicit TypedBase(QJsonObject o = {}) : Base(std::move(o)) {} virtual QMimeType type() const = 0; virtual const FileInfo* fileInfo() const { return nullptr; } virtual FileInfo* fileInfo() { return nullptr; } @@ -198,8 +183,7 @@ namespace EventContent * \tparam InfoT base info class */ template - class UrlBasedContent : public TypedBase, public InfoT - { + class UrlBasedContent : public TypedBase, public InfoT { public: using InfoT::InfoT; explicit UrlBasedContent(const QJsonObject& json) @@ -227,13 +211,11 @@ namespace EventContent }; template - class UrlWithThumbnailContent : public UrlBasedContent - { + class UrlWithThumbnailContent : public UrlBasedContent { public: using UrlBasedContent::UrlBasedContent; explicit UrlWithThumbnailContent(const QJsonObject& json) - : UrlBasedContent(json) - , thumbnail(InfoT::originalInfoJson) + : UrlBasedContent(json), thumbnail(InfoT::originalInfoJson) { // Another small hack, to simplify making a thumbnail link UrlBasedContent::originalJson.insert("thumbnailMediaId", diff --git a/lib/events/eventloader.h b/lib/events/eventloader.h index a203eaa3..9e8bb410 100644 --- a/lib/events/eventloader.h +++ b/lib/events/eventloader.h @@ -20,10 +20,8 @@ #include "stateevent.h" -namespace QMatrixClient -{ -namespace _impl -{ +namespace QMatrixClient { +namespace _impl { template static inline auto loadEvent(const QJsonObject& json, const QString& matrixType) @@ -75,8 +73,7 @@ inline StateEventPtr loadStateEvent(const QString& matrixType, } template -struct JsonConverter> -{ +struct JsonConverter> { static auto load(const QJsonValue& jv) { return loadEvent(jv.toObject()); diff --git a/lib/events/reactionevent.h b/lib/events/reactionevent.h index d524b549..b1e04561 100644 --- a/lib/events/reactionevent.h +++ b/lib/events/reactionevent.h @@ -20,11 +20,9 @@ #include "roomevent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { -struct EventRelation -{ +struct EventRelation { using reltypeid_t = const char*; static constexpr reltypeid_t Reply() { return "m.in_reply_to"; } static constexpr reltypeid_t Annotation() { return "m.annotation"; } @@ -48,14 +46,12 @@ struct EventRelation } }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const EventRelation& pod); static void fillFrom(const QJsonObject& jo, EventRelation& pod); }; -class ReactionEvent : public RoomEvent -{ +class ReactionEvent : public RoomEvent { public: DEFINE_EVENT_TYPEID("m.reaction", ReactionEvent) @@ -63,9 +59,7 @@ public: : RoomEvent(typeId(), matrixTypeId(), { { QStringLiteral("m.relates_to"), toJson(value) } }) {} - explicit ReactionEvent(const QJsonObject& obj) - : RoomEvent(typeId(), obj) - {} + explicit ReactionEvent(const QJsonObject& obj) : RoomEvent(typeId(), obj) {} EventRelation relation() const { return content(QStringLiteral("m.relates_to")); diff --git a/lib/events/receiptevent.cpp b/lib/events/receiptevent.cpp index fcb8431b..4a54b744 100644 --- a/lib/events/receiptevent.cpp +++ b/lib/events/receiptevent.cpp @@ -40,8 +40,7 @@ Example of a Receipt Event: using namespace QMatrixClient; -ReceiptEvent::ReceiptEvent(const QJsonObject& obj) - : Event(typeId(), obj) +ReceiptEvent::ReceiptEvent(const QJsonObject& obj) : Event(typeId(), obj) { const auto& contents = contentJson(); _eventsWithReceipts.reserve(contents.size()); diff --git a/lib/events/receiptevent.h b/lib/events/receiptevent.h index e8396670..c32e0543 100644 --- a/lib/events/receiptevent.h +++ b/lib/events/receiptevent.h @@ -23,22 +23,18 @@ #include #include -namespace QMatrixClient -{ -struct Receipt -{ +namespace QMatrixClient { +struct Receipt { QString userId; QDateTime timestamp; }; -struct ReceiptsForEvent -{ +struct ReceiptsForEvent { QString evtId; QVector receipts; }; using EventsWithReceipts = QVector; -class ReceiptEvent : public Event -{ +class ReceiptEvent : public Event { public: DEFINE_EVENT_TYPEID("m.receipt", ReceiptEvent) explicit ReceiptEvent(const QJsonObject& obj); diff --git a/lib/events/redactionevent.h b/lib/events/redactionevent.h index a7dd9705..3628fb33 100644 --- a/lib/events/redactionevent.h +++ b/lib/events/redactionevent.h @@ -20,15 +20,12 @@ #include "roomevent.h" -namespace QMatrixClient -{ -class RedactionEvent : public RoomEvent -{ +namespace QMatrixClient { +class RedactionEvent : public RoomEvent { public: DEFINE_EVENT_TYPEID("m.room.redaction", RedactionEvent) - explicit RedactionEvent(const QJsonObject& obj) - : RoomEvent(typeId(), obj) + explicit RedactionEvent(const QJsonObject& obj) : RoomEvent(typeId(), obj) {} QString redactedEvent() const diff --git a/lib/events/roomavatarevent.h b/lib/events/roomavatarevent.h index ee460339..16aeb070 100644 --- a/lib/events/roomavatarevent.h +++ b/lib/events/roomavatarevent.h @@ -21,18 +21,15 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient -{ -class RoomAvatarEvent : public StateEvent -{ +namespace QMatrixClient { +class RoomAvatarEvent : public StateEvent { // It's a bit of an overkill to use a full-fledged ImageContent // because in reality m.room.avatar usually only has a single URL, // without a thumbnail. But The Spec says there be thumbnails, and // we follow The Spec. public: DEFINE_EVENT_TYPEID("m.room.avatar", RoomAvatarEvent) - explicit RoomAvatarEvent(const QJsonObject& obj) - : StateEvent(typeId(), obj) + explicit RoomAvatarEvent(const QJsonObject& obj) : StateEvent(typeId(), obj) {} QUrl url() const { return content().url; } }; diff --git a/lib/events/roomcreateevent.h b/lib/events/roomcreateevent.h index 17b86388..c8ba8c40 100644 --- a/lib/events/roomcreateevent.h +++ b/lib/events/roomcreateevent.h @@ -20,22 +20,17 @@ #include "stateevent.h" -namespace QMatrixClient -{ -class RoomCreateEvent : public StateEventBase -{ +namespace QMatrixClient { +class RoomCreateEvent : public StateEventBase { public: DEFINE_EVENT_TYPEID("m.room.create", RoomCreateEvent) - explicit RoomCreateEvent() - : StateEventBase(typeId(), matrixTypeId()) - {} + explicit RoomCreateEvent() : StateEventBase(typeId(), matrixTypeId()) {} explicit RoomCreateEvent(const QJsonObject& obj) : StateEventBase(typeId(), obj) {} - struct Predecessor - { + struct Predecessor { QString roomId; QString eventId; }; diff --git a/lib/events/roomevent.cpp b/lib/events/roomevent.cpp index fb715473..543640ca 100644 --- a/lib/events/roomevent.cpp +++ b/lib/events/roomevent.cpp @@ -32,8 +32,7 @@ RoomEvent::RoomEvent(Type type, event_mtype_t matrixType, : Event(type, matrixType, contentJson) {} -RoomEvent::RoomEvent(Type type, const QJsonObject& json) - : Event(type, json) +RoomEvent::RoomEvent(Type type, const QJsonObject& json) : Event(type, json) { const auto unsignedData = json[UnsignedKeyL].toObject(); const auto redaction = unsignedData[RedactedCauseKeyL]; diff --git a/lib/events/roomevent.h b/lib/events/roomevent.h index 8edb397c..155d4600 100644 --- a/lib/events/roomevent.h +++ b/lib/events/roomevent.h @@ -22,13 +22,11 @@ #include -namespace QMatrixClient -{ +namespace QMatrixClient { class RedactionEvent; /** This class corresponds to m.room.* events */ -class RoomEvent : public Event -{ +class RoomEvent : public Event { Q_GADGET Q_PROPERTY(QString id READ id) Q_PROPERTY(QDateTime timestamp READ timestamp CONSTANT) @@ -93,8 +91,7 @@ using RoomEventPtr = event_ptr_tt; using RoomEvents = EventsArray; using RoomEventsRange = Range; -class CallEventBase : public RoomEvent -{ +class CallEventBase : public RoomEvent { public: CallEventBase(Type type, event_mtype_t matrixType, const QString& callId, int version, const QJsonObject& contentJson = {}); diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp index e6292b73..3cbf6685 100644 --- a/lib/events/roommemberevent.cpp +++ b/lib/events/roommemberevent.cpp @@ -28,11 +28,9 @@ static const std::array membershipStrings = { QStringLiteral("leave"), QStringLiteral("ban") } }; -namespace QMatrixClient -{ +namespace QMatrixClient { template <> -struct JsonConverter -{ +struct JsonConverter { static MembershipType load(const QJsonValue& jv) { const auto& membershipString = jv.toString(); diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h index c1015df2..59d59e3a 100644 --- a/lib/events/roommemberevent.h +++ b/lib/events/roommemberevent.h @@ -21,13 +21,10 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient -{ -class MemberEventContent : public EventContent::Base -{ +namespace QMatrixClient { +class MemberEventContent : public EventContent::Base { public: - enum MembershipType : size_t - { + enum MembershipType : size_t { Invite = 0, Join, Knock, @@ -36,9 +33,7 @@ public: Undefined }; - explicit MemberEventContent(MembershipType mt = Join) - : membership(mt) - {} + explicit MemberEventContent(MembershipType mt = Join) : membership(mt) {} explicit MemberEventContent(const QJsonObject& json); MembershipType membership; @@ -52,16 +47,14 @@ protected: using MembershipType = MemberEventContent::MembershipType; -class RoomMemberEvent : public StateEvent -{ +class RoomMemberEvent : public StateEvent { Q_GADGET public: DEFINE_EVENT_TYPEID("m.room.member", RoomMemberEvent) using MembershipType = MemberEventContent::MembershipType; - explicit RoomMemberEvent(const QJsonObject& obj) - : StateEvent(typeId(), obj) + explicit RoomMemberEvent(const QJsonObject& obj) : StateEvent(typeId(), obj) {} [[deprecated("Use RoomMemberEvent(userId, contentArgs) " "instead")]] RoomMemberEvent(MemberEventContent&& c) @@ -103,8 +96,7 @@ private: }; template <> -class EventFactory -{ +class EventFactory { public: static event_ptr_tt make(const QJsonObject& json, const QString&) diff --git a/lib/events/roommessageevent.cpp b/lib/events/roommessageevent.cpp index da8d59ca..991931de 100644 --- a/lib/events/roommessageevent.cpp +++ b/lib/events/roommessageevent.cpp @@ -54,8 +54,7 @@ TypedBase* make(const QJsonObject& json) : nullptr; } -struct MsgTypeDesc -{ +struct MsgTypeDesc { QString matrixType; MsgType enumType; TypedBase* (*maker)(const QJsonObject&); @@ -174,8 +173,7 @@ RoomMessageEvent::RoomMessageEvent(const QString& plainBody, {} RoomMessageEvent::RoomMessageEvent(const QJsonObject& obj) - : RoomEvent(typeId(), obj) - , _content(nullptr) + : RoomEvent(typeId(), obj), _content(nullptr) { if (isRedacted()) return; @@ -281,8 +279,7 @@ TextContent::TextContent(const QString& text, const QString& contentType, mimeType = QMimeDatabase().mimeTypeForName("text/html"); } -namespace QMatrixClient -{ +namespace QMatrixClient { // Overload the default fromJson<> logic that defined in converters.h // as we want template <> @@ -350,8 +347,7 @@ void TextContent::fillJson(QJsonObject* json) const LocationContent::LocationContent(const QString& geoUri, const Thumbnail& thumbnail) - : geoUri(geoUri) - , thumbnail(thumbnail) + : geoUri(geoUri), thumbnail(thumbnail) {} LocationContent::LocationContent(const QJsonObject& json) diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index 1f1fde41..c7a5cb47 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -23,15 +23,13 @@ class QFileInfo; -namespace QMatrixClient -{ +namespace QMatrixClient { namespace MessageEventContent = EventContent; // Back-compatibility /** * The event class corresponding to m.room.message events */ -class RoomMessageEvent : public RoomEvent -{ +class RoomMessageEvent : public RoomEvent { Q_GADGET Q_PROPERTY(QString msgType READ rawMsgtype CONSTANT) Q_PROPERTY(QString plainBody READ plainBody CONSTANT) @@ -40,8 +38,7 @@ class RoomMessageEvent : public RoomEvent public: DEFINE_EVENT_TYPEID("m.room.message", RoomMessageEvent) - enum class MsgType - { + enum class MsgType { Text, Emote, Notice, @@ -96,12 +93,10 @@ REGISTER_EVENT_TYPE(RoomMessageEvent) DEFINE_EVENTTYPE_ALIAS(RoomMessage, RoomMessageEvent) using MessageEventType = RoomMessageEvent::MsgType; -namespace EventContent -{ +namespace EventContent { // Additional event content types - struct RelatesTo - { + struct RelatesTo { static constexpr const char* ReplyTypeId() { return "m.in_reply_to"; } static constexpr const char* ReplacementTypeId() { return "m.replace"; } QString type; // The only supported relation so far @@ -118,8 +113,7 @@ namespace EventContent * Available fields: mimeType, body. The body can be either rich text * or plain text, depending on what mimeType specifies. */ - class TextContent : public TypedBase - { + class TextContent : public TypedBase { public: TextContent(const QString& text, const QString& contentType, Omittable relatesTo = none); @@ -148,8 +142,7 @@ namespace EventContent * - thumbnail.mimeType * - thumbnail.imageSize */ - class LocationContent : public TypedBase - { + class LocationContent : public TypedBase { public: LocationContent(const QString& geoUri, const Thumbnail& thumbnail = {}); explicit LocationContent(const QJsonObject& json); @@ -168,8 +161,7 @@ namespace EventContent * A base class for info types that include duration: audio and video */ template - class PlayableContent : public ContentT - { + class PlayableContent : public ContentT { public: using ContentT::ContentT; PlayableContent(const QJsonObject& json) diff --git a/lib/events/roomtombstoneevent.h b/lib/events/roomtombstoneevent.h index aa9cb766..95fed998 100644 --- a/lib/events/roomtombstoneevent.h +++ b/lib/events/roomtombstoneevent.h @@ -20,16 +20,12 @@ #include "stateevent.h" -namespace QMatrixClient -{ -class RoomTombstoneEvent : public StateEventBase -{ +namespace QMatrixClient { +class RoomTombstoneEvent : public StateEventBase { public: DEFINE_EVENT_TYPEID("m.room.tombstone", RoomTombstoneEvent) - explicit RoomTombstoneEvent() - : StateEventBase(typeId(), matrixTypeId()) - {} + explicit RoomTombstoneEvent() : StateEventBase(typeId(), matrixTypeId()) {} explicit RoomTombstoneEvent(const QJsonObject& obj) : StateEventBase(typeId(), obj) {} diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index 0078c44d..6dad8020 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -20,25 +20,20 @@ #include "stateevent.h" -namespace QMatrixClient -{ -namespace EventContent -{ +namespace QMatrixClient { +namespace EventContent { template - class SimpleContent - { + class SimpleContent { public: using value_type = T; // The constructor is templated to enable perfect forwarding template SimpleContent(QString keyName, TT&& value) - : value(std::forward(value)) - , key(std::move(keyName)) + : value(std::forward(value)), key(std::move(keyName)) {} SimpleContent(const QJsonObject& json, QString keyName) - : value(fromJson(json[keyName])) - , key(std::move(keyName)) + : value(fromJson(json[keyName])), key(std::move(keyName)) {} QJsonObject toJson() const { @@ -54,14 +49,11 @@ namespace EventContent } // namespace EventContent #define DEFINE_SIMPLE_STATE_EVENT(_Name, _TypeId, _ValueType, _ContentKey) \ - class _Name : public StateEvent> \ - { \ + class _Name : public StateEvent> { \ public: \ using value_type = content_type::value_type; \ DEFINE_EVENT_TYPEID(_TypeId, _Name) \ - explicit _Name() \ - : _Name(value_type()) \ - {} \ + explicit _Name() : _Name(value_type()) {} \ template \ explicit _Name(T&& value) \ : StateEvent(typeId(), matrixTypeId(), QString(), \ @@ -86,8 +78,7 @@ DEFINE_EVENTTYPE_ALIAS(RoomTopic, RoomTopicEvent) DEFINE_EVENTTYPE_ALIAS(RoomEncryption, EncryptionEvent) class RoomAliasesEvent - : public StateEvent> -{ + : public StateEvent> { public: DEFINE_EVENT_TYPEID("m.room.aliases", RoomAliasesEvent) explicit RoomAliasesEvent(const QJsonObject& obj) diff --git a/lib/events/stateevent.h b/lib/events/stateevent.h index d1b742ba..757c94ee 100644 --- a/lib/events/stateevent.h +++ b/lib/events/stateevent.h @@ -20,8 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { /// Make a minimal correct Matrix state event JSON template @@ -34,13 +33,11 @@ inline QJsonObject basicStateEventJson(StrT matrixType, { ContentKey, content } }; } -class StateEventBase : public RoomEvent -{ +class StateEventBase : public RoomEvent { public: using factory_t = EventFactory; - StateEventBase(Type type, const QJsonObject& json) - : RoomEvent(type, json) + StateEventBase(Type type, const QJsonObject& json) : RoomEvent(type, json) {} StateEventBase(Type type, event_mtype_t matrixType, const QString& stateKey = {}, @@ -71,8 +68,7 @@ inline bool is(const Event& e) using StateEventKey = QPair; template -struct Prev -{ +struct Prev { template explicit Prev(const QJsonObject& unsignedJson, ContentParamTs&&... contentParams) @@ -86,8 +82,7 @@ struct Prev }; template -class StateEvent : public StateEventBase -{ +class StateEvent : public StateEventBase { public: using content_type = ContentT; @@ -135,11 +130,9 @@ private: }; } // namespace QMatrixClient -namespace std -{ +namespace std { template <> -struct hash -{ +struct hash { size_t operator()(const QMatrixClient::StateEventKey& k) const Q_DECL_NOEXCEPT { return qHash(k); diff --git a/lib/events/typingevent.cpp b/lib/events/typingevent.cpp index 128a206a..ee3d6b67 100644 --- a/lib/events/typingevent.cpp +++ b/lib/events/typingevent.cpp @@ -22,8 +22,7 @@ using namespace QMatrixClient; -TypingEvent::TypingEvent(const QJsonObject& obj) - : Event(typeId(), obj) +TypingEvent::TypingEvent(const QJsonObject& obj) : Event(typeId(), obj) { const auto& array = contentJson()["user_ids"_ls].toArray(); for (const auto& user : array) diff --git a/lib/events/typingevent.h b/lib/events/typingevent.h index 241359b4..c8170865 100644 --- a/lib/events/typingevent.h +++ b/lib/events/typingevent.h @@ -20,10 +20,8 @@ #include "event.h" -namespace QMatrixClient -{ -class TypingEvent : public Event -{ +namespace QMatrixClient { +class TypingEvent : public Event { public: DEFINE_EVENT_TYPEID("m.typing", TypingEvent) diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index e4a74954..a6471ece 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -32,8 +32,7 @@ using namespace QMatrixClient; -struct NetworkReplyDeleter : public QScopedPointerDeleteLater -{ +struct NetworkReplyDeleter : public QScopedPointerDeleteLater { static inline void cleanup(QNetworkReply* reply) { if (reply && reply->isRunning()) @@ -42,8 +41,7 @@ struct NetworkReplyDeleter : public QScopedPointerDeleteLater } }; -class BaseJob::Private -{ +class BaseJob::Private { public: // Using an idiom from clang-tidy: // http://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h index f445d087..c85d2d90 100644 --- a/lib/jobs/basejob.h +++ b/lib/jobs/basejob.h @@ -28,32 +28,22 @@ class QNetworkReply; class QSslError; -namespace QMatrixClient -{ +namespace QMatrixClient { class ConnectionData; -enum class HttpVerb -{ - Get, - Put, - Post, - Delete -}; +enum class HttpVerb { Get, Put, Post, Delete }; -struct JobTimeoutConfig -{ +struct JobTimeoutConfig { int jobTimeout; int nextRetryInterval; }; -class BaseJob : public QObject -{ +class BaseJob : public QObject { Q_OBJECT Q_PROPERTY(QUrl requestUrl READ requestUrl CONSTANT) Q_PROPERTY(int maxRetries READ maxRetries WRITE setMaxRetries) public: - enum StatusCode - { + enum StatusCode { NoError = 0 // To be compatible with Qt conventions , Success = 0, @@ -93,8 +83,7 @@ public: * A simple wrapper around QUrlQuery that allows its creation from * a list of string pairs */ - class Query : public QUrlQuery - { + class Query : public QUrlQuery { public: using QUrlQuery::QUrlQuery; Query() = default; @@ -115,16 +104,10 @@ public: * along the lines of StatusCode, with additional values * starting at UserDefinedError */ - class Status - { + class Status { public: - Status(StatusCode c) - : code(c) - {} - Status(int c, QString m) - : code(c) - , message(std::move(m)) - {} + Status(StatusCode c) : code(c) {} + Status(int c, QString m) : code(c), message(std::move(m)) {} bool good() const { return code < ErrorLevel; } friend QDebug operator<<(QDebug dbg, const Status& s) diff --git a/lib/jobs/downloadfilejob.cpp b/lib/jobs/downloadfilejob.cpp index 3dff5a68..9722186c 100644 --- a/lib/jobs/downloadfilejob.cpp +++ b/lib/jobs/downloadfilejob.cpp @@ -6,12 +6,9 @@ using namespace QMatrixClient; -class DownloadFileJob::Private -{ +class DownloadFileJob::Private { public: - Private() - : tempFile(new QTemporaryFile()) - {} + Private() : tempFile(new QTemporaryFile()) {} explicit Private(const QString& localFilename) : targetFile(new QFile(localFilename)) diff --git a/lib/jobs/downloadfilejob.h b/lib/jobs/downloadfilejob.h index 58858448..ebfe5a0d 100644 --- a/lib/jobs/downloadfilejob.h +++ b/lib/jobs/downloadfilejob.h @@ -2,15 +2,10 @@ #include "csapi/content-repo.h" -namespace QMatrixClient -{ -class DownloadFileJob : public GetContentJob -{ +namespace QMatrixClient { +class DownloadFileJob : public GetContentJob { public: - enum - { - FileError = BaseJob::UserDefinedError + 1 - }; + enum { FileError = BaseJob::UserDefinedError + 1 }; using GetContentJob::makeRequestUrl; static QUrl makeRequestUrl(QUrl baseUrl, const QUrl& mxcUri); diff --git a/lib/jobs/mediathumbnailjob.h b/lib/jobs/mediathumbnailjob.h index eeabe7a9..df0a7f31 100644 --- a/lib/jobs/mediathumbnailjob.h +++ b/lib/jobs/mediathumbnailjob.h @@ -22,10 +22,8 @@ #include -namespace QMatrixClient -{ -class MediaThumbnailJob : public GetContentThumbnailJob -{ +namespace QMatrixClient { +class MediaThumbnailJob : public GetContentThumbnailJob { public: using GetContentThumbnailJob::makeRequestUrl; static QUrl makeRequestUrl(QUrl baseUrl, const QUrl& mxcUri, diff --git a/lib/jobs/postreadmarkersjob.h b/lib/jobs/postreadmarkersjob.h index d53ae66c..cf482a9a 100644 --- a/lib/jobs/postreadmarkersjob.h +++ b/lib/jobs/postreadmarkersjob.h @@ -24,8 +24,7 @@ using namespace QMatrixClient; -class PostReadMarkersJob : public BaseJob -{ +class PostReadMarkersJob : public BaseJob { public: explicit PostReadMarkersJob(const QString& roomId, const QString& readUpToEventId) diff --git a/lib/jobs/requestdata.cpp b/lib/jobs/requestdata.cpp index 8248d6b1..6ad7c007 100644 --- a/lib/jobs/requestdata.cpp +++ b/lib/jobs/requestdata.cpp @@ -23,16 +23,10 @@ inline auto fromJson(const JsonDataT& jdata) return fromData(QJsonDocument(jdata).toJson(QJsonDocument::Compact)); } -RequestData::RequestData(const QByteArray& a) - : _source(fromData(a)) -{} +RequestData::RequestData(const QByteArray& a) : _source(fromData(a)) {} -RequestData::RequestData(const QJsonObject& jo) - : _source(fromJson(jo)) -{} +RequestData::RequestData(const QJsonObject& jo) : _source(fromJson(jo)) {} -RequestData::RequestData(const QJsonArray& ja) - : _source(fromJson(ja)) -{} +RequestData::RequestData(const QJsonArray& ja) : _source(fromJson(ja)) {} RequestData::~RequestData() = default; diff --git a/lib/jobs/requestdata.h b/lib/jobs/requestdata.h index 974a9ddf..55987a3b 100644 --- a/lib/jobs/requestdata.h +++ b/lib/jobs/requestdata.h @@ -26,23 +26,20 @@ class QJsonArray; class QJsonDocument; class QIODevice; -namespace QMatrixClient -{ +namespace QMatrixClient { /** * A simple wrapper that represents the request body. * Provides a unified interface to dump an unstructured byte stream * as well as JSON (and possibly other structures in the future) to * a QByteArray consumed by QNetworkAccessManager request methods. */ -class RequestData -{ +class RequestData { public: RequestData() = default; RequestData(const QByteArray& a); RequestData(const QJsonObject& jo); RequestData(const QJsonArray& ja); - RequestData(QIODevice* source) - : _source(std::unique_ptr(source)) + RequestData(QIODevice* source) : _source(std::unique_ptr(source)) {} RequestData(const RequestData&) = delete; RequestData& operator=(const RequestData&) = delete; diff --git a/lib/jobs/syncjob.h b/lib/jobs/syncjob.h index e2cec8f7..8f925414 100644 --- a/lib/jobs/syncjob.h +++ b/lib/jobs/syncjob.h @@ -22,10 +22,8 @@ #include "../syncdata.h" #include "basejob.h" -namespace QMatrixClient -{ -class SyncJob : public BaseJob -{ +namespace QMatrixClient { +class SyncJob : public BaseJob { public: explicit SyncJob(const QString& since = {}, const QString& filter = {}, int timeout = -1, const QString& presence = {}); diff --git a/lib/joinstate.h b/lib/joinstate.h index e4dc679a..fcf840ae 100644 --- a/lib/joinstate.h +++ b/lib/joinstate.h @@ -22,10 +22,8 @@ #include -namespace QMatrixClient -{ -enum class JoinState : unsigned int -{ +namespace QMatrixClient { +enum class JoinState : unsigned int { Join = 0x1, Invite = 0x2, Leave = 0x4, diff --git a/lib/logging.h b/lib/logging.h index a50c1795..24799752 100644 --- a/lib/logging.h +++ b/lib/logging.h @@ -28,8 +28,7 @@ Q_DECLARE_LOGGING_CATEGORY(EPHEMERAL) Q_DECLARE_LOGGING_CATEGORY(JOBS) Q_DECLARE_LOGGING_CATEGORY(SYNCJOB) -namespace QMatrixClient -{ +namespace QMatrixClient { // QDebug manipulators using QDebugManip = QDebug (*)(QDebug); diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp index 9ac589b8..7bff654c 100644 --- a/lib/networkaccessmanager.cpp +++ b/lib/networkaccessmanager.cpp @@ -23,15 +23,13 @@ using namespace QMatrixClient; -class NetworkAccessManager::Private -{ +class NetworkAccessManager::Private { public: QList ignoredSslErrors; }; NetworkAccessManager::NetworkAccessManager(QObject* parent) - : QNetworkAccessManager(parent) - , d(std::make_unique()) + : QNetworkAccessManager(parent), d(std::make_unique()) {} QList NetworkAccessManager::ignoredSslErrors() const diff --git a/lib/networkaccessmanager.h b/lib/networkaccessmanager.h index bf8f0cbc..dfa388f0 100644 --- a/lib/networkaccessmanager.h +++ b/lib/networkaccessmanager.h @@ -22,10 +22,8 @@ #include -namespace QMatrixClient -{ -class NetworkAccessManager : public QNetworkAccessManager -{ +namespace QMatrixClient { +class NetworkAccessManager : public QNetworkAccessManager { Q_OBJECT public: NetworkAccessManager(QObject* parent = nullptr); diff --git a/lib/networksettings.h b/lib/networksettings.h index 0c21a9fe..75bf726d 100644 --- a/lib/networksettings.h +++ b/lib/networksettings.h @@ -24,10 +24,8 @@ Q_DECLARE_METATYPE(QNetworkProxy::ProxyType) -namespace QMatrixClient -{ -class NetworkSettings : public SettingsGroup -{ +namespace QMatrixClient { +class NetworkSettings : public SettingsGroup { Q_OBJECT QMC_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType) QMC_DECLARE_SETTING(QString, proxyHostName, setProxyHostName) diff --git a/lib/qt_connection_util.h b/lib/qt_connection_util.h index 1b3229d4..94c1ec60 100644 --- a/lib/qt_connection_util.h +++ b/lib/qt_connection_util.h @@ -22,10 +22,8 @@ #include -namespace QMatrixClient -{ -namespace _impl -{ +namespace QMatrixClient { +namespace _impl { template inline QMetaObject::Connection connectUntil(SenderT* sender, SignalT signal, ContextT* context, @@ -86,12 +84,10 @@ inline auto connectSingleShot(SenderT* sender, SignalT signal, * destruction. */ template -class ConnectionsGuard : public QPointer -{ +class ConnectionsGuard : public QPointer { public: ConnectionsGuard(T* publisher, QObject* subscriber) - : QPointer(publisher) - , subscriber(subscriber) + : QPointer(publisher), subscriber(subscriber) {} ~ConnectionsGuard() { diff --git a/lib/room.cpp b/lib/room.cpp index cf58f3c0..b32d3492 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -78,24 +78,16 @@ using std::move; using std::llround; #endif -enum EventsPlacement : int -{ - Older = -1, - Newer = 1 -}; +enum EventsPlacement : int { Older = -1, Newer = 1 }; -class Room::Private -{ +class Room::Private { public: /// Map of user names to users /** User names potentially duplicate, hence QMultiHash. */ using members_map_t = QMultiHash; Private(Connection* c, QString id_, JoinState initialJoinState) - : q(nullptr) - , connection(c) - , id(move(id_)) - , joinState(initialJoinState) + : q(nullptr), connection(c), id(move(id_)), joinState(initialJoinState) {} Room* q; @@ -144,8 +136,7 @@ public: QPointer eventsHistoryJob; QPointer allMembersJob; - struct FileTransferPrivateInfo - { + struct FileTransferPrivateInfo { FileTransferPrivateInfo() = default; FileTransferPrivateInfo(BaseJob* j, const QString& fileName, bool isUploading = false) @@ -354,8 +345,7 @@ private: decltype(Room::Private::baseState) Room::Private::stubbedState {}; Room::Room(Connection* connection, QString id, JoinState initialJoinState) - : QObject(connection) - , d(new Private(connection, id, initialJoinState)) + : QObject(connection), d(new Private(connection, id, initialJoinState)) { setObjectName(id); // See "Accessing the Public Class" section in @@ -1617,9 +1607,9 @@ QString Room::postFile(const QString& plainText, const QUrl& localPath, // Normally in this situation we should instruct // the media server to delete the file; alas, there's no // API specced for that. - qCWarning(MAIN) - << "File uploaded to" << mxcUri - << "but the event referring to it was cancelled"; + qCWarning(MAIN) << "File uploaded to" << mxcUri + << "but the event referring to it was " + "cancelled"; } context->deleteLater(); } @@ -2382,9 +2372,9 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) break; case MembershipType::Join: if (evt.membership() == MembershipType::Invite) - qCWarning(MAIN) - << "Invalid membership change from Join to Invite:" - << evt; + qCWarning(MAIN) << "Invalid membership change from " + "Join to Invite:" + << evt; if (evt.membership() != prevMembership) { disconnect(u, &User::nameAboutToChange, this, nullptr); disconnect(u, &User::nameChanged, this, nullptr); @@ -2564,7 +2554,8 @@ Room::Private::buildShortlist(const ContT& users) const std::partial_sort_copy( users.begin(), users.end(), shortlist.begin(), shortlist.end(), [this](const User* u1, const User* u2) { - // localUser(), if it's in the list, is sorted below all others + // localUser(), if it's in the list, is sorted + // below all others return isLocalUser(u2) || (!isLocalUser(u1) && u1->id() < u2->id()); }); return shortlist; diff --git a/lib/room.h b/lib/room.h index f5433fb6..d6fb8a61 100644 --- a/lib/room.h +++ b/lib/room.h @@ -35,8 +35,7 @@ #include #include -namespace QMatrixClient -{ +namespace QMatrixClient { class Event; class Avatar; class SyncRoomData; @@ -52,8 +51,7 @@ class RedactEventJob; * This is specifically tuned to work with QML exposing all traits as * Q_PROPERTY values. */ -class FileTransferInfo -{ +class FileTransferInfo { Q_GADGET Q_PROPERTY(bool isUpload MEMBER isUpload CONSTANT) Q_PROPERTY(bool active READ active CONSTANT) @@ -65,14 +63,7 @@ class FileTransferInfo Q_PROPERTY(QUrl localDir MEMBER localDir CONSTANT) Q_PROPERTY(QUrl localPath MEMBER localPath CONSTANT) public: - enum Status - { - None, - Started, - Completed, - Failed, - Cancelled - }; + enum Status { None, Started, Completed, Failed, Cancelled }; Status status = None; bool isUpload = false; int progress = 0; @@ -86,8 +77,7 @@ public: bool failed() const { return status == Failed; } }; -class Room : public QObject -{ +class Room : public QObject { Q_OBJECT Q_PROPERTY(Connection* connection READ connection CONSTANT) Q_PROPERTY(User* localUser READ localUser CONSTANT) @@ -146,8 +136,7 @@ public: using rev_iter_t = Timeline::const_reverse_iterator; using timeline_iter_t = Timeline::const_iterator; - enum Change : uint - { + enum Change : uint { NoChange = 0x0, NameChange = 0x1, CanonicalAliasChange = 0x2, @@ -663,12 +652,9 @@ private: void setJoinState(JoinState state); }; -class MemberSorter -{ +class MemberSorter { public: - explicit MemberSorter(const Room* r) - : room(r) - {} + explicit MemberSorter(const Room* r) : room(r) {} bool operator()(User* u1, User* u2) const; bool operator()(User* u1, const QString& u2name) const; diff --git a/lib/settings.h b/lib/settings.h index e1ca0866..6747631e 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -24,10 +24,8 @@ class QVariant; -namespace QMatrixClient -{ -class Settings : public QSettings -{ +namespace QMatrixClient { +class Settings : public QSettings { Q_OBJECT public: /** @@ -42,9 +40,7 @@ public: #if defined(_MSC_VER) && _MSC_VER < 1900 // VS 2013 (and probably older) aren't friends with 'using' statements // that involve private constructors - explicit Settings(QObject* parent = 0) - : QSettings(parent) - {} + explicit Settings(QObject* parent = 0) : QSettings(parent) {} #else using QSettings::QSettings; #endif @@ -71,8 +67,7 @@ protected: QSettings legacySettings { legacyOrganizationName, legacyApplicationName }; }; -class SettingsGroup : public Settings -{ +class SettingsGroup : public Settings { public: template explicit SettingsGroup(QString path, ArgTs&&... qsettingsArgs) @@ -121,8 +116,7 @@ private: setValue(QStringLiteral(qsettingname), std::move(newValue)); \ } -class AccountSettings : public SettingsGroup -{ +class AccountSettings : public SettingsGroup { Q_OBJECT Q_PROPERTY(QString userId READ userId CONSTANT) QMC_DECLARE_SETTING(QString, deviceId, setDeviceId) diff --git a/lib/syncdata.h b/lib/syncdata.h index 6932878d..ad9902e4 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -22,8 +22,7 @@ #include "events/stateevent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { /// Room summary, as defined in MSC688 /** * Every member of this structure is an Omittable; as per the MSC, only @@ -32,8 +31,7 @@ namespace QMatrixClient * means that nothing has come from the server; heroes.value().isEmpty() * means a peculiar case of a room with the only member - the current user. */ -struct RoomSummary -{ +struct RoomSummary { Omittable joinedMemberCount; Omittable invitedMemberCount; Omittable heroes; //< mxids of users to take part in the room @@ -48,14 +46,12 @@ struct RoomSummary }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const RoomSummary& rs); static void fillFrom(const QJsonObject& jo, RoomSummary& rs); }; -class SyncRoomData -{ +class SyncRoomData { public: QString roomId; JoinState joinState; @@ -82,8 +78,7 @@ public: // QVector cannot work with non-copiable objects, std::vector can. using SyncDataList = std::vector; -class SyncData -{ +class SyncData { public: SyncData() = default; explicit SyncData(const QString& cacheFileName); diff --git a/lib/user.cpp b/lib/user.cpp index f0216454..0705aee7 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -41,8 +41,7 @@ using namespace QMatrixClient; using namespace std::placeholders; using std::move; -class User::Private -{ +class User::Private { public: static Avatar makeAvatar(QUrl url) { return Avatar(move(url)); } @@ -184,8 +183,7 @@ void User::Private::setAvatarForRoom(const Room* r, const QUrl& newUrl, } User::User(QString userId, Connection* connection) - : QObject(connection) - , d(new Private(move(userId), connection)) + : QObject(connection), d(new Private(move(userId), connection)) { setObjectName(userId); } diff --git a/lib/user.h b/lib/user.h index f4d7cff3..779efb34 100644 --- a/lib/user.h +++ b/lib/user.h @@ -23,14 +23,12 @@ #include #include -namespace QMatrixClient -{ +namespace QMatrixClient { class Connection; class Room; class RoomMemberEvent; -class User : public QObject -{ +class User : public QObject { Q_OBJECT Q_PROPERTY(QString id READ id CONSTANT) Q_PROPERTY(bool isGuest READ isGuest CONSTANT) diff --git a/lib/util.cpp b/lib/util.cpp index 9e0807c6..1919e811 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -124,7 +124,8 @@ QString QMatrixClient::serverPart(const QString& mxId) % ServerPartRegEx % ")$"; static QRegularExpression parser( re, - QRegularExpression::UseUnicodePropertiesOption); // Because Asian digits + QRegularExpression::UseUnicodePropertiesOption); // Because Asian + // digits return parser.match(mxId).captured(1); } @@ -148,16 +149,14 @@ void f2(int, QString); static_assert(std::is_same, QString>::value, "Test fn_arg_t<>"); -struct S -{ +struct S { int mf(); }; static_assert(is_callable_v, "Test member function"); static_assert(returns(), "Test returns<> with member function"); -struct Fo -{ +struct Fo { int operator()(); }; static_assert(is_callable_v, "Test is_callable<> with function object"); @@ -165,8 +164,7 @@ static_assert(function_traits::arg_number == 0, "Test function object"); static_assert(std::is_same, int>::value, "Test return type of function object"); -struct Fo1 -{ +struct Fo1 { void operator()(int); }; static_assert(function_traits::arg_number == 1, "Test function object 1"); @@ -182,13 +180,11 @@ static_assert(std::is_same, int>::value, #endif template -struct fn_object -{ +struct fn_object { static int smf(double) { return 0; } }; template <> -struct fn_object -{ +struct fn_object { void operator()(QString); }; static_assert(is_callable_v>, "Test function object"); diff --git a/lib/util.h b/lib/util.h index a29f6253..d055fa46 100644 --- a/lib/util.h +++ b/lib/util.h @@ -63,8 +63,7 @@ static void qAsConst(const T&&) Q_DECL_EQ_DELETE; # define BROKEN_INITIALIZER_LISTS #endif -namespace QMatrixClient -{ +namespace QMatrixClient { // The below enables pretty-printing of enums in logs #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) # define REGISTER_ENUM(EnumName) Q_ENUM(EnumName) @@ -88,8 +87,7 @@ inline auto unique_ptr_cast(PtrT2&& p) return std::unique_ptr(static_cast(p.release())); } -struct NoneTag -{}; +struct NoneTag {}; constexpr NoneTag none {}; /** A crude substitute for `optional` while we're not C++17 @@ -97,27 +95,17 @@ constexpr NoneTag none {}; * Only works with default-constructible types. */ template -class Omittable -{ +class Omittable { static_assert(!std::is_reference::value, "You cannot make an Omittable<> with a reference type"); public: using value_type = std::decay_t; - explicit Omittable() - : Omittable(none) - {} - Omittable(NoneTag) - : _value(value_type()) - , _omitted(true) - {} - Omittable(const value_type& val) - : _value(val) - {} - Omittable(value_type&& val) - : _value(std::move(val)) - {} + explicit Omittable() : Omittable(none) {} + Omittable(NoneTag) : _value(value_type()), _omitted(true) {} + Omittable(const value_type& val) : _value(val) {} + Omittable(value_type&& val) : _value(std::move(val)) {} Omittable& operator=(const value_type& val) { _value = val; @@ -192,8 +180,7 @@ private: bool _omitted = false; }; -namespace _impl -{ +namespace _impl { template struct fn_traits; } @@ -205,13 +192,11 @@ namespace _impl * https://stackoverflow.com/questions/7943525/is-it-possible-to-figure-out-the-parameter-type-and-return-type-of-a-lambda#7943765 */ template -struct function_traits : public _impl::fn_traits -{}; +struct function_traits : public _impl::fn_traits {}; // Specialisation for a function template -struct function_traits -{ +struct function_traits { static constexpr auto is_callable = true; using return_type = ReturnT; using arg_types = std::tuple; @@ -219,30 +204,26 @@ struct function_traits static constexpr auto arg_number = std::tuple_size::value; }; -namespace _impl -{ +namespace _impl { template - struct fn_traits - { + struct fn_traits { static constexpr auto is_callable = false; }; template struct fn_traits - : public fn_traits - {}; // A generic function object that has (non-overloaded) operator() + : public fn_traits { + }; // A generic function object that has (non-overloaded) operator() // Specialisation for a member function template struct fn_traits - : function_traits - {}; + : function_traits {}; // Specialisation for a const member function template struct fn_traits - : function_traits - {}; + : function_traits {}; } // namespace _impl template @@ -272,22 +253,15 @@ inline auto operator"" _ls(const char* s, std::size_t size) * are at least ForwardIterators. Inspired by Ranges TS. */ template -class Range -{ +class Range { // Looking forward for Ranges TS to produce something (in C++23?..) using iterator = typename ArrayT::iterator; using const_iterator = typename ArrayT::const_iterator; using size_type = typename ArrayT::size_type; public: - Range(ArrayT& arr) - : from(std::begin(arr)) - , to(std::end(arr)) - {} - Range(iterator from, iterator to) - : from(from) - , to(to) - {} + Range(ArrayT& arr) : from(std::begin(arr)), to(std::end(arr)) {} + Range(iterator from, iterator to) : from(from), to(to) {} size_type size() const { -- cgit v1.2.3 From 27ca32a1e5a56e09b9cc1d94224d2831004dcf3d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jul 2019 19:32:34 +0900 Subject: Namespace: QMatrixClient -> Quotient (with back comp alias) --- examples/qmc-example.cpp | 2 +- lib/application-service/definitions/location.cpp | 2 +- lib/application-service/definitions/location.h | 4 ++-- lib/application-service/definitions/protocol.cpp | 2 +- lib/application-service/definitions/protocol.h | 4 ++-- lib/application-service/definitions/user.cpp | 2 +- lib/application-service/definitions/user.h | 4 ++-- lib/avatar.cpp | 2 +- lib/avatar.h | 6 ++++-- lib/connection.cpp | 6 +++--- lib/connection.h | 6 +++--- lib/connectiondata.cpp | 2 +- lib/connectiondata.h | 4 ++-- lib/converters.cpp | 2 +- lib/converters.h | 4 ++-- lib/csapi/account-data.cpp | 2 +- lib/csapi/account-data.h | 4 ++-- lib/csapi/admin.cpp | 6 +++--- lib/csapi/admin.h | 4 ++-- lib/csapi/administrative_contact.cpp | 10 +++++----- lib/csapi/administrative_contact.h | 4 ++-- lib/csapi/appservice_room_directory.cpp | 2 +- lib/csapi/appservice_room_directory.h | 4 ++-- lib/csapi/banning.cpp | 2 +- lib/csapi/banning.h | 4 ++-- lib/csapi/capabilities.cpp | 6 +++--- lib/csapi/capabilities.h | 4 ++-- lib/csapi/content-repo.cpp | 2 +- lib/csapi/content-repo.h | 4 ++-- lib/csapi/create_room.cpp | 6 +++--- lib/csapi/create_room.h | 4 ++-- lib/csapi/definitions/auth_data.cpp | 2 +- lib/csapi/definitions/auth_data.h | 4 ++-- lib/csapi/definitions/client_device.cpp | 2 +- lib/csapi/definitions/client_device.h | 4 ++-- lib/csapi/definitions/device_keys.cpp | 2 +- lib/csapi/definitions/device_keys.h | 4 ++-- lib/csapi/definitions/event_filter.cpp | 2 +- lib/csapi/definitions/event_filter.h | 4 ++-- lib/csapi/definitions/public_rooms_response.cpp | 2 +- lib/csapi/definitions/public_rooms_response.h | 4 ++-- lib/csapi/definitions/push_condition.cpp | 2 +- lib/csapi/definitions/push_condition.h | 4 ++-- lib/csapi/definitions/push_rule.cpp | 2 +- lib/csapi/definitions/push_rule.h | 4 ++-- lib/csapi/definitions/push_ruleset.cpp | 2 +- lib/csapi/definitions/push_ruleset.h | 4 ++-- lib/csapi/definitions/room_event_filter.cpp | 2 +- lib/csapi/definitions/room_event_filter.h | 4 ++-- lib/csapi/definitions/sync_filter.cpp | 2 +- lib/csapi/definitions/sync_filter.h | 4 ++-- lib/csapi/definitions/user_identifier.cpp | 2 +- lib/csapi/definitions/user_identifier.h | 4 ++-- lib/csapi/definitions/wellknown/full.cpp | 2 +- lib/csapi/definitions/wellknown/full.h | 4 ++-- lib/csapi/definitions/wellknown/homeserver.cpp | 2 +- lib/csapi/definitions/wellknown/homeserver.h | 4 ++-- lib/csapi/definitions/wellknown/identity_server.cpp | 2 +- lib/csapi/definitions/wellknown/identity_server.h | 4 ++-- lib/csapi/device_management.cpp | 2 +- lib/csapi/device_management.h | 4 ++-- lib/csapi/directory.cpp | 2 +- lib/csapi/directory.h | 4 ++-- lib/csapi/event_context.cpp | 2 +- lib/csapi/event_context.h | 4 ++-- lib/csapi/filter.cpp | 2 +- lib/csapi/filter.h | 4 ++-- lib/csapi/inviting.cpp | 2 +- lib/csapi/inviting.h | 4 ++-- lib/csapi/joining.cpp | 10 +++++----- lib/csapi/joining.h | 4 ++-- lib/csapi/keys.cpp | 6 +++--- lib/csapi/keys.h | 4 ++-- lib/csapi/kicking.cpp | 2 +- lib/csapi/kicking.h | 4 ++-- lib/csapi/leaving.cpp | 2 +- lib/csapi/leaving.h | 4 ++-- lib/csapi/list_joined_rooms.cpp | 2 +- lib/csapi/list_joined_rooms.h | 4 ++-- lib/csapi/list_public_rooms.cpp | 6 +++--- lib/csapi/list_public_rooms.h | 4 ++-- lib/csapi/login.cpp | 6 +++--- lib/csapi/login.h | 4 ++-- lib/csapi/logout.cpp | 2 +- lib/csapi/logout.h | 4 ++-- lib/csapi/message_pagination.cpp | 2 +- lib/csapi/message_pagination.h | 4 ++-- lib/csapi/notifications.cpp | 6 +++--- lib/csapi/notifications.h | 4 ++-- lib/csapi/openid.cpp | 2 +- lib/csapi/openid.h | 4 ++-- lib/csapi/peeking_events.cpp | 2 +- lib/csapi/peeking_events.h | 4 ++-- lib/csapi/presence.cpp | 2 +- lib/csapi/presence.h | 4 ++-- lib/csapi/profile.cpp | 2 +- lib/csapi/profile.h | 4 ++-- lib/csapi/pusher.cpp | 10 +++++----- lib/csapi/pusher.h | 4 ++-- lib/csapi/pushrules.cpp | 2 +- lib/csapi/pushrules.h | 4 ++-- lib/csapi/read_markers.cpp | 2 +- lib/csapi/read_markers.h | 4 ++-- lib/csapi/receipts.cpp | 2 +- lib/csapi/receipts.h | 4 ++-- lib/csapi/redaction.cpp | 2 +- lib/csapi/redaction.h | 4 ++-- lib/csapi/registration.cpp | 2 +- lib/csapi/registration.h | 4 ++-- lib/csapi/report_content.cpp | 2 +- lib/csapi/report_content.h | 4 ++-- lib/csapi/room_send.cpp | 2 +- lib/csapi/room_send.h | 4 ++-- lib/csapi/room_state.cpp | 2 +- lib/csapi/room_state.h | 4 ++-- lib/csapi/room_upgrades.cpp | 2 +- lib/csapi/room_upgrades.h | 4 ++-- lib/csapi/rooms.cpp | 6 +++--- lib/csapi/rooms.h | 4 ++-- lib/csapi/search.cpp | 6 +++--- lib/csapi/search.h | 4 ++-- lib/csapi/sso_login_redirect.cpp | 2 +- lib/csapi/sso_login_redirect.h | 4 ++-- lib/csapi/tags.cpp | 6 +++--- lib/csapi/tags.h | 4 ++-- lib/csapi/third_party_lookup.cpp | 2 +- lib/csapi/third_party_lookup.h | 4 ++-- lib/csapi/third_party_membership.cpp | 2 +- lib/csapi/third_party_membership.h | 4 ++-- lib/csapi/to_device.cpp | 2 +- lib/csapi/to_device.h | 4 ++-- lib/csapi/typing.cpp | 2 +- lib/csapi/typing.h | 4 ++-- lib/csapi/users.cpp | 6 +++--- lib/csapi/users.h | 4 ++-- lib/csapi/versions.cpp | 2 +- lib/csapi/versions.h | 4 ++-- lib/csapi/voip.cpp | 2 +- lib/csapi/voip.h | 4 ++-- lib/csapi/wellknown.cpp | 2 +- lib/csapi/wellknown.h | 4 ++-- lib/csapi/whoami.cpp | 2 +- lib/csapi/whoami.h | 4 ++-- lib/csapi/{{base}}.cpp.mustache | 4 ++-- lib/csapi/{{base}}.h.mustache | 4 ++-- lib/e2ee.h | 4 ++-- lib/encryptionmanager.cpp | 2 +- lib/encryptionmanager.h | 4 ++-- lib/eventitem.cpp | 2 +- lib/eventitem.h | 6 +++--- lib/events/accountdataevents.h | 4 ++-- lib/events/callanswerevent.cpp | 2 +- lib/events/callanswerevent.h | 4 ++-- lib/events/callcandidatesevent.h | 4 ++-- lib/events/callhangupevent.cpp | 2 +- lib/events/callhangupevent.h | 4 ++-- lib/events/callinviteevent.cpp | 2 +- lib/events/callinviteevent.h | 4 ++-- lib/events/directchatevent.cpp | 2 +- lib/events/directchatevent.h | 4 ++-- lib/events/encryptedevent.h | 4 ++-- lib/events/encryptionevent.cpp | 6 +++--- lib/events/encryptionevent.h | 4 ++-- lib/events/event.cpp | 2 +- lib/events/event.h | 10 +++++----- lib/events/eventcontent.cpp | 2 +- lib/events/eventcontent.h | 4 ++-- lib/events/eventloader.h | 4 ++-- lib/events/reactionevent.cpp | 4 ++-- lib/events/reactionevent.h | 4 ++-- lib/events/receiptevent.cpp | 2 +- lib/events/receiptevent.h | 4 ++-- lib/events/redactionevent.h | 4 ++-- lib/events/roomavatarevent.h | 4 ++-- lib/events/roomcreateevent.cpp | 2 +- lib/events/roomcreateevent.h | 4 ++-- lib/events/roomevent.cpp | 4 ++-- lib/events/roomevent.h | 8 ++++---- lib/events/roommemberevent.cpp | 6 +++--- lib/events/roommemberevent.h | 4 ++-- lib/events/roommessageevent.cpp | 6 +++--- lib/events/roommessageevent.h | 4 ++-- lib/events/roomtombstoneevent.cpp | 2 +- lib/events/roomtombstoneevent.h | 4 ++-- lib/events/simplestateevents.h | 6 +++--- lib/events/stateevent.cpp | 2 +- lib/events/stateevent.h | 8 ++++---- lib/events/typingevent.cpp | 2 +- lib/events/typingevent.h | 4 ++-- lib/identity/definitions/request_email_validation.cpp | 2 +- lib/identity/definitions/request_email_validation.h | 4 ++-- lib/identity/definitions/request_msisdn_validation.cpp | 2 +- lib/identity/definitions/request_msisdn_validation.h | 4 ++-- lib/identity/definitions/sid.cpp | 2 +- lib/identity/definitions/sid.h | 4 ++-- lib/jobs/basejob.cpp | 2 +- lib/jobs/basejob.h | 4 ++-- lib/jobs/downloadfilejob.cpp | 2 +- lib/jobs/downloadfilejob.h | 4 ++-- lib/jobs/mediathumbnailjob.cpp | 2 +- lib/jobs/mediathumbnailjob.h | 4 ++-- lib/jobs/postreadmarkersjob.h | 2 +- lib/jobs/requestdata.cpp | 2 +- lib/jobs/requestdata.h | 6 ++++-- lib/jobs/syncjob.cpp | 2 +- lib/jobs/syncjob.h | 4 ++-- lib/joinstate.h | 6 +++--- lib/logging.h | 6 ++++-- lib/networkaccessmanager.cpp | 2 +- lib/networkaccessmanager.h | 4 ++-- lib/networksettings.cpp | 2 +- lib/networksettings.h | 2 +- lib/qt_connection_util.h | 4 ++-- lib/room.cpp | 4 ++-- lib/room.h | 10 +++++----- lib/settings.cpp | 2 +- lib/settings.h | 4 ++-- lib/syncdata.cpp | 4 ++-- lib/syncdata.h | 4 ++-- lib/user.cpp | 2 +- lib/user.h | 6 +++--- lib/util.cpp | 14 +++++++------- lib/util.h | 6 ++++-- 223 files changed, 414 insertions(+), 406 deletions(-) (limited to 'lib/events') diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index 4a06d9b8..bf4d04c7 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -19,7 +19,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; using std::cout; using std::endl; using namespace std::placeholders; diff --git a/lib/application-service/definitions/location.cpp b/lib/application-service/definitions/location.cpp index 2ab83ae9..0a054029 100644 --- a/lib/application-service/definitions/location.cpp +++ b/lib/application-service/definitions/location.cpp @@ -4,7 +4,7 @@ #include "location.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const ThirdPartyLocation& pod) diff --git a/lib/application-service/definitions/location.h b/lib/application-service/definitions/location.h index caf28615..77512514 100644 --- a/lib/application-service/definitions/location.h +++ b/lib/application-service/definitions/location.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -30,4 +30,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, ThirdPartyLocation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/application-service/definitions/protocol.cpp b/lib/application-service/definitions/protocol.cpp index e87001fb..8c66aa4d 100644 --- a/lib/application-service/definitions/protocol.cpp +++ b/lib/application-service/definitions/protocol.cpp @@ -4,7 +4,7 @@ #include "protocol.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const FieldType& pod) diff --git a/lib/application-service/definitions/protocol.h b/lib/application-service/definitions/protocol.h index 0d227851..ab99264f 100644 --- a/lib/application-service/definitions/protocol.h +++ b/lib/application-service/definitions/protocol.h @@ -10,7 +10,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -85,4 +85,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, ThirdPartyProtocol& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/application-service/definitions/user.cpp b/lib/application-service/definitions/user.cpp index 0f3c3130..17d15a20 100644 --- a/lib/application-service/definitions/user.cpp +++ b/lib/application-service/definitions/user.cpp @@ -4,7 +4,7 @@ #include "user.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const ThirdPartyUser& pod) diff --git a/lib/application-service/definitions/user.h b/lib/application-service/definitions/user.h index 3fd099d0..34c6829c 100644 --- a/lib/application-service/definitions/user.h +++ b/lib/application-service/definitions/user.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -30,4 +30,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, ThirdPartyUser& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/avatar.cpp b/lib/avatar.cpp index 614f008d..cb734984 100644 --- a/lib/avatar.cpp +++ b/lib/avatar.cpp @@ -29,7 +29,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; using std::move; class Avatar::Private { diff --git a/lib/avatar.h b/lib/avatar.h index c33e1982..7a566bfa 100644 --- a/lib/avatar.h +++ b/lib/avatar.h @@ -24,7 +24,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { class Connection; class Avatar { @@ -56,4 +56,6 @@ private: class Private; std::unique_ptr d; }; -} // namespace QMatrixClient +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; \ No newline at end of file diff --git a/lib/connection.cpp b/lib/connection.cpp index 58d2e01a..22db8e3d 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -53,7 +53,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; // This is very much Qt-specific; STL iterators don't have key() and value() template @@ -1349,9 +1349,9 @@ void Connection::setCacheState(bool newValue) } } -bool QMatrixClient::Connection::lazyLoading() const { return d->lazyLoading; } +bool Connection::lazyLoading() const { return d->lazyLoading; } -void QMatrixClient::Connection::setLazyLoading(bool newValue) +void Connection::setLazyLoading(bool newValue) { if (d->lazyLoading != newValue) { d->lazyLoading = newValue; diff --git a/lib/connection.h b/lib/connection.h index b89c0c65..c807b827 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -36,7 +36,7 @@ namespace QtOlm { class Account; } -namespace QMatrixClient { +namespace Quotient { class Room; class User; class ConnectionData; @@ -778,5 +778,5 @@ private: static room_factory_t _roomFactory; static user_factory_t _userFactory; }; -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::Connection*) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::Connection*) diff --git a/lib/connectiondata.cpp b/lib/connectiondata.cpp index df4cece2..486de03d 100644 --- a/lib/connectiondata.cpp +++ b/lib/connectiondata.cpp @@ -21,7 +21,7 @@ #include "logging.h" #include "networkaccessmanager.h" -using namespace QMatrixClient; +using namespace Quotient; struct ConnectionData::Private { explicit Private(QUrl url) : baseUrl(std::move(url)) {} diff --git a/lib/connectiondata.h b/lib/connectiondata.h index 9b579b1c..80ace08c 100644 --- a/lib/connectiondata.h +++ b/lib/connectiondata.h @@ -24,7 +24,7 @@ class QNetworkAccessManager; -namespace QMatrixClient { +namespace Quotient { class ConnectionData { public: explicit ConnectionData(QUrl baseUrl); @@ -50,4 +50,4 @@ private: struct Private; std::unique_ptr d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/converters.cpp b/lib/converters.cpp index ef58c85e..9f4b9360 100644 --- a/lib/converters.cpp +++ b/lib/converters.cpp @@ -20,7 +20,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; QJsonValue JsonConverter::dump(const QVariant& v) { diff --git a/lib/converters.h b/lib/converters.h index 0085fa4b..587e4544 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -55,7 +55,7 @@ struct hash { class QVariant; -namespace QMatrixClient { +namespace Quotient { template struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const T& pod) { jo = pod.toJson(); } @@ -439,4 +439,4 @@ inline void addParam(ContT& container, const QString& key, ValT&& value) _impl::AddNode, Force>::impl(container, key, std::forward(value)); } -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 7d4f1ad7..2e466fa3 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h index 75bb9ce3..7417da0d 100644 --- a/lib/csapi/account-data.h +++ b/lib/csapi/account-data.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -122,4 +122,4 @@ public: const QString& roomId, const QString& type); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp index 58334118..d2c20ba8 100644 --- a/lib/csapi/admin.cpp +++ b/lib/csapi/admin.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -46,7 +46,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetWhoIsJob::Private { diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h index bc27c025..472ccf72 100644 --- a/lib/csapi/admin.h +++ b/lib/csapi/admin.h @@ -11,7 +11,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -94,4 +94,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 067fb68a..32bc8c86 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -29,7 +29,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetAccount3PIDsJob::Private { @@ -67,7 +67,7 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -82,7 +82,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient static const auto Post3PIDsJobName = QStringLiteral("Post3PIDsJob"); diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h index 7f2d0cdc..4ccd7596 100644 --- a/lib/csapi/administrative_contact.h +++ b/lib/csapi/administrative_contact.h @@ -12,7 +12,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -256,4 +256,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index 74e037cd..87221aa4 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/appservice_room_directory.h b/lib/csapi/appservice_room_directory.h index d1c3f89f..e19bf320 100644 --- a/lib/csapi/appservice_room_directory.h +++ b/lib/csapi/appservice_room_directory.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -42,4 +42,4 @@ public: const QString& visibility); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index a46e78f1..eac09d5a 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/banning.h b/lib/csapi/banning.h index 0aa5785b..5df878a8 100644 --- a/lib/csapi/banning.h +++ b/lib/csapi/banning.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -58,4 +58,4 @@ public: explicit UnbanJob(const QString& roomId, const QString& userId); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/capabilities.cpp b/lib/csapi/capabilities.cpp index 9a054fe9..6a544a1e 100644 --- a/lib/csapi/capabilities.cpp +++ b/lib/csapi/capabilities.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -49,7 +49,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetCapabilitiesJob::Private { diff --git a/lib/csapi/capabilities.h b/lib/csapi/capabilities.h index f6e7ad06..b608a2f2 100644 --- a/lib/csapi/capabilities.h +++ b/lib/csapi/capabilities.h @@ -11,7 +11,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -84,4 +84,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index c2720d63..395337f3 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -9,7 +9,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/media/r0"); diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index 9f267f6c..83069490 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -282,4 +282,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index e94cb008..68741f13 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -38,7 +38,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class CreateRoomJob::Private { diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index a066a3f3..e7000155 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -11,7 +11,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -235,4 +235,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/auth_data.cpp b/lib/csapi/definitions/auth_data.cpp index 3bb51626..edeb7111 100644 --- a/lib/csapi/definitions/auth_data.cpp +++ b/lib/csapi/definitions/auth_data.cpp @@ -4,7 +4,7 @@ #include "auth_data.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const AuthenticationData& pod) diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h index 9e46812c..1aeea6c2 100644 --- a/lib/csapi/definitions/auth_data.h +++ b/lib/csapi/definitions/auth_data.h @@ -9,7 +9,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -34,4 +34,4 @@ struct JsonObjectConverter static void fillFrom(QJsonObject jo, AuthenticationData& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/client_device.cpp b/lib/csapi/definitions/client_device.cpp index c9e6a223..09544138 100644 --- a/lib/csapi/definitions/client_device.cpp +++ b/lib/csapi/definitions/client_device.cpp @@ -4,7 +4,7 @@ #include "client_device.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const Device& pod) { diff --git a/lib/csapi/definitions/client_device.h b/lib/csapi/definitions/client_device.h index e4accc35..f076c4da 100644 --- a/lib/csapi/definitions/client_device.h +++ b/lib/csapi/definitions/client_device.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -34,4 +34,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, Device& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/device_keys.cpp b/lib/csapi/definitions/device_keys.cpp index cc5262b7..0583840d 100644 --- a/lib/csapi/definitions/device_keys.cpp +++ b/lib/csapi/definitions/device_keys.cpp @@ -4,7 +4,7 @@ #include "device_keys.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const DeviceKeys& pod) diff --git a/lib/csapi/definitions/device_keys.h b/lib/csapi/definitions/device_keys.h index 6bd96584..d1d8abef 100644 --- a/lib/csapi/definitions/device_keys.h +++ b/lib/csapi/definitions/device_keys.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -41,4 +41,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, DeviceKeys& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/event_filter.cpp b/lib/csapi/definitions/event_filter.cpp index 9b2c7a33..b21e08b5 100644 --- a/lib/csapi/definitions/event_filter.cpp +++ b/lib/csapi/definitions/event_filter.cpp @@ -4,7 +4,7 @@ #include "event_filter.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const EventFilter& pod) diff --git a/lib/csapi/definitions/event_filter.h b/lib/csapi/definitions/event_filter.h index 9b9b3fa3..b41e2e9e 100644 --- a/lib/csapi/definitions/event_filter.h +++ b/lib/csapi/definitions/event_filter.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -40,4 +40,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, EventFilter& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/public_rooms_response.cpp b/lib/csapi/definitions/public_rooms_response.cpp index d07b1494..b6009718 100644 --- a/lib/csapi/definitions/public_rooms_response.cpp +++ b/lib/csapi/definitions/public_rooms_response.cpp @@ -4,7 +4,7 @@ #include "public_rooms_response.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index e86e306f..1cb3aad5 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -67,4 +67,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PublicRoomsResponse& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/push_condition.cpp b/lib/csapi/definitions/push_condition.cpp index 5bcb845e..343b4f1a 100644 --- a/lib/csapi/definitions/push_condition.cpp +++ b/lib/csapi/definitions/push_condition.cpp @@ -4,7 +4,7 @@ #include "push_condition.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const PushCondition& pod) diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h index 2c17023e..34a183de 100644 --- a/lib/csapi/definitions/push_condition.h +++ b/lib/csapi/definitions/push_condition.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -36,4 +36,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PushCondition& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/push_rule.cpp b/lib/csapi/definitions/push_rule.cpp index fc2be2c7..eae7e446 100644 --- a/lib/csapi/definitions/push_rule.cpp +++ b/lib/csapi/definitions/push_rule.cpp @@ -4,7 +4,7 @@ #include "push_rule.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const PushRule& pod) { diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index fe6eb0e6..e64d6ba8 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -12,7 +12,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -43,4 +43,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PushRule& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/push_ruleset.cpp b/lib/csapi/definitions/push_ruleset.cpp index 6f48d27b..a2db35d9 100644 --- a/lib/csapi/definitions/push_ruleset.cpp +++ b/lib/csapi/definitions/push_ruleset.cpp @@ -4,7 +4,7 @@ #include "push_ruleset.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const PushRuleset& pod) diff --git a/lib/csapi/definitions/push_ruleset.h b/lib/csapi/definitions/push_ruleset.h index f9aedad8..b6b9670e 100644 --- a/lib/csapi/definitions/push_ruleset.h +++ b/lib/csapi/definitions/push_ruleset.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -36,4 +36,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PushRuleset& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/room_event_filter.cpp b/lib/csapi/definitions/room_event_filter.cpp index bd38ebc7..5613d8d2 100644 --- a/lib/csapi/definitions/room_event_filter.cpp +++ b/lib/csapi/definitions/room_event_filter.cpp @@ -4,7 +4,7 @@ #include "room_event_filter.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const RoomEventFilter& pod) diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h index 72bf34d3..ae06a615 100644 --- a/lib/csapi/definitions/room_event_filter.h +++ b/lib/csapi/definitions/room_event_filter.h @@ -8,7 +8,7 @@ #include "csapi/definitions/event_filter.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -35,4 +35,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, RoomEventFilter& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/sync_filter.cpp b/lib/csapi/definitions/sync_filter.cpp index 87274a06..15c4bdc1 100644 --- a/lib/csapi/definitions/sync_filter.cpp +++ b/lib/csapi/definitions/sync_filter.cpp @@ -4,7 +4,7 @@ #include "sync_filter.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const StateFilter& pod) diff --git a/lib/csapi/definitions/sync_filter.h b/lib/csapi/definitions/sync_filter.h index 1d6a845c..9ea39a65 100644 --- a/lib/csapi/definitions/sync_filter.h +++ b/lib/csapi/definitions/sync_filter.h @@ -9,7 +9,7 @@ #include "csapi/definitions/event_filter.h" #include "csapi/definitions/room_event_filter.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -104,4 +104,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, Filter& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/user_identifier.cpp b/lib/csapi/definitions/user_identifier.cpp index 52bb1ae6..9e9b4fe9 100644 --- a/lib/csapi/definitions/user_identifier.cpp +++ b/lib/csapi/definitions/user_identifier.cpp @@ -4,7 +4,7 @@ #include "user_identifier.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const UserIdentifier& pod) diff --git a/lib/csapi/definitions/user_identifier.h b/lib/csapi/definitions/user_identifier.h index 51c47cca..74e6ce2b 100644 --- a/lib/csapi/definitions/user_identifier.h +++ b/lib/csapi/definitions/user_identifier.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -31,4 +31,4 @@ struct JsonObjectConverter static void fillFrom(QJsonObject jo, UserIdentifier& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/full.cpp b/lib/csapi/definitions/wellknown/full.cpp index 34d3bfbe..595db0e5 100644 --- a/lib/csapi/definitions/wellknown/full.cpp +++ b/lib/csapi/definitions/wellknown/full.cpp @@ -4,7 +4,7 @@ #include "full.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const DiscoveryInformation& pod) diff --git a/lib/csapi/definitions/wellknown/full.h b/lib/csapi/definitions/wellknown/full.h index ddc06653..92c8afff 100644 --- a/lib/csapi/definitions/wellknown/full.h +++ b/lib/csapi/definitions/wellknown/full.h @@ -12,7 +12,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -39,4 +39,4 @@ struct JsonObjectConverter static void fillFrom(QJsonObject jo, DiscoveryInformation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/homeserver.cpp b/lib/csapi/definitions/wellknown/homeserver.cpp index f5746ede..7b87aa95 100644 --- a/lib/csapi/definitions/wellknown/homeserver.cpp +++ b/lib/csapi/definitions/wellknown/homeserver.cpp @@ -4,7 +4,7 @@ #include "homeserver.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const HomeserverInformation& pod) diff --git a/lib/csapi/definitions/wellknown/homeserver.h b/lib/csapi/definitions/wellknown/homeserver.h index b73cee17..606df88b 100644 --- a/lib/csapi/definitions/wellknown/homeserver.h +++ b/lib/csapi/definitions/wellknown/homeserver.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -25,4 +25,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, HomeserverInformation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/identity_server.cpp b/lib/csapi/definitions/wellknown/identity_server.cpp index 922d4665..3b2a5720 100644 --- a/lib/csapi/definitions/wellknown/identity_server.cpp +++ b/lib/csapi/definitions/wellknown/identity_server.cpp @@ -4,7 +4,7 @@ #include "identity_server.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const IdentityServerInformation& pod) diff --git a/lib/csapi/definitions/wellknown/identity_server.h b/lib/csapi/definitions/wellknown/identity_server.h index a35644fc..b4304ef7 100644 --- a/lib/csapi/definitions/wellknown/identity_server.h +++ b/lib/csapi/definitions/wellknown/identity_server.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -25,4 +25,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, IdentityServerInformation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index 9135c22d..0889089e 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index 01838c6f..d380a44f 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -13,7 +13,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -145,4 +145,4 @@ public: const Omittable& auth = none); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index 992d1da5..b2689d1e 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0/directory"); diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index f5331db8..7863aa1a 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -93,4 +93,4 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index 936b2430..d233eedb 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index ca06f4b9..755fc662 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -9,7 +9,7 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -71,4 +71,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index 79dd5ea5..b4160ba4 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index 0a5a98ae..5001a492 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -10,7 +10,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -88,4 +88,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index 4ddbe5d0..b60df6f8 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h index b0911ea8..faf315b1 100644 --- a/lib/csapi/inviting.h +++ b/lib/csapi/inviting.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -44,4 +44,4 @@ public: explicit InviteUserJob(const QString& roomId, const QString& userId); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index cb40cb96..2dd617bb 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -29,7 +29,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class JoinRoomByIdJob::Private { @@ -67,7 +67,7 @@ BaseJob::Status JoinRoomByIdJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -91,7 +91,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class JoinRoomJob::Private { diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index a96f323d..cf456da9 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -165,4 +165,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index 1752b865..cd33ad19 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); @@ -50,7 +50,7 @@ BaseJob::Status UploadKeysJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -74,7 +74,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class QueryKeysJob::Private { diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index f69028fd..27867b8c 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -14,7 +14,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -231,4 +231,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index 05c4c581..ce7fcdad 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/kicking.h b/lib/csapi/kicking.h index 9566a9a4..d51edb47 100644 --- a/lib/csapi/kicking.h +++ b/lib/csapi/kicking.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -39,4 +39,4 @@ public: const QString& reason = {}); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index 325b1e04..abf04888 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/leaving.h b/lib/csapi/leaving.h index 2ed6c8e7..280545b0 100644 --- a/lib/csapi/leaving.h +++ b/lib/csapi/leaving.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -73,4 +73,4 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp index 43c948f7..1260499a 100644 --- a/lib/csapi/list_joined_rooms.cpp +++ b/lib/csapi/list_joined_rooms.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/list_joined_rooms.h b/lib/csapi/list_joined_rooms.h index 1b64a004..5dab9dfc 100644 --- a/lib/csapi/list_joined_rooms.h +++ b/lib/csapi/list_joined_rooms.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -43,4 +43,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 4d96dac3..0e065440 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); @@ -108,7 +108,7 @@ BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -121,7 +121,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class QueryPublicRoomsJob::Private { diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index da68416d..e68030ad 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -10,7 +10,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -189,4 +189,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 29ee4ab5..02730ff0 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -26,7 +26,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetLoginFlowsJob::Private { diff --git a/lib/csapi/login.h b/lib/csapi/login.h index 3ab0648f..dc944782 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -13,7 +13,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -143,4 +143,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/logout.cpp b/lib/csapi/logout.cpp index d0bef20e..4b391967 100644 --- a/lib/csapi/logout.cpp +++ b/lib/csapi/logout.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h index c03af180..34d5a441 100644 --- a/lib/csapi/logout.h +++ b/lib/csapi/logout.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -55,4 +55,4 @@ public: static QUrl makeRequestUrl(QUrl baseUrl); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index 3f09bd85..b612ee91 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 03b3d42a..271e1dd9 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -9,7 +9,7 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -80,4 +80,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index 3a05a0b2..da568a0f 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -31,7 +31,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetNotificationsJob::Private { diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index 4170d539..eeec5d4e 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -13,7 +13,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -94,4 +94,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 39ba3b9e..8c00df97 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index 40f1bc40..b2f003e5 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -64,4 +64,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index 6962d363..bc29b682 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index 1fe63c4d..c5cc07f6 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -9,7 +9,7 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -74,4 +74,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index b6e8caf2..0f019026 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index 82c3a300..c5ecb987 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -8,7 +8,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -78,4 +78,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 630452f6..27168f77 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 95d3ec97..54dc53aa 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -164,4 +164,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index 41a0cffe..90877a95 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -43,7 +43,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetPushersJob::Private { @@ -79,7 +79,7 @@ BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -92,7 +92,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient static const auto PostPusherJobName = QStringLiteral("PostPusherJob"); diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h index a909b9a0..65f8aa15 100644 --- a/lib/csapi/pusher.h +++ b/lib/csapi/pusher.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -169,4 +169,4 @@ public: Omittable append = none); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index 5842369f..eae5445f 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/pushrules.h b/lib/csapi/pushrules.h index 9074addb..cb94fe7b 100644 --- a/lib/csapi/pushrules.h +++ b/lib/csapi/pushrules.h @@ -14,7 +14,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -297,4 +297,4 @@ public: const QStringList& actions); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index 5ea45f88..a07d09ce 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/read_markers.h b/lib/csapi/read_markers.h index e1fbc263..35c428b2 100644 --- a/lib/csapi/read_markers.h +++ b/lib/csapi/read_markers.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -34,4 +34,4 @@ public: const QString& mRead = {}); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index 28d7032f..f9a45912 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h index bb037c08..376d4006 100644 --- a/lib/csapi/receipts.h +++ b/lib/csapi/receipts.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -37,4 +37,4 @@ public: const QJsonObject& receipt = {}); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index f944cdd4..d2dbe19b 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index c75421cb..42022930 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -53,4 +53,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 52b4098d..270011e1 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 40f1caa6..89aecb80 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -11,7 +11,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -480,4 +480,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index eb62cd12..352f52c9 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/report_content.h b/lib/csapi/report_content.h index c545d800..c86a4301 100644 --- a/lib/csapi/report_content.h +++ b/lib/csapi/report_content.h @@ -8,7 +8,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -36,4 +36,4 @@ public: int score, const QString& reason); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index a29dd99a..5e970d65 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index aa2efd79..110fc83b 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -62,4 +62,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index ef4afcd0..bfcd6e17 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index 6ddd5594..80619d63 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -126,4 +126,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp index a72304d1..1d6006ef 100644 --- a/lib/csapi/room_upgrades.cpp +++ b/lib/csapi/room_upgrades.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/room_upgrades.h b/lib/csapi/room_upgrades.h index 94520aca..5f9262f1 100644 --- a/lib/csapi/room_upgrades.h +++ b/lib/csapi/room_upgrades.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -41,4 +41,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 280e8d59..5bfbe44d 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); @@ -168,7 +168,7 @@ BaseJob::Status GetMembersByRoomJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -182,7 +182,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetJoinedMembersByRoomJob::Private { diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 29d7808e..1020fdb1 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -12,7 +12,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -269,4 +269,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp index ee1fa70c..9619f340 100644 --- a/lib/csapi/search.cpp +++ b/lib/csapi/search.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -144,7 +144,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class SearchJob::Private { diff --git a/lib/csapi/search.h b/lib/csapi/search.h index f965a72a..079ac8e9 100644 --- a/lib/csapi/search.h +++ b/lib/csapi/search.h @@ -16,7 +16,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -200,4 +200,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index b1dc3674..c2cc81cf 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/sso_login_redirect.h b/lib/csapi/sso_login_redirect.h index af9e7780..b932a15e 100644 --- a/lib/csapi/sso_login_redirect.h +++ b/lib/csapi/sso_login_redirect.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -37,4 +37,4 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& redirectUrl); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/tags.cpp b/lib/csapi/tags.cpp index 13c933e5..3df38074 100644 --- a/lib/csapi/tags.cpp +++ b/lib/csapi/tags.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -26,7 +26,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetRoomTagsJob::Private { diff --git a/lib/csapi/tags.h b/lib/csapi/tags.h index dc20cd3d..8ddebd6b 100644 --- a/lib/csapi/tags.h +++ b/lib/csapi/tags.h @@ -11,7 +11,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -123,4 +123,4 @@ public: const QString& roomId, const QString& tag); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index 986ead01..678f6b3c 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/third_party_lookup.h b/lib/csapi/third_party_lookup.h index d25c1cf3..63607549 100644 --- a/lib/csapi/third_party_lookup.h +++ b/lib/csapi/third_party_lookup.h @@ -15,7 +15,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -253,4 +253,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index 9fe702aa..7e401163 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h index 36622c94..bd4c6896 100644 --- a/lib/csapi/third_party_membership.h +++ b/lib/csapi/third_party_membership.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -74,4 +74,4 @@ public: const QString& medium, const QString& address); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index 3fb17109..3f6e8097 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h index e0bbbe28..14445439 100644 --- a/lib/csapi/to_device.h +++ b/lib/csapi/to_device.h @@ -9,7 +9,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -39,4 +39,4 @@ public: const QHash>& messages = {}); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index 03499c76..064ebe39 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/typing.h b/lib/csapi/typing.h index 0c3f75a8..350c209d 100644 --- a/lib/csapi/typing.h +++ b/lib/csapi/typing.h @@ -8,7 +8,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -38,4 +38,4 @@ public: bool typing, Omittable timeout = none); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 39b05a77..77c297dd 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -28,7 +28,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class SearchUserDirectoryJob::Private { diff --git a/lib/csapi/users.h b/lib/csapi/users.h index 2e86c009..d9a16a9d 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -80,4 +80,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/versions.cpp b/lib/csapi/versions.cpp index 1d66b94f..9607a1b6 100644 --- a/lib/csapi/versions.cpp +++ b/lib/csapi/versions.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client"); diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h index 513e7f27..aa8cbac6 100644 --- a/lib/csapi/versions.h +++ b/lib/csapi/versions.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -70,4 +70,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/voip.cpp b/lib/csapi/voip.cpp index 0e83c915..c95afe16 100644 --- a/lib/csapi/voip.cpp +++ b/lib/csapi/voip.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/voip.h b/lib/csapi/voip.h index ab34dcad..38abfa27 100644 --- a/lib/csapi/voip.h +++ b/lib/csapi/voip.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -46,4 +46,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/wellknown.cpp b/lib/csapi/wellknown.cpp index c2bd7822..9a52a2a5 100644 --- a/lib/csapi/wellknown.cpp +++ b/lib/csapi/wellknown.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/.well-known"); diff --git a/lib/csapi/wellknown.h b/lib/csapi/wellknown.h index 66917806..bce67d00 100644 --- a/lib/csapi/wellknown.h +++ b/lib/csapi/wellknown.h @@ -10,7 +10,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -54,4 +54,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp index 2ca9c435..fb7f54dc 100644 --- a/lib/csapi/whoami.cpp +++ b/lib/csapi/whoami.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index e62b7dad..bbbb3899 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -50,4 +50,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/{{base}}.cpp.mustache b/lib/csapi/{{base}}.cpp.mustache index 8ebac6ef..6cbd1b65 100644 --- a/lib/csapi/{{base}}.cpp.mustache +++ b/lib/csapi/{{base}}.cpp.mustache @@ -8,7 +8,7 @@ {{/producesNonJson?}} #include {{/operations}} -using namespace QMatrixClient; +using namespace Quotient; {{#models.model}} {{#in?}} void JsonObjectConverter<{{qualifiedName}}>::dumpTo(QJsonObject& jo, const {{qualifiedName}}& pod) @@ -38,7 +38,7 @@ void JsonObjectConverter<{{qualifiedName}}>::fillFrom({{>maybeCrefJsonObject}} j static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); {{#operation}}{{#models}} // Converters -namespace QMatrixClient +namespace Quotient { {{#model}} template <> struct JsonObjectConverter<{{qualifiedName}}> diff --git a/lib/csapi/{{base}}.h.mustache b/lib/csapi/{{base}}.h.mustache index 61380ec6..56044e7d 100644 --- a/lib/csapi/{{base}}.h.mustache +++ b/lib/csapi/{{base}}.h.mustache @@ -8,7 +8,7 @@ {{#imports}} #include {{_}}{{/imports}} -namespace QMatrixClient +namespace Quotient { {{#models}} // Data structures @@ -92,4 +92,4 @@ private: }; {{/ operation}} {{/operations}} -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/e2ee.h b/lib/e2ee.h index c85211be..5a9b83c5 100644 --- a/lib/e2ee.h +++ b/lib/e2ee.h @@ -4,7 +4,7 @@ #include -namespace QMatrixClient { +namespace Quotient { static const auto CiphertextKeyL = "ciphertext"_ls; static const auto SenderKeyKeyL = "sender_key"_ls; static const auto DeviceIdKeyL = "device_id"_ls; @@ -28,4 +28,4 @@ static const auto MegolmV1AesSha2AlgoKey = QStringLiteral("m.megolm.v1.aes-sha2"); static const QStringList SupportedAlgorithms = { OlmV1Curve25519AesSha2AlgoKey, MegolmV1AesSha2AlgoKey }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/encryptionmanager.cpp b/lib/encryptionmanager.cpp index 15723688..22387cf9 100644 --- a/lib/encryptionmanager.cpp +++ b/lib/encryptionmanager.cpp @@ -12,7 +12,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; using namespace QtOlm; using std::move; diff --git a/lib/encryptionmanager.h b/lib/encryptionmanager.h index 79c25a00..b210a85a 100644 --- a/lib/encryptionmanager.h +++ b/lib/encryptionmanager.h @@ -9,7 +9,7 @@ namespace QtOlm { class Account; } -namespace QMatrixClient { +namespace Quotient { class Connection; class EncryptionManager : public QObject { @@ -35,4 +35,4 @@ private: std::unique_ptr d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/eventitem.cpp b/lib/eventitem.cpp index de0a5c9f..2e2b11c0 100644 --- a/lib/eventitem.cpp +++ b/lib/eventitem.cpp @@ -21,7 +21,7 @@ #include "events/roomavatarevent.h" #include "events/roommessageevent.h" -using namespace QMatrixClient; +using namespace Quotient; void PendingEventItem::setFileUploaded(const QUrl& remoteUrl) { diff --git a/lib/eventitem.h b/lib/eventitem.h index 68d1ae06..3a7061d3 100644 --- a/lib/eventitem.h +++ b/lib/eventitem.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { class StateEventBase; class EventStatus { @@ -153,5 +153,5 @@ inline QDebug& operator<<(QDebug& d, const TimelineItem& ti) d.nospace() << "(" << ti.index() << "|" << ti->id() << ")"; return d; } -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::EventStatus) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::EventStatus) diff --git a/lib/events/accountdataevents.h b/lib/events/accountdataevents.h index 3f519668..600fa5be 100644 --- a/lib/events/accountdataevents.h +++ b/lib/events/accountdataevents.h @@ -24,7 +24,7 @@ #include "event.h" #include "eventcontent.h" -namespace QMatrixClient { +namespace Quotient { constexpr const char* FavouriteTag = "m.favourite"; constexpr const char* LowPriorityTag = "m.lowpriority"; @@ -93,4 +93,4 @@ DEFINE_SIMPLE_EVENT(IgnoredUsersEvent, "m.ignored_user_list", QSet, DEFINE_EVENTTYPE_ALIAS(Tag, TagEvent) DEFINE_EVENTTYPE_ALIAS(ReadMarker, ReadMarkerEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/callanswerevent.cpp b/lib/events/callanswerevent.cpp index 7ab4a6fb..d6622b30 100644 --- a/lib/events/callanswerevent.cpp +++ b/lib/events/callanswerevent.cpp @@ -44,7 +44,7 @@ m.call.answer } */ -using namespace QMatrixClient; +using namespace Quotient; CallAnswerEvent::CallAnswerEvent(const QJsonObject& obj) : CallEventBase(typeId(), obj) diff --git a/lib/events/callanswerevent.h b/lib/events/callanswerevent.h index 052f732d..e01b39db 100644 --- a/lib/events/callanswerevent.h +++ b/lib/events/callanswerevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class CallAnswerEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.answer", CallAnswerEvent) @@ -43,4 +43,4 @@ public: REGISTER_EVENT_TYPE(CallAnswerEvent) DEFINE_EVENTTYPE_ALIAS(CallAnswer, CallAnswerEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/callcandidatesevent.h b/lib/events/callcandidatesevent.h index 2a915a43..3d13ba8a 100644 --- a/lib/events/callcandidatesevent.h +++ b/lib/events/callcandidatesevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class CallCandidatesEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.candidates", CallCandidatesEvent) @@ -43,4 +43,4 @@ public: REGISTER_EVENT_TYPE(CallCandidatesEvent) DEFINE_EVENTTYPE_ALIAS(CallCandidates, CallCandidatesEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/callhangupevent.cpp b/lib/events/callhangupevent.cpp index 2a4fd3da..d41849c3 100644 --- a/lib/events/callhangupevent.cpp +++ b/lib/events/callhangupevent.cpp @@ -39,7 +39,7 @@ m.call.hangup } */ -using namespace QMatrixClient; +using namespace Quotient; CallHangupEvent::CallHangupEvent(const QJsonObject& obj) : CallEventBase(typeId(), obj) diff --git a/lib/events/callhangupevent.h b/lib/events/callhangupevent.h index 97fa2f52..d23e29db 100644 --- a/lib/events/callhangupevent.h +++ b/lib/events/callhangupevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class CallHangupEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.hangup", CallHangupEvent) @@ -31,4 +31,4 @@ public: REGISTER_EVENT_TYPE(CallHangupEvent) DEFINE_EVENTTYPE_ALIAS(CallHangup, CallHangupEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/callinviteevent.cpp b/lib/events/callinviteevent.cpp index f565fc3e..54faac8d 100644 --- a/lib/events/callinviteevent.cpp +++ b/lib/events/callinviteevent.cpp @@ -44,7 +44,7 @@ m.call.invite } */ -using namespace QMatrixClient; +using namespace Quotient; CallInviteEvent::CallInviteEvent(const QJsonObject& obj) : CallEventBase(typeId(), obj) diff --git a/lib/events/callinviteevent.h b/lib/events/callinviteevent.h index 9b9d0ae5..3e39e0ba 100644 --- a/lib/events/callinviteevent.h +++ b/lib/events/callinviteevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class CallInviteEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.invite", CallInviteEvent) @@ -42,4 +42,4 @@ public: REGISTER_EVENT_TYPE(CallInviteEvent) DEFINE_EVENTTYPE_ALIAS(CallInvite, CallInviteEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/directchatevent.cpp b/lib/events/directchatevent.cpp index 4ba098c2..b4027e16 100644 --- a/lib/events/directchatevent.cpp +++ b/lib/events/directchatevent.cpp @@ -20,7 +20,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; QMultiHash DirectChatEvent::usersToDirectChats() const { diff --git a/lib/events/directchatevent.h b/lib/events/directchatevent.h index 94857a93..b4981f2e 100644 --- a/lib/events/directchatevent.h +++ b/lib/events/directchatevent.h @@ -20,7 +20,7 @@ #include "event.h" -namespace QMatrixClient { +namespace Quotient { class DirectChatEvent : public Event { public: DEFINE_EVENT_TYPEID("m.direct", DirectChatEvent) @@ -31,4 +31,4 @@ public: }; REGISTER_EVENT_TYPE(DirectChatEvent) DEFINE_EVENTTYPE_ALIAS(DirectChat, DirectChatEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/encryptedevent.h b/lib/events/encryptedevent.h index 67298a27..235b2aa4 100644 --- a/lib/events/encryptedevent.h +++ b/lib/events/encryptedevent.h @@ -3,7 +3,7 @@ #include "e2ee.h" #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class Room; /* * While the specification states: @@ -63,4 +63,4 @@ public: }; REGISTER_EVENT_TYPE(EncryptedEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/encryptionevent.cpp b/lib/events/encryptionevent.cpp index 0c732a51..945e6696 100644 --- a/lib/events/encryptionevent.cpp +++ b/lib/events/encryptionevent.cpp @@ -12,10 +12,10 @@ #include static const std::array encryptionStrings = { - { QMatrixClient::MegolmV1AesSha2AlgoKey } + { Quotient::MegolmV1AesSha2AlgoKey } }; -namespace QMatrixClient { +namespace Quotient { template <> struct JsonConverter { static EncryptionType load(const QJsonValue& jv) @@ -32,7 +32,7 @@ struct JsonConverter { }; } // namespace QMatrixClient -using namespace QMatrixClient; +using namespace Quotient; EncryptionEventContent::EncryptionEventContent(const QJsonObject& json) : encryption(fromJson(json["algorithm"_ls])) diff --git a/lib/events/encryptionevent.h b/lib/events/encryptionevent.h index debabcae..68e41719 100644 --- a/lib/events/encryptionevent.h +++ b/lib/events/encryptionevent.h @@ -21,7 +21,7 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class EncryptionEventContent : public EventContent::Base { public: enum EncryptionType : size_t { MegolmV1AesSha2 = 0, Undefined }; @@ -71,4 +71,4 @@ private: REGISTER_EVENT_TYPE(EncryptionEvent) DEFINE_EVENTTYPE_ALIAS(Encryption, EncryptionEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/event.cpp b/lib/events/event.cpp index 694254fe..96e33864 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -22,7 +22,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; event_type_t EventTypeRegistry::initializeTypeId(event_mtype_t matrixTypeId) { diff --git a/lib/events/event.h b/lib/events/event.h index 686bd8e0..e96d6897 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -25,7 +25,7 @@ # define USE_EVENTTYPE_ALIAS 1 #endif -namespace QMatrixClient { +namespace Quotient { // === event_ptr_tt<> and type casting facilities === template @@ -292,7 +292,7 @@ using Events = EventsArray; // provide matrixTypeId() and typeId(). #define DEFINE_EVENT_TYPEID(_Id, _Type) \ static constexpr event_mtype_t matrixTypeId() { return _Id; } \ - static auto typeId() { return QMatrixClient::typeId<_Type>(); } \ + static auto typeId() { return Quotient::typeId<_Type>(); } \ // End of macro // This macro should be put after an event class definition (in .h or .cpp) @@ -406,6 +406,6 @@ visit(const BaseEventT& event, FnT1&& visitor1, FnT2&& visitor2, return visit(event, std::forward(visitor2), std::forward(visitors)...); } -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::Event*) -Q_DECLARE_METATYPE(const QMatrixClient::Event*) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::Event*) +Q_DECLARE_METATYPE(const Quotient::Event*) diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp index 814f2787..802d8176 100644 --- a/lib/events/eventcontent.cpp +++ b/lib/events/eventcontent.cpp @@ -23,7 +23,7 @@ #include -using namespace QMatrixClient::EventContent; +using namespace Quotient::EventContent; QJsonObject Base::toJson() const { diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 5c0f92d1..c26cb931 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -26,7 +26,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { namespace EventContent { /** * A base class for all content types that can be stored @@ -275,4 +275,4 @@ namespace EventContent { */ using FileContent = UrlWithThumbnailContent; } // namespace EventContent -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/eventloader.h b/lib/events/eventloader.h index 9e8bb410..ebb96441 100644 --- a/lib/events/eventloader.h +++ b/lib/events/eventloader.h @@ -20,7 +20,7 @@ #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { namespace _impl { template static inline auto loadEvent(const QJsonObject& json, @@ -83,4 +83,4 @@ struct JsonConverter> { return loadEvent(jd.object()); } }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/reactionevent.cpp b/lib/events/reactionevent.cpp index 0a080607..df8910fe 100644 --- a/lib/events/reactionevent.cpp +++ b/lib/events/reactionevent.cpp @@ -20,7 +20,7 @@ using namespace QMatrixClient; -void QMatrixClient::JsonObjectConverter::dumpTo( +void JsonObjectConverter::dumpTo( QJsonObject& jo, const EventRelation& pod) { if (pod.type.isEmpty()) { @@ -33,7 +33,7 @@ void QMatrixClient::JsonObjectConverter::dumpTo( jo.insert(QStringLiteral("key"), pod.key); } -void QMatrixClient::JsonObjectConverter::fillFrom( +void JsonObjectConverter::fillFrom( const QJsonObject& jo, EventRelation& pod) { // The experimental logic for generic relationships (MSC1849) diff --git a/lib/events/reactionevent.h b/lib/events/reactionevent.h index b1e04561..75c6528c 100644 --- a/lib/events/reactionevent.h +++ b/lib/events/reactionevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { struct EventRelation { using reltypeid_t = const char*; @@ -70,4 +70,4 @@ private: }; REGISTER_EVENT_TYPE(ReactionEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/receiptevent.cpp b/lib/events/receiptevent.cpp index 4a54b744..bf050cb2 100644 --- a/lib/events/receiptevent.cpp +++ b/lib/events/receiptevent.cpp @@ -38,7 +38,7 @@ Example of a Receipt Event: #include "converters.h" #include "logging.h" -using namespace QMatrixClient; +using namespace Quotient; ReceiptEvent::ReceiptEvent(const QJsonObject& obj) : Event(typeId(), obj) { diff --git a/lib/events/receiptevent.h b/lib/events/receiptevent.h index c32e0543..71cd5de0 100644 --- a/lib/events/receiptevent.h +++ b/lib/events/receiptevent.h @@ -23,7 +23,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { struct Receipt { QString userId; QDateTime timestamp; @@ -49,4 +49,4 @@ private: }; REGISTER_EVENT_TYPE(ReceiptEvent) DEFINE_EVENTTYPE_ALIAS(Receipt, ReceiptEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/redactionevent.h b/lib/events/redactionevent.h index 3628fb33..eac627d5 100644 --- a/lib/events/redactionevent.h +++ b/lib/events/redactionevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class RedactionEvent : public RoomEvent { public: DEFINE_EVENT_TYPEID("m.room.redaction", RedactionEvent) @@ -36,4 +36,4 @@ public: }; REGISTER_EVENT_TYPE(RedactionEvent) DEFINE_EVENTTYPE_ALIAS(Redaction, RedactionEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roomavatarevent.h b/lib/events/roomavatarevent.h index 16aeb070..109f4014 100644 --- a/lib/events/roomavatarevent.h +++ b/lib/events/roomavatarevent.h @@ -21,7 +21,7 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class RoomAvatarEvent : public StateEvent { // It's a bit of an overkill to use a full-fledged ImageContent // because in reality m.room.avatar usually only has a single URL, @@ -35,4 +35,4 @@ public: }; REGISTER_EVENT_TYPE(RoomAvatarEvent) DEFINE_EVENTTYPE_ALIAS(RoomAvatar, RoomAvatarEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roomcreateevent.cpp b/lib/events/roomcreateevent.cpp index cb575f24..c72b5bc2 100644 --- a/lib/events/roomcreateevent.cpp +++ b/lib/events/roomcreateevent.cpp @@ -18,7 +18,7 @@ #include "roomcreateevent.h" -using namespace QMatrixClient; +using namespace Quotient; bool RoomCreateEvent::isFederated() const { diff --git a/lib/events/roomcreateevent.h b/lib/events/roomcreateevent.h index c8ba8c40..91aefe9e 100644 --- a/lib/events/roomcreateevent.h +++ b/lib/events/roomcreateevent.h @@ -20,7 +20,7 @@ #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class RoomCreateEvent : public StateEventBase { public: DEFINE_EVENT_TYPEID("m.room.create", RoomCreateEvent) @@ -41,4 +41,4 @@ public: bool isUpgrade() const; }; REGISTER_EVENT_TYPE(RoomCreateEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roomevent.cpp b/lib/events/roomevent.cpp index 543640ca..e19c03ce 100644 --- a/lib/events/roomevent.cpp +++ b/lib/events/roomevent.cpp @@ -22,7 +22,7 @@ #include "logging.h" #include "redactionevent.h" -using namespace QMatrixClient; +using namespace Quotient; [[gnu::unused]] static auto roomEventTypeInitialised = Event::factory_t::chainFactory(); @@ -48,7 +48,7 @@ QString RoomEvent::id() const { return fullJson()[EventIdKeyL].toString(); } QDateTime RoomEvent::timestamp() const { - return QMatrixClient::fromJson(fullJson()["origin_server_ts"_ls]); + return Quotient::fromJson(fullJson()["origin_server_ts"_ls]); } QString RoomEvent::roomId() const diff --git a/lib/events/roomevent.h b/lib/events/roomevent.h index 155d4600..f943bce4 100644 --- a/lib/events/roomevent.h +++ b/lib/events/roomevent.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { class RedactionEvent; /** This class corresponds to m.room.* events */ @@ -102,6 +102,6 @@ public: QString callId() const { return content("call_id"_ls); } int version() const { return content("version"_ls); } }; -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::RoomEvent*) -Q_DECLARE_METATYPE(const QMatrixClient::RoomEvent*) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::RoomEvent*) +Q_DECLARE_METATYPE(const Quotient::RoomEvent*) diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp index 3cbf6685..d0787170 100644 --- a/lib/events/roommemberevent.cpp +++ b/lib/events/roommemberevent.cpp @@ -28,7 +28,7 @@ static const std::array membershipStrings = { QStringLiteral("leave"), QStringLiteral("ban") } }; -namespace QMatrixClient { +namespace Quotient { template <> struct JsonConverter { static MembershipType load(const QJsonValue& jv) @@ -43,9 +43,9 @@ struct JsonConverter { return MembershipType::Undefined; } }; -} // namespace QMatrixClient +} // namespace Quotient -using namespace QMatrixClient; +using namespace Quotient; MemberEventContent::MemberEventContent(const QJsonObject& json) : membership(fromJson(json["membership"_ls])) diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h index 59d59e3a..2a16617a 100644 --- a/lib/events/roommemberevent.h +++ b/lib/events/roommemberevent.h @@ -21,7 +21,7 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class MemberEventContent : public EventContent::Base { public: enum MembershipType : size_t { @@ -107,4 +107,4 @@ public: REGISTER_EVENT_TYPE(RoomMemberEvent) DEFINE_EVENTTYPE_ALIAS(RoomMember, RoomMemberEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roommessageevent.cpp b/lib/events/roommessageevent.cpp index 991931de..09562d65 100644 --- a/lib/events/roommessageevent.cpp +++ b/lib/events/roommessageevent.cpp @@ -25,7 +25,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; using namespace EventContent; using MsgType = RoomMessageEvent::MsgType; @@ -279,7 +279,7 @@ TextContent::TextContent(const QString& text, const QString& contentType, mimeType = QMimeDatabase().mimeTypeForName("text/html"); } -namespace QMatrixClient { +namespace Quotient { // Overload the default fromJson<> logic that defined in converters.h // as we want template <> @@ -295,7 +295,7 @@ Omittable fromJson(const QJsonValue& jv) return RelatesTo { jo.value("rel_type"_ls).toString(), jo.value(EventIdKeyL).toString() }; } -} // namespace QMatrixClient +} // namespace Quotient TextContent::TextContent(const QJsonObject& json) : relatesTo(fromJson>(json[RelatesToKeyL])) diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index c7a5cb47..aa515c71 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -23,7 +23,7 @@ class QFileInfo; -namespace QMatrixClient { +namespace Quotient { namespace MessageEventContent = EventContent; // Back-compatibility /** @@ -217,4 +217,4 @@ namespace EventContent { */ using AudioContent = PlayableContent>; } // namespace EventContent -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roomtombstoneevent.cpp b/lib/events/roomtombstoneevent.cpp index a74bb367..f93eb60d 100644 --- a/lib/events/roomtombstoneevent.cpp +++ b/lib/events/roomtombstoneevent.cpp @@ -18,7 +18,7 @@ #include "roomtombstoneevent.h" -using namespace QMatrixClient; +using namespace Quotient; QString RoomTombstoneEvent::serverMessage() const { diff --git a/lib/events/roomtombstoneevent.h b/lib/events/roomtombstoneevent.h index 95fed998..2c2f0663 100644 --- a/lib/events/roomtombstoneevent.h +++ b/lib/events/roomtombstoneevent.h @@ -20,7 +20,7 @@ #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class RoomTombstoneEvent : public StateEventBase { public: DEFINE_EVENT_TYPEID("m.room.tombstone", RoomTombstoneEvent) @@ -34,4 +34,4 @@ public: QString successorRoomId() const; }; REGISTER_EVENT_TYPE(RoomTombstoneEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index 6dad8020..520f6b4b 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -20,7 +20,7 @@ #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { namespace EventContent { template class SimpleContent { @@ -37,7 +37,7 @@ namespace EventContent { {} QJsonObject toJson() const { - return { { key, QMatrixClient::toJson(value) } }; + return { { key, Quotient::toJson(value) } }; } public: @@ -92,4 +92,4 @@ public: QStringList aliases() const { return content().value; } }; REGISTER_EVENT_TYPE(RoomAliasesEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp index bd228abd..c0bb0794 100644 --- a/lib/events/stateevent.cpp +++ b/lib/events/stateevent.cpp @@ -18,7 +18,7 @@ #include "stateevent.h" -using namespace QMatrixClient; +using namespace Quotient; // Aside from the normal factory to instantiate StateEventBase inheritors // StateEventBase itself can be instantiated if there's a state_key JSON key diff --git a/lib/events/stateevent.h b/lib/events/stateevent.h index 757c94ee..74e36e74 100644 --- a/lib/events/stateevent.h +++ b/lib/events/stateevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { /// Make a minimal correct Matrix state event JSON template @@ -128,12 +128,12 @@ private: ContentT _content; std::unique_ptr> _prev; }; -} // namespace QMatrixClient +} // namespace Quotient namespace std { template <> -struct hash { - size_t operator()(const QMatrixClient::StateEventKey& k) const Q_DECL_NOEXCEPT +struct hash { + size_t operator()(const Quotient::StateEventKey& k) const Q_DECL_NOEXCEPT { return qHash(k); } diff --git a/lib/events/typingevent.cpp b/lib/events/typingevent.cpp index ee3d6b67..0c5fc6ba 100644 --- a/lib/events/typingevent.cpp +++ b/lib/events/typingevent.cpp @@ -20,7 +20,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; TypingEvent::TypingEvent(const QJsonObject& obj) : Event(typeId(), obj) { diff --git a/lib/events/typingevent.h b/lib/events/typingevent.h index c8170865..d659c597 100644 --- a/lib/events/typingevent.h +++ b/lib/events/typingevent.h @@ -20,7 +20,7 @@ #include "event.h" -namespace QMatrixClient { +namespace Quotient { class TypingEvent : public Event { public: DEFINE_EVENT_TYPEID("m.typing", TypingEvent) @@ -34,4 +34,4 @@ private: }; REGISTER_EVENT_TYPE(TypingEvent) DEFINE_EVENTTYPE_ALIAS(Typing, TypingEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/identity/definitions/request_email_validation.cpp b/lib/identity/definitions/request_email_validation.cpp index 131b9488..22cb0072 100644 --- a/lib/identity/definitions/request_email_validation.cpp +++ b/lib/identity/definitions/request_email_validation.cpp @@ -4,7 +4,7 @@ #include "request_email_validation.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const RequestEmailValidation& pod) diff --git a/lib/identity/definitions/request_email_validation.h b/lib/identity/definitions/request_email_validation.h index 2496d7f5..99487073 100644 --- a/lib/identity/definitions/request_email_validation.h +++ b/lib/identity/definitions/request_email_validation.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -39,4 +39,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, RequestEmailValidation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/identity/definitions/request_msisdn_validation.cpp b/lib/identity/definitions/request_msisdn_validation.cpp index 0087d202..6024bf61 100644 --- a/lib/identity/definitions/request_msisdn_validation.cpp +++ b/lib/identity/definitions/request_msisdn_validation.cpp @@ -4,7 +4,7 @@ #include "request_msisdn_validation.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const RequestMsisdnValidation& pod) diff --git a/lib/identity/definitions/request_msisdn_validation.h b/lib/identity/definitions/request_msisdn_validation.h index f8060cfc..ecccf567 100644 --- a/lib/identity/definitions/request_msisdn_validation.h +++ b/lib/identity/definitions/request_msisdn_validation.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -43,4 +43,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, RequestMsisdnValidation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/identity/definitions/sid.cpp b/lib/identity/definitions/sid.cpp index cc6973f2..99fe9b59 100644 --- a/lib/identity/definitions/sid.cpp +++ b/lib/identity/definitions/sid.cpp @@ -4,7 +4,7 @@ #include "sid.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const Sid& pod) { diff --git a/lib/identity/definitions/sid.h b/lib/identity/definitions/sid.h index 752d62bb..0f7ce58a 100644 --- a/lib/identity/definitions/sid.h +++ b/lib/identity/definitions/sid.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -27,4 +27,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, Sid& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index 5615736e..ec6b8375 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -30,7 +30,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; struct NetworkReplyDeleter : public QScopedPointerDeleteLater { static inline void cleanup(QNetworkReply* reply) diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h index c85d2d90..90c20c37 100644 --- a/lib/jobs/basejob.h +++ b/lib/jobs/basejob.h @@ -28,7 +28,7 @@ class QNetworkReply; class QSslError; -namespace QMatrixClient { +namespace Quotient { class ConnectionData; enum class HttpVerb { Get, Put, Post, Delete }; @@ -364,4 +364,4 @@ inline bool isJobRunning(BaseJob* job) { return job && job->error() == BaseJob::Pending; } -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/jobs/downloadfilejob.cpp b/lib/jobs/downloadfilejob.cpp index 9722186c..3a03efde 100644 --- a/lib/jobs/downloadfilejob.cpp +++ b/lib/jobs/downloadfilejob.cpp @@ -4,7 +4,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; class DownloadFileJob::Private { public: diff --git a/lib/jobs/downloadfilejob.h b/lib/jobs/downloadfilejob.h index ebfe5a0d..fa697219 100644 --- a/lib/jobs/downloadfilejob.h +++ b/lib/jobs/downloadfilejob.h @@ -2,7 +2,7 @@ #include "csapi/content-repo.h" -namespace QMatrixClient { +namespace Quotient { class DownloadFileJob : public GetContentJob { public: enum { FileError = BaseJob::UserDefinedError + 1 }; @@ -24,4 +24,4 @@ private: void beforeAbandon(QNetworkReply*) override; Status parseReply(QNetworkReply*) override; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/jobs/mediathumbnailjob.cpp b/lib/jobs/mediathumbnailjob.cpp index db2bbc13..0a346392 100644 --- a/lib/jobs/mediathumbnailjob.cpp +++ b/lib/jobs/mediathumbnailjob.cpp @@ -18,7 +18,7 @@ #include "mediathumbnailjob.h" -using namespace QMatrixClient; +using namespace Quotient; QUrl MediaThumbnailJob::makeRequestUrl(QUrl baseUrl, const QUrl& mxcUri, QSize requestedSize) diff --git a/lib/jobs/mediathumbnailjob.h b/lib/jobs/mediathumbnailjob.h index df0a7f31..75e2e55a 100644 --- a/lib/jobs/mediathumbnailjob.h +++ b/lib/jobs/mediathumbnailjob.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { class MediaThumbnailJob : public GetContentThumbnailJob { public: using GetContentThumbnailJob::makeRequestUrl; @@ -42,4 +42,4 @@ protected: private: QImage _thumbnail; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/jobs/postreadmarkersjob.h b/lib/jobs/postreadmarkersjob.h index cf482a9a..5a4d942c 100644 --- a/lib/jobs/postreadmarkersjob.h +++ b/lib/jobs/postreadmarkersjob.h @@ -22,7 +22,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; class PostReadMarkersJob : public BaseJob { public: diff --git a/lib/jobs/requestdata.cpp b/lib/jobs/requestdata.cpp index 6ad7c007..0c70f085 100644 --- a/lib/jobs/requestdata.cpp +++ b/lib/jobs/requestdata.cpp @@ -6,7 +6,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; auto fromData(const QByteArray& data) { diff --git a/lib/jobs/requestdata.h b/lib/jobs/requestdata.h index 55987a3b..020d5ef2 100644 --- a/lib/jobs/requestdata.h +++ b/lib/jobs/requestdata.h @@ -26,7 +26,7 @@ class QJsonArray; class QJsonDocument; class QIODevice; -namespace QMatrixClient { +namespace Quotient { /** * A simple wrapper that represents the request body. * Provides a unified interface to dump an unstructured byte stream @@ -52,4 +52,6 @@ public: private: std::unique_ptr _source; }; -} // namespace QMatrixClient +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; diff --git a/lib/jobs/syncjob.cpp b/lib/jobs/syncjob.cpp index f660e1b6..cd7709e1 100644 --- a/lib/jobs/syncjob.cpp +++ b/lib/jobs/syncjob.cpp @@ -18,7 +18,7 @@ #include "syncjob.h" -using namespace QMatrixClient; +using namespace Quotient; static size_t jobId = 0; diff --git a/lib/jobs/syncjob.h b/lib/jobs/syncjob.h index 8f925414..df419ba8 100644 --- a/lib/jobs/syncjob.h +++ b/lib/jobs/syncjob.h @@ -22,7 +22,7 @@ #include "../syncdata.h" #include "basejob.h" -namespace QMatrixClient { +namespace Quotient { class SyncJob : public BaseJob { public: explicit SyncJob(const QString& since = {}, const QString& filter = {}, @@ -38,4 +38,4 @@ protected: private: SyncData d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/joinstate.h b/lib/joinstate.h index fcf840ae..718ae3fd 100644 --- a/lib/joinstate.h +++ b/lib/joinstate.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { enum class JoinState : unsigned int { Join = 0x1, Invite = 0x2, @@ -43,5 +43,5 @@ inline const char* toCString(JoinState js) ++index; return JoinStateStrings[index]; } -} // namespace QMatrixClient -Q_DECLARE_OPERATORS_FOR_FLAGS(QMatrixClient::JoinStates) +} // namespace Quotient +Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::JoinStates) diff --git a/lib/logging.h b/lib/logging.h index 24799752..3d13569a 100644 --- a/lib/logging.h +++ b/lib/logging.h @@ -28,7 +28,7 @@ Q_DECLARE_LOGGING_CATEGORY(EPHEMERAL) Q_DECLARE_LOGGING_CATEGORY(JOBS) Q_DECLARE_LOGGING_CATEGORY(SYNCJOB) -namespace QMatrixClient { +namespace Quotient { // QDebug manipulators using QDebugManip = QDebug (*)(QDebug); @@ -75,7 +75,9 @@ inline qint64 profilerMinNsecs() #endif * 1000; } -} // namespace QMatrixClient +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; inline QDebug operator<<(QDebug debug_object, const QElapsedTimer& et) { diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp index 7bff654c..8ee080bf 100644 --- a/lib/networkaccessmanager.cpp +++ b/lib/networkaccessmanager.cpp @@ -21,7 +21,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; class NetworkAccessManager::Private { public: diff --git a/lib/networkaccessmanager.h b/lib/networkaccessmanager.h index dfa388f0..a678b80f 100644 --- a/lib/networkaccessmanager.h +++ b/lib/networkaccessmanager.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { class NetworkAccessManager : public QNetworkAccessManager { Q_OBJECT public: @@ -43,4 +43,4 @@ private: class Private; std::unique_ptr d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/networksettings.cpp b/lib/networksettings.cpp index f5655975..cb071483 100644 --- a/lib/networksettings.cpp +++ b/lib/networksettings.cpp @@ -18,7 +18,7 @@ #include "networksettings.h" -using namespace QMatrixClient; +using namespace Quotient; void NetworkSettings::setupApplicationProxy() const { diff --git a/lib/networksettings.h b/lib/networksettings.h index 75bf726d..a82a44d0 100644 --- a/lib/networksettings.h +++ b/lib/networksettings.h @@ -24,7 +24,7 @@ Q_DECLARE_METATYPE(QNetworkProxy::ProxyType) -namespace QMatrixClient { +namespace Quotient { class NetworkSettings : public SettingsGroup { Q_OBJECT QMC_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType) diff --git a/lib/qt_connection_util.h b/lib/qt_connection_util.h index 94c1ec60..159e7522 100644 --- a/lib/qt_connection_util.h +++ b/lib/qt_connection_util.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { namespace _impl { template inline QMetaObject::Connection @@ -102,4 +102,4 @@ public: private: QObject* subscriber; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/room.cpp b/lib/room.cpp index 52f86616..d8fee5aa 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -71,7 +71,7 @@ #include // QtOlm #include // QtOlm -using namespace QMatrixClient; +using namespace Quotient; using namespace std::placeholders; using std::move; #if !(defined __GLIBCXX__ && __GLIBCXX__ <= 20150123) @@ -1085,7 +1085,7 @@ QUrl Room::fileSource(const QString& id) const QString Room::prettyPrint(const QString& plainText) const { - return QMatrixClient::prettyPrint(plainText); + return Quotient::prettyPrint(plainText); } QList Room::usersTyping() const { return d->usersTyping; } diff --git a/lib/room.h b/lib/room.h index d6fb8a61..8448815d 100644 --- a/lib/room.h +++ b/lib/room.h @@ -35,7 +35,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { class Event; class Avatar; class SyncRoomData; @@ -423,7 +423,7 @@ public: Q_INVOKABLE QUrl fileSource(const QString& id) const; /** Pretty-prints plain text into HTML - * As of now, it's exactly the same as QMatrixClient::prettyPrint(); + * As of now, it's exactly the same as Quotient::prettyPrint(); * in the future, it will also linkify room aliases, mxids etc. * using the room context. */ @@ -668,6 +668,6 @@ public: private: const Room* room; }; -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::FileTransferInfo) -Q_DECLARE_OPERATORS_FOR_FLAGS(QMatrixClient::Room::Changes) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::FileTransferInfo) +Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::Room::Changes) diff --git a/lib/settings.cpp b/lib/settings.cpp index 1278fe33..9c61ab5e 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -4,7 +4,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; QString Settings::legacyOrganizationName {}; QString Settings::legacyApplicationName {}; diff --git a/lib/settings.h b/lib/settings.h index 427f5494..4dcbbea0 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -24,7 +24,7 @@ class QVariant; -namespace QMatrixClient { +namespace Quotient { class Settings : public QSettings { Q_OBJECT public: @@ -148,4 +148,4 @@ public: void setEncryptionAccountPickle(const QByteArray& encryptionAccountPickle); Q_INVOKABLE void clearEncryptionAccountPickle(); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp index 0c39b438..c784cd7d 100644 --- a/lib/syncdata.cpp +++ b/lib/syncdata.cpp @@ -23,7 +23,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; const QString SyncRoomData::UnreadCountKey = QStringLiteral("x-qmatrixclient.unread_count"); @@ -42,7 +42,7 @@ bool RoomSummary::merge(const RoomSummary& other) | heroes.merge(other.heroes); } -QDebug QMatrixClient::operator<<(QDebug dbg, const RoomSummary& rs) +QDebug Quotient::operator<<(QDebug dbg, const RoomSummary& rs) { QDebugStateSaver _(dbg); QStringList sl; diff --git a/lib/syncdata.h b/lib/syncdata.h index ad9902e4..d55438d7 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -22,7 +22,7 @@ #include "events/stateevent.h" -namespace QMatrixClient { +namespace Quotient { /// Room summary, as defined in MSC688 /** * Every member of this structure is an Omittable; as per the MSC, only @@ -111,4 +111,4 @@ private: static QJsonObject loadJson(const QString& fileName); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/user.cpp b/lib/user.cpp index 0705aee7..5dea3942 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -37,7 +37,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; using namespace std::placeholders; using std::move; diff --git a/lib/user.h b/lib/user.h index 779efb34..c9e3dbc1 100644 --- a/lib/user.h +++ b/lib/user.h @@ -23,7 +23,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { class Connection; class Room; class RoomMemberEvent; @@ -160,5 +160,5 @@ private: class Private; QScopedPointer d; }; -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::User*) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::User*) diff --git a/lib/util.cpp b/lib/util.cpp index 1919e811..be9656f8 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -32,7 +32,7 @@ static const auto RegExpOptions = | QRegularExpression::UseUnicodePropertiesOption; // Converts all that looks like a URL into HTML links -void QMatrixClient::linkifyUrls(QString& htmlEscapedText) +void Quotient::linkifyUrls(QString& htmlEscapedText) { // Note: outer parentheses are a part of C++ raw string delimiters, not of // the regex (see http://en.cppreference.com/w/cpp/language/string_literal). @@ -70,7 +70,7 @@ void QMatrixClient::linkifyUrls(QString& htmlEscapedText) QStringLiteral(R"(\1\2)")); } -QString QMatrixClient::sanitized(const QString& plainText) +QString Quotient::sanitized(const QString& plainText) { auto text = plainText; text.remove(QChar(0x202e)); // RLO @@ -79,7 +79,7 @@ QString QMatrixClient::sanitized(const QString& plainText) return text; } -QString QMatrixClient::prettyPrint(const QString& plainText) +QString Quotient::prettyPrint(const QString& plainText) { auto pt = plainText.toHtmlEscaped(); linkifyUrls(pt); @@ -88,7 +88,7 @@ QString QMatrixClient::prettyPrint(const QString& plainText) + QStringLiteral(""); } -QString QMatrixClient::cacheLocation(const QString& dirName) +QString Quotient::cacheLocation(const QString& dirName) { const QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) % '/' @@ -99,7 +99,7 @@ QString QMatrixClient::cacheLocation(const QString& dirName) return cachePath; } -qreal QMatrixClient::stringToHueF(const QString& string) +qreal Quotient::stringToHueF(const QString& string) { Q_ASSERT(!string.isEmpty()); QByteArray hash = QCryptographicHash::hash(string.toUtf8(), @@ -118,7 +118,7 @@ static const auto ServerPartRegEx = QStringLiteral( "(?::(\\d{1,5}))?" // Optional port ); -QString QMatrixClient::serverPart(const QString& mxId) +QString Quotient::serverPart(const QString& mxId) { static QString re = "^[@!#$+].+?:(" // Localpart and colon % ServerPartRegEx % ")$"; @@ -135,7 +135,7 @@ QString QMatrixClient::serverPart(const QString& mxId) # pragma clang diagnostic push # pragma ide diagnostic ignored "OCSimplifyInspection" #endif -using namespace QMatrixClient; +using namespace Quotient; int f(); static_assert(std::is_same, int>::value, diff --git a/lib/util.h b/lib/util.h index d055fa46..d94c7321 100644 --- a/lib/util.h +++ b/lib/util.h @@ -63,7 +63,7 @@ static void qAsConst(const T&&) Q_DECL_EQ_DELETE; # define BROKEN_INITIALIZER_LISTS #endif -namespace QMatrixClient { +namespace Quotient { // The below enables pretty-printing of enums in logs #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) # define REGISTER_ENUM(EnumName) Q_ENUM(EnumName) @@ -330,4 +330,6 @@ qreal stringToHueF(const QString& string); /** Extract the serverpart from MXID */ QString serverPart(const QString& mxId); -} // namespace QMatrixClient +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; \ No newline at end of file -- cgit v1.2.3 From 0c425aedbf3729941e40b1606a7c54169b84cf97 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 11 Aug 2019 09:31:59 +0900 Subject: Cleanup [skip ci] --- .appveyor.yml | 2 +- lib/events/accountdataevents.h | 2 +- lib/events/encryptedevent.cpp | 2 +- lib/events/encryptionevent.cpp | 2 +- lib/events/reactionevent.cpp | 2 +- lib/networksettings.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/events') diff --git a/.appveyor.yml b/.appveyor.yml index f596b856..76f6b70f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -13,7 +13,7 @@ environment: init: - call "%QTDIR%\bin\qtenv2.bat" - set PATH=C:\Qt\Tools\QtCreator\bin;%PATH% -- call "%VCVARS%" %platform% +- call "%VCVARS%" %PLATFORM% - cd /D "%APPVEYOR_BUILD_FOLDER%" before_build: diff --git a/lib/events/accountdataevents.h b/lib/events/accountdataevents.h index 600fa5be..68392a32 100644 --- a/lib/events/accountdataevents.h +++ b/lib/events/accountdataevents.h @@ -48,7 +48,7 @@ struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, TagRecord& rec) { // Parse a float both from JSON double and JSON string because - // libqmatrixclient previously used to use strings to store order. + // the library previously used to use strings to store order. const auto orderJv = jo.value("order"_ls); if (orderJv.isDouble()) rec.order = fromJson(orderJv); diff --git a/lib/events/encryptedevent.cpp b/lib/events/encryptedevent.cpp index dac245fa..b5cedc69 100644 --- a/lib/events/encryptedevent.cpp +++ b/lib/events/encryptedevent.cpp @@ -2,7 +2,7 @@ #include "room.h" -using namespace QMatrixClient; +using namespace Quotient; using namespace QtOlm; EncryptedEvent::EncryptedEvent(const QJsonObject& ciphertext, diff --git a/lib/events/encryptionevent.cpp b/lib/events/encryptionevent.cpp index 945e6696..073303b0 100644 --- a/lib/events/encryptionevent.cpp +++ b/lib/events/encryptionevent.cpp @@ -30,7 +30,7 @@ struct JsonConverter { return EncryptionType::Undefined; } }; -} // namespace QMatrixClient +} // namespace Quotient using namespace Quotient; diff --git a/lib/events/reactionevent.cpp b/lib/events/reactionevent.cpp index df8910fe..003c8ead 100644 --- a/lib/events/reactionevent.cpp +++ b/lib/events/reactionevent.cpp @@ -18,7 +18,7 @@ #include "reactionevent.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const EventRelation& pod) diff --git a/lib/networksettings.h b/lib/networksettings.h index a82a44d0..a6a13f93 100644 --- a/lib/networksettings.h +++ b/lib/networksettings.h @@ -40,4 +40,4 @@ public: Q_INVOKABLE void setupApplicationProxy() const; }; -} // namespace QMatrixClient +} // namespace Quotient -- cgit v1.2.3 From 9ce16ef3123d5e63b931cafefb7dba4e894fc82b Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 11 Aug 2019 13:18:40 +0900 Subject: Drop EventType namespace and DEFINE_EVENTTYPE_ALIAS macro They've been deprecated for almost a year by now. --- lib/events/accountdataevents.h | 3 --- lib/events/callanswerevent.h | 1 - lib/events/callcandidatesevent.h | 1 - lib/events/callhangupevent.h | 1 - lib/events/callinviteevent.h | 1 - lib/events/directchatevent.h | 1 - lib/events/encryptionevent.h | 1 - lib/events/event.h | 22 ---------------------- lib/events/receiptevent.h | 1 - lib/events/redactionevent.h | 1 - lib/events/roomavatarevent.h | 1 - lib/events/roommemberevent.h | 1 - lib/events/roommessageevent.h | 1 - lib/events/simplestateevents.h | 4 ---- lib/events/typingevent.h | 1 - 15 files changed, 41 deletions(-) (limited to 'lib/events') diff --git a/lib/events/accountdataevents.h b/lib/events/accountdataevents.h index 68392a32..a8df08a5 100644 --- a/lib/events/accountdataevents.h +++ b/lib/events/accountdataevents.h @@ -90,7 +90,4 @@ DEFINE_SIMPLE_EVENT(TagEvent, "m.tag", TagsMap, tags) DEFINE_SIMPLE_EVENT(ReadMarkerEvent, "m.fully_read", QString, event_id) DEFINE_SIMPLE_EVENT(IgnoredUsersEvent, "m.ignored_user_list", QSet, ignored_users) - -DEFINE_EVENTTYPE_ALIAS(Tag, TagEvent) -DEFINE_EVENTTYPE_ALIAS(ReadMarker, ReadMarkerEvent) } // namespace Quotient diff --git a/lib/events/callanswerevent.h b/lib/events/callanswerevent.h index e01b39db..2709882b 100644 --- a/lib/events/callanswerevent.h +++ b/lib/events/callanswerevent.h @@ -42,5 +42,4 @@ public: }; REGISTER_EVENT_TYPE(CallAnswerEvent) -DEFINE_EVENTTYPE_ALIAS(CallAnswer, CallAnswerEvent) } // namespace Quotient diff --git a/lib/events/callcandidatesevent.h b/lib/events/callcandidatesevent.h index 3d13ba8a..e224f048 100644 --- a/lib/events/callcandidatesevent.h +++ b/lib/events/callcandidatesevent.h @@ -42,5 +42,4 @@ public: }; REGISTER_EVENT_TYPE(CallCandidatesEvent) -DEFINE_EVENTTYPE_ALIAS(CallCandidates, CallCandidatesEvent) } // namespace Quotient diff --git a/lib/events/callhangupevent.h b/lib/events/callhangupevent.h index d23e29db..5d73fb62 100644 --- a/lib/events/callhangupevent.h +++ b/lib/events/callhangupevent.h @@ -30,5 +30,4 @@ public: }; REGISTER_EVENT_TYPE(CallHangupEvent) -DEFINE_EVENTTYPE_ALIAS(CallHangup, CallHangupEvent) } // namespace Quotient diff --git a/lib/events/callinviteevent.h b/lib/events/callinviteevent.h index 3e39e0ba..b067a492 100644 --- a/lib/events/callinviteevent.h +++ b/lib/events/callinviteevent.h @@ -41,5 +41,4 @@ public: }; REGISTER_EVENT_TYPE(CallInviteEvent) -DEFINE_EVENTTYPE_ALIAS(CallInvite, CallInviteEvent) } // namespace Quotient diff --git a/lib/events/directchatevent.h b/lib/events/directchatevent.h index b4981f2e..bb091c5c 100644 --- a/lib/events/directchatevent.h +++ b/lib/events/directchatevent.h @@ -30,5 +30,4 @@ public: QMultiHash usersToDirectChats() const; }; REGISTER_EVENT_TYPE(DirectChatEvent) -DEFINE_EVENTTYPE_ALIAS(DirectChat, DirectChatEvent) } // namespace Quotient diff --git a/lib/events/encryptionevent.h b/lib/events/encryptionevent.h index 68e41719..7bbcc418 100644 --- a/lib/events/encryptionevent.h +++ b/lib/events/encryptionevent.h @@ -70,5 +70,4 @@ private: }; REGISTER_EVENT_TYPE(EncryptionEvent) -DEFINE_EVENTTYPE_ALIAS(Encryption, EncryptionEvent) } // namespace Quotient diff --git a/lib/events/event.h b/lib/events/event.h index e96d6897..d9c8e088 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -305,28 +305,6 @@ using Events = EventsArray; } \ // End of macro -#ifdef USE_EVENTTYPE_ALIAS -namespace EventType { - inline event_type_t logEventType(event_type_t id, const char* idName) - { - qDebug(EVENTS) << "Using id" << id << "for" << idName; - return id; - } -} // namespace EventType - -// This macro provides constants in EventType:: namespace for -// back-compatibility with libQMatrixClient 0.3 event type system. -# define DEFINE_EVENTTYPE_ALIAS(_Id, _Type) \ - namespace EventType { \ - [[deprecated("Use is<>(), eventCast<>() or " \ - "visit<>()")]] static const auto _Id = \ - logEventType(typeId<_Type>(), #_Id); \ - } \ - // End of macro -#else -# define DEFINE_EVENTTYPE_ALIAS(_Id, _Type) // Nothing -#endif - // === is<>(), eventCast<>() and visit<>() === template diff --git a/lib/events/receiptevent.h b/lib/events/receiptevent.h index 71cd5de0..dd54a476 100644 --- a/lib/events/receiptevent.h +++ b/lib/events/receiptevent.h @@ -48,5 +48,4 @@ private: EventsWithReceipts _eventsWithReceipts; }; REGISTER_EVENT_TYPE(ReceiptEvent) -DEFINE_EVENTTYPE_ALIAS(Receipt, ReceiptEvent) } // namespace Quotient diff --git a/lib/events/redactionevent.h b/lib/events/redactionevent.h index eac627d5..3b3af18e 100644 --- a/lib/events/redactionevent.h +++ b/lib/events/redactionevent.h @@ -35,5 +35,4 @@ public: QString reason() const { return contentJson()["reason"_ls].toString(); } }; REGISTER_EVENT_TYPE(RedactionEvent) -DEFINE_EVENTTYPE_ALIAS(Redaction, RedactionEvent) } // namespace Quotient diff --git a/lib/events/roomavatarevent.h b/lib/events/roomavatarevent.h index 109f4014..4013773c 100644 --- a/lib/events/roomavatarevent.h +++ b/lib/events/roomavatarevent.h @@ -34,5 +34,4 @@ public: QUrl url() const { return content().url; } }; REGISTER_EVENT_TYPE(RoomAvatarEvent) -DEFINE_EVENTTYPE_ALIAS(RoomAvatar, RoomAvatarEvent) } // namespace Quotient diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h index 2a16617a..43aaa8be 100644 --- a/lib/events/roommemberevent.h +++ b/lib/events/roommemberevent.h @@ -106,5 +106,4 @@ public: }; REGISTER_EVENT_TYPE(RoomMemberEvent) -DEFINE_EVENTTYPE_ALIAS(RoomMember, RoomMemberEvent) } // namespace Quotient diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index aa515c71..d0dbbfb3 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -90,7 +90,6 @@ private: REGISTER_ENUM(MsgType) }; REGISTER_EVENT_TYPE(RoomMessageEvent) -DEFINE_EVENTTYPE_ALIAS(RoomMessage, RoomMessageEvent) using MessageEventType = RoomMessageEvent::MsgType; namespace EventContent { diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index 520f6b4b..eb1d2f7a 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -69,13 +69,9 @@ namespace EventContent { // End of macro DEFINE_SIMPLE_STATE_EVENT(RoomNameEvent, "m.room.name", QString, name) -DEFINE_EVENTTYPE_ALIAS(RoomName, RoomNameEvent) DEFINE_SIMPLE_STATE_EVENT(RoomCanonicalAliasEvent, "m.room.canonical_alias", QString, alias) -DEFINE_EVENTTYPE_ALIAS(RoomCanonicalAlias, RoomCanonicalAliasEvent) DEFINE_SIMPLE_STATE_EVENT(RoomTopicEvent, "m.room.topic", QString, topic) -DEFINE_EVENTTYPE_ALIAS(RoomTopic, RoomTopicEvent) -DEFINE_EVENTTYPE_ALIAS(RoomEncryption, EncryptionEvent) class RoomAliasesEvent : public StateEvent> { diff --git a/lib/events/typingevent.h b/lib/events/typingevent.h index d659c597..1cf4e69d 100644 --- a/lib/events/typingevent.h +++ b/lib/events/typingevent.h @@ -33,5 +33,4 @@ private: QStringList _users; }; REGISTER_EVENT_TYPE(TypingEvent) -DEFINE_EVENTTYPE_ALIAS(Typing, TypingEvent) } // namespace Quotient -- cgit v1.2.3 From e9ae0d5eaac12a276ea352f1e633fb22cdd46828 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 11 Aug 2019 17:01:41 +0900 Subject: Now that we're C++17, remove old compatibility cruft --- lib/events/encryptionevent.h | 2 +- lib/events/event.h | 23 ++++++++------- lib/events/roommemberevent.h | 2 +- lib/events/roommessageevent.h | 2 +- lib/joinstate.h | 2 +- lib/room.cpp | 10 ------- lib/syncdata.cpp | 2 +- lib/util.h | 65 +++---------------------------------------- 8 files changed, 20 insertions(+), 88 deletions(-) (limited to 'lib/events') diff --git a/lib/events/encryptionevent.h b/lib/events/encryptionevent.h index 7bbcc418..cbd3ba4a 100644 --- a/lib/events/encryptionevent.h +++ b/lib/events/encryptionevent.h @@ -66,7 +66,7 @@ public: int rotationPeriodMsgs() const { return content().rotationPeriodMsgs; } private: - REGISTER_ENUM(EncryptionType) + Q_ENUM(EncryptionType) }; REGISTER_EVENT_TYPE(EncryptionEvent) diff --git a/lib/events/event.h b/lib/events/event.h index d9c8e088..25362786 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -47,11 +47,10 @@ inline TargetEventT* weakPtrCast(const event_ptr_tt& ptr) /// Re-wrap a smart pointer to base into a smart pointer to derived template -[[deprecated("Consider using eventCast() or visit() " - "instead")]] inline event_ptr_tt -ptrCast(event_ptr_tt&& ptr) +[[deprecated("Consider using eventCast() or visit() instead")]] +inline event_ptr_tt ptrCast(event_ptr_tt&& ptr) { - return unique_ptr_cast(ptr); + return std::unique_ptr(static_cast(ptr.release())); } // === Standard Matrix key names and basicEventJson() === @@ -290,19 +289,19 @@ using Events = EventsArray; // This macro should be used in a public section of an event class to // provide matrixTypeId() and typeId(). -#define DEFINE_EVENT_TYPEID(_Id, _Type) \ - static constexpr event_mtype_t matrixTypeId() { return _Id; } \ - static auto typeId() { return Quotient::typeId<_Type>(); } \ +#define DEFINE_EVENT_TYPEID(_Id, _Type) \ + static constexpr event_mtype_t matrixTypeId() { return _Id; } \ + static auto typeId() { return Quotient::typeId<_Type>(); } \ // End of macro // This macro should be put after an event class definition (in .h or .cpp) // to enable its deserialisation from a /sync and other // polymorphic event arrays -#define REGISTER_EVENT_TYPE(_Type) \ - namespace { \ - [[gnu::unused]] static const auto _factoryAdded##_Type = \ - registerEventType<_Type>(); \ - } \ +#define REGISTER_EVENT_TYPE(_Type) \ + namespace { \ + [[maybe_unused]] static const auto _factoryAdded##_Type = \ + registerEventType<_Type>(); \ + } \ // End of macro // === is<>(), eventCast<>() and visit<>() === diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h index 43aaa8be..6a34fd7f 100644 --- a/lib/events/roommemberevent.h +++ b/lib/events/roommemberevent.h @@ -92,7 +92,7 @@ public: bool isAvatarUpdate() const; private: - REGISTER_ENUM(MembershipType) + Q_ENUM(MembershipType) }; template <> diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index d0dbbfb3..b393382a 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -87,7 +87,7 @@ private: const QString& jsonMsgType, EventContent::TypedBase* content); - REGISTER_ENUM(MsgType) + Q_ENUM(MsgType) }; REGISTER_EVENT_TYPE(RoomMessageEvent) using MessageEventType = RoomMessageEvent::MsgType; diff --git a/lib/joinstate.h b/lib/joinstate.h index 718ae3fd..31c2b6a7 100644 --- a/lib/joinstate.h +++ b/lib/joinstate.h @@ -31,7 +31,7 @@ enum class JoinState : unsigned int { Q_DECLARE_FLAGS(JoinStates, JoinState) -// We cannot use REGISTER_ENUM outside of a Q_OBJECT and besides, we want +// We cannot use Q_ENUM outside of a Q_OBJECT and besides, we want // to use strings that match respective JSON keys. static const std::array JoinStateStrings { { "join", "invite", "leave" } }; diff --git a/lib/room.cpp b/lib/room.cpp index d8fee5aa..f70e0b0e 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1050,22 +1050,12 @@ FileTransferInfo Room::fileTransferInfo(const QString& id) const total = INT_MAX; } -#ifdef BROKEN_INITIALIZER_LISTS - FileTransferInfo fti; - fti.status = infoIt->status; - fti.progress = int(progress); - fti.total = int(total); - fti.localDir = QUrl::fromLocalFile(infoIt->localFileInfo.absolutePath()); - fti.localPath = QUrl::fromLocalFile(infoIt->localFileInfo.absoluteFilePath()); - return fti; -#else return { infoIt->status, infoIt->isUpload, int(progress), int(total), QUrl::fromLocalFile(infoIt->localFileInfo.absolutePath()), QUrl::fromLocalFile(infoIt->localFileInfo.absoluteFilePath()) }; -#endif } QUrl Room::fileSource(const QString& id) const diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp index 5fcc8dda..5b47b30f 100644 --- a/lib/syncdata.cpp +++ b/lib/syncdata.cpp @@ -92,7 +92,7 @@ SyncRoomData::SyncRoomData(const QString& roomId_, JoinState joinState_, switch (joinState) { case JoinState::Join: ephemeral = load(room_, "ephemeral"_ls); - FALLTHROUGH; + [[fallthrough]]; case JoinState::Leave: { accountData = load(room_, "account_data"_ls); timeline = load(room_, "timeline"_ls); diff --git a/lib/util.h b/lib/util.h index 12d3f8ba..7c79804b 100644 --- a/lib/util.h +++ b/lib/util.h @@ -20,73 +20,15 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) -# include -# include -#endif - #include #include -#if __has_cpp_attribute(fallthrough) -# define FALLTHROUGH [[fallthrough]] -#elif __has_cpp_attribute(clang::fallthrough) -# define FALLTHROUGH [[clang::fallthrough]] -#elif __has_cpp_attribute(gnu::fallthrough) -# define FALLTHROUGH [[gnu::fallthrough]] -#else -# define FALLTHROUGH // -fallthrough -#endif - -// Along the lines of Q_DISABLE_COPY +// Along the lines of Q_DISABLE_COPY - the upstream version comes in Qt 5.13 #define DISABLE_MOVE(_ClassName) \ _ClassName(_ClassName&&) Q_DECL_EQ_DELETE; \ _ClassName& operator=(_ClassName&&) Q_DECL_EQ_DELETE; -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -// Copy-pasted from Qt 5.10 -template -Q_DECL_CONSTEXPR typename std::add_const::type& qAsConst(T& t) Q_DECL_NOTHROW -{ - return t; -} -// prevent rvalue arguments: -template -static void qAsConst(const T&&) Q_DECL_EQ_DELETE; -#endif - -// MSVC 2015 and older GCC's don't handle initialisation from initializer lists -// right in the absense of a constructor; MSVC 2015, notably, fails with -// "error C2440: 'return': cannot convert from 'initializer list' to ''" -#if (defined(_MSC_VER) && _MSC_VER < 1910) \ - || (defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 4) -# define BROKEN_INITIALIZER_LISTS -#endif - namespace Quotient { -// The below enables pretty-printing of enums in logs -#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) -# define REGISTER_ENUM(EnumName) Q_ENUM(EnumName) -#else -// Thanks to Olivier for spelling it and for making Q_ENUM to replace it: -// https://woboq.com/blog/q_enum.html -# define REGISTER_ENUM(EnumName) \ - Q_ENUMS(EnumName) \ - friend QDebug operator<<(QDebug dbg, EnumName val) \ - { \ - static int enumIdx = staticMetaObject.indexOfEnumerator(#EnumName); \ - return dbg << Event::staticMetaObject.enumerator(enumIdx).valueToKey( \ - int(val)); \ - } -#endif - -/** static_cast<> for unique_ptr's */ -template -inline auto unique_ptr_cast(PtrT2&& p) -{ - return std::unique_ptr(static_cast(p.release())); -} - struct NoneTag {}; constexpr NoneTag none {}; @@ -185,7 +127,8 @@ namespace _impl { struct fn_traits; } -/** Determine traits of an arbitrary function/lambda/functor +/// Determine traits of an arbitrary function/lambda/functor +/*! * Doesn't work with generic lambdas and function objects that have * operator() overloaded. * \sa @@ -332,4 +275,4 @@ qreal stringToHueF(const QString& s); QString serverPart(const QString& mxId); } // namespace Quotient /// \deprecated Use namespace Quotient instead -namespace QMatrixClient = Quotient; \ No newline at end of file +namespace QMatrixClient = Quotient; -- cgit v1.2.3 From 372a9ed301e52d6daf7ccdb9a9982a67f46486a1 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 11 Aug 2019 17:08:20 +0900 Subject: Use [[maybe_unused]] instead of [[gnu::unused]] --- lib/events/roomevent.cpp | 2 +- lib/events/stateevent.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/events') diff --git a/lib/events/roomevent.cpp b/lib/events/roomevent.cpp index e19c03ce..971d8597 100644 --- a/lib/events/roomevent.cpp +++ b/lib/events/roomevent.cpp @@ -24,7 +24,7 @@ using namespace Quotient; -[[gnu::unused]] static auto roomEventTypeInitialised = +[[maybe_unused]] static auto roomEventTypeInitialised = Event::factory_t::chainFactory(); RoomEvent::RoomEvent(Type type, event_mtype_t matrixType, diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp index c0bb0794..5909e8a6 100644 --- a/lib/events/stateevent.cpp +++ b/lib/events/stateevent.cpp @@ -23,7 +23,7 @@ using namespace Quotient; // Aside from the normal factory to instantiate StateEventBase inheritors // StateEventBase itself can be instantiated if there's a state_key JSON key // but the event type is unknown. -[[gnu::unused]] static auto stateEventTypeInitialised = +[[maybe_unused]] static auto stateEventTypeInitialised = RoomEvent::factory_t::addMethod( [](const QJsonObject& json, const QString& matrixType) -> StateEventPtr { if (!json.contains(StateKeyKeyL)) -- cgit v1.2.3 From fadce11be92abe76cecfe6356b3b38f25dd93e8d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 13 Aug 2019 20:28:56 +0900 Subject: Support for server notices rooms (MSC1452) Closes #326. --- lib/events/accountdataevents.h | 1 + lib/jobs/basejob.cpp | 3 +++ lib/jobs/basejob.h | 1 + lib/room.cpp | 5 +++++ lib/room.h | 2 ++ 5 files changed, 12 insertions(+) (limited to 'lib/events') diff --git a/lib/events/accountdataevents.h b/lib/events/accountdataevents.h index a8df08a5..31176766 100644 --- a/lib/events/accountdataevents.h +++ b/lib/events/accountdataevents.h @@ -27,6 +27,7 @@ namespace Quotient { constexpr const char* FavouriteTag = "m.favourite"; constexpr const char* LowPriorityTag = "m.lowpriority"; +constexpr const char* ServerNoticeTag = "m.server_notice"; struct TagRecord { using order_type = Omittable; diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index ec6b8375..5930e8b8 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -426,6 +426,9 @@ BaseJob::Status BaseJob::parseError(QNetworkReply* reply, ? tr("Requested room version: %1") .arg(errorJson.value("room_version"_ls).toString()) : errorJson.value("error"_ls).toString() }; + if (errCode == "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM") + return { CannotLeaveRoom, + tr("It's not allowed to leave a server notices room") }; // Not localisable on the client side if (errorJson.contains("error"_ls)) diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h index 90c20c37..68467d48 100644 --- a/lib/jobs/basejob.h +++ b/lib/jobs/basejob.h @@ -76,6 +76,7 @@ public: NetworkAuthRequiredError = NetworkAuthRequired, UserConsentRequired, UserConsentRequiredError = UserConsentRequired, + CannotLeaveRoom, UserDefinedError = 256 }; diff --git a/lib/room.cpp b/lib/room.cpp index f70e0b0e..bee9e9cb 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -951,6 +951,11 @@ bool Room::isFavourite() const { return d->tags.contains(FavouriteTag); } bool Room::isLowPriority() const { return d->tags.contains(LowPriorityTag); } +bool Room::isServerNoticeRoom() const +{ + return d->tags.contains(ServerNoticeTag); +} + bool Room::isDirectChat() const { return connection()->isDirectChat(id()); } QList Room::directChatUsers() const diff --git a/lib/room.h b/lib/room.h index 8448815d..2139f28b 100644 --- a/lib/room.h +++ b/lib/room.h @@ -389,6 +389,8 @@ public: bool isFavourite() const; /// Check whether the list of tags has m.lowpriority bool isLowPriority() const; + /// Check whether this room is for server notices (MSC1452) + bool isServerNoticeRoom() const; /// Check whether this room is a direct chat Q_INVOKABLE bool isDirectChat() const; -- cgit v1.2.3 From e997f214562acf30ae8d4ea7132dde6e583ac6fe Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 23 Aug 2019 08:09:28 +0900 Subject: RoomMessageEvent::content(): constify event content --- lib/events/eventcontent.h | 2 ++ lib/events/roommessageevent.h | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/events') diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index c26cb931..e7656de5 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace Quotient { namespace EventContent { @@ -276,3 +277,4 @@ namespace EventContent { using FileContent = UrlWithThumbnailContent; } // namespace EventContent } // namespace Quotient +Q_DECLARE_METATYPE(const Quotient::EventContent::TypedBase*) diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index b393382a..e95aabfc 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -34,7 +34,7 @@ class RoomMessageEvent : public RoomEvent { Q_PROPERTY(QString msgType READ rawMsgtype CONSTANT) Q_PROPERTY(QString plainBody READ plainBody CONSTANT) Q_PROPERTY(QMimeType mimeType READ mimeType STORED false CONSTANT) - Q_PROPERTY(EventContent::TypedBase* content READ content CONSTANT) + Q_PROPERTY(const EventContent::TypedBase* content READ content CONSTANT) public: DEFINE_EVENT_TYPEID("m.room.message", RoomMessageEvent) @@ -62,13 +62,13 @@ public: MsgType msgtype() const; QString rawMsgtype() const; QString plainBody() const; - EventContent::TypedBase* content() const { return _content.data(); } + const EventContent::TypedBase* content() const { return _content.data(); } template - void editContent(VisitorT visitor) + void editContent(VisitorT&& visitor) { visitor(*_content); editJson()[ContentKeyL] = assembleContentJson(plainBody(), rawMsgtype(), - content()); + _content.data()); } QMimeType mimeType() const; bool hasTextContent() const; -- cgit v1.2.3 From 944653463fe4134c82d85e2d01e2bc0fa43fd727 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 12 Sep 2019 11:12:37 +0900 Subject: Introduce HashQ<> and UnorderedMap<> Invading into std:: is frowned upon, even though legitimate from the C++ standard perspective. Given that it's possible to pass a hash object to unordered_map, it only takes an alias for std::unordered_map to avoid having to specialize std::hash. And besides, a generic compatibility bridge between qHash and std::hash has been long needed. std::hash in converters.h remains for now; it will be dropped separately when the API files get regenerated to use UnorderedMap. --- lib/connection.cpp | 2 +- lib/connection.h | 2 +- lib/converters.h | 14 ++++---------- lib/events/stateevent.h | 10 ---------- lib/room.cpp | 4 ++-- lib/util.h | 14 ++++++++++++++ 6 files changed, 22 insertions(+), 24 deletions(-) (limited to 'lib/events') diff --git a/lib/connection.cpp b/lib/connection.cpp index 5ebdcf6c..c3e46356 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -98,7 +98,7 @@ public: // See https://github.com/quotient-im/libQuotient/wiki/Handling-direct-chat-events DirectChatsMap dcLocalAdditions; DirectChatsMap dcLocalRemovals; - std::unordered_map accountData; + UnorderedMap accountData; int syncLoopTimeout = -1; GetCapabilitiesJob* capabilitiesJob = nullptr; diff --git a/lib/connection.h b/lib/connection.h index 7e32e5c9..b4b16679 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -124,7 +124,7 @@ public: using IgnoredUsersList = IgnoredUsersEvent::content_type; using UsersToDevicesToEvents = - std::unordered_map>; + UnorderedMap>; enum RoomVisibility { PublishRoom, diff --git a/lib/converters.h b/lib/converters.h index 587e4544..b753a80b 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -28,16 +28,10 @@ #include #include -#include #include -#if 0 // Waiting for C++17 -# include - -template -using optional = std::experimental::optional; -#endif // Enable std::unordered_map +// REMOVEME in favor of UnorderedMap, once we regenerate API files namespace std { template <> struct hash { @@ -296,9 +290,9 @@ struct HashMapFromJson { } }; -template -struct JsonObjectConverter> - : public HashMapFromJson> {}; +template +struct JsonObjectConverter> + : public HashMapFromJson> {}; template struct JsonObjectConverter> diff --git a/lib/events/stateevent.h b/lib/events/stateevent.h index 74e36e74..710b4271 100644 --- a/lib/events/stateevent.h +++ b/lib/events/stateevent.h @@ -129,13 +129,3 @@ private: std::unique_ptr> _prev; }; } // namespace Quotient - -namespace std { -template <> -struct hash { - size_t operator()(const Quotient::StateEventKey& k) const Q_DECL_NOEXCEPT - { - return qHash(k); - } -}; -} // namespace std diff --git a/lib/room.cpp b/lib/room.cpp index 2c9fca63..2f697589 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -98,7 +98,7 @@ public: RoomSummary summary = { none, 0, none }; /// The state of the room at timeline position before-0 /// \sa timelineBase - std::unordered_map baseState; + UnorderedMap baseState; /// State event stubs - events without content, just type and state key static decltype(baseState) stubbedState; /// The state of the room at timeline position after-maxTimelineIndex() @@ -131,7 +131,7 @@ public: QHash lastReadEventIds; QString serverReadMarker; TagsMap tags; - std::unordered_map accountData; + UnorderedMap accountData; QString prevBatch; QPointer eventsHistoryJob; QPointer allMembersJob; diff --git a/lib/util.h b/lib/util.h index 7c79804b..788ce5bc 100644 --- a/lib/util.h +++ b/lib/util.h @@ -19,9 +19,11 @@ #pragma once #include +#include #include #include +#include // Along the lines of Q_DISABLE_COPY - the upstream version comes in Qt 5.13 #define DISABLE_MOVE(_ClassName) \ @@ -29,6 +31,18 @@ _ClassName& operator=(_ClassName&&) Q_DECL_EQ_DELETE; namespace Quotient { +/// An equivalent of std::hash for QTypes to enable std::unordered_map +template +struct HashQ { + size_t operator()(const T& s) const Q_DECL_NOEXCEPT + { + return qHash(s, uint(qGlobalQHashSeed())); + } +}; +/// A wrapper around std::unordered_map compatible with types that have qHash +template +using UnorderedMap = std::unordered_map>; + struct NoneTag {}; constexpr NoneTag none {}; -- cgit v1.2.3