Loading...
Searching...
No Matches
QXmppGlobal.h
// SPDX-FileCopyrightText: 2010 Manjeet Dahiya <manjeetdahiya@gmail.com>
// SPDX-FileCopyrightText: 2017 Niels Ole Salscheider <niels_ole@salscheider-online.de>
// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPGLOBAL_H
#define QXMPPGLOBAL_H
#include "qxmpp_export.h"
#include <variant>
#include <QString>
struct QXmppError;
#define QXMPP_AUTOTEST_EXPORT
#define QXMPP_PRIVATE_EXPORT QXMPP_EXPORT
#define QXMPP_VERSION QT_VERSION_CHECK(QXMPP_VERSION_MAJOR, QXMPP_VERSION_MINOR, QXMPP_VERSION_PATCH)
inline QLatin1String QXmppVersion()
{
return QLatin1String(
QT_STRINGIFY(QXMPP_VERSION_MAJOR) "." QT_STRINGIFY(QXMPP_VERSION_MINOR) "." QT_STRINGIFY(QXMPP_VERSION_PATCH));
}
// This sets which deprecated functions should still be usable
// It works exactly like QT_DISABLE_DEPRECATED_BEFORE
#ifndef QXMPP_DISABLE_DEPRECATED_BEFORE
#define QXMPP_DISABLE_DEPRECATED_BEFORE 0x0
#endif
// This works exactly like QT_DEPRECATED_SINCE, but checks QXMPP_DISABLE_DEPRECATED_BEFORE instead.
#define QXMPP_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QXMPP_DISABLE_DEPRECATED_BEFORE)
// workaround for Qt < 5.12
#ifndef Q_DECL_ENUMERATOR_DEPRECATED_X
#define Q_DECL_ENUMERATOR_DEPRECATED_X(msg)
#endif
#ifndef QT_WARNING_DISABLE_DEPRECATED
#define QT_WARNING_DISABLE_DEPRECATED
#endif
// Adds constructor and operator declarations to a ".h" file corresponding to the rule of six.
// A default constructor has to be declared manually.
#define QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(name) \
name(const name &); \
name(name &&) noexcept; \
~name(); \
name &operator=(const name &); \
name &operator=(name &&) noexcept;
// Adds constructor and operator definitions to a ".cpp" file corresponding to the rule of six.
// A default constructor has to be defined manually.
#define QXMPP_PRIVATE_DEFINE_RULE_OF_SIX(name) \
name::name(const name &) = default; \
name::name(name &&) noexcept = default; \
name::~name() = default; \
name &name::operator=(const name &) = default; \
name &name::operator=(name &&) noexcept = default;
// Same as QXMPP_PRIVATE_DEFINE_RULE_OF_SIX but for an inner class.
#define QXMPP_PRIVATE_DEFINE_RULE_OF_SIX_INNER(outer, name) \
outer::name::name(const outer::name &) = default; \
outer::name::name(outer::name &&) noexcept = default; \
outer::name::~name() = default; \
outer::name &outer::name::operator=(const outer::name &) = default; \
outer::name &outer::name::operator=(outer::name &&) noexcept = default;
namespace QXmpp {
enum EncryptionMethod {
NoEncryption,
UnknownEncryption,
Otr,
LegacyOpenPgp,
Ox,
Omemo0,
Omemo1,
Omemo2,
// Keep in sync with namespaces and names in Global/Message.cpp!
#if QXMPP_DEPRECATED_SINCE(1, 5)
OTR = Otr,
LegacyOpenPGP = LegacyOpenPgp,
OX = Ox,
OMEMO = Omemo0,
#endif
};
enum SceMode : uint8_t {
SceAll,
ScePublic,
SceSensitive,
};
inline constexpr bool operator&(SceMode mode1, SceMode mode2)
{
return mode1 == SceAll || mode1 == mode2;
}
enum Cipher {
Aes128GcmNoPad,
Aes256GcmNoPad,
Aes256CbcPkcs7,
};
struct Success { };
struct Cancelled { };
struct TimeoutError { };
template<typename T = Success>
using Result = std::variant<T, QXmppError>;
template<typename T>
bool hasValue(const Result<T> &r) { return std::holds_alternative<T>(r); }
template<typename T>
bool hasError(const Result<T> &r) { return std::holds_alternative<QXmppError>(r); }
template<typename T>
const T &getValue(const Result<T> &r) { return std::get<T>(r); }
template<typename T>
T &getValue(Result<T> &r) { return std::get<T>(r); }
template<typename T>
T getValue(Result<T> &&r) { return std::get<T>(std::move(r)); }
// getError() is defined in QXmppError.h
} // namespace QXmpp
#endif // QXMPPGLOBAL_H
QXmpp
Definition Algorithms.h:14
QXmpp::Cipher
Cipher
Definition QXmppGlobal.h:172
QXmpp::Result
std::variant< T, QXmppError > Result
Definition QXmppGlobal.h:209
QXmpp::getValue
const T & getValue(const Result< T > &r)
Definition QXmppGlobal.h:232
QXmpp::hasValue
bool hasValue(const Result< T > &r)
Definition QXmppGlobal.h:216
QXmpp::operator&
constexpr bool operator&(SceMode mode1, SceMode mode2)
Definition QXmppGlobal.h:162
QXmpp::SceMode
SceMode
Definition QXmppGlobal.h:148
QXmpp::SceSensitive
@ SceSensitive
Only processes sensitive elements that should be encrypted.
Definition QXmppGlobal.h:151
QXmpp::SceAll
@ SceAll
Processes all known elements.
Definition QXmppGlobal.h:149
QXmpp::ScePublic
@ ScePublic
Only processes 'public' elements (e.g. needed for routing).
Definition QXmppGlobal.h:150
QXmpp::hasError
bool hasError(const Result< T > &r)
Definition QXmppGlobal.h:224
QXmpp::EncryptionMethod
EncryptionMethod
Definition QXmppGlobal.h:101
QXmpp::LegacyOpenPgp
@ LegacyOpenPgp
XEP-0027: Current Jabber OpenPGP Usage
Definition QXmppGlobal.h:109
QXmpp::OMEMO
@ OMEMO
Definition QXmppGlobal.h:137
QXmpp::Omemo0
@ Omemo0
XEP-0384: OMEMO Encryption
Definition QXmppGlobal.h:113
QXmpp::Ox
@ Ox
XEP-0373: OpenPGP for XMPP
Definition QXmppGlobal.h:111
QXmpp::Omemo2
@ Omemo2
XEP-0384: OMEMO Encryption since version 0.8
Definition QXmppGlobal.h:117
QXmpp::OTR
@ OTR
Definition QXmppGlobal.h:125
QXmpp::Otr
@ Otr
XEP-0364: Current Off-the-Record Messaging Usage
Definition QXmppGlobal.h:107
QXmpp::NoEncryption
@ NoEncryption
No encryption.
Definition QXmppGlobal.h:103
QXmpp::OX
@ OX
Definition QXmppGlobal.h:133
QXmpp::LegacyOpenPGP
@ LegacyOpenPGP
Definition QXmppGlobal.h:129
QXmpp::Omemo1
@ Omemo1
XEP-0384: OMEMO Encryption since version 0.4
Definition QXmppGlobal.h:115
QXmpp::UnknownEncryption
@ UnknownEncryption
Unknown encryption.
Definition QXmppGlobal.h:105
QXmppError
Definition QXmppError.h:17
QXmpp::Cancelled
Definition QXmppGlobal.h:190
QXmpp::Success
Definition QXmppGlobal.h:183
QXmpp::TimeoutError
Definition QXmppGlobal.h:199