aboutsummaryrefslogtreecommitdiff
path: root/room.h
AgeCommit message (Collapse)Author
2017-11-02Room: Move away internal methods to not mislead client authorsKitsune Ral
2017-10-30Room::timelineSize() convenience methodKitsune Ral
2017-10-27Support m.room.avatar eventsKitsune Ral
The events are detected in /sync output, and avatars for rooms are loaded from respective URLs. Clients can use Room::avatar() method to request a pixmap of a certain size, and react to avatarChanged() in order to update the UI when new pixmaps/avatars arrive. avatarChanged() signal is overloaded with two tasks - the first firing merely indicates that a new avatar is available (without actual pixmap yet available) while the second firing means that an actual pixmap has arrived (all this is entirely transparent for clients, they just should update their pixmaps from Room::avatar() every time when Room::avatarChanged() is emitted).
2017-10-14Leaving a room now uses a generated Job fileKitsune Ral
2017-10-14Cleanup around Room (potentially breaks API compatibility, beware)Kitsune Ral
Notably: * API for SendEventJob and SetRoomStateJob has been altered to accept references, not pointers. * Methods on Room that invoke requests to the server, have lost const, because they may be reflecting the changed state on the fly, within themselves
2017-10-13Support banning and unbanningKitsune Ral
Closes #38. Also rearranged #includes
2017-10-02Room::id(): return crefKitsune Ral
A cref is still faster than incrementing a refcounter in QString, and all the other COW stuff, and room id is not supposed to change ever.
2017-09-21jobs: SetRoomStateJob (with or without state key); setting room topicKitsune Ral
2017-09-21Merge branch 'master' into kitsune-invite-kickKitsune Ral
2017-09-19Merge branch 'master' into cache-state-to-jsonKitsune Ral
2017-09-09Kicking, inviting, exposing rooms in Invite stateKitsune Ral
Kicking and inviting use generated job classes. Rooms in Invite state are stored separately in the hash from those in Join/Leave state because The Spec says so. For clients, this means that the same room may appear twice in the rooms map if it's been left and then the user was again invited to it. The code in Quaternion that properly processes this will arrive shortly.
2017-09-05Room: memberCount(); slight optimization and reformattingKitsune Ral
2017-09-03More fixesRoman Plášil
2017-08-19Room::localUser() facility methodKitsune Ral
2017-08-16WIP saving intermediate state to JSONRoman Plášil
2017-06-27Enable sending RoomMessageEventsKitsune Ral
1. PostMessageJob is now SendEventJob, which reflects two things: first, it's a PUT instead of a POST (POST for /send is not supported by the latest spec anyway), so that we could enable tracking transaction ids for local echo in the near future; second, it's no more just about messages, the job can support sending any room events (topic changes etc.). 2. Room::postMessage() now uses the new RoomMessageEvent API to send m.room.message events.
2017-06-07Make markAllMessagesAsRead() Q_INVOKABLERoman Plášil
2017-06-02Add Room::memberNames() for nick completion in QMLRoman Plášil
2017-05-22Refactored EventsKitsune Ral
The biggest change is we have no pimpls in Event objects anymore - because it's two new's instead of one per Event, and we have thousands and even more of Events created during initial sync. The other big change is introduction of RoomEvent, so that now the structure of events almost precisely reflects the CS API spec. The refactoring made UnknownEvent unnecessary as a separate class; a respective base class (either RoomEvent or Event) is used for this purpose now. All the other changes are consequences of these (mostly of RoomEvent introduction).
2017-05-13More code cleanup and tweaks; fine-tuning logs; performance improvementsKitsune Ral
After adding some profiling it became clear that to recalculate the room name and emit namesChanged() upon each member event is a waste, especially when there are thousands of those coming at initial sync (*cough* Matrix HQ room). So the room name is recalculated only once and unconditionally (in most cases this will boil down to checking whether name/canonicalAlias changed after processing the events batch), and namesChanged is only emitted once per batch, if any name or alias changed.
2017-05-09LeaveRoomJob now accepts a roomId, not a Room object; Room::leaveRoom() ↵Kitsune Ral
introduced; Connection and Room cleanup Helps to better encapsulate Room
2017-05-09Allow to get a Connection object of the RoomKitsune Ral
It's just natural, after all, Connection is a parent of Room. But seriously, this will be needed when we have rooms from different Connections living next to each other.
2017-05-09Code cleanup and tweaking (partially driven by clang-tidy)Kitsune Ral
Mainly it's about const-ification (in particular, passing const-refs instead of values) and deleting unneeded declarations/#includes. Since the changes alter the external interface, this is submitted as a PR for peer review. One of unneeded declarations/definitions is a virtual destructor in BaseJob descendants. Since a job object should be deleted through QObject::deleteLater() anyway (and it's the only correct way of disposing of the object), all deletions will call the stack of destructors through virtual QObject::~QObject(). Therefore even BaseJob could get on with a non-virtual destructor but for the sake of clarity BaseJob::~BaseJob() is still declared virtual.
2017-04-18Added markAllMessagesAsRead()Kitsune Ral
2017-04-14Enable PostMessageJob to send rich text messagesKitsune Ral
2017-04-05Make Room data Q_PROPERTY's so that they could be accessed from QML tooKitsune Ral
2017-03-14Room: exposed findInTimeline and related things from Room::PrivateKitsune Ral
This will be used from Quaternion for a better algorithm dealing with read markers
2017-03-10Use special indices instead of iterators for persistent pointers into ↵Kitsune Ral
timeline + no more discarding read markers to events that haven't arrived yet When using deque::const_reverse_iterator for read markers and eventsIndex, I didn't realise that insertions into std::deque invalidate iterators (though preserve references and pointers). Therefore, a small TimelineItem class has been introduced that stores an event together with a persistent index that is generated upon insertion into the timeline (timeline.back()+1 for newer events, timeline.front()-1 for older events). Using such indices, we can still reach an event by it's index in constant time, while avoiding a problem with invalidating iterators. While rewriting the code, another problem has been detected with read markers to events that haven't yet arrived to the timeline (in particular, older events). The old code simply discarded such read markers. The new code stores such read markers anyway, so that when that event arrives, it could be matched against the stored last-read-event id.
2017-03-08Room::getPreviousContent() gets a number of messages + Room::postMessage()Kitsune Ral
Also, Room now uses callApi<PostReceiptJob>() instead of postReceipt() (to allow further removal of postReceipt() from Connection)
2017-02-28Room: Make sure an event with the same id isn't added twice to the timeline; ↵Kitsune Ral
forbid empty event id's Added assertions and enhanced debug messages along the way
2017-01-17Room: Use reverse iterators internally to deal with read markersKitsune Ral
Turns out that because the read marker is positioned _after_ the last read message, a reverse iterator models it much better than the usual one. This commit switches the internal representation to reverse iterators (externally, we operate in terms of event id's, still).
2016-11-26Room: provide ability to find an event in the timeline by its idKitsune Ral
A new hashmap, eventsIndex, is provided, that allows you to find the event in the timeline if you have eventId. This hashmap uses the fact that deque iterators don't invalidate upon insertion of elements to either end of the deque. Thanks to that, promoteReadMarker() and doAddNewMessageEvents() have been considerably simplified; also, it should be easier now to calculate event indices without rolling back and forth over the timeline.
2016-11-26Room: use std::deque for the timelineKitsune Ral
2016-11-26CleanupKitsune Ral
2016-11-25Merge pull request #48 from Fxrh/kitsune-unread-messages-in-libKitsuneRal
Unread messages implementation in the library
2016-11-06Use #pragma once everywhereMalte Brandy
2016-11-06Room: extend promoteReadMarker over non-local users (again)Kitsune 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-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-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-14Room::messageEvents: switch to an alias instead of explicit QList<>Kitsune Ral
To facilitate a possible change of a container type.
2016-08-31Room: Drop unused codeKitsune Ral
2016-08-23Fix compilation with Qt 5.2.1Kitsune Ral