00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifndef _WX_DOWNLOAD_H_
00012 #define _WX_DOWNLOAD_H_
00013
00014 #include "wx/curl/thread.h"
00015
00016
00017
00018
00019
00020
00021 BEGIN_DECLARE_EVENT_TYPES()
00022 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CURL, wxCURL_SIZE_QUERY_EVENT, 66987)
00023 END_DECLARE_EVENT_TYPES()
00024
00027 class WXDLLIMPEXP_CURL wxCurlSizeEvent : public wxEvent
00028 {
00029 protected:
00030 wxString m_url;
00031 double m_size;
00032
00033 public:
00034 wxCurlSizeEvent(int id, const wxString &url, double size)
00035 : wxEvent(id, wxCURL_SIZE_QUERY_EVENT), m_url(url), m_size(size) {}
00036
00037 double GetSize() const
00038 { return m_size; }
00039 wxString GetURL() const
00040 { return m_url; }
00041
00042 wxEvent* Clone() const
00043 { return new wxCurlSizeEvent(*this); }
00044 };
00045
00046 typedef void (wxEvtHandler::*wxCurlSizeEventFunction)(wxCurlSizeEvent&);
00047
00048 #define wxCurlSizeEventHandler(func) \
00049 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCurlSizeEventFunction, &func)
00050
00051 #define EVT_CURL_SIZE_QUERY(id, fn) \
00052 wx__DECLARE_EVT1(wxCURL_SIZE_EVENT, id, wxCurlSizeEventHandler(fn))
00053
00054
00055
00056
00057
00058
00059
00063 class WXDLLIMPEXP_CURL wxCurlSizeQueryThread : public wxCurlBaseThread
00064 {
00065 friend class wxCurlSizeQueryOutput;
00066
00067 protected:
00068
00070 wxArrayLong m_urlSize;
00071
00073 wxArrayString m_urls;
00074
00075 public:
00076 wxCurlSizeQueryThread(wxEvtHandler *handler = NULL,
00077 int id = wxID_ANY)
00078 : wxCurlBaseThread(handler, id) { }
00079
00083 wxCurlSizeQueryThread(wxEvtHandler *handler,
00084 int id,
00085 const wxArrayString& urls)
00086 : wxCurlBaseThread(handler, id) { m_urls=urls; }
00087
00089 void SetURLs(const wxArrayString &urls)
00090 {
00091 wxCHECK_RET(!IsAlive(), wxT("Call this function before creating the thread!"));
00092 m_urls=urls;
00093 }
00094
00095 protected:
00096
00098 virtual void *Entry();
00099
00102 virtual void OnExit();
00103 };
00104
00105
00106 #endif // _WX_DOWNLOAD_H_
00107