aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorAlexey Andreev <aa13q@ya.ru>2020-02-25 20:06:19 +0300
committerAlexey Andreev <aa13q@ya.ru>2020-03-12 17:11:03 +0300
commit56d9a0addaabf2cec78e1c82a9846997a3669736 (patch)
tree2f4ccea66fd69d718356f678c4279a29151b2a5c /lib/room.cpp
parent8ff15ee94fc39eef1279d479d12b1cbdec9f4ac5 (diff)
downloadlibquotient-56d9a0addaabf2cec78e1c82a9846997a3669736.tar.gz
libquotient-56d9a0addaabf2cec78e1c82a9846997a3669736.zip
E2EE: Make building E2EE optional. Contributes to #369
Signed-off-by: Alexey Andreev <aa13q@ya.ru>
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index ecb5a7ad..5a966ceb 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -69,9 +69,11 @@
#include <cmath>
#include <functional>
+#ifdef Quotient_E2EE_ENABLED
#include <account.h> // QtOlm
#include <errors.h> // QtOlm
#include <groupsession.h> // QtOlm
+#endif // Quotient_E2EE_ENABLED
using namespace Quotient;
using namespace QtOlm;
@@ -342,6 +344,7 @@ public:
QJsonObject toJson() const;
+#ifdef Quotient_E2EE_ENABLED
// A map from <sessionId, messageIndex> to <event_id, origin_server_ts>
QHash<QPair<QString, uint32_t>, QPair<QString, QDateTime>>
groupSessionIndexRecord; // TODO: cache
@@ -424,6 +427,7 @@ public:
return decrypted.first;
}
+#endif // Quotient_E2EE_ENABLED
private:
using users_shortlist_t = std::array<User*, 3>;
@@ -1238,6 +1242,11 @@ const StateEventBase* Room::getCurrentState(const QString& evtType,
RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent)
{
+#ifndef Quotient_E2EE_ENABLED
+ Q_UNUSED(encryptedEvent);
+ qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off.";
+ return {};
+#else // Quotient_E2EE_ENABLED
if (encryptedEvent.algorithm() == MegolmV1AesSha2AlgoKey) {
QString decrypted = d->groupSessionDecryptMessage(
encryptedEvent.ciphertext(), encryptedEvent.senderKey(),
@@ -1252,10 +1261,17 @@ RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent)
qCDebug(E2EE) << "Algorithm of the encrypted event with id"
<< encryptedEvent.id() << "is not for the current device";
return {};
+#endif // Quotient_E2EE_ENABLED
}
void Room::handleRoomKeyEvent(RoomKeyEvent* roomKeyEvent, QString senderKey)
{
+#ifndef Quotient_E2EE_ENABLED
+ Q_UNUSED(roomKeyEvent);
+ Q_UNUSED(senderKey);
+ qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off.";
+ return;
+#else // Quotient_E2EE_ENABLED
if (roomKeyEvent->algorithm() != MegolmV1AesSha2AlgoKey) {
qCWarning(E2EE) << "Ignoring unsupported algorithm"
<< roomKeyEvent->algorithm() << "in m.room_key event";
@@ -1265,6 +1281,7 @@ void Room::handleRoomKeyEvent(RoomKeyEvent* roomKeyEvent, QString senderKey)
qCDebug(E2EE) << "added new inboundGroupSession:"
<< d->groupSessions.count();
}
+#endif // Quotient_E2EE_ENABLED
}
int Room::joinedCount() const