aboutsummaryrefslogtreecommitdiff
path: root/room.cpp
AgeCommit message (Collapse)Author
2018-01-17Room::getPreviousContent(): Don't skip if the last job just finishedKitsune Ral
working The sequence is: RoomMessagesJob::success -> addHistoricalMessageEvents -> MessageEventModel notification -> QML notification about model reset -> MessageEventModel completes updating -> QML updates from the model but by then scrolling has already stopped at the oldest (just loaded) event -> since there's no momentum, next batch is not fetched. In order to address this, two things are done: in QML, the current position is checked in modelReset() handler; in Room (this commit), prev_batch is updated before historical messages are added (and the model gets notified, respectively), to prevent firing another job with the old prev_batch.
2018-01-17Room::downloadFile(): make sure temporary file names don't clashKitsune Ral
Particularly in case when there are two events that have an image with the same file name (image.png).
2018-01-15One more fix, this time for MSVC 2015 onlyKitsune Ral
Making a structure from an initializer list seems to be a problem for it if initializers are defined in the structure.
2018-01-14RoomEvent-aware file up/downloads along with status trackingKitsune Ral
Closes #121; closes #122.
2018-01-12Qualify a bind() invocation with 'std::'; use an actual value instead of a ↵Kitsune Ral
placeholder An unqualified bind() seems to upset some build environments; also, use a User* value at hand instead of binding it at the moment of signal-slot triggering.
2018-01-06Add a missing #includeKitsune Ral
std::bind belongs to <functional>, don't rely on implicitly including it from other standard headers.
2017-12-28Switch from QPixmap to QImage; add convenience avatar() overloads to Room ↵Kitsune Ral
and User The switch is necessary because MediaThumbnailJob is supposed to return something that can be worked on in non-GUI threads (as is the case of QML image providers), and QPixmap is not supposed for usage out of the main thread.
2017-12-25Room: Remove C++14 code from the header fileKitsune Ral
This will provide some backwards-compatibility to clients that are not ready to move _their_ code to C++14 (at least, it will allow them to not add C++14 requirement to their makefiles as of yet).
2017-12-25Now really switching to the new toolchain: C++14, GCC/Clang 5, Qt 5.6Kitsune Ral
Also a bit of code tightening with some C++14 (but not only) things.
2017-12-14Another fix for CI on OSXKitsune Ral
2017-12-14Add a missing header to fixing building on OSXKitsune Ral
2017-12-14Fixed building with older compilersKitsune Ral
2017-12-14Move all internal event pointers to std::unique_ptr<>Kitsune Ral
This causes the following changes along the way: - Owning<> template is decommissioned. - event.h has been rearranged, and Event/RoomEvent::fromJson static methods have been replaced with an external makeEvent<> function template. A side effect of that is that one cannot use a factory with a type other than the one it's defined for (i.e. you cannot call makeEvent<TypingEvent>) but that feature has been out of use for long anyway. - Room::doAddNewMessageEvents() and Room::doAddHistoricalMessageEvents() have been removed, giving place to Room::onAddNewTimelineEvents() and Room::onAddHistoricalTimelineEvents(). The most important difference is that all code that must be executed now resides in addNewMessageEvents() (it moved from Room to Room::Private) and classes inheriting from Room are not obliged to call the overridden function from the overriding function (they can do it but those functions have empty bodies in Room). This was a long overdue change, and owning pointers simply mandated it. Room::onAddNewTimelineEvents/onAddHistoricalTimelineEvents should not do anything with the passed range in terms of ownership, it's just a way to allow the derived class to update his data in due course. - Room::Private::dropDuplicateEvents() and Room::Private::insertEvents(), notably, have been updated to work with owning pointers. insertEvents() move()s pointers to the timeline, while dropDuplicateEvents uses remove_if instead of stable_partition and doesn't explicitly delete event objects. Also, a bugfix: Event accidentally had not virtual destructor for quite a long time. According to the standard, deleting an object through a pointer to a base class without a virtual destructor leads to UB. So the fact that libqmatrixclient clients even worked all these months is mere coincidence and compiler authors good will :-D
2017-12-14Room::markMessagesAsRead(): Move private overload to pimplKitsune Ral
2017-12-13Refactoring around Room::Private::insertEvent(s)Kitsune Ral
2017-12-12Deduplicate events within a batchKitsune Ral
Closes #130.
2017-12-11Whitelist origin_server_ts in redaction logicKitsune Ral
The Spec doesn't mention it but both Synapse and Riot act as if origin_server_ts was whitelisted, and it was also confirmed in #matrix-dev to be reasonable behaviour.
2017-12-10Enable sending requests for redaction to the serverKitsune Ral
Closes #118
2017-12-10Process incoming redactionsKitsune Ral
This only applies to new messages; historical redaction events are just skipped because historical events are already redacted on the server side. Closes #117.
2017-12-10Use the generated PostReceiptJob; don't compile unused job classesKitsune Ral
Rewire Connection::postReceipt() to the generated job too; this call is still deprecated though.
2017-12-10Log room creation only onceKitsune Ral
2017-11-16Fix CIKitsune Ral
2017-11-16Require state_key to be present in all state eventsKitsune Ral
This impacts the cache as well, as we don't save state_keys for most state events.
2017-11-01StateEvent; EventContent::SimpleContent; event types refactoringKitsune Ral
* StateEvent<> is a new class template for all state events. It provides a uniform interface to the state content, as well as a means to serialize the content back to JSON. In addition, StateEvent now parses the "prev_content" JSON object, so one can refer to the previous state now (a notable step to proper reflection of state changes in the displayed timeline in clients). * EventContent::SimpleContent, together with StateEvent<>, forms a generalisation for simple state events, such as room name, topic, aliases etc. that boil down to a single key-value pair. DECLARE_SIMPLE_STATE_EVENT is a macro defined to streamline creation of events based on SimpleContent, providing API back-compatibility for events defined so far. As a result, a very concise simplestateevents.h replaces all those room*event.* files. * Event/RoomEvent::fromJson() code is squeezed down to plain type lists passed to makeIfMatches() "chained factory" function template. TypeId is mandatory for an event type to be included into that factory. * Event::toTimestamp() and Event::toStringList are completely superseded by respective fromJson<>() converters.
2017-10-30Room::timelineSize() convenience methodKitsune Ral
2017-10-27Fix room avatars getting lost after restarting QuaternionKitsune 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-17Cache the actual user name, not the display nameKitsune Ral
Display name is a calculated thing, name is received from the server.
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-03Room: cache unread indicator inside m.read content, not next to itKitsune Ral
The CS API, turns out, has a quite official extension point inside m.read event content - clients are allowed to put whatever extra data they feel reasonable.
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-20Room::Private::toJson(): save user avatar URLs as wellKitsune Ral
Otherwise, users are doomed to stay avatarless upon restoration, until they update avatars again.
2017-09-20Room::updateData(): Don't profile empty structuresKitsune Ral
2017-09-19Room: Fixed a special case with invalid-read-marker-becoming-validKitsune Ral
It's a case when the last-read-event id refers to an event that was outside the loaded timeline and has just arrived. Depending on what messages follow the discovered last-read one, we might need to promote the read marker and update unreadMessages flag. The latter is especially relevant in our current situation when empty timelines upon the application startup are a norm.
2017-09-19Merge branch 'master' into cache-state-to-jsonKitsune Ral
2017-09-19Room: cache last read event and unread messages flag with the room stateKitsune Ral
Since there's no such thing as "unread messages flag" in the CS API spec, there's now a non-standard key-value in cached m.read receipts for that.
2017-09-19Room: Slight optimization of makeErrorStr()Kitsune Ral
The previous version constructed QString from const char* and QByteArray parts, only to convert it back to QByteArray; the current version does the whole thing in QByteArray terms.
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-05Include unread/notification counters to the cacheKitsune Ral
2017-09-03More fixesRoman Plášil
2017-08-27Use QJsonObject.insert and QStringLiteralRoman Plášil
2017-08-19Room::localUser() facility methodKitsune Ral
2017-08-18Fix compilation for Qt 5.2.1Roman Plášil
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.