aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
AgeCommit message (Collapse)Author
2021-10-10Merge branch 'master' into kitsune-fix-read-receipts-and-markersAlexey Rusakov
2021-10-04Room: use more modern Connection APIAlexey 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-08-10Room::Private::sync/historyEdge()Alexey Rusakov
Move Room::sync/historyEdge() implementation to Room::Private, so that internal logic could use the same readable shortcuts without q-> prefixes, instead of timeline.crend() and timeline.cend() that are much less readable.
2021-08-09Room::setDisplayed(): Don't reset unread countersAlexey Rusakov
Closes #489.
2021-08-09Room::toJson(): save the last local user's read receiptAlexey Rusakov
Read receipts are entangled with counting unread messages, and saving them also helps in not sending receipts for too old events. Other users' read receipts are still treated as truly ephemeral.
2021-08-09Enhanced logging for read receiptsAlexey Rusakov
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-30Use a better type in makeRedactedAlexey Rusakov
2021-07-30Room: drop 0.6 deprecations; deprecate RoomAliasEventAlexey Rusakov
Namely memberCount(), localAliases(), remoteAliases(), timelineEdge().
2021-07-28Room: fix the read markers/receipts confusionAlexey Rusakov
This turns the design changes laid out in #464 comments to code, as of 0.6.x branch (0.7 API will be introduced separately): - readMarker() now returns the fully read marker, unlike readMarker(User*) that returns a read receipt, even when called for the local user. - Private::setLastReadEvent() -> setLastReadReceipt(), incorporating the "promotion" logic from promoteReadReceipt(). - The above makes promoteReadReceipt() unneeded; the remaining piece of logic that recalculates the number of unread messages is put to its own method - Private::recalculateUnreadCount(). - Private::updateUnreadCount() is only slightly refreshed, continues to use the fully read marker position (as it used to). - Now that read receipts and fully read markers are managed separately, Private::setLastReadReceipt() has got its counterpart, Private::setFullyReadMarker(); both only update their respective markers locally (emitting signals as needed), without interaction with the homeserver. - Private::markMessagesAsRead() now delegates updating the fully read marker to setFullyReadMarker() and on top of that sends the new fully read marker to the homeserver. - Private::serverReadMarker -> fullyReadUntilEventId (to be really clear what it stores). - The hand-written PostReadMarkersJob is replaced with the generated SetReadMarkerJob that does the same thing (and can update the read receipt on top).
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-28setFirst/LastDisplayedEvent(): warn about unloaded eventsAlexey Rusakov
2021-07-24Wrap SyncRoomData counters into OmittablesAlexey Rusakov
Also: introduce a merge(T1&, const Omittable<T2>&) that does pretty much the same as Omittable<T1>::merge(const Omittable<T2>&) except it works on non-omittables as the left/first operand. The change removes the need for a clumsy -2 fallback in unreadCount, and makes the logic loading those counters cleaner along the way.
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-07-11Fix Room::processAccountDataEvent() return valueAlexey Rusakov
(cherry picked from commit 7b65051e959968fe538f40c975d85757cfcc7df7) (cherry picked from commit 9edfefe9b209583d18ce92e7ffd73e8aa1f3ef1e)
2021-06-13uri.cpp, room.*: Get rid of QStringRefsAlexey Rusakov
2021-06-12Adjust to new moc/QMetaType requirementsAlexey Rusakov
See https://www.qt.io/blog/whats-new-in-qmetatype-qvariant#qmetatype-knows-your-properties-and-methods-types
2021-01-25Room::P::removeMemberFromMap: comment that Q_ASSERTAlexey Rusakov
Maybe it's not even that bad, given that an effort is taken to recover from the internal member list corruption.
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.
2021-01-15Merge branch 'master' into dfaure/stricter-flagsKitsune Ral
2021-01-15Merge pull request #428 from ognarb/licensingKitsune Ral
Port existing copyright statement to reuse using licensedigger
2021-01-07isJobRunning() -> isJobPending()Kitsune Ral
To be very clear what this function checks. See also #437.
2020-12-28Room: inline a once-used variableKitsune Ral
2020-12-28Room: really fix namesakes assertion failureKitsune Ral
This removes now-deprecated RoomMemberEvent API usages and also does a few more things differently from the stable branch. Rather than rely on prev_content (the way pre-0.7 goes), processStateEvent() now includes a pre-check for no-op state events (the fix in ff020f3b turned out to be insufficient for such events and they still caused the same assertion failure at some point down the line). Now the state event is only added to currentState and, where relevant, to baseState, if it actually changes the room state; otherwise, it is ignored for the purpose of state tracking (even when still added to the timeline, if it came in the timeline block). One side-effect of this change is that processStateEvent() now returns OtherChange instead of NoChange for unknown state events. At the same time removeMemberFromMap() now has an additional safety net, making sure that a given user is actually deleted from the map even if their name is mismatched. This comes at a cost of looking through the whole hashmap but normally should not occur with the current code that shaves away no-op state events. We'll only see when some client starts to actively use 0.7 (quotest doesn't trigger those).
2020-12-28Use generated SetReadMarkerJob instead of PostReadMarkersJobKitsune Ral
2020-12-28Cleanup and clang-tidy/clazy fixesKitsune Ral
2020-12-26Port existing copyright statement to reuse using licensediggerCarl Schwan
2020-12-24Room: don't accept . at 0-th position in the tagKitsune Ral
Also: use a structured binding for better code readability. (cherry picked from commit 66972c81d018231f08f3767feda4b41ae5e1b8e0)
2020-12-24Fix clang-tidy/clazy warningsKitsune Ral
(cherry picked from commit 0a2acd750a4155969092be674ed3dd9a71b2354f)
2020-12-03Room: fix breakage in internal member mapKitsune Ral
The change in 39830496 led to prev_content becoming a fallback not only for displaying user names but also for storing them in the internal member map, which is really not what was intended. A lot of debug logging has been added - this will be moved to a new logging category before merging.
2020-11-26Enable QT_NO_URL_CAST_FROM_STRING and QT_STRICT_ITERATORS.David Faure
* QT_NO_URL_CAST_FROM_STRING makes it clearer where QUrls are created from QStrings (which incurs a parsing cost). * QT_STRICT_ITERATORS helps detecting where begin()/end() is used instead of cbegin()/cend(). KDE developers have verified that the generated assembly code is identical.
2020-11-19Fix Q_ASSERT failure on sending messagesKitsune Ral
Changes in e81117fb exposed a flaw in EncryptionEvent causing assertion failure when this event is default-initialised (i.e. no encryption).
2020-11-15Cleanup across event classesKitsune Ral
In particular: removed unnecessary #includes, deprecated and no more used constructs, replaced stored members with dynamic generation from JSON (TypingEvent and, especially promising for performance, ReceiptEvent)
2020-11-14CleanupKitsune Ral
2020-11-12Room: add power level events to redaction rulesKitsune Ral
2020-11-12More JSON key constantsKitsune Ral
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.