Base class for wxCurl threads. More...
#include <thread.h>
Public Member Functions | |
wxCurlBaseThread (wxEvtHandler *handler=NULL, int id=wxID_ANY) | |
virtual bool | IsOk () const |
Returns true if this thread is ready to be started using e.g. StartTransfer. | |
virtual wxCurlThreadError | StartTransfer ()=0 |
Starts the transfer. | |
virtual void | Abort () |
Aborts this thread. | |
virtual wxCurlThreadError | Wait () |
Waits for the completion of the transfer. | |
virtual wxCurlThreadError | Pause () |
Pauses the transfer. | |
virtual wxCurlThreadError | Resume () |
Resumes the transfer. | |
void | SetEvtHandler (wxEvtHandler *handler, int id=wxID_ANY) |
Sets the event handler to which wxCurlBeginPerformEvent, wxCurlEndPerformEvent and wxCurlDownloadEvent/wxCurlUploadEvents will be posted. | |
wxCurlThreadError | SetURL (const wxString &url) |
Sets the URL to download/upload from/to. | |
wxEvtHandler * | GetEvtHandler () const |
int | GetId () const |
wxCurlBase * | GetCurlSession () const |
Returns the wxCurlBase-derived object which is being used for the transfer. | |
wxCurlProtocol | GetProtocol () const |
Returns the protocol used for the transfer. | |
wxString | GetURL () const |
Returns the URL of current transfer. | |
Static Public Member Functions | |
static wxCurlProtocol | GetProtocolFromURL (const wxString &url) |
Returns the protocol which should be used to download the resource associated with the given URL. | |
static wxCurlBase * | CreateHandlerFor (wxCurlProtocol prot) |
Returns a pointer to a wxCurlBase-derived class suitable for handling transfers on the given protocol. | |
Protected Member Functions | |
virtual bool | TestDestroy () |
virtual void | OnExit () |
virtual wxCurlThreadError | Create (unsigned int stackSize) |
virtual wxCurlThreadError | Run () |
virtual wxCurlThreadError | Delete () |
Protected Attributes | |
wxString | m_url |
The URL identifying the resource to download/upload. | |
wxCurlBase * | m_pCurl |
The libcurl handle being used for the transfer. | |
wxCurlProtocol | m_protocol |
The protocol being used for the transfer. | |
wxEvtHandler * | m_pHandler |
The event handler which gets m_pCurl's events. | |
int | m_nId |
bool | m_bAbort |
This flag is set to true when the thread has been cancelled using Delete(). | |
wxMutex | m_bAbortMutex |
Base class for wxCurl threads.
static wxCurlBase* wxCurlBaseThread::CreateHandlerFor | ( | wxCurlProtocol | prot | ) | [static] |
Returns a pointer to a wxCurlBase-derived class suitable for handling transfers on the given protocol.
You'll need to wx_static_cast the return value to the right class in order to be able to set/get further options (e.g. url/username/password/proxy/etc etc).
wxCurlBase* wxCurlBaseThread::GetCurlSession | ( | ) | const [inline] |
Returns the wxCurlBase-derived object which is being used for the transfer.
Note that the returned value will be NULL if you've not called SetURL yet. You can cast it to the wxCurlBase-derived class associated with the return value of GetProtocol() (e.g. if GetProtocol() returns wxCP_HTTP, you can cast GetCurlSession() to wxCurlHTTP).
wxCurlProtocol wxCurlBaseThread::GetProtocol | ( | ) | const [inline] |
Returns the protocol used for the transfer.
This function will return something different from wxCP_INVALID only after a call to SetURL with a valid URL.
static wxCurlProtocol wxCurlBaseThread::GetProtocolFromURL | ( | const wxString & | url | ) | [static] |
Returns the protocol which should be used to download the resource associated with the given URL.
void wxCurlBaseThread::SetEvtHandler | ( | wxEvtHandler * | handler, | |
int | id = wxID_ANY | |||
) | [inline] |
Sets the event handler to which wxCurlBeginPerformEvent, wxCurlEndPerformEvent and wxCurlDownloadEvent/wxCurlUploadEvents will be posted.
virtual wxCurlThreadError wxCurlBaseThread::StartTransfer | ( | ) | [pure virtual] |
Starts the transfer.
This is equivalent to call wxCurlDownloadThread::Download or wxCurlUploadThread::Upload.
Implemented in wxCurlDownloadThread, and wxCurlUploadThread.
bool wxCurlBaseThread::m_bAbort [protected] |
This flag is set to true when the thread has been cancelled using Delete().
Since it's continuosly read by the running thread and maybe written from other threads, it needs a mutex.