aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
AgeCommit message (Collapse)Author
2018-10-29Connection::joinRoom: allow to specify intermediate serversKitsune Ral
Closes #127.
2018-09-16Merge remote-tracking branch 'upstream/master'Josip Delic
2018-09-16Connection: make factories a bit more customisableKitsune Ral
2018-09-09Room::beforeDestruction()Kitsune Ral
This is to allow connecting to before-destruction of one specific room, rather than any room under a connection (for which Connection::aboutToDeleteRoom() still exists).
2018-09-09CleanupKitsune Ral
2018-08-29Merge branch 'master' of https://github.com/QMatrixClient/libqmatrixclientJosip Delic
2018-08-29Use GetTurnServerJob for csapiJosip Delic
2018-08-25Update to the recent CS API (watch out for breakage)Kitsune Ral
Breaking changes: * guest_can_join is no more a thing - neither in Connection::createRoom, nor even in CreateRoomJob (it turned out that Synapse didn't really process this flag); * LoginJob has changed its list of arguments. If you use Connection to do logins (and you really should), you shouldn't be affected. * GetPublicRoomsJob now returns PublicRoomsResponse instead of providing all the response parts within the job Watch other changes in the diff.
2018-08-25Update marius voip to new libqtmcJosip Delic
2018-08-12Fix FTBFS (in a hacky way, needs a proper fix)Kitsune Ral
2018-08-12Fix building with older Qt versionsKitsune Ral
2018-08-11Reverse direct chats mapKitsune Ral
Speeds up lookup of user(s) in a direct chat room. Also: "The other one's" avatar is used to set the avatar of direct chats only, not any room with 2 participants.
2018-08-11Connection::doInDirectChat: don't remove invite/left rooms from direct chatsKitsune Ral
Deletion of Invite rooms was a clear bug; as for left rooms, it makes sense to keep them in direct chat maps because they may be re-joined later on.
2018-08-11Connection: don't crash on invalid user ids coming from the serverKitsune Ral
Closes #230.
2018-08-11Connection::*DirectChat(): add overloads accepting User*Kitsune Ral
2018-08-03Connection::sendMessage: mark as tentativeKitsune Ral
...and therefore deprecated for use in clients _yet_.
2018-07-27Initial support for local echoKitsune Ral
The Room class has gained a new internal container, unsyncedEvents, storing locally-created Event objects that are about to be sent or are sent but not yet synced. These objects are supposed to be complete enough to be displayed by clients in a usual way; access to them is provided by Room::pendingEvents() accessor. A set of pendingEvent* signals has been added to notify clients about changes in this container (adding, removal, status update). Yet unsent events don't have Event::id() at all; sent but yet unsynced ones have Event::id() but have almost nothing else except the content for now (probably a sender and an (at least local) timestamp are worth adding). Also: SendEventJob is removed in favor of GTAD-generated SendMessageJob.
2018-07-27connectSingleShot()Kitsune Ral
Time and again I need one-off slots that disconnect once they are done. The code has been inside Connection implementation for quite some time, now it's put to the interface for usage in other places (notably qmc-example).
2018-07-19Connection::stateChanged() signalKitsune Ral
Also: as of the previous commit, we officially bump API version to 0.4
2018-07-16Connection::uploadFile(): Fix a missing negationKitsune Ral
...leading to uploadFile() being never even functional - the code really needs tests. Closes #221.
2018-07-04Add more #includes missingKitsune Ral
2018-07-04Support ignoring usersKitsune Ral
Closes #215.
2018-07-04Event types system remade to be extensibleKitsune Ral
There were two common points that had to be updated every time a new event is introduced: the EventType enumeration and one of 3 doMakeEvent<> specialisations. The new code has a template class, EventFactory<>, that uses a list of static factory methods to create events instead of typelists used in doMakeEvent<>(); the EventType enumeration is replaced with a namespace populated with constants as necessary. In general, EventType is considered a deprecated mechanism altogether; instead, a set of facilities is provided: is<>() to check if an event has a certain type (to replace comparison against an EventType value) and visit<>() to execute actions based on the event type (replacing switch statements over EventType values). Closes #129.
2018-07-04Merge branch 'kitsune-raw-literal-qstringliteral'Kitsune Ral
2018-07-04Connection: Trim raw data in emitted signalsKitsune Ral
If the payload is too large, an attempt to allocate a QString out of QByteArray may end with qBadAlloc(). So by default the data emitted in case of error are trimmed to 64KiB, and this can be overridden to a different value (or switched off entirely with <n>=0) by adding - DTRIM_RAW_DATA=<n> to CPP_FLAGS.
2018-07-04Experimental usage of QStringLiteral with a raw string literalKitsune Ral
2018-06-16Connection::doInDirectChat: "direct chat with self" featureKitsune Ral
Essentially - create/switch to the room with you as the only member instead of getting the first room where you happen to be flagged as a direct chat user (which is pretty unpredictable even if stable from the user point of view).
2018-06-16Connection::createRoom: avoid inviting yourself to the created roomKitsune Ral
2018-06-16Connection::doInDirectChat: be more careful with cleanupKitsune Ral
d->directChats was cleaned up while it was iterated upon, obviously leading to Undefined Behaviour. Closes #214.
2018-06-11BaseJob: Drop 'error' from methods that work in normal job state tooKitsune Ral
2018-06-11Connection: InFore/Background -> Fore/BackgroundRequestKitsune Ral
2018-06-08csapi: Fix boolean query parameters incorrectly passedKitsune Ral
2018-06-03csapi + converters: Support variant types (using QVariant)Kitsune Ral
This mandated some rearrangement of toJson() overloads and FromJson<> specializations for QVariant* types - instead of variant_converters.h they are now in converters.cpp.
2018-06-02Connection::loadedRoomState() signalKitsune Ral
Closes #211.
2018-05-29BaseJob: "background" switch; more extensive error reportingKitsune Ral
Running a request in background, aside from some tweaks on the network layer (see QNetworkRequest::BackgroundRequestAttribute), allows to distinguish jobs not immediately caused by user interaction (such as fetching thumbnails). This can be used to show or not show certain notifications in UI of clients. Error reporting has been extended with more methods: errorCaption() - a human-readable phrase calculated from the status code; intended to be shown as a dialog caption and in similar situations. errorRawData() - former errorDetails(), returns the raw response from the server. errorUrl() - returns a URL that may be useful with the error (e.g. for the upcoming "consent not given" error, this will have the policy URL). Connection::resultFailed() - a new signal emitted when _any_ BaseJob::failure() is emitted (enables centralised error handling across all network requests in clients). As a part of matching changes in Connection, callApi has an overload that allows to specify the policy; a custom enum instead of bool has been chosen for the parameter type, to avoid clashes with (arbitrary) types of job parameters.
2018-05-23BaseJob: more careful error handling; unify and extend error signals in ↵Kitsune Ral
Connection (Note: this commit breaks back-compatibility.) BaseJob::gotReply() had a bold assumption that whenever there's no reasonable JSON body in case of error, that meant IncorrectRequestError (which of course was incorrect). This led to syncs dying in Quaternion because it (correctly) considered IncorrectRequestError to be grave enough to not retry. Closes #206. Also: don't dump the whole payload to logs, limit with initial 500 characters (closes #205)
2018-05-06Optimise #includes, eliminate some excess blank lines in lib/csapiKitsune Ral
2018-05-04New home for the generated code - lib/csapiKitsune Ral
2018-05-04Connection, jobs/generated: Use QStringList instead of QVector<QString>Kitsune Ral
QStringList's API is richer, after all.
2018-05-03Preempt jobs/joinroomjob.* with jobs/generated/joining.*Kitsune Ral
Enables responding to third-party invites.
2018-05-03GetRoomEventsJob (replaces RoomMessagesJob) + refactoringKitsune Ral
1. Updates in this commit (see further) allow to generate and build GetRoomEventsJob from message_pagination.yaml; this job completely preempts RoomMessagesJob. 2. EventsBatch<> is no more a thing; there's EventsArray<> to replace it but it's loaded from a JSON array rather than an event batch (a JSON array inside another JSON object). SyncJob that used it extensively has been moved to "conventional" containers (Events, RoomEvents and the newly introduced StateEvents). RoomMessagesJob that also used EventsBatch<> is decommissioned (see above). 3. RoomEventsRange is now an alias for Range<RoomEvents>, defined in util.h (otherwise almost the same). 4. Connection::getMessages() is no more. Use Room::getPreviousContent() and Connection::callApi<GetRooMEventsJob>() instead. 5. Moving things around in Room, since SyncJob now supplies state events in more specific StateEvents, rather than RoomEvents.
2018-05-01Event and Room: further abstract event pointersKitsune Ral
So that eventual switch from std::unique_ptr to some other pointer (as a case - QSharedPointer) would be as painless as possible.
2018-04-27Cache bridge names along with user namesKitsune Ral
Otherwise the bridge is forgotten after restart. This bumps the cache version.
2018-04-27Fix broken User::displayName() logicKitsune Ral
Also, add an assert to Connection::user() to make sure it doesn't create users with invalid ids. Closes #201.
2018-04-13Support Qt 5.4Kitsune Ral
That is until ubports move to xenial.
2018-04-05Unofficially relax Qt requirement to 5.5.1Kitsune Ral
This is to support uMatriks that still has to compile on xenial codebase.
2018-04-03DirectChatEvent: be careful with range-for over temporariesKitsune Ral
...because temporaries returned by temporaries tend to disappear before you enter the loop body (see the bottom of http://en.cppreference.com/w/cpp/language/range-for#Explanation).
2018-04-02Fixes according to results of static analysisKitsune Ral
Many thanks to clang-tidy and clazy authors for the tools, and to Qt Creator developers for making them easily available in the IDE.
2018-04-02Be more cautious with rvaluesKitsune Ral
Clang on FreeBSD doesn't seem to be playing nice in Release configuration. See the comment in the committed code.
2018-04-02Room/Connection: accountData()/accountDataChanged()Kitsune Ral
Generic account data are at least readable now (you can get, say, pushers from the library without it even being aware of what a pusher is).