aboutsummaryrefslogtreecommitdiff
path: root/lib/e2ee/qolmmessage.cpp
blob: 81b166b0fd89d745170ec97698a84cc33a333c45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-FileCopyrightText: 2021 Alexey Andreyev <aa13q@ya.ru>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#include "qolmmessage.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::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);
}