aboutsummaryrefslogtreecommitdiff
path: root/lib/jobs/basejob.h
AgeCommit message (Collapse)Author
2020-11-27Make it compile with QT_NO_KEYWORDSCarl Schwan
2020-06-07BaseJob: jsonData() and prepareResult/Error()Kitsune Ral
* JSON response is stored internally in BaseJob, rather than passed around virtual response handlers. This allow to lazily deserialise parts of the JSON response when the client calls for them instead of deserialising upon arrival and storing POD pieces. This is incompatible with the current generated code, so temporarily FTBFS. * BaseJob::loadFromJson() and BaseJob::takeFromJson() have been added to facilitate picking parts of the result as described above in derived job classes. * BaseJob::jsonData(), BaseJob::jsonItems() and (protected) BaseJob::reply() for direct access to the response in its various forms. * To further eliminate boilerplate code in generated job classes, a group of *ExpectedKeys() methods has been added - this allows to reflect the API definition of required response keys in a more "declarative" way, delegating validation to BaseJob. * parseReply() and parseJson() pair turns to singular prepareResult(). Thanks to all the changes above, in most cases it will not need overriding, unlike before. * BaseJob::Private::parseJson() is introduced, to wrap QJsonDocument::parseJson() into something less verbose. This serves a completely different purpose to the former BaseJob::parseJson(). * BaseJob::doCheckReply() takes the place, and the name, of checkReply().
2020-06-07BaseJob: expose statusCode as Q_PROPERTYKitsune Ral
2020-05-31BaseJob::rawData: overload for (even) quicker accessKitsune Ral
No functional changes either.
2020-05-31Move around and format codeKitsune Ral
No functional changes here.
2020-04-14BaseJob::makeRequestUrl(): even more tolerance to slash separatorsKitsune Ral
The code is really defensive now, making sure there's exactly one slash between the base path and the endpoint. It's still very conservative about the path composition otherwise (no normalisation etc.).
2019-12-12BaseJob: prepare() -> initiate() + refactoring around itKitsune Ral
* BaseJob::initiate() now calls ConnectionData::submit() without relying on Connection to do that * ConnectionData::submit() is now the only site where a job enters Pending state * No more shortcuts to BaseJob::sendRequest(), even retries are sent through the ConnectionData submission queue * Additional validation in BaseJob::initiate() that the request data device is actually open (because QtNetwork API officially requires that, even if you can get away passing a closed QBuffer to it)
2019-12-12Move FileError definition from DownloadFileJob to BaseJobKitsune Ral
Will use it in BaseJob in a later commit.
2019-12-11BaseJob::StatusCode: offset first error from ErrorLevelKitsune Ral
Q_ENUM seems to resolve int to the first enum identifier with that value so NetworkError == ErrorLevel looks confusing in logs.
2019-11-19BaseJob: Don't send accessToken if not needed; send again on 401Kitsune Ral
The first part closes #358; the second part is a workaround for non-standard cases when endpoints without security by the spec turn out to be secured (in particular, the case of authenticating media servers).
2019-10-20Qualify types in signals and Q_INVOKABLEsKitsune Ral
Because https://doc.qt.io/qt-5/moc.html#limitations . For direct connections that doesn't matter but it very much does for queued ones. Along with this DirectChatsMap and IgnoredUsersList have been moved from Connection:: to Quotient::.
2019-08-27Don't use enumerator attributesKitsune Ral
Anything after enumerators is a problem for moc before Qt 5.12; so we can't use enumerator attributes before then.
2019-08-20BaseJob/ConnectionData: connection-wide rate-limitingKitsune Ral
As before, completely transparent for clients, driven by 529 errors from the server (but cases of rate limiting are signalled by BaseJob::rateLimited). That brings changes to BaseJob API: timeouts now use int64_t and also can be handled in std::chrono terms; aboutToStart() -> aboutToSendRequest(); started() -> sentRequest(). Closes #292.
2019-08-20BaseJob: Status/StatusCode tweaks, cleanup, mo' commentsKitsune Ral
Notably, recovered Status::fromHttpCode() that was introduced in 5722ceaf4bd10c29f1091e3dc5a87f5650ea8c71 but fell victim of a careless merge (so much for introducing non-topical changes in feature branches).
2019-08-16BaseJob: support M_USER_DEACTIVATED error codeKitsune Ral
Closes #344.
2019-08-13Support for server notices rooms (MSC1452)Kitsune Ral
Closes #326.
2019-08-09Namespace: QMatrixClient -> Quotient (with back comp alias)Kitsune Ral
2019-08-02Apply the new brace wrapping to source filesKitsune Ral
2019-08-02Merge branch 'master' into use-clang-formatKitsune Ral
2019-07-09Merge branch 'master' into use-clang-formatKitsune Ral
2019-07-01Merge branch 'master' into forget-rooms-reallyKitsune Ral
2019-07-01Handle M_UNKNOWN as The Spec says; factor out BaseJob::parseError()Kitsune Ral
2019-06-26BaseJob::Status: fromHttpCodeKitsune Ral
2019-06-24Merge branch 'master' into clang-formatKitsune Ral
# Conflicts: # CMakeLists.txt # lib/avatar.cpp # lib/connection.cpp # lib/connection.h # lib/connectiondata.cpp # lib/csapi/account-data.cpp # lib/csapi/account-data.h # lib/csapi/capabilities.cpp # lib/csapi/capabilities.h # lib/csapi/content-repo.cpp # lib/csapi/create_room.cpp # lib/csapi/filter.cpp # lib/csapi/joining.cpp # lib/csapi/keys.cpp # lib/csapi/list_joined_rooms.cpp # lib/csapi/notifications.cpp # lib/csapi/openid.cpp # lib/csapi/presence.cpp # lib/csapi/pushrules.cpp # lib/csapi/registration.cpp # lib/csapi/room_upgrades.cpp # lib/csapi/room_upgrades.h # lib/csapi/search.cpp # lib/csapi/users.cpp # lib/csapi/versions.cpp # lib/csapi/whoami.cpp # lib/csapi/{{base}}.cpp.mustache # lib/events/accountdataevents.h # lib/events/eventcontent.h # lib/events/roommemberevent.cpp # lib/events/stateevent.cpp # lib/jobs/basejob.cpp # lib/jobs/basejob.h # lib/networkaccessmanager.cpp # lib/networksettings.cpp # lib/room.cpp # lib/room.h # lib/settings.cpp # lib/settings.h # lib/syncdata.cpp # lib/user.cpp # lib/user.h # lib/util.cpp
2019-06-07BaseJob::StatusCode: add Error-less synonyms; officially deprecate ↵Kitsune Ral
JsonParseError
2019-05-31Ignore some errors on leaving rooms, add new error enum. Fixes #307Ville Ranki
2019-03-02style: apply .clang-format to all .cpp and .h filesMarc Deop
2019-02-20BaseJob: M_UNSUPPORTED_ROOM_VERSION & M_INCOMPATIBLE_ROOM_VERSIONKitsune Ral
2018-12-24Clarify doc-comment for BaseJob::finished a bitKitsune Ral
[skip ci]
2018-11-19BaseJob::rawDataSample()Kitsune Ral
A new recommended (and localisable) way of getting a piece of raw response to display next to error messages as "details". BaseJob::rawData() returns exactly the trimmed piece of data, no "truncated" suffix there anymore.
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-06-11BaseJob: Drop 'error' from methods that work in normal job state tooKitsune Ral
2018-05-29BaseJob: Treat M_CONSENT_NOT_GIVEN separately from other content access errorsKitsune Ral
Closes #207.
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-28BaseJob: support status trackingKitsune Ral
The newly introduced statusChanged() signal allows clients to be notified about the job state transitions.
2018-05-28BaseJob: refresh rotten comments about kill()Kitsune Ral
There is no more BaseJob::kill() for a very long time; we have abandon() instead, with a bit different meaning. Which, by the way, now emits finished() because that's what finished() has been for.
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-04-25BaseJob: rewrite error detection using genuine HTTP codesKitsune Ral
Qt Network error codes don't represent well some cases. Closes #200.
2018-04-02BaseJob: set the status upon headers arrivalKitsune Ral
So that DownloadFileJob could figure if it should save the incoming payload to the file or it's the JSON details about the error.
2018-04-01BaseJob: use QDebugStateSaverKitsune Ral
...instead of copying the whole QDebug object.
2018-03-31Move source files to a separate folderKitsune Ral
It's been long overdue to separate them from the rest of the stuff (docs etc.). Also, this allows installing to a directory within the checked out git tree (say, ./install/, similar to ./build/).