1 2 #ifndef _PROANTS_H 3 #define _PROANTS_H 4 5 #include <string> 6 #include "common.h" 7 #include <pthread.h> 8 9 class CMgSingleTask; 10 11 class CMgFileManager; 12 13 class CProAnts 14 { 15 16 public: 17 CProAnts( 18 CMgSingleTask *parent, 19 CMgFileManager *fm, 20 int aid, 21 llong filesize, 22 int retry = 99, 23 int retrywait = 30 24 ); 25 26 virtual ~CProAnts(); 27 bool Go(); 28 //socks proxy set 29 void SetProxy( std::string server, int port, std::string user, std::string pass, _SOCKVER ver = V5 ); 30 //http proxy set 31 void SetHttpProxy( std::string server, int port ); 32 //ftp proxy set 33 void SetFtpProxy( std::string server, int port ); 34 35 protected: 36 //get a new task piece from task manager 37 bool GetTask( 38 std::string& fullurl, 39 bool& urlneedcheck, 40 llong& from, 41 std::string& refer 42 ); //get task from fm; 43 44 45 protected: 46 static void* SwapThread( void* p ); 47 void WorkThread(); 48 void ThreadQuit(); 49 void OutMsg( std::string str, _MSGTYPE type ); 50 bool Retry(); 51 void ReportUrl( int prior, std::string url ); 52 void ReportRedirect( std::string origin, std::string redirect ); 53 54 private: 55 CMgSingleTask *m_pParent; 56 CMgFileManager *m_pFM; 57 pthread_t m_pid; 58 pthread_mutex_t m_QuitMutex; 59 std::string m_sServer; 60 int m_nPort; 61 std::string m_sUrl; 62 _PROTYPE m_Protocol; 63 std::string m_sRefer; 64 std::string m_sFile; 65 int m_nRetry; 66 int m_nRetryWait; 67 int m_nAntId; 68 llong m_nFrom; 69 llong m_nFileSize; //the total file size 70 llong m_nTotalByte; //this thread download bytes 71 72 //SOCKS proxy 73 bool m_bUseProxy; 74 std::string m_Proxy; 75 int m_ProxyPort; 76 std::string m_ProxyUser; 77 std::string m_ProxyPass; 78 _SOCKVER m_ProxyVersion; 79 //HTTP proxy 80 bool m_bUseHttpProxy; 81 std::string m_HttpProxy; 82 int m_HttpProxyPort; 83 //FTP proxy 84 bool m_bUseFtpProxy; 85 std::string m_FtpProxy; 86 int m_FtpProxyPort; 87 }; 88 89 90 #endif 91 92