libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
quotient_common.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2019 Kitsune Ral <Kitsune-Ral@users.sf.net>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7
8#include <qobjectdefs.h>
9#include "util.h"
10
11#include <array>
12
13
14//! \brief Quotient replacement for the Q_FLAG/Q_DECLARE_FLAGS combination
15//!
16//! Although the comment in QTBUG-82295 says that Q_FLAG[_NS] "should" be
17//! applied to the enum type only, Qt then doesn't allow to wrap the
18//! corresponding flag type (defined with Q_DECLARE_FLAGS) into a QVariant.
19//! This macro defines Q_FLAG and on top of that adds Q_ENUM_IMPL which is
20//! a part of Q_ENUM() macro that enables the metatype data but goes under
21//! the moc radar to avoid double registration of the same data in the map
22//! defined in moc_*.cpp.
23//!
24//! Simply put, instead of using Q_FLAG/Q_DECLARE_FLAGS combo (and struggling
25//! to figure out what you should pass to Q_FLAG if you want to make it
26//! wrappable in a QVariant) use the macro below, and things will just work.
27//!
28//! \sa https://bugreports.qt.io/browse/QTBUG-82295
29#define QUO_DECLARE_FLAGS(Flags, Enum)
30 Q_DECLARE_FLAGS(Flags, Enum)
31 Q_ENUM_IMPL(Enum)
32 Q_FLAG(Flags)
33
34//! \brief Quotient replacement for the Q_FLAG_NS/Q_DECLARE_FLAGS combination
35//!
36//! This is the equivalent of QUO_DECLARE_FLAGS for enums declared at the
37//! namespace level (be sure to provide Q_NAMESPACE _in the same file_
38//! as the enum definition and this macro).
39//! \sa QUO_DECLARE_FLAGS
40#define QUO_DECLARE_FLAGS_NS(Flags, Enum)
41 Q_DECLARE_FLAGS(Flags, Enum)
42 Q_ENUM_NS_IMPL(Enum)
43 Q_FLAG_NS(Flags)
44
45namespace Quotient {
46Q_NAMESPACE_EXPORT(QUOTIENT_API)
47
48// TODO: code like this should be generated from the CS API definition
49
50//! \brief Membership states
51//!
52//! These are used for member events. The names here are case-insensitively
53//! equal to state names used on the wire.
54//! \sa MemberEventContent, RoomMemberEvent
55enum class Membership : uint16_t {
56 // Specific power-of-2 values (1,2,4,...) are important here as syncdata.cpp
57 // depends on that, as well as Join being the first in line
58 Invalid = 0x0,
59 Join = 0x1,
60 Leave = 0x2,
61 Invite = 0x4,
62 Knock = 0x8,
63 Ban = 0x10,
65};
67
69 // The order MUST be the same as the order in the Membership enum
70 "join"_L1, "leave"_L1, "invite"_L1, "knock"_L1, "ban"_L1
71};
72
73//! \brief Local user join-state names
74//!
75//! This represents a subset of Membership values that may arrive as the local
76//! user's state grouping for the sync response.
77//! \sa SyncData
84};
86
89 MembershipStrings[3] /* same as MembershipStrings, sans "ban" */
90};
91
92//! \brief Network job running policy flags
93//!
94//! So far only background/foreground flags are available.
95//! \sa Connection::callApi, Connection::run
97Q_ENUM_NS(RunningPolicy)
98
99//! \brief The result of URI resolution using UriResolver
100//! \sa UriResolver
109Q_ENUM_NS(UriResolveResult)
110
111enum class RoomType : uint8_t {
112 Space = 0,
113 Undefined = 0xFF,
114};
115Q_ENUM_NS(RoomType)
116
117[[maybe_unused]] constexpr std::array RoomTypeStrings { "m.space"_L1 };
118
120 MegolmV1AesSha2 = 0,
121 Undefined = 0xFF,
122};
123Q_ENUM_NS(EncryptionType)
124
125} // namespace Quotient
126Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::MembershipMask)
127Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::JoinStates)
RunningPolicy
Network job running policy flags.
Membership
Membership states.
UriResolveResult
The result of URI resolution using UriResolver.
JoinState
Local user join-state names.
constexpr std::array RoomTypeStrings
#define QUO_DECLARE_FLAGS_NS(Flags, Enum)
Quotient replacement for the Q_FLAG_NS/Q_DECLARE_FLAGS combination.
#define QUOTIENT_API