aboutsummaryrefslogtreecommitdiff
path: root/room.cpp
AgeCommit message (Collapse)Author
2016-11-26CleanupKitsune Ral
2016-11-07Fixed a crasher that slipped in the previous commitKitsune Ral
Room::Private::member() filters out non-members of the room, which is not the right thing when adding messages from a person that left the room, e.g.
2016-11-07Room::doAddNewMessages: Extend auto-promotion to all users, not only localKitsune Ral
Thanks to @maralorn for pointing out.
2016-11-06Room: extend promoteReadMarker over non-local users (again)Kitsune Ral
2016-11-03Auto-promote the read marker over locally-originated messagesKitsune Ral
2016-11-02Room: make read marker a Q_PROPERTY; markMessagesAsRead now uses eventId againKitsune Ral
The first change allows to use the read marker from QML (hint to Tensor). The second change is actually a fix for a case when markMessagesAsRead() is called with an iterator behind the last read event (in that case markMessagesAsRead() would post a receipt for that older event, which is not quite right).
2016-11-01Moved MemberNameSorter from Quaternion to libKitsune Ral
This code is useful for any client that uses the Room class and needs to display the list of room members. Also removed an unused #include.
2016-10-28Relax logging a bitKitsune Ral
Kicking markMessagesAsRead() at each mouse move is still a bad idea - I'm looking at you Quaternion.
2016-10-28Implemented unread messages indication on the lib sideKitsune Ral
The implementation allows further extension to actually counting unread messages (in their Room::isEventNotable() sense - see the code) but so far just replicates what Quaternion previously provided. The only difference from the Quaternion implementation is that last own message is not marked as read immediately - so that we can allow the local user to send messages while staying with the read marker well above. This implies, though, that the read marker won't reset to the timeline bottom at any movement of the user - rather that it resets to the bottom of the current view (which is the ultimately correct behaviour, anyway).
2016-10-23Room: Don't let the read marker (of any user) get back, only forwardKitsune Ral
2016-10-23A couple of fixes according to the PR reviewKitsune Ral
Room::markMessagesAsRead: use the iterator to the message, not after the message. Room::setLastReadEvent: moved to protected
2016-10-21Room::markMessagesAsRead correctly handles local user's messages nowKitsune Ral
setLastReadEvent() is called in any case (read marks a stored in a hashmap so it's a constant time operation anyway); postReceipt() is now called for the nearest previous non-local message.
2016-10-20Room: added setLastReadEvent accessor and a signal for it; don't post ↵Kitsune Ral
receipts for own messages to the server As discussed with Matthew in #quaternion: https://matrix.to/#/!PCzUtxtOjUySxSelof:matrix.org/$14768896199130qcJqe:matrix.org
2016-10-07Fixed massive leaks of Event objectsKitsune Ral
2016-10-05Check there are no non-members "typing" or "having read" messagesKitsune Ral
Normally, this shouldn't happen anyway - just a double-check,
2016-10-04Changed angle brackets to parentheses for user disambiguationKitsune Ral
This fixes a case when another person mentions you by disambiguated name, and this is not highlighted because Riot uses () and Quaternion uses <> to decorate disambiguated names (as well as to check mentions).
2016-09-21Room: don't emit signals if there are no message events receivedKitsune Ral
2016-09-21Fixed the order of historical messagesKitsune Ral
2016-09-16Group processing of state events as wellKitsune Ral
2016-09-16Room: change the way messages are orderedKitsune Ral
This replaces the one-by-one timestamp-ordering algorithm of adding new messages with copying the whole group of just-arrived messages to either the beginning or the end of the timeline. Since origin timestamps do not provide a reasonable order, findInsertionPos() is entirely deleted. processMessageEvent() is replaced by two functions: addNewMessageEvents() appends at messageEvents.end() while addHistoricalMessageEvents() inserts them at messageEvents.begin(). There's no official way to insert messages in the middle; cases when getPreviousContent() is called in parallel or a RoomMessagesJob runs on a gap somewhere in the middle of the timeline weren't considered before this commit and aren't considered in it. The new ordering requires you to understand where you have got your events from (or rather, where you want to insert them). In particular, updateData() that processes /sync results uses addNewMessageEvents(); getPreviousContent() calls addHistoricalMessageEvents(). In order to notify clients, a single newMessages() signal gives way to 3 new signals: 2 aboutToAdd*Messages() and a common addedMessages(). In addition, clients can derive from Room and use doAdd*Messages() virtual functions to alter/extend the behaviour.
2016-09-15Replace an array of room deconstruction log lines with a single connection ↵Kitsune Ral
deconstruction log line
2016-09-15More compact fix with the same meaningKitsune Ral
2016-09-15Correct user sorting for room name creationFelix Rohrbach
In the previous version, it was possible that u1 >= u2 and u2 >= u1: Assume u1 == me, u1->id() < u2->id() Then u1 >= u2, as u1 == me (i.e. it returns false) but also u2 >= u1, as u2->id() > u1->id() (returns false again) For me, this had the effect of having three rooms called fxrh.
2016-09-14Use Receipt by reference in a loopKitsune Ral
Thanks to Clang for pointing this out.
2016-09-14Room::messageEvents: switch to an alias instead of explicit QList<>Kitsune Ral
To facilitate a possible change of a container type.
2016-09-14Initialize Room::Private more carefullyKitsune Ral
See https://marcmutz.wordpress.com/translated-articles/pimp-my-pimpl- %E2%80%94-reloaded
2016-08-31Room: Drop unused codeKitsune Ral
2016-08-22Replaced QList<> with QVector<> where appropriate + minor code cleanupKitsune Ral
See https://marcmutz.wordpress.com/effective-qt/containers/ for the background and http://lists.qt-project.org/pipermail/development/2015-July/022283.html for the relevant flamewar in Qt dev mailing list.
2016-08-22Minor cleanupKitsune Ral
The two additional braces are due to the fact that array<> is a wrapper around a C-style array, which means I'm initializing a sub-object with a list initialization. Google -Wmissing-braces.
2016-07-29Added roomMembername() overload for userId, in addition to User*Kitsune Ral
2016-06-13Dropped unused codeKitsune Ral
Previously Room::Private used to have a gotMessages() slot; now that it doesn't, it doesn't need to be a QObject either.
2016-05-07Minors: one fix, one cleanupKitsune Ral
2016-05-06Use lambda captures instead of throwing job pointers aroundKitsune Ral
2016-05-02Actually connect User::nameChanged to Room; make a new Room::memberRenamed ↵Kitsune Ral
signal, which clients should use in the room context. Processing changes of user displaynames is tricky: we have to not only deal with the currently renamed user but also with its past and new namesakes which might change representation due to that renaming. So in the worst case a single User::nameChanged signal may lead to three Room::memberRenamed references (and 3 user displaynames updated in the UI, respectively). And the newly added users should be taken care of in a similar manner, of course.
2016-05-02Reworked room name calculation to get rid of do {} while (false)Kitsune Ral
(as requested at PR review)
2016-05-02Calculate room displayname according to CS spec, with a new signal fired on ↵Kitsune Ral
a displayname update. This changes the way displayname is supplied to a client application - instead of calculating immediately, displayname becomes a separate stored value that is refreshed with every change of the list of members, or the name, or the canonical alias. displaynameChanged signal is supplied to subscribe to these updates: in case of displaying a room in the roomlist a client should use this new signal instead of Room::namesChanged. The displaname calculation algorithm is described in section 11.2.2.5 of the CS spec: https://matrix.org/docs/spec/r0.0.1/client_server.html#calculating-the-display-name-for-a-room
2016-05-02Introduced Room::roomMemberName(User*) that follows CS spec section 11.2.2.3Kitsune Ral
2016-05-02Mark read-only accessors in Room::Private as const.Kitsune Ral
2016-05-02Change the way room members are stored to the one recommended by the CS spec.Kitsune Ral
According to section 11.2.2.3 of the CS spec, clients SHOULD follow a certain algorithm of making a non-ambiguous display name of a user in the room context. This algorithm implies checking whether other room members have the same display name. This commit prepares for implementation of the algorithm: 1. Use a hash map instead of a list to store room members. The external Room::users() API is kept intact. 2. Convenience CRUD methods are implemented to deal with the hash map. 3. An additional slot for user renaming is introduced (because renaming affects the hash map). Binding of actual signals is left for the next commit. 4. nullptr is the recommended representation of a null pointer since C++11. Use that and mandate compiler support of that.
2016-05-02Store left room members as well.Kitsune Ral
In particular, this will be needed to render room names according to the CS spec.
2016-04-11Factor out the code that searches an insertion point in a timeline.Kitsune Ral
This is used once in the library and, I guess, twice more in the Quaternion. Implemented as a template function that is equally suitable for Event and Message, and any container that supports STL-style iterators (QList and other Qt containers do).
2016-04-11Drop unneeded check and debug messageKitsune Ral
2016-04-11Don't put excess whitespaces in log lines before QStrings - Qt inserts them ↵Kitsune Ral
automatically.
2016-04-09Merge pull request #1 from davidar/masterFelix Rohrbach
Make Connection parent of Room.
2016-04-09Make Connection parent of Room.David A Roberts
2016-04-08Rename Room::messages to Room::messageEventsKitsune Ral
Originally by Felx Rohrbach (kde@fxrh.de)
2016-04-05Imported the current source tree from Quaternion/lib.Kitsune Ral