aboutsummaryrefslogtreecommitdiff
path: root/jobs
AgeCommit message (Collapse)Author
2017-12-14Declare SyncRoomData as C++-movableKitsune Ral
This fixes compilation with older compilers that try to instantiate a copy constructor (and fail because unique_ptr) but actually is more proper in general. Also: do not advertise the class as Q_MOVABLE_TYPE: this was useful for QList/QVector when SyncRoomData was copyable; now it isn't, and Qt containers can't deal with non-copyable classes at all.
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-07PasswordLogin: Fix the legacy job class to compile with new BaseJob::DataKitsune Ral
2017-12-07New generated jobs for: room directory, 3PIDs, redactions, typing ↵Kitsune Ral
notifications and others Closes #128 (the issue has the full list of jobs arriving herewith).
2017-12-07Make BaseJob::Data consume QByteArray as well, not only QJsonObjectKitsune Ral
This is needed to support cases of content-repo, where the request/response bodies are not JSON.
2017-12-07jobs/generated: don't rely on QString's COW; firmer formattingKitsune Ral
2017-12-07Generated jobs: Apply naming convention to parametersKitsune Ral
It's now camelCase everywhere, even if The Spec uses snake_case (it is not consistent in that respect).
2017-12-07Generated jobs: Don't dump empty strings to body parametersKitsune Ral
This is important for (soon to be added) LoginJob, since the server is sensitive to getting an (even empty) entity for "medium" as opposed to omitting it entirely. This cannot be addressed on the spec level; on the other hand, removing empty parameters from the payload reduces useless bytes getting on the wire.
2017-11-21Use QStringLiteral instead of bare QString constructors for string constantsKitsune Ral
For job endpoints, we should eventually move to QLatin1String or QByteArray instead. Maybe later.
2017-11-21Mitigate the mess with slashes between base URL and endpoint stringKitsune Ral
Closes #125
2017-11-16Simplify code that loads events from JSON arraysKitsune Ral
2017-11-01Move converters.h out of jobs/Kitsune Ral
Because they are applicable beyond jobs.
2017-10-27Put access token to headers instead of queryKitsune Ral
2017-10-25Fixed a typo in the logsKitsune Ral
2017-10-19Introduce device_id and initial_device_name support; switch to generated ↵Kitsune Ral
LoginJob This is _almost_ a backwards-compatible change, except that connect*() and other relevant methods in Connection are no more virtual (that wasn't much useful anyway). Otherwise it's a matter of passing initial_device_name to connectToServer(), saving device_id (along with access_token) from the result of LoginJob and then passing device_id (along with access_token, again) to connectWithToken() upon the next run.
2017-10-17Avoid leaking access_token in the logsKitsune Ral
Closes #102.
2017-10-14Actually added generated/profile.* files, needed to change display nameKitsune Ral
2017-10-14LogoutJob is supplied by generated codeKitsune Ral
2017-10-14Leaving a room now uses a generated Job fileKitsune Ral
2017-10-14Make JoinState (de)serializable library-wideKitsune 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-13Cleaner generated filesKitsune Ral
2017-10-13Extend the number of types supported by fromJson<>()Kitsune Ral
Template function cannot have partial specializations, and we need to deserialise QVector<> objects. So fromJson<>() is now a wrapper around FromJson<> template class that does all the dispatching stuff in its operator().
2017-10-13All jobs: Drop ConnectionData parameter from the constructorKitsune Ral
Having to pass ConnectionData to each and every job class was nothing but boilerplate since the very beginning. Removing it required to prepend BaseJob::start() with ConnectionData-setting code, and to provide a way to alter the request configuration depending on the (late-coming) ConnectionData object. This is a new responsibility of BaseJob::start(); the previous BaseJob::start() contents have moved to BaseJob::sendRequest() (which is now invoked on retries, instead of start()).
2017-09-22BaseJob: Log the sent request more nicelyKitsune Ral
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-20BaseJob: track the outcome of sendRequest() in the logsKitsune Ral
Also: no reason to start the job timer if the request is not running, so don't even bother.
2017-09-20Minor optimisations in sync data parsingKitsune Ral
2017-09-19Merge branch 'master' into cache-state-to-jsonKitsune Ral
2017-09-19BaseJob: improved loggingKitsune Ral
Your QT_LOGGING_RULES (especially useful with Qt 5.6 and newer) should work a bit better now: * "Job" prefix is no more needed because the Qt logging prefix (libqmatrixclient.jobs) says it already; * The "created" record didn't follow the logging category if overridden from the concrete job class (see SyncJob); so instead of "created" there's now much more useful "sending request" record.
2017-09-19Fix a race condition leading to a crash on closeKitsune Ral
It seems that some reply processing still might have happened after BaseJob::abandon() (caused in turn by destroying a Connection object), probably because the event from QNetworkReply landed in the event queue after BaseJob::abandon() but before actual deletion of a job object. Now countered by disconnecting from QNetworkReply signals in abandon() and stop().
2017-09-16Merge branch 'master' into kitsune-invite-kickKitsune Ral
2017-09-15MediaThumbnailJob: get rid of useless pimpl; add scaledThumbnail()Kitsune Ral
Also use scaledThumbnail() in User::requestAvatar()
2017-09-13Add a missing #includeKitsune 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-09First files made by api-generatorKitsune Ral
Actual usage will come with the next commit.
2017-09-09converters.h: Facility methods for generated jobsKitsune Ral
A cherry-pick from the kitsune-apigen branch; a family of toJson() and fromJson<>() functions to unify conversion of data back and forth.
2017-09-08Revert previous commit as it breaks building with VC 2015Kitsune Ral
This reverts commit da975f68f6a8503bf5466292dcdceed8c6f7fa6f.
2017-09-05Initialize more properly to fix a warningKitsune Ral
2017-09-04Use move on SyncDataRoman Plášil
2017-09-04Use SyncJob::SyncData as a plain memberRoman Plášil
2017-09-03More fixesRoman Plášil
2017-09-02Use status return type for parseJsonRoman Plášil
2017-09-01BaseJob::Data: expose constructors from QJsonObjectKitsune Ral
We had a stupid situation when this class has less features when compiled with newer Qt because we explicitly added a constructor from std::initializer_list for older Qt versions but did not reuse the same constructor from QJsonObject for newer versions.
2017-08-19BaseJob::Data: Small update to better match Qt APIKitsune Ral
Also: Query and Data constructors from initialization_list<> are no more explicit, as clang-tidy recommends.
2017-08-16Implement saving save to enable incremental sync even after shutdownRoman Plášil
2017-07-22SendEventJob: Fixed empty transaction id'sKitsune Ral
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.