aboutsummaryrefslogtreecommitdiff
path: root/events
AgeCommit message (Collapse)Author
2017-11-16Simplify code that loads events from JSON arraysKitsune 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-02Fix AppVeyor CIKitsune Ral
2017-11-02Fixed CIKitsune Ral
2017-11-01Imbue RoomMemberEvent with EventContentKitsune Ral
It now allows to check what exactly has happened to the member (display name change, joining, avatar update), fixing #105.
2017-11-01Event::isStateEvent(); fixed StateEvent::_prev always being initialisedKitsune Ral
Event::isStateEvent() is an easier way to make checking an event kind (instead of enumerating through all types corresponding to state changes). StateEvent::_prev (accessible through prev_content) should only be initialised if there's a previous state in the original JSON.
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-11-01Add TypeId to more eventsKitsune Ral
2017-11-01ReceiptEvent: Use fromJson<>() from converters.h; add TypeIdKitsune Ral
Event::toTimestamp() duplicates fromJson<>() code, so it should go.
2017-11-01Drop UnknownEvent files from the source treeKitsune Ral
We don't use them for several months already.
2017-10-31Streamline EventContent hierarchyKitsune Ral
Two changes to make EventContent hierarchy easier to understand and use: - InfoBase is unbound from Base, and downstream classes use multiple inheritance to work "info" objects - MIME types are separated from Base into a separate TypedBase class because MIME typing is not common to all content kinds.
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-26Move out common message event content classesKitsune Ral
ImageContent is usable outside of m.room.message (in particular, m.room.avatar uses the same structure for content. And EventContent::Base is very suitable to derive from even for standard event content structures (such as in room name events), let alone non-standard ones. Also, renamed MessageEventContent to EventContent (for obvious reasons).
2017-10-20CleanupKitsune 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-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-02Introduce EncryptionEvent classKitsune Ral
This allows to detect if a room has been encrypted (no room state, just an event as of yet). Closes #84.
2017-09-21jobs: SetRoomStateJob (with or without state key); setting room topicKitsune Ral
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-19Event::originalJsonObject(), RoomEvent validations commented outKitsune Ral
* Event::originalJsonObject() exposes the original JSON for the event without converting it to QByteArray. This is useful to quickly dump an event into a bigger JSON without reconstructing a JSON object. * Validations in RoomEvent::RoomEvent() do more harm than good. The rest of the library tolerates absence of those attributes pretty well (it wouldn't be able to do much with that anyway); at the same time, dumping JSON to logs turns out to be pretty heavy, and throwing many invalid events at a client is a good way to hit its performance.
2017-08-08Vector has been renamed to Riot long agoKitsune Ral
2017-07-18Room event timestamp can also be undefinedRoman Plášil
2017-07-16Fixed too strict validations in (Room)EventKitsune Ral
2017-06-22RoomMessageEvent: Simplify constructors, use QString msgType internallyKitsune Ral
QString msgType allows non-standard types (we don't want to restrict clients to types from the spec)
2017-06-22MessageEventContent: generalise mimeTypeKitsune Ral
mimeType is relevant to most of the content types, and at the same time getting a MIME type in a generic way is handy for clients to uniformly detect whether they can display the content and what renderer to use for it.
2017-06-22Enable creation of RoomMessageEventsKitsune Ral
RoomMessageEvent and MessageContentEvent::* classes have been massively overhauled to enable creation of m.room.message events locally instead of from JSON.
2017-06-22Enable creation and usage of Event and RoomEvent objects locally, including QMLKitsune Ral
This includes RoomEvent gaining transactionId property and addId() method so that it could gain ids when being/having been sent.
2017-06-13Removed RoomMessageEvent::userId in favor of RoomEvent::senderIdKitsune Ral
2017-05-22Fixed building with CLang 3.5Kitsune Ral
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-22util.h: lookup() uses forwarding refs; added Dispatch/dispatch and REGISTER_ENUMKitsune Ral
The Dispatch<> template and dispatch(), a facility function for it, simplify dispatching to functions that have different signatures that still can be converted to the same std::function<> type. The case in point is in event.cpp; Event::fromJson calls make() that always returns the type we need; however, once we have several possible base types (Event, RoomEvent, StateEvent), we'd have to either write a specific make() incarnation for each of them, or mess with function return type conversions. Dispatch<> helps to keep the code clean. REGISTER_ENUM is a cross-Qt versions approach to dumping enumeration values to qDebug() and the likes.
2017-05-13Refactored logging enhancementsKitsune Ral
logging.h/logging.cpp is now a full-fledged pair for all things logging. Two more categories added, EPHEMERAL and SYNCJOB, that control logging for ephemeral events and SyncJob, respectively (in particular, switching off EPHEMERAL greatly reduces the logspam about moving read markers and how many users have read up to which event).
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-30Port to categorized loggingElvis Angelaccio
This greatly reduces the noise made by quaternion. To enable full logging, export the following variable: QT_LOGGING_RULES="libqmatrixclient.*.debug=true"
2017-04-16Make sure message body is treated as plain textKitsune Ral
The previous code deviated from the spec, trying to guess on the content type of body as if there could be HTML in some cases. The spec openly states that 'body' value should always be in plain text.
2017-02-28Renamed logging_util.h to util.h and moved (improved) Owning<> and lookup() ↵Kitsune Ral
there Because these fall outside of SyncJob and Event context, respectively. In addition, Owning<> has gained a move assignment operator (because we have a move constructor) and assign() convenience method to take ownership over an existing container; also, Owning<>::release() is done the right way now (the previous version was copying the return value to a new container instead of releasing the old container).
2017-02-28Parse event id for all events; timestamp for all except typing and receiptsKitsune Ral
This is not quite correct because only room events are guaranteed by the spec to have an id and a timestamp. But we don't parse all room events as of yet, so that's a way to at least make those attributes universally available for even unknown room events. It matters, because read receipts can refer to any room event id and because we'll use event id's to filter out duplicate events in further commits; and missing timestamps used to break the timeline display (showing <> instead of <valid timestamps>).
2017-02-26Skip read events with an empty event idKitsune Ral
2017-02-23Receipts internal handling improvedKitsune Ral
Instead of QHash, use QVector< QPair<> > because it's more efficient and we don't really need a hashmap functions, only direct iteration over the list of event-to-receipt pairs. Also, iteration over QJsonObjects is more efficient (and better conveys the intention) than collecting keys() and then finding a value() for each of them. Also, fixed accidental allocation of empty Receipt structures instead of reserving space for them.
2016-11-14Merge branch 'pragma-once'Kitsune Ral
2016-11-06Use #pragma once everywhereMalte Brandy
2016-11-01Receipt: eventId is extraneous inside the receipt, since receipts are ↵Kitsune Ral
associated with Event objects anyway
2016-11-01Removed unused #includesKitsune Ral
2016-10-07Fixed leaks of RoomMessageEvent contentKitsune Ral
2016-10-07Use Q_DECLARE_TYPEINFO correctlyKitsune Ral
The previous code had no effect because QVector<Receipt> was instantiated before Q_DECLARE_TYPEINFO occurence.
2016-09-21Merge pull request #31 from Fxrh/kitsune-sender-in-all-eventsKitsuneRal
Push sender from RoomTopicEvent to Event
2016-09-21Push sender from RoomTopicEvent to EventKitsune Ral
Because it's supposed to exist in (at least) all events from /sync.
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-14Don't search for event_id and origin_server_ts in m.receipt eventsKitsune Ral