diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-09-26 20:57:28 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-02 08:20:40 +0900 |
commit | 79f52e3f6142afd48d30b842618ef0867072443b (patch) | |
tree | 5fb2699ed7d3ee449a6a2b6a754e810de962abcf | |
parent | faa395c5e3b148217073dc9d2953084d68d685bd (diff) | |
download | libquotient-79f52e3f6142afd48d30b842618ef0867072443b.tar.gz libquotient-79f52e3f6142afd48d30b842618ef0867072443b.zip |
Introduce EncryptionEvent class
This allows to detect if a room has been encrypted (no room state, just
an event as of yet). Closes #84.
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | events/encryptedevent.cpp | 5 | ||||
-rw-r--r-- | events/encryptedevent.h | 39 | ||||
-rw-r--r-- | events/event.cpp | 3 | ||||
-rw-r--r-- | events/event.h | 4 |
5 files changed, 50 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e55335ec..35eec50e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ set(libqmatrixclient_SRCS events/roomtopicevent.cpp events/typingevent.cpp events/receiptevent.cpp + events/encryptedevent.cpp jobs/basejob.cpp jobs/checkauthmethods.cpp jobs/passwordlogin.cpp 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 |