aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r--lib/connection.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 98c8a4bc..6ad24fba 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -19,7 +19,9 @@
#include "connection.h"
#include "connectiondata.h"
+#ifdef Quotient_E2EE_ENABLED
#include "encryptionmanager.h"
+#endif // Quotient_E2EE_ENABLED
#include "room.h"
#include "settings.h"
#include "user.h"
@@ -43,7 +45,9 @@
#include "jobs/mediathumbnailjob.h"
#include "jobs/syncjob.h"
+#ifdef Quotient_E2EE_ENABLED
#include "account.h" // QtOlm
+#endif // Quotient_E2EE_ENABLED
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
@@ -107,7 +111,9 @@ public:
GetCapabilitiesJob* capabilitiesJob = nullptr;
GetCapabilitiesJob::Capabilities capabilities;
+#ifdef Quotient_E2EE_ENABLED
QScopedPointer<EncryptionManager> encryptionManager;
+#endif // Quotient_E2EE_ENABLED
SyncJob* syncJob = nullptr;
@@ -153,6 +159,10 @@ public:
RoomEventPtr sessionDecryptMessage(const EncryptedEvent& encryptedEvent)
{
+#ifndef Quotient_E2EE_ENABLED
+ qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off.";
+ return {};
+#else // Quotient_E2EE_ENABLED
if (encryptedEvent.algorithm() != OlmV1Curve25519AesSha2AlgoKey)
{
return {};
@@ -208,6 +218,7 @@ public:
}
return decryptedEvent;
+#endif // Quotient_E2EE_ENABLED
}
};
@@ -304,8 +315,12 @@ void Connection::doConnectToServer(const QString& user, const QString& password,
connect(loginJob, &BaseJob::success, this, [this, loginJob] {
d->connectWithToken(loginJob->userId(), loginJob->accessToken(),
loginJob->deviceId());
+#ifndef Quotient_E2EE_ENABLED
+ qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off.";
+#else // Quotient_E2EE_ENABLED
d->encryptionManager->uploadIdentityKeys(this);
d->encryptionManager->uploadOneTimeKeys(this);
+#endif // Quotient_E2EE_ENABLED
});
connect(loginJob, &BaseJob::failure, this, [this, loginJob] {
emit loginError(loginJob->errorString(), loginJob->rawDataSample());
@@ -362,12 +377,16 @@ void Connection::Private::connectWithToken(const QString& userId,
qCDebug(MAIN) << "Using server" << data->baseUrl().toDisplayString()
<< "by user" << userId << "from device" << deviceId;
AccountSettings accountSettings(userId);
+#ifndef Quotient_E2EE_ENABLED
+ qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off.";
+#else // Quotient_E2EE_ENABLED
encryptionManager.reset(
new EncryptionManager(accountSettings.encryptionAccountPickle()));
if (accountSettings.encryptionAccountPickle().isEmpty()) {
accountSettings.setEncryptionAccountPickle(
encryptionManager->olmAccountPickle());
}
+#endif // Quotient_E2EE_ENABLED
emit q->stateChanged();
emit q->connected();
q->reloadCapabilities();
@@ -594,6 +613,9 @@ void Connection::onSyncSuccess(SyncData&& data, bool fromCache)
d->dcLocalAdditions.clear();
d->dcLocalRemovals.clear();
}
+#ifndef Quotient_E2EE_ENABLED
+ qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off.";
+#else // Quotient_E2EE_ENABLED
// handling m.room_key to-device encrypted event
for (auto&& toDeviceEvent : data.takeToDeviceEvents()) {
if (toDeviceEvent->type() == EncryptedEvent::typeId()) {
@@ -645,6 +667,7 @@ void Connection::onSyncSuccess(SyncData&& data, bool fromCache)
d->encryptionManager->updateOneTimeKeyCounts(this,
deviceOneTimeKeysCount);
}
+#endif // Quotient_E2EE_ENABLED
}
void Connection::stopSync()
@@ -1068,10 +1091,12 @@ QString Connection::deviceId() const { return d->data->deviceId(); }
QByteArray Connection::accessToken() const { return d->data->accessToken(); }
+#ifdef Quotient_E2EE_ENABLED
QtOlm::Account* Connection::olmAccount() const
{
return d->encryptionManager->account();
}
+#endif // Quotient_E2EE_ENABLED
SyncJob* Connection::syncJob() const { return d->syncJob; }