aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-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
-rw-r--r--libqmatrixclient.pri8
-rw-r--r--room.cpp8
-rw-r--r--room.h2
9 files changed, 67 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 44f63c79..0d2f688f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,6 +75,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
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();
}
diff --git a/libqmatrixclient.pri b/libqmatrixclient.pri
index c352e186..36f6429c 100644
--- a/libqmatrixclient.pri
+++ b/libqmatrixclient.pri
@@ -1,7 +1,7 @@
QT += network
CONFIG += c++11
-INCLUDEPATH += $$PWD $$PWD/kcoreaddons/src/lib/jobs
+INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/connectiondata.h \
@@ -29,6 +29,9 @@ HEADERS += \
$$PWD/jobs/syncjob.h \
$$PWD/jobs/mediathumbnailjob.h \
$$PWD/jobs/logoutjob.h \
+ $$PWD/jobs/setroomstatejob.h \
+ $$PWD/jobs/generated/inviting.h \
+ $$PWD/jobs/generated/kicking.h \
$$PWD/logging.h \
$$PWD/settings.h
@@ -57,5 +60,8 @@ SOURCES += \
$$PWD/jobs/syncjob.cpp \
$$PWD/jobs/mediathumbnailjob.cpp \
$$PWD/jobs/logoutjob.cpp \
+ $$PWD/jobs/setroomstatejob.cpp \
+ $$PWD/jobs/generated/inviting.cpp \
+ $$PWD/jobs/generated/kicking.cpp \
$$PWD/logging.cpp \
$$PWD/settings.cpp
diff --git a/room.cpp b/room.cpp
index 2ba3766a..05b16b65 100644
--- a/room.cpp
+++ b/room.cpp
@@ -155,7 +155,7 @@ Room::~Room()
delete d;
}
-QString Room::id() const
+const QString& Room::id() const
{
return d->id;
}
@@ -994,14 +994,12 @@ QJsonObject Room::Private::toJson() const
QJsonObject lastReadEvent;
lastReadEvent.insert(q->readMarkerEventId(), receipt);
+ lastReadEvent.insert("x-qmatrixclient.unread_messages",
+ unreadMessages);
QJsonObject receiptsObj;
receiptsObj.insert("type", QStringLiteral("m.receipt"));
receiptsObj.insert("content", lastReadEvent);
- // In extension of the spec we add a hint to the receipt event
- // to allow setting the unread indicator without downloading
- // and analysing the timeline.
- receiptsObj.insert("x-qmatrixclient.unread_messages", unreadMessages);
ephemeralEvents.append(receiptsObj);
}
diff --git a/room.h b/room.h
index 393dced3..455ef6cc 100644
--- a/room.h
+++ b/room.h
@@ -82,7 +82,7 @@ namespace QMatrixClient
Connection* connection() const;
User* localUser() const;
- QString id() const;
+ const QString& id() const;
QString name() const;
QStringList aliases() const;
QString canonicalAlias() const;