aboutsummaryrefslogtreecommitdiff
path: root/jobs/basejob.cpp
AgeCommit message (Collapse)Author
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-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-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-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-05-17Merge pull request #62 from Fxrh/kitsune-refactoringKitsune Ral
Code tweaks and cleanup
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-12BaseJob: Do not leak access token into the job configurationKitsune Ral
Before the access token was added to Private::requestQuery on every sendRequest() invocation, leading to the same access token being added up to the request once more with each retry.
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-02Renamed JobHttpType to more fitting HttpVerb; removed Job from enum valuesKitsune Ral
2017-03-27Map QNetworkReply::UnknownContentError to BaseJob::IncorrectRequestErrorKitsune Ral
This is what /join returns if I supply garbage for the alias.
2017-03-25Jobs retry on network and timeout errorsKitsune Ral
As of now, the retry logic (see BaseJob::finishJob() method) invokes the same network request several times with increasing timeouts and retry intervals. Some additional signals and accessors are also provided to control the behaviour from inheriting classes (see a notable example with SyncJob in the same commit) and clients (support of retries in Quaternion comes in a respective commit shortly).
2017-03-24BaseJob: Add more error statesKitsune Ral
This should help to provide more reasonable error messages when a particular resource is not found or entered data are outright incorrect.
2016-10-15BaseJob: Use saved parameters instead of overriding apiPath(), query() and ↵Kitsune Ral
data() in each job class
2016-09-11Explicitly stop the timer in finishJob()Kitsune Ral
This should avoid timeout event catching up on a not-yet-deleted-but- already-invalid job object.
2016-09-06Connection: homeserver(); Connection and ConnectionData: accessToken(); ↵Kitsune Ral
accessors de-virtualized Details: - New: Connection::homeserver(), returns the homeserver URL from inside ConnectionData - New/Modify: Connection::accessToken() and ConnectionData::accessToken() - because we will also have refresh tokens eventually; deprecate token() for the same reason - Modify: Connection::user(), token(), accessToken() are no more virtual (they should have never been, these are plain accessors, after all)
2016-07-28Fixed double-emission of signal(s) on job timeout + general cleanupKitsune Ral
2016-07-27Introduce Status class + BaseJob::{checkReply,parseReply,parseJson} now ↵Kitsune Ral
return it This better fixes the contract for derived job classes and simplifies error reporting. Methods error() and errorString() are kept for back-compatibility; status() returns a combination of them, conveniently packed into a Status object. For a quick status check, Status::good() is provided.
2016-07-26Split BaseJob::gotReply into checkReply and parseReply + internal tweaks to ↵Kitsune Ral
BaseJob 1. The externally (for derived classes) visible additions are checkReply() and parseReply() virtual methods, with gotReply becoming a mere dispatcher (and therefore a private method). Splitting gotReply() in that way allowed to remove boilerplate code from MediaThumbnailJob. 2. The internal tweak is using QScopedPointer<> to store pointers both to the Private object and to a QNetworkReply (with a special deleter that aborts the reply before destructing the object). This allows to remove desperate attempts to call reply->abort() wherever it's no more needed (and not aborting the in-flight replies seems to be a/the culprit of Quaternion after-exit hangs).
2016-07-26Rewritten BaseJob to not depend on KJob.Kitsune Ral
Some parts of the code were copied from the KCoreAddons sources - surprisingly few, in fact, mostly API with comments. With this commit, libqmatrixclient doesn't depend on KCoreAddons.
2016-07-26Log creation/deletion of jobs (especially SyncJob)Kitsune Ral
Due to signal-slot processing it's not obvious when exactly each job object is deleted.
2016-07-22Separate errors of access denial kind to a different BaseJob error code as ↵Kitsune Ral
well + stability fixes 1. Introduce ContentAccessDenied error code to BaseJob to allow clients to treat access denial errors differently from other network errors. 2. Since parseJson() overrides are responsible for calling emitResult(), the "default" BaseJob::parseJson() should call emitResult() as well. 3. Make sure BaseJob::fail() doesn't crash in absence of QNetworkReply.
2016-05-27Use 'override' keyword throughout job classes; constify apiPath(), query(), ↵Kitsune Ral
data() Thanks to CLang model.
2016-05-27Set the object name for each job, to make it clear which job has failedKitsune Ral
And we don't need two log lines for timeouts.
2016-05-27Use nullptrKitsune Ral
2016-05-06Enhanced logging of job failuresKitsune Ral
2016-05-06Make sure the QNetworkReply object is aborted at any failure and even silent ↵Kitsune Ral
destruction of the job
2016-05-06Add separate success() and failure() signals to BaseJobKitsune Ral
This is to facilitate processing of job results (see further commits).
2016-04-12Merge remote-tracking branch 'upstream/master'David A Roberts
2016-04-12Resolve Matrix SRV records.David A Roberts
2016-04-11Minor fixes and cleanupKitsune Ral
1. Remove accidental trailing \ 2. Show the contents of NetworkError in logs
2016-04-05Imported the current source tree from Quaternion/lib.Kitsune Ral