source: filezilla/trunk/fuentes/src/engine/transfersocket.h @ 130

Last change on this file since 130 was 130, checked in by jrpelegrina, 3 years ago

First release to xenial

File size: 2.4 KB
Line 
1#ifndef __TRANSFERSOCKET_H__
2#define __TRANSFERSOCKET_H__
3
4#include "iothread.h"
5#include "backend.h"
6#include "ControlSocket.h"
7
8class CFileZillaEnginePrivate;
9class CFtpControlSocket;
10class CDirectoryListingParser;
11
12enum class TransferMode
13{
14        list,
15        upload,
16        download,
17        resumetest
18};
19
20class CIOThread;
21class CTlsSocket;
22class CTransferSocket final : public CEventHandler
23{
24public:
25        CTransferSocket(CFileZillaEnginePrivate & engine, CFtpControlSocket & controlSocket, TransferMode transferMode);
26        virtual ~CTransferSocket();
27
28        wxString SetupActiveTransfer(const wxString& ip);
29        bool SetupPassiveTransfer(wxString host, int port);
30
31        void SetActive();
32
33        CDirectoryListingParser *m_pDirectoryListingParser{};
34
35        bool m_binaryMode{true};
36
37        TransferEndReason GetTransferEndreason() const { return m_transferEndReason; }
38
39        void SetIOThread(CIOThread* ioThread) { ioThread_ = ioThread; }
40
41protected:
42        bool CheckGetNextWriteBuffer();
43        bool CheckGetNextReadBuffer();
44        void FinalizeWrite();
45
46        void TransferEnd(TransferEndReason reason);
47
48        bool InitBackend();
49        bool InitTls(const CTlsSocket* pPrimaryTlsSocket);
50
51        void ResetSocket();
52
53        void OnSocketEvent(CSocketEventSource* source, SocketEventType t, int error);
54        void OnConnect();
55        void OnAccept(int error);
56        void OnReceive();
57        void OnSend();
58        void OnClose(int error);
59
60        // Create a socket server
61        CSocket* CreateSocketServer();
62        CSocket* CreateSocketServer(int port);
63
64        void SetSocketBufferSizes(CSocket* pSocket);
65
66        virtual void operator()(CEventBase const& ev);
67        void OnIOThreadEvent();
68
69        CSocket *m_pSocket{};
70
71        // Will be set only while creating active mode connections
72        CSocket* m_pSocketServer{};
73
74        CFileZillaEnginePrivate & engine_;
75        CFtpControlSocket & controlSocket_;
76
77        bool m_bActive{};
78        TransferEndReason m_transferEndReason{TransferEndReason::none};
79
80        TransferMode const m_transferMode;
81
82        char *m_pTransferBuffer{};
83        int m_transferBufferLen{};
84
85        // Set to true if OnClose got called
86        // We now have to read all available data in the socket, ignoring any
87        // speed limits
88        bool m_onCloseCalled{};
89
90        bool m_postponedReceive{};
91        bool m_postponedSend{};
92        void TriggerPostponedEvents();
93
94        CBackend* m_pBackend{};
95
96        CProxySocket* m_pProxyBackend{};
97
98        CTlsSocket* m_pTlsSocket{};
99        bool m_shutdown{};
100
101        // Needed for the madeProgress field in CTransferStatus
102        // Initially 0, 2 if made progress
103        // On uploads, 1 after first WSAE_WOULDBLOCK
104        int m_madeProgress{};
105
106        CIOThread* ioThread_{};
107};
108
109#endif
Note: See TracBrowser for help on using the repository browser.