aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt13
-rw-r--r--lib/connection.cpp12
-rw-r--r--lib/events/roomevent.cpp2
-rw-r--r--lib/events/roomevent.h5
-rw-r--r--lib/room.cpp6
5 files changed, 24 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a84a70fb..43fed3e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,11 +83,12 @@ else()
set(QtExtraModules "Multimedia") # See #483
endif()
string(REGEX REPLACE "^(.).*" "Qt\\1" Qt ${QtMinVersion}) # makes "Qt5" or "Qt6"
-find_package(${Qt} ${QtMinVersion} REQUIRED Core Network Gui Test Sql ${QtExtraModules})
+find_package(${Qt} ${QtMinVersion} REQUIRED Core Network Gui Test ${QtExtraModules})
get_filename_component(Qt_Prefix "${${Qt}_DIR}/../../../.." ABSOLUTE)
message(STATUS "Using Qt ${${Qt}_VERSION} at ${Qt_Prefix}")
if (${PROJECT_NAME}_ENABLE_E2EE)
+ find_package(${Qt} ${QtMinVersion} REQUIRED Sql)
find_package(Olm 3.2.1 REQUIRED)
set_package_properties(Olm PROPERTIES
DESCRIPTION "Implementation of the Olm and Megolm cryptographic ratchets"
@@ -107,9 +108,9 @@ if (${PROJECT_NAME}_ENABLE_E2EE)
if (OpenSSL_FOUND)
message(STATUS "Using OpenSSL ${OpenSSL_VERSION} at ${OpenSSL_DIR}")
endif()
+ find_package(${Qt}Keychain REQUIRED)
endif()
-find_package(${Qt}Keychain REQUIRED)
# Set up source files
list(APPEND lib_SRCS
@@ -133,7 +134,6 @@ list(APPEND lib_SRCS
lib/eventitem.cpp
lib/accountregistry.cpp
lib/mxcreply.cpp
- lib/database.cpp
lib/events/event.cpp
lib/events/roomevent.cpp
lib/events/stateevent.cpp
@@ -164,6 +164,7 @@ list(APPEND lib_SRCS
)
if (${PROJECT_NAME}_ENABLE_E2EE)
list(APPEND lib_SRCS
+ lib/database.cpp
lib/e2ee/qolmaccount.cpp
lib/e2ee/qolmsession.cpp
lib/e2ee/qolminboundsession.cpp
@@ -323,12 +324,14 @@ target_include_directories(${PROJECT_NAME} PUBLIC
if (${PROJECT_NAME}_ENABLE_E2EE)
target_link_libraries(${PROJECT_NAME} Olm::Olm
OpenSSL::Crypto
- OpenSSL::SSL)
+ OpenSSL::SSL
+ ${Qt}::Sql
+ ${QTKEYCHAIN_LIBRARIES})
set(FIND_DEPS "find_dependency(Olm)
find_dependency(OpenSSL)") # For QuotientConfig.cmake.in
endif()
-target_link_libraries(${PROJECT_NAME} ${Qt}::Core ${Qt}::Network ${Qt}::Gui ${Qt}::Sql ${QTKEYCHAIN_LIBRARIES})
+target_link_libraries(${PROJECT_NAME} ${Qt}::Core ${Qt}::Network ${Qt}::Gui)
if (Qt STREQUAL Qt5) # See #483
target_link_libraries(${PROJECT_NAME} ${Qt}::Multimedia)
diff --git a/lib/connection.cpp b/lib/connection.cpp
index b7aaca86..433dd942 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -7,9 +7,6 @@
#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"
@@ -40,6 +37,8 @@
#ifdef Quotient_E2EE_ENABLED
# include "e2ee/qolmaccount.h"
# include "e2ee/qolmutils.h"
+# include "encryptionmanager.h"
+# include "database.h"
#endif // Quotient_E2EE_ENABLED
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
@@ -62,7 +61,6 @@
# include <qt5keychain/keychain.h>
#endif
-#include "database.h"
using namespace Quotient;
@@ -274,9 +272,9 @@ Connection::Connection(const QUrl& server, QObject* parent)
connect(qApp, &QCoreApplication::aboutToQuit, this, [this](){
saveOlmAccount();
});
+ Database::instance();
#endif
d->q = this; // All d initialization should occur before this line
- Database::instance();
}
Connection::Connection(QObject* parent) : Connection({}, parent) {}
@@ -442,15 +440,13 @@ void Connection::Private::loginToServer(LoginArgTs&&... loginArgs)
auto loginJob =
q->callApi<LoginJob>(std::forward<LoginArgTs>(loginArgs)...);
connect(loginJob, &BaseJob::success, q, [this, loginJob] {
- Database::instance().clear(loginJob->userId());
data->setToken(loginJob->accessToken().toLatin1());
data->setDeviceId(loginJob->deviceId());
completeSetup(loginJob->userId());
#ifndef Quotient_E2EE_ENABLED
qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off.";
#else // Quotient_E2EE_ENABLED
- //encryptionManager->uploadIdentityKeys(q);
- //encryptionManager->uploadOneTimeKeys(q);
+ Database::instance().clear(loginJob->userId());
#endif // Quotient_E2EE_ENABLED
});
connect(loginJob, &BaseJob::failure, q, [this, loginJob] {
diff --git a/lib/events/roomevent.cpp b/lib/events/roomevent.cpp
index b99d1381..dbce2255 100644
--- a/lib/events/roomevent.cpp
+++ b/lib/events/roomevent.cpp
@@ -127,6 +127,7 @@ CallEventBase::CallEventBase(Event::Type type, const QJsonObject& json)
qCWarning(EVENTS) << id() << "is a call event with an empty call id";
}
+#ifdef Quotient_E2EE_ENABLED
void RoomEvent::setOriginalEvent(event_ptr_tt<RoomEvent> originalEvent)
{
_originalEvent = std::move(originalEvent);
@@ -139,3 +140,4 @@ const QJsonObject RoomEvent::encryptedJson() const
}
return _originalEvent->fullJson();
}
+#endif
diff --git a/lib/events/roomevent.h b/lib/events/roomevent.h
index 35527a62..36b45f09 100644
--- a/lib/events/roomevent.h
+++ b/lib/events/roomevent.h
@@ -60,15 +60,20 @@ public:
//! callback for that in RoomEvent.
void addId(const QString& newId);
+#ifdef Quotient_E2EE_ENABLED
void setOriginalEvent(event_ptr_tt<RoomEvent> originalEvent);
const QJsonObject encryptedJson() const;
+#endif
protected:
void dumpTo(QDebug dbg) const override;
private:
event_ptr_tt<RedactionEvent> _redactedBecause;
+
+#ifdef Quotient_E2EE_ENABLED
event_ptr_tt<RoomEvent> _originalEvent;
+#endif
};
using RoomEventPtr = event_ptr_tt<RoomEvent>;
using RoomEvents = EventsArray<RoomEvent>;
diff --git a/lib/room.cpp b/lib/room.cpp
index b3a092f3..7d608520 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -68,9 +68,9 @@
#include "e2ee/qolmaccount.h"
#include "e2ee/qolmerrors.h"
#include "e2ee/qolminboundsession.h"
+#include "database.h"
#endif // Quotient_E2EE_ENABLED
-#include "database.h"
using namespace Quotient;
using namespace std::placeholders;
@@ -2593,6 +2593,7 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events)
QElapsedTimer et;
et.start();
+#ifdef Quotient_E2EE_ENABLED
for(long unsigned int i = 0; i < events.size(); i++) {
if(auto* encrypted = eventCast<EncryptedEvent>(events[i])) {
auto decrypted = q->decryptMessage(*encrypted);
@@ -2604,6 +2605,7 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events)
}
}
}
+#endif
{
// Pre-process redactions and edits so that events that get
@@ -2758,6 +2760,7 @@ void Room::Private::addHistoricalMessageEvents(RoomEvents&& events)
Changes changes {};
+#ifdef Quotient_E2EE_ENABLED
for(long unsigned int i = 0; i < events.size(); i++) {
if(auto* encrypted = eventCast<EncryptedEvent>(events[i])) {
auto decrypted = q->decryptMessage(*encrypted);
@@ -2769,6 +2772,7 @@ void Room::Private::addHistoricalMessageEvents(RoomEvents&& events)
}
}
}
+#endif
// In case of lazy-loading new members may be loaded with historical
// messages. Also, the cache doesn't store events with empty content;