1 /*************************************************************************** 2 * mgftpbase.h 3 * 4 * Wed Sep 6 22:19:52 2006 5 * Copyright 2006 liubin,China 6 * Email multiget@gmail.com 7 ****************************************************************************/ 8 9 /* 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 23 */ 24 #ifndef _MG_FTP_BASE_H 25 #define _MG_FTP_BASE_H 26 27 #include "common.h" 28 #include "mgftpsocket.h" 29 #include <string> 30 #include <cstdio> // for sprintf sscanf etc 31 32 /* 33 CMgSocket -> CMgProxySocket -> CMgHttpSocket -> CMgHttpBase-> CMgHttpInfo 34 | `->CMgHttpAnts 35 \-> CMgFtpSocket -> CMgFtpBase* -> CMgFtpInfo 36 `->CMgFtpAnts 37 */ 38 39 class CMgFtpBase : public CMgFtpSocket 40 { 41 42 public: 43 CMgFtpBase(); 44 virtual ~CMgFtpBase(); 45 46 bool MakeCtrlConn( const char *server, int port ); 47 bool Login( const char *user, const char *pass ); 48 int GetRetCode(); 49 int GetBufLine( char *buf, int maxpos, char *line ); 50 51 bool SetResume( llong pos ); 52 bool EnterBinaryMode(); 53 bool EnterTextMode(); 54 bool EnterPasv( char *dip, int *dport ); 55 bool AbortTransfer(); 56 bool Logout(); 57 bool ListFile( const char* filename ); //send list to server 58 bool ListFile( const char* filename, llong& size ); //to get size 59 bool SizeFile( const char* filename, llong& size ); //send size to get size 60 61 protected: 62 bool GetLenFromBuf( const char* listdataline, llong& size ); 63 virtual void OutMsg( std::string str, _MSGTYPE type ) = 0; 64 65 private: 66 //bool m_bBinaryMode; 67 std::string m_Server; 68 int m_Port; 69 }; 70 71 #endif 72 73