aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/events/encryptionevent.cpp4
-rw-r--r--lib/events/encryptionevent.h8
-rw-r--r--lib/events/roommemberevent.cpp6
-rw-r--r--lib/events/roommemberevent.h7
-rw-r--r--lib/events/roompowerlevelsevent.cpp10
-rw-r--r--lib/events/roompowerlevelsevent.h8
6 files changed, 19 insertions, 24 deletions
diff --git a/lib/events/encryptionevent.cpp b/lib/events/encryptionevent.cpp
index 47b0a032..6e994cd4 100644
--- a/lib/events/encryptionevent.cpp
+++ b/lib/events/encryptionevent.cpp
@@ -47,10 +47,12 @@ EncryptionEventContent::EncryptionEventContent(EncryptionType et)
}
}
-void EncryptionEventContent::fillJson(QJsonObject& o) const
+QJsonObject EncryptionEventContent::toJson() const
{
+ QJsonObject o;
if (encryption != EncryptionType::Undefined)
o.insert(AlgorithmKey, algorithm);
o.insert(RotationPeriodMsKey, rotationPeriodMs);
o.insert(RotationPeriodMsgsKey, rotationPeriodMsgs);
+ return o;
}
diff --git a/lib/events/encryptionevent.h b/lib/events/encryptionevent.h
index fe76b1af..5b5420ec 100644
--- a/lib/events/encryptionevent.h
+++ b/lib/events/encryptionevent.h
@@ -4,12 +4,11 @@
#pragma once
-#include "eventcontent.h"
#include "stateevent.h"
#include "quotient_common.h"
namespace Quotient {
-class QUOTIENT_API EncryptionEventContent : public EventContent::Base {
+class QUOTIENT_API EncryptionEventContent {
public:
enum EncryptionType : size_t { MegolmV1AesSha2 = 0, Undefined };
@@ -20,13 +19,12 @@ public:
{}
explicit EncryptionEventContent(const QJsonObject& json);
+ QJsonObject toJson() const;
+
EncryptionType encryption;
QString algorithm;
int rotationPeriodMs;
int rotationPeriodMsgs;
-
-protected:
- void fillJson(QJsonObject& o) const override;
};
using EncryptionType = EncryptionEventContent::EncryptionType;
diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp
index 55da5809..c3be0e00 100644
--- a/lib/events/roommemberevent.cpp
+++ b/lib/events/roommemberevent.cpp
@@ -4,8 +4,6 @@
#include "roommemberevent.h"
-#include "logging.h"
-
#include <QtCore/QtAlgorithms>
namespace Quotient {
@@ -43,8 +41,9 @@ MemberEventContent::MemberEventContent(const QJsonObject& json)
displayName = sanitized(*displayName);
}
-void MemberEventContent::fillJson(QJsonObject& o) const
+QJsonObject MemberEventContent::toJson() const
{
+ QJsonObject o;
if (membership != Membership::Invalid)
o.insert(QStringLiteral("membership"),
MembershipStrings[qCountTrailingZeroBits(
@@ -55,6 +54,7 @@ void MemberEventContent::fillJson(QJsonObject& o) const
o.insert(QStringLiteral("avatar_url"), avatarUrl->toString());
if (!reason.isEmpty())
o.insert(QStringLiteral("reason"), reason);
+ return o;
}
bool RoomMemberEvent::changesMembership() const
diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h
index afbaf825..dd33ea6b 100644
--- a/lib/events/roommemberevent.h
+++ b/lib/events/roommemberevent.h
@@ -5,18 +5,18 @@
#pragma once
-#include "eventcontent.h"
#include "stateevent.h"
#include "quotient_common.h"
namespace Quotient {
-class QUOTIENT_API MemberEventContent : public EventContent::Base {
+class QUOTIENT_API MemberEventContent {
public:
using MembershipType
[[deprecated("Use Quotient::Membership instead")]] = Membership;
QUO_IMPLICIT MemberEventContent(Membership ms) : membership(ms) {}
explicit MemberEventContent(const QJsonObject& json);
+ QJsonObject toJson() const;
Membership membership;
/// (Only for invites) Whether the invite is to a direct chat
@@ -24,9 +24,6 @@ public:
Omittable<QString> displayName;
Omittable<QUrl> avatarUrl;
QString reason;
-
-protected:
- void fillJson(QJsonObject& o) const override;
};
using MembershipType [[deprecated("Use Membership instead")]] = Membership;
diff --git a/lib/events/roompowerlevelsevent.cpp b/lib/events/roompowerlevelsevent.cpp
index 1c87fd47..84a31d55 100644
--- a/lib/events/roompowerlevelsevent.cpp
+++ b/lib/events/roompowerlevelsevent.cpp
@@ -3,8 +3,6 @@
#include "roompowerlevelsevent.h"
-#include <QJsonDocument>
-
using namespace Quotient;
PowerLevelsEventContent::PowerLevelsEventContent(const QJsonObject& json) :
@@ -21,7 +19,9 @@ PowerLevelsEventContent::PowerLevelsEventContent(const QJsonObject& json) :
{
}
-void PowerLevelsEventContent::fillJson(QJsonObject& o) const {
+QJsonObject PowerLevelsEventContent::toJson() const
+{
+ QJsonObject o;
o.insert(QStringLiteral("invite"), invite);
o.insert(QStringLiteral("kick"), kick);
o.insert(QStringLiteral("ban"), ban);
@@ -31,7 +31,9 @@ void PowerLevelsEventContent::fillJson(QJsonObject& o) const {
o.insert(QStringLiteral("state_default"), stateDefault);
o.insert(QStringLiteral("users"), Quotient::toJson(users));
o.insert(QStringLiteral("users_default"), usersDefault);
- o.insert(QStringLiteral("notifications"), QJsonObject{{"room", notifications.room}});
+ o.insert(QStringLiteral("notifications"),
+ QJsonObject { { "room", notifications.room } });
+ return o;
}
int RoomPowerLevelsEvent::powerLevelForEvent(const QString &eventId) const {
diff --git a/lib/events/roompowerlevelsevent.h b/lib/events/roompowerlevelsevent.h
index 3ce83763..a1638a27 100644
--- a/lib/events/roompowerlevelsevent.h
+++ b/lib/events/roompowerlevelsevent.h
@@ -3,17 +3,16 @@
#pragma once
-#include "eventcontent.h"
#include "stateevent.h"
namespace Quotient {
-class QUOTIENT_API PowerLevelsEventContent : public EventContent::Base {
-public:
+struct QUOTIENT_API PowerLevelsEventContent {
struct Notifications {
int room;
};
explicit PowerLevelsEventContent(const QJsonObject& json);
+ QJsonObject toJson() const;
int invite;
int kick;
@@ -29,9 +28,6 @@ public:
int usersDefault;
Notifications notifications;
-
-protected:
- void fillJson(QJsonObject& o) const override;
};
class QUOTIENT_API RoomPowerLevelsEvent