|
MoSync 3.3
|
Simplifies asynchronous downloading of data to a memory buffer. More...
#include <MAUtil/BuffDownloader.h>
Public Member Functions | |
| BuffDownloader () | |
| virtual | ~BuffDownloader () |
| virtual void | addBuffDownloadListener (BuffDownloadListener *bdl) |
| virtual int | beginDownloading (const char *url) |
| 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 char * | getData () |
| void | fireFinishedDownloading (char *data) |
| void | fireError (int code) |
| void | connRecvFinished (Connection *conn, int result) |
| virtual void | httpFinished (HttpConnection *http, int result) |
Protected Attributes | |
| HttpConnection * | mConn |
| bool | mDownloading |
| char * | mData |
| int | mDataOffset |
| int | mContentLength |
| Vector< BuffDownloadListener * > | mBuffDownloadListeners |
Simplifies asynchronous downloading of data to a memory buffer.
The constructor.
| virtual MAUtil::BuffDownloader::~BuffDownloader | ( | ) | [virtual] |
The destructor.
| virtual void MAUtil::BuffDownloader::addBuffDownloadListener | ( | BuffDownloadListener * | bdl | ) | [virtual] |
Registers a BuffDownloadListener, to which all events for this BuffDownloader is distributed.
| bdl | Pointer to the BuffDownloadListener instance. |
| virtual int MAUtil::BuffDownloader::beginDownloading | ( | const char * | url | ) | [virtual] |
Begins downloading a file.
| url | C string containing a null terminated url to the file. |
Cancels the current download.
| bool MAUtil::BuffDownloader::isDownloading | ( | ) | const [inline] |
Indicates whether the BuffDownloader is currently downloading something.
References mDownloading.
| virtual char* MAUtil::BuffDownloader::getData | ( | ) | [protected, virtual] |
| void MAUtil::BuffDownloader::fireFinishedDownloading | ( | char * | data | ) | [protected] |
| void MAUtil::BuffDownloader::fireError | ( | int | code | ) | [protected] |
| void MAUtil::BuffDownloader::connRecvFinished | ( | Connection * | conn, |
| int | result | ||
| ) | [protected, virtual] |
Called when a recv operation finishes.
| 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::BuffDownloader::httpFinished | ( | HttpConnection * | http, |
| int | result | ||
| ) | [protected, virtual] |
Called when a finish operation is done.
| 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.
| virtual void MAUtil::ConnectionListener::connectFinished | ( | Connection * | conn, |
| int | result | ||
| ) | [virtual, inherited] |
Called when a connect operation finishes.
| conn | The Connection that ran the operation. |
| result | > 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.
| conn | The Connection that ran the operation. |
| result | > 0 on success, or a CONNERR code < 0 on failure. |
Reimplemented in Wormhole::HighLevelHttpConnection.
| virtual void MAUtil::ConnectionListener::connReadFinished | ( | Connection * | conn, |
| int | result | ||
| ) | [virtual, inherited] |
Called when a read operation finishes.
| conn | The Connection that ran the operation. |
| result | > 0 on success, or a CONNERR code < 0 on failure. |
Reimplemented in Wormhole::HighLevelHttpConnection.
HttpConnection* MAUtil::BuffDownloader::mConn [protected] |
bool MAUtil::BuffDownloader::mDownloading [protected] |
Referenced by isDownloading().
char* MAUtil::BuffDownloader::mData [protected] |
int MAUtil::BuffDownloader::mDataOffset [protected] |
int MAUtil::BuffDownloader::mContentLength [protected] |