aboutsummaryrefslogtreecommitdiff
path: root/lib/jobs/basejob.h
diff options
context:
space:
mode:
authorBlack Hat <bhat@encom.eu.org>2019-12-29 21:42:10 +0800
committerBlack Hat <bhat@encom.eu.org>2019-12-29 21:42:10 +0800
commit7d55e22ee3465e75e5ac7750bb1d205eb555761d (patch)
tree36f7fcef622c44aca8d46514395126280111ed8a /lib/jobs/basejob.h
parente0c01b6fee5027211bd44a39860e40a2b7b226ad (diff)
parent16d6700950f5f0ebd71481efd5e1a24f04e3c651 (diff)
downloadlibquotient-7d55e22ee3465e75e5ac7750bb1d205eb555761d.tar.gz
libquotient-7d55e22ee3465e75e5ac7750bb1d205eb555761d.zip
Merge branch 'master' of https://github.com/quotient-im/libQuotient into bhat-powerlevel
Diffstat (limited to 'lib/jobs/basejob.h')
-rw-r--r--lib/jobs/basejob.h32
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h
index 6c1b802c..c8046e9e 100644
--- a/lib/jobs/basejob.h
+++ b/lib/jobs/basejob.h
@@ -57,9 +57,10 @@ public:
Unprepared = 25, //< Initial job state is incomplete, hence warning level
Abandoned = 50, //< A tiny period between abandoning and object deletion
ErrorLevel = 100, //< Errors have codes starting from this
- NetworkError = 100,
+ NetworkError = 101,
Timeout,
TimeoutError = Timeout,
+ Unauthorised,
ContentAccessError,
NotFoundError,
IncorrectRequest,
@@ -81,6 +82,7 @@ public:
UserConsentRequiredError = UserConsentRequired,
CannotLeaveRoom,
UserDeactivated,
+ FileError,
UserDefinedError = 256
};
Q_ENUM(StatusCode)
@@ -113,7 +115,12 @@ public:
struct Status {
Status(StatusCode c) : code(c) {}
Status(int c, QString m) : code(c), message(std::move(m)) {}
- static Status fromHttpCode(int httpCode, QString msg = {});
+
+ static StatusCode fromHttpCode(int httpCode);
+ static Status fromHttpCode(int httpCode, QString msg)
+ {
+ return { fromHttpCode(httpCode), std::move(msg) };
+ }
bool good() const { return code < ErrorLevel; }
QDebug dumpToLog(QDebug dbg) const;
@@ -184,11 +191,11 @@ public:
using duration_ms_t = std::chrono::milliseconds::rep; // normally int64_t
std::chrono::seconds getCurrentTimeout() const;
- Q_INVOKABLE duration_ms_t getCurrentTimeoutMs() const;
+ Q_INVOKABLE Quotient::BaseJob::duration_ms_t getCurrentTimeoutMs() const;
std::chrono::seconds getNextRetryInterval() const;
- Q_INVOKABLE duration_ms_t getNextRetryMs() const;
+ Q_INVOKABLE Quotient::BaseJob::duration_ms_t getNextRetryMs() const;
std::chrono::milliseconds timeToRetry() const;
- Q_INVOKABLE duration_ms_t millisToRetry() const;
+ Q_INVOKABLE Quotient::BaseJob::duration_ms_t millisToRetry() const;
friend QDebug operator<<(QDebug dbg, const BaseJob* j)
{
@@ -196,7 +203,7 @@ public:
}
public slots:
- void prepare(ConnectionData* connData, bool inBackground);
+ void initiate(ConnectionData* connData, bool inBackground);
/**
* Abandons the result of this job, arrived or unarrived.
@@ -215,7 +222,7 @@ signals:
void sentRequest();
/** The job has changed its status */
- void statusChanged(Status newStatus);
+ void statusChanged(Quotient::BaseJob::Status newStatus);
/**
* The previous network request has failed; the next attempt will
@@ -225,7 +232,8 @@ signals:
* @param inMilliseconds the interval after which the next attempt will be
* taken
*/
- void retryScheduled(int nextAttempt, duration_ms_t inMilliseconds);
+ void retryScheduled(int nextAttempt,
+ Quotient::BaseJob::duration_ms_t inMilliseconds);
/**
* The previous network request has been rate-limited; the next attempt
@@ -251,7 +259,7 @@ signals:
*
* @see result, success, failure
*/
- void finished(BaseJob* job);
+ void finished(Quotient::BaseJob* job);
/**
* Emitted when the job is finished (except when abandoned).
@@ -262,14 +270,14 @@ signals:
*
* @see success, failure
*/
- void result(BaseJob* job);
+ void result(Quotient::BaseJob* job);
/**
* Emitted together with result() in case there's no error.
*
* @see result, failure
*/
- void success(BaseJob*);
+ void success(Quotient::BaseJob*);
/**
* Emitted together with result() if there's an error.
@@ -277,7 +285,7 @@ signals:
*
* @see result, success
*/
- void failure(BaseJob*);
+ void failure(Quotient::BaseJob*);
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void uploadProgress(qint64 bytesSent, qint64 bytesTotal);