diff --git a/src/events/AliasesEventContent.cc b/src/events/AliasesEventContent.cc
deleted file mode 100644
index 87acbade..00000000
--- a/src/events/AliasesEventContent.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <QJsonArray>
-
-#include "AliasesEventContent.h"
-
-using namespace matrix::events;
-
-void
-AliasesEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("AliasesEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("aliases") == QJsonValue::Undefined)
- throw DeserializationException("aliases key is missing");
-
- auto aliases = object.value("aliases").toArray();
-
- for (const auto &alias : aliases)
- aliases_.push_back(alias.toString());
-}
-
-QJsonObject
-AliasesEventContent::serialize() const
-{
- QJsonObject object;
-
- QJsonArray aliases;
-
- for (const auto &alias : aliases_)
- aliases.push_back(alias);
-
- if (aliases.size() > 0)
- object["aliases"] = aliases;
-
- return object;
-}
diff --git a/src/events/AvatarEventContent.cc b/src/events/AvatarEventContent.cc
deleted file mode 100644
index fc58ad5c..00000000
--- a/src/events/AvatarEventContent.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <QDebug>
-
-#include "AvatarEventContent.h"
-
-using namespace matrix::events;
-
-void
-AvatarEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("AvatarEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("url") == QJsonValue::Undefined)
- throw DeserializationException("url key is missing");
-
- url_ = QUrl(object.value("url").toString());
-
- if (!url_.isValid())
- qWarning() << "Invalid avatar url" << url_;
-}
-
-QJsonObject
-AvatarEventContent::serialize() const
-{
- QJsonObject object;
-
- if (!url_.isEmpty())
- object["url"] = url_.toString();
-
- return object;
-}
diff --git a/src/events/CanonicalAliasEventContent.cc b/src/events/CanonicalAliasEventContent.cc
deleted file mode 100644
index 189a0cb0..00000000
--- a/src/events/CanonicalAliasEventContent.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "CanonicalAliasEventContent.h"
-
-using namespace matrix::events;
-
-void
-CanonicalAliasEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("CanonicalAliasEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("alias") == QJsonValue::Undefined)
- throw DeserializationException("alias key is missing");
-
- alias_ = object.value("alias").toString();
-}
-
-QJsonObject
-CanonicalAliasEventContent::serialize() const
-{
- QJsonObject object;
-
- if (!alias_.isEmpty())
- object["alias"] = alias_;
-
- return object;
-}
diff --git a/src/events/CreateEventContent.cc b/src/events/CreateEventContent.cc
deleted file mode 100644
index f28099c4..00000000
--- a/src/events/CreateEventContent.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "CreateEventContent.h"
-
-using namespace matrix::events;
-
-void
-CreateEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("CreateEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("creator") == QJsonValue::Undefined)
- throw DeserializationException("creator key is missing");
-
- creator_ = object.value("creator").toString();
-}
-
-QJsonObject
-CreateEventContent::serialize() const
-{
- QJsonObject object;
-
- if (!creator_.isEmpty())
- object["creator"] = creator_;
-
- return object;
-}
diff --git a/src/events/Event.cc b/src/events/Event.cc
deleted file mode 100644
index 7e5bd1db..00000000
--- a/src/events/Event.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "events/Event.h"
-
-#include "AliasesEventContent.h"
-#include "AvatarEventContent.h"
-#include "CanonicalAliasEventContent.h"
-#include "CreateEventContent.h"
-#include "Deserializable.h"
-#include "HistoryVisibilityEventContent.h"
-#include "JoinRulesEventContent.h"
-#include "MemberEventContent.h"
-#include "NameEventContent.h"
-#include "PowerLevelsEventContent.h"
-#include "TopicEventContent.h"
-
-matrix::events::EventType
-matrix::events::extractEventType(const QJsonObject &object)
-{
- if (!object.contains("type"))
- throw DeserializationException("Missing event type");
-
- auto type = object.value("type").toString();
-
- if (type == "m.room.aliases")
- return EventType::RoomAliases;
- else if (type == "m.room.avatar")
- return EventType::RoomAvatar;
- else if (type == "m.room.canonical_alias")
- return EventType::RoomCanonicalAlias;
- else if (type == "m.room.create")
- return EventType::RoomCreate;
- else if (type == "m.room.history_visibility")
- return EventType::RoomHistoryVisibility;
- else if (type == "m.room.join_rules")
- return EventType::RoomJoinRules;
- else if (type == "m.room.member")
- return EventType::RoomMember;
- else if (type == "m.room.message")
- return EventType::RoomMessage;
- else if (type == "m.room.name")
- return EventType::RoomName;
- else if (type == "m.room.power_levels")
- return EventType::RoomPowerLevels;
- else if (type == "m.room.topic")
- return EventType::RoomTopic;
- else
- return EventType::Unsupported;
-}
-
-bool
-matrix::events::isStateEvent(EventType type)
-{
- return type == EventType::RoomAliases || type == EventType::RoomAvatar ||
- type == EventType::RoomCanonicalAlias || type == EventType::RoomCreate ||
- type == EventType::RoomHistoryVisibility || type == EventType::RoomJoinRules ||
- type == EventType::RoomMember || type == EventType::RoomName ||
- type == EventType::RoomPowerLevels || type == EventType::RoomTopic;
-}
-
-bool
-matrix::events::isMessageEvent(EventType type)
-{
- return type == EventType::RoomMessage;
-}
-
-void
-matrix::events::UnsignedData::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("UnsignedData is not a JSON object");
-
- auto object = data.toObject();
-
- transaction_id_ = object.value("transaction_id").toString();
- age_ = object.value("age").toDouble();
-}
-
-QJsonObject
-matrix::events::UnsignedData::serialize() const
-{
- QJsonObject object;
-
- if (!transaction_id_.isEmpty())
- object["transaction_id"] = transaction_id_;
-
- if (age_ > 0)
- object["age"] = age_;
-
- return object;
-}
diff --git a/src/events/HistoryVisibilityEventContent.cc b/src/events/HistoryVisibilityEventContent.cc
deleted file mode 100644
index 7c0a149c..00000000
--- a/src/events/HistoryVisibilityEventContent.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "HistoryVisibilityEventContent.h"
-
-using namespace matrix::events;
-
-void
-HistoryVisibilityEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException(
- "HistoryVisibilityEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("history_visibility") == QJsonValue::Undefined)
- throw DeserializationException("history_visibility key is missing");
-
- auto value = object.value("history_visibility").toString();
-
- if (value == "invited")
- history_visibility_ = HistoryVisibility::Invited;
- else if (value == "joined")
- history_visibility_ = HistoryVisibility::Joined;
- else if (value == "shared")
- history_visibility_ = HistoryVisibility::Shared;
- else if (value == "world_readable")
- history_visibility_ = HistoryVisibility::WorldReadable;
- else
- throw DeserializationException(
- QString("Unknown history_visibility value: %1").arg(value).toUtf8().constData());
-}
-
-QJsonObject
-HistoryVisibilityEventContent::serialize() const
-{
- QJsonObject object;
-
- if (history_visibility_ == HistoryVisibility::Invited)
- object["history_visibility"] = "invited";
- else if (history_visibility_ == HistoryVisibility::Joined)
- object["history_visibility"] = "joined";
- else if (history_visibility_ == HistoryVisibility::Shared)
- object["history_visibility"] = "shared";
- else if (history_visibility_ == HistoryVisibility::WorldReadable)
- object["history_visibility"] = "world_readable";
-
- return object;
-}
diff --git a/src/events/JoinRulesEventContent.cc b/src/events/JoinRulesEventContent.cc
deleted file mode 100644
index 4f5cf6ee..00000000
--- a/src/events/JoinRulesEventContent.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "JoinRulesEventContent.h"
-
-using namespace matrix::events;
-
-void
-JoinRulesEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("JoinRulesEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("join_rule") == QJsonValue::Undefined)
- throw DeserializationException("join_rule key is missing");
-
- auto value = object.value("join_rule").toString();
-
- if (value == "invite")
- join_rule_ = JoinRule::Invite;
- else if (value == "knock")
- join_rule_ = JoinRule::Knock;
- else if (value == "private")
- join_rule_ = JoinRule::Private;
- else if (value == "public")
- join_rule_ = JoinRule::Public;
- else
- throw DeserializationException(
- QString("Unknown join_rule value: %1").arg(value).toUtf8().constData());
-}
-
-QJsonObject
-JoinRulesEventContent::serialize() const
-{
- QJsonObject object;
-
- if (join_rule_ == JoinRule::Invite)
- object["join_rule"] = "invite";
- else if (join_rule_ == JoinRule::Knock)
- object["join_rule"] = "knock";
- else if (join_rule_ == JoinRule::Private)
- object["join_rule"] = "private";
- else if (join_rule_ == JoinRule::Public)
- object["join_rule"] = "public";
-
- return object;
-}
diff --git a/src/events/MemberEventContent.cc b/src/events/MemberEventContent.cc
deleted file mode 100644
index f80130e6..00000000
--- a/src/events/MemberEventContent.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <QDebug>
-
-#include "MemberEventContent.h"
-
-using namespace matrix::events;
-
-void
-MemberEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("MemberEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (!object.contains("membership"))
- throw DeserializationException("membership key is missing");
-
- auto value = object.value("membership").toString();
-
- if (value == "ban")
- membership_state_ = Membership::Ban;
- else if (value == "invite")
- membership_state_ = Membership::Invite;
- else if (value == "join")
- membership_state_ = Membership::Join;
- else if (value == "knock")
- membership_state_ = Membership::Knock;
- else if (value == "leave")
- membership_state_ = Membership::Leave;
- else
- throw DeserializationException(
- QString("Unknown membership value: %1").arg(value).toUtf8().constData());
-
- if (object.contains("avatar_url"))
- avatar_url_ = QUrl(object.value("avatar_url").toString());
-
- if (!avatar_url_.toString().isEmpty() && !avatar_url_.isValid())
- qWarning() << "Invalid avatar url" << avatar_url_;
-
- if (object.contains("displayname"))
- display_name_ = object.value("displayname").toString();
-}
-
-QJsonObject
-MemberEventContent::serialize() const
-{
- QJsonObject object;
-
- if (membership_state_ == Membership::Ban)
- object["membership"] = "ban";
- else if (membership_state_ == Membership::Invite)
- object["membership"] = "invite";
- else if (membership_state_ == Membership::Join)
- object["membership"] = "join";
- else if (membership_state_ == Membership::Knock)
- object["membership"] = "knock";
- else if (membership_state_ == Membership::Leave)
- object["membership"] = "leave";
-
- if (!avatar_url_.isEmpty())
- object["avatar_url"] = avatar_url_.toString();
-
- if (!display_name_.isEmpty())
- object["displayname"] = display_name_;
-
- return object;
-}
diff --git a/src/events/MessageEventContent.cc b/src/events/MessageEventContent.cc
deleted file mode 100644
index fcf25da1..00000000
--- a/src/events/MessageEventContent.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <QDebug>
-
-#include "MessageEventContent.h"
-
-using namespace matrix::events;
-
-MessageEventType
-matrix::events::extractMessageEventType(const QJsonObject &data)
-{
- if (!data.contains("content"))
- return MessageEventType::Unknown;
-
- auto content = data.value("content").toObject();
- auto msgtype = content.value("msgtype").toString();
-
- if (msgtype == "m.audio")
- return MessageEventType::Audio;
- else if (msgtype == "m.emote")
- return MessageEventType::Emote;
- else if (msgtype == "m.file")
- return MessageEventType::File;
- else if (msgtype == "m.image")
- return MessageEventType::Image;
- else if (msgtype == "m.location")
- return MessageEventType::Location;
- else if (msgtype == "m.notice")
- return MessageEventType::Notice;
- else if (msgtype == "m.text")
- return MessageEventType::Text;
- else if (msgtype == "m.video")
- return MessageEventType::Video;
- else
- return MessageEventType::Unknown;
-}
-
-void
-MessageEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("MessageEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (!object.contains("body"))
- throw DeserializationException("body key is missing");
-
- body_ = object.value("body").toString();
-}
-
-QJsonObject
-MessageEventContent::serialize() const
-{
- // TODO: Add for all the message contents.
- QJsonObject object;
-
- return object;
-}
diff --git a/src/events/NameEventContent.cc b/src/events/NameEventContent.cc
deleted file mode 100644
index 45759cf2..00000000
--- a/src/events/NameEventContent.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "NameEventContent.h"
-
-using namespace matrix::events;
-
-void
-NameEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("NameEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("name") == QJsonValue::Undefined)
- throw DeserializationException("name key is missing");
-
- name_ = object.value("name").toString();
-}
-
-QJsonObject
-NameEventContent::serialize() const
-{
- QJsonObject object;
-
- if (!name_.isEmpty())
- object["name"] = name_;
-
- return object;
-}
diff --git a/src/events/PowerLevelsEventContent.cc b/src/events/PowerLevelsEventContent.cc
deleted file mode 100644
index c796f81f..00000000
--- a/src/events/PowerLevelsEventContent.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <QJsonObject>
-
-#include "Deserializable.h"
-#include "PowerLevelsEventContent.h"
-
-using namespace matrix::events;
-
-void
-PowerLevelsEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("PowerLevelsEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("ban") != QJsonValue::Undefined)
- ban_ = object.value("ban").toInt();
-
- if (object.value("invite") != QJsonValue::Undefined)
- invite_ = object.value("invite").toInt();
-
- if (object.value("kick") != QJsonValue::Undefined)
- kick_ = object.value("kick").toInt();
-
- if (object.value("redact") != QJsonValue::Undefined)
- redact_ = object.value("redact").toInt();
-
- if (object.value("events_default") != QJsonValue::Undefined)
- events_default_ = object.value("events_default").toInt();
-
- if (object.value("state_default") != QJsonValue::Undefined)
- state_default_ = object.value("state_default").toInt();
-
- if (object.value("users_default") != QJsonValue::Undefined)
- users_default_ = object.value("users_default").toInt();
-
- if (object.value("users").isObject()) {
- auto users = object.value("users").toObject();
-
- for (auto it = users.constBegin(); it != users.constEnd(); ++it)
- users_.insert(it.key(), it.value().toInt());
- }
-
- if (object.value("events").isObject()) {
- auto events = object.value("events").toObject();
-
- for (auto it = events.constBegin(); it != events.constEnd(); ++it)
- events_.insert(it.key(), it.value().toInt());
- }
-}
-
-QJsonObject
-PowerLevelsEventContent::serialize() const
-{
- QJsonObject object;
-
- object["ban"] = ban_;
- object["invite"] = invite_;
- object["kick"] = kick_;
- object["redact"] = redact_;
-
- object["events_default"] = events_default_;
- object["users_default"] = users_default_;
- object["state_default"] = state_default_;
-
- QJsonObject users;
- QJsonObject events;
-
- for (auto it = users_.constBegin(); it != users_.constEnd(); ++it)
- users.insert(it.key(), it.value());
-
- for (auto it = events_.constBegin(); it != events_.constEnd(); ++it)
- events.insert(it.key(), it.value());
-
- object["users"] = users;
- object["events"] = events;
-
- return object;
-}
-
-int
-PowerLevelsEventContent::eventLevel(QString event_type) const
-{
- if (events_.contains(event_type))
- return events_[event_type];
-
- return events_default_;
-}
-
-int
-PowerLevelsEventContent::userLevel(QString userid) const
-{
- if (users_.contains(userid))
- return users_[userid];
-
- return users_default_;
-}
diff --git a/src/events/TopicEventContent.cc b/src/events/TopicEventContent.cc
deleted file mode 100644
index 89602ded..00000000
--- a/src/events/TopicEventContent.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "TopicEventContent.h"
-
-using namespace matrix::events;
-
-void
-TopicEventContent::deserialize(const QJsonValue &data)
-{
- if (!data.isObject())
- throw DeserializationException("TopicEventContent is not a JSON object");
-
- auto object = data.toObject();
-
- if (object.value("topic") == QJsonValue::Undefined)
- throw DeserializationException("topic key is missing");
-
- topic_ = object.value("topic").toString();
-}
-
-QJsonObject
-TopicEventContent::serialize() const
-{
- QJsonObject object;
-
- if (!topic_.isEmpty())
- object["topic"] = topic_;
-
- return object;
-}
diff --git a/src/events/messages/Audio.cc b/src/events/messages/Audio.cc
deleted file mode 100644
index 6b8f8c7e..00000000
--- a/src/events/messages/Audio.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "Audio.h"
-
-using namespace matrix::events::messages;
-
-void
-Audio::deserialize(const QJsonObject &object)
-{
- if (!object.contains("url"))
- throw DeserializationException("url key is missing");
-
- url_ = object.value("url").toString();
-
- if (object.value("msgtype") != "m.audio")
- throw DeserializationException("invalid msgtype for audio");
-
- if (object.contains("info")) {
- auto info = object.value("info").toObject();
-
- info_.duration = info.value("duration").toInt();
- info_.mimetype = info.value("mimetype").toString();
- info_.size = info.value("size").toInt();
- }
-}
diff --git a/src/events/messages/Emote.cc b/src/events/messages/Emote.cc
deleted file mode 100644
index 2c9ab823..00000000
--- a/src/events/messages/Emote.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "Emote.h"
-
-using namespace matrix::events::messages;
-
-void
-Emote::deserialize(const QJsonObject &object)
-{
- if (object.value("msgtype") != "m.emote")
- throw DeserializationException("invalid msgtype for emote");
-}
diff --git a/src/events/messages/File.cc b/src/events/messages/File.cc
deleted file mode 100644
index 28bce441..00000000
--- a/src/events/messages/File.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "File.h"
-
-using namespace matrix::events::messages;
-
-void
-File::deserialize(const QJsonObject &object)
-{
- if (!object.contains("url"))
- throw DeserializationException("messages::File url key is missing");
-
- if (object.value("msgtype") != "m.file")
- throw DeserializationException("invalid msgtype for file");
-
- url_ = object.value("url").toString();
- filename_ = object.value("filename").toString();
-
- if (object.contains("info")) {
- auto file_info = object.value("info").toObject();
-
- info_.size = file_info.value("size").toInt();
- info_.mimetype = file_info.value("mimetype").toString();
- info_.thumbnail_url = file_info.value("thumbnail_url").toString();
-
- if (file_info.contains("thumbnail_info")) {
- auto thumbinfo = file_info.value("thumbnail_info").toObject();
-
- info_.thumbnail_info.h = thumbinfo.value("h").toInt();
- info_.thumbnail_info.w = thumbinfo.value("w").toInt();
- info_.thumbnail_info.size = thumbinfo.value("size").toInt();
- info_.thumbnail_info.mimetype = thumbinfo.value("mimetype").toString();
- }
- }
-}
diff --git a/src/events/messages/Image.cc b/src/events/messages/Image.cc
deleted file mode 100644
index 9d7c7a3b..00000000
--- a/src/events/messages/Image.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "Image.h"
-
-using namespace matrix::events::messages;
-
-void
-Image::deserialize(const QJsonObject &object)
-{
- if (!object.contains("url"))
- throw DeserializationException("messages::Image url key is missing");
-
- url_ = object.value("url").toString();
-
- if (object.value("msgtype") != "m.image")
- throw DeserializationException("invalid msgtype for image");
-
- if (object.contains("info")) {
- auto imginfo = object.value("info").toObject();
-
- info_.w = imginfo.value("w").toInt();
- info_.h = imginfo.value("h").toInt();
- info_.size = imginfo.value("size").toInt();
-
- info_.mimetype = imginfo.value("mimetype").toString();
- info_.thumbnail_url = imginfo.value("thumbnail_url").toString();
-
- if (imginfo.contains("thumbnail_info")) {
- auto thumbinfo = imginfo.value("thumbnail_info").toObject();
-
- info_.thumbnail_info.h = thumbinfo.value("h").toInt();
- info_.thumbnail_info.w = thumbinfo.value("w").toInt();
- info_.thumbnail_info.size = thumbinfo.value("size").toInt();
- info_.thumbnail_info.mimetype = thumbinfo.value("mimetype").toString();
- }
- }
-}
diff --git a/src/events/messages/Location.cc b/src/events/messages/Location.cc
deleted file mode 100644
index ea2b333a..00000000
--- a/src/events/messages/Location.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "Location.h"
-
-using namespace matrix::events::messages;
-
-void
-Location::deserialize(const QJsonObject &object)
-{
- if (!object.contains("geo_uri"))
- throw DeserializationException("messages::Location geo_uri key is missing");
-
- if (object.value("msgtype") != "m.location")
- throw DeserializationException("invalid msgtype for location");
-
- geo_uri_ = object.value("geo_uri").toString();
-
- if (object.contains("info")) {
- auto location_info = object.value("info").toObject();
-
- info_.thumbnail_url = location_info.value("thumbnail_url").toString();
-
- if (location_info.contains("thumbnail_info")) {
- auto thumbinfo = location_info.value("thumbnail_info").toObject();
-
- info_.thumbnail_info.h = thumbinfo.value("h").toInt();
- info_.thumbnail_info.w = thumbinfo.value("w").toInt();
- info_.thumbnail_info.size = thumbinfo.value("size").toInt();
- info_.thumbnail_info.mimetype = thumbinfo.value("mimetype").toString();
- }
- }
-}
diff --git a/src/events/messages/Notice.cc b/src/events/messages/Notice.cc
deleted file mode 100644
index 5b809c77..00000000
--- a/src/events/messages/Notice.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "Notice.h"
-
-using namespace matrix::events::messages;
-
-void
-Notice::deserialize(const QJsonObject &object)
-{
- if (object.value("msgtype") != "m.notice")
- throw DeserializationException("invalid msgtype for notice");
-}
diff --git a/src/events/messages/Text.cc b/src/events/messages/Text.cc
deleted file mode 100644
index 6797ec01..00000000
--- a/src/events/messages/Text.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "Text.h"
-
-using namespace matrix::events::messages;
-
-void
-Text::deserialize(const QJsonObject &object)
-{
- if (object.value("msgtype") != "m.text")
- throw DeserializationException("invalid msgtype for text");
-}
diff --git a/src/events/messages/Video.cc b/src/events/messages/Video.cc
deleted file mode 100644
index 89f90304..00000000
--- a/src/events/messages/Video.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "Video.h"
-
-using namespace matrix::events::messages;
-
-void
-Video::deserialize(const QJsonObject &object)
-{
- if (!object.contains("url"))
- throw DeserializationException("messages::Video url key is missing");
-
- url_ = object.value("url").toString();
-
- if (object.value("msgtype") != "m.video")
- throw DeserializationException("invalid msgtype for video");
-
- if (object.contains("info")) {
- auto video_info = object.value("info").toObject();
-
- info_.w = video_info.value("w").toInt();
- info_.h = video_info.value("h").toInt();
- info_.size = video_info.value("size").toInt();
- info_.duration = video_info.value("duration").toInt();
-
- info_.mimetype = video_info.value("mimetype").toString();
- info_.thumbnail_url = video_info.value("thumbnail_url").toString();
-
- if (video_info.contains("thumbnail_info")) {
- auto thumbinfo = video_info.value("thumbnail_info").toObject();
-
- info_.thumbnail_info.h = thumbinfo.value("h").toInt();
- info_.thumbnail_info.w = thumbinfo.value("w").toInt();
- info_.thumbnail_info.size = thumbinfo.value("size").toInt();
- info_.thumbnail_info.mimetype = thumbinfo.value("mimetype").toString();
- }
- }
-}
|