KGAPI2::Drive::FileAbstractResumableJob

Search for usage in LXR

KGAPI2::Drive::FileAbstractResumableJob Class Referenceabstract

#include <fileabstractresumablejob.h>

Signals

void readyWrite (KGAPI2::Drive::FileAbstractResumableJob *job)
 

Public Member Functions

 FileAbstractResumableJob (const AccountPtr &account, QObject *parent=nullptr)
 
 FileAbstractResumableJob (const FilePtr &metadata, const AccountPtr &account, QObject *parent=nullptr)
 
 FileAbstractResumableJob (QIODevice *device, const AccountPtr &account, QObject *parent=nullptr)
 
 FileAbstractResumableJob (QIODevice *device, const FilePtr &metadata, const AccountPtr &account, QObject *parent=nullptr)
 
 ~FileAbstractResumableJob () override
 
FilePtr metadata () const
 
void setUploadSize (int size)
 
void write (const QByteArray &data)
 

Protected Member Functions

virtual QUrl createUrl ()=0
 
void dispatchRequest (QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override
 
void emitReadyWrite ()
 
void handleReply (const QNetworkReply *reply, const QByteArray &rawData) override
 
void start () override
 

Detailed Description

Abstract superclass for KGAPI2::Drive::File create or modify jobs that use chunked uploading of the file's content.

The Job starts an upload session and data is written in chunks. When the Job is out of chunks to write it will emit the readyWrite() signal and expect new data to be written via write().

Writing 0 bytes will indicate that the File has been completely transferred and the Job will close the upload session.

See also
Perform a resumable upload
readyWrite, write
Author
David Barchiesi david.nosp@m.@bar.nosp@m.chie..nosp@m.si
Since
20.12

Definition at line 41 of file fileabstractresumablejob.h.

Constructor & Destructor Documentation

◆ FileAbstractResumableJob() [1/4]

FileAbstractResumableJob::FileAbstractResumableJob ( const AccountPtr & account,
QObject * parent = nullptr )
explicit

Constructs a job that will upload an Untitled file in the users root folder.

Parameters
accountAccount to authenticate the request
parent

Definition at line 190 of file fileabstractresumablejob.cpp.

◆ FileAbstractResumableJob() [2/4]

FileAbstractResumableJob::FileAbstractResumableJob ( const FilePtr & metadata,
const AccountPtr & account,
QObject * parent = nullptr )
explicit

Constructs a job that will upload a file with its metadata.

Parameters
metadataFile metadata to upload
accountAccount to authenticate the request
parent

Definition at line 196 of file fileabstractresumablejob.cpp.

◆ FileAbstractResumableJob() [3/4]

FileAbstractResumableJob::FileAbstractResumableJob ( QIODevice * device,
const AccountPtr & account,
QObject * parent = nullptr )
explicit

Constructs a job that will upload an Untitled file in the users root folder with data contained in device.

Parameters
deviceOpen device to read from
accountAccount to authenticate the request
parent

Definition at line 203 of file fileabstractresumablejob.cpp.

◆ FileAbstractResumableJob() [4/4]

FileAbstractResumableJob::FileAbstractResumableJob ( QIODevice * device,
const FilePtr & metadata,
const AccountPtr & account,
QObject * parent = nullptr )
explicit

Constructs a job that will upload a file with its metadata with data contained in device.

Parameters
deviceOpen device to read from
metadataFile metadata to upload
accountAccount to authenticate the request
parent

Definition at line 210 of file fileabstractresumablejob.cpp.

◆ ~FileAbstractResumableJob()

FileAbstractResumableJob::~FileAbstractResumableJob ( )
overridedefault

Destructor.

Member Function Documentation

◆ createUrl()

virtual QUrl KGAPI2::Drive::FileAbstractResumableJob::createUrl ( )
protectedpure virtual

Generates url that will be used during upload session start.

◆ dispatchRequest()

void FileAbstractResumableJob::dispatchRequest ( QNetworkAccessManager * accessManager,
const QNetworkRequest & request,
const QByteArray & data,
const QString & contentType )
overrideprotectedvirtual

KGAPI2::Job::dispatchRequest implementation.

Parameters
accessManager
request
data
contentType

Implements KGAPI2::Job.

Definition at line 281 of file fileabstractresumablejob.cpp.

◆ emitReadyWrite()

void FileAbstractResumableJob::emitReadyWrite ( )
protected

Emit readyWrite() signal.

Definition at line 378 of file fileabstractresumablejob.cpp.

◆ handleReply()

void FileAbstractResumableJob::handleReply ( const QNetworkReply * reply,
const QByteArray & rawData )
overrideprotectedvirtual

KGAPI2::Job::handleReply implementation.

Parameters
reply
rawData

Implements KGAPI2::Job.

Definition at line 302 of file fileabstractresumablejob.cpp.

◆ metadata()

FilePtr FileAbstractResumableJob::metadata ( ) const

Returns metadata supplied at Job creation or retrieved on Job completion.

Definition at line 220 of file fileabstractresumablejob.cpp.

◆ readyWrite

void KGAPI2::Drive::FileAbstractResumableJob::readyWrite ( KGAPI2::Drive::FileAbstractResumableJob * job)
signal

Emitted when job requires more data to proceed.

Bytes should be written via write(). When connecting to this signal always use a synchronous connection type like Qt::DirectConnection.

Subclasses should never ever emit this signal directly.

Parameters
jobThe job that requires data
See also
readyWrite()
Note
Connecting via Qt::QueuedConnection or any other asynchronous connection type will potentially crash the job or end it prematurely. Use Qt::DirectConnection
See also
write

◆ setUploadSize()

void FileAbstractResumableJob::setUploadSize ( int size)

Sets the total upload size and is required for progress reporting via the Job::progress() signal.

Definition at line 225 of file fileabstractresumablejob.cpp.

◆ start()

void FileAbstractResumableJob::start ( )
overrideprotectedvirtual

KGAPI2::Job::start implementation.

Implements KGAPI2::Job.

Definition at line 268 of file fileabstractresumablejob.cpp.

◆ write()

void FileAbstractResumableJob::write ( const QByteArray & data)

This function writes all the bytes in data to the upload session.

The write operation splits written data in chunks that will be subsequently uploaded in the session.

Writing an empty data will signal the Job that it can complete as no more data will be written.

When more data is required the readyWrite() signal is emitted.

See also
readyWrite
Parameters
datathe data to write

Definition at line 235 of file fileabstractresumablejob.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.