1 // 2 // This file is part of the aMule Project. 3 // 4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 5 // Copyright (c) 2002-2011 Timo Kujala ( tiku@users.sourceforge.net ) 6 // Copyright (c) 2002-2011 Patrizio Bassi ( hetfield@amule.org ) 7 // 8 // Any parts of this program derived from the xMule, lMule or eMule project, 9 // or contributed by third-party developers are copyrighted by their 10 // respective authors. 11 // 12 // This program is free software; you can redistribute it and/or modify 13 // it under the terms of the GNU General Public License as published by 14 // the Free Software Foundation; either version 2 of the License, or 15 // (at your option) any later version. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of the GNU General Public License 23 // along with this program; if not, write to the Free Software 24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 25 // 26 27 #ifndef HTTPDOWNLOAD_H 28 #define HTTPDOWNLOAD_H 29 30 #include "GuiEvents.h" // Needed for HTTP_Download_File 31 #include "MuleThread.h" // Needed for CMuleThread 32 #include <wx/datetime.h> // Needed for wxDateTime 33 #include <set> 34 35 class wxEvtHandler; 36 class wxHTTP; 37 class wxInputStream; 38 39 enum HTTPDownloadResult { 40 HTTP_Success = 0, 41 HTTP_Error, 42 HTTP_Skipped 43 }; 44 45 class CHTTPDownloadThread : public CMuleThread 46 { 47 public: 48 /** Note: wxChar* is used to circumvent the thread-unsafe wxString reference counting. */ 49 CHTTPDownloadThread(const wxString& url, const wxString& filename, const wxString& oldfilename, HTTP_Download_File file_id, 50 bool showDialog, bool checkDownloadNewer); 51 52 static void StopAll(); 53 private: 54 ExitCode Entry(); 55 virtual void OnExit(); CHTTPDownloadDialog(CHTTPDownloadThread * thread)56 57 wxString m_url; 58 wxString m_tempfile; 59 wxDateTime m_lastmodified; //! Date on which the file being updated was last modified. 60 int m_result; 61 int m_response; //! HTTP response code (e.g. 200) 62 int m_error; //! Additional error code (@see wxProtocol class) 63 HTTP_Download_File m_file_id; 64 wxEvtHandler* m_companion; 65 typedef std::set<CHTTPDownloadThread *> ThreadSet; 66 static ThreadSet s_allThreads; 67 static wxMutex s_allThreadsMutex; 68 69 wxInputStream* GetInputStream(wxHTTP * & url_handler, const wxString& location, bool proxy); 70 static wxString FormatDateHTTP(const wxDateTime& date); 71 }; ~CHTTPDownloadDialog()72 73 #endif // HTTPDOWNLOAD_H 74 // File_checked_for_headers 75