merge FTPSClientSession from develop-experimental

This commit is contained in:
Günter Obiltschnig
2020-01-23 11:57:28 +01:00
parent 958ce15bb5
commit 5d481ff493
13 changed files with 1416 additions and 37 deletions

View File

@@ -63,7 +63,7 @@ public:
///
/// Passive mode will be used for data transfers.
explicit FTPClientSession(const StreamSocket& socket);
explicit FTPClientSession(const StreamSocket& socket, bool readWelcomeMessage = true);
/// Creates an FTPClientSession using the given
/// connected socket for the control connection.
///
@@ -99,14 +99,14 @@ public:
bool getPassive() const;
/// Returns true iff passive mode is enabled for this connection.
void open(const std::string& host,
virtual void open(const std::string& host,
Poco::UInt16 port,
const std::string& username = "",
const std::string& password = "");
/// Opens the FTP connection to the given host and port.
/// If username is supplied, login is attempted.
void login(const std::string& username, const std::string& password);
virtual void login(const std::string& username, const std::string& password);
/// Authenticates the user against the FTP server. Must be
/// called before any other commands (except QUIT) can be sent.
///
@@ -302,7 +302,16 @@ public:
bool isLoggedIn() const;
/// Returns true if the session is logged in.
bool isSecure() const;
/// Returns true if the session is FTPS.
const std::string& welcomeMessage();
/// Returns welcome message.
protected:
virtual void receiveServerReadyReply();
/// Function that read server welcome message after connetion
enum StatusClass
{
FTP_POSITIVE_PRELIMINARY = 1,
@@ -335,20 +344,23 @@ protected:
void parseExtAddress(const std::string& str, SocketAddress& addr);
void endTransfer();
DialogSocket* _pControlSocket = nullptr;
SocketStream* _pDataStream = nullptr;
private:
FTPClientSession(const FTPClientSession&);
FTPClientSession& operator = (const FTPClientSession&);
std::string _host;
Poco::UInt16 _port;
DialogSocket* _pControlSocket;
SocketStream* _pDataStream;
bool _passiveMode;
FileType _fileType;
bool _supports1738;
bool _serverReady;
bool _isLoggedIn;
Poco::Timespan _timeout;
std::string _host;
Poco::UInt16 _port = 0;
bool _passiveMode = true;
FileType _fileType = TYPE_BINARY;
bool _supports1738 = true;
bool _serverReady = false;
bool _isLoggedIn = false;
Poco::Timespan _timeout = DEFAULT_TIMEOUT;
std::string _welcomeMessage;
Poco::FastMutex _wmMutex;
};
@@ -397,6 +409,19 @@ inline bool FTPClientSession::isLoggedIn() const
}
inline bool FTPClientSession::isSecure() const
{
return false;
}
inline const std::string& FTPClientSession::welcomeMessage()
{
Poco::FastMutex::ScopedLock lock(_wmMutex);
return _welcomeMessage;
}
} } // namespace Poco::Net