aboutsummaryrefslogtreecommitdiff
path: root/lib/crypto/qolmmessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/crypto/qolmmessage.cpp')
-rw-r--r--lib/crypto/qolmmessage.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/crypto/qolmmessage.cpp b/lib/crypto/qolmmessage.cpp
new file mode 100644
index 00000000..ae98d52f
--- /dev/null
+++ b/lib/crypto/qolmmessage.cpp
@@ -0,0 +1,42 @@
+// SPDX-FileCopyrightText: 2021 Alexey Andreyev <aa13q@ya.ru>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#ifdef Quotient_E2EE_ENABLED
+#include "qolmmessage.h"
+
+using namespace Quotient;
+
+QOlmMessage::QOlmMessage(const QByteArray &ciphertext, QOlmMessage::Type type)
+ : QByteArray(std::move(ciphertext))
+ , m_messageType(type)
+{
+ Q_ASSERT_X(!ciphertext.isEmpty(), "olm message", "Ciphertext is empty");
+}
+
+QOlmMessage::QOlmMessage(const QOlmMessage &message)
+ : QByteArray(message)
+ , m_messageType(message.type())
+{
+}
+
+QOlmMessage::Type QOlmMessage::type() const
+{
+ return m_messageType;
+}
+
+QByteArray QOlmMessage::toCiphertext() const
+{
+ return QByteArray(*this);
+}
+
+QOlmMessage QOlmMessage::fromCiphertext(const QByteArray &ciphertext)
+{
+ return QOlmMessage(ciphertext, QOlmMessage::General);
+}
+
+
+#endif // Quotient_E2EE_ENABLED
+
+
+