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