itom 1.3.0
FileDownloader Class Reference

List of all members.

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.
void abortDownload ()
 Aboarts a download.
int getDownloadProgress ()
 This functions returns the downloadprogress of a file.
Status getStatus (QString &errorMsg)
 Returns the status of a download.

Private Slots

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

Private Member Functions

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

Private Attributes

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

Member Function Documentation

int 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 FileDownloader::downloadedData ( ) const

This function returns the downloaded data.

Returns:
returns downloaded data as a QByteArray.
void FileDownloader::downloadProgress ( qint64  bytesReceived,
qint64  bytesTotal 
) [private, slot]

Setting method to set the meber variables.

Parameters:
bytesReceivedreceived bytes
bytesTotaltotal size of the downloading file bytes
See also:
getDownloadProgress
void FileDownloader::fileDownloaded ( QNetworkReply *  pReply) [private, slot]

This function is called when the download is finished.

It stores the downloaded data in a member variable and

Parameters:
pReply
int 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 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:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends