diff options
Diffstat (limited to 'jobs/syncjob.cpp')
-rw-r--r-- | jobs/syncjob.cpp | 66 |
1 files changed, 14 insertions, 52 deletions
diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index 59c40785..e8ee25df 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -32,25 +32,28 @@ using namespace QMatrixClient; class SyncJob::Private { public: - QString since; - QString filter; - bool fullState; - QString presence; - int timeout; QString nextBatch; - SyncData roomData; }; static size_t jobId = 0; -SyncJob::SyncJob(ConnectionData* connection, QString since) - : BaseJob(connection, JobHttpType::GetJob, QString("SyncJob-%1").arg(++jobId)) +SyncJob::SyncJob(ConnectionData* connection, QString filter, int timeout, + QString since, QString presence) + : BaseJob(connection, JobHttpType::GetJob, QString("SyncJob-%1").arg(++jobId), + "_matrix/client/r0/sync") , d(new Private) { - d->since = since; - d->fullState = false; - d->timeout = -1; + QUrlQuery query; + if( !filter.isEmpty() ) + query.addQueryItem("filter", filter); + if( !presence.isEmpty() ) + query.addQueryItem("set_presence", presence); + if( timeout >= 0 ) + query.addQueryItem("timeout", QString::number(timeout)); + if( !since.isEmpty() ) + query.addQueryItem("since", since); + setRequestQuery(query); } SyncJob::~SyncJob() @@ -58,26 +61,6 @@ SyncJob::~SyncJob() delete d; } -void SyncJob::setFilter(QString filter) -{ - d->filter = filter; -} - -void SyncJob::setFullState(bool full) -{ - d->fullState = full; -} - -void SyncJob::setPresence(QString presence) -{ - d->presence = presence; -} - -void SyncJob::setTimeout(int timeout) -{ - d->timeout = timeout; -} - QString SyncJob::nextBatch() const { return d->nextBatch; @@ -88,27 +71,6 @@ SyncData& SyncJob::roomData() return d->roomData; } -QString SyncJob::apiPath() const -{ - return "_matrix/client/r0/sync"; -} - -QUrlQuery SyncJob::query() const -{ - QUrlQuery query; - if( !d->filter.isEmpty() ) - query.addQueryItem("filter", d->filter); - if( d->fullState ) - query.addQueryItem("full_state", "true"); - if( !d->presence.isEmpty() ) - query.addQueryItem("set_presence", d->presence); - if( d->timeout >= 0 ) - query.addQueryItem("timeout", QString::number(d->timeout)); - if( !d->since.isEmpty() ) - query.addQueryItem("since", d->since); - return query; -} - BaseJob::Status SyncJob::parseJson(const QJsonDocument& data) { QJsonObject json = data.object(); |