diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-02 12:16:36 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-02 12:20:33 +0900 |
commit | b2c9daabc2e8b89e1108211d8c9badf1bac66640 (patch) | |
tree | f2a7ba70eacc8c69e2741ae1af47eeb5887bb396 /jobs/basejob.h | |
parent | b469f1c9ab7603a297b1c0082d804312cabbd550 (diff) | |
download | libquotient-b2c9daabc2e8b89e1108211d8c9badf1bac66640.tar.gz libquotient-b2c9daabc2e8b89e1108211d8c9badf1bac66640.zip |
All jobs: Drop ConnectionData parameter from the constructor
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()).
Diffstat (limited to 'jobs/basejob.h')
-rw-r--r-- | jobs/basejob.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/jobs/basejob.h b/jobs/basejob.h index b8cc9511..2f7bd9cd 100644 --- a/jobs/basejob.h +++ b/jobs/basejob.h @@ -118,8 +118,7 @@ namespace QMatrixClient using duration_t = int; // milliseconds public: - BaseJob(const ConnectionData* connection, HttpVerb verb, - const QString& name, const QString& endpoint, + BaseJob(HttpVerb verb, const QString& name, const QString& endpoint, const Query& query = {}, const Data& data = {}, bool needsToken = true); @@ -135,7 +134,7 @@ namespace QMatrixClient Q_INVOKABLE duration_t millisToRetry() const; public slots: - void start(); + void start(const ConnectionData* connData); /** * Abandons the result of this job, arrived or unarrived. @@ -205,13 +204,15 @@ namespace QMatrixClient void failure(BaseJob*); protected: - const ConnectionData* connection() const; - + const QString& apiEndpoint() const; + void setApiEndpoint(const QString& apiEndpoint); const QUrlQuery& query() const; void setRequestQuery(const QUrlQuery& query); const Data& requestData() const; void setRequestData(const Data& data); + virtual void beforeStart(const ConnectionData* connData); + /** * Used by gotReply() to check the received reply for general * issues such as network errors or access denial. @@ -260,6 +261,7 @@ namespace QMatrixClient void sslErrors(const QList<QSslError>& errors); private slots: + void sendRequest(); void gotReply(); private: |