aboutsummaryrefslogtreecommitdiff
path: root/src/client/QXmppSendStanzaParams.cpp
blob: 9711750dbebad961a53a3a82ff3dfd0d79627dea (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#include "QXmppSendStanzaParams.h"

#include <QVector>

using namespace QXmpp;

///
/// \class QXmppSendStanzaParams
///
/// Contains additional parameters for sending stanzas.
///
/// \since QXmpp 1.5
///

class QXmppSendStanzaParamsPrivate : public QSharedData
{
public:
    TrustLevels acceptedTrustLevels;
    QVector<QString> encryptionJids;
};

QXmppSendStanzaParams::QXmppSendStanzaParams()
    : d(new QXmppSendStanzaParamsPrivate)
{
}

/// Copy-constructor
QXmppSendStanzaParams::QXmppSendStanzaParams(const QXmppSendStanzaParams &other) = default;
/// Move-constructor
QXmppSendStanzaParams::QXmppSendStanzaParams(QXmppSendStanzaParams &&) = default;
QXmppSendStanzaParams::~QXmppSendStanzaParams() = default;
/// Assignment operator
QXmppSendStanzaParams &QXmppSendStanzaParams::operator=(const QXmppSendStanzaParams &) = default;
/// Move-assignment operator
QXmppSendStanzaParams &QXmppSendStanzaParams::operator=(QXmppSendStanzaParams &&) = default;

///
/// Returns the list of JIDs that the stanza should be encrypted for.
///
/// If this is empty, the stanza should be encrypted for the recipient.
/// This option is useful for groupchats.
///
QVector<QString> QXmppSendStanzaParams::encryptionJids() const
{
    return d->encryptionJids;
}

///
/// Sets the list of JIDs that the stanza should be encrypted for.
///
/// If this is empty, the stanza should be encrypted for the recipient.
/// This option is useful for groupchats.
///
void QXmppSendStanzaParams::setEncryptionJids(QVector<QString> encryptionJids)
{
    d->encryptionJids = std::move(encryptionJids);
}

///
/// Returns the possible trust levels a key must have to be used for encryption.
///
/// If no trust levels are set, the encryption manager uses an own default.
///
/// \return the trust levels of the keys used for encryption
///
std::optional<TrustLevels> QXmppSendStanzaParams::acceptedTrustLevels() const
{
    if (d->acceptedTrustLevels) {
        return d->acceptedTrustLevels;
    }
    return {};
}

///
/// Sets the possible trust levels a key must have to be used for encryption.
///
/// If no trust levels are set, the encryption manager uses an own default.
///
/// \param trustLevels trust levels of the keys used for encryption
///
void QXmppSendStanzaParams::setAcceptedTrustLevels(std::optional<TrustLevels> trustLevels)
{
    d->acceptedTrustLevels = trustLevels.value_or(QXmpp::TrustLevels());
}