aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connection.h8
-rw-r--r--jobs/basejob.cpp38
-rw-r--r--jobs/basejob.h12
-rw-r--r--jobs/checkauthmethods.cpp6
-rw-r--r--jobs/checkauthmethods.h2
-rw-r--r--jobs/generated/inviting.cpp18
-rw-r--r--jobs/generated/inviting.h10
-rw-r--r--jobs/generated/kicking.cpp13
-rw-r--r--jobs/generated/kicking.h12
-rw-r--r--jobs/joinroomjob.cpp4
-rw-r--r--jobs/joinroomjob.h2
-rw-r--r--jobs/leaveroomjob.cpp4
-rw-r--r--jobs/leaveroomjob.h2
-rw-r--r--jobs/logoutjob.cpp4
-rw-r--r--jobs/logoutjob.h2
-rw-r--r--jobs/mediathumbnailjob.cpp11
-rw-r--r--jobs/mediathumbnailjob.h10
-rw-r--r--jobs/passwordlogin.cpp10
-rw-r--r--jobs/passwordlogin.h9
-rw-r--r--jobs/postreceiptjob.cpp8
-rw-r--r--jobs/postreceiptjob.h3
-rw-r--r--jobs/roommessagesjob.cpp10
-rw-r--r--jobs/roommessagesjob.h6
-rw-r--r--jobs/sendeventjob.cpp12
-rw-r--r--jobs/sendeventjob.h16
-rw-r--r--jobs/setroomstatejob.h11
-rw-r--r--jobs/syncjob.cpp8
-rw-r--r--jobs/syncjob.h21
28 files changed, 129 insertions, 143 deletions
diff --git a/connection.h b/connection.h
index 4ca6fbc5..213bf26f 100644
--- a/connection.h
+++ b/connection.h
@@ -72,6 +72,9 @@ namespace QMatrixClient
Q_INVOKABLE void sync(int timeout = -1);
Q_INVOKABLE void stopSync();
+
+ // Old API that will be abolished any time soon. DO NOT USE.
+
/** @deprecated Use callApi<PostMessageJob>() or Room::postMessage() instead */
Q_INVOKABLE virtual void postMessage(Room* room, const QString& type,
const QString& message) const;
@@ -82,6 +85,7 @@ namespace QMatrixClient
Q_INVOKABLE virtual JoinRoomJob* joinRoom(const QString& roomAlias);
/** @deprecated Use callApi<LeaveRoomJob>() or Room::leaveRoom() instead */
Q_INVOKABLE virtual void leaveRoom( Room* room );
+ /** @deprecated User callApi<RoomMessagesJob>() or Room::getPreviousContent() instead */
Q_INVOKABLE virtual RoomMessagesJob* getMessages(Room* room,
const QString& from) const;
/** @deprecated Use callApi<MediaThumbnailJob>() instead */
@@ -142,8 +146,8 @@ namespace QMatrixClient
template <typename JobT, typename... JobArgTs>
JobT* callApi(JobArgTs... jobArgs) const
{
- auto job = new JobT(connectionData(), jobArgs...);
- job->start();
+ auto job = new JobT(jobArgs...);
+ job->start(connectionData());
return job;
}
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp
index ea1a7158..240192d9 100644
--- a/jobs/basejob.cpp
+++ b/jobs/basejob.cpp
@@ -24,7 +24,7 @@
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QtCore/QTimer>
-#include <QtCore/QStringBuilder>
+//#include <QtCore/QStringBuilder>
#include <array>
@@ -45,16 +45,15 @@ class BaseJob::Private
public:
// Using an idiom from clang-tidy:
// http://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html
- Private(const ConnectionData* c, HttpVerb v,
- QString endpoint, QUrlQuery q, Data data, bool nt)
- : connection(c), verb(v), apiEndpoint(std::move(endpoint))
+ Private(HttpVerb v, QString endpoint, QUrlQuery q, Data data, bool nt)
+ : verb(v), apiEndpoint(std::move(endpoint))
, requestQuery(std::move(q)), requestData(std::move(data))
, needsToken(nt)
{ }
void sendRequest();
- const ConnectionData* connection;
+ const ConnectionData* connection = nullptr;
// Contents for the network request
HttpVerb verb;
@@ -80,16 +79,15 @@ inline QDebug operator<<(QDebug dbg, const BaseJob* j)
return dbg << j->objectName();
}
-BaseJob::BaseJob(const ConnectionData* connection, HttpVerb verb,
- const QString& name, const QString& endpoint,
+BaseJob::BaseJob(HttpVerb verb, const QString& name, const QString& endpoint,
const Query& query, const Data& data, bool needsToken)
- : d(new Private(connection, verb, endpoint, query, data, needsToken))
+ : d(new Private(verb, endpoint, query, data, needsToken))
{
setObjectName(name);
d->timer.setSingleShot(true);
connect (&d->timer, &QTimer::timeout, this, &BaseJob::timeout);
d->retryTimer.setSingleShot(true);
- connect (&d->retryTimer, &QTimer::timeout, this, &BaseJob::start);
+ connect (&d->retryTimer, &QTimer::timeout, this, &BaseJob::sendRequest);
}
BaseJob::~BaseJob()
@@ -98,9 +96,14 @@ BaseJob::~BaseJob()
qCDebug(d->logCat) << this << "destroyed";
}
-const ConnectionData* BaseJob::connection() const
+const QString& BaseJob::apiEndpoint() const
{
- return d->connection;
+ return d->apiEndpoint;
+}
+
+void BaseJob::setApiEndpoint(const QString& apiEndpoint)
+{
+ d->apiEndpoint = apiEndpoint;
}
const QUrlQuery& BaseJob::query() const
@@ -155,7 +158,18 @@ void BaseJob::Private::sendRequest()
}
}
-void BaseJob::start()
+void BaseJob::beforeStart(const ConnectionData* connData)
+{
+}
+
+void BaseJob::start(const ConnectionData* connData)
+{
+ d->connection = connData;
+ beforeStart(connData);
+ sendRequest();
+}
+
+void BaseJob::sendRequest()
{
emit aboutToStart();
d->retryTimer.stop(); // In case we were counting down at the moment
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:
diff --git a/jobs/checkauthmethods.cpp b/jobs/checkauthmethods.cpp
index 95b9a8f2..117def89 100644
--- a/jobs/checkauthmethods.cpp
+++ b/jobs/checkauthmethods.cpp
@@ -29,9 +29,9 @@ class CheckAuthMethods::Private
QString session;
};
-CheckAuthMethods::CheckAuthMethods(const ConnectionData* connection)
- : BaseJob(connection, HttpVerb::Get, "CheckAuthMethods",
- "_matrix/client/r0/login", Query(), Data(), false)
+CheckAuthMethods::CheckAuthMethods()
+ : BaseJob(HttpVerb::Get, "CheckAuthMethods",
+ QStringLiteral("_matrix/client/r0/login"), Query(), Data(), false)
, d(new Private)
{
}
diff --git a/jobs/checkauthmethods.h b/jobs/checkauthmethods.h
index 7d7dc40f..647f3db6 100644
--- a/jobs/checkauthmethods.h
+++ b/jobs/checkauthmethods.h
@@ -25,7 +25,7 @@ namespace QMatrixClient
class CheckAuthMethods : public BaseJob
{
public:
- CheckAuthMethods(const ConnectionData* connection);
+ CheckAuthMethods();
virtual ~CheckAuthMethods();
QString session();
diff --git a/jobs/generated/inviting.cpp b/jobs/generated/inviting.cpp
index e5e7f410..1e0c29a3 100644
--- a/jobs/generated/inviting.cpp
+++ b/jobs/generated/inviting.cpp
@@ -16,19 +16,11 @@ using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-InviteUserJob::InviteUserJob(const ConnectionData* connection,
- QString roomId
- ,
- QString user_id
- )
- : BaseJob(connection, HttpVerb::Post, "InviteUserJob"
- , basePath % "/rooms/" % roomId % "/invite"
- , Query { }
- , Data {
- { "user_id", toJson(user_id) }
- }
-
+InviteUserJob::InviteUserJob(QString roomId, QString user_id)
+ : BaseJob(HttpVerb::Post, "InviteUserJob",
+ basePath % "/rooms/" % roomId % "/invite",
+ Query {},
+ Data { { "user_id", toJson(user_id) } }
)
{ }
diff --git a/jobs/generated/inviting.h b/jobs/generated/inviting.h
index af5a426d..84cce06e 100644
--- a/jobs/generated/inviting.h
+++ b/jobs/generated/inviting.h
@@ -27,15 +27,7 @@ namespace QMatrixClient
class InviteUserJob : public BaseJob
{
public:
- InviteUserJob(const ConnectionData* connection
-
- ,
- QString roomId
-
- ,
- QString user_id
- );
-
+ InviteUserJob(QString roomId, QString user_id);
};
diff --git a/jobs/generated/kicking.cpp b/jobs/generated/kicking.cpp
index 726f6fb0..4f9d6580 100644
--- a/jobs/generated/kicking.cpp
+++ b/jobs/generated/kicking.cpp
@@ -16,23 +16,14 @@ using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-KickJob::KickJob(const ConnectionData* connection,
- QString roomId
- ,
- QString user_id
- ,
- QString reason
- )
- : BaseJob(connection, HttpVerb::Post, "KickJob"
+KickJob::KickJob(QString roomId, QString user_id, QString reason)
+ : BaseJob(HttpVerb::Post, "KickJob"
, basePath % "/rooms/" % roomId % "/kick"
, Query { }
, Data {
{ "user_id", toJson(user_id) },
-
{ "reason", toJson(reason) }
}
-
)
{ }
diff --git a/jobs/generated/kicking.h b/jobs/generated/kicking.h
index 7b183b08..a746db8b 100644
--- a/jobs/generated/kicking.h
+++ b/jobs/generated/kicking.h
@@ -27,17 +27,7 @@ namespace QMatrixClient
class KickJob : public BaseJob
{
public:
- KickJob(const ConnectionData* connection
-
- ,
- QString roomId
-
- ,
- QString user_id
-
- ,
- QString reason
- );
+ KickJob(QString roomId, QString user_id, QString reason);
};
diff --git a/jobs/joinroomjob.cpp b/jobs/joinroomjob.cpp
index 6278c18b..d465dd42 100644
--- a/jobs/joinroomjob.cpp
+++ b/jobs/joinroomjob.cpp
@@ -27,8 +27,8 @@ class JoinRoomJob::Private
QString roomId;
};
-JoinRoomJob::JoinRoomJob(const ConnectionData* data, const QString& roomAlias)
- : BaseJob(data, HttpVerb::Post, "JoinRoomJob",
+JoinRoomJob::JoinRoomJob(const QString& roomAlias)
+ : BaseJob(HttpVerb::Post, "JoinRoomJob",
QString("_matrix/client/r0/join/%1").arg(roomAlias))
, d(new Private)
{
diff --git a/jobs/joinroomjob.h b/jobs/joinroomjob.h
index 7cf90fd5..f3ba216f 100644
--- a/jobs/joinroomjob.h
+++ b/jobs/joinroomjob.h
@@ -25,7 +25,7 @@ namespace QMatrixClient
class JoinRoomJob: public BaseJob
{
public:
- JoinRoomJob(const ConnectionData* data, const QString& roomAlias);
+ explicit JoinRoomJob(const QString& roomAlias);
virtual ~JoinRoomJob();
QString roomId();
diff --git a/jobs/leaveroomjob.cpp b/jobs/leaveroomjob.cpp
index f73919ac..54e7f307 100644
--- a/jobs/leaveroomjob.cpp
+++ b/jobs/leaveroomjob.cpp
@@ -20,7 +20,7 @@
using namespace QMatrixClient;
-LeaveRoomJob::LeaveRoomJob(const ConnectionData* data, const QString& roomId)
- : BaseJob(data, HttpVerb::Post, "LeaveRoomJob",
+LeaveRoomJob::LeaveRoomJob(const QString& roomId)
+ : BaseJob(HttpVerb::Post, "LeaveRoomJob",
QStringLiteral("_matrix/client/r0/rooms/%1/leave").arg(roomId))
{ }
diff --git a/jobs/leaveroomjob.h b/jobs/leaveroomjob.h
index 70883b68..9224c1c8 100644
--- a/jobs/leaveroomjob.h
+++ b/jobs/leaveroomjob.h
@@ -25,6 +25,6 @@ namespace QMatrixClient
class LeaveRoomJob: public BaseJob
{
public:
- LeaveRoomJob(const ConnectionData* data, const QString& roomId);
+ explicit LeaveRoomJob(const QString& roomId);
};
} // namespace QMatrixClient
diff --git a/jobs/logoutjob.cpp b/jobs/logoutjob.cpp
index 84e88760..5ea5cf4d 100644
--- a/jobs/logoutjob.cpp
+++ b/jobs/logoutjob.cpp
@@ -20,7 +20,7 @@
using namespace QMatrixClient;
-LogoutJob::LogoutJob(const ConnectionData* connection)
- : BaseJob(connection, HttpVerb::Post, "LogoutJob", "/_matrix/client/r0/logout")
+LogoutJob::LogoutJob()
+ : BaseJob(HttpVerb::Post, "LogoutJob", "/_matrix/client/r0/logout")
{
}
diff --git a/jobs/logoutjob.h b/jobs/logoutjob.h
index 780719e4..e1b988dc 100644
--- a/jobs/logoutjob.h
+++ b/jobs/logoutjob.h
@@ -25,6 +25,6 @@ namespace QMatrixClient
class LogoutJob: public BaseJob
{
public:
- explicit LogoutJob(const ConnectionData* connection);
+ LogoutJob();
};
}
diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp
index 9579f6b2..5945493a 100644
--- a/jobs/mediathumbnailjob.cpp
+++ b/jobs/mediathumbnailjob.cpp
@@ -23,10 +23,11 @@
using namespace QMatrixClient;
-MediaThumbnailJob::MediaThumbnailJob(const ConnectionData* data, QUrl url, QSize requestedSize,
+MediaThumbnailJob::MediaThumbnailJob(QUrl url, QSize requestedSize,
ThumbnailType thumbnailType)
- : BaseJob(data, HttpVerb::Get, "MediaThumbnailJob",
- QString("/_matrix/media/v1/thumbnail/%1%2").arg(url.host(), url.path()),
+ : BaseJob(HttpVerb::Get, "MediaThumbnailJob",
+ QStringLiteral("/_matrix/media/v1/thumbnail/%1%2")
+ .arg(url.host(), url.path()),
Query(
{ { "width", QString::number(requestedSize.width()) }
, { "height", QString::number(requestedSize.height()) }
@@ -35,12 +36,12 @@ MediaThumbnailJob::MediaThumbnailJob(const ConnectionData* data, QUrl url, QSize
}))
{ }
-QPixmap MediaThumbnailJob::thumbnail()
+QPixmap MediaThumbnailJob::thumbnail() const
{
return pixmap;
}
-QPixmap MediaThumbnailJob::scaledThumbnail(QSize toSize)
+QPixmap MediaThumbnailJob::scaledThumbnail(QSize toSize) const
{
return pixmap.scaled(toSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
diff --git a/jobs/mediathumbnailjob.h b/jobs/mediathumbnailjob.h
index 186da829..292e7f14 100644
--- a/jobs/mediathumbnailjob.h
+++ b/jobs/mediathumbnailjob.h
@@ -29,11 +29,11 @@ namespace QMatrixClient
class MediaThumbnailJob: public BaseJob
{
public:
- MediaThumbnailJob(const ConnectionData* data, QUrl url, QSize requestedSize,
- ThumbnailType thumbnailType=ThumbnailType::Scale);
+ MediaThumbnailJob(QUrl url, QSize requestedSize,
+ ThumbnailType thumbnailType = ThumbnailType::Scale);
- QPixmap thumbnail();
- QPixmap scaledThumbnail(QSize toSize);
+ QPixmap thumbnail() const;
+ QPixmap scaledThumbnail(QSize toSize) const;
protected:
Status parseReply(QByteArray data) override;
@@ -41,4 +41,4 @@ namespace QMatrixClient
private:
QPixmap pixmap;
};
-}
+} // namespace QMatrixClient
diff --git a/jobs/passwordlogin.cpp b/jobs/passwordlogin.cpp
index 09108215..9af025e6 100644
--- a/jobs/passwordlogin.cpp
+++ b/jobs/passwordlogin.cpp
@@ -28,8 +28,8 @@ class PasswordLogin::Private
QString returned_token;
};
-PasswordLogin::PasswordLogin(const ConnectionData* connection, QString user, QString password)
- : BaseJob(connection, HttpVerb::Post, "PasswordLogin"
+PasswordLogin::PasswordLogin(QString user, QString password)
+ : BaseJob(HttpVerb::Post, "PasswordLogin"
, "_matrix/client/r0/login"
, Query()
, Data(
@@ -48,17 +48,17 @@ PasswordLogin::~PasswordLogin()
delete d;
}
-QString PasswordLogin::token()
+QString PasswordLogin::token() const
{
return d->returned_token;
}
-QString PasswordLogin::id()
+QString PasswordLogin::id() const
{
return d->returned_id;
}
-QString PasswordLogin::server()
+QString PasswordLogin::server() const
{
return d->returned_server;
}
diff --git a/jobs/passwordlogin.h b/jobs/passwordlogin.h
index 6b7db0b3..fb8777a3 100644
--- a/jobs/passwordlogin.h
+++ b/jobs/passwordlogin.h
@@ -25,13 +25,12 @@ namespace QMatrixClient
class PasswordLogin : public BaseJob
{
public:
- PasswordLogin(const ConnectionData* connection,
- QString user, QString password);
+ PasswordLogin(QString user, QString password);
virtual ~PasswordLogin();
- QString token();
- QString id();
- QString server();
+ QString token() const;
+ QString id() const;
+ QString server() const;
protected:
Status parseJson(const QJsonDocument& data) override;
diff --git a/jobs/postreceiptjob.cpp b/jobs/postreceiptjob.cpp
index 00926de6..4572d74c 100644
--- a/jobs/postreceiptjob.cpp
+++ b/jobs/postreceiptjob.cpp
@@ -20,8 +20,8 @@
using namespace QMatrixClient;
-PostReceiptJob::PostReceiptJob(const ConnectionData* connection,
- const QString& roomId, const QString& eventId)
- : BaseJob(connection, HttpVerb::Post, "PostReceiptJob",
- QString("/_matrix/client/r0/rooms/%1/receipt/m.read/%2").arg(roomId, eventId))
+PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& eventId)
+ : BaseJob(HttpVerb::Post, "PostReceiptJob",
+ QStringLiteral("/_matrix/client/r0/rooms/%1/receipt/m.read/%2")
+ .arg(roomId, eventId))
{ }
diff --git a/jobs/postreceiptjob.h b/jobs/postreceiptjob.h
index 1c84f411..23df7c05 100644
--- a/jobs/postreceiptjob.h
+++ b/jobs/postreceiptjob.h
@@ -25,7 +25,6 @@ namespace QMatrixClient
class PostReceiptJob: public BaseJob
{
public:
- PostReceiptJob(const ConnectionData* connection, const QString& roomId,
- const QString& eventId);
+ PostReceiptJob(const QString& roomId, const QString& eventId);
};
}
diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp
index 3e603a50..078c692a 100644
--- a/jobs/roommessagesjob.cpp
+++ b/jobs/roommessagesjob.cpp
@@ -18,8 +18,6 @@
#include "roommessagesjob.h"
-#include "util.h"
-
using namespace QMatrixClient;
class RoomMessagesJob::Private
@@ -29,9 +27,9 @@ class RoomMessagesJob::Private
QString end;
};
-RoomMessagesJob::RoomMessagesJob(const ConnectionData* data, const QString& roomId,
- const QString& from, int limit, FetchDirection dir)
- : BaseJob(data, HttpVerb::Get, "RoomMessagesJob",
+RoomMessagesJob::RoomMessagesJob(const QString& roomId, const QString& from,
+ int limit, FetchDirection dir)
+ : BaseJob(HttpVerb::Get, "RoomMessagesJob",
QString("/_matrix/client/r0/rooms/%1/messages").arg(roomId),
Query(
{ { "from", from }
@@ -53,7 +51,7 @@ RoomEvents RoomMessagesJob::releaseEvents()
return d->events.release();
}
-QString RoomMessagesJob::end()
+QString RoomMessagesJob::end() const
{
return d->end;
}
diff --git a/jobs/roommessagesjob.h b/jobs/roommessagesjob.h
index a029c27c..9680d52c 100644
--- a/jobs/roommessagesjob.h
+++ b/jobs/roommessagesjob.h
@@ -29,13 +29,13 @@ namespace QMatrixClient
class RoomMessagesJob: public BaseJob
{
public:
- RoomMessagesJob(const ConnectionData* data, const QString& roomId,
- const QString& from, int limit = 10,
+ RoomMessagesJob(const QString& roomId, const QString& from,
+ int limit = 10,
FetchDirection dir = FetchDirection::Backward);
virtual ~RoomMessagesJob();
RoomEvents releaseEvents();
- QString end();
+ QString end() const;
protected:
Status parseJson(const QJsonDocument& data) override;
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();
diff --git a/jobs/sendeventjob.h b/jobs/sendeventjob.h
index 42948cc2..7b10b3d4 100644
--- a/jobs/sendeventjob.h
+++ b/jobs/sendeventjob.h
@@ -29,12 +29,10 @@ namespace QMatrixClient
public:
/** Constructs a job that sends an arbitrary room event */
template <typename EvT>
- SendEventJob(const ConnectionData* connection, const QString& roomId,
- const EvT* event)
- : BaseJob(connection, HttpVerb::Put, "SendEventJob",
- QStringLiteral("_matrix/client/r0/rooms/%1/send/%2/%3")
- .arg(roomId, EvT::TypeId,
- connection->generateTxnId()),
+ SendEventJob(const QString& roomId, const EvT* event)
+ : BaseJob(HttpVerb::Put, QStringLiteral("SendEventJob"),
+ QStringLiteral("_matrix/client/r0/rooms/%1/send/%2/")
+ .arg(roomId, EvT::TypeId), // See also beforeStart()
Query(),
Data(event->toJson()))
{ }
@@ -43,8 +41,8 @@ namespace QMatrixClient
* Constructs a plain text message job (for compatibility with
* the old PostMessageJob API).
*/
- SendEventJob(const ConnectionData* connection, const QString& roomId,
- const QString& type, const QString& plainText);
+ SendEventJob(const QString& roomId, const QString& type,
+ const QString& plainText);
QString eventId() const { return _eventId; }
@@ -53,5 +51,7 @@ namespace QMatrixClient
private:
QString _eventId;
+
+ void beforeStart(const ConnectionData* connData) override;
};
} // namespace QMatrixClient
diff --git a/jobs/setroomstatejob.h b/jobs/setroomstatejob.h
index 1c72f31c..ddc271b9 100644
--- a/jobs/setroomstatejob.h
+++ b/jobs/setroomstatejob.h
@@ -32,9 +32,9 @@ namespace QMatrixClient
* with a state key.
*/
template <typename EvT>
- SetRoomStateJob(const ConnectionData* connection, const QString& roomId,
- const EvT* event, const QString& stateKey)
- : BaseJob(connection, HttpVerb::Put, "SetRoomStateJob",
+ SetRoomStateJob(const QString& roomId, const QString& stateKey,
+ const EvT* event)
+ : BaseJob(HttpVerb::Put, "SetRoomStateJob",
QStringLiteral("_matrix/client/r0/rooms/%1/state/%2/%3")
.arg(roomId, EvT::TypeId, stateKey),
Query(),
@@ -45,9 +45,8 @@ namespace QMatrixClient
* without a state key.
*/
template <typename EvT>
- SetRoomStateJob(const ConnectionData* connection, const QString& roomId,
- const EvT* event)
- : BaseJob(connection, HttpVerb::Put, "SetRoomStateJob",
+ SetRoomStateJob(const QString& roomId, const EvT* event)
+ : BaseJob(HttpVerb::Put, "SetRoomStateJob",
QStringLiteral("_matrix/client/r0/rooms/%1/state/%2")
.arg(roomId, EvT::TypeId),
Query(),
diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp
index f679e6f4..6d37db5c 100644
--- a/jobs/syncjob.cpp
+++ b/jobs/syncjob.cpp
@@ -24,10 +24,10 @@ using namespace QMatrixClient;
static size_t jobId = 0;
-SyncJob::SyncJob(const ConnectionData* connection, const QString& since,
- const QString& filter, int timeout, const QString& presence)
- : BaseJob(connection, HttpVerb::Get, QString("SyncJob-%1").arg(++jobId),
- "_matrix/client/r0/sync")
+SyncJob::SyncJob(const QString& since, const QString& filter, int timeout,
+ const QString& presence)
+ : BaseJob(HttpVerb::Get, QStringLiteral("SyncJob-%1").arg(++jobId),
+ QStringLiteral("_matrix/client/r0/sync"))
{
setLoggingCategory(SYNCJOB);
QUrlQuery query;
diff --git a/jobs/syncjob.h b/jobs/syncjob.h
index 6697a265..b1db914d 100644
--- a/jobs/syncjob.h
+++ b/jobs/syncjob.h
@@ -68,21 +68,22 @@ namespace QMatrixClient
// QVector cannot work with non-copiable objects, std::vector can.
using SyncDataList = std::vector<SyncRoomData>;
- class SyncData {
- public:
- BaseJob::Status parseJson(const QJsonDocument &data);
- SyncDataList&& takeRoomData();
- QString nextBatch() const;
-
- private:
- QString nextBatch_;
- SyncDataList roomData;
+ class SyncData
+ {
+ public:
+ BaseJob::Status parseJson(const QJsonDocument &data);
+ SyncDataList&& takeRoomData();
+ QString nextBatch() const;
+
+ private:
+ QString nextBatch_;
+ SyncDataList roomData;
};
class SyncJob: public BaseJob
{
public:
- explicit SyncJob(const ConnectionData* connection, const QString& since = {},
+ explicit SyncJob(const QString& since = {},
const QString& filter = {},
int timeout = -1, const QString& presence = {});