diff options
-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; |