aboutsummaryrefslogtreecommitdiff
path: root/lib/jobs
AgeCommit message (Collapse)Author
2022-02-16More cleanup, especially in EncryptedFileAlexey Rusakov
For EncryptedFile: - JSON converter bodies moved away to .cpp; - instead of C-style casts, reinterpret_cast is used to convert from (const) char* to (const) unsigned char*; - the size for the target plain text takes into account the case where the cipher block size can be larger than 1 (after reading https://www.openssl.org/docs/man1.1.1/man3/EVP_DecryptUpdate.html). - file decryption is wrapped in #ifdef Quotient_E2EE_ENABLED, to avoid OpenSSL linking errors when compiling without E2EE.
2022-02-13Merge branch 'dev'Alexey Rusakov
The result is FTBFS as yet; next commits will fix that, along with a few other things.
2022-02-07Remove encryptionmanager and various fixesTobias Fella
2022-01-29SyncData: expect self-contained /sync responseAlexey Rusakov
SyncData can load room objects out-of-line. This is only expected when loading data from the cache (and since quite long ago, the cache always saves room objects out of line, avoiding too large JSON payloads that Qt parser chokes on). However, the code processed /sync response in the same way; in particular, this meant that SyncData filled the vector of unresolved room ids even when it came from /sync. SyncJob then looked at this vector and entered an error state if it was not empty. Well, payloads from the wire can be weird and it ultimately came to pass that a homeserver returned a non-object against a given room key, triggering the unresolved rooms branch in SyncJob - and stalling the whole sync loop as a result (https://invent.kde.org/network/neochat/-/issues/500). With this commit SyncData only fills unresolvedRoomIds when loading rooms from the cache (with the implied fallback of discarding the cache and loading from /sync anew instead). Respectively, SyncJob must never end up with SyncData that has unresolved rooms (even if those occur in the actual payload like in the mentioned issue, those rooms will be completely empty instead); the added assertion only guards for internal consistency.
2022-01-23Cleanup some #includesAlexey Rusakov
2022-01-18Revise inline keyword usageAlexey Rusakov
- Templates and constexpr imply inline - A function called from a single site better be inlined.
2022-01-05Fully-qualify types passed to slotsAlexey Rusakov
2022-01-02Add ImplPtr and makeImplAlexey Rusakov
The original (more complex and comprehensive) solution belongs to https://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html - this commit only provides a small wrapper for non-copyable Private class implementations common throughout libQuotient. Unlike the original, default initialisation is made explicit - you have to pass ZeroImpl<Private>() instead (and I firmly believe it's a good thing: normally pointers to Private should not remain nullptr). The reason ZeroImpl<> is not a template variable is quite simple: unique_ptr is non-copyable and so cannot be initialised from; while a template function will initialise the value in-place thanks to copy elision.
2022-01-01Define destructors out-of-line when unique/scoped ptr are involvedAlexey Rusakov
Once visibility kicks in, MSVC changes its ways and tries to instantiate Private classes wrapped in smart pointers upon their occurence in the header file - which leads to build breakage because of a missing destructor. Usually making the outer class destructor out-of-line helps to fix this (see RoomEvent, for one example).
2021-12-29Add QUOTIENT_API throughout non-generated codeAlexey Rusakov
This include all (hopefully) classes/structures and functions that have non-inline definitions, as well as namespaces with Q_NAMESPACE since those have non-inline (as of Qt 5.15) QMetaObject - for that a new macro, QUO_NAMESPACE, has been devised to accommodate the lack of Q_NAMESPACE_EXPORT in Qt before 5.14.
2021-12-01Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-01Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-01Add mxc protocol to the networkaccessmanagerTobias Fella
2021-12-01Handle encrypted file download through existing APITobias Fella
2021-12-01Implement download and decryption of encrypted filesTobias Fella
2021-11-11DECL_DEPRECATED_ENUMERATORAlexey Rusakov
A handy macro that introduces an enumerator with a respective Q_DECL_DEPRECATED_X recommending the substitution.
2021-10-05BaseJob: refresh error handlingAlexey Rusakov
- BaseJob::prepareError() slightly updated to get the current status instead of checking the returned value outside in gotReply() - BaseJob::gotReply() no more reports on 429 Too Many Requests twice (the first time with dubious "Too Many Requests: Unknown error")
2021-10-05BaseJob::StatusCode: officially deprecate most *Error enumeratorsAlexey Rusakov
2021-10-04BaseJob: percent-encode variable path partsAlexey Rusakov
This is meant to spare clients from having to percent-encode room aliases, v3 event ids etc. that happen to hit the endpoint path. It is unfair to expect clients to do that since they are not supposed to care about the shape of CS API, which parameter should be encoded in which way. The trick (together with the slightly updated GTAD configuration) is to percent-encode parts that happen to be QStrings and not `const char[]`'s while passing all constant parts as plain C character literals. This also allows to make it more certain that the path is correctly encoded by passing and storing QByteArray's wherever the path is already encoded, and only use QStrings (next to const char arrays) before that. Since the change alters the API contract (even if that contract was crappy), some crude detection of percent-encoded stuff on input is inserted; if input is already percent-encoded, a warning is put to the logs, alerting developers about the change.
2021-09-11BaseJob: deprecate endpoint accessors; query returns an objectAlexey Rusakov
To provide more room for internal changes in BaseJob.
2021-09-01Fix building with MSVCAlexey Rusakov
Turned out it was broken, and I was looking the other way.
2021-08-22Fix building with MSVCAlexey Rusakov
2021-08-22Drop other stuff deprecated pre- or early 0.6Alexey Rusakov
BaseJob: StatusCode::JsonParseError Connection: resolved() and reconnected() signals; roomMap(); postReceipt() User: bridged() and rawName() ConnectionData: setHost() and setPort() StateEventBase: prev_content()
2021-08-22Drop QMatrixClient namespace aliasAlexey Rusakov
2021-08-22Deprecate BaseJob::DataAlexey Rusakov
The grand plan is to get rid of `BaseJob` and turn job invocations to function calls returning `QFuture`. `RequestData` will stay though, feeding data into those calls.
2021-08-07Drop an out-of-date commentAlexey Rusakov
BaseJob::loadFromJson() does just fine without QStringViews. [skip ci]
2021-07-18Introduce to_array() to fix building on macOSAlexey Rusakov
A previous incarnation, make_array, existed in basejob.cpp before. The new direction taken by C++20 is to either deduce the array (but the used Apple standard library doesn't have deduction guides yet) or to use to_array() that converts a C array to std::array. This latter option is taken here, with to_array() defined in quotient_common.h until we move over to C++20.
2021-07-16Log thumbnail requests in their own categoryAlexey Rusakov
As pointed out by one of users, thumbnail requests produce quite a bit of logging traffic, so it's better to manage them separately.
2021-07-02Actually delete BaseJob::QueryAlexey Rusakov
It was a tiny wrapper around QUrlQuery to facilitate creation from an initializer list - however, Mustache templates long changed to not actually used that additional constructor.
2021-06-13BaseJob: FollowRedirectsAttribute -> RedirectPolicyAttributeAlexey Rusakov
The latter obsoleted the former since Qt 5.9, actually.
2021-06-13Make RequestData compile againAlexey Rusakov
This fixes reliance on QIODevice being magically available for std::unique_ptr<> by indirect inclusion. Since Qt 6 this inclusion no more happens, time to #include <QIODevice> explicitly.
2021-01-16Updated copyright statements upon Git auditKitsune Ral
After going through all the files and the history of commits on them it was clear that some copyright statements are obsolete (the code has been overwritten since) and some are missing. This commit tries best to remedy that, along with adding SPDX tags where they were still not used. Also, a minimal SPDX convention is documented for further contributions. Closes #426.
2021-01-15Merge branch 'master' into dfaure/stricter-flagsKitsune Ral
2021-01-15Merge pull request #428 from ognarb/licensingKitsune Ral
Port existing copyright statement to reuse using licensedigger
2021-01-15Drop a file deleted in masterKitsune Ral
2021-01-07isJobRunning() -> isJobPending()Kitsune Ral
To be very clear what this function checks. See also #437.
2021-01-07BaseJob: setStatus(Pending) on scheduling a retryKitsune Ral
Fixes #437. (cherry picked from commit 12e00b234e5c5f4ed57b5c400d06f780e71014f4)
2021-01-07BaseJob: more loggingKitsune Ral
(cherry picked from commit 4f06d46d6d6062d6d17f69eeaddb7810edac5bbf)
2020-12-28Use generated SetReadMarkerJob instead of PostReadMarkersJobKitsune Ral
2020-12-28BaseJob::initiate: add Q_LIKELYKitsune Ral
...to show the sunny-day case.
2020-12-28Cleanup and clang-tidy/clazy fixesKitsune Ral
2020-12-27Fix use-after-free of QNetworkReply in BaseJobNicolas Fella
Usually QNetworkAccessManager expects the user to delete the replies, but when the QNetworkAccessManager itself is deleted it deletes all pending replies (https://code.woboq.org/qt5/qtbase/src/network/access/qnetworkaccessmanager.cpp.html#529). This can lead to use-after-free crashes when d->reply is accessed. By putting the reply into a QPointer the exiting if(d->reply) checks can work properly.
2020-12-26Port existing copyright statement to reuse using licensediggerCarl Schwan
2020-12-24Fix clang-tidy/clazy warningsKitsune Ral
(cherry picked from commit 0a2acd750a4155969092be674ed3dd9a71b2354f)
2020-12-23BaseJob::Status: add comparison with intKitsune Ral
Since Status single-parameter constructor is (intentionally) not explicit, comparisons may not do what's expected in cases like the one fixed by 3ef036cd. This makes comparisons "do the right thing".
2020-12-23BaseJob: add [[fallthrough]] as clang-tidy saysKitsune Ral
(cherry picked from commit 1a832ae9b6a0d679b551fd644136e4bc17e7db29)
2020-12-23BaseJob: tolerate unexpected error payloadsKitsune Ral
Proxy servers may return arbitrary HTML, for one example; so don't expect to find a valid JSON object in whatever non-empty payload next to a non-2xx HTTP code. Fixes #421. (cherry picked from commit 9ef83e044ed4f8409156b19d529dfc7e45f565c1)
2020-12-10Fix DELETE jobs with json dataTobias Fella
DeleteDeviceJob requires authentication, but the JSON data is not added for DELETE requests. Since QNetworkAccessManager::deleteResource does not support body data, we need to send a custom request.
2020-11-27Make it compile with QT_NO_KEYWORDSCarl Schwan
2020-11-26Enable QT_NO_URL_CAST_FROM_STRING and QT_STRICT_ITERATORS.David Faure
* QT_NO_URL_CAST_FROM_STRING makes it clearer where QUrls are created from QStrings (which incurs a parsing cost). * QT_STRICT_ITERATORS helps detecting where begin()/end() is used instead of cbegin()/cend(). KDE developers have verified that the generated assembly code is identical.