MAUtil::Downloader Class Reference

#include <MAUtil/Downloader.h>

Inheritance diagram for MAUtil::Downloader:

MAUtil::HttpConnectionListener MAUtil::ConnectionListener MAUtil::AudioDownloader MAUtil::ImageDownloader List of all members.

Detailed Description

The Downloader class. Use it to simplify asynchronous downloading of files to binary resources.


Public Member Functions

 Downloader ()
virtual ~Downloader ()
void addDownloadListener (DownloadListener *dl)
void removeDownloadListener (DownloadListener *dl)
virtual int beginDownloading (const char *url, MAHandle placeholder=0)
virtual void cancelDownloading ()
bool isDownloading () const
virtual void connectFinished (Connection *conn, int result) __attribute__((noreturn))
virtual void connWriteFinished (Connection *conn, int result) __attribute__((noreturn))
virtual void connReadFinished (Connection *conn, int result) __attribute__((noreturn))

Protected Member Functions

virtual MAHandle getHandle ()
void fireFinishedDownloading (MAHandle data)
void fireError (int code)
void connRecvFinished (Connection *conn, int result)
virtual void httpFinished (HttpConnection *http, int result)

Protected Attributes

HttpConnectionmConn
bool mIsDownloading
bool mUserData
MAHandle mData
int mDataOffset
int mContentLength
Vector< DownloadListener * > mDownloadListeners


Constructor & Destructor Documentation

MAUtil::Downloader::Downloader  ) 
 

The constructor.

virtual MAUtil::Downloader::~Downloader  )  [virtual]
 

The destructor.


Member Function Documentation

void MAUtil::Downloader::addDownloadListener DownloadListener dl  ) 
 

Function to register a DownloadListener, to which all events for this Downloader is distributed.

Parameters:
dl Pointer to the DownloadListener instance.

void MAUtil::Downloader::removeDownloadListener DownloadListener dl  ) 
 

virtual int MAUtil::Downloader::beginDownloading const char *  url,
MAHandle  placeholder = 0
[virtual]
 

Function to begin downloading a file.

Parameters:
url C string containing a null terminated url to the file.
placeholder Optional argument to specify a placeholder to use for the binary resource of the downloaded data.
Returns:
>0 on success, or a CONNERR code < 0 on failure.

Reimplemented in MAUtil::ImageDownloader, and MAUtil::AudioDownloader.

virtual void MAUtil::Downloader::cancelDownloading  )  [virtual]
 

Function to cancel the current download.

Reimplemented in MAUtil::ImageDownloader.

bool MAUtil::Downloader::isDownloading  )  const [inline]
 

Function to retrieve if the Downloader is currently downloading something.

Returns:
a boolean value, if true the function is currently downloading otherwise it isn't.

virtual MAHandle MAUtil::Downloader::getHandle  )  [protected, virtual]
 

Reimplemented in MAUtil::ImageDownloader.

void MAUtil::Downloader::fireFinishedDownloading MAHandle  data  )  [protected]
 

void MAUtil::Downloader::fireError int  code  )  [protected]
 

void MAUtil::Downloader::connRecvFinished Connection conn,
int  result
[protected, virtual]
 

Called when a recv operation finishes.

Parameters:
conn The Connection that ran the operation.
result The number of bytes read on success, or a CONNERR code < 0 on failure.

Reimplemented from MAUtil::ConnectionListener.

virtual void MAUtil::Downloader::httpFinished HttpConnection http,
int  result
[protected, virtual]
 

Called when a finish operation is done.

Parameters:
http The HttpConnection that ran the operation.
result The HTTP response code (eg 200 or 404) on success, or a CONNERR code < 0 on failure.

Implements MAUtil::HttpConnectionListener.

Reimplemented in MAUtil::AudioDownloader.

virtual void MAUtil::ConnectionListener::connectFinished Connection conn,
int  result
[virtual, inherited]
 

Called when a connect operation finishes.

Parameters:
conn The Connection that ran the operation.
result The result of the operation. > 0 on success, or a CONNERR code < 0 on failure.

virtual void MAUtil::ConnectionListener::connWriteFinished Connection conn,
int  result
[virtual, inherited]
 

Called when a write operation finishes.

virtual void MAUtil::ConnectionListener::connReadFinished Connection conn,
int  result
[virtual, inherited]
 

Called when a read operation finishes.


Member Data Documentation

HttpConnection* MAUtil::Downloader::mConn [protected]
 

bool MAUtil::Downloader::mIsDownloading [protected]
 

bool MAUtil::Downloader::mUserData [protected]
 

MAHandle MAUtil::Downloader::mData [protected]
 

int MAUtil::Downloader::mDataOffset [protected]
 

int MAUtil::Downloader::mContentLength [protected]
 

Vector<DownloadListener*> MAUtil::Downloader::mDownloadListeners [protected]
 


Generated on Sat Feb 13 00:15:39 2010 for MoSync 2 beta 1 by  doxygen 1.4.6-NO