aboutsummaryrefslogtreecommitdiff
path: root/lib/olm/message.cpp
blob: ac7038aecd1d632c1cc6f68320a05cde70f20883 (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
36
37
38
39
40
41
42
// SPDX-FileCopyrightText: 2021 Alexey Andreyev <aa13q@ya.ru>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#ifdef Quotient_E2EE_ENABLED
#include "olm/message.h"

using namespace Quotient;

Message::Message(const QByteArray &ciphertext, Message::Type type)
    : QByteArray(std::move(ciphertext))
    , m_messageType(type)
{
    Q_ASSERT_X(!ciphertext.isEmpty(), "olm message", "Ciphertext is empty");
}

Message::Message(const Message &message)
    : QByteArray(message)
    , m_messageType(message.type())
{
}

Message::Type Message::type() const
{
    return m_messageType;
}

QByteArray Message::toCiphertext() const
{
    return QByteArray(*this);
}

Message Message::fromCiphertext(const QByteArray &ciphertext)
{
    return Message(ciphertext, Message::General);
}


#endif // Quotient_E2EE_ENABLED