itom  3.0.0
ito::FileDownloader Class Reference
Inheritance diagram for ito::FileDownloader:

Public Types

enum  Status { sRunning, sAborted, sFinished, sError }
 

Public Member Functions

 FileDownloader (QUrl imageUrl, int nrOfAllowedRedirects=0, QObject *parent=0)
 
QByteArray downloadedData () const
 This function returns the downloaded data. More...
 
void abortDownload ()
 Aboarts a download.
 
int getDownloadProgress ()
 This functions returns the downloadprogress of a file. More...
 
Status getStatus (QString &errorMsg)
 Returns the status of a download. More...
 

Private Slots

void fileDownloaded (QNetworkReply *pReply)
 This function is called when the download is finished. More...
 
void downloadProgress (qint64 bytesReceived, qint64 bytesTotal)
 Setting method to set the meber variables. More...
 

Private Member Functions

int checkRedirect (QString &errorMsg)
 This function checks if the given error message is caused by a redirect. More...
 

Private Attributes

QNetworkAccessManager m_WebCtrl
 
QByteArray m_DownloadedData
 
QNetworkReply * m_pCurrentNetworkReply
 
qint64 m_bytesReceived
 
qint64 m_bytesTotal
 
int m_nrOfAllowedRedirects
 

Member Function Documentation

int ito::FileDownloader::checkRedirect ( QString &  errorMsg)
private

This function checks if the given error message is caused by a redirect.

Parameters
errorMsg
Returns
returns status of redirection. 0 = ok (no redirection, 1 = redirection, -1 = number of redirections exceeded
QByteArray ito::FileDownloader::downloadedData ( ) const

This function returns the downloaded data.

Returns
returns downloaded data as a QByteArray.
void ito::FileDownloader::downloadProgress ( qint64  bytesReceived,
qint64  bytesTotal 
)
privateslot

Setting method to set the meber variables.

Parameters
bytesReceivedreceived bytes
bytesTotaltotal size of the downloading file bytes
See also
getDownloadProgress
void ito::FileDownloader::fileDownloaded ( QNetworkReply *  pReply)
privateslot

This function is called when the download is finished.

It stores the downloaded data in a member variable and

Parameters
pReply
int ito::FileDownloader::getDownloadProgress ( )

This functions returns the downloadprogress of a file.

The progress is returned in percent as an integer between 0 and 100.

Returns
downloadprogress in percent.
FileDownloader::Status ito::FileDownloader::getStatus ( QString &  errorMsg)

Returns the status of a download.

The status is returned as a Filedownloader::Status. This enumeration has different states: sRunning, sAborted, sFinished, sError This function also handles redirects!

Parameters
errorMsgThe function stores the message in Qstring thst it can be displayed
Returns
statusmessage of the downlaod

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