aboutsummaryrefslogtreecommitdiff
path: root/lib/events
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events')
-rw-r--r--lib/events/accountdataevents.h50
-rw-r--r--lib/events/callanswerevent.h6
-rw-r--r--lib/events/callcandidatesevent.h6
-rw-r--r--lib/events/callhangupevent.h6
-rw-r--r--lib/events/callinviteevent.h6
-rw-r--r--lib/events/directchatevent.h10
-rw-r--r--lib/events/encryptedevent.h6
-rw-r--r--lib/events/encryptionevent.cpp6
-rw-r--r--lib/events/encryptionevent.h15
-rw-r--r--lib/events/event.cpp4
-rw-r--r--lib/events/event.h24
-rw-r--r--lib/events/eventcontent.cpp3
-rw-r--r--lib/events/eventcontent.h46
-rw-r--r--lib/events/eventloader.h9
-rw-r--r--lib/events/reactionevent.h16
-rw-r--r--lib/events/receiptevent.cpp3
-rw-r--r--lib/events/receiptevent.h12
-rw-r--r--lib/events/redactionevent.h9
-rw-r--r--lib/events/roomavatarevent.h9
-rw-r--r--lib/events/roomcreateevent.h13
-rw-r--r--lib/events/roomevent.cpp3
-rw-r--r--lib/events/roomevent.h9
-rw-r--r--lib/events/roommemberevent.cpp6
-rw-r--r--lib/events/roommemberevent.h22
-rw-r--r--lib/events/roommessageevent.cpp12
-rw-r--r--lib/events/roommessageevent.h24
-rw-r--r--lib/events/roomtombstoneevent.h10
-rw-r--r--lib/events/simplestateevents.h25
-rw-r--r--lib/events/stateevent.h21
-rw-r--r--lib/events/typingevent.cpp3
-rw-r--r--lib/events/typingevent.h6
31 files changed, 133 insertions, 267 deletions
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<float>;
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<TagRecord>
-{
+struct JsonObjectConverter<TagRecord> {
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<TagRecord>
using TagsMap = QHash<QString, TagRecord>;
-#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<content_type>(#_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<content_type>(#_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<QString, QString> 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<QString, 1> encryptionStrings = {
{ QMatrixClient::MegolmV1AesSha2AlgoKey }
};
-namespace QMatrixClient
-{
+namespace QMatrixClient {
template <>
-struct JsonConverter<EncryptionType>
-{
+struct JsonConverter<EncryptionType> {
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<EncryptionEventContent>
-{
+class EncryptionEvent : public StateEvent<EncryptionEventContent> {
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 <typename EventT>
@@ -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<void>()
}
template <typename EventT>
-struct EventTypeTraits
-{
+struct EventTypeTraits {
static event_type_t id()
{
static const auto id = EventTypeRegistry::initializeTypeId<EventT>();
@@ -148,8 +145,7 @@ inline event_ptr_tt<EventT> makeEvent(ArgTs&&... args)
}
template <typename BaseEventT>
-class EventFactory
-{
+class EventFactory {
public:
template <typename FnT>
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<Event>;
// 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 <QtCore/QSize>
#include <QtCore/QUrl>
-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 InfoT>
- 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 <typename InfoT>
- class UrlWithThumbnailContent : public UrlBasedContent<InfoT>
- {
+ class UrlWithThumbnailContent : public UrlBasedContent<InfoT> {
public:
using UrlBasedContent<InfoT>::UrlBasedContent;
explicit UrlWithThumbnailContent(const QJsonObject& json)
- : UrlBasedContent<InfoT>(json)
- , thumbnail(InfoT::originalInfoJson)
+ : UrlBasedContent<InfoT>(json), thumbnail(InfoT::originalInfoJson)
{
// Another small hack, to simplify making a thumbnail link
UrlBasedContent<InfoT>::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 <typename BaseEventT>
static inline auto loadEvent(const QJsonObject& json,
const QString& matrixType)
@@ -75,8 +73,7 @@ inline StateEventPtr loadStateEvent(const QString& matrixType,
}
template <typename EventT>
-struct JsonConverter<event_ptr_tt<EventT>>
-{
+struct JsonConverter<event_ptr_tt<EventT>> {
static auto load(const QJsonValue& jv)
{
return loadEvent<EventT>(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<EventRelation>
-{
+struct JsonObjectConverter<EventRelation> {
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<EventRelation>(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 <QtCore/QDateTime>
#include <QtCore/QVector>
-namespace QMatrixClient
-{
-struct Receipt
-{
+namespace QMatrixClient {
+struct Receipt {
QString userId;
QDateTime timestamp;
};
-struct ReceiptsForEvent
-{
+struct ReceiptsForEvent {
QString evtId;
QVector<Receipt> receipts;
};
using EventsWithReceipts = QVector<ReceiptsForEvent>;
-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<EventContent::ImageContent>
-{
+namespace QMatrixClient {
+class RoomAvatarEvent : public StateEvent<EventContent::ImageContent> {
// 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 <QtCore/QDateTime>
-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<RoomEvent>;
using RoomEvents = EventsArray<RoomEvent>;
using RoomEventsRange = Range<RoomEvents>;
-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<QString, 5> membershipStrings = {
QStringLiteral("leave"), QStringLiteral("ban") }
};
-namespace QMatrixClient
-{
+namespace QMatrixClient {
template <>
-struct JsonConverter<MembershipType>
-{
+struct JsonConverter<MembershipType> {
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<MemberEventContent>
-{
+class RoomMemberEvent : public StateEvent<MemberEventContent> {
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<RoomMemberEvent>
-{
+class EventFactory<RoomMemberEvent> {
public:
static event_ptr_tt<RoomMemberEvent> 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<TextContent>(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> 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 <typename ContentT>
- 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 <typename T>
- class SimpleContent
- {
+ class SimpleContent {
public:
using value_type = T;
// The constructor is templated to enable perfect forwarding
template <typename TT>
SimpleContent(QString keyName, TT&& value)
- : value(std::forward<TT>(value))
- , key(std::move(keyName))
+ : value(std::forward<TT>(value)), key(std::move(keyName))
{}
SimpleContent(const QJsonObject& json, QString keyName)
- : value(fromJson<T>(json[keyName]))
- , key(std::move(keyName))
+ : value(fromJson<T>(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<EventContent::SimpleContent<_ValueType>> \
- { \
+ class _Name : public StateEvent<EventContent::SimpleContent<_ValueType>> { \
public: \
using value_type = content_type::value_type; \
DEFINE_EVENT_TYPEID(_TypeId, _Name) \
- explicit _Name() \
- : _Name(value_type()) \
- {} \
+ explicit _Name() : _Name(value_type()) {} \
template <typename T> \
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<EventContent::SimpleContent<QStringList>>
-{
+ : public StateEvent<EventContent::SimpleContent<QStringList>> {
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 <typename StrT>
@@ -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>;
- 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<StateEventBase>(const Event& e)
using StateEventKey = QPair<QString, QString>;
template <typename ContentT>
-struct Prev
-{
+struct Prev {
template <typename... ContentParamTs>
explicit Prev(const QJsonObject& unsignedJson,
ContentParamTs&&... contentParams)
@@ -86,8 +82,7 @@ struct Prev
};
template <typename ContentT>
-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<QMatrixClient::StateEventKey>
-{
+struct hash<QMatrixClient::StateEventKey> {
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)