aboutsummaryrefslogtreecommitdiff
path: root/events
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-10-08 11:23:41 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-10-08 11:23:41 +0900
commitc0953cf02f18d3ce6d514af1d22b54a4612bd139 (patch)
treeab5000146743da82e95d651f8d4128bd7355840c /events
parentce1bbe88509715c9a35bb7aeeb5f20f0d4918ec4 (diff)
parentc9dc5e12b835425f1ba5c447ddb3c3394ccac93e (diff)
downloadlibquotient-c0953cf02f18d3ce6d514af1d22b54a4612bd139.tar.gz
libquotient-c0953cf02f18d3ce6d514af1d22b54a4612bd139.zip
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'events')
-rw-r--r--events/encryptedevent.cpp5
-rw-r--r--events/encryptedevent.h39
-rw-r--r--events/event.cpp3
-rw-r--r--events/event.h4
-rw-r--r--events/receiptevent.cpp7
5 files changed, 55 insertions, 3 deletions
diff --git a/events/encryptedevent.cpp b/events/encryptedevent.cpp
new file mode 100644
index 00000000..90e77c36
--- /dev/null
+++ b/events/encryptedevent.cpp
@@ -0,0 +1,5 @@
+//
+// Created by rusakov on 26/09/2017.
+//
+
+#include "encryptedevent.h"
diff --git a/events/encryptedevent.h b/events/encryptedevent.h
new file mode 100644
index 00000000..9db462e1
--- /dev/null
+++ b/events/encryptedevent.h
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * Copyright (C) 2017 Kitsune Ral <kitsune-ral@users.sf.net>
+ *
+ * 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 "event.h"
+
+namespace QMatrixClient
+{
+ class EncryptionEvent : public RoomEvent
+ {
+ public:
+ explicit EncryptionEvent(const QJsonObject& obj)
+ : RoomEvent(Type::RoomEncryption, obj)
+ , _algorithm(contentJson()["algorithm"].toString())
+ { }
+
+ QString algorithm() const { return _algorithm; }
+
+ private:
+ QString _algorithm;
+ };
+} // namespace QMatrixClient
+
diff --git a/events/event.cpp b/events/event.cpp
index d718306d..304f2af6 100644
--- a/events/event.cpp
+++ b/events/event.cpp
@@ -26,7 +26,7 @@
#include "roomtopicevent.h"
#include "typingevent.h"
#include "receiptevent.h"
-#include "unknownevent.h"
+#include "encryptedevent.h"
#include "logging.h"
#include <QtCore/QJsonDocument>
@@ -136,6 +136,7 @@ RoomEvent* RoomEvent::fromJson(const QJsonObject& obj)
"m.room.canonical_alias", make<RoomCanonicalAliasEvent>,
"m.room.member", make<RoomMemberEvent>,
"m.room.topic", make<RoomTopicEvent>,
+ "m.room.encryption", make<EncryptionEvent>,
/* Insert new ROOM event types BEFORE this line */
nullptr
);
diff --git a/events/event.h b/events/event.h
index 7db14100..ec993522 100644
--- a/events/event.h
+++ b/events/event.h
@@ -34,7 +34,8 @@ namespace QMatrixClient
enum class Type
{
RoomMessage, RoomName, RoomAliases, RoomCanonicalAlias,
- RoomMember, RoomTopic, Typing, Receipt, Unknown
+ RoomMember, RoomTopic, RoomEncryption, RoomEncryptedMessage,
+ Typing, Receipt, Unknown
};
explicit Event(Type type) : _type(type) { }
@@ -94,6 +95,7 @@ namespace QMatrixClient
return evs;
}
+ /** This class corresponds to m.room.* events */
class RoomEvent : public Event
{
Q_GADGET
diff --git a/events/receiptevent.cpp b/events/receiptevent.cpp
index 3d6be9f1..646bb989 100644
--- a/events/receiptevent.cpp
+++ b/events/receiptevent.cpp
@@ -66,6 +66,11 @@ ReceiptEvent::ReceiptEvent(const QJsonObject& obj)
}
_eventsWithReceipts.push_back({eventIt.key(), receipts});
}
- _unreadMessages = obj["x-qmatrixclient.unread_messages"].toBool();
+ static const auto UnreadMsgsKey =
+ QStringLiteral("x-qmatrixclient.unread_messages");
+ if (contents.contains(UnreadMsgsKey))
+ _unreadMessages = contents["x-qmatrixclient.unread_messages"].toBool();
+ else
+ _unreadMessages = obj["x-qmatrixclient.unread_messages"].toBool();
}