aboutsummaryrefslogtreecommitdiff
path: root/lib/room.h
AgeCommit message (Collapse)Author
2021-11-27Merge pull request #518 from Smittyvb/room-stateEventsAlexey Rusakov
2021-11-26Add Room::{stateEventsOfType,currentState}Smitty
This is useful for implementing Spaces support, where all events of type `m.space.child` are needed, and we don't know their state keys in advance.
2021-11-26Room::processEphemeralEvents: Fix updatedCount always being zeroAlexey Rusakov
Trying to test bits with Changes::testFlag(Change::Any) was a bad idea. Along the way: made logging in setLastReadReceipt() refer to the actual timeline item when possible.
2021-11-21Document Room::Change and its enumeratorsAlexey Rusakov
2021-11-21EventStats and Room::partiallyRead/unreadStats()Alexey Rusakov
This introduces a new API to count unread events that would allow to obtain those unread and highlight counts since either the fully read marker (Room::partiallyReadStats) or the last read receipt (Room::unreadStats). Element uses the read receipt as the anchor to count unread numbers, while Quaternion historically used the fully read marker for that (with the pre-0.7 library sticking the two markers to each other). From now on the meaning of "unread" in Quotient is aligned with that of the spec and Element, and "partially read" means events between the fully read marker and the local read receipt; the design allows client authors to use either or both counting strategies as they see fit. Respectively, Room::P::setFullyReadMarker() updates partially-read statistics, while Room::P::setLastReadReceipt(), when called on a local user, updates unread statistics. Room::notificationCount() and Room::highlightCount() maintain their previous meaning as the counters since the last read receipt; Room::notificationCount() counts unread events locally, falling back to the value from the above-mentioned key defined by MSC2654, and if that is not there, further to `unread_notifications/notification_count` defined in the current spec. Room::highlightCount(), however, is still taken from the homeserver, not from Room::unreadStats().highlightCount.
2021-11-21Room::Private::postprocessChanges()Alexey Rusakov
This makes updating display name and emission of necessary signals including Room::changed() more systematic when it has to occur outside of updateData() flow - e.g. when loading all members.
2021-11-21SyncData: support MSC2654; partiallyReadCountAlexey Rusakov
Since MSC2654's unread count is counted from the m.read receipt, and the course is to follow the spec's terminology and use "unread count" for the number of notable events since m.read, this required to move the existing number of notable events since m.fully_read to another field, henceforth called partiallyReadCount. At the same time, SyncData::notificationCount is dropped completely since MSC2654 claims to supersede it. Also: Room::resetNotificationCount() and Room::resetHighlightCount() are deprecated, as these never worked properly overwriting values that can be calculated or sourced from the server, only for these values to be set back again the next time the room is updated from /sync.
2021-11-21Room: isEventNotable, notificationFor, checkForNotificationsAlexey Rusakov
Room::isEventNotable has been moved out from Room::Private and made compliant with MSC2654. The concept of Room::checkForNotifications is taken from Quaternion where a method with the same name has been in QuaternionRoom for a long time - however, actual body is a stub for now, always returning { Notification::None } (Quaternion's implementation is too crude to be taken to the library). Now we really need a pushrules processor to fill this method with something reasonably good. Internally the library now calls checkForNotifications() on every event added to the timeline, filling up the events-to-notifications map because it is anticipated that calculation of notifications can be rather resource-intensive and should only be done once for a given event. Finally, Room::notificationsFor is an accessor into the mentioned map, standing next to isEventNotable (but unlike isEventNotable, it's not virtual; checkForNotifications is).
2021-11-18Make Room::Changes an enum class; simplify enumeratorsAlexey Rusakov
This enumeration sees very limited (if any) use outside Quotient; and though this change will surely break code using it the fix is very straightforward and quick.
2021-11-17Room: lastLocalReadReceipt(), localReadReceiptMarker()Alexey Rusakov
To simplify retrieval of the local m.read receipt and the marker for it.
2021-11-17Room: doc-comments cleanupAlexey Rusakov
[skip ci]
2021-11-17Bind read receipts to userIds, not to User* valuesAlexey Rusakov
This reduces the surface interacting with the User class that eventually will be split into LocalUser (most part) and RoomMember (a tiny wrapper around the member data in a given room, used almost everywhere in Room where User currently is). Also: dropped a log message when the new receipt is at or behind the old one as it causes a lot of noise in the logs.
2021-11-11Merge branch 'dev' into kitsune-fix-read-receipts-and-markersAlexey Rusakov
2021-11-08Room::Change: deprecate AccountDataChange, ReadMarkerChangeAlexey Rusakov
These usually don't affect the room outlooks in the room list in any way; so can be merged into OtherChange instead. Also: OtherChanges synonym has been added, implying that there might be more than one change behind a single "Other" flag.
2021-11-07Add method to get all state events in a roomSmitty
It is useful to be able to get all of the state events that have occured in a room, instead of needing to use Room::getCurrentState, which filters based on the event type and state key.
2021-10-17Room: qualify signal parametersAlexey Rusakov
2021-10-12Make sure to expose both the flags type and the underlying enumAlexey Rusakov
See also https://bugreports.qt.io/browse/QTBUG-82295.
2021-10-10ReadReceipt::operator==/!=: Add const where it's dueAlexey Rusakov
2021-10-10Merge branch 'master' into kitsune-fix-read-receipts-and-markersAlexey Rusakov
2021-09-12Merge pull request #506 from TobiasFella/activateencryptionAlexey Rusakov
Add convenience function for activating encryption
2021-09-12Merge pull request #499 from TobiasFella/mxcnamAlexey Rusakov
Implement the mxc protocol in the NetworkAccessManager
2021-09-11Add convenience function for activating encryption and fixTobias Fella
EncryptionEvent constructor
2021-09-10Move URL creation to Room/Connection; use query instead of fragmentAlexey Rusakov
The query is easier to manipulate; and the original mxc URL is not used for the real network request anyway.
2021-09-09Straighten up file transfer cancellationAlexey Rusakov
There was a mess with fileTransferCancelled(); it was only emitted when a download (but not an upload) was cancelled; besides, in case of downloads a file transfer info structure was getting deleted whereas uploads left a file transfer in Cancelled status. This all now converges on: - fileTransferFailed() for both failures and cancellations (to simplify slot connection, and also to follow the practice in, e.g., Qt Network). - the file transfer info structure is kept around in Cancelled status, following the logic used for failures. There's no particular cleanup which may become a problem if one uploads and cancels many times (download file transfers are keyed to event ids, mitigating the problem); this will be fixed in another commit. Closes #503. Closes #504.
2021-08-30Room: displayNameForHtmlAlexey Rusakov
This is useful for cases when the room display name is returned to QML that doesn't have an equivalent of QString::toHtmlEscaped().
2021-08-23Room: isMember(); memberState() only needs user idAlexey Rusakov
Room::memberJoinState() was only used to check if the user has joined the room (it couldn't be used for anything else), meaning that its best replacement is actually not memberState() but isMember() introduced hereby. It's also better to pass user ids instead of User objects to memberState() and isMember() since that is enough to check membership. # Conflicts: # lib/room.cpp # lib/room.h
2021-08-22Use Q_DECL_DEPRECATED_X instead of \deprecated doc-commentAlexey Rusakov
This still works with older moc yet produces actual warnings when compiling C++ code.
2021-07-31Room: Mark dependent Q_PROPERTYs as STORED falseAlexey Rusakov
hasUnreadMessages is derived from unreadCount; isFavourite/isLowPriority effectively depend on tagNames.
2021-07-31Add/update doc-comments on the new/updated methodsAlexey Rusakov
[skip ci]
2021-07-30Room::setReadReceipt()Alexey Rusakov
2021-07-30Merge branch 'master' into kitsune-fix-read-receipts-and-markersAlexey Rusakov
2021-07-30Quotient::ReadReceipt; deprecated readMarker()Alexey Rusakov
It's now possible to get receipts along with their timestamps by calling Room::lastReadReceipt(). Together this new method, fullyReadMarker(), and lastFullyReadEventId() deprecate readMarker() overloads and readMarkerEventId() respectively. lastFullyReadEventId is also a Q_PROPERTY (deprecating readMarkerEventId); readMarkerMoved() signal is deprecated by fullyReadMarkerMoved(), while readMarkerForUserMoved() is deprecated in favour of existing lastReadEventChanged().
2021-07-30Room: drop 0.6 deprecations; deprecate RoomAliasEventAlexey Rusakov
Namely memberCount(), localAliases(), remoteAliases(), timelineEdge().
2021-07-30FormattingAlexey Rusakov
2021-07-28Room::usersAtEventId(): switch from QMultiHash to QHash of QSetsAlexey Rusakov
While slightly more complex for updating, this allows COW to kick in in the read accessor; using QSet instead of QList also provides better consistency guarantees. For QML both are converted to an Array-like collection since Qt 5.15; Qt 5.12 turns QSet<> in a QVariantList, according to the documentation, which is quite reasonable too.
2021-07-18MembershipType -> Membership, also used for JoinStateAlexey Rusakov
Instead of being defined independently, JoinState now uses values from the Membership enumeration (former MemberEventContent::MembershipType) that was moved to quotient_common.h for that purpose. Both enumerations gained a Q_FLAG_NS decoration and operator<< overrides that strip "Quotient::" prefix when dumping member/join state values to the log - obviating toCString(JoinState) along the way. Quotient::MembershipType alias is deprecated from now.
2021-07-18Room::postFile(): adjust to the changed RoomMessageEvent APIAlexey Rusakov
9a5fa623 dropped one of RoomMessageEvent constructors for Qt 6 in order to address #483 - breaking the build with Qt 6 along the way, as Room::postFile() relied on that constructor. This commit changes Room::postFile() in turn, deprecating the current signature and adding a new one that accepts an EventContent object rather than a path to a file. In order to achieve that, FileInfo and ImageInfo classes have gained new constructors that accept QFileInfo instead of the legacy series of parameters, streamlining usage of EventContent structures.
2021-06-13uri.cpp, room.*: Get rid of QStringRefsAlexey Rusakov
2021-01-16Updated copyright statements upon Git auditKitsune Ral
After going through all the files and the history of commits on them it was clear that some copyright statements are obsolete (the code has been overwritten since) and some are missing. This commit tries best to remedy that, along with adding SPDX tags where they were still not used. Also, a minimal SPDX convention is documented for further contributions. Closes #426.
2020-12-26Port existing copyright statement to reuse using licensediggerCarl Schwan
2020-11-27Make it compile with QT_NO_KEYWORDSCarl Schwan
2020-11-08Room: drop setMemberState()Kitsune Ral
2020-11-08More robust member profile data retrievalKitsune Ral
MemberEventContent: displayname and avatarUrl are now Omittables; CS API doesn't guarantee their presence (see also https://github.com/matrix-org/matrix-doc/issues/1375) but Quotient used to assume they are always there, causing #412. RoomMemberEvent: displayname() -> newDisplayName() and avatarUrl() -> newAvatarUrl(), to emphasise the actual semantics (and also the changed interface). The old signatures still work but are deprecated. Instead of roomMembername() (with weird camel-casing), three new methods in addition to safeMemberName() are introduced to Room: - memberName() - produces the "best known" display name for a given member; User::name() uses it to avoid the pitfall of #412. - disambiguatedMemberName() - this is what roomMembername() used to be; not recommended for direct use when UI is concerned. - safeMemberName() - remains as is, with the fix to the documentation that used to mislead that the function returns HTML-escaped content (it didn't, and doesn't). - htmlSafeMemberName() - does what safeMemberName() claimed to do. Respectively, memberNames() is deprecated in favor of safeMemberNames() and htmlSafeMemberNames(). The corresponding Q_PROPERTY uses safeMemberNames() now. Similar to memberName(), Room has got memberAvatarUrl() to spare User class from diving into Room state to find the member avatar URL. Closes #412.
2020-10-27Added filter param to getPreviousContent so that a server side filterJohn
can be applied.
2020-08-04User: optimise names/avatars storing and updatingKitsune Ral
The current mechanism relied on a complicated and fragile machinery around setNameForRoom() and setAvatarForRoom() that maintained the "most used" entity for a given user along with "other" ones. Given that per-room avatars are pretty rare in Matrix, it's also been inefficient as kitsune-benchmark-set_ForRoom branch shows. The new mechanism stores the "default" (as per user profile) name and avatar and maintains a singleton map of avatar objects across all users. Per-user profile only (normally) exists for the local user so there's yet another inefficiency that will be fixed further down the road by introducing a separate user profile class.
2020-04-12Room::safeMemberName()Kitsune Ral
Pulled from Quaternion code.
2020-04-12Room::canSwitchVersions(): refactor and make Q_INVOKABLEKitsune Ral
2020-03-26Refactoring around Connection::onSyncSuccess()Kitsune Ral
The method grew large and a bit unwieldy over the years.
2020-03-23Expose aliases() and altAliases() as propertiesBlack Hat
2020-03-21Merge pull request #383 from ram-nad/msc2432-fixKitsune Ral
fixing msc2432