aboutsummaryrefslogtreecommitdiff
path: root/lib/olm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/olm')
-rw-r--r--lib/olm/message.cpp15
-rw-r--r--lib/olm/message.h7
-rw-r--r--lib/olm/qolmaccount.cpp2
-rw-r--r--lib/olm/session.cpp4
-rw-r--r--lib/olm/session.h4
5 files changed, 19 insertions, 13 deletions
diff --git a/lib/olm/message.cpp b/lib/olm/message.cpp
index 0998a66b..634a6f0c 100644
--- a/lib/olm/message.cpp
+++ b/lib/olm/message.cpp
@@ -8,19 +8,15 @@
using namespace Quotient;
Message::Message(const QByteArray &ciphertext, Message::Type type)
- : QByteArray(std::move(ciphertext)), _messageType(type)
-{
- Q_ASSERT_X(!ciphertext.isEmpty(), "olm message", "Ciphertext is empty");
-}
-
-Message::Message(QByteArray ciphertext) : QByteArray(std::move(ciphertext))
+ : QByteArray(std::move(ciphertext))
+ , m_messageType(type)
{
Q_ASSERT_X(!ciphertext.isEmpty(), "olm message", "Ciphertext is empty");
}
Message::Type Message::type() const
{
- return _messageType;
+ return m_messageType;
}
QByteArray Message::toCiphertext() const
@@ -28,6 +24,11 @@ QByteArray Message::toCiphertext() const
return QByteArray(*this);
}
+Message Message::fromCiphertext(const QByteArray &ciphertext)
+{
+ return Message(ciphertext, Message::General);
+}
+
#endif // Quotient_E2EE_ENABLED
diff --git a/lib/olm/message.h b/lib/olm/message.h
index 6c8ab485..067d9b5a 100644
--- a/lib/olm/message.h
+++ b/lib/olm/message.h
@@ -28,16 +28,15 @@ public:
Q_ENUM(Type)
Message() = default;
- explicit Message(const QByteArray& ciphertext, Type type = General);
- explicit Message(QByteArray ciphertext);
+ explicit Message(const QByteArray &ciphertext, Type type = General);
- static Message fromCiphertext(QByteArray ciphertext);
+ static Message fromCiphertext(const QByteArray &ciphertext);
Q_INVOKABLE Type type() const;
Q_INVOKABLE QByteArray toCiphertext() const;
private:
- Type _messageType = General;
+ Type m_messageType = General;
};
diff --git a/lib/olm/qolmaccount.cpp b/lib/olm/qolmaccount.cpp
index 9c47bc87..ef51a395 100644
--- a/lib/olm/qolmaccount.cpp
+++ b/lib/olm/qolmaccount.cpp
@@ -199,11 +199,13 @@ OlmAccount *Quotient::QOlmAccount::data()
std::variant<std::unique_ptr<QOlmSession>, OlmError> QOlmAccount::createInboundSession(const Message &preKeyMessage)
{
+ Q_ASSERT(preKeyMessage.type() == Message::PreKey);
return QOlmSession::createInboundSession(this, preKeyMessage);
}
std::variant<std::unique_ptr<QOlmSession>, OlmError> QOlmAccount::createInboundSessionFrom(const QByteArray &theirIdentityKey, const Message &preKeyMessage)
{
+ Q_ASSERT(preKeyMessage.type() == Message::PreKey);
return QOlmSession::createInboundSessionFrom(this, theirIdentityKey, preKeyMessage);
}
diff --git a/lib/olm/session.cpp b/lib/olm/session.cpp
index b5cd7b81..f6cab650 100644
--- a/lib/olm/session.cpp
+++ b/lib/olm/session.cpp
@@ -152,9 +152,9 @@ QByteArray QOlmSession::sessionId() const
return idBuffer;
}
-QOlmSession::QOlmSession(OlmSession *session): m_session(session)
+QOlmSession::QOlmSession(OlmSession *session)
+ : m_session(session)
{
-
}
#endif // Quotient_E2EE_ENABLED
diff --git a/lib/olm/session.h b/lib/olm/session.h
index e3a52c88..89f5d822 100644
--- a/lib/olm/session.h
+++ b/lib/olm/session.h
@@ -14,6 +14,8 @@
namespace Quotient {
class QOlmAccount;
+class QOlmSession;
+
//! Either an outbound or inbound session for secure communication.
class QOlmSession
@@ -43,6 +45,8 @@ private:
OlmSession* m_session;
};
+//using QOlmSessionPtr = std::unique_ptr<QOlmSession>;
+
} //namespace Quotient
#endif // Quotient_E2EE_ENABLED