QXmpp Version: 1.12.0
Loading...
Searching...
No Matches
QXmppGlobal.h
1// SPDX-FileCopyrightText: 2010 Manjeet Dahiya <manjeetdahiya@gmail.com>
2// SPDX-FileCopyrightText: 2017 Niels Ole Salscheider <niels_ole@salscheider-online.de>
3// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
4// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
5//
6// SPDX-License-Identifier: LGPL-2.1-or-later
7
8#ifndef QXMPPGLOBAL_H
9#define QXMPPGLOBAL_H
10
11#include "qxmpp_export.h"
12
13#include <QString>
14
15struct QXmppError;
16
17#define QXMPP_AUTOTEST_EXPORT
18#define QXMPP_PRIVATE_EXPORT QXMPP_EXPORT
19
29#define QXMPP_VERSION QT_VERSION_CHECK(QXMPP_VERSION_MAJOR, QXMPP_VERSION_MINOR, QXMPP_VERSION_PATCH)
30
34inline QLatin1String QXmppVersion()
35{
36 return QLatin1String(
37 QT_STRINGIFY(QXMPP_VERSION_MAJOR) "." QT_STRINGIFY(QXMPP_VERSION_MINOR) "." QT_STRINGIFY(QXMPP_VERSION_PATCH));
38}
39
40// This sets which deprecated functions should still be usable
41// It works exactly like QT_DISABLE_DEPRECATED_BEFORE
42#ifndef QXMPP_DISABLE_DEPRECATED_BEFORE
43#define QXMPP_DISABLE_DEPRECATED_BEFORE 0x0
44#endif
45
46// This works exactly like QT_DEPRECATED_SINCE, but checks QXMPP_DISABLE_DEPRECATED_BEFORE instead.
47#define QXMPP_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QXMPP_DISABLE_DEPRECATED_BEFORE)
48
49// workaround for Qt < 5.12
50#ifndef Q_DECL_ENUMERATOR_DEPRECATED_X
51#define Q_DECL_ENUMERATOR_DEPRECATED_X(msg)
52#endif
53
54#ifndef QT_WARNING_DISABLE_DEPRECATED
55#define QT_WARNING_DISABLE_DEPRECATED
56#endif
57
58// Adds constructor and operator declarations to a ".h" file corresponding to the rule of six.
59// A default constructor has to be declared manually.
60#define QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(name) \
61 name(const name &); \
62 name(name &&) noexcept; \
63 ~name(); \
64 name &operator=(const name &); \
65 name &operator=(name &&) noexcept;
66
67// Adds constructor and operator definitions to a ".cpp" file corresponding to the rule of six.
68// A default constructor has to be defined manually.
69#define QXMPP_PRIVATE_DEFINE_RULE_OF_SIX(name) \
70 name::name(const name &) = default; \
71 name::name(name &&) noexcept = default; \
72 name::~name() = default; \
73 name &name::operator=(const name &) = default; \
74 name &name::operator=(name &&) noexcept = default;
75// Same as QXMPP_PRIVATE_DEFINE_RULE_OF_SIX but for an inner class.
76#define QXMPP_PRIVATE_DEFINE_RULE_OF_SIX_INNER(outer, name) \
77 outer::name::name(const outer::name &) = default; \
78 outer::name::name(outer::name &&) noexcept = default; \
79 outer::name::~name() = default; \
80 outer::name &outer::name::operator=(const outer::name &) = default; \
81 outer::name &outer::name::operator=(outer::name &&) noexcept = default;
82
90namespace QXmpp {
91
116
117// Keep in sync with namespaces and names in Global/Message.cpp!
118
119#if QXMPP_DEPRECATED_SINCE(1, 5)
136#endif
137};
138
151
160inline constexpr bool operator&(SceMode mode1, SceMode mode2)
161{
162 return mode1 == SceAll || mode1 == mode2;
163}
164
170enum Cipher {
171 Aes128GcmNoPad,
172 Aes256GcmNoPad,
173 Aes256CbcPkcs7,
174};
175
181struct Success { };
182
188struct Cancelled { };
189
197struct TimeoutError { };
198
204template<typename T>
205using Result = std::variant<T, QXmppError>;
206
207} // namespace QXmpp
208
209#endif // QXMPPGLOBAL_H
Definition Algorithms.h:14
std::variant< T, QXmppError > Result
Definition QXmppGlobal.h:205
Cipher
Definition QXmppGlobal.h:170
constexpr bool operator&(SceMode mode1, SceMode mode2)
Definition QXmppGlobal.h:160
SceMode
Definition QXmppGlobal.h:146
@ SceSensitive
Only processes sensitive elements that should be encrypted.
Definition QXmppGlobal.h:149
@ SceAll
Processes all known elements.
Definition QXmppGlobal.h:147
@ ScePublic
Only processes 'public' elements (e.g. needed for routing).
Definition QXmppGlobal.h:148
EncryptionMethod
Definition QXmppGlobal.h:99
@ LegacyOpenPgp
XEP-0027: Current Jabber OpenPGP Usage
Definition QXmppGlobal.h:107
@ OMEMO
Definition QXmppGlobal.h:135
@ Omemo0
XEP-0384: OMEMO Encryption
Definition QXmppGlobal.h:111
@ Ox
XEP-0373: OpenPGP for XMPP
Definition QXmppGlobal.h:109
@ Omemo2
XEP-0384: OMEMO Encryption since version 0.8
Definition QXmppGlobal.h:115
@ OTR
Definition QXmppGlobal.h:123
@ Otr
XEP-0364: Current Off-the-Record Messaging Usage
Definition QXmppGlobal.h:105
@ NoEncryption
No encryption.
Definition QXmppGlobal.h:101
@ OX
Definition QXmppGlobal.h:131
@ LegacyOpenPGP
Definition QXmppGlobal.h:127
@ Omemo1
XEP-0384: OMEMO Encryption since version 0.4
Definition QXmppGlobal.h:113
@ UnknownEncryption
Unknown encryption.
Definition QXmppGlobal.h:103
Definition QXmppError.h:17
Definition QXmppGlobal.h:188
Definition QXmppGlobal.h:181
Definition QXmppGlobal.h:197