libQuotient
A Qt library for building matrix clients
Quotient::BaseJob Class Reference

#include <basejob.h>

Inherits QObject.

Inherited by Quotient::Add3PIDJob, Quotient::BanJob, Quotient::Bind3PIDJob, Quotient::ChangePasswordJob, Quotient::CheckUsernameAvailabilityJob, Quotient::ClaimKeysJob, Quotient::CreateContentJob, Quotient::CreateRoomJob, Quotient::DeactivateAccountJob, Quotient::DefineFilterJob, Quotient::Delete3pidFromAccountJob, Quotient::DeleteDeviceJob, Quotient::DeleteDevicesJob, Quotient::DeletePushRuleJob, Quotient::DeleteRoomAliasJob, Quotient::DeleteRoomKeyBySessionIdJob, Quotient::DeleteRoomKeysByRoomIdJob, Quotient::DeleteRoomKeysJob, Quotient::DeleteRoomKeysVersionJob, Quotient::DeleteRoomTagJob, Quotient::ForgetRoomJob, Quotient::GenerateLoginTokenJob, Quotient::GetAccount3PIDsJob, Quotient::GetAccountDataJob, Quotient::GetAccountDataPerRoomJob, Quotient::GetAvatarUrlJob, Quotient::GetCapabilitiesJob, Quotient::GetConfigJob, Quotient::GetContentJob, Quotient::GetContentOverrideNameJob, Quotient::GetContentThumbnailJob, Quotient::GetDeviceJob, Quotient::GetDevicesJob, Quotient::GetDisplayNameJob, Quotient::GetEventByTimestampJob, Quotient::GetEventContextJob, Quotient::GetFilterJob, Quotient::GetJoinedMembersByRoomJob, Quotient::GetJoinedRoomsJob, Quotient::GetKeysChangesJob, Quotient::GetLocalAliasesJob, Quotient::GetLoginFlowsJob, Quotient::GetMembersByRoomJob, Quotient::GetNotificationsJob, Quotient::GetOneRoomEventJob, Quotient::GetPresenceJob, Quotient::GetProtocolMetadataJob, Quotient::GetProtocolsJob, Quotient::GetPublicRoomsJob, Quotient::GetPushRuleActionsJob, Quotient::GetPushRuleJob, Quotient::GetPushRulesJob, Quotient::GetPushersJob, Quotient::GetRelatingEventsJob, Quotient::GetRelatingEventsWithRelTypeAndEventTypeJob, Quotient::GetRelatingEventsWithRelTypeJob, Quotient::GetRoomEventsJob, Quotient::GetRoomIdByAliasJob, Quotient::GetRoomKeyBySessionIdJob, Quotient::GetRoomKeysByRoomIdJob, Quotient::GetRoomKeysJob, Quotient::GetRoomKeysVersionCurrentJob, Quotient::GetRoomKeysVersionJob, Quotient::GetRoomStateJob, Quotient::GetRoomStateWithKeyJob, Quotient::GetRoomTagsJob, Quotient::GetRoomVisibilityOnDirectoryJob, Quotient::GetSpaceHierarchyJob, Quotient::GetThreadRootsJob, Quotient::GetTokenOwnerJob, Quotient::GetTurnServerJob, Quotient::GetUrlPreviewJob, Quotient::GetUserProfileJob, Quotient::GetVersionsJob, Quotient::GetWellknownJob, Quotient::GetWellknownSupportJob, Quotient::GetWhoIsJob, Quotient::InviteBy3PIDJob, Quotient::InviteUserJob, Quotient::IsPushRuleEnabledJob, Quotient::JoinRoomByIdJob, Quotient::JoinRoomJob, Quotient::KickJob, Quotient::KnockRoomJob, Quotient::LeaveRoomJob, Quotient::LoginJob, Quotient::LogoutAllJob, Quotient::LogoutJob, Quotient::PeekEventsJob, Quotient::Post3PIDsJob, Quotient::PostPusherJob, Quotient::PostReceiptJob, Quotient::PostRoomKeysVersionJob, Quotient::PutRoomKeyBySessionIdJob, Quotient::PutRoomKeysByRoomIdJob, Quotient::PutRoomKeysJob, Quotient::PutRoomKeysVersionJob, Quotient::QueryKeysJob, Quotient::QueryLocationByAliasJob, Quotient::QueryLocationByProtocolJob, Quotient::QueryPublicRoomsJob, Quotient::QueryUserByIDJob, Quotient::QueryUserByProtocolJob, Quotient::RedactEventJob, Quotient::RedirectToIdPJob, Quotient::RedirectToSSOJob, Quotient::RefreshJob, Quotient::RegisterJob, Quotient::RegistrationTokenValidityJob, Quotient::ReportContentJob, Quotient::RequestOpenIdTokenJob, Quotient::RequestTokenTo3PIDEmailJob, Quotient::RequestTokenTo3PIDMSISDNJob, Quotient::RequestTokenToRegisterEmailJob, Quotient::RequestTokenToRegisterMSISDNJob, Quotient::RequestTokenToResetPasswordEmailJob, Quotient::RequestTokenToResetPasswordMSISDNJob, Quotient::SearchJob, Quotient::SearchUserDirectoryJob, Quotient::SendMessageJob, Quotient::SendToDeviceJob, Quotient::SetAccountDataJob, Quotient::SetAccountDataPerRoomJob, Quotient::SetAvatarUrlJob, Quotient::SetDisplayNameJob, Quotient::SetPresenceJob, Quotient::SetPushRuleActionsJob, Quotient::SetPushRuleEnabledJob, Quotient::SetPushRuleJob, Quotient::SetReadMarkerJob, Quotient::SetRoomAliasJob, Quotient::SetRoomStateWithKeyJob, Quotient::SetRoomTagJob, Quotient::SetRoomVisibilityOnDirectoryJob, Quotient::SetTypingJob, Quotient::SyncJob, Quotient::UnbanJob, Quotient::Unbind3pidFromAccountJob, Quotient::UpdateAppserviceRoomDirectoryVisibilityJob, Quotient::UpdateDeviceJob, Quotient::UpgradeRoomJob, Quotient::UploadContentJob, Quotient::UploadContentToMXCJob, Quotient::UploadCrossSigningKeysJob, Quotient::UploadCrossSigningSignaturesJob, and Quotient::UploadKeysJob.

Collaboration diagram for Quotient::BaseJob:

Classes

struct  Status
 

Public Types

enum  StatusCode {
  Success = 0 , NoError = Success , Pending = 1 , WarningLevel = 20 ,
  UnexpectedResponseType = 21 , UnexpectedResponseTypeWarning = UnexpectedResponseType , Unprepared = 25 , Abandoned = 50 ,
  ErrorLevel = 100 , NetworkError = 101 , Timeout , Unauthorised ,
  ContentAccessError , NotFound , IncorrectRequest , IncorrectResponse ,
  TooManyRequests , RateLimited = TooManyRequests , RequestNotImplemented , UnsupportedRoomVersion ,
  NetworkAuthRequired , UserConsentRequired , CannotLeaveRoom , UserDeactivated ,
  FileError , UserDefinedError = 256
}
 
using duration_ms_t = std::chrono::milliseconds::rep
 

Public Slots

void initiate (Quotient::ConnectionData *connData, bool inBackground)
 
void abandon ()
 Abandon the result of this job, arrived or unarrived. More...
 

Signals

void aboutToSendRequest (QNetworkRequest *req)
 The job is about to send a network request. More...
 
void sentRequest ()
 
void statusChanged (Quotient::BaseJob::Status newStatus)
 
void retryScheduled (int nextAttempt, Quotient::BaseJob::duration_ms_t inMilliseconds)
 
void rateLimited ()
 
void finished (Quotient::BaseJob *job)
 
void result (Quotient::BaseJob *job)
 
void success (Quotient::BaseJob *)
 
void failure (Quotient::BaseJob *)
 
void downloadProgress (qint64 bytesReceived, qint64 bytesTotal)
 
void uploadProgress (qint64 bytesSent, qint64 bytesTotal)
 

Public Member Functions

 BaseJob (HttpVerb verb, const QString &name, QByteArray endpoint, bool needsToken=true)
 
 BaseJob (HttpVerb verb, const QString &name, QByteArray endpoint, const QUrlQuery &query, RequestData &&data={}, bool needsToken=true)
 
QUrl requestUrl () const
 
bool isBackground () const
 
Status status () const
 
QString statusCaption () const
 
QByteArray rawData (int bytesAtMost) const
 
const QByteArray & rawData () const
 
QString rawDataSample (int bytesAtMost=65535) const
 
QJsonObject jsonData () const
 
QJsonArray jsonItems () const
 
template<typename T , typename StrT >
loadFromJson (const StrT &keyName, T &&defaultValue={}) const
 
template<typename T >
takeFromJson (const QString &key, T &&defaultValue={})
 
int error () const
 
virtual QString errorString () const
 
QUrl errorUrl () const
 
int maxRetries () const
 
void setMaxRetries (int newMaxRetries)
 
std::chrono::seconds getCurrentTimeout () const
 
Q_INVOKABLE Quotient::BaseJob::duration_ms_t getCurrentTimeoutMs () const
 
std::chrono::seconds getNextRetryInterval () const
 
Q_INVOKABLE Quotient::BaseJob::duration_ms_t getNextRetryMs () const
 
std::chrono::milliseconds timeToRetry () const
 
Q_INVOKABLE Quotient::BaseJob::duration_ms_t millisToRetry () const
 

Static Public Member Functions

template<typename... StrTs>
static QByteArray makePath (StrTs &&... parts)
 

Protected Types

using headers_t = QHash< QByteArray, QByteArray >
 

Protected Slots

void timeout ()
 
virtual Status checkReply (const QNetworkReply *reply) const
 Check the pending or received reply for upfront issues. More...
 

Protected Member Functions

const headers_trequestHeaders () const
 
void setRequestHeader (const headers_t::key_type &headerName, const headers_t::mapped_type &headerValue)
 
void setRequestHeaders (const headers_t &headers)
 
QUrlQuery query () const
 
void setRequestQuery (const QUrlQuery &query)
 
const RequestDatarequestData () const
 
void setRequestData (RequestData &&data)
 
const QByteArrayList & expectedContentTypes () const
 
void addExpectedContentType (const QByteArray &contentType)
 
void setExpectedContentTypes (const QByteArrayList &contentTypes)
 
QByteArrayList expectedKeys () const
 
void addExpectedKey (const QByteArray &key)
 
void setExpectedKeys (const QByteArrayList &keys)
 
const QNetworkReply * reply () const
 
QNetworkReply * reply ()
 
virtual void doPrepare ()
 
virtual void onSentRequest (QNetworkReply *)
 
virtual void beforeAbandon ()
 
virtual Status prepareResult ()
 An extension point for additional reply processing. More...
 
virtual Status prepareError (Status currentStatus)
 Process details of the error. More...
 
QJsonValue takeValueFromJson (const QString &key)
 Get direct access to the JSON response object in the job. More...
 
void setStatus (Status s)
 
void setStatus (int code, QString message)
 
void setLoggingCategory (QMessageLogger::CategoryFunction lcf)
 Set the logging category for the given job instance. More...
 
 ~BaseJob () override
 

Static Protected Member Functions

static QUrl makeRequestUrl (QUrl baseUrl, const QByteArray &encodedPath, const QUrlQuery &query={})
 

Properties

QUrl requestUrl
 
int maxRetries
 
int statusCode
 

Friends

class ConnectionData
 
template<class JobT >
class JobHandle
 
QDebug operator<< (QDebug dbg, const BaseJob *j)
 

Detailed Description

Definition at line 26 of file basejob.h.

Member Typedef Documentation

◆ duration_ms_t

using Quotient::BaseJob::duration_ms_t = std::chrono::milliseconds::rep

Definition at line 228 of file basejob.h.

◆ headers_t

using Quotient::BaseJob::headers_t = QHash<QByteArray, QByteArray>
protected

Definition at line 340 of file basejob.h.

Member Enumeration Documentation

◆ StatusCode

The status code of a job

Every job is created in Unprepared status; upon calling prepare() from Connection (if things are fine) it go to Pending status. After that, the next transition comes after the reply arrives and its contents are analysed. At any point in time the job can be abandon()ed, causing it to switch to status Abandoned for a brief period before deletion.

Enumerator
Success 
NoError 
Pending 
WarningLevel 

Warnings have codes starting from this.

UnexpectedResponseType 
UnexpectedResponseTypeWarning 
Unprepared 

Initial job state is incomplete, hence warning level.

Abandoned 

A tiny period between abandoning and object deletion.

ErrorLevel 

Errors have codes starting from this.

NetworkError 
Timeout 
Unauthorised 
ContentAccessError 
NotFound 
IncorrectRequest 
IncorrectResponse 
TooManyRequests 
RateLimited 
RequestNotImplemented 
UnsupportedRoomVersion 
NetworkAuthRequired 
UserConsentRequired 
CannotLeaveRoom 
UserDeactivated 
FileError 
UserDefinedError 

Definition at line 48 of file basejob.h.

Constructor & Destructor Documentation

◆ BaseJob() [1/2]

Quotient::BaseJob::BaseJob ( HttpVerb  verb,
const QString &  name,
QByteArray  endpoint,
bool  needsToken = true 
)

◆ BaseJob() [2/2]

Quotient::BaseJob::BaseJob ( HttpVerb  verb,
const QString &  name,
QByteArray  endpoint,
const QUrlQuery &  query,
RequestData &&  data = {},
bool  needsToken = true 
)

◆ ~BaseJob()

Quotient::BaseJob::~BaseJob ( )
overrideprotected

Member Function Documentation

◆ abandon

void Quotient::BaseJob::abandon ( )
slot

Abandon the result of this job, arrived or unarrived.

This aborts waiting for a reply from the server (if there was any pending) and deletes the job object. No result signals (result, success, failure) are emitted, only finished() is.

◆ aboutToSendRequest

void Quotient::BaseJob::aboutToSendRequest ( QNetworkRequest *  req)
signal

The job is about to send a network request.

This signal is emitted every time a network request is made (which can occur several times due to job retries). You can use it to change the request parameters (such as redirect policy) if necessary. If you need to set additional request headers or query items, do that using setRequestHeaders() and setRequestQuery() instead.

Note
req is not guaranteed to exist (i.e. it may point to garbage) unless this signal is handled via a DirectConnection (or BlockingQueuedConnection if in another thread), i.e., synchronously.
See also
setRequestHeaders, setRequestQuery

◆ addExpectedContentType()

void Quotient::BaseJob::addExpectedContentType ( const QByteArray &  contentType)
protected

◆ addExpectedKey()

void Quotient::BaseJob::addExpectedKey ( const QByteArray &  key)
protected

◆ beforeAbandon()

virtual void Quotient::BaseJob::beforeAbandon ( )
protectedvirtual

◆ checkReply

virtual Status Quotient::BaseJob::checkReply ( const QNetworkReply *  reply) const
protectedvirtualslot

Check the pending or received reply for upfront issues.

This is invoked when headers are first received and also once the complete reply is obtained; the base implementation checks the HTTP headers to detect general issues such as network errors or access denial and it's strongly recommended to call it from overrides, as early as possible. This slot is const and cannot read the response body. If you need to read the body on the fly, override onSentRequest() and connect in it to reply->readyRead(); and if you only need to validate the body after it fully arrived, use prepareResult() for that). Returning anything except NoError/Success switches further processing from prepareResult() to prepareError().

Returns
the result of checking the reply
See also
gotReply

◆ doPrepare()

virtual void Quotient::BaseJob::doPrepare ( )
protectedvirtual

Prepares the job for execution

This method is called no more than once per job lifecycle, when it's first scheduled for execution; in particular, it is not called on retries.

◆ downloadProgress

void Quotient::BaseJob::downloadProgress ( qint64  bytesReceived,
qint64  bytesTotal 
)
signal

◆ error()

int Quotient::BaseJob::error ( ) const

Error (more generally, status) code Equivalent to status().code

See also
status

◆ errorString()

virtual QString Quotient::BaseJob::errorString ( ) const
virtual

Error-specific message, as returned by the server

◆ errorUrl()

QUrl Quotient::BaseJob::errorUrl ( ) const

A URL to help/clarify the error, if provided by the server

◆ expectedContentTypes()

const QByteArrayList& Quotient::BaseJob::expectedContentTypes ( ) const
protected

◆ expectedKeys()

QByteArrayList Quotient::BaseJob::expectedKeys ( ) const
protected

◆ failure

void Quotient::BaseJob::failure ( Quotient::BaseJob )
signal

Emitted together with result() if there's an error. Similar to result(), this won't be emitted in case of abandon().

See also
result, success

◆ finished

void Quotient::BaseJob::finished ( Quotient::BaseJob job)
signal

Emitted when the job is finished, in any case. It is used to notify observers that the job is terminated and that progress can be hidden.

This should not be emitted directly by subclasses; use finishJob() instead.

In general, to be notified of a job's completion, client code should connect to result(), success(), or failure() rather than finished(). However if you need to track the job's lifecycle you should connect to this instead of result(); in particular, only this signal will be emitted on abandoning.

Parameters
jobthe job that emitted this signal
See also
result, success, failure

◆ getCurrentTimeout()

std::chrono::seconds Quotient::BaseJob::getCurrentTimeout ( ) const

◆ getCurrentTimeoutMs()

Q_INVOKABLE Quotient::BaseJob::duration_ms_t Quotient::BaseJob::getCurrentTimeoutMs ( ) const

◆ getNextRetryInterval()

std::chrono::seconds Quotient::BaseJob::getNextRetryInterval ( ) const

◆ getNextRetryMs()

Q_INVOKABLE Quotient::BaseJob::duration_ms_t Quotient::BaseJob::getNextRetryMs ( ) const

◆ initiate

void Quotient::BaseJob::initiate ( Quotient::ConnectionData connData,
bool  inBackground 
)
slot

◆ isBackground()

bool Quotient::BaseJob::isBackground ( ) const

◆ jsonData()

QJsonObject Quotient::BaseJob::jsonData ( ) const

Get the response body as a JSON object

If the job's returned content type is not application/json or if the top-level JSON entity is not an object, an empty object is returned.

◆ jsonItems()

QJsonArray Quotient::BaseJob::jsonItems ( ) const

Get the response body as a JSON array

If the job's returned content type is not application/json or if the top-level JSON entity is not an array, an empty array is returned.

◆ loadFromJson()

template<typename T , typename StrT >
T Quotient::BaseJob::loadFromJson ( const StrT &  keyName,
T &&  defaultValue = {} 
) const
inline

Load the property from the JSON response assuming a given C++ type

If there's no top-level JSON object in the response or if there's no node with the key keyName, defaultValue is returned.

Definition at line 192 of file basejob.h.

◆ makePath()

template<typename... StrTs>
static QByteArray Quotient::BaseJob::makePath ( StrTs &&...  parts)
inlinestatic

Definition at line 79 of file basejob.h.

◆ makeRequestUrl()

static QUrl Quotient::BaseJob::makeRequestUrl ( QUrl  baseUrl,
const QByteArray &  encodedPath,
const QUrlQuery &  query = {} 
)
staticprotected

Construct a URL out of baseUrl, path and query

The function ensures exactly one '/' between the path component of baseUrl and path. The query component of baseUrl is ignored.

◆ maxRetries()

int Quotient::BaseJob::maxRetries ( ) const

◆ millisToRetry()

Q_INVOKABLE Quotient::BaseJob::duration_ms_t Quotient::BaseJob::millisToRetry ( ) const

◆ onSentRequest()

virtual void Quotient::BaseJob::onSentRequest ( QNetworkReply *  )
protectedvirtual

Postprocessing after the network request has been sent

This method is called every time the job receives a running QNetworkReply object from NetworkAccessManager - basically, after successfully sending a network request (including retries).

◆ prepareError()

virtual Status Quotient::BaseJob::prepareError ( Status  currentStatus)
protectedvirtual

Process details of the error.

The function processes the reply in case when status from checkReply() was not good (usually because of an unsuccessful HTTP code). The base implementation assumes Matrix JSON error object in the body; overrides are strongly recommended to call it for all stock Matrix responses as early as possible and only then process custom errors, with JSON or non-JSON payload.

Returns
updated (if necessary) job status

◆ prepareResult()

virtual Status Quotient::BaseJob::prepareResult ( )
protectedvirtual

An extension point for additional reply processing.

The base implementation does nothing and returns Success.

See also
gotReply

Reimplemented in Quotient::SyncJob, and Quotient::MediaThumbnailJob.

◆ query()

QUrlQuery Quotient::BaseJob::query ( ) const
protected

◆ rateLimited

void Quotient::BaseJob::rateLimited ( )
signal

The previous network request has been rate-limited; the next attempt will be queued and run sometime later. Since other jobs may already wait in the queue, it's not possible to predict the wait time.

◆ rawData() [1/2]

const QByteArray& Quotient::BaseJob::rawData ( ) const

Access the whole response body as received from the server

◆ rawData() [2/2]

QByteArray Quotient::BaseJob::rawData ( int  bytesAtMost) const

Get first bytes of the raw response body as received from the server

Parameters
bytesAtMostthe number of leftmost bytes to return
See also
rawDataSample

◆ rawDataSample()

QString Quotient::BaseJob::rawDataSample ( int  bytesAtMost = 65535) const

Get UI-friendly sample of raw data

This is almost the same as rawData but appends the "truncated" suffix if not all data fit in bytesAtMost. This call is recommended to present a sample of raw data as "details" next to error messages. Note that the default bytesAtMost value is also tailored to UI cases.

See also
rawData

◆ reply() [1/2]

QNetworkReply* Quotient::BaseJob::reply ( )
protected

◆ reply() [2/2]

const QNetworkReply* Quotient::BaseJob::reply ( ) const
protected

◆ requestData()

const RequestData& Quotient::BaseJob::requestData ( ) const
protected

◆ requestHeaders()

const headers_t& Quotient::BaseJob::requestHeaders ( ) const
protected

◆ requestUrl()

QUrl Quotient::BaseJob::requestUrl ( ) const

◆ result

void Quotient::BaseJob::result ( Quotient::BaseJob job)
signal

Emitted when the job is finished (except when abandoned).

Use error() to know if the job was finished with error.

Parameters
jobthe job that emitted this signal
See also
success, failure

◆ retryScheduled

void Quotient::BaseJob::retryScheduled ( int  nextAttempt,
Quotient::BaseJob::duration_ms_t  inMilliseconds 
)
signal

The previous network request has failed; the next attempt will be done in the specified time

Parameters
nextAttemptthe 1-based number of attempt (will always be more than 1)
inMillisecondsthe interval after which the next attempt will be taken

◆ sentRequest

void Quotient::BaseJob::sentRequest ( )
signal

The job has sent a network request

◆ setExpectedContentTypes()

void Quotient::BaseJob::setExpectedContentTypes ( const QByteArrayList &  contentTypes)
protected

◆ setExpectedKeys()

void Quotient::BaseJob::setExpectedKeys ( const QByteArrayList &  keys)
protected

◆ setLoggingCategory()

void Quotient::BaseJob::setLoggingCategory ( QMessageLogger::CategoryFunction  lcf)
protected

Set the logging category for the given job instance.

Parameters
lcfThe logging category function to provide the category - the one you define with Q_LOGGING_CATEGORY (without parentheses, BaseJob will call it for you)

◆ setMaxRetries()

void Quotient::BaseJob::setMaxRetries ( int  newMaxRetries)

◆ setRequestData()

void Quotient::BaseJob::setRequestData ( RequestData &&  data)
protected

◆ setRequestHeader()

void Quotient::BaseJob::setRequestHeader ( const headers_t::key_type &  headerName,
const headers_t::mapped_type &  headerValue 
)
protected

◆ setRequestHeaders()

void Quotient::BaseJob::setRequestHeaders ( const headers_t headers)
protected

◆ setRequestQuery()

void Quotient::BaseJob::setRequestQuery ( const QUrlQuery &  query)
protected

◆ setStatus() [1/2]

void Quotient::BaseJob::setStatus ( int  code,
QString  message 
)
protected

◆ setStatus() [2/2]

void Quotient::BaseJob::setStatus ( Status  s)
protected

◆ status()

Status Quotient::BaseJob::status ( ) const

Current status of the job

◆ statusCaption()

QString Quotient::BaseJob::statusCaption ( ) const

Short human-friendly message on the job status

◆ statusChanged

void Quotient::BaseJob::statusChanged ( Quotient::BaseJob::Status  newStatus)
signal

The job has changed its status

◆ success

void Quotient::BaseJob::success ( Quotient::BaseJob )
signal

Emitted together with result() in case there's no error.

See also
result, failure

◆ takeFromJson()

template<typename T >
T Quotient::BaseJob::takeFromJson ( const QString &  key,
T &&  defaultValue = {} 
)
inline

Load the property from the JSON response and delete it from JSON

If there's no top-level JSON object in the response or if there's no node with the key keyName, defaultValue is returned.

Definition at line 205 of file basejob.h.

◆ takeValueFromJson()

QJsonValue Quotient::BaseJob::takeValueFromJson ( const QString &  key)
protected

Get direct access to the JSON response object in the job.

This allows to implement deserialisation with "move" semantics for parts of the response. Assuming that the response body is a valid JSON object, the function calls QJsonObject::take(key) on it and returns the result.

Returns
QJsonValue::Null, if the response content type is not advertised as application/json; QJsonValue::Undefined, if the response is a JSON object but doesn't have key; the value for key otherwise.
See also
takeFromJson

◆ timeout

void Quotient::BaseJob::timeout ( )
protectedslot

◆ timeToRetry()

std::chrono::milliseconds Quotient::BaseJob::timeToRetry ( ) const

◆ uploadProgress

void Quotient::BaseJob::uploadProgress ( qint64  bytesSent,
qint64  bytesTotal 
)
signal

Friends And Related Function Documentation

◆ ConnectionData

friend class ConnectionData
friend

Definition at line 463 of file basejob.h.

◆ JobHandle

template<class JobT >
friend class JobHandle
friend

Definition at line 465 of file basejob.h.

◆ operator<<

QDebug operator<< ( QDebug  dbg,
const BaseJob j 
)
friend

Definition at line 237 of file basejob.h.

Property Documentation

◆ maxRetries

int Quotient::BaseJob::maxRetries
readwrite

Definition at line 475 of file basejob.h.

◆ requestUrl

QUrl Quotient::BaseJob::requestUrl
read

Definition at line 475 of file basejob.h.

◆ statusCode

int Quotient::BaseJob::statusCode
read

Definition at line 475 of file basejob.h.


The documentation for this class was generated from the following file: