TransferSocket.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 LogError(int Error);
  80. void SetBuffers();
  81. LARGE_INTEGER m_LastUpdateTime;
  82. unsigned int m_LastSendBufferUpdate;
  83. DWORD m_SendBuf;
  84. #ifndef MPEXT_NO_ZLIB
  85. z_stream m_zlibStream;
  86. bool m_useZlib;
  87. #endif
  88. };
  89. //---------------------------------------------------------------------------
  90. #endif // TransferSocketH