From b2a017303a34e248873b2e47e560a41dc4c5111c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 2 Oct 2017 12:16:36 +0900 Subject: 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()). --- jobs/sendeventjob.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'jobs/sendeventjob.cpp') diff --git a/jobs/sendeventjob.cpp b/jobs/sendeventjob.cpp index f3c95fe8..7e33e089 100644 --- a/jobs/sendeventjob.cpp +++ b/jobs/sendeventjob.cpp @@ -22,13 +22,17 @@ using namespace QMatrixClient; -SendEventJob::SendEventJob(const ConnectionData* connection, - const QString& roomId, const QString& type, +SendEventJob::SendEventJob(const QString& roomId, const QString& type, const QString& plainText) - : SendEventJob(connection, roomId, - new RoomMessageEvent(plainText, type)) + : SendEventJob(roomId, new RoomMessageEvent(plainText, type)) { } +void SendEventJob::beforeStart(const ConnectionData* connData) +{ + BaseJob::beforeStart(connData); + setApiEndpoint(apiEndpoint() + connData->generateTxnId()); +} + BaseJob::Status SendEventJob::parseJson(const QJsonDocument& data) { _eventId = data.object().value("event_id").toString(); -- cgit v1.2.3 From 76c42a9863b83229e6afaf4be32e9582e3d97d3f Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 14 Oct 2017 01:22:04 +0200 Subject: Cleanup around Room (potentially breaks API compatibility, beware) Notably: * API for SendEventJob and SetRoomStateJob has been altered to accept references, not pointers. * Methods on Room that invoke requests to the server, have lost const, because they may be reflecting the changed state on the fly, within themselves --- jobs/sendeventjob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'jobs/sendeventjob.cpp') diff --git a/jobs/sendeventjob.cpp b/jobs/sendeventjob.cpp index 7e33e089..f5190d4b 100644 --- a/jobs/sendeventjob.cpp +++ b/jobs/sendeventjob.cpp @@ -24,7 +24,7 @@ using namespace QMatrixClient; SendEventJob::SendEventJob(const QString& roomId, const QString& type, const QString& plainText) - : SendEventJob(roomId, new RoomMessageEvent(plainText, type)) + : SendEventJob(roomId, RoomMessageEvent(plainText, type)) { } void SendEventJob::beforeStart(const ConnectionData* connData) -- cgit v1.2.3