libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
room.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2016 Kitsune Ral <Kitsune-Ral@users.sf.net>
2
// SPDX-FileCopyrightText: 2017 Roman Plášil <me@rplasil.name>
3
// SPDX-FileCopyrightText: 2017 Marius Gripsgard <marius@ubports.com>
4
// SPDX-FileCopyrightText: 2018 Josip Delic <delijati@googlemail.com>
5
// SPDX-FileCopyrightText: 2018 Black Hat <bhat@encom.eu.org>
6
// SPDX-FileCopyrightText: 2019 Alexey Andreyev <aa13q@ya.ru>
7
// SPDX-FileCopyrightText: 2020 Ram Nad <ramnad1999@gmail.com>
8
// SPDX-License-Identifier: LGPL-2.1-or-later
9
10
#
pragma
once
11
12
#
include
"connection.h"
13
#
include
"roommember.h"
14
#
include
"roomstateview.h"
15
#
include
"eventitem.h"
16
#
include
"quotient_common.h"
17
18
#
include
"csapi/message_pagination.h"
19
20
#
include
"events/accountdataevents.h"
21
#
include
"events/encryptedevent.h"
22
#
include
"events/eventrelation.h"
23
#
include
"events/roomcreateevent.h"
24
#
include
"events/roomkeyevent.h"
25
#
include
"events/roommessageevent.h"
26
#
include
"events/roompowerlevelsevent.h"
27
#
include
"events/roomtombstoneevent.h"
28
#
include
"events/roomjoinrulesevent.h"
29
30
#
include
<
QtCore
/
QJsonObject
>
31
#
include
<
QtGui
/
QImage
>
32
33
#
include
<
deque
>
34
#
include
<
utility
>
35
36
namespace
Quotient
{
37
class
Event;
38
class
Avatar;
39
class
SyncRoomData;
40
class
RoomMemberEvent;
41
class
User;
42
class
RoomMember;
43
struct
MemberSorter;
44
class
LeaveRoomJob;
45
class
SetRoomStateWithKeyJob;
46
class
RedactEventJob;
47
class
Thread;
48
49
/** The data structure used to expose file transfer information to views
50
*
51
* This is specifically tuned to work with QML exposing all traits as
52
* Q_PROPERTY values.
53
*/
54
class
QUOTIENT_API
FileTransferInfo
{
55
Q_GADGET
56
Q_PROPERTY
(
bool
isUpload
MEMBER
isUpload
CONSTANT
)
57
Q_PROPERTY
(
bool
active
READ
active
CONSTANT
)
58
Q_PROPERTY
(
bool
started
READ
started
CONSTANT
)
59
Q_PROPERTY
(
bool
completed
READ
completed
CONSTANT
)
60
Q_PROPERTY
(
bool
failed
READ
failed
CONSTANT
)
61
Q_PROPERTY
(
int
progress
MEMBER
progress
CONSTANT
)
62
Q_PROPERTY
(
int
total
MEMBER
total
CONSTANT
)
63
Q_PROPERTY
(
QUrl
localDir
MEMBER
localDir
CONSTANT
)
64
Q_PROPERTY
(
QUrl
localPath
MEMBER
localPath
CONSTANT
)
65
public
:
66
enum
Status
{
None
,
Started
,
Completed
,
Failed
,
Cancelled
};
67
Status
status
=
None
;
68
bool
isUpload
=
false
;
69
int
progress
= 0;
70
int
total
= -1;
71
QUrl
localDir
{};
72
QUrl
localPath
{};
73
74
bool
started
()
const
{
return
status
==
Started
; }
75
bool
completed
()
const
{
return
status
==
Completed
; }
76
bool
active
()
const
{
return
started
() ||
completed
(); }
77
bool
failed
()
const
{
return
status
==
Failed
; }
78
};
79
80
//! \brief Data structure for a room member's read receipt
81
//! \sa Room::lastReadReceipt
82
class
QUOTIENT_API
ReadReceipt
{
83
Q_GADGET
84
Q_PROPERTY
(
QString
eventId
MEMBER
eventId
CONSTANT
)
85
Q_PROPERTY
(
QDateTime
timestamp
MEMBER
timestamp
CONSTANT
)
86
public
:
87
QString
eventId
;
88
QDateTime
timestamp
= {};
89
90
bool
operator
==(
const
ReadReceipt
&
other
)
const
91
{
92
return
eventId
==
other
.
eventId
&&
timestamp
==
other
.
timestamp
;
93
}
94
bool
operator
!=(
const
ReadReceipt
&
other
)
const
95
{
96
return
!
operator
==(
other
);
97
}
98
};
99
inline
void
swap
(
ReadReceipt
&
lhs
,
ReadReceipt
&
rhs
)
100
{
101
swap
(
lhs
.
eventId
,
rhs
.
eventId
);
102
swap
(
lhs
.
timestamp
,
rhs
.
timestamp
);
103
}
104
105
struct
EventStats;
106
107
struct
Notification
108
{
109
enum
Type
{
None
= 0,
Basic
,
Highlight
};
110
Q_ENUM
(
Type
)
111
112
Type
type
=
None
;
113
114
private
:
115
Q_GADGET
116
Q_PROPERTY(
Type
type MEMBER type CONSTANT)
117
};
118
119
class
QUOTIENT_API
Room
:
public
QObject
{
120
Q_OBJECT
121
Q_PROPERTY
(
Connection
*
connection
READ
connection
CONSTANT
)
122
Q_PROPERTY
(
RoomMember
localMember
READ
localMember
CONSTANT
)
123
Q_PROPERTY
(
QString
id
READ
id
CONSTANT
)
124
Q_PROPERTY
(
QString
version
READ
version
NOTIFY
baseStateLoaded
)
125
Q_PROPERTY
(
bool
isUnstable
READ
isUnstable
NOTIFY
stabilityUpdated
)
126
Q_PROPERTY
(
QString
predecessorId
READ
predecessorId
NOTIFY
baseStateLoaded
)
127
Q_PROPERTY
(
QString
successorId
READ
successorId
NOTIFY
upgraded
)
128
Q_PROPERTY
(
QString
name
READ
name
NOTIFY
namesChanged
)
129
Q_PROPERTY
(
QStringList
aliases
READ
aliases
NOTIFY
namesChanged
)
130
Q_PROPERTY
(
QStringList
altAliases
READ
altAliases
NOTIFY
namesChanged
)
131
Q_PROPERTY
(
QString
canonicalAlias
READ
canonicalAlias
NOTIFY
namesChanged
)
132
Q_PROPERTY
(
QString
displayName
READ
displayName
NOTIFY
displaynameChanged
)
133
Q_PROPERTY
(
QStringList
pinnedEventIds
READ
pinnedEventIds
WRITE
setPinnedEvents
134
NOTIFY
pinnedEventsChanged
)
135
Q_PROPERTY
(
QString
displayNameForHtml
READ
displayNameForHtml
NOTIFY
displaynameChanged
)
136
Q_PROPERTY
(
QString
topic
READ
topic
NOTIFY
topicChanged
)
137
Q_PROPERTY
(
QString
avatarMediaId
READ
avatarMediaId
NOTIFY
avatarChanged
138
STORED
false
)
139
Q_PROPERTY
(
QUrl
avatarUrl
READ
avatarUrl
NOTIFY
avatarChanged
)
140
Q_PROPERTY
(
bool
usesEncryption
READ
usesEncryption
NOTIFY
encryption
)
141
142
Q_PROPERTY
(
int
timelineSize
READ
timelineSize
NOTIFY
addedMessages
)
143
Q_PROPERTY
(
int
joinedCount
READ
joinedCount
NOTIFY
memberListChanged
)
144
Q_PROPERTY
(
int
invitedCount
READ
invitedCount
NOTIFY
memberListChanged
)
145
Q_PROPERTY
(
int
totalMemberCount
READ
totalMemberCount
NOTIFY
memberListChanged
)
146
Q_PROPERTY
(
QList
<
RoomMember
>
membersTyping
READ
membersTyping
NOTIFY
typingChanged
)
147
Q_PROPERTY
(
QList
<
RoomMember
>
otherMembersTyping
READ
otherMembersTyping
NOTIFY
typingChanged
)
148
Q_PROPERTY
(
int
localMemberEffectivePowerLevel
READ
memberEffectivePowerLevel
NOTIFY
changed
)
149
150
Q_PROPERTY
(
bool
displayed
READ
displayed
WRITE
setDisplayed
NOTIFY
151
displayedChanged
)
152
Q_PROPERTY
(
QString
firstDisplayedEventId
READ
firstDisplayedEventId
WRITE
153
setFirstDisplayedEventId
NOTIFY
firstDisplayedEventChanged
)
154
Q_PROPERTY
(
QString
lastDisplayedEventId
READ
lastDisplayedEventId
WRITE
155
setLastDisplayedEventId
NOTIFY
lastDisplayedEventChanged
)
156
Q_PROPERTY
(
QString
lastFullyReadEventId
READ
lastFullyReadEventId
WRITE
157
markMessagesAsRead
NOTIFY
fullyReadMarkerMoved
)
158
Q_PROPERTY
(
qsizetype
highlightCount
READ
highlightCount
159
NOTIFY
highlightCountChanged
)
160
Q_PROPERTY
(
qsizetype
notificationCount
READ
notificationCount
161
NOTIFY
notificationCountChanged
)
162
Q_PROPERTY
(
EventStats
partiallyReadStats
READ
partiallyReadStats
NOTIFY
partiallyReadStatsChanged
)
163
Q_PROPERTY
(
EventStats
unreadStats
READ
unreadStats
NOTIFY
unreadStatsChanged
)
164
Q_PROPERTY
(
bool
allHistoryLoaded
READ
allHistoryLoaded
NOTIFY
allHistoryLoadedChanged
165
STORED
false
)
166
Q_PROPERTY
(
QStringList
tagNames
READ
tagNames
NOTIFY
tagsChanged
)
167
Q_PROPERTY
(
bool
isFavourite
READ
isFavourite
NOTIFY
tagsChanged
STORED
false
)
168
Q_PROPERTY
(
bool
isLowPriority
READ
isLowPriority
NOTIFY
tagsChanged
STORED
false
)
169
Q_PROPERTY
(
JoinRule
joinRule
READ
joinRule
WRITE
setJoinRule
NOTIFY
joinRuleChanged
)
170
Q_PROPERTY
(
QList
<
QString
>
allowIds
READ
allowIds
NOTIFY
joinRuleChanged
)
171
172
Q_PROPERTY
(
GetRoomEventsJob
*
eventsHistoryJob
READ
eventsHistoryJob
NOTIFY
eventsHistoryJobChanged
)
173
Q_PROPERTY
(
int
requestedHistorySize
READ
requestedHistorySize
NOTIFY
eventsHistoryJobChanged
)
174
175
Q_PROPERTY
(
QStringList
accountDataEventTypes
READ
accountDataEventTypes
NOTIFY
accountDataChanged
)
176
177
public
:
178
using
Timeline
=
std
::
deque
<
TimelineItem
>;
179
using
PendingEvents
=
std
::
vector
<
PendingEventItem
>;
180
using
RelatedEvents
=
QVector
<
const
RoomEvent
*>;
181
using
rev_iter_t
=
Timeline
::
const_reverse_iterator
;
182
using
timeline_iter_t
=
Timeline
::
const_iterator
;
183
using
ThreadView
=
QHash
<
QString
,
Thread
>;
184
185
//! \brief Room changes that can be tracked using Room::changed() signal
186
//!
187
//! This enumeration lists kinds of changes that can be tracked with
188
//! a "cumulative" changed() signal instead of using individual signals for
189
//! each change. Specific enumerators mention these individual signals.
190
//! \sa changed
191
enum
class
Change
:
quint32
{
// QFlags can't go more than 32-bit
192
None
= 0x0,
//!< No changes occurred in the room
193
RoomNames
= 0x1,
//!< \sa namesChanged, displaynameChanged
194
// NotInUse = 0x2,
195
Topic
= 0x4,
//!< \sa topicChanged
196
PartiallyReadStats
= 0x8,
//!< \sa partiallyReadStatsChanged
197
Avatar
= 0x10,
//!< \sa avatarChanged
198
JoinState
= 0x20,
//!< \sa joinStateChanged
199
Tags
= 0x40,
//!< \sa tagsChanged
200
//! \sa userAdded, userRemoved, memberRenamed, memberListChanged,
201
//! displaynameChanged
202
Members
= 0x80,
203
UnreadStats
= 0x100,
//!< \sa unreadStatsChanged
204
// AccountData pre-0.9 = 0x200,
205
Summary
= 0x400,
//!< \sa summaryChanged, displaynameChanged
206
// ReadMarker pre-0.9 = 0x800,
207
Highlights
= 0x1000,
//!< \sa highlightCountChanged
208
//! A catch-all value that covers changes not listed above (such as
209
//! encryption turned on or the room having been upgraded), as well as
210
//! changes in the room state that the library is not aware of (e.g.,
211
//! custom state events) and m.read/m.fully_read position changes.
212
//! \sa encryptionChanged, upgraded, accountDataChanged
213
Other
= 0x8000,
214
//! This is intended to test a Change/Changes value for non-emptiness;
215
//! adding <tt>& Change::Any</tt> has the same meaning as
216
//! !testFlag(Change::None) or adding <tt>!= Change::None</tt>
217
//! \note testFlag(Change::Any) tests that _all_ bits are on and
218
//! will always return false.
219
Any
= 0xFFFF
220
};
221
QUO_DECLARE_FLAGS
(
Changes
,
Change
)
222
223
Room
(
Connection
*
connection
,
QString
id
,
JoinState
initialJoinState
);
224
Q_DISABLE_COPY_MOVE
(
Room
)
225
~
Room
()
override
;
226
227
// Property accessors
228
229
Connection
*
connection
()
const
;
230
231
//! Get a RoomMember object for the local user.
232
RoomMember
localMember
()
const
;
233
const
QString
&
id
()
const
;
234
QString
version
()
const
;
235
bool
isUnstable
()
const
;
236
QString
predecessorId
()
const
;
237
/// Room predecessor
238
/** This function validates that the predecessor has a tombstone and
239
* the tombstone refers to the current room. If that's not the case,
240
* or if the predecessor is in a join state not matching \p stateFilter,
241
* the function returns nullptr.
242
*/
243
Room
*
predecessor
(
JoinStates
statesFilter
=
JoinState
::
Invite
244
|
JoinState
::
Join
)
const
;
245
QString
successorId
()
const
;
246
/// Room successor
247
/** This function validates that the successor room's creation event
248
* refers to the current room. If that's not the case, or if the successor
249
* is in a join state not matching \p stateFilter, it returns nullptr.
250
*/
251
Room
*
successor
(
JoinStates
statesFilter
=
JoinState
::
Invite
252
|
JoinState
::
Join
)
const
;
253
QString
name
()
const
;
254
QString
canonicalAlias
()
const
;
255
QStringList
altAliases
()
const
;
256
//! Get a list of both canonical and alternative aliases
257
QStringList
aliases
()
const
;
258
QString
displayName
()
const
;
259
QStringList
pinnedEventIds
()
const
;
260
// Returns events available locally, use pinnedEventIds() for full list
261
QVector
<
const
RoomEvent
*>
pinnedEvents
()
const
;
262
QString
displayNameForHtml
()
const
;
263
QString
topic
()
const
;
264
QString
avatarMediaId
()
const
;
265
QUrl
avatarUrl
()
const
;
266
const
Avatar
&
avatarObject
()
const
;
267
Q_INVOKABLE
JoinState
joinState
()
const
;
268
269
int
timelineSize
()
const
;
270
bool
usesEncryption
()
const
;
271
RoomEventPtr
decryptMessage
(
const
EncryptedEvent
&
encryptedEvent
);
272
void
handleRoomKeyEvent
(
const
RoomKeyEvent
&
roomKeyEvent
,
273
const
QString
&
senderId
,
274
const
QByteArray
&
olmSessionId
,
275
const
QByteArray
&
senderKey
,
276
const
QByteArray
&
senderEdKey
);
277
int
joinedCount
()
const
;
278
int
invitedCount
()
const
;
279
int
totalMemberCount
()
const
;
280
281
GetRoomEventsJob
*
eventsHistoryJob
()
const
;
282
283
/**
284
* Returns a square room avatar with the given size and requests it
285
* from the network if needed
286
* \return a pixmap with the avatar or a placeholder if there's none
287
* available yet
288
*/
289
Q_INVOKABLE
QImage
avatar
(
int
dimension
);
290
/**
291
* Returns a room avatar with the given dimensions and requests it
292
* from the network if needed
293
* \return a pixmap with the avatar or a placeholder if there's none
294
* available yet
295
*/
296
Q_INVOKABLE
QImage
avatar
(
int
width
,
int
height
);
297
298
//! \brief Get a RoomMember object for the given user Matrix ID
299
//!
300
//! Will return a nullptr if there is no m.room.member event for the user in
301
//! the room so needs to be null checked.
302
//!
303
//! \note This can return a member in any state that is known to the room so
304
//! check the state (using RoomMember::membershipState()) before use.
305
Q_INVOKABLE
RoomMember
member
(
const
QString
&
userId
)
const
;
306
307
//! Get a list of room members who have joined the room.
308
QList
<
RoomMember
>
joinedMembers
()
const
;
309
310
//! Get a list of all members known to the room.
311
QList
<
RoomMember
>
members
()
const
;
312
313
//! Get a list of all members known to have left the room.
314
QList
<
RoomMember
>
membersLeft
()
const
;
315
316
//! Get a list of room members who are currently sending a typing indicator.
317
QList
<
RoomMember
>
membersTyping
()
const
;
318
319
//! \brief Get a list of room members who are currently sending a typing indicator.
320
//!
321
//! The local member is excluded from this list.
322
QList
<
RoomMember
>
otherMembersTyping
()
const
;
323
324
//! Get a list of room member Matrix IDs who have joined the room.
325
QStringList
joinedMemberIds
()
const
;
326
327
//! Get a list of all member Matrix IDs known to the room.
328
QStringList
memberIds
()
const
;
329
330
//! Whether the name for the given member should be disambiguated
331
bool
needsDisambiguation
(
const
QString
&
userId
)
const
;
332
333
//! \brief Check the join state of a given user in this room
334
//!
335
//! \return the given user's state with respect to the room
336
Q_INVOKABLE
Quotient
::
Membership
memberState
(
const
QString
&
userId
)
const
;
337
338
//! Check whether a user with the given id is a member of the room
339
Q_INVOKABLE
bool
isMember
(
const
QString
&
userId
)
const
;
340
341
const
Avatar
&
memberAvatarObject
(
const
QString
&
memberId
)
const
;
342
343
//! \brief Get a avatar of the specified dimensions
344
//!
345
//! This always returns immediately; if there's no avatar cached yet, the call triggers
346
//! a network request, that will emit Room::memberAvatarUpdated() once completed.
347
//! \return a pixmap with the avatar or a placeholder if there's none available yet
348
Q_INVOKABLE
QImage
memberAvatar
(
const
QString
&
memberId
,
int
width
,
int
height
);
349
350
//! \brief Get a square avatar of the specified size
351
//!
352
//! This is an overload for the case when the needed width and height are equal.
353
Q_INVOKABLE
QImage
memberAvatar
(
const
QString
&
memberId
,
int
dimension
);
354
355
const
Timeline
&
messageEvents
()
const
;
356
const
PendingEvents
&
pendingEvents
()
const
;
357
358
//! \brief Get the number of requested historical events
359
//! \return The number of requested events if there's a pending request; 0 otherwise
360
int
requestedHistorySize
()
const
;
361
362
//! Check whether all historical messages are already loaded
363
//! \return true if the "oldest" event in the timeline is a room creation event and there's
364
//! no further history to load; false otherwise
365
bool
allHistoryLoaded
()
const
;
366
367
//! \brief Get a reverse iterator at the position before the "oldest" event
368
//!
369
//! Same as messageEvents().crend()
370
rev_iter_t
historyEdge
()
const
;
371
372
const
ThreadView
&
threads
()
const
;
373
374
//! \brief Get an iterator for the position beyond the latest arrived event
375
//!
376
//! Same as messageEvents().cend()
377
Timeline
::
const_iterator
syncEdge
()
const
;
378
Q_INVOKABLE
Quotient
::
TimelineItem
::
index_t
minTimelineIndex
()
const
;
379
Q_INVOKABLE
Quotient
::
TimelineItem
::
index_t
maxTimelineIndex
()
const
;
380
Q_INVOKABLE
bool
isValidIndex
(
Quotient
::
TimelineItem
::
index_t
timelineIndex
)
const
;
381
382
rev_iter_t
findInTimeline
(
TimelineItem
::
index_t
index
)
const
;
383
rev_iter_t
findInTimeline
(
const
QString
&
evtId
)
const
;
384
PendingEvents
::
iterator
findPendingEvent
(
const
QString
&
txnId
);
385
PendingEvents
::
const_iterator
findPendingEvent
(
const
QString
&
txnId
)
const
;
386
387
const
RelatedEvents
relatedEvents
(
const
QString
&
evtId
,
388
EventRelation
::
reltypeid_t
relType
)
const
;
389
const
RelatedEvents
relatedEvents
(
const
RoomEvent
&
evt
,
390
EventRelation
::
reltypeid_t
relType
)
const
;
391
392
const
RoomCreateEvent
*
creation
()
const
;
393
const
RoomTombstoneEvent
*
tombstone
()
const
;
394
395
bool
displayed
()
const
;
396
/// Mark the room as currently displayed to the user
397
/**
398
* Marking the room displayed causes the room to obtain the full
399
* list of members if it's been lazy-loaded before; in the future
400
* it may do more things bound to "screen time" of the room, e.g.
401
* measure that "screen time".
402
*/
403
void
setDisplayed
(
bool
displayed
=
true
);
404
QString
firstDisplayedEventId
()
const
;
405
rev_iter_t
firstDisplayedMarker
()
const
;
406
void
setFirstDisplayedEventId
(
const
QString
&
eventId
);
407
void
setFirstDisplayedEvent
(
TimelineItem
::
index_t
index
);
408
QString
lastDisplayedEventId
()
const
;
409
rev_iter_t
lastDisplayedMarker
()
const
;
410
void
setLastDisplayedEventId
(
const
QString
&
eventId
);
411
void
setLastDisplayedEvent
(
TimelineItem
::
index_t
index
);
412
413
//! \brief Get the latest read receipt from a user
414
//!
415
//! The user id must be valid. A read receipt with an empty event id
416
//! is returned if the user id is valid but there was no read receipt
417
//! from them.
418
//! \sa usersAtEventId
419
ReadReceipt
lastReadReceipt
(
const
QString
&
userId
)
const
;
420
421
//! \brief Get the latest read receipt from the local user
422
//!
423
//! This is a shortcut for <tt>lastReadReceipt(localUserId)</tt>.
424
//! \sa lastReadReceipt
425
ReadReceipt
lastLocalReadReceipt
()
const
;
426
427
//! \brief Find the timeline item the local read receipt is at
428
//!
429
//! This is a shortcut for \code
430
//! room->findInTimeline(room->lastLocalReadReceipt().eventId);
431
//! \endcode
432
rev_iter_t
localReadReceiptMarker
()
const
;
433
434
//! \brief Get the latest event id marked as fully read
435
//!
436
//! This can be either the event id pointed to by the actual latest
437
//! m.fully_read event, or the latest event id marked locally as fully read
438
//! if markMessagesAsRead or markAllMessagesAsRead has been called and
439
//! the homeserver didn't return an updated m.fully_read event yet.
440
//! \sa markMessagesAsRead, markAllMessagesAsRead, fullyReadMarker
441
QString
lastFullyReadEventId
()
const
;
442
443
//! \brief Get the iterator to the latest timeline item marked as fully read
444
//!
445
//! This method calls findInTimeline on the result of lastFullyReadEventId.
446
//! If the fully read marker turns out to be outside the timeline (because
447
//! the event marked as fully read is too far back in the history) the
448
//! returned value will be equal to historyEdge.
449
//!
450
//! Be sure to read the caveats on iterators returned by findInTimeline.
451
//! \sa lastFullyReadEventId, findInTimeline
452
rev_iter_t
fullyReadMarker
()
const
;
453
454
//! \brief Get users whose latest read receipts point to the event
455
//!
456
//! This method is for cases when you need to show users who have read
457
//! an event. Calling it on inexistent or empty event id will return
458
//! an empty set.
459
//! \note The returned list may contain ids resolving to users that are
460
//! not loaded as room members yet (in particular, if members are not
461
//! yet lazy-loaded). For now this merely means that the user's
462
//! room-specific name and avatar will not be there; but generally
463
//! it's recommended to ensure that all room members are loaded
464
//! before operating on the result of this function.
465
//! \sa lastReadReceipt, allMembersLoaded
466
QSet
<
QString
>
userIdsAtEvent
(
const
QString
&
eventId
)
const
;
467
468
//! \brief Mark the event with uptoEventId as fully read
469
//!
470
//! Marks the event with the specified id as fully read locally and also
471
//! sends an update to m.fully_read account data to the server either
472
//! for this message or, if it's from the local user, for
473
//! the nearest non-local message before. uptoEventId must point to a known
474
//! event in the timeline; the method will do nothing if the event is behind
475
//! the current m.fully_read marker or is not loaded, to prevent
476
//! accidentally trying to move the marker back in the timeline.
477
//! \sa markAllMessagesAsRead, fullyReadMarker
478
Q_INVOKABLE
void
markMessagesAsRead
(
const
QString
&
uptoEventId
);
479
480
//! \brief Determine whether an event should be counted as unread
481
//!
482
//! The criteria of including an event in unread counters are described in
483
//! [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654); according
484
//! to these, the event should be counted as unread (or, in libQuotient
485
//! parlance, is "notable") if it is:
486
//! - either
487
//! - a message event that is not m.notice, or
488
//! - a state event with type being one of:
489
//! `m.room.topic`, `m.room.name`, `m.room.avatar`, `m.room.tombstone`;
490
//! - neither redacted, nor an edit (redactions cause the redacted event
491
//! to stop being notable, while edits are not notable themselves while
492
//! the original event usually is);
493
//! - from a non-local user (events from other devices of the local
494
//! user are not notable).
495
//! \sa partiallyReadStats, unreadStats
496
virtual
bool
isEventNotable
(
const
TimelineItem
&
ti
)
const
;
497
498
//! \brief Get notification details for an event
499
//!
500
//! This allows to get details on the kind of notification that should
501
//! generated for \p evt.
502
Notification
notificationFor
(
const
TimelineItem
&
ti
)
const
;
503
504
//! \brief Get event statistics since the fully read marker
505
//!
506
//! This call returns a structure containing:
507
//! - the number of notable unread events since the fully read marker;
508
//! depending on the fully read marker state with respect to the local
509
//! timeline, this number may be either exact or estimated
510
//! (see EventStats::isEstimate);
511
//! - the number of highlights (TODO).
512
//!
513
//! Note that this is different from the unread count defined by MSC2654
514
//! and from the notification/highlight numbers defined by the spec in that
515
//! it counts events since the fully read marker, not since the last
516
//! read receipt position.
517
//!
518
//! As E2EE is not supported in the library, the returned result will always
519
//! be an estimate (<tt>isEstimate == true</tt>) for encrypted rooms;
520
//! moreover, since the library doesn't know how to tackle push rules yet
521
//! the number of highlights returned here will always be zero (there's no
522
//! good substitute for that now).
523
//!
524
//! \sa isEventNotable, fullyReadMarker, unreadStats, EventStats
525
EventStats
partiallyReadStats
()
const
;
526
527
//! \brief Get event statistics since the last read receipt
528
//!
529
//! This call returns a structure that contains the following three numbers,
530
//! all counted on the timeline segment between the event pointed to by
531
//! the m.fully_read marker and the sync edge:
532
//! - the number of unread events - depending on the read receipt state
533
//! with respect to the local timeline, this number may be either precise
534
//! or estimated (see EventStats::isEstimate);
535
//! - the number of highlights (TODO).
536
//!
537
//! As E2EE is not supported in the library, the returned result will always
538
//! be an estimate (<tt>isEstimate == true</tt>) for encrypted rooms;
539
//! moreover, since the library doesn't know how to tackle push rules yet
540
//! the number of highlights returned here will always be zero - use
541
//! highlightCount() for now.
542
//!
543
//! \sa isEventNotable, lastLocalReadReceipt, partiallyReadStats,
544
//! highlightCount
545
EventStats
unreadStats
()
const
;
546
547
//! \brief Get the number of notifications since the last read receipt
548
//!
549
//! This is the same as <tt>unreadStats().notableCount</tt>.
550
//!
551
//! \sa unreadStats, lastLocalReadReceipt
552
qsizetype
notificationCount
()
const
;
553
554
//! \brief Get the number of highlights since the last read receipt
555
//!
556
//! As of 0.7, this is defined by the homeserver as Quotient doesn't process
557
//! push rules.
558
//!
559
//! \sa unreadStats, lastLocalReadReceipt
560
qsizetype
highlightCount
()
const
;
561
562
/** Check whether the room has account data of the given type
563
* Tags and read markers are not supported by this method _yet_.
564
*/
565
bool
hasAccountData
(
const
QString
&
type
)
const
;
566
567
/** Get a generic account data event of the given type
568
* This returns a generic hash map for any room account data event
569
* stored on the server. Tags and read markers cannot be retrieved
570
* using this method _yet_.
571
*/
572
const
EventPtr
&
accountData
(
const
QString
&
type
)
const
;
573
574
//! Get a list of all room account data events
575
//! \return A list of event types that exist in the room
576
QStringList
accountDataEventTypes
()
const
;
577
578
QStringList
tagNames
()
const
;
579
TagsMap
tags
()
const
;
580
Tag
tag
(
const
QString
&
name
)
const
;
581
582
/** Add a new tag to this room
583
* If this room already has this tag, nothing happens. If it's a new
584
* tag for the room, the respective tag record is added to the set
585
* of tags and the new set is sent to the server to update other
586
* clients.
587
*/
588
void
addTag
(
const
QString
&
name
,
const
Tag
&
tagData
= {});
589
Q_INVOKABLE
void
addTag
(
const
QString
&
name
,
float
order
);
590
591
/// Remove a tag from the room
592
Q_INVOKABLE
void
removeTag
(
const
QString
&
name
);
593
594
/// The scope to apply an action on
595
/*! This enumeration is used to pick a strategy to propagate certain
596
* actions on the room to its predecessors and successors.
597
*/
598
enum
ActionScope
{
599
ThisRoomOnly
,
///< Do not apply to predecessors and successors
600
WithinSameState
,
///< Apply to predecessors and successors in the same
601
///< state as the current one
602
OmitLeftState
,
///< Apply to all reachable predecessors and successors
603
///< except those in Leave state
604
WholeSequence
///< Apply to all reachable predecessors and successors
605
};
606
607
/** Overwrite the room's tags
608
* This completely replaces the existing room's tags with a set
609
* of new ones and updates the new set on the server. Unlike
610
* most other methods in Room, this one sends a signal about changes
611
* immediately, not waiting for confirmation from the server
612
* (because tags are saved in account data rather than in shared
613
* room state).
614
* \param applyOn setting this to Room::OnAllConversations will set tags
615
* on this and all _known_ predecessors and successors;
616
* by default only the current room is changed
617
*/
618
void
setTags
(
TagsMap
newTags
,
ActionScope
applyOn
=
ThisRoomOnly
);
619
620
/// Check whether the list of tags has m.favourite
621
bool
isFavourite
()
const
;
622
/// Check whether the list of tags has m.lowpriority
623
bool
isLowPriority
()
const
;
624
/// Check whether this room is for server notices (MSC1452)
625
bool
isServerNoticeRoom
()
const
;
626
627
/// Check whether this room is a direct chat
628
Q_INVOKABLE
bool
isDirectChat
()
const
;
629
630
/// Get the list of members this room is a direct chat with
631
QList
<
RoomMember
>
directChatMembers
()
const
;
632
633
Q_INVOKABLE
QUrl
makeMediaUrl
(
const
QString
&
eventId
,
634
const
QUrl
&
mxcUrl
)
const
;
635
636
Q_INVOKABLE
QUrl
urlToThumbnail
(
const
QString
&
eventId
)
const
;
637
Q_INVOKABLE
QUrl
urlToDownload
(
const
QString
&
eventId
)
const
;
638
639
/// Get a file name for downloading for a given event id
640
/*!
641
* The event MUST be RoomMessageEvent and have content
642
* for downloading. \sa RoomMessageEvent::hasContent
643
*/
644
Q_INVOKABLE
QString
fileNameToDownload
(
const
QString
&
eventId
)
const
;
645
646
/// Get information on file upload/download
647
/*!
648
* \param id uploads are identified by the corresponding event's
649
* transactionId (because uploads are done before
650
* the event is even sent), while downloads are using
651
* the normal event id for identifier.
652
*/
653
Q_INVOKABLE
Quotient
::
FileTransferInfo
654
fileTransferInfo
(
const
QString
&
id
)
const
;
655
656
/// Get the URL to the actual file source in a unified way
657
/*!
658
* For uploads it will return a URL to a local file; for downloads
659
* the URL will be taken from the corresponding room event.
660
*/
661
Q_INVOKABLE
QUrl
fileSource
(
const
QString
&
id
)
const
;
662
663
/** Pretty-prints plain text into HTML
664
* As of now, it's exactly the same as Quotient::prettyPrint();
665
* in the future, it will also linkify room aliases, mxids etc.
666
* using the room context.
667
*/
668
Q_INVOKABLE
QString
prettyPrint
(
const
QString
&
plainText
)
const
;
669
670
Q_INVOKABLE
bool
supportsCalls
()
const
;
671
672
/// Whether the current user is allowed to upgrade the room
673
Q_INVOKABLE
bool
canSwitchVersions
()
const
;
674
675
/// \brief Get the current room state
676
RoomStateView
currentState
()
const
;
677
678
//! \brief The current Join Rule for the room
679
//!
680
//! \sa https://spec.matrix.org/latest/client-server-api/#mroomjoin_rules
681
JoinRule
joinRule
()
const
;
682
683
//! \brief Set the Join Rule for the room
684
//!
685
//! If the local user does not have a high enough power level the request is rejected.
686
//!
687
//! \param newRule the new JoinRule to apply to the room
688
//! \param allowedRooms only required when the join rule is restricted. This is a
689
//! list of room IDs that members of can join without an invite.
690
//! If the rule is restricted and this list is empty it is treated as a join
691
//! rule of invite instead.
692
//!
693
//! \note While any room ID is permitted it is designed to be only spaces that are
694
//! input. I.e. only memebers of space `x` can join this room.
695
//!
696
//! \sa https://spec.matrix.org/latest/client-server-api/#mroomjoin_rules
697
Q_INVOKABLE
void
setJoinRule
(
JoinRule
newRule
,
const
QList
<
QString
>&
allowedRooms
= {});
698
699
//! \brief The list of Room IDs for when the join rule is Restricted
700
//!
701
//! This value will be empty when the Join Rule is not Restricted or
702
//! Knock-Restricted.
703
//!
704
//! \sa https://spec.matrix.org/latest/client-server-api/#mroomjoin_rules
705
QList
<
QString
>
allowIds
()
const
;
706
707
//! \brief The effective power level of the given member in the room
708
//!
709
//! This is normally the same as calling `RoomPowerLevelEvent::powerLevelForUser(userId)` but
710
//! takes into account the room context and works even if the room state has no power levels
711
//! event. It is THE recommended way to get a room member's power level to display in the UI.
712
//! \param memberId The room member ID to check; if empty, the local user will be checked
713
//! \sa RoomPowerLevelsEvent, https://spec.matrix.org/v1.11/client-server-api/#mroompower_levels
714
Q_INVOKABLE
int
memberEffectivePowerLevel
(
const
QString
&
memberId
= {})
const
;
715
716
//! \brief Get the power level required to send events of the given type
717
//!
718
//! \note This is a generic method that only gets the power level to send events with a given
719
//! type. Some operations have additional restrictions or enablers though: e.g.,
720
//! room member changes (kicks, invites) have special power levels; on the other hand,
721
//! redactions of one's own messages are allowed regardless of the power level. To check
722
//! effective ability to perform an operation, use Room's can*() methods instead of
723
//! comparing the power levels (those are also slightly more efficient).
724
//! \note Unlike the template version below, this method determines at runtime whether an event
725
//! type is that of a state event, assuming unknown event types to be non-state; pass
726
//! `true` as the second parameter to override that.
727
//! \sa canSend, canRedact, canSwitchVersions
728
Q_INVOKABLE
int
powerLevelFor
(
const
QString
&
eventTypeId
,
bool
forceStateEvent
=
false
)
const
;
729
730
//! \brief Get the power level required to send events of the given type
731
//!
732
//! This is an optimised version of non-template powerLevelFor() (with the same caveat about
733
//! operations based on some event types) for cases when the event type is known at build time.
734
//! \tparam EvT the event type to get the power level for
735
template
<
EventClass
EvT
>
736
int
powerLevelFor
()
const
737
{
738
return
currentState
().
get
<
RoomPowerLevelsEvent
>()->
powerLevelForEventType
<
EvT
>();
739
}
740
741
//! \brief Post a pre-created room message event
742
//!
743
//! Takes ownership of the event, deleting it once the matching one arrives with the sync.
744
//! \note Do not assume that the event is already on the road to the homeserver when this (or
745
//! any other `post*`) method returns; it can be queued internally.
746
//! \sa PendingEventItem::deliveryStatus()
747
//! \return a reference to the pending event item
748
const
PendingEventItem
&
post
(
RoomEventPtr
event
);
749
750
template
<
typename
EvT
,
typename
...
ArgTs
>
751
const
PendingEventItem
&
post
(
ArgTs
&&...
args
)
752
{
753
return
post
(
makeEvent
<
EvT
>(
std
::
forward
<
ArgTs
>(
args
)...));
754
}
755
756
//! \brief Send a text type message
757
//!
758
//! This means MessageEventType Text, Emote or Notice.
759
template
<
MessageEventType
type
=
MessageEventType
::
Text
>
760
QString
postText
(
const
QString
&
plainText
,
761
const
std
::
optional
<
QString
>&
html
=
std
::
nullopt
,
762
const
std
::
optional
<
EventRelation
>&
relatesTo
=
std
::
nullopt
)
763
{
764
static_assert
(
type
==
MessageEventType
::
Text
||
765
type
==
MessageEventType
::
Emote
||
766
type
==
MessageEventType
::
Notice
,
767
"MessageEvent type is not a text message"
768
);
769
770
std
::
unique_ptr
<
EventContent
::
TextContent
>
content
=
nullptr
;
771
if
(
html
) {
772
content
=
std
::
make_unique
<
EventContent
::
TextContent
>(*
html
, u"text/html"_s);
773
}
774
return
post
<
RoomMessageEvent
>(
plainText
,
type
,
std
::
move
(
content
),
relatesTo
)->
transactionId
();
775
}
776
777
//! Send a file with the given content
778
QString
postFile
(
const
QString
&
plainText
,
779
std
::
unique_ptr
<
EventContent
::
FileContentBase
>
fileContent
,
780
std
::
optional
<
EventRelation
>
relatesTo
=
std
::
nullopt
);
781
782
//! Send the given Json as a message
783
QString
postJson
(
const
QString
&
matrixType
,
const
QJsonObject
&
eventContent
);
784
785
//! Send a reaction on a given event with a given key
786
QString
postReaction
(
const
QString
&
eventId
,
const
QString
&
key
);
787
788
PendingEventItem
::
future_type
whenMessageMerged
(
QString
txnId
)
const
;
789
790
//! Send a request to update the room state with the given event
791
SetRoomStateWithKeyJob
*
setState
(
const
StateEvent
&
evt
);
792
793
//! \brief Set a state event of the given type with the given arguments
794
//!
795
//! This type-safe overload attempts to send a state event of the type \p EvT constructed from
796
//! \p args.
797
template
<
typename
EvT
,
typename
...
ArgTs
>
798
auto
setState
(
ArgTs
&&...
args
)
799
{
800
return
setState
(
EvT
(
std
::
forward
<
ArgTs
>(
args
)...));
801
}
802
803
void
addMegolmSessionFromBackup
(
const
QByteArray
&
sessionId
,
const
QByteArray
&
sessionKey
,
uint32_t
index
,
const
QByteArray
&
senderKey
,
const
QByteArray
&
senderEdKey
);
804
805
Q_INVOKABLE
void
startVerification
();
806
807
QJsonArray
exportMegolmSessions
();
808
809
public
Q_SLOTS
:
810
/** Check whether the room should be upgraded */
811
void
checkVersion
();
812
813
QString
retryMessage
(
const
QString
&
txnId
);
814
void
discardMessage
(
const
QString
&
txnId
);
815
816
//! Send a request to update the room state based on freeform inputs
817
SetRoomStateWithKeyJob
*
setState
(
const
QString
&
evtType
,
818
const
QString
&
stateKey
,
819
const
QJsonObject
&
contentJson
);
820
void
setName
(
const
QString
&
newName
);
821
void
setCanonicalAlias
(
const
QString
&
newAlias
);
822
void
setPinnedEvents
(
const
QStringList
&
events
);
823
/// Set room aliases on the user's current server
824
void
setLocalAliases
(
const
QStringList
&
aliases
);
825
void
setTopic
(
const
QString
&
newTopic
);
826
827
/// You shouldn't normally call this method; it's here for debugging
828
void
refreshDisplayName
();
829
830
JobHandle
<
GetRoomEventsJob
>
getPreviousContent
(
int
limit
= 10,
const
QString
&
filter
= {});
831
832
void
inviteToRoom
(
const
QString
&
memberId
);
833
JobHandle
<
LeaveRoomJob
>
leaveRoom
();
834
void
kickMember
(
const
QString
&
memberId
,
const
QString
&
reason
= {});
835
void
ban
(
const
QString
&
userId
,
const
QString
&
reason
= {});
836
void
unban
(
const
QString
&
userId
);
837
void
redactEvent
(
const
QString
&
eventId
,
const
QString
&
reason
= {});
838
839
void
uploadFile
(
const
QString
&
id
,
const
QUrl
&
localFilename
,
840
const
QString
&
overrideContentType
= {});
841
// If localFilename is empty a temporary file is created
842
void
downloadFile
(
const
QString
&
eventId
,
const
QUrl
&
localFilename
= {});
843
void
cancelFileTransfer
(
const
QString
&
id
);
844
845
//! \brief Set a given event as last read and post a read receipt on it
846
//!
847
//! Does nothing if the event is behind the current read receipt.
848
//! \sa lastReadReceipt, markMessagesAsRead, markAllMessagesAsRead
849
void
setReadReceipt
(
const
QString
&
atEventId
);
850
//! Put the fully-read marker at the latest message in the room
851
void
markAllMessagesAsRead
();
852
853
/// Switch the room's version (aka upgrade)
854
void
switchVersion
(
QString
newVersion
);
855
856
void
inviteCall
(
const
QString
&
callId
,
const
int
lifetime
,
857
const
QString
&
sdp
);
858
void
sendCallCandidates
(
const
QString
&
callId
,
const
QJsonArray
&
candidates
);
859
void
answerCall
(
const
QString
&
callId
,
const
QString
&
sdp
);
860
void
hangupCall
(
const
QString
&
callId
);
861
862
/**
863
* Activates encryption for this room.
864
* Warning: Cannot be undone
865
*/
866
void
activateEncryption
();
867
868
Q_SIGNALS
:
869
/// Initial set of state events has been loaded
870
/**
871
* The initial set is what comes from the initial sync for the room.
872
* This includes all basic things like RoomCreateEvent,
873
* RoomNameEvent, a (lazy-loaded, not full) set of RoomMemberEvents
874
* etc. This is a per-room reflection of Connection::loadedRoomState
875
* \sa Connection::loadedRoomState
876
*/
877
void
baseStateLoaded
();
878
void
eventsHistoryJobChanged
();
879
void
aboutToAddHistoricalMessages
(
Quotient
::
RoomEventsRange
events
);
880
void
aboutToAddNewMessages
(
Quotient
::
RoomEventsRange
events
);
881
void
addedMessages
(
int
fromIndex
,
int
toIndex
);
882
/// The event is about to be appended to the list of pending events
883
void
pendingEventAboutToAdd
(
Quotient
::
RoomEvent
*
event
);
884
/// An event has been appended to the list of pending events
885
void
pendingEventAdded
(
const
Quotient
::
RoomEvent
*
event
);
886
/// The remote echo has arrived with the sync and will be merged
887
/// with its local counterpart
888
/** NB: Requires a sync loop to be emitted */
889
void
pendingEventAboutToMerge
(
Quotient
::
RoomEvent
*
serverEvent
,
890
int
pendingEventIndex
);
891
/// The remote and local copies of the event have been merged
892
/** NB: Requires a sync loop to be emitted */
893
void
pendingEventMerged
();
894
/// An event will be removed from the list of pending events
895
void
pendingEventAboutToDiscard
(
int
pendingEventIndex
);
896
/// An event has just been removed from the list of pending events
897
void
pendingEventDiscarded
();
898
/// The status of a pending event has changed
899
/** \sa PendingEventItem::deliveryStatus */
900
void
pendingEventChanged
(
int
pendingEventIndex
);
901
/// The server accepted the message
902
/** This is emitted when an event sending request has successfully
903
* completed. This does not mean that the event is already in the
904
* local timeline, only that the server has accepted it.
905
* \param txnId transaction id assigned by the client during sending
906
* \param eventId event id assigned by the server upon acceptance
907
* \sa postEvent, postPlainText, postMessage, postHtmlMessage
908
* \sa pendingEventMerged, aboutToAddNewMessages
909
*/
910
void
messageSent
(
QString
txnId
,
QString
eventId
);
911
912
//! A new thread has been created/added in the room
913
void
newThread
(
const
Thread
&
newThread
);
914
915
/** A common signal for various kinds of changes in the room
916
* Aside from all changes in the room state
917
* @param changes a set of flags describing what changes occurred
918
* upon the last sync
919
* \sa Changes
920
*/
921
void
changed
(
Quotient
::
Room
::
Changes
changes
);
922
/**
923
* \brief The room name, the canonical alias or other aliases changed
924
*
925
* Not triggered when display name changes.
926
*/
927
void
namesChanged
(
Quotient
::
Room
*
room
);
928
void
displaynameAboutToChange
(
Quotient
::
Room
*
room
);
929
void
displaynameChanged
(
Quotient
::
Room
*
room
,
QString
oldName
);
930
void
pinnedEventsChanged
();
931
void
topicChanged
();
932
void
avatarChanged
();
933
934
//! \brief The join rule for the room has changed
935
void
joinRuleChanged
();
936
937
//! \brief A new member has joined the room
938
//!
939
//! This can be from any previous state or a member previously unknown to
940
//! the room.
941
void
memberJoined
(
RoomMember
member
);
942
943
//! \brief A member who previously joined has left
944
//!
945
//! The member will still be known to the room their membership state has changed
946
//! from Membership::Join to anything else.
947
void
memberLeft
(
RoomMember
member
);
948
949
//! A known joined member is about to update their display name
950
void
memberNameAboutToUpdate
(
RoomMember
member
,
QString
newName
);
951
952
//! A known joined member has updated their display name
953
void
memberNameUpdated
(
RoomMember
member
);
954
955
//! A known joined member has updated their avatar
956
void
memberAvatarUpdated
(
RoomMember
member
);
957
958
/// The list of members has changed
959
/** Emitted no more than once per sync, this is a good signal to
960
* for cases when some action should be done upon any change in
961
* the member list. If you need per-item granularity you should use
962
* userAdded, userRemoved and memberAboutToRename / memberRenamed
963
* instead.
964
*/
965
void
memberListChanged
();
966
967
/// The previously lazy-loaded members list is now loaded entirely
968
/// \sa setDisplayed
969
void
allMembersLoaded
();
970
void
encryption
();
971
972
void
joinStateChanged
(
Quotient
::
JoinState
oldState
,
973
Quotient
::
JoinState
newState
);
974
975
//! The list of members sending typing indicators has changed.
976
void
typingChanged
();
977
978
void
highlightCountChanged
();
///< \sa highlightCount
979
void
notificationCountChanged
();
///< \sa notificationCount
980
981
void
displayedChanged
(
bool
displayed
);
982
void
firstDisplayedEventChanged
();
983
void
lastDisplayedEventChanged
();
984
//! The event the m.read receipt points to has changed for the listed users
985
//! \sa lastReadReceipt
986
void
lastReadEventChanged
(
QVector
<
QString
>
userIds
);
987
void
fullyReadMarkerMoved
(
QString
fromEventId
,
QString
toEventId
);
988
void
partiallyReadStatsChanged
();
989
void
unreadStatsChanged
();
990
void
allHistoryLoadedChanged
();
991
992
void
accountDataAboutToChange
(
QString
type
);
993
void
accountDataChanged
(
QString
type
);
994
void
tagsAboutToChange
();
995
void
tagsChanged
();
996
997
void
updatedEvent
(
QString
eventId
);
998
void
replacedEvent
(
const
Quotient
::
RoomEvent
*
newEvent
,
999
const
Quotient
::
RoomEvent
*
oldEvent
);
1000
1001
void
newFileTransfer
(
QString
id
,
QUrl
localFile
);
1002
void
fileTransferProgress
(
QString
id
,
qint64
progress
,
qint64
total
);
1003
void
fileTransferCompleted
(
QString
id
,
QUrl
localFile
,
1004
FileSourceInfo
fileMetadata
);
1005
void
fileTransferFailed
(
QString
id
,
QString
errorMessage
= {});
1006
// fileTransferCancelled() is no more here; use fileTransferFailed() and
1007
// check the transfer status instead
1008
1009
void
callEvent
(
Quotient
::
Room
*
room
,
const
Quotient
::
RoomEvent
*
event
);
1010
1011
/// The room's version stability may have changed
1012
void
stabilityUpdated
(
QString
recommendedDefault
,
1013
QStringList
stableVersions
);
1014
/// This room has been upgraded and won't receive updates any more
1015
void
upgraded
(
QString
serverMessage
,
Quotient
::
Room
*
successor
);
1016
/// An attempted room upgrade has failed
1017
void
upgradeFailed
(
QString
errorMessage
);
1018
1019
/// The room is about to be deleted
1020
void
beforeDestruction
(
Quotient
::
Room
*);
1021
1022
protected
:
1023
virtual
Changes
processStateEvent
(
const
RoomEvent
&
e
);
1024
virtual
Changes
processEphemeralEvent
(
EventPtr
&&
event
);
1025
virtual
Changes
processAccountDataEvent
(
EventPtr
&&
event
);
1026
virtual
void
onAddNewTimelineEvents
(
timeline_iter_t
/*from*/
) {}
1027
virtual
void
onAddHistoricalTimelineEvents
(
rev_iter_t
/*from*/
) {}
1028
virtual
void
onRedaction
(
const
RoomEvent
&
/*prevEvent*/
,
1029
const
RoomEvent
&
/*after*/
)
1030
{}
1031
virtual
QJsonObject
toJson
()
const
;
1032
virtual
void
updateData
(
SyncRoomData
&&
data
,
bool
fromCache
=
false
);
1033
virtual
Notification
checkForNotifications
(
const
TimelineItem
&
ti
);
1034
1035
private
:
1036
friend
class
Connection
;
1037
1038
class
Private
;
1039
Private
*
d
;
1040
1041
// This is called from Connection, reflecting a state change that
1042
// arrived from the server. Clients should use
1043
// Connection::joinRoom() and Room::leaveRoom() to change the state.
1044
void
setJoinState
(
JoinState
state
);
1045
};
1046
1047
template
<
template
<
class
>
class
ContT>
1048
inline
typename
ContT<RoomMember>::
size_type
lowerBoundMemberIndex
(
const
ContT<RoomMember>& c,
1049
const
auto
& v,
1050
MemberSorter ms = {})
1051
{
1052
return
std::ranges::lower_bound(c, v, ms) - c.begin();
1053
}
1054
1055
template
<
template
<
class
>
class
ContT>
1056
inline
typename
ContT
<
QString
>::
size_type
lowerBoundMemberIndex
(
const
ContT<QString>& c,
1057
const
auto
& v,
const
Room* r,
1058
MemberSorter ms = {})
1059
{
1060
return
std::ranges::lower_bound(c, v, ms, std::bind_front(&Room::member, r)) - c.begin();
1061
}
1062
1063
}
// namespace Quotient
1064
Q_DECLARE_METATYPE
(
Quotient
::
FileTransferInfo
)
1065
Q_DECLARE_METATYPE(Quotient::ReadReceipt)
1066
Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::Room::Changes)
Quotient::FileTransferInfo
Definition
room.h:54
Quotient::ReadReceipt
Data structure for a room member's read receipt.
Definition
room.h:82
Quotient::Room
Definition
room.h:119
Quotient
Definition
accountregistry.h:13
Quotient::swap
void swap(ReadReceipt &lhs, ReadReceipt &rhs)
Definition
room.h:99
Quotient::lowerBoundMemberIndex
ContT< QString >::size_type lowerBoundMemberIndex(const ContT< QString > &c, const auto &v, const Room *r, MemberSorter ms={})
Definition
room.h:1056
Quotient::lowerBoundMemberIndex
ContT< RoomMember >::size_type lowerBoundMemberIndex(const ContT< RoomMember > &c, const auto &v, MemberSorter ms={})
Definition
room.h:1048
QUO_DECLARE_FLAGS
#define QUO_DECLARE_FLAGS(Flags, Enum)
Quotient replacement for the Q_FLAG/Q_DECLARE_FLAGS combination.
Definition
quotient_common.h:29
QUOTIENT_API
#define QUOTIENT_API
Definition
quotient_export.h:22
Quotient::Notification
Definition
room.h:108
Quotient::Notification::Type
Type
Definition
room.h:109
Quotient::Notification::None
@ None
Definition
room.h:109
Quotient::Notification::Highlight
@ Highlight
Definition
room.h:109
Quotient::Notification::Basic
@ Basic
Definition
room.h:109
Quotient
room.h
Generated by
1.9.8