libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
roompowerlevelsevent.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
2
// SPDX-License-Identifier: LGPL-2.1-or-later
3
4
#
pragma
once
5
6
#
include
"stateevent.h"
7
8
namespace
Quotient
{
9
10
struct
QUOTIENT_API
PowerLevelsEventContent
{
11
// See https://spec.matrix.org/v1.11/client-server-api/#mroompower_levels for the defaults
12
13
int
invite
= 0;
14
int
kick
= 50;
15
int
ban
= 50;
16
17
int
redact
= 50;
18
19
QHash
<
QString
,
int
>
events
{};
20
int
eventsDefault
= 0;
21
int
stateDefault
= 50;
22
23
QHash
<
QString
,
int
>
users
{};
24
int
usersDefault
= 0;
25
26
struct
Notifications
{
27
int
room
= 50;
28
};
29
Notifications
notifications
{};
30
};
31
32
template
<>
33
struct
QUOTIENT_API
JsonConverter
<
PowerLevelsEventContent
> {
34
static
PowerLevelsEventContent
load
(
const
QJsonValue
&
jv
);
35
static
QJsonObject
dump
(
const
PowerLevelsEventContent
&
c
);
36
};
37
38
class
QUOTIENT_API
RoomPowerLevelsEvent
39
:
public
KeylessStateEventBase
<
RoomPowerLevelsEvent
,
PowerLevelsEventContent
> {
40
public
:
41
QUO_EVENT
(
RoomPowerLevelsEvent
,
"m.room.power_levels"
)
42
43
using
KeylessStateEventBase
::
KeylessStateEventBase
;
44
45
int
invite
()
const
{
return
content
().
invite
; }
46
int
kick
()
const
{
return
content
().
kick
; }
47
int
ban
()
const
{
return
content
().
ban
; }
48
49
int
redact
()
const
{
return
content
().
redact
; }
50
51
QHash
<
QString
,
int
>
events
()
const
{
return
content
().
events
; }
52
int
eventsDefault
()
const
{
return
content
().
eventsDefault
; }
53
int
stateDefault
()
const
{
return
content
().
stateDefault
; }
54
55
QHash
<
QString
,
int
>
users
()
const
{
return
content
().
users
; }
56
int
usersDefault
()
const
{
return
content
().
usersDefault
; }
57
58
int
roomNotification
()
const
{
return
content
().
notifications
.
room
; }
59
60
//! \brief Get the power level for message events of a given type
61
//!
62
//! \note You normally should not compare power levels returned from this
63
//! and other powerLevelFor*() functions directly; use
64
//! Room::canSendEvents() instead
65
int
powerLevelForEvent
(
const
QString
&
eventTypeId
)
const
;
66
67
//! \brief Get the power level for state events of a given type
68
//!
69
//! \note You normally should not compare power levels returned from this
70
//! and other powerLevelFor*() functions directly; use
71
//! Room::canSetState() instead
72
int
powerLevelForState
(
const
QString
&
eventTypeId
)
const
;
73
74
//! \brief Get the power level for a given user
75
//!
76
//! \note You normally should not directly use power levels returned by this
77
//! and other powerLevelFor*() functions; use Room API instead
78
//! \sa Room::canSend, Room::canSendEvents, Room::canSetState,
79
//! Room::effectivePowerLevel
80
int
powerLevelForUser
(
const
QString
&
userId
)
const
;
81
82
template
<
EventClass
EvT
>
83
int
powerLevelForEventType
()
const
84
{
85
if
constexpr
(
std
::
is_base_of_v
<
StateEvent
,
EvT
>) {
86
return
powerLevelForState
(
EvT
::
TypeId
);
87
}
else
{
88
return
powerLevelForEvent
(
EvT
::
TypeId
);
89
}
90
}
91
};
92
93
}
// namespace Quotient
Quotient::RoomPowerLevelsEvent
Definition
roompowerlevelsevent.h:39
QUO_EVENT
#define QUO_EVENT(CppType_, MatrixType_)
Supply event metatype information in (specific) event types.
Definition
event.h:436
Quotient
Definition
accountregistry.h:13
QUOTIENT_API
#define QUOTIENT_API
Definition
quotient_export.h:22
Quotient::PowerLevelsEventContent
Definition
roompowerlevelsevent.h:10
Quotient
events
roompowerlevelsevent.h
Generated by
1.9.8