TransferSocket.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. __int64 m_uploaded;
  36. void SetActive();
  37. int CheckForTimeout(int delay);
  38. #ifndef MPEXT_NO_GSS
  39. void UseGSS(CAsyncGssSocketLayer * pGssLayer);
  40. #endif
  41. #ifndef MPEXT_NO_ZLIB
  42. bool InitZlib(int level);
  43. #endif
  44. public:
  45. virtual void OnReceive(int nErrorCode);
  46. virtual void OnAccept(int nErrorCode);
  47. virtual void OnConnect(int nErrorCode);
  48. virtual void OnClose(int nErrorCode);
  49. virtual void OnSend(int nErrorCode);
  50. virtual void SetState(int nState);
  51. protected:
  52. virtual int OnLayerCallback(std::list<t_callbackMsg> & callbacks);
  53. int ReadDataFromFile(char * buffer, int len);
  54. virtual void LogSocketMessageRaw(int nMessageType, LPCTSTR pMsg);
  55. virtual int GetSocketOptionVal(int OptionID) const;
  56. virtual void ConfigureSocket();
  57. bool Activate();
  58. void Start();
  59. CFtpControlSocket * m_pOwner;
  60. CAsyncProxySocketLayer * m_pProxyLayer;
  61. CAsyncSslSocketLayer * m_pSslLayer;
  62. #ifndef MPEXT_NO_GSS
  63. CAsyncGssSocketLayer * m_pGssLayer;
  64. #endif
  65. void UpdateStatusBar(bool forceUpdate);
  66. BOOL m_bSentClose;
  67. int m_bufferpos;
  68. char * m_pBuffer;
  69. #ifndef MPEXT_NO_ZLIB
  70. char * m_pBuffer2; // Used by zlib transfers
  71. #endif
  72. BOOL m_bCheckTimeout;
  73. CTime m_LastActiveTime;
  74. int m_nTransferState;
  75. int m_nMode;
  76. int m_nNotifyWaiting;
  77. bool m_bActivationPending;
  78. void CloseAndEnsureSendClose(int Mode);
  79. void EnsureSendClose(int Mode);
  80. void CloseOnShutDownOrError(int Mode);
  81. void SetBuffers();
  82. LARGE_INTEGER m_LastUpdateTime;
  83. unsigned int m_LastSendBufferUpdate;
  84. DWORD m_SendBuf;
  85. #ifndef MPEXT_NO_ZLIB
  86. z_stream m_zlibStream;
  87. bool m_useZlib;
  88. #endif
  89. };
  90. //---------------------------------------------------------------------------
  91. #endif // TransferSocketH