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. __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 void ConfigureSocket();
  56. bool Activate();
  57. void Start();
  58. CFtpControlSocket * m_pOwner;
  59. CAsyncProxySocketLayer * m_pProxyLayer;
  60. CAsyncSslSocketLayer * m_pSslLayer;
  61. #ifndef MPEXT_NO_GSS
  62. CAsyncGssSocketLayer * m_pGssLayer;
  63. #endif
  64. void UpdateStatusBar(bool forceUpdate);
  65. BOOL m_bSentClose;
  66. int m_bufferpos;
  67. char * m_pBuffer;
  68. #ifndef MPEXT_NO_ZLIB
  69. char * m_pBuffer2; // Used by zlib transfers
  70. #endif
  71. BOOL m_bCheckTimeout;
  72. CTime m_LastActiveTime;
  73. int m_nTransferState;
  74. int m_nMode;
  75. int m_nNotifyWaiting;
  76. bool m_bActivationPending;
  77. void CloseAndEnsureSendClose(int Mode);
  78. void EnsureSendClose(int Mode);
  79. void CloseOnShutDownOrError(int Mode);
  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