FtpControlSocket.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // FileZilla - a Windows ftp client
  2. // Copyright (C) 2002-2004 - Tim Kosse <[email protected]>
  3. // This program is free software; you can redistribute it and/or
  4. // modify it under the terms of the GNU General Public License
  5. // as published by the Free Software Foundation; either version 2
  6. // of the License, or (at your option) any later version.
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU General Public License for more details.
  11. // You should have received a copy of the GNU General Public License
  12. // along with this program; if not, write to the Free Software
  13. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. #if !defined(AFX_FTPCONTROLSOCKET_H__AE6AA44E_B09D_487A_8EF2_A23697434945__INCLUDED_)
  15. #define AFX_FTPCONTROLSOCKET_H__AE6AA44E_B09D_487A_8EF2_A23697434945__INCLUDED_
  16. #include "structures.h" // Hinzugefügt von der Klassenansicht
  17. #include "StdAfx.h" // Hinzugefügt von der Klassenansicht
  18. #include "FileZillaApi.h"
  19. #include "FileZillaIntf.h"
  20. #include "ControlSocket.h"
  21. #if _MSC_VER > 1000
  22. #pragma once
  23. #endif // _MSC_VER > 1000
  24. // FtpControlSocket.h : Header-Datei
  25. //
  26. class CTransferSocket;
  27. class CMainThread;
  28. /////////////////////////////////////////////////////////////////////////////
  29. // Befehlsziel CFtpControlSocket
  30. class CAsyncProxySocketLayer;
  31. class CMainThread;
  32. class CFtpControlSocket : public CControlSocket
  33. {
  34. friend CTransferSocket;
  35. // Attribute
  36. public:
  37. // Operationen
  38. public:
  39. CFtpControlSocket(CMainThread *pMainThread, CFileZillaTools * pTools);
  40. virtual ~CFtpControlSocket();
  41. // Überschreibungen
  42. public:
  43. virtual void Connect(t_server &server);
  44. virtual void OnTimer();
  45. virtual BOOL IsReady();
  46. virtual void List(BOOL bFinish, int nError=0, CServerPath path=CServerPath(), CString subdir=_MPT(""), int nListMode = 0);
  47. #ifdef MPEXT
  48. virtual void ListFile(CServerPath path=CServerPath(), CString fileName="");
  49. #endif
  50. virtual void FtpCommand(LPCTSTR pCommand);
  51. virtual void Disconnect();
  52. virtual void FileTransfer(t_transferfile *transferfile = 0, BOOL bFinish = FALSE, int nError = 0);
  53. virtual void Delete(CString filename, const CServerPath &path);
  54. virtual void Rename(CString oldName, CString newName, const CServerPath &path, const CServerPath &newPath);
  55. virtual void MakeDir(const CServerPath &path);
  56. virtual void RemoveDir(CString dirname, const CServerPath &path);
  57. virtual void Chmod(CString filename, const CServerPath &path, int nValue);
  58. virtual void ProcessReply();
  59. virtual void TransferEnd(int nMode);
  60. virtual void Cancel(BOOL bQuit=FALSE);
  61. virtual void SetAsyncRequestResult(int nAction, CAsyncRequestData *pData);
  62. int CheckOverwriteFile();
  63. virtual BOOL Create();
  64. void TransfersocketListenFinished(unsigned int ip,unsigned short port);
  65. BOOL m_bKeepAliveActive;
  66. #ifndef MPEXT_NO_SSL
  67. BOOL m_bDidRejectCertificate;
  68. #endif
  69. // Some servers are broken. Instead of an empty listing, some MVS servers
  70. // for example they return something "550 no members found"
  71. // Other servers return "550 No files found."
  72. bool IsMisleadingListResponse();
  73. #ifdef MPEXT
  74. virtual bool UsingMlsd();
  75. virtual bool UsingUtf8();
  76. virtual std::string GetTlsVersionStr();
  77. virtual std::string GetCipherName();
  78. #endif
  79. // Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen
  80. //{{AFX_VIRTUAL(CFtpControlSocket)
  81. public:
  82. virtual void OnReceive(int nErrorCode);
  83. virtual void OnConnect(int nErrorCode);
  84. virtual void OnClose(int nErrorCode);
  85. virtual void OnSend(int nErrorCode);
  86. //}}AFX_VIRTUAL
  87. // Generierte Nachrichtenzuordnungsfunktionen
  88. //{{AFX_MSG(CFtpControlSocket)
  89. // HINWEIS - Der Klassen-Assistent fügt hier Member-Funktionen ein und entfernt diese.
  90. //}}AFX_MSG
  91. // Implementierung
  92. protected:
  93. //Called by OnTimer()
  94. void ResumeTransfer();
  95. void CheckForTimeout();
  96. void SendKeepAliveCommand();
  97. virtual int OnLayerCallback(std::list<t_callbackMsg>& callbacks);
  98. void SetFileExistsAction(int nAction, COverwriteRequestData *pData);
  99. #ifndef MPEXT_NO_SSL
  100. void SetVerifyCertResult( int nResult, t_SslCertData *pData );
  101. #endif
  102. void ResetOperation(int nSuccessful = -1);
  103. virtual void DoClose(int nError = 0);
  104. int GetReplyCode();
  105. CString GetReply();
  106. void LogOnToServer(BOOL bSkipReply = FALSE);
  107. BOOL Send(CString str);
  108. BOOL ParsePwdReply(CString& rawpwd);
  109. void DiscardLine(CStringA line);
  110. bool NeedModeCommand();
  111. bool NeedOptsCommand();
  112. CString GetListingCmd();
  113. bool InitConnect();
  114. #ifdef MPEXT
  115. bool IsRoutableAddress(const CString & host);
  116. bool CheckForcePasvIp(CString & host);
  117. void TransferFinished(bool preserveFileTimeForUploads);
  118. #endif
  119. CFile *m_pDataFile;
  120. CTransferSocket *m_pTransferSocket;
  121. CStringA m_MultiLine;
  122. CTime m_LastSendTime;
  123. CString m_ServerName;
  124. std::list<CStringA> m_RecvBuffer;
  125. CTime m_LastRecvTime;
  126. class CLogonData;
  127. class CListData;
  128. class CFileTransferData;
  129. class CMakeDirData;
  130. #ifndef MPEXT_NO_ZLIB
  131. bool m_useZlib;
  132. bool m_zlibSupported;
  133. int m_zlibLevel;
  134. #endif
  135. bool m_bUTF8;
  136. bool m_bAnnouncesUTF8;
  137. bool m_hasClntCmd;
  138. #ifdef MPEXT
  139. TFTPServerCapabilities m_serverCapabilities;
  140. CStringA m_ListFile;
  141. #endif
  142. bool m_isFileZilla;
  143. bool m_awaitsReply;
  144. bool m_skipReply;
  145. char* m_sendBuffer;
  146. int m_sendBufferLen;
  147. bool m_bProtP;
  148. bool m_mayBeMvsFilesystem;
  149. bool m_mayBeBS2000Filesystem;
  150. private:
  151. BOOL m_bCheckForTimeout;
  152. };
  153. /////////////////////////////////////////////////////////////////////////////
  154. //{{AFX_INSERT_LOCATION}}
  155. // Microsoft Visual C++ fügt unmittelbar vor der vorhergehenden Zeile zusätzliche Deklarationen ein.
  156. #endif // AFX_FTPCONTROLSOCKET_H__AE6AA44E_B09D_487A_8EF2_A23697434945__INCLUDED_