TransferSocket.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //---------------------------------------------------------------------------
  2. #ifndef TransferSocketH
  3. #define TransferSocketH
  4. //---------------------------------------------------------------------------
  5. #include "FtpListResult.h"
  6. //---------------------------------------------------------------------------
  7. #include "FtpControlSocket.h"
  8. #include "ApiLog.h"
  9. //---------------------------------------------------------------------------
  10. #ifndef MPEXT_NO_ZLIB
  11. #include <zlib.h>
  12. #endif
  13. //---------------------------------------------------------------------------
  14. class CFtpControlSocket;
  15. class CAsyncProxySocketLayer;
  16. class CAsyncSslSocketLayer;
  17. #ifndef MPEXT_NO_GSS
  18. class CAsyncGssSocketLayer;
  19. #endif
  20. //---------------------------------------------------------------------------
  21. class CTransferSocket : public CAsyncSocketEx, public CApiLog
  22. {
  23. public:
  24. CFtpListResult * m_pListResult;
  25. public:
  26. CTransferSocket(CFtpControlSocket * pOwner, int nMode);
  27. virtual ~CTransferSocket();
  28. public:
  29. int m_nInternalMessageID;
  30. virtual void Close();
  31. virtual BOOL Create(BOOL bUseSsl);
  32. BOOL m_bListening;
  33. CFile * m_pFile;
  34. t_transferdata m_transferdata;
  35. void SetActive();
  36. int CheckForTimeout(int delay);
  37. #ifndef MPEXT_NO_GSS
  38. void UseGSS(CAsyncGssSocketLayer * pGssLayer);
  39. #endif
  40. #ifndef MPEXT_NO_ZLIB
  41. bool InitZlib(int level);
  42. #endif
  43. public:
  44. virtual void OnReceive(int nErrorCode);
  45. virtual void OnAccept(int nErrorCode);
  46. virtual void OnConnect(int nErrorCode);
  47. virtual void OnClose(int nErrorCode);
  48. virtual void OnSend(int nErrorCode);
  49. virtual void SetState(int nState);
  50. protected:
  51. virtual int OnLayerCallback(std::list<t_callbackMsg> & callbacks);
  52. int ReadDataFromFile(char * buffer, int len);
  53. virtual void LogSocketMessageRaw(int nMessageType, LPCTSTR pMsg);
  54. virtual void ConfigureSocket();
  55. bool Activate();
  56. CFtpControlSocket * m_pOwner;
  57. CAsyncProxySocketLayer * m_pProxyLayer;
  58. CAsyncSslSocketLayer * m_pSslLayer;
  59. #ifndef MPEXT_NO_GSS
  60. CAsyncGssSocketLayer * m_pGssLayer;
  61. #endif
  62. void UpdateStatusBar(bool forceUpdate);
  63. BOOL m_bSentClose;
  64. int m_bufferpos;
  65. char * m_pBuffer;
  66. #ifndef MPEXT_NO_ZLIB
  67. char * m_pBuffer2; // Used by zlib transfers
  68. #endif
  69. BOOL m_bCheckTimeout;
  70. CTime m_LastActiveTime;
  71. int m_nTransferState;
  72. int m_nMode;
  73. int m_nNotifyWaiting;
  74. BOOL m_bShutDown;
  75. bool m_bActivationPending;
  76. void CloseAndEnsureSendClose(int Mode);
  77. void EnsureSendClose(int Mode);
  78. void CloseOnShutDownOrError(int Mode);
  79. void LogError(int Error);
  80. void SetBuffers();
  81. LARGE_INTEGER m_LastUpdateTime;
  82. #ifndef MPEXT_NO_ZLIB
  83. z_stream m_zlibStream;
  84. bool m_useZlib;
  85. #endif
  86. };
  87. //---------------------------------------------------------------------------
  88. #endif // TransferSocketH