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"
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#include <QtQmlIntegration/qqmlintegration.h>
33
34#include <deque>
35#include <utility>
36
37namespace Quotient {
38class Event;
39class Avatar;
40class SyncRoomData;
41class RoomMemberEvent;
42class User;
43class RoomMember;
44struct MemberSorter;
45class LeaveRoomJob;
46class SetRoomStateWithKeyJob;
47class RedactEventJob;
48struct ThreadInfo;
49class ThreadInfos;
50
51/** The data structure used to expose file transfer information to views
52 *
53 * This is specifically tuned to work with QML exposing all traits as
54 * Q_PROPERTY values.
55 */
67public:
70 bool isUpload = false;
71 int progress = 0;
72 int total = -1;
73 QUrl localDir {};
74 QUrl localPath {};
75
76 bool started() const { return status == Started; }
77 bool completed() const { return status == Completed; }
78 bool active() const { return started() || completed(); }
79 bool failed() const { return status == Failed; }
80};
81
82//! \brief Data structure for a room member's read receipt
83//! \sa Room::lastReadReceipt
88public:
91
92 bool operator==(const ReadReceipt& other) const
93 {
95 }
96 bool operator!=(const ReadReceipt& other) const
97 {
98 return !operator==(other);
99 }
100};
102{
105}
106
107struct EventStats;
108
110{
111 enum Type { None = 0, Basic, Highlight };
112 Q_ENUM(Type)
113
115
116private:
117 Q_GADGET
118 Q_PROPERTY(Type type MEMBER type CONSTANT)
119};
120
121class QUOTIENT_API Room : public QObject {
125
143 STORED false)
146
154
170 STORED false)
176
179
181
182public:
188
189 //! \brief Room changes that can be tracked using Room::changed() signal
190 //!
191 //! This enumeration lists kinds of changes that can be tracked with
192 //! a "cumulative" changed() signal instead of using individual signals for
193 //! each change. Specific enumerators mention these individual signals.
194 //! \sa changed
195 enum class Change : quint32 { // QFlags can't go more than 32-bit
196 None = 0x0, //!< No changes occurred in the room
197 RoomNames = 0x1, //!< \sa namesChanged, displaynameChanged
198 // NotInUse = 0x2,
199 Topic = 0x4, //!< \sa topicChanged
200 PartiallyReadStats = 0x8, //!< \sa partiallyReadStatsChanged
201 Avatar = 0x10, //!< \sa avatarChanged
202 JoinState = 0x20, //!< \sa joinStateChanged
203 Tags = 0x40, //!< \sa tagsChanged
204 //! \sa userAdded, userRemoved, memberRenamed, memberListChanged,
205 //! displaynameChanged
206 Members = 0x80,
207 UnreadStats = 0x100, //!< \sa unreadStatsChanged
208 // AccountData pre-0.9 = 0x200,
209 Summary = 0x400, //!< \sa summaryChanged, displaynameChanged
210 // ReadMarker pre-0.9 = 0x800,
211 Highlights = 0x1000, //!< \sa highlightCountChanged
212 //! A catch-all value that covers changes not listed above (such as
213 //! encryption turned on or the room having been upgraded), as well as
214 //! changes in the room state that the library is not aware of (e.g.,
215 //! custom state events) and m.read/m.fully_read position changes.
216 //! \sa encryptionChanged, upgraded, accountDataChanged
217 Other = 0x8000,
218 //! This is intended to test a Change/Changes value for non-emptiness;
219 //! adding <tt>& Change::Any</tt> has the same meaning as
220 //! !testFlag(Change::None) or adding <tt>!= Change::None</tt>
221 //! \note testFlag(Change::Any) tests that _all_ bits are on and
222 //! will always return false.
223 Any = 0xFFFF
224 };
226
230
231 // Property accessors
232
234
235 //! Get a RoomMember object for the local user.
237 const QString& id() const;
239 bool isUnstable() const;
241 /// Room predecessor
242 /** This function validates that the predecessor has a tombstone and
243 * the tombstone refers to the current room. If that's not the case,
244 * or if the predecessor is in a join state not matching \p stateFilter,
245 * the function returns nullptr.
246 */
248 | JoinState::Join) const;
250 /// Room successor
251 /** This function validates that the successor room's creation event
252 * refers to the current room. If that's not the case, or if the successor
253 * is in a join state not matching \p stateFilter, it returns nullptr.
254 */
256 | JoinState::Join) const;
257 QString name() const;
260 //! Get a list of both canonical and alternative aliases
264 // Returns events available locally, use pinnedEventIds() for full list
267 QString topic() const;
270 const Avatar& avatarObject() const;
272
273 int timelineSize() const;
274 bool usesEncryption() const;
277 const QString& senderId,
279 const QByteArray& senderKey,
280 const QByteArray& senderEdKey);
281 int joinedCount() const;
282 int invitedCount() const;
283 int totalMemberCount() const;
284
286
287 /**
288 * Returns a square room avatar with the given size and requests it
289 * from the network if needed
290 * \return a pixmap with the avatar or a placeholder if there's none
291 * available yet
292 */
294 /**
295 * Returns a room avatar with the given dimensions and requests it
296 * from the network if needed
297 * \return a pixmap with the avatar or a placeholder if there's none
298 * available yet
299 */
301
302 //! \brief Get a RoomMember object for the given user Matrix ID
303 //!
304 //! Will return a nullptr if there is no m.room.member event for the user in
305 //! the room so needs to be null checked.
306 //!
307 //! \note This can return a member in any state that is known to the room so
308 //! check the state (using RoomMember::membershipState()) before use.
310
311 //! Get a list of room members who have joined the room.
313
314 //! Get a list of all members known to the room.
316
317 //! Get a list of all members known to have left the room.
319
320 //! Get a list of room members who are currently sending a typing indicator.
322
323 //! \brief Get a list of room members who are currently sending a typing indicator.
324 //!
325 //! The local member is excluded from this list.
327
328 //! Get a list of room member Matrix IDs who have joined the room.
330
331 //! Get a list of all member Matrix IDs known to the room.
333
334 //! \brief Get Matrix IDs for room creator(s)
335 //!
336 //! As long as the create event for the room is known, the returned list will start with
337 //! MXID of the room creation event sender. For room versions 12 and newer, the returned list
338 //! will further include additional creators if there are any.
340
341 //! Whether the name for the given member should be disambiguated
343
344 //! \brief Check the join state of a given user in this room
345 //!
346 //! \return the given user's state with respect to the room
348
349 //! Check whether a user with the given id is a member of the room
350 Q_INVOKABLE bool isMember(const QString& userId) const;
351
353
354 //! \brief Get a avatar of the specified dimensions
355 //!
356 //! This always returns immediately; if there's no avatar cached yet, the call triggers
357 //! a network request, that will emit Room::memberAvatarUpdated() once completed.
358 //! \return a pixmap with the avatar or a placeholder if there's none available yet
360
361 //! \brief Get a square avatar of the specified size
362 //!
363 //! This is an overload for the case when the needed width and height are equal.
365
366 const Timeline& messageEvents() const;
368
369 //! \brief Get the number of requested historical events
370 //! \return The number of requested events if there's a pending request; 0 otherwise
372
373 //! Check whether all historical messages are already loaded
374 //! \return true if the "oldest" event in the timeline is a room creation event and there's
375 //! no further history to load; false otherwise
376 bool allHistoryLoaded() const;
377
378 //! \brief Get a reverse iterator at the position before the "oldest" event
379 //!
380 //! Same as messageEvents().crend()
382
383 const ThreadInfos& threads() const;
384
385 //! \brief Get an iterator for the position beyond the latest arrived event
386 //!
387 //! Same as messageEvents().cend()
392
397
402
403 const RoomCreateEvent* creation() const;
405
406 bool displayed() const;
407 /// Mark the room as currently displayed to the user
408 /**
409 * Marking the room displayed causes the room to obtain the full
410 * list of members if it's been lazy-loaded before; in the future
411 * it may do more things bound to "screen time" of the room, e.g.
412 * measure that "screen time".
413 */
414 void setDisplayed(bool displayed = true);
423
424 //! \brief Get the latest read receipt from a user
425 //!
426 //! The user id must be valid. A read receipt with an empty event id
427 //! is returned if the user id is valid but there was no read receipt
428 //! from them.
429 //! \sa usersAtEventId
431
432 //! \brief Get the latest read receipt from the local user
433 //!
434 //! This is a shortcut for <tt>lastReadReceipt(localUserId)</tt>.
435 //! \sa lastReadReceipt
437
438 //! \brief Find the timeline item the local read receipt is at
439 //!
440 //! This is a shortcut for \code
441 //! room->findInTimeline(room->lastLocalReadReceipt().eventId);
442 //! \endcode
444
445 //! \brief Get the latest event id marked as fully read
446 //!
447 //! This can be either the event id pointed to by the actual latest
448 //! m.fully_read event, or the latest event id marked locally as fully read
449 //! if markMessagesAsRead or markAllMessagesAsRead has been called and
450 //! the homeserver didn't return an updated m.fully_read event yet.
451 //! \sa markMessagesAsRead, markAllMessagesAsRead, fullyReadMarker
453
454 //! \brief Get the iterator to the latest timeline item marked as fully read
455 //!
456 //! This method calls findInTimeline on the result of lastFullyReadEventId.
457 //! If the fully read marker turns out to be outside the timeline (because
458 //! the event marked as fully read is too far back in the history) the
459 //! returned value will be equal to historyEdge.
460 //!
461 //! Be sure to read the caveats on iterators returned by findInTimeline.
462 //! \sa lastFullyReadEventId, findInTimeline
464
465 //! \brief Get users whose latest read receipts point to the event
466 //!
467 //! This method is for cases when you need to show users who have read
468 //! an event. Calling it on inexistent or empty event id will return
469 //! an empty set.
470 //! \note The returned list may contain ids resolving to users that are
471 //! not loaded as room members yet (in particular, if members are not
472 //! yet lazy-loaded). For now this merely means that the user's
473 //! room-specific name and avatar will not be there; but generally
474 //! it's recommended to ensure that all room members are loaded
475 //! before operating on the result of this function.
476 //! \sa lastReadReceipt, allMembersLoaded
478
479 //! \brief Mark the event with uptoEventId as fully read
480 //!
481 //! Marks the event with the specified id as fully read locally and also
482 //! sends an update to m.fully_read account data to the server either
483 //! for this message or, if it's from the local user, for
484 //! the nearest non-local message before. uptoEventId must point to a known
485 //! event in the timeline; the method will do nothing if the event is behind
486 //! the current m.fully_read marker or is not loaded, to prevent
487 //! accidentally trying to move the marker back in the timeline.
488 //! \sa markAllMessagesAsRead, fullyReadMarker
490
491 //! \brief Determine whether an event should be counted as unread
492 //!
493 //! The criteria of including an event in unread counters are described in
494 //! [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654); according
495 //! to these, the event should be counted as unread (or, in libQuotient
496 //! parlance, is "notable") if it is:
497 //! - either
498 //! - a message event that is not m.notice, or
499 //! - a state event with type being one of:
500 //! `m.room.topic`, `m.room.name`, `m.room.avatar`, `m.room.tombstone`;
501 //! - neither redacted, nor an edit (redactions cause the redacted event
502 //! to stop being notable, while edits are not notable themselves while
503 //! the original event usually is);
504 //! - from a non-local user (events from other devices of the local
505 //! user are not notable).
506 //! \sa partiallyReadStats, unreadStats
507 virtual bool isEventNotable(const TimelineItem& ti) const;
508
509 //! \brief Get notification details for an event
510 //!
511 //! This allows to get details on the kind of notification that should
512 //! generated for \p evt.
514
515 //! \brief Get event statistics since the fully read marker
516 //!
517 //! This call returns a structure containing:
518 //! - the number of notable unread events since the fully read marker;
519 //! depending on the fully read marker state with respect to the local
520 //! timeline, this number may be either exact or estimated
521 //! (see EventStats::isEstimate);
522 //! - the number of highlights (TODO).
523 //!
524 //! Note that this is different from the unread count defined by MSC2654
525 //! and from the notification/highlight numbers defined by the spec in that
526 //! it counts events since the fully read marker, not since the last
527 //! read receipt position.
528 //!
529 //! As E2EE is not supported in the library, the returned result will always
530 //! be an estimate (<tt>isEstimate == true</tt>) for encrypted rooms;
531 //! moreover, since the library doesn't know how to tackle push rules yet
532 //! the number of highlights returned here will always be zero (there's no
533 //! good substitute for that now).
534 //!
535 //! \sa isEventNotable, fullyReadMarker, unreadStats, EventStats
537
538 //! \brief Get event statistics since the last read receipt
539 //!
540 //! This call returns a structure that contains the following three numbers,
541 //! all counted on the timeline segment between the event pointed to by
542 //! the m.fully_read marker and the sync edge:
543 //! - the number of unread events - depending on the read receipt state
544 //! with respect to the local timeline, this number may be either precise
545 //! or estimated (see EventStats::isEstimate);
546 //! - the number of highlights (TODO).
547 //!
548 //! As E2EE is not supported in the library, the returned result will always
549 //! be an estimate (<tt>isEstimate == true</tt>) for encrypted rooms;
550 //! moreover, since the library doesn't know how to tackle push rules yet
551 //! the number of highlights returned here will always be zero - use
552 //! highlightCount() for now.
553 //!
554 //! \sa isEventNotable, lastLocalReadReceipt, partiallyReadStats,
555 //! highlightCount
557
558 //! \brief Get the number of notifications since the last read receipt
559 //!
560 //! This is the same as <tt>unreadStats().notableCount</tt>.
561 //!
562 //! \sa unreadStats, lastLocalReadReceipt
564
565 //! \brief Get the number of highlights since the last read receipt
566 //!
567 //! As of 0.7, this is defined by the homeserver as Quotient doesn't process
568 //! push rules.
569 //!
570 //! \sa unreadStats, lastLocalReadReceipt
572
573 /** Check whether the room has account data of the given type
574 * Tags and read markers are not supported by this method _yet_.
575 */
576 bool hasAccountData(const QString& type) const;
577
578 /** Get a generic account data event of the given type
579 * This returns a generic hash map for any room account data event
580 * stored on the server. Tags and read markers cannot be retrieved
581 * using this method _yet_.
582 */
583 const EventPtr& accountData(const QString& type) const;
584
585 //! Get a list of all room account data events
586 //! \return A list of event types that exist in the room
588
590 TagsMap tags() const;
591 Tag tag(const QString& name) const;
592
593 /** Add a new tag to this room
594 * If this room already has this tag, nothing happens. If it's a new
595 * tag for the room, the respective tag record is added to the set
596 * of tags and the new set is sent to the server to update other
597 * clients.
598 */
599 void addTag(const QString& name, const Tag& tagData = {});
600 Q_INVOKABLE void addTag(const QString& name, float order);
601
602 /// Remove a tag from the room
604
605 /// The scope to apply an action on
606 /*! This enumeration is used to pick a strategy to propagate certain
607 * actions on the room to its predecessors and successors.
608 */
610 ThisRoomOnly, ///< Do not apply to predecessors and successors
611 WithinSameState, ///< Apply to predecessors and successors in the same
612 ///< state as the current one
613 OmitLeftState, ///< Apply to all reachable predecessors and successors
614 ///< except those in Leave state
615 WholeSequence ///< Apply to all reachable predecessors and successors
616 };
617
618 /** Overwrite the room's tags
619 * This completely replaces the existing room's tags with a set
620 * of new ones and updates the new set on the server. Unlike
621 * most other methods in Room, this one sends a signal about changes
622 * immediately, not waiting for confirmation from the server
623 * (because tags are saved in account data rather than in shared
624 * room state).
625 * \param applyOn setting this to Room::OnAllConversations will set tags
626 * on this and all _known_ predecessors and successors;
627 * by default only the current room is changed
628 */
630
631 /// Check whether the list of tags has m.favourite
632 bool isFavourite() const;
633 /// Check whether the list of tags has m.lowpriority
634 bool isLowPriority() const;
635 /// Check whether this room is for server notices (MSC1452)
636 bool isServerNoticeRoom() const;
637
638 /// Check whether this room is a direct chat
640
641 /// Get the list of members this room is a direct chat with
643
645 const QUrl &mxcUrl) const;
646
649
650 /// Get a file name for downloading for a given event id
651 /*!
652 * The event MUST be RoomMessageEvent and have content
653 * for downloading. \sa RoomMessageEvent::hasContent
654 */
656
657 /// Get information on file upload/download
658 /*!
659 * \param id uploads are identified by the corresponding event's
660 * transactionId (because uploads are done before
661 * the event is even sent), while downloads are using
662 * the normal event id for identifier.
663 */
666
667 /// Get the URL to the actual file source in a unified way
668 /*!
669 * For uploads it will return a URL to a local file; for downloads
670 * the URL will be taken from the corresponding room event.
671 */
673
674 /** Pretty-prints plain text into HTML
675 * As of now, it's exactly the same as Quotient::prettyPrint();
676 * in the future, it will also linkify room aliases, mxids etc.
677 * using the room context.
678 */
680
682
683 /// Whether the current user is allowed to upgrade the room
685
686 /// \brief Get the current room state
688
689 //! \brief The current Join Rule for the room
690 //!
691 //! \sa https://spec.matrix.org/latest/client-server-api/#mroomjoin_rules
693
694 //! \brief Set the Join Rule for the room
695 //!
696 //! If the local user does not have a high enough power level the request is rejected.
697 //!
698 //! \param newRule the new JoinRule to apply to the room
699 //! \param allowedRooms only required when the join rule is restricted. This is a
700 //! list of room IDs that members of can join without an invite.
701 //! If the rule is restricted and this list is empty it is treated as a join
702 //! rule of invite instead.
703 //!
704 //! \note While any room ID is permitted it is designed to be only spaces that are
705 //! input. I.e. only memebers of space `x` can join this room.
706 //!
707 //! \sa https://spec.matrix.org/latest/client-server-api/#mroomjoin_rules
709
710 //! \brief The list of Room IDs for when the join rule is Restricted
711 //!
712 //! This value will be empty when the Join Rule is not Restricted or
713 //! Knock-Restricted.
714 //!
715 //! \sa https://spec.matrix.org/latest/client-server-api/#mroomjoin_rules
717
718 //! \brief The effective power level of the given member in the room
719 //!
720 //! This is normally the same as calling `RoomPowerLevelEvent::powerLevelForUser(userId)` but
721 //! takes into account the room context and works even if the room state has no power levels
722 //! event. It is THE recommended way to get a room member's power level to display in the UI.
723 //! \param memberId The room member ID to check; if empty, the local user will be checked
724 //! \sa RoomPowerLevelsEvent, https://spec.matrix.org/v1.11/client-server-api/#mroompower_levels
726
727 //! \brief Get the power level required to send events of the given type
728 //!
729 //! \note This is a generic method that only gets the power level to send events with a given
730 //! type. Some operations have additional restrictions or enablers though: e.g.,
731 //! room member changes (kicks, invites) have special power levels; on the other hand,
732 //! redactions of one's own messages are allowed regardless of the power level.
733 //! The library has no method to check effective ability to perform an operation as yet;
734 //! you have to either blindly make a call to the homeserver or implement the logic
735 //! described in the Federation API and respective room versions, in the client code.
736 //! \note Unlike the template version below, this method determines at runtime whether an event
737 //! type is that of a state event, assuming unknown event types to be non-state; pass
738 //! `true` as the second parameter to override that.
739 //! \sa canSwitchVersions
741
742 //! \brief Get the power level required to send events of the given type
743 //!
744 //! This is an optimised version of non-template powerLevelFor() (with the same caveat about
745 //! operations based on some event types) for cases when the event type is known at build time.
746 //! \tparam EvT the event type to get the power level for
747 template <EventClass EvT>
748 int powerLevelFor() const
749 {
751 }
752
753 //! \brief Post a pre-created room message event
754 //!
755 //! Takes ownership of the event, deleting it once the matching one arrives with the sync.
756 //! \note Do not assume that the event is already on the road to the homeserver when this (or
757 //! any other `post*`) method returns; it can be queued internally.
758 //! \sa PendingEventItem::deliveryStatus()
759 //! \return a reference to the pending event item
761
762 template <typename EvT, typename... ArgTs>
764 {
765 return post(makeEvent<EvT>(std::forward<ArgTs>(args)...));
766 }
767
768 //! \brief Send a text type message
769 //!
770 //! This means MessageEventType Text, Emote or Notice.
773 const std::optional<QString>& html = std::nullopt,
775 {
776 static_assert(type == MessageEventType::Text ||
779 "MessageEvent type is not a text message"
780 );
781
783 if (html) {
784 content = std::make_unique<EventContent::TextContent>(*html, u"text/html"_s);
785 }
787 }
788
789 //! Send a file with the given content
793
794 //! Send the given Json as a message
796
797 //! Send a reaction on a given event with a given key
799
801
802 //! Send a request to update the room state with the given event
804
805 //! \brief Set a state event of the given type with the given arguments
806 //!
807 //! This type-safe overload attempts to send a state event of the type \p EvT constructed from
808 //! \p args.
809 template <typename EvT, typename... ArgTs>
810 auto setState(ArgTs&&... args)
811 {
812 return setState(EvT(std::forward<ArgTs>(args)...));
813 }
814
816
818
820
821 //! \brief Upgrade the room to \p newVersion
822 //!
823 //! Triggers an upgrade process that puts the tombstone event on the current room and creates
824 //! a new room of the specified version. It is possible to specify \p additionalCreators for
825 //! room versions that support those (unfortunately it is only possible to find out whether
826 //! a given room version supports additional creators by attempting to upgrade a room).
827 //! \return a future eventually holding a new room once it arrives via sync
830
831public Q_SLOTS:
832 /** Check whether the room should be upgraded */
834
837
838 //! Send a request to update the room state based on freeform inputs
840 const QString& stateKey,
841 const QJsonObject& contentJson);
842 void setName(const QString& newName);
845 /// Set room aliases on the user's current server
848
849 /// You shouldn't normally call this method; it's here for debugging
851
853
856 void kickMember(const QString& memberId, const QString& reason = {});
857 void ban(const QString& userId, const QString& reason = {});
858 void unban(const QString& userId);
859 void redactEvent(const QString& eventId, const QString& reason = {});
860
862 const QString& overrideContentType = {});
863 // If localFilename is empty a temporary file is created
864 void downloadFile(const QString& eventId, const QUrl& localFilename = {});
866
867 //! \brief Set a given event as last read and post a read receipt on it
868 //!
869 //! Does nothing if the event is behind the current read receipt.
870 //! \sa lastReadReceipt, markMessagesAsRead, markAllMessagesAsRead
872 //! Put the fully-read marker at the latest message in the room
874
875 //! Switch the room's version (aka upgrade)
876 [[deprecated("Use upgrade() instead")]]
878
879 void inviteCall(const QString& callId, const int lifetime,
880 const QString& sdp);
882 void answerCall(const QString& callId, const QString& sdp);
884
885 /**
886 * Activates encryption for this room.
887 * Warning: Cannot be undone
888 */
890
892 /// Initial set of state events has been loaded
893 /**
894 * The initial set is what comes from the initial sync for the room.
895 * This includes all basic things like RoomCreateEvent,
896 * RoomNameEvent, a (lazy-loaded, not full) set of RoomMemberEvents
897 * etc. This is a per-room reflection of Connection::loadedRoomState
898 * \sa Connection::loadedRoomState
899 */
905 /// The event is about to be appended to the list of pending events
907 /// An event has been appended to the list of pending events
909 /// The remote echo has arrived with the sync and will be merged
910 /// with its local counterpart
911 /** NB: Requires a sync loop to be emitted */
914 /// The remote and local copies of the event have been merged
915 /** NB: Requires a sync loop to be emitted */
917 /// An event will be removed from the list of pending events
919 /// An event has just been removed from the list of pending events
921 /// The status of a pending event has changed
922 /** \sa PendingEventItem::deliveryStatus */
924 /// The server accepted the message
925 /** This is emitted when an event sending request has successfully
926 * completed. This does not mean that the event is already in the
927 * local timeline, only that the server has accepted it.
928 * \param txnId transaction id assigned by the client during sending
929 * \param eventId event id assigned by the server upon acceptance
930 * \sa postEvent, postPlainText, postMessage, postHtmlMessage
931 * \sa pendingEventMerged, aboutToAddNewMessages
932 */
934
935 //! A new thread has been created/added in the room
937
938 /** A common signal for various kinds of changes in the room
939 * Aside from all changes in the room state
940 * @param changes a set of flags describing what changes occurred
941 * upon the last sync
942 * \sa Changes
943 */
945 /**
946 * \brief The room name, the canonical alias or other aliases changed
947 *
948 * Not triggered when display name changes.
949 */
956
957 //! \brief The join rule for the room has changed
959
960 //! \brief A new member has joined the room
961 //!
962 //! This can be from any previous state or a member previously unknown to
963 //! the room.
965
966 //! \brief A member who previously joined has left
967 //!
968 //! The member will still be known to the room their membership state has changed
969 //! from Membership::Join to anything else.
971
972 //! A known joined member is about to update their display name
974
975 //! A known joined member has updated their display name
977
978 //! A known joined member has updated their avatar
980
981 /// The list of members has changed
982 /** Emitted no more than once per sync, this is a good signal to
983 * for cases when some action should be done upon any change in
984 * the member list. If you need per-item granularity you should use
985 * userAdded, userRemoved and memberAboutToRename / memberRenamed
986 * instead.
987 */
989
990 /// The previously lazy-loaded members list is now loaded entirely
991 /// \sa setDisplayed
994
997
998 //! The list of members sending typing indicators has changed.
1000
1001 void highlightCountChanged(); ///< \sa highlightCount
1002 void notificationCountChanged(); ///< \sa notificationCount
1003
1007 //! The event the m.read receipt points to has changed for the listed users
1008 //! \sa lastReadReceipt
1014
1019
1022 const Quotient::RoomEvent* oldEvent);
1023
1029 // fileTransferCancelled() is no more here; use fileTransferFailed() and
1030 // check the transfer status instead
1031
1033
1034 /// The room's version stability may have changed
1037 /// This room has been upgraded and won't receive updates any more
1039 /// An attempted room upgrade has failed
1041
1042 /// The room is about to be deleted
1044
1045protected:
1049 virtual void onAddNewTimelineEvents(timeline_iter_t /*from*/) {}
1051 virtual void onRedaction(const RoomEvent& /*prevEvent*/,
1052 const RoomEvent& /*after*/)
1053 {}
1054 virtual QJsonObject toJson() const;
1055 virtual void updateData(SyncRoomData&& data, bool fromCache = false);
1057
1058private:
1059 friend class Connection;
1060
1061 class Private;
1062 Private* d;
1063
1064 // This is called from Connection, reflecting a state change that
1065 // arrived from the server. Clients should use
1066 // Connection::joinRoom() and Room::leaveRoom() to change the state.
1068};
1069
1070template <typename RangeT, typename ValT, typename CompT = MemberSorter,
1071 typename ProjT = std::identity>
1074[[deprecated("Use std::ranges::lower_bound(range, ...) - std::ranges::begin(range)")]]
1075inline std::ranges::range_size_t<RangeT> lowerBoundMemberIndex(const RangeT &rng, const ValT &val,
1076 CompT comp = {}, ProjT proj = {})
1077{
1078 return std::ranges::lower_bound(rng, val, std::move(comp), std::move(proj))
1079 - std::ranges::begin(rng);
1080}
1081} // namespace Quotient
1083Q_DECLARE_METATYPE(Quotient::ReadReceipt)
1084Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::Room::Changes)
Data structure for a room member's read receipt.
Definition room.h:84
void swap(ReadReceipt &lhs, ReadReceipt &rhs)
Definition room.h:101
std::ranges::range_size_t< RangeT > lowerBoundMemberIndex(const RangeT &rng, const ValT &val, CompT comp={}, ProjT proj={})
Definition room.h:1075
#define QUO_DECLARE_FLAGS(Flags, Enum)
Quotient replacement for the Q_FLAG/Q_DECLARE_FLAGS combination.
#define QUOTIENT_API