HttpDownloader Class Reference

Class for handling downloads with http. More...

#include <HttpDownloader.h>

List of all members.

Signals

void downloadFinished (int errorID)
 Emitted when download is finished.
void progressMaxValue (int value)
 Emitted from void DownloadProgress(int ready, int total) to update the download progressbar maximum value.
void progressCurrentValue (int value)
 Emitted from void DownloadProgress(int ready, int total) to update the download progressbar value.
void setFileLabelText (const QString &text)
 emitted from StartDownload(const QByteArray &encodedHost, const QByteArray &encodedPath, QIODevice *target, bool showProgressDialog) to show the name of the file being downloaded in the dialog.
void setTitleLabelText (const QString &text)
 Emitted from void HandleUiLanguageChange() to update the title of the Dialog when language is changed.

Public Member Functions

 HttpDownloader (QWidget *parent=0)
void StartDownload (const QByteArray &encodedHost, const QByteArray &encodedPath, QIODevice *target, bool showProgressDialog)
 Start downloading a file.
int getErrorID ()
 Get ID of last error.
QString getErrorString ()
 Get description of last error.
void HandleUiLanguageChange ()
 Reload the texts in elemnets.
QString getLastAttemptedDownloadAddress ()
 Get the adress of last last attmepted download.

Protected Slots

void DownloadProgress (int ready, int total)
 Keeps track of the download progress.
void DownloadReady (bool error)
 Notified when download is finished and passes the notification to parent.

Protected Member Functions

void changeEvent (QEvent *e)

Private Attributes

Ui::HttpDownloader * m_ui
 Pointer to ui of the download progress dialog.
QHttp * httpEngine
 Pointer to QHttp object that handles the download.
QString iFullDownloadAddress
 String containing the internet address and path/filename of the file being downloaded in case someone asks to know it.


Detailed Description

Class for handling downloads with http.

Implements http downloader with option to show dialog that will show the progress of the download and name of file being downloaded.


Member Function Documentation

void HttpDownloader::downloadFinished ( int  errorID  )  [signal]

Emitted when download is finished.

Parameters:
errorID ID of the error that occured during download. QHttp::NoError if download was succesfull.

void HttpDownloader::DownloadProgress ( int  ready,
int  total 
) [protected, slot]

Keeps track of the download progress.

Parameters:
ready Bytes downloaded so far.
total Total size of the download.
Slot connected to QHttp *httpEngine's dataReadProgress signal. Updates the progressbar in the download progress dialog.

void HttpDownloader::DownloadReady ( bool  error  )  [protected, slot]

Notified when download is finished and passes the notification to parent.

Parameters:
error False if download was succesfull
Slot connected to QHttp *httpEngine's done signal. Emits downloadFinished signal with errorID and hides the dialog.
If there was no error the errorID will be QHttp::NoError.

int HttpDownloader::getErrorID (  ) 

Get ID of last error.

If download ended to an error, this function can be used to query for more specific information about what went wrong.

Returns:
One of the error identifiers defined in enum QHttp::Error

QString HttpDownloader::getErrorString (  ) 

Get description of last error.

If download ended to an error, this function can be used to query for more specific information about what went wrong.

Returns:
Description of last error

QString HttpDownloader::getLastAttemptedDownloadAddress (  ) 

Get the adress of last last attmepted download.

Returns:
Adress of last attmepted download including the server adress, path and filename on the server.

void HttpDownloader::HandleUiLanguageChange (  ) 

Reload the texts in elemnets.

Called by Xiaoning's Diary when reload of UI language is required. This may be during start of the program or when user changes the UI language.

void HttpDownloader::progressCurrentValue ( int  value  )  [signal]

Emitted from void DownloadProgress(int ready, int total) to update the download progressbar value.

Parameters:
value Current progress of the download.

void HttpDownloader::progressMaxValue ( int  value  )  [signal]

Emitted from void DownloadProgress(int ready, int total) to update the download progressbar maximum value.

Parameters:
value Size of the file being downloaded.

void HttpDownloader::setFileLabelText ( const QString &  text  )  [signal]

emitted from StartDownload(const QByteArray &encodedHost, const QByteArray &encodedPath, QIODevice *target, bool showProgressDialog) to show the name of the file being downloaded in the dialog.

Parameters:
text Name of the file being downloaded.

void HttpDownloader::setTitleLabelText ( const QString &  text  )  [signal]

Emitted from void HandleUiLanguageChange() to update the title of the Dialog when language is changed.

Parameters:
text New title for Dialog.

void HttpDownloader::StartDownload ( const QByteArray &  encodedHost,
const QByteArray &  encodedPath,
QIODevice *  target,
bool  showProgressDialog 
)

Start downloading a file.

Parameters:
encodedHost Hostname of the server (xiaoningsdiary.sourceforge.net for example).
encodedPath Path and name of the file in the server (/current_version.txt for example).
target Pointer to QIODevice object that can store the downloaded data.
showProgressDialog 
  • true = Show dialog with name of the file being downloaded and download progress.
  • false = Don't show the dialog. Work silently on the background


Member Data Documentation

QHttp* HttpDownloader::httpEngine [private]

Pointer to QHttp object that handles the download.

QHttp *httpEngine

String containing the internet address and path/filename of the file being downloaded in case someone asks to know it.

QString iFullDownloadAddress

Ui::HttpDownloader* HttpDownloader::m_ui [private]

Pointer to ui of the download progress dialog.

Ui::HttpDownloader *m_ui


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

Generated on Thu Mar 3 17:42:04 2011 for Xiaoning's Diary by  doxygen 1.5.9