|
MoSync 3.0.1
|
The AudioDownloader class. Use it to simplify asynchronous downloading of audio to audio resources. Note that for AudioDownloader to work, the server must return a content-length header in the HTTP response. More...
#include <MAUtil/Downloader.h>
Public Member Functions | |
| int | beginDownloading (const char *url, MAHandle placeholder=0, const char *mimeType=NULL, bool forceMime=false) |
| virtual int | beginDownloading (const char *url, MAHandle placeholder) |
| void | addDownloadListener (DownloadListener *dl) |
| void | removeDownloadListener (DownloadListener *dl) |
| 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 void | httpFinished (HttpConnection *http, int result) |
| virtual MAHandle | getHandle () |
| MAHandle | getDataPlaceholder () |
| void | fireNotifyProgress (int dataOffset, int contentLength) |
| void | fireFinishedDownloading (MAHandle data) |
| void | fireError (int code) |
| virtual void | closeConnection (int cleanup) |
| void | deleteReader () |
| void | connRecvFinished (Connection *conn, int result) |
Protected Attributes | |
| String | mMimeType |
| bool | mForceMimeType |
| HttpConnection * | mConn |
| bool | mIsDownloading |
| bool | mIsDataPlaceholderSystemAllocated |
| MAHandle | mDataPlaceholder |
| Vector< DownloadListener * > | mDownloadListeners |
| DownloaderReader * | mReader |
The AudioDownloader class. Use it to simplify asynchronous downloading of audio to audio resources. Note that for AudioDownloader to work, the server must return a content-length header in the HTTP response.
| int MAUtil::AudioDownloader::beginDownloading | ( | const char * | url, |
| MAHandle | placeholder = 0, |
||
| const char * | mimeType = NULL, |
||
| bool | forceMime = false |
||
| ) |
Same as Downloader::beginDownloading() with an additional optional parameter to specify mime type of the downloaded file. If neither the server or you provide a mime type, CONNERR_NOHEADER will be thrown. If both the server and you provide a mime type, by default the server's will be picked, but you can force use of your mime type.
| virtual int MAUtil::AudioDownloader::beginDownloading | ( | const char * | url, |
| MAHandle | placeholder | ||
| ) | [virtual] |
Function to begin downloading a file.
| 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. |
Reimplemented from MAUtil::Downloader.
| virtual void MAUtil::AudioDownloader::httpFinished | ( | HttpConnection * | http, |
| int | result | ||
| ) | [protected, virtual] |
Callback method in HttpConnectionListener.
Reimplemented from MAUtil::Downloader.
| void MAUtil::Downloader::addDownloadListener | ( | DownloadListener * | dl | ) | [inherited] |
Function to register a DownloadListener, to which all events for this Downloader is distributed.
| dl | Pointer to the DownloadListener instance. |
| void MAUtil::Downloader::removeDownloadListener | ( | DownloadListener * | dl | ) | [inherited] |
Remove a DownloadListener.
| dl | Pointer to the DownloadListener instance. |
| virtual void MAUtil::Downloader::cancelDownloading | ( | ) | [virtual, inherited] |
Function to cancel the current download. Do cleanup and send downloadCancelled to listeners.
| bool MAUtil::Downloader::isDownloading | ( | ) | const [inline, inherited] |
Function to retrieve if the Downloader is currently downloading something.
References MAUtil::Downloader::mIsDownloading.
| virtual MAHandle MAUtil::Downloader::getHandle | ( | ) | [protected, virtual, inherited] |
Should return a handle to the final product of the download. May return zero if a handle could not be obtained. Do NOT call explicitly. Use the handle provided in finishedDownloading.
Reimplemented in MAUtil::ImageDownloader.
| MAHandle MAUtil::Downloader::getDataPlaceholder | ( | ) | [protected, inherited] |
Helper method to get the data handle. Used by friend classes.
| void MAUtil::Downloader::fireNotifyProgress | ( | int | dataOffset, |
| int | contentLength | ||
| ) | [protected, inherited] |
Send notifyProgress to listeners.
| void MAUtil::Downloader::fireFinishedDownloading | ( | MAHandle | data | ) | [protected, inherited] |
Close connection and send finishedDownloading to listeners.
| void MAUtil::Downloader::fireError | ( | int | code | ) | [protected, inherited] |
Do cleanup and send error to listeners.
| virtual void MAUtil::Downloader::closeConnection | ( | int | cleanup | ) | [protected, virtual, inherited] |
Close the connection used by the downloader. This is part of the normal finishing of the download, and is also done on errors and on cancelling the download.
| cleanup | if 1 free downloaded resources, if 0 do not do free downloaded resources. Cleanup is done on errors and on cancelling a download. |
Reimplemented in MAUtil::ImageDownloader.
| void MAUtil::Downloader::deleteReader | ( | ) | [protected, inherited] |
Delete the reader object (this is the object that performs the download).
| void MAUtil::Downloader::connRecvFinished | ( | Connection * | conn, |
| int | result | ||
| ) | [protected, virtual, inherited] |
Callback method.
Reimplemented from MAUtil::ConnectionListener.
| 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. |
| 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. |
String MAUtil::AudioDownloader::mMimeType [protected] |
bool MAUtil::AudioDownloader::mForceMimeType [protected] |
HttpConnection* MAUtil::Downloader::mConn [protected, inherited] |
bool MAUtil::Downloader::mIsDownloading [protected, inherited] |
Referenced by MAUtil::Downloader::isDownloading().
bool MAUtil::Downloader::mIsDataPlaceholderSystemAllocated [protected, inherited] |
MAHandle MAUtil::Downloader::mDataPlaceholder [protected, inherited] |
Vector<DownloadListener*> MAUtil::Downloader::mDownloadListeners [protected, inherited] |
DownloaderReader* MAUtil::Downloader::mReader [protected, inherited] |
Object that performs the actual download. A downloader is configured with different readers depending on the how the server sends the data to the client.