TransferSocket.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. void Start();
  57. CFtpControlSocket * m_pOwner;
  58. CAsyncProxySocketLayer * m_pProxyLayer;
  59. CAsyncSslSocketLayer * m_pSslLayer;
  60. #ifndef MPEXT_NO_GSS
  61. CAsyncGssSocketLayer * m_pGssLayer;
  62. #endif
  63. void UpdateStatusBar(bool forceUpdate);
  64. BOOL m_bSentClose;
  65. int m_bufferpos;
  66. char * m_pBuffer;
  67. #ifndef MPEXT_NO_ZLIB
  68. char * m_pBuffer2; // Used by zlib transfers
  69. #endif
  70. BOOL m_bCheckTimeout;
  71. CTime m_LastActiveTime;
  72. int m_nTransferState;
  73. int m_nMode;
  74. int m_nNotifyWaiting;
  75. bool m_bActivationPending;
  76. void CloseAndEnsureSendClose(int Mode);
  77. void EnsureSendClose(int Mode);
  78. void CloseOnShutDownOrError(int Mode);
  79. void SetBuffers();
  80. LARGE_INTEGER m_LastUpdateTime;
  81. unsigned int m_LastSendBufferUpdate;
  82. DWORD m_SendBuf;
  83. #ifndef MPEXT_NO_ZLIB
  84. z_stream m_zlibStream;
  85. bool m_useZlib;
  86. #endif
  87. };
  88. //---------------------------------------------------------------------------
  89. #endif // TransferSocketH