MoSync 3.3
MAUtil::BuffDownloader Class Reference

Simplifies asynchronous downloading of data to a memory buffer. More...

#include <MAUtil/BuffDownloader.h>

Inheritance diagram for MAUtil::BuffDownloader:
MAUtil::HttpConnectionListener MAUtil::ConnectionListener

List of all members.

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

HttpConnectionmConn
bool mDownloading
char * mData
int mDataOffset
int mContentLength
Vector< BuffDownloadListener * > mBuffDownloadListeners

Detailed Description

Simplifies asynchronous downloading of data to a memory buffer.


Constructor & Destructor Documentation

The destructor.


Member Function Documentation

Registers a BuffDownloadListener, to which all events for this BuffDownloader is distributed.

Parameters:
bdlPointer to the BuffDownloadListener instance.
virtual int MAUtil::BuffDownloader::beginDownloading ( const char *  url) [virtual]

Begins downloading a file.

Parameters:
urlC string containing a null terminated url to the file.
Returns:
>0 on success, or a CONNERR code < 0 on failure.

Cancels the current download.

bool MAUtil::BuffDownloader::isDownloading ( ) const [inline]

Indicates whether the BuffDownloader is currently downloading something.

Returns:
True if the function is currently downloading, false otherwise.

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.

Parameters:
connThe Connection that ran the operation.
resultThe 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.

Parameters:
httpThe HttpConnection that ran the operation.
resultThe 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.

Parameters:
connThe 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.

Parameters:
connThe 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.

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

Reimplemented in Wormhole::HighLevelHttpConnection.


Member Data Documentation

Referenced by isDownloading().

char* MAUtil::BuffDownloader::mData [protected]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines