aboutsummaryrefslogtreecommitdiff
path: root/lib/olm/session.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/olm/session.h')
-rw-r--r--lib/olm/session.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/olm/session.h b/lib/olm/session.h
index 3f1622c7..03b3514e 100644
--- a/lib/olm/session.h
+++ b/lib/olm/session.h
@@ -9,6 +9,7 @@
#include "olm/e2ee.h"
#include "olm/message.h"
#include "olm/errors.h"
+#include <QDebug>
#include "olm/qolmaccount.h"
namespace Quotient {
@@ -29,7 +30,7 @@ public:
//! Serialises an `QOlmSession` to encrypted Base64.
std::variant<QByteArray, OlmError> pickle(const PicklingMode &mode);
//! Deserialises from encrypted Base64 that was previously obtained by pickling a `QOlmSession`.
- static std::variant<std::unique_ptr<QOlmSession>, OlmError> unpickle(QByteArray &pickled, const PicklingMode &mode);
+ static std::variant<std::unique_ptr<QOlmSession>, OlmError> unpickle(const QByteArray &pickled, const PicklingMode &mode);
//! Encrypts a plaintext message using the session.
Message encrypt(const QString &plaintext);
@@ -50,6 +51,15 @@ public:
//! Checks if the 'prekey' message is for this in-bound session.
std::variant<bool, OlmError> matchesInboundSession(Message &preKeyMessage);
+ friend bool operator<(const QOlmSession& lhs, const QOlmSession& rhs)
+ {
+ return lhs.sessionId() < rhs.sessionId();
+ }
+
+ friend bool operator<(const std::unique_ptr<QOlmSession> &lhs, const std::unique_ptr<QOlmSession> &rhs) {
+ return *lhs < *rhs;
+ }
+
QOlmSession(OlmSession* session);
private:
//! Helper function for creating new sessions and handling errors.
@@ -58,6 +68,7 @@ private:
OlmSession* m_session;
};
+
//using QOlmSessionPtr = std::unique_ptr<QOlmSession>;
} //namespace Quotient