Paste P439

Masterwork From Distant Lands
ActivePublic

Authored by sitter on Jul 19 2019, 1:46 PM.
diff --git a/src/ioslaves/ftp/CMakeLists.txt b/src/ioslaves/ftp/CMakeLists.txt
index 8743a30f..b9e2139b 100644
--- a/src/ioslaves/ftp/CMakeLists.txt
+++ b/src/ioslaves/ftp/CMakeLists.txt
@@ -1,6 +1,8 @@
project(kioslave-ftp)
+kde_enable_exceptions()
+
remove_definitions(-DQT_NO_CAST_FROM_ASCII) # TODO REMOVE
include(ConfigureChecks.cmake)
diff --git a/src/ioslaves/ftp/ftp.cpp b/src/ioslaves/ftp/ftp.cpp
index 8a67e2c0..99ce6e5f 100644
--- a/src/ioslaves/ftp/ftp.cpp
+++ b/src/ioslaves/ftp/ftp.cpp
@@ -76,6 +76,25 @@ Q_LOGGING_CATEGORY(KIO_FTP, "kf5.kio.kio_ftp", QtWarningMsg)
#define ENABLE_CAN_RESUME
+class KIOExcpetion : public std::exception
+{
+public:
+ KIOExcpetion(KIO::Error error, const QString &what)
+ : m_error(error)
+ , m_what(what)
+ {
+ }
+
+
+ KIOExcpetion(int error, const QString &what)
+ : KIOExcpetion(static_cast<KIO::Error>(error), what)
+ {
+ }
+
+ KIO::Error m_error;
+ QString m_what;
+};
+
// Pseudo plugin class to embed meta data
class KIOPluginForMetaData : public QObject
{
@@ -170,7 +189,7 @@ int WriteToFile(int fd, const char *buf, size_t len)
}
}
-const KIO::filesize_t Ftp::UnknownSize = (KIO::filesize_t) - 1;
+const KIO::filesize_t FtpInternal::UnknownSize = (KIO::filesize_t) - 1;
using namespace KIO;
@@ -197,8 +216,8 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
// Ftp
//===============================================================================
-Ftp::Ftp(const QByteArray &pool, const QByteArray &app)
- : SlaveBase(QByteArrayLiteral("ftp"), pool, app)
+FtpInternal::FtpInternal(const QByteArray &pool, const QByteArray &app, Ftp *api)
+ : q(api)
{
// init the socket data
m_data = m_control = nullptr;
@@ -210,16 +229,51 @@ Ftp::Ftp(const QByteArray &pool, const QByteArray &app)
m_socketProxyAuth = nullptr;
}
-Ftp::~Ftp()
+FtpInternal::~FtpInternal()
{
qCDebug(KIO_FTP);
closeConnection();
}
+void FtpInternal::infoMessage(const QString &msg)
+{
+ q->infoMessage(msg);
+}
+
+KConfigGroup *FtpInternal::config()
+{
+ return q->config();
+}
+
+void FtpInternal::connected()
+{
+ q->connected();
+}
+
+void FtpInternal::redirection(const QUrl &url)
+{
+ q->redirection(url);
+}
+
+KRemoteEncoding *FtpInternal::remoteEncoding()
+{
+ return q->remoteEncoding();
+}
+
+bool FtpInternal::checkCachedAuthentication(AuthInfo &info)
+{
+ return q->checkCachedAuthentication(info);
+}
+
+bool FtpInternal::openPasswordDialogV2(AuthInfo &info, const QString &errorMsg)
+{
+ return q->openPasswordDialogV2(info, errorMsg);
+}
+
/**
* This closes a data connection opened by ftpOpenDataConnection().
*/
-void Ftp::ftpCloseDataConnection()
+void FtpInternal::ftpCloseDataConnection()
{
delete m_data;
m_data = nullptr;
@@ -231,7 +285,7 @@ void Ftp::ftpCloseDataConnection()
* This closes a control connection opened by ftpOpenControlConnection() and reinits the
* related states. This method gets called from the constructor with m_control = nullptr.
*/
-void Ftp::ftpCloseControlConnection()
+void FtpInternal::ftpCloseControlConnection()
{
m_extControl = 0;
delete m_control;
@@ -246,7 +300,7 @@ void Ftp::ftpCloseControlConnection()
* Returns the last response from the server (iOffset >= 0) -or- reads a new response
* (iOffset < 0). The result is returned (with iOffset chars skipped for iOffset > 0).
*/
-const char *Ftp::ftpResponse(int iOffset)
+const char *FtpInternal::ftpResponse(int iOffset)
{
Q_ASSERT(m_control); // must have control connection socket
const char *pTxt = m_lastControlLine.data();
@@ -264,7 +318,7 @@ const char *Ftp::ftpResponse(int iOffset)
// "nnn-text" we loop here until a final "nnn text" line is
// reached. Only data from the final line will be stored.
do {
- while (!m_control->canReadLine() && m_control->waitForReadyRead((readTimeout() * 1000))) {}
+ while (!m_control->canReadLine() && m_control->waitForReadyRead((q->readTimeout() * 1000))) {}
m_lastControlLine = m_control->readLine();
pTxt = m_lastControlLine.data();
int iCode = atoi(pTxt);
@@ -300,7 +354,7 @@ const char *Ftp::ftpResponse(int iOffset)
return pTxt;
}
-void Ftp::closeConnection()
+void FtpInternal::closeConnection()
{
if (m_control || m_data)
qCDebug(KIO_FTP) << "m_bLoggedOn=" << m_bLoggedOn << " m_bBusy=" << m_bBusy;
@@ -321,13 +375,13 @@ void Ftp::closeConnection()
ftpCloseControlConnection();
}
-void Ftp::setHost(const QString &_host, quint16 _port, const QString &_user,
+void FtpInternal::setHost(const QString &_host, quint16 _port, const QString &_user,
const QString &_pass)
{
qCDebug(KIO_FTP) << _host << "port=" << _port << "user=" << _user;
m_proxyURL.clear();
- m_proxyUrls = config()->readEntry("ProxyUrls", QStringList());
+ m_proxyUrls = q->config()->readEntry("ProxyUrls", QStringList());
qCDebug(KIO_FTP) << "proxy urls:" << m_proxyUrls;
if (m_host != _host || m_port != _port ||
@@ -341,12 +395,12 @@ void Ftp::setHost(const QString &_host, quint16 _port, const QString &_user,
m_pass = _pass;
}
-void Ftp::openConnection()
+void FtpInternal::openConnection()
{
ftpOpenConnection(loginExplicit);
}
-bool Ftp::ftpOpenConnection(LoginMode loginMode)
+bool FtpInternal::ftpOpenConnection(LoginMode loginMode)
{
// check for implicit login if we are already logged on ...
if (loginMode == loginImplicit && m_bLoggedOn) {
@@ -356,10 +410,10 @@ bool Ftp::ftpOpenConnection(LoginMode loginMode)
qCDebug(KIO_FTP) << "host=" << m_host << ", port=" << m_port << ", user=" << m_user << "password= [password hidden]";
- infoMessage(i18n("Opening connection to host %1", m_host));
+ q->infoMessage(i18n("Opening connection to host %1", m_host));
if (m_host.isEmpty()) {
- error(ERR_UNKNOWN_HOST, QString());
+ throw KIOExcpetion(ERR_UNKNOWN_HOST, QByteArray());
return false;
}
@@ -404,7 +458,6 @@ bool Ftp::ftpOpenConnection(LoginMode loginMode)
realURL.setPath(m_initialPath);
qCDebug(KIO_FTP) << "User name changed! Redirecting to" << realURL;
redirection(realURL);
- finished();
return false;
}
@@ -416,7 +469,7 @@ bool Ftp::ftpOpenConnection(LoginMode loginMode)
*
* @return true on success.
*/
-bool Ftp::ftpOpenControlConnection()
+bool FtpInternal::ftpOpenControlConnection()
{
if (m_proxyUrls.isEmpty()) {
return ftpOpenControlConnection(m_host, m_port);
@@ -453,14 +506,14 @@ bool Ftp::ftpOpenControlConnection()
}
}
- if (errorCode) {
- error(errorCode, errorMessage);
+ if (errorCode != 0) {
+ throw KIOExcpetion(static_cast<KIO::Error>(errorCode), errorMessage.toLatin1());
}
return false;
}
-bool Ftp::ftpOpenControlConnection(const QString &host, int port)
+bool FtpInternal::ftpOpenControlConnection(const QString &host, int port)
{
// implicitly close, then try to open a new connection ...
closeConnection();
@@ -472,7 +525,7 @@ bool Ftp::ftpOpenControlConnection(const QString &host, int port)
}
m_control = synchronousConnectToHost(host, port);
connect(m_control, &QAbstractSocket::proxyAuthenticationRequired,
- this, &Ftp::proxyAuthentication);
+ this, &FtpInternal::proxyAuthentication);
int iErrorCode = m_control->state() == QAbstractSocket::ConnectedState ? 0 : ERR_CANNOT_CONNECT;
// on connect success try to read the server message...
@@ -498,7 +551,7 @@ bool Ftp::ftpOpenControlConnection(const QString &host, int port)
return true;
}
closeConnection(); // clean-up on error
- error(iErrorCode, sErrorMsg);
+ throw KIOExcpetion(iErrorCode, sErrorMsg);
return false;
}
@@ -509,7 +562,7 @@ bool Ftp::ftpOpenControlConnection(const QString &host, int port)
*
* @return true on success.
*/
-bool Ftp::ftpLogin(bool *userChanged)
+bool FtpInternal::ftpLogin(bool *userChanged)
{
infoMessage(i18n("Sending login information"));
@@ -587,12 +640,12 @@ bool Ftp::ftpLogin(bool *userChanged)
const bool disablePassDlg = config()->readEntry("DisablePassDlg", false);
if (disablePassDlg) {
- error(ERR_USER_CANCELED, m_host);
+ throw KIOExcpetion(ERR_USER_CANCELED, m_host);
return false;
}
const int errorCode = openPasswordDialogV2(info, errorMsg);
if (errorCode) {
- error(errorCode, QString());
+ throw KIOExcpetion(ERR_USER_CANCELED, QByteArray());
return false;
} else {
// User can decide go anonymous using checkbox
@@ -650,7 +703,7 @@ bool Ftp::ftpLogin(bool *userChanged)
// Cache the password if the user requested it.
if (info.keepPassword) {
- cacheAuthentication(info);
+ q->cacheAuthentication(info);
}
}
failedAuth = -1;
@@ -694,7 +747,7 @@ bool Ftp::ftpLogin(bool *userChanged)
qCDebug(KIO_FTP) << "Searching for pwd";
if (!ftpSendCmd(QByteArrayLiteral("PWD")) || (m_iRespType != 2)) {
qCDebug(KIO_FTP) << "Couldn't issue pwd command";
- error(ERR_CANNOT_LOGIN, i18n("Could not login to %1.", m_host)); // or anything better ?
+ throw KIOExcpetion(ERR_CANNOT_LOGIN, i18n("Could not login to %1.", m_host)); // or anything better ?
return false;
}
@@ -712,9 +765,9 @@ bool Ftp::ftpLogin(bool *userChanged)
return true;
}
-void Ftp::ftpAutoLoginMacro()
+void FtpInternal::ftpAutoLoginMacro()
{
- QString macro = metaData(QStringLiteral("autoLoginMacro"));
+ QString macro = q->metaData(QStringLiteral("autoLoginMacro"));
if (macro.isEmpty()) {
return;
@@ -750,14 +803,14 @@ void Ftp::ftpAutoLoginMacro()
*
* return true if any response received, false on error
*/
-bool Ftp::ftpSendCmd(const QByteArray &cmd, int maxretries)
+bool FtpInternal::ftpSendCmd(const QByteArray &cmd, int maxretries)
{
Q_ASSERT(m_control); // must have control connection socket
if (cmd.indexOf('\r') != -1 || cmd.indexOf('\n') != -1) {
qCWarning(KIO_FTP) << "Invalid command received (contains CR or LF):"
<< cmd.data();
- error(ERR_UNSUPPORTED_ACTION, m_host);
+ throw KIOExcpetion(ERR_UNSUPPORTED_ACTION, m_host);
return false;
}
@@ -815,7 +868,7 @@ bool Ftp::ftpSendCmd(const QByteArray &cmd, int maxretries)
if (!m_bLoggedOn) {
if (m_control) { // if openConnection succeeded ...
qCDebug(KIO_FTP) << "Login failure, aborting";
- error(ERR_CANNOT_LOGIN, m_host);
+ throw KIOExcpetion(ERR_CANNOT_LOGIN, m_host);
closeConnection();
}
return false;
@@ -843,7 +896,7 @@ bool Ftp::ftpSendCmd(const QByteArray &cmd, int maxretries)
* doesn't set error message, since non-pasv mode will always be tried if
* this one fails
*/
-int Ftp::ftpOpenPASVDataConnection()
+int FtpInternal::ftpOpenPASVDataConnection()
{
Q_ASSERT(m_control); // must have control connection socket
Q_ASSERT(!m_data); // ... but no data connection
@@ -900,7 +953,7 @@ int Ftp::ftpOpenPASVDataConnection()
/*
* ftpOpenEPSVDataConnection - opens a data connection via EPSV
*/
-int Ftp::ftpOpenEPSVDataConnection()
+int FtpInternal::ftpOpenEPSVDataConnection()
{
Q_ASSERT(m_control); // must have control connection socket
Q_ASSERT(!m_data); // ... but no data connection
@@ -944,7 +997,7 @@ int Ftp::ftpOpenEPSVDataConnection()
*
* @return 0 if successful, err code otherwise
*/
-int Ftp::ftpOpenDataConnection()
+int FtpInternal::ftpOpenDataConnection()
{
// make sure that we are logged on and have no data connection...
Q_ASSERT(m_bLoggedOn);
@@ -994,7 +1047,7 @@ int Ftp::ftpOpenDataConnection()
* @return 0 if successful, err code otherwise (but never ERR_INTERNAL
* because this is the last connection mode that is tried)
*/
-int Ftp::ftpOpenPortDataConnection()
+int FtpInternal::ftpOpenPortDataConnection()
{
Q_ASSERT(m_control); // must have control connection socket
Q_ASSERT(!m_data); // ... but no data connection
@@ -1042,7 +1095,7 @@ int Ftp::ftpOpenPortDataConnection()
return ERR_INTERNAL;
}
-bool Ftp::ftpOpenCommand(const char *_command, const QString &_path, char _mode,
+bool FtpInternal::ftpOpenCommand(const char *_command, const QString &_path, char _mode,
int errorcode, KIO::fileoffset_t _offset)
{
int errCode = 0;
@@ -1053,7 +1106,7 @@ bool Ftp::ftpOpenCommand(const char *_command, const QString &_path, char _mode,
}
if (errCode != 0) {
- error(errCode, m_host);
+ throw KIOExcpetion(errCode, m_host);
return false;
}
@@ -1065,7 +1118,7 @@ bool Ftp::ftpOpenCommand(const char *_command, const QString &_path, char _mode,
return false;
}
if (m_iRespType != 3) {
- error(ERR_CANNOT_RESUME, _path); // should never happen
+ throw KIOExcpetion(ERR_CANNOT_RESUME, _path); // should never happen
return false;
}
}
@@ -1088,12 +1141,12 @@ bool Ftp::ftpOpenCommand(const char *_command, const QString &_path, char _mode,
else {
// Only now we know for sure that we can resume
if (_offset > 0 && qstrcmp(_command, "retr") == 0) {
- canResume();
+ q->canResume();
}
if (m_server && !m_data) {
qCDebug(KIO_FTP) << "waiting for connection from remote.";
- m_server->waitForNewConnection(connectTimeout() * 1000);
+ m_server->waitForNewConnection(q->connectTimeout() * 1000);
m_data = m_server->nextPendingConnection();
}
@@ -1110,12 +1163,12 @@ bool Ftp::ftpOpenCommand(const char *_command, const QString &_path, char _mode,
}
if (errorcode != KJob::NoError) {
- error(errorcode, errormessage);
+ throw KIOExcpetion(errorcode, errormessage);
}
return false;
}
-bool Ftp::ftpCloseCommand()
+bool FtpInternal::ftpCloseCommand()
{
// first close data sockets (if opened), then read response that
// we got for whatever was used in ftpOpenCommand ( should be 226 )
@@ -1135,7 +1188,7 @@ bool Ftp::ftpCloseCommand()
return true;
}
-void Ftp::mkdir(const QUrl &url, int permissions)
+void FtpInternal::mkdir(const QUrl &url, int permissions)
{
if (!ftpOpenConnection(loginImplicit)) {
return;
@@ -1150,13 +1203,13 @@ void Ftp::mkdir(const QUrl &url, int permissions)
// Check whether or not mkdir failed because
// the directory already exists...
if (ftpFolder(path, false)) {
- error(ERR_DIR_ALREADY_EXIST, path);
+ throw KIOExcpetion(ERR_DIR_ALREADY_EXIST, path);
// Change the directory back to what it was...
(void) ftpFolder(currentPath, false);
return;
}
- error(ERR_CANNOT_MKDIR, path);
+ throw KIOExcpetion(ERR_CANNOT_MKDIR, path);
return;
}
@@ -1164,36 +1217,32 @@ void Ftp::mkdir(const QUrl &url, int permissions)
// chmod the dir we just created, ignoring errors.
(void) ftpChmod(path, permissions);
}
-
- finished();
}
-void Ftp::rename(const QUrl &src, const QUrl &dst, KIO::JobFlags flags)
+void FtpInternal::rename(const QUrl &src, const QUrl &dst, KIO::JobFlags flags)
{
if (!ftpOpenConnection(loginImplicit)) {
return;
}
// The actual functionality is in ftpRename because put needs it
- if (ftpRename(src.path(), dst.path(), flags)) {
- finished();
- }
+ ftpRename(src.path(), dst.path(), flags);
}
-bool Ftp::ftpRename(const QString &src, const QString &dst, KIO::JobFlags jobFlags)
+bool FtpInternal::ftpRename(const QString &src, const QString &dst, KIO::JobFlags jobFlags)
{
Q_ASSERT(m_bLoggedOn);
// Must check if dst already exists, RNFR+RNTO overwrites by default (#127793).
if (!(jobFlags & KIO::Overwrite)) {
if (ftpFileExists(dst)) {
- error(ERR_FILE_ALREADY_EXIST, dst);
+ throw KIOExcpetion(ERR_FILE_ALREADY_EXIST, dst);
return false;
}
}
if (ftpFolder(dst, false)) {
- error(ERR_DIR_ALREADY_EXIST, dst);
+ throw KIOExcpetion(ERR_DIR_ALREADY_EXIST, dst);
return false;
}
@@ -1201,26 +1250,27 @@ bool Ftp::ftpRename(const QString &src, const QString &dst, KIO::JobFlags jobFla
const int pos = src.lastIndexOf(QLatin1Char('/'));
if (pos >= 0) {
if (!ftpFolder(src.left(pos + 1), false)) {
+#warning this needs an error
return false;
}
}
const QByteArray from_cmd = "RNFR " + remoteEncoding()->encode(src.mid(pos + 1));
if (!ftpSendCmd(from_cmd) || (m_iRespType != 3)) {
- error(ERR_CANNOT_RENAME, src);
+ throw KIOExcpetion(ERR_CANNOT_RENAME, src);
return false;
}
const QByteArray to_cmd = "RNTO " + remoteEncoding()->encode(dst);
if (!ftpSendCmd(to_cmd) || (m_iRespType != 2)) {
- error(ERR_CANNOT_RENAME, src);
+ throw KIOExcpetion(ERR_CANNOT_RENAME, src);
return false;
}
return true;
}
-void Ftp::del(const QUrl &url, bool isfile)
+void FtpInternal::del(const QUrl &url, bool isfile)
{
if (!ftpOpenConnection(loginImplicit)) {
return;
@@ -1235,13 +1285,11 @@ void Ftp::del(const QUrl &url, bool isfile)
const QByteArray cmd = (isfile ? "DELE " : "RMD ") + remoteEncoding()->encode(url);
if (!ftpSendCmd(cmd) || (m_iRespType != 2)) {
- error(ERR_CANNOT_DELETE, url.path());
- } else {
- finished();
+ throw KIOExcpetion(ERR_CANNOT_DELETE, url.path());
}
}
-bool Ftp::ftpChmod(const QString &path, int permissions)
+bool FtpInternal::ftpChmod(const QString &path, int permissions)
{
Q_ASSERT(m_bLoggedOn);
@@ -1265,20 +1313,18 @@ bool Ftp::ftpChmod(const QString &path, int permissions)
return false;
}
-void Ftp::chmod(const QUrl &url, int permissions)
+void FtpInternal::chmod(const QUrl &url, int permissions)
{
if (!ftpOpenConnection(loginImplicit)) {
return;
}
if (!ftpChmod(url.path(), permissions)) {
- error(ERR_CANNOT_CHMOD, url.path());
- } else {
- finished();
+ throw KIOExcpetion(ERR_CANNOT_CHMOD, url.path());
}
}
-void Ftp::ftpCreateUDSEntry(const QString &filename, const FtpEntry &ftpEnt, UDSEntry &entry, bool isDir)
+void FtpInternal::ftpCreateUDSEntry(const QString &filename, const FtpEntry &ftpEnt, UDSEntry &entry, bool isDir)
{
Q_ASSERT(entry.count() == 0); // by contract :-)
@@ -1312,7 +1358,7 @@ void Ftp::ftpCreateUDSEntry(const QString &filename, const FtpEntry &ftpEnt, UDS
// entry.insert KIO::UDSEntry::UDS_CREATION_TIME,buff.st_ctime);
}
-void Ftp::ftpShortStatAnswer(const QString &filename, bool isDir)
+void FtpInternal::ftpShortStatAnswer(const QString &filename, bool isDir)
{
UDSEntry entry;
@@ -1324,16 +1370,15 @@ void Ftp::ftpShortStatAnswer(const QString &filename, bool isDir)
}
// No details about size, ownership, group, etc.
- statEntry(entry);
- finished();
+ q->statEntry(entry);
}
-void Ftp::ftpStatAnswerNotFound(const QString &path, const QString &filename)
+void FtpInternal::ftpStatAnswerNotFound(const QString &path, const QString &filename)
{
// Only do the 'hack' below if we want to download an existing file (i.e. when looking at the "source")
// When e.g. uploading a file, we still need stat() to return "not found"
// when the file doesn't exist.
- QString statSide = metaData(QStringLiteral("statSide"));
+ QString statSide = q->metaData(QStringLiteral("statSide"));
qCDebug(KIO_FTP) << "statSide=" << statSide;
if (statSide == QLatin1String("source")) {
qCDebug(KIO_FTP) << "Not found, but assuming found, because some servers don't allow listing";
@@ -1347,10 +1392,10 @@ void Ftp::ftpStatAnswerNotFound(const QString &path, const QString &filename)
return;
}
- error(ERR_DOES_NOT_EXIST, path);
+ throw KIOExcpetion(ERR_DOES_NOT_EXIST, path);
}
-void Ftp::stat(const QUrl &url)
+void FtpInternal::stat(const QUrl &url)
{
qCDebug(KIO_FTP) << "path=" << url.path();
if (!ftpOpenConnection(loginImplicit)) {
@@ -1372,8 +1417,7 @@ void Ftp::stat(const QUrl &url)
entry.fastInsert(KIO::UDSEntry::UDS_GROUP, QStringLiteral("root"));
// no size
- statEntry(entry);
- finished();
+ q->statEntry(entry);
return;
}
@@ -1390,7 +1434,7 @@ void Ftp::stat(const QUrl &url)
bool isDir = ftpFolder(path, false);
// if we're only interested in "file or directory", we should stop here
- QString sDetails = metaData(QStringLiteral("details"));
+ QString sDetails = q->metaData(QStringLiteral("details"));
int details = sDetails.isEmpty() ? 2 : sDetails.toInt();
qCDebug(KIO_FTP) << "details=" << details;
if (details == 0) {
@@ -1418,8 +1462,7 @@ void Ftp::stat(const QUrl &url)
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
// No clue about size, ownership, group, etc.
- statEntry(entry);
- finished();
+ q->statEntry(entry);
return;
}
@@ -1471,30 +1514,29 @@ void Ftp::stat(const QUrl &url)
if (!linkURL.isEmpty()) {
if (linkURL == url || linkURL == tempurl) {
- error(ERR_CYCLIC_LINK, linkURL.toString());
+ throw KIOExcpetion(ERR_CYCLIC_LINK, linkURL.toString());
return;
}
- Ftp::stat(linkURL);
+ FtpInternal::stat(linkURL);
return;
}
qCDebug(KIO_FTP) << "stat : finished successfully";
- finished();
}
-bool Ftp::maybeEmitStatEntry(FtpEntry &ftpEnt, const QString &search, const QString &filename, bool isDir)
+bool FtpInternal::maybeEmitStatEntry(FtpEntry &ftpEnt, const QString &search, const QString &filename, bool isDir)
{
if ((search == ftpEnt.name || filename == ftpEnt.name) && !filename.isEmpty()) {
UDSEntry entry;
ftpCreateUDSEntry(filename, ftpEnt, entry, isDir);
- statEntry(entry);
+ q->statEntry(entry);
return true;
}
return false;
}
-void Ftp::listDir(const QUrl &url)
+void FtpInternal::listDir(const QUrl &url)
{
qCDebug(KIO_FTP) << url;
if (!ftpOpenConnection(loginImplicit)) {
@@ -1518,7 +1560,6 @@ void Ftp::listDir(const QUrl &url)
realURL.setPath(m_initialPath);
qCDebug(KIO_FTP) << "REDIRECTION to " << realURL;
redirection(realURL);
- finished();
return;
}
@@ -1526,11 +1567,11 @@ void Ftp::listDir(const QUrl &url)
if (!ftpOpenDir(path)) {
if (ftpFileExists(path)) {
- error(ERR_IS_FILE, path);
+ throw KIOExcpetion(ERR_IS_FILE, path);
} else {
// not sure which to emit
//error( ERR_DOES_NOT_EXIST, path );
- error(ERR_CANNOT_ENTER_DIRECTORY, path);
+ throw KIOExcpetion(ERR_CANNOT_ENTER_DIRECTORY, path);
}
return;
}
@@ -1552,7 +1593,7 @@ void Ftp::listDir(const QUrl &url)
//if ( !ftpEnt.link.isEmpty() )
// qDebug() << "is a link to " << ftpEnt.link;
ftpCreateUDSEntry(ftpEnt.name, ftpEnt, entry, false);
- listEntry(entry);
+ q->listEntry(entry);
entry.clear();
}
}
@@ -1561,21 +1602,20 @@ void Ftp::listDir(const QUrl &url)
FtpEntry &ftpEnt = ftpValidateEntList[i];
fixupEntryName(&ftpEnt);
ftpCreateUDSEntry(ftpEnt.name, ftpEnt, entry, false);
- listEntry(entry);
+ q->listEntry(entry);
entry.clear();
}
ftpCloseCommand(); // closes the data connection only
- finished();
}
-void Ftp::slave_status()
+void FtpInternal::slave_status()
{
qCDebug(KIO_FTP) << "Got slave_status host = " << (!m_host.toLatin1().isEmpty() ? m_host.toLatin1() : "[None]") << " [" << (m_bLoggedOn ? "Connected" : "Not connected") << "]";
- slaveStatus(m_host, m_bLoggedOn);
+ q->slaveStatus(m_host, m_bLoggedOn);
}
-bool Ftp::ftpOpenDir(const QString &path)
+bool FtpInternal::ftpOpenDir(const QString &path)
{
//QString path( _url.path(QUrl::RemoveTrailingSlash) );
@@ -1606,13 +1646,13 @@ bool Ftp::ftpOpenDir(const QString &path)
return true;
}
-bool Ftp::ftpReadDir(FtpEntry &de)
+bool FtpInternal::ftpReadDir(FtpEntry &de)
{
Q_ASSERT(m_data);
// get a line from the data connection ...
while (true) {
- while (!m_data->canReadLine() && m_data->waitForReadyRead((readTimeout() * 1000))) {}
+ while (!m_data->canReadLine() && m_data->waitForReadyRead((q->readTimeout() * 1000))) {}
QByteArray data = m_data->readLine();
if (data.size() == 0) {
break;
@@ -1846,7 +1886,7 @@ bool Ftp::ftpReadDir(FtpEntry &de)
// public: get download file from server
// helper: ftpGet called from get() and copy()
//===============================================================================
-void Ftp::get(const QUrl &url)
+void FtpInternal::get(const QUrl &url)
{
qCDebug(KIO_FTP) << url;
@@ -1855,16 +1895,15 @@ void Ftp::get(const QUrl &url)
ftpCloseCommand(); // must close command!
if (cs == statusSuccess) {
- finished();
return;
}
if (iError) { // can have only server side errs
- error(iError, url.path());
+ throw KIOExcpetion(iError, url.path());
}
}
-Ftp::StatusCode Ftp::ftpGet(int &iError, int iCopyFile, const QUrl &url, KIO::fileoffset_t llOffset)
+FtpInternal::StatusCode FtpInternal::ftpGet(int &iError, int iCopyFile, const QUrl &url, KIO::fileoffset_t llOffset)
{
// Calls error() by itself!
if (!ftpOpenConnection(loginImplicit)) {
@@ -1884,9 +1923,9 @@ Ftp::StatusCode Ftp::ftpGet(int &iError, int iCopyFile, const QUrl &url, KIO::fi
return statusServerError;
}
- QString resumeOffset = metaData(QStringLiteral("range-start"));
+ QString resumeOffset = q->metaData(QStringLiteral("range-start"));
if (resumeOffset.isEmpty()) {
- resumeOffset = metaData(QStringLiteral("resume")); // old name
+ resumeOffset = q->metaData(QStringLiteral("resume")); // old name
}
if (!resumeOffset.isEmpty()) {
llOffset = resumeOffset.toLongLong();
@@ -1920,7 +1959,7 @@ Ftp::StatusCode Ftp::ftpGet(int &iError, int iCopyFile, const QUrl &url, KIO::fi
KIO::filesize_t bytesLeft = 0;
if (m_size != UnknownSize) {
bytesLeft = m_size - llOffset;
- totalSize(m_size); // emit the total size...
+ q->totalSize(m_size); // emit the total size...
}
qCDebug(KIO_FTP) << "starting with offset=" << llOffset;
@@ -1945,7 +1984,7 @@ Ftp::StatusCode Ftp::ftpGet(int &iError, int iCopyFile, const QUrl &url, KIO::fi
iBlockSize = sizeof(buffer) - iBufferCur;
}
if (m_data->bytesAvailable() == 0) {
- m_data->waitForReadyRead((readTimeout() * 1000));
+ m_data->waitForReadyRead((q->readTimeout() * 1000));
}
int n = m_data->read(buffer + iBufferCur, iBlockSize);
if (n <= 0) {
@@ -1964,7 +2003,7 @@ Ftp::StatusCode Ftp::ftpGet(int &iError, int iCopyFile, const QUrl &url, KIO::fi
bytesLeft -= n;
iBufferCur += n;
if (iBufferCur < minimumMimeSize && bytesLeft > 0) {
- processedSize(processed_size);
+ q->processedSize(processed_size);
continue;
}
n = iBufferCur;
@@ -1974,20 +2013,20 @@ Ftp::StatusCode Ftp::ftpGet(int &iError, int iCopyFile, const QUrl &url, KIO::fi
// write output file or pass to data pump ...
if (iCopyFile == -1) {
array = QByteArray::fromRawData(buffer, n);
- data(array);
+ q->data(array);
array.clear();
} else if ((iError = WriteToFile(iCopyFile, buffer, n)) != 0) {
return statusClientError; // client side error
}
- processedSize(processed_size);
+ q->processedSize(processed_size);
}
qCDebug(KIO_FTP) << "done";
if (iCopyFile == -1) { // must signal EOF to data pump ...
- data(array); // array is empty and must be empty!
+ q->data(array); // array is empty and must be empty!
}
- processedSize(m_size == UnknownSize ? processed_size : m_size);
+ q->processedSize(m_size == UnknownSize ? processed_size : m_size);
return statusSuccess;
}
@@ -2060,7 +2099,7 @@ void Ftp::ftpAbortTransfer()
// public: put upload file to server
// helper: ftpPut called from put() and copy()
//===============================================================================
-void Ftp::put(const QUrl &url, int permissions, KIO::JobFlags flags)
+void FtpInternal::put(const QUrl &url, int permissions, KIO::JobFlags flags)
{
qCDebug(KIO_FTP) << url;
@@ -2069,16 +2108,15 @@ void Ftp::put(const QUrl &url, int permissions, KIO::JobFlags flags)
ftpCloseCommand(); // must close command!
if (cs == statusSuccess) {
- finished();
return;
}
if (iError) { // can have only server side errs
- error(iError, url.path());
+ throw KIOExcpetion(iError, url.path());
}
}
-Ftp::StatusCode Ftp::ftpPut(int &iError, int iCopyFile, const QUrl &dest_url,
+FtpInternal::StatusCode FtpInternal::ftpPut(int &iError, int iCopyFile, const QUrl &dest_url,
int permissions, KIO::JobFlags flags)
{
if (!ftpOpenConnection(loginImplicit)) {
@@ -2127,7 +2165,7 @@ Ftp::StatusCode Ftp::ftpPut(int &iError, int iCopyFile, const QUrl &dest_url,
return statusServerError;
}
} else if (!(flags & KIO::Overwrite) && !(flags & KIO::Resume)) {
- flags |= canResume(m_size) ? KIO::Resume : KIO::DefaultFlags;
+ flags |= q->canResume(m_size) ? KIO::Resume : KIO::DefaultFlags;
if (!(flags & KIO::Resume)) {
iError = ERR_FILE_ALREADY_EXIST;
return statusServerError;
@@ -2173,8 +2211,8 @@ Ftp::StatusCode Ftp::ftpPut(int &iError, int iCopyFile, const QUrl &dest_url,
// Loop until we got 'dataEnd'
do {
if (iCopyFile == -1) {
- dataReq(); // Request for data
- result = readData(buffer);
+ q->dataReq(); // Request for data
+ result = q->readData(buffer);
} else {
// let the buffer size grow if the file is larger 64kByte ...
if (processed_size - offset > 1024 * 64) {
@@ -2193,7 +2231,7 @@ Ftp::StatusCode Ftp::ftpPut(int &iError, int iCopyFile, const QUrl &dest_url,
m_data->write(buffer);
while (m_data->bytesToWrite() && m_data->waitForBytesWritten()) {}
processed_size += result;
- processedSize(processed_size);
+ q->processedSize(processed_size);
}
} while (result > 0);
@@ -2242,7 +2280,7 @@ Ftp::StatusCode Ftp::ftpPut(int &iError, int iCopyFile, const QUrl &dest_url,
/** Use the SIZE command to get the file size.
Warning : the size depends on the transfer mode, hence the second arg. */
-bool Ftp::ftpSize(const QString &path, char mode)
+bool FtpInternal::ftpSize(const QString &path, char mode)
{
m_size = UnknownSize;
if (!ftpDataMode(mode)) {
@@ -2267,7 +2305,7 @@ bool Ftp::ftpSize(const QString &path, char mode)
return true;
}
-bool Ftp::ftpFileExists(const QString &path)
+bool FtpInternal::ftpFileExists(const QString &path)
{
const QByteArray buf = "SIZE " + remoteEncoding()->encode(path);
if (!ftpSendCmd(buf) || (m_iRespType != 2)) {
@@ -2286,7 +2324,7 @@ bool Ftp::ftpFileExists(const QString &path)
// more important.
// Theoretically "list" could return different results in ASCII
// and BINARY mode. But again, most servers ignore ASCII here.
-bool Ftp::ftpDataMode(char cMode)
+bool FtpInternal::ftpDataMode(char cMode)
{
if (cMode == '?') {
cMode = m_bTextMode ? 'A' : 'I';
@@ -2309,7 +2347,7 @@ bool Ftp::ftpDataMode(char cMode)
return true;
}
-bool Ftp::ftpFolder(const QString &path, bool bReportError)
+bool FtpInternal::ftpFolder(const QString &path, bool bReportError)
{
QString newPath = path;
int iLen = newPath.length();
@@ -2328,7 +2366,7 @@ bool Ftp::ftpFolder(const QString &path, bool bReportError)
}
if (m_iRespType != 2) {
if (bReportError) {
- error(ERR_CANNOT_ENTER_DIRECTORY, path);
+ throw KIOExcpetion(ERR_CANNOT_ENTER_DIRECTORY, path);
}
return false; // not a folder
}
@@ -2341,7 +2379,7 @@ bool Ftp::ftpFolder(const QString &path, bool bReportError)
// helper: ftpCopyPut called from copy() on upload
// helper: ftpCopyGet called from copy() on download
//===============================================================================
-void Ftp::copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags)
+void FtpInternal::copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags)
{
int iError = 0;
int iCopyFile = -1;
@@ -2359,7 +2397,7 @@ void Ftp::copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags
qCDebug(KIO_FTP) << "ftp" << src.path() << "-> local file" << sCopyFile;
cs = ftpCopyGet(iError, iCopyFile, sCopyFile, src, permissions, flags);
} else {
- error(ERR_UNSUPPORTED_ACTION, QString());
+ throw KIOExcpetion(ERR_UNSUPPORTED_ACTION, QString());
return;
}
@@ -2368,16 +2406,12 @@ void Ftp::copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags
QT_CLOSE(iCopyFile);
}
ftpCloseCommand(); // must close command!
- if (cs != statusServerError) {
- if (iError) {
- error(iError, sCopyFile);
- } else {
- finished();
- }
+ if (cs != statusServerError && iError) {
+ throw KIOExcpetion(iError, sCopyFile);
}
}
-Ftp::StatusCode Ftp::ftpCopyPut(int &iError, int &iCopyFile, const QString &sCopyFile,
+FtpInternal::StatusCode FtpInternal::ftpCopyPut(int &iError, int &iCopyFile, const QString &sCopyFile,
const QUrl &url, int permissions, KIO::JobFlags flags)
{
// check if source is ok ...
@@ -2400,7 +2434,7 @@ Ftp::StatusCode Ftp::ftpCopyPut(int &iError, int &iCopyFile, const QString &sCop
}
// delegate the real work (iError gets status) ...
- totalSize(info.size());
+ q->totalSize(info.size());
#ifdef ENABLE_CAN_RESUME
return ftpPut(iError, iCopyFile, url, permissions, flags & ~KIO::Resume);
#else
@@ -2408,7 +2442,7 @@ Ftp::StatusCode Ftp::ftpCopyPut(int &iError, int &iCopyFile, const QString &sCop
#endif
}
-Ftp::StatusCode Ftp::ftpCopyGet(int &iError, int &iCopyFile, const QString &sCopyFile,
+FtpInternal::StatusCode FtpInternal::ftpCopyGet(int &iError, int &iCopyFile, const QString &sCopyFile,
const QUrl &url, int permissions, KIO::JobFlags flags)
{
// check if destination is ok ...
@@ -2440,7 +2474,7 @@ Ftp::StatusCode Ftp::ftpCopyGet(int &iError, int &iCopyFile, const QString &sCop
}
//doesn't work for copy? -> design flaw?
#ifdef ENABLE_CAN_RESUME
- bResume = canResume(sPartInfo.size());
+ bResume = q->canResume(sPartInfo.size());
#else
bResume = true;
#endif
@@ -2512,7 +2546,7 @@ Ftp::StatusCode Ftp::ftpCopyGet(int &iError, int &iCopyFile, const QString &sCop
}
if (iRes == statusSuccess) {
- const QString mtimeStr = metaData(QStringLiteral("modified"));
+ const QString mtimeStr = q->metaData(QStringLiteral("modified"));
if (!mtimeStr.isEmpty()) {
QDateTime dt = QDateTime::fromString(mtimeStr, Qt::ISODate);
if (dt.isValid()) {
@@ -2529,14 +2563,14 @@ Ftp::StatusCode Ftp::ftpCopyGet(int &iError, int &iCopyFile, const QString &sCop
return iRes;
}
-Ftp::StatusCode Ftp::ftpSendMimeType(int &iError, const QUrl &url)
+FtpInternal::StatusCode FtpInternal::ftpSendMimeType(int &iError, const QUrl &url)
{
const int totalSize = ((m_size == UnknownSize || m_size > 1024) ? 1024 : m_size);
QByteArray buffer(totalSize, '\0');
while (true) {
// Wait for content to be available...
- if (m_data->bytesAvailable() == 0 && !m_data->waitForReadyRead((readTimeout() * 1000))) {
+ if (m_data->bytesAvailable() == 0 && !m_data->waitForReadyRead((q->readTimeout() * 1000))) {
iError = ERR_CANNOT_READ;
return statusServerError;
}
@@ -2560,13 +2594,13 @@ Ftp::StatusCode Ftp::ftpSendMimeType(int &iError, const QUrl &url)
QMimeDatabase db;
QMimeType mime = db.mimeTypeForFileNameAndData(url.path(), buffer);
qCDebug(KIO_FTP) << "Emitting mimetype" << mime.name();
- mimeType(mime.name()); // emit the mime type...
+ q->mimeType(mime.name()); // emit the mime type...
}
return statusSuccess;
}
-void Ftp::proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator *authenticator)
+void FtpInternal::proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator *authenticator)
{
Q_UNUSED(proxy);
qCDebug(KIO_FTP) << "Authenticator received -- realm:" << authenticator->realm() << "user:" << authenticator->user();
@@ -2584,7 +2618,7 @@ void Ftp::proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator *authen
if (!haveCachedCredentials || m_socketProxyAuth) {
// Save authentication info if the connection succeeds. We need to disconnect
// this after saving the auth data (or an error) so we won't save garbage afterwards!
- connect(m_control, &QAbstractSocket::connected, this, &Ftp::saveProxyAuthentication);
+ connect(m_control, &QAbstractSocket::connected, this, &FtpInternal::saveProxyAuthentication);
//### fillPromptInfo(&info);
info.prompt = i18n("You need to supply a username and a password for "
"the proxy server listed below before you are allowed "
@@ -2595,7 +2629,7 @@ void Ftp::proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator *authen
const int errorCode = openPasswordDialogV2(info, i18n("Proxy Authentication Failed."));
if (errorCode) {
qCDebug(KIO_FTP) << "user canceled proxy authentication, or communication error.";
- error(errorCode, m_proxyURL.host());
+ throw KIOExcpetion(errorCode, m_proxyURL.host());
return;
}
}
@@ -2613,10 +2647,10 @@ void Ftp::proxyAuthentication(const QNetworkProxy &proxy, QAuthenticator *authen
m_proxyURL.setPassword(info.password);
}
-void Ftp::saveProxyAuthentication()
+void FtpInternal::saveProxyAuthentication()
{
qCDebug(KIO_FTP);
- disconnect(m_control, &QAbstractSocket::connected, this, &Ftp::saveProxyAuthentication);
+ disconnect(m_control, &QAbstractSocket::connected, this, &FtpInternal::saveProxyAuthentication);
Q_ASSERT(m_socketProxyAuth);
if (m_socketProxyAuth) {
qCDebug(KIO_FTP) << "-- realm:" << m_socketProxyAuth->realm() << "user:" << m_socketProxyAuth->user();
@@ -2627,13 +2661,13 @@ void Ftp::saveProxyAuthentication()
a.username = m_socketProxyAuth->user();
a.password = m_socketProxyAuth->password();
a.keepPassword = m_socketProxyAuth->option(QStringLiteral("keepalive")).toBool();
- cacheAuthentication(a);
+ q->cacheAuthentication(a);
}
delete m_socketProxyAuth;
m_socketProxyAuth = nullptr;
}
-void Ftp::fixupEntryName(FtpEntry *e)
+void FtpInternal::fixupEntryName(FtpEntry *e)
{
Q_ASSERT(e);
if (e->type == S_IFDIR) {
@@ -2677,13 +2711,174 @@ void Ftp::fixupEntryName(FtpEntry *e)
}
}
-QTcpSocket *Ftp::synchronousConnectToHost(const QString &host, quint16 port)
+QTcpSocket *FtpInternal::synchronousConnectToHost(const QString &host, quint16 port)
{
QTcpSocket *socket = new QSslSocket;
socket->connectToHost(host, port);
- socket->waitForConnected(connectTimeout() * 1000);
+ socket->waitForConnected(q->connectTimeout() * 1000);
return socket;
}
-// needed for JSON file embedding
+Ftp::Ftp(const QByteArray &pool, const QByteArray &app)
+ : SlaveBase(QByteArrayLiteral("ftp"), pool, app)
+ , d(new FtpInternal(pool, app, this))
+{
+
+}
+
+Ftp::~Ftp()
+{
+ delete d;
+}
+
+void Ftp::setHost(const QString &host, quint16 port, const QString &user, const QString &pass)
+{
+ try {
+ d->setHost(host, port, user, pass);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::openConnection()
+{
+ try {
+ d->openConnection();
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::closeConnection()
+{
+ try {
+ d->closeConnection();
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::stat(const QUrl &url)
+{
+ try {
+ d->stat(url);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::listDir(const QUrl &url)
+{
+ try {
+ d->listDir(url);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::mkdir(const QUrl &url, int permissions)
+{
+ try {
+ d->mkdir(url, permissions);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::rename(const QUrl &src, const QUrl &dst, JobFlags flags)
+{
+ try {
+ d->rename(src, dst, flags);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::del(const QUrl &url, bool isfile)
+{
+ try {
+ d->del(url, isfile);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::chmod(const QUrl &url, int permissions)
+{
+ try {
+ d->chmod(url, permissions);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::get(const QUrl &url)
+{
+ try {
+ d->get(url);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::put(const QUrl &url, int permissions, JobFlags flags)
+{
+ try {
+ d->put(url, permissions, flags);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
+void Ftp::slave_status()
+{
+ d->slave_status();
+ // Doesn't need error/finished I think.
+}
+
+void Ftp::copy(const QUrl &src, const QUrl &dest, int permissions, JobFlags flags)
+{
+ try {
+ d->copy(src, dest, permissions, flags);
+ finished();
+ } catch (const KIOExcpetion &e) {
+ error(e.m_error, e.m_what);
+ } catch (...) {
+ error(KIO::ERR_UNKNOWN, QString());
+ }
+}
+
#include "ftp.moc"
diff --git a/src/ioslaves/ftp/ftp.h b/src/ioslaves/ftp/ftp.h
index bdf7872b..b44fe5a2 100644
--- a/src/ioslaves/ftp/ftp.h
+++ b/src/ioslaves/ftp/ftp.h
@@ -43,18 +43,30 @@ struct FtpEntry {
QDateTime date;
};
+class Ftp;
+
//===============================================================================
// Ftp
//===============================================================================
-class Ftp : public QObject, public KIO::SlaveBase
+class FtpInternal : public QObject
{
Q_OBJECT
public:
- Ftp(const QByteArray &pool, const QByteArray &app);
- virtual ~Ftp();
+ FtpInternal(const QByteArray &pool, const QByteArray &app, Ftp *api);
+ virtual ~FtpInternal();
+
+ void infoMessage(const QString &msg);
+ KConfigGroup *config();
+ void connected();
+ void redirection(const QUrl &url);
+ KRemoteEncoding *remoteEncoding();
+ bool checkCachedAuthentication(KIO::AuthInfo &info);
+ bool openPasswordDialogV2(KIO::AuthInfo &info, const QString &errorMsg);
- void setHost(const QString &host, quint16 port, const QString &user, const QString &pass) override;
+
+
+ void setHost(const QString &host, quint16 port, const QString &user, const QString &pass);
/**
* Connects to a ftp server and logs us in
@@ -62,31 +74,31 @@ public:
* It is set to false if the connection becomes closed.
*
*/
- void openConnection() override;
+ void openConnection();
/**
* Closes the connection
*/
- void closeConnection() override;
+ void closeConnection();
- void stat(const QUrl &url) override;
+ void stat(const QUrl &url);
- void listDir(const QUrl &url) override;
- void mkdir(const QUrl &url, int permissions) override;
- void rename(const QUrl &src, const QUrl &dst, KIO::JobFlags flags) override;
- void del(const QUrl &url, bool isfile) override;
- void chmod(const QUrl &url, int permissions) override;
+ void listDir(const QUrl &url);
+ void mkdir(const QUrl &url, int permissions);
+ void rename(const QUrl &src, const QUrl &dst, KIO::JobFlags flags);
+ void del(const QUrl &url, bool isfile);
+ void chmod(const QUrl &url, int permissions);
- void get(const QUrl &url) override;
- void put(const QUrl &url, int permissions, KIO::JobFlags flags) override;
+ void get(const QUrl &url);
+ void put(const QUrl &url, int permissions, KIO::JobFlags flags);
//virtual void mimetype( const QUrl& url );
- void slave_status() override;
+ void slave_status();
/**
* Handles the case that one side of the job is a local file
*/
- void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) override;
+ void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags);
private:
// ------------------------------------------------------------------------
@@ -441,6 +453,66 @@ private: // data members
* proxy server authenticator
*/
QAuthenticator *m_socketProxyAuth;
+
+ Ftp *const q;
+};
+
+
+//===============================================================================
+// Ftp
+//===============================================================================
+class Ftp : public KIO::SlaveBase
+{
+public:
+ Ftp(const QByteArray &pool, const QByteArray &app);
+ virtual ~Ftp();
+
+ void setHost(const QString &host, quint16 port, const QString &user, const QString &pass) override;
+
+ /**
+ * Connects to a ftp server and logs us in
+ * m_bLoggedOn is set to true if logging on was successful.
+ * It is set to false if the connection becomes closed.
+ *
+ */
+ void openConnection() override;
+
+ /**
+ * Closes the connection
+ */
+ void closeConnection() override;
+
+ void stat(const QUrl &url) override;
+
+ void listDir(const QUrl &url) override;
+ void mkdir(const QUrl &url, int permissions) override;
+ void rename(const QUrl &src, const QUrl &dst, KIO::JobFlags flags) override;
+ void del(const QUrl &url, bool isfile) override;
+ void chmod(const QUrl &url, int permissions) override;
+
+ void get(const QUrl &url) override;
+ void put(const QUrl &url, int permissions, KIO::JobFlags flags) override;
+ //virtual void mimetype( const QUrl& url );
+
+ void slave_status() override;
+
+ /**
+ * Handles the case that one side of the job is a local file
+ */
+ void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) override;
+
+private:
+ void error(int _errid, const QString &_text)
+ {
+ SlaveBase::error(_errid, _text);
+ }
+
+ void finished()
+ {
+ SlaveBase::finished();
+ }
+
+ FtpInternal *const d;
};
#endif // KDELIBS_FTP_H
sitter edited the content of this paste. (Show Details)Jul 19 2019, 1:46 PM
sitter changed the title of this paste from untitled to Masterwork From Distant Lands.