MAUtil::BuffDownloader Class Reference

#include <MAUtil/BuffDownloader.h>

Inheritance diagram for MAUtil::BuffDownloader:

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

Detailed Description

Useful to simplify asynchronous downloading of data to a memory buffer.


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


Constructor & Destructor Documentation

MAUtil::BuffDownloader::BuffDownloader  ) 
 

The constructor.

virtual MAUtil::BuffDownloader::~BuffDownloader  )  [virtual]
 

The destructor.


Member Function Documentation

virtual void MAUtil::BuffDownloader::addBuffDownloadListener BuffDownloadListener bdl  )  [virtual]
 

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

Parameters:
bdl Pointer to the BuffDownloadListener instance.

virtual int MAUtil::BuffDownloader::beginDownloading const char *  url  )  [virtual]
 

Begins downloading a file.

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

void MAUtil::BuffDownloader::cancelDownloading  ) 
 

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.

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

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.

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::BuffDownloader::mConn [protected]
 

bool MAUtil::BuffDownloader::mDownloading [protected]
 

char* MAUtil::BuffDownloader::mData [protected]
 

int MAUtil::BuffDownloader::mDataOffset [protected]
 

int MAUtil::BuffDownloader::mContentLength [protected]
 

Vector<BuffDownloadListener*> MAUtil::BuffDownloader::mBuffDownloadListeners [protected]
 


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