Skip to content

Commit

Permalink
Introduce EncryptionEvent class
Browse files Browse the repository at this point in the history
This allows to detect if a room has been encrypted (no room state, just
an event as of yet). Closes #84.
  • Loading branch information
KitsuneRal authored and a-andreyev committed Jun 25, 2019
1 parent 90623dd commit 1cf6773
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ set(libqmatrixclient_SRCS
lib/events/callhangupevent.cpp
lib/events/callinviteevent.cpp
lib/events/directchatevent.cpp
lib/events/encryptionevent.cpp
lib/jobs/requestdata.cpp
lib/jobs/basejob.cpp
lib/jobs/syncjob.cpp
Expand Down
5 changes: 5 additions & 0 deletions lib/events/encryptionevent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Created by rusakov on 26/09/2017.
//

#include "encryptionevent.h"
43 changes: 43 additions & 0 deletions lib/events/encryptionevent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/******************************************************************************
* 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 "roomevent.h"

namespace QMatrixClient
{
class EncryptionEvent : public RoomEvent
{
public:
DEFINE_EVENT_TYPEID("m.room.encryption", EncryptionEvent)

explicit EncryptionEvent(const QJsonObject& obj)
: RoomEvent(typeId(), obj)
, _algorithm(contentJson()["algorithm"].toString())
{ }

QString algorithm() const { return _algorithm; }

private:
QString _algorithm;
};
REGISTER_EVENT_TYPE(EncryptionEvent)
DEFINE_EVENTTYPE_ALIAS(Encryption, EncryptionEvent)
} // namespace QMatrixClient

0 comments on commit 1cf6773

Please sign in to comment.