diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-05-06 22:11:08 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-05-06 22:11:08 +0900 |
commit | f638c58545ee0a159cae3e91e1ccb3089945930e (patch) | |
tree | f6cd97d350f5c92e482004ff85b6716f772cda3c /jobs | |
parent | fc95edb7a63bcacb02418c55e15a1aa21ac080cd (diff) | |
download | libquotient-f638c58545ee0a159cae3e91e1ccb3089945930e.tar.gz libquotient-f638c58545ee0a159cae3e91e1ccb3089945930e.zip |
Add separate success() and failure() signals to BaseJob
This is to facilitate processing of job results (see further commits).
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/basejob.cpp | 7 | ||||
-rw-r--r-- | jobs/basejob.h | 13 |
2 files changed, 19 insertions, 1 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index 519e1517..e24db012 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -42,6 +42,13 @@ class BaseJob::Private BaseJob::BaseJob(ConnectionData* connection, JobHttpType type, bool needsToken) : d(new Private(connection, type, needsToken)) { + // Work around KJob inability to separate success and failure signals + connect(this, &BaseJob::result, [this]() { + if (error() == NoError) + emit success(this); + else + emit failure(this); + }); } BaseJob::~BaseJob() diff --git a/jobs/basejob.h b/jobs/basejob.h index 95cf4232..f343c769 100644 --- a/jobs/basejob.h +++ b/jobs/basejob.h @@ -46,7 +46,18 @@ namespace QMatrixClient void start() override; enum ErrorCode { NetworkError = KJob::UserDefinedError, JsonParseError, UserDefinedError }; - + + signals: + /** + * Emitted together with KJob::result() but only if there's no error. + */ + void success(BaseJob*); + /** + * Emitted together with KJob::result() if there's an error. + * Same as result(), this won't be emitted in case of kill(Quietly). + */ + void failure(BaseJob*); + protected: ConnectionData* connection() const; |