From de9448a65655451e1310947955dd6b341479dc23 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 8 Mar 2017 20:22:44 +0900 Subject: Connection::callApi<>, a factory for all API call jobs This call (intended to only be used within the lib) creates a job object of the passed type and passes a ConnectionData pointer to its constructor. This allows to avoid making a switchboard of methods on Connection for the whole API, leaving only those that naturally belong there - e.g. joinRoom() or sync() - and moving, e.g., postMessage() to where it belongs - Room. PostMessageJob and RoomMessagesJob were updated along the way, to unbind from the Room class (which they really don't and won't need). --- connection.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'connection.h') diff --git a/connection.h b/connection.h index 0e25d695..1ce3e0de 100644 --- a/connection.h +++ b/connection.h @@ -69,6 +69,14 @@ namespace QMatrixClient Q_INVOKABLE QString token() const; Q_INVOKABLE QString accessToken() const; + template + JobT* callApi(JobArgTs... jobArgs) + { + auto job = new JobT(connectionData(), jobArgs...); + job->start(); + return job; + } + signals: void resolved(); void connected(); -- cgit v1.2.3