aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2021-11-22Fix a crash on trying to mark unknown events as fully readAlexey Rusakov
2021-11-21Log the hexadecimal value of Changes too, just in caseAlexey Rusakov
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-21Minor brushup in the comment to QUO_DECLARE_FLAGSAlexey Rusakov
[skip ci]
2021-11-19CleanupAlexey Rusakov
2021-11-19Make enum values logging more terse()Alexey Rusakov
By default enum class values are logged along with the qualifier; this may or may not be desirable in a given setting. For JoinState(s) and Membership(Mask) operator<< was overloaded to implicitly suppress qualification; however, this is both overly sweeping and uses Qt's internal API for the backend. Instead, a new QDebug manipulator, terse(), is introduced, that does the same as those operator<< overloads but on a per-invocation basis. This makes it slightly more verbose to log enums but makes the QDebug reconfiguration explicit and doesn't require to produce new overloads every time a new enum ends up in logs. And it's built entirely on the published Qt API, reusing the QDebugManip framework that Quotient already has. Also: operator<<(QDebug, QDebugManip) has been moved out of the namespace to fix lookup issues when there's no prior `using namespace Quotient`.
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-17Fix QDateTime(QDate) deprecation warningsAlexey Rusakov
2021-11-17Room: refactoring around logging (esp. profile logs)Alexey Rusakov
2021-11-17Merge branch 'dev' into kitsune-fix-read-receipts-and-markersAlexey Rusakov
# Conflicts: # lib/room.cpp
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-16Merge pull request #520 from TobiasFella/implicitthiscaptureAlexey Rusakov
Port away from implicit 'this' captures in lambdas
2021-11-16Port away from implicit 'this' captures in lambdasTobias Fella
Deprecated with C++20
2021-11-15Port away from deprecated upfront percent encodingTobias Fella
2021-11-12Make ReceiptEvent constructible from contentAlexey Rusakov
Makes the Room::P::toJson() code more readable.
2021-11-12Fix a few quirks in converters.hAlexey Rusakov
2021-11-12Fix building with GCCAlexey Rusakov
It didn't like using QT_IGNORE_DEPRECATIONS inside a statement.
2021-11-11Fix a few quirks in converters.hAlexey Rusakov
2021-11-11Update comments around read receipts codeAlexey Rusakov
2021-11-11Merge branch 'dev' into kitsune-fix-read-receipts-and-markersAlexey Rusakov
2021-11-11DECL_DEPRECATED_ENUMERATORAlexey Rusakov
A handy macro that introduces an enumerator with a respective Q_DECL_DEPRECATED_X recommending the substitution.
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-08Drop unused #includeAlexey Rusakov
2021-11-08Q_DISABLE_MOVE/COPY_MOVE; QT_IGNORE_DEPRECATIONSAlexey Rusakov
DISABLE_MOVE is no more; instead, the library provides Q_DISABLE_MOVE (and also Q_DISABLE_COPY_MOVE while at it) for Qt pre-5.13 that don't have it yet. Same for QT_IGNORE_DEPRECATIONS - it only arrived in 5.15 but all the building pieces existed prior so libQuotient has it regardless of the Qt version used for building.
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-11-03Merge pull request #513 from TobiasFella/editedrepliesAlexey Rusakov
Keep the reply when replacing an event
2021-10-17Room: qualify signal parametersAlexey Rusakov
2021-10-13Connection::resolveServer(): don't connect to loginFlowsJobAlexey Rusakov
Checking whether any login flows are available is a good enough measure of the homeserver actual workability. Closes #515.
2021-10-13connection.h: more doc-commentsAlexey 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-12Omittable: add a deduction guideAlexey Rusakov
Just for completeness, not really needed anywhere yet.
2021-10-12RoomMemberEvent::is*(): fix comparison against OmittableAlexey Rusakov
Closes #514.
2021-10-11formatJson(QDebug): Drop some very old cruftAlexey Rusakov
2021-10-10Room: actually initialise read marker when neededAlexey Rusakov
This fixes the `q->readMarker() != historyEdge()` assertion failure occuring in recalculateUnreadCount() when new events from sync arrive to a room with no read marker and all history loaded.
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-10-10Keep the reply when replacing an eventTobias Fella
2021-10-05Connection: fix C++20 warningsAlexey Rusakov
2021-10-05BaseJob: refresh error handlingAlexey Rusakov
- BaseJob::prepareError() slightly updated to get the current status instead of checking the returned value outside in gotReply() - BaseJob::gotReply() no more reports on 429 Too Many Requests twice (the first time with dubious "Too Many Requests: Unknown error")
2021-10-05BaseJob::StatusCode: officially deprecate most *Error enumeratorsAlexey Rusakov
2021-10-04Room: use more modern Connection APIAlexey Rusakov
2021-10-04Regenerate CS API files upon the previous commitAlexey Rusakov
2021-10-04BaseJob: percent-encode variable path partsAlexey Rusakov
This is meant to spare clients from having to percent-encode room aliases, v3 event ids etc. that happen to hit the endpoint path. It is unfair to expect clients to do that since they are not supposed to care about the shape of CS API, which parameter should be encoded in which way. The trick (together with the slightly updated GTAD configuration) is to percent-encode parts that happen to be QStrings and not `const char[]`'s while passing all constant parts as plain C character literals. This also allows to make it more certain that the path is correctly encoded by passing and storing QByteArray's wherever the path is already encoded, and only use QStrings (next to const char arrays) before that. Since the change alters the API contract (even if that contract was crappy), some crude detection of percent-encoded stuff on input is inserted; if input is already percent-encoded, a warning is put to the logs, alerting developers about the change.
2021-10-04Make connectSingleShot() a tiny wrapper on Qt 6Alexey Rusakov
Qt 6 has Qt::SingleShotConnection; connectSingleShot remains just for the sake of compatibility across Qt 5 and Qt 6. If you target Qt 6 only, feel free to use the Qt facility directly.