diff --git a/fish/CMakeLists.txt b/fish/CMakeLists.txt --- a/fish/CMakeLists.txt +++ b/fish/CMakeLists.txt @@ -2,6 +2,7 @@ include(CheckIncludeFiles) include(CheckFunctionExists) +include(ECMQtDeclareLoggingCategory) check_include_files(termios.h HAVE_TERMIOS_H) check_include_files(util.h HAVE_UTIL_H) @@ -43,9 +44,15 @@ set(kio_fish_PART_SRCS fish.cpp ${CMAKE_CURRENT_BINARY_DIR}/fishcode.h) + ecm_qt_declare_logging_category(kio_fish_PART_SRCS + HEADER loggingcategory.h + IDENTIFIER KIO_FISH_DEBUG + CATEGORY_NAME kio_fish + DEFAULT_SEVERITY Debug) + add_library(kio_fish MODULE ${kio_fish_PART_SRCS}) - target_link_libraries(kio_fish KF5::KIOCore KF5::KDELibs4Support) + target_link_libraries(kio_fish KF5::KIOCore KF5::WidgetsAddons KF5::I18n) set_target_properties(kio_fish PROPERTIES OUTPUT_NAME "fish") diff --git a/fish/fish.h b/fish/fish.h --- a/fish/fish.h +++ b/fish/fish.h @@ -16,12 +16,9 @@ #ifndef FISH_H #define FISH_H -#include #include #include -#include #include -#include #define FISH_EXEC_CMD 'X' @@ -113,7 +110,7 @@ QString wantedFn; QString statPath; /** url of current request */ - KUrl url; + QUrl url; /** true if connection is logged in successfully */ bool isLoggedIn; /** host name of current connection */ diff --git a/fish/fish.cpp b/fish/fish.cpp --- a/fish/fish.cpp +++ b/fish/fish.cpp @@ -32,25 +32,21 @@ #include #include #include +#include +#include +#include +#include #include +#include #ifdef HAVE_PTY_H #include #endif #ifdef HAVE_TERMIOS_H #include #endif -#include -#include -#include -#include -#include -#include -#include -#include - #ifdef HAVE_SYS_IOCTL_H #include #endif @@ -63,43 +59,30 @@ #include #endif -#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "fishcode.h" +#include "loggingcategory.h" #ifndef NDEBUG -#define myDebug(x) kDebug(7127) << __LINE__ << ": " x -#define connected() do{myDebug( << "_______ emitting connected()" << endl); connected();}while(0) -#define dataReq() do{myDebug( << "_______ emitting dataReq()" << endl); dataReq();}while(0) -#define needSubURLData() do{myDebug( << "_______ emitting needSubURLData()" << endl); needSubURLData();}while(0) -#define slaveStatus(x,y) do{myDebug( << "_______ emitting slaveStatus(" << x << ", " << y << ")" << endl); slaveStatus(x,y);}while(0) -#define statEntry(x) do{myDebug( << "_______ emitting statEntry("<&1 | grep OpenSSH > /dev/null"); #ifdef Q_OS_WIN - sshPath = strdup(QFile::encodeName(KStandardDirs::findExe("plink"))); + sshPath = strdup(QFile::encodeName(QStandardPaths::findExecutable("plink"))); #else sshPath = strdup(QFile::encodeName(QStandardPaths::findExecutable("ssh"))); #endif @@ -279,7 +262,7 @@ fishProtocol::~fishProtocol() { - myDebug( << "fishProtocol::~fishProtocol()" << endl); + myDebug( << "fishProtocol::~fishProtocol()"); shutdownConnection(true); } @@ -299,15 +282,15 @@ infoMessage(i18n("Connecting...")); - myDebug( << "connecting to: " << connectionUser << "@" << connectionHost << ":" << connectionPort << endl); + myDebug( << "connecting to: " << connectionUser << "@" << connectionHost << ":" << connectionPort); sendCommand(FISH_FISH); sendCommand(FISH_VER); if (connectionStart()) { error(ERR_COULD_NOT_CONNECT,connectionHost); shutdownConnection(); return; }; - myDebug( << "subprocess is running" << endl); + myDebug( << "subprocess is running"); } // XXX Use KPty! XXX @@ -389,13 +372,13 @@ #ifndef Q_OS_WIN rc = open_pty_pair(fd); if (rc == -1) { - myDebug( << "socketpair failed, error: " << strerror(errno) << endl); + myDebug( << "socketpair failed, error: " << strerror(errno)); return true; } #endif if (!requestNetwork()) return true; - myDebug( << "Exec: " << (local ? suPath : sshPath) << " Port: " << connectionPort << " User: " << connectionUser << endl); + myDebug( << "Exec: " << (local ? suPath : sshPath) << " Port: " << connectionPort << " User: " << connectionUser); #ifdef Q_OS_WIN childPid = new KProcess(); childPid->setOutputChannelMode(KProcess::MergedChannels); @@ -434,7 +417,7 @@ #else childPid = fork(); if (childPid == -1) { - myDebug( << "fork failed, error: " << strerror(errno) << endl); + myDebug( << "fork failed, error: " << strerror(errno)); ::close(fd[0]); ::close(fd[1]); childPid = 0; @@ -491,7 +474,7 @@ execl(sshPath, "ssh", common_args); #undef common_args } - myDebug( << "could not exec! " << strerror(errno) << endl); + myDebug( << "could not exec! " << strerror(errno)); ::exit(-1); } ::close(fd[1]); @@ -515,7 +498,7 @@ if (rc < 0) { if (errno == EINTR) continue; - myDebug( << "select failed, rc: " << rc << ", error: " << strerror(errno) << endl); + myDebug( << "select failed, rc: " << rc << ", error: " << strerror(errno)); return true; } if (FD_ISSET(childFd, &wfds) && outBufPos >= 0) { @@ -529,7 +512,7 @@ else { if (errno == EINTR) continue; - myDebug( << "write failed, rc: " << rc << ", error: " << strerror(errno) << endl); + myDebug( << "write failed, rc: " << rc << ", error: " << strerror(errno)); outBufPos = -1; //return true; } @@ -550,7 +533,7 @@ } else { if (errno == EINTR) continue; - myDebug( << "read failed, rc: " << rc << ", error: " << strerror(errno) << endl); + myDebug( << "read failed, rc: " << rc << ", error: " << strerror(errno)); return true; } } @@ -571,7 +554,7 @@ #endif #if 0 QString debug = QString::fromLatin1(outBuf,outBufLen); - if (len > 0) myDebug( << "write request while old one is pending, throwing away input (" << outBufLen << "," << outBufPos << "," << debug.left(10) << "...)" << endl); + if (len > 0) myDebug( << "write request while old one is pending, throwing away input (" << outBufLen << "," << outBufPos << "," << debug.left(10) << "...)"); #endif return; } @@ -595,7 +578,7 @@ while (buf.length() && (buf[buf.length()-1] == ' ')) buf.truncate(buf.length()-1); - myDebug( << "establishing: got " << buf << endl); + myDebug( << "establishing: got " << buf); while (childPid && ((pos = buf.indexOf('\n')) >= 0 || buf.endsWith(':') || buf.endsWith('?'))) { pos++; @@ -616,46 +599,47 @@ thisFn += str; } else if (buf.endsWith(':')) { if (!redirectUser.isEmpty() && connectionUser != redirectUser) { - KUrl dest = url; - dest.setUser(redirectUser); - dest.setPass(redirectPass); + QUrl dest = url; + dest.setUserName(redirectUser); + dest.setPassword(redirectPass); redirection(dest); commandList.clear(); commandCodes.clear(); finished(); redirectUser = ""; redirectPass = ""; return -1; } else if (!connectionPassword.isEmpty()) { - myDebug( << "sending cpass" << endl); + myDebug( << "sending cpass"); connectionAuth.password = connectionPassword+ENDLINE; connectionPassword.clear(); // su does not like receiving a password directly after sending // the password prompt so we wait a while. if (local) sleep(1); writeChild(connectionAuth.password.toLatin1(),connectionAuth.password.length()); } else { - myDebug( << "sending mpass" << endl); + myDebug( << "sending mpass"); connectionAuth.prompt = thisFn+buf; if (local) connectionAuth.caption = i18n("Local Login"); else connectionAuth.caption = i18n("SSH Authentication"); if ((!firstLogin || !checkCachedAuthentication(connectionAuth))) { connectionAuth.password.clear(); // don't prefill - if ( !openPasswordDialog(connectionAuth)) { - error(ERR_USER_CANCELED,connectionHost); + int errorCode = openPasswordDialogV2(connectionAuth); + if (errorCode != 0) { + error(errorCode, connectionHost); shutdownConnection(); return -1; } } firstLogin = false; connectionAuth.password += ENDLINE; if (connectionAuth.username != connectionUser) { - KUrl dest = url; - dest.setUser(connectionAuth.username); - dest.setPass(connectionAuth.password); + QUrl dest = url; + dest.setUserName(connectionAuth.username); + dest.setPassword(connectionAuth.password); redirection(dest); if (isStat) { // FIXME: just a workaround for konq deficiencies redirectUser = connectionAuth.username; @@ -666,7 +650,7 @@ finished(); return -1; } - myDebug( << "sending pass" << endl); + myDebug( << "sending pass"); if (local) sleep(1); writeChild(connectionAuth.password.toLatin1(),connectionAuth.password.length()); @@ -689,7 +673,7 @@ } #endif else { - myDebug( << "unmatched case in initial handling! should not happen!" << endl); + myDebug( << "unmatched case in initial handling! should not happen!"); } #ifdef Q_OS_WIN if (buf.endsWith(QLatin1String("(y/n)"))) { @@ -725,7 +709,7 @@ if (host == connectionHost && port == connectionPort && user == connectionUser) return; - myDebug( << "setHost " << u << "@" << host << endl); + myDebug( << "setHost " << u << "@" << host); if (childPid) shutdownConnection(); @@ -748,7 +732,7 @@ it shouldn't send any response. */ void fishProtocol::closeConnection(){ - myDebug( << "closeConnection()" << endl); + myDebug( << "closeConnection()"); shutdownConnection(true); } @@ -793,7 +777,7 @@ */ bool fishProtocol::sendCommand(fish_command_type cmd, ...) { const fish_info &info = fishInfo[cmd]; - myDebug( << "queuing: cmd="<< cmd << "['" << info.command << "'](" << info.params <<"), alt=['" << info.alt << "'], lines=" << info.lines << endl); + myDebug( << "queuing: cmd="<< cmd << "['" << info.command << "'](" << info.params <<"), alt=['" << info.alt << "'], lines=" << info.lines); va_list list; va_start(list, cmd); @@ -806,7 +790,7 @@ while ((pos = rx.indexIn(arg,pos+2)) >= 0) { arg.replace(pos,0,QString("\\")); } - //myDebug( << "arg " << i << ": " << arg << endl); + //myDebug( << "arg " << i << ": " << arg); realCmd.append(" ").append(arg); realAlt.replace(QRegExp('%'+QString::number(i+1)),arg); } @@ -824,14 +808,14 @@ checks response string for result code, converting 000 and 001 appropriately */ int fishProtocol::handleResponse(const QString &str){ - myDebug( << "handling: " << str << endl); + myDebug( << "handling: " << str); if (str.startsWith(QLatin1String("### "))) { bool isOk = false; int result = str.mid(4,3).toInt(&isOk); if (!isOk) result = 500; if (result == 0) result = (errorCount != 0?500:200); if (result == 1) result = (errorCount != 0?500:100); - myDebug( << "result: " << result << ", errorCount: " << errorCount << endl); + myDebug( << "result: " << result << ", errorCount: " << errorCount); return result; } else { errorCount++; @@ -866,7 +850,7 @@ if (month > currentMonth + 1) year--; dt.time().setHMS(timeyearStr.left(pos).toInt(),timeyearStr.mid(pos+1).toInt(),0); } - dt.date().setYMD(year,month,day); + dt.date().setDate(year,month,day); return dt.toTime_t(); } @@ -896,7 +880,7 @@ redirection(url); break; case FISH_LIST: - myDebug( << "listReason: " << static_cast(listReason) << endl); + myDebug( << "listReason: " << static_cast(listReason)); /* Fall through */ case FISH_STAT: if (line.length() > 0) { @@ -939,12 +923,12 @@ } else if (line[1] == 'p') { udsType = S_IFIFO; } else { - myDebug( << "unknown file type: " << line[1].cell() << endl); + myDebug( << "unknown file type: " << line[1].cell()); errorCount++; break; } } - //myDebug( << "file type: " << udsType << endl); + //myDebug( << "file type: " << udsType); long long accessVal = 0; if (line[2] == 'r') accessVal |= S_IRUSR; @@ -1017,11 +1001,11 @@ // By default, the mimetype comes from the extension // We'll use the file(1) result only as fallback [like the rest of KDE does] { - KUrl kurl("fish://host/"); - kurl.setFileName(thisFn); // properly encode special chars - KMimeType::Ptr mime = KMimeType::findByUrl(kurl, udsType); - if ( mime->name() != KMimeType::defaultMimeType() ) - udsMime = mime->name(); + QUrl kurl("fish://host/"+thisFn); + QMimeDatabase db; + QMimeType mime = db.mimeTypeForUrl(kurl); + if ( !mime.isDefault() ) + udsMime = mime.name(); } errorCount--; break; @@ -1065,13 +1049,13 @@ case FISH_RETR: if (line.length() == 0) { - error(ERR_IS_DIRECTORY,url.prettyUrl()); + error(ERR_IS_DIRECTORY,url.toDisplayString()); recvLen = 0; break; } recvLen = line.toLongLong(&isOk); if (!isOk) { - error(ERR_COULD_NOT_READ,url.prettyUrl()); + error(ERR_COULD_NOT_READ,url.toDisplayString()); shutdownConnection(); break; } @@ -1088,9 +1072,9 @@ recvLen = 1024; /* fall through */ case FISH_RETR: - myDebug( << "reading " << recvLen << endl); + myDebug( << "reading " << recvLen); if (recvLen == -1) { - error(ERR_COULD_NOT_READ,url.prettyUrl()); + error(ERR_COULD_NOT_READ,url.toDisplayString()); shutdownConnection(); } else { rawRead = recvLen; @@ -1107,7 +1091,7 @@ case FISH_WRITE: case FISH_APPEND: rawWrite = sendLen; - //myDebug( << "sending " << sendLen << endl); + //myDebug( << "sending " << sendLen); writeChild(NULL,0); break; default : break; @@ -1117,11 +1101,11 @@ case FISH_STOR: case FISH_WRITE: case FISH_APPEND: - error(ERR_COULD_NOT_WRITE,url.prettyUrl()); + error(ERR_COULD_NOT_WRITE,url.toDisplayString()); shutdownConnection(); break; case FISH_RETR: - error(ERR_COULD_NOT_READ,url.prettyUrl()); + error(ERR_COULD_NOT_READ,url.toDisplayString()); shutdownConnection(); break; case FISH_READ: @@ -1134,7 +1118,7 @@ } else { - error(ERR_COULD_NOT_READ,url.prettyUrl()); + error(ERR_COULD_NOT_READ,url.toDisplayString()); shutdownConnection(); } break; @@ -1145,46 +1129,46 @@ break; case FISH_PWD: case FISH_CWD: - error(ERR_CANNOT_ENTER_DIRECTORY,url.prettyUrl()); + error(ERR_CANNOT_ENTER_DIRECTORY,url.toDisplayString()); break; case FISH_LIST: - myDebug( << "list error. reason: " << static_cast(listReason) << endl); - if (listReason == LIST) error(ERR_CANNOT_ENTER_DIRECTORY,url.prettyUrl()); + myDebug( << "list error. reason: " << static_cast(listReason)); + if (listReason == LIST) error(ERR_CANNOT_ENTER_DIRECTORY,url.toDisplayString()); else if (listReason == CHECK) { checkExist = false; finished(); } break; case FISH_STAT: - error(ERR_DOES_NOT_EXIST,url.prettyUrl()); + error(ERR_DOES_NOT_EXIST,url.toDisplayString()); udsStatEntry.clear(); break; case FISH_CHMOD: - error(ERR_CANNOT_CHMOD,url.prettyUrl()); + error(ERR_CANNOT_CHMOD,url.toDisplayString()); break; case FISH_CHOWN: case FISH_CHGRP: - error(ERR_ACCESS_DENIED,url.prettyUrl()); + error(ERR_ACCESS_DENIED,url.toDisplayString()); break; case FISH_MKD: if ( rc == 501 ) - error(ERR_DIR_ALREADY_EXIST,url.prettyUrl()); + error(ERR_DIR_ALREADY_EXIST,url.toDisplayString()); else - error(ERR_COULD_NOT_MKDIR,url.prettyUrl()); + error(ERR_COULD_NOT_MKDIR,url.toDisplayString()); break; case FISH_RMD: - error(ERR_COULD_NOT_RMDIR,url.prettyUrl()); + error(ERR_COULD_NOT_RMDIR,url.toDisplayString()); break; case FISH_DELE: - error(ERR_CANNOT_DELETE,url.prettyUrl()); + error(ERR_CANNOT_DELETE,url.toDisplayString()); break; case FISH_RENAME: - error(ERR_CANNOT_RENAME,url.prettyUrl()); + error(ERR_CANNOT_RENAME,url.toDisplayString()); break; case FISH_COPY: case FISH_LINK: case FISH_SYMLINK: - error(ERR_COULD_NOT_WRITE,url.prettyUrl()); + error(ERR_COULD_NOT_WRITE,url.toDisplayString()); break; default : break; } @@ -1194,7 +1178,7 @@ connected(); } else if (fishCommand == FISH_LIST) { if (listReason == CHECK && !checkOverwrite && checkExist) { - error(ERR_FILE_ALREADY_EXIST,url.prettyUrl()); + error(ERR_FILE_ALREADY_EXIST,url.toDisplayString()); return; // Don't call finished! } } else if (fishCommand == FISH_STAT) { @@ -1224,17 +1208,17 @@ if (writeReady) { writeReady = false; - //myDebug( << "Writing: " << qlist.first().mid(0,qlist.first().indexOf('\n')) << endl); - myDebug( << "Writing: " << qlist.first() << endl); - myDebug( << "---------" << endl); + //myDebug( << "Writing: " << qlist.first().mid(0,qlist.first().indexOf('\n'))); + myDebug( << "Writing: " << qlist.first()); + myDebug( << "---------"); writeChild((const char *)qlist.first(), qlist.first().length()); } } void fishProtocol::sent() { if (rawWrite > 0) { - myDebug( << "writing raw: " << rawData.size() << "/" << rawWrite << endl); + myDebug( << "writing raw: " << rawData.size() << "/" << rawWrite); writeChild(rawData.data(),(rawWrite > rawData.size()?rawData.size():rawWrite)); rawWrite -= rawData.size(); if (rawWrite > 0) { @@ -1256,9 +1240,9 @@ if (qlist.count() == 0) { writeReady = true; } else { - //myDebug( << "Writing: " << qlist.first().mid(0,qlist.first().indexOf('\n')) << endl); - myDebug( << "Writing: " << qlist.first() << endl); - myDebug( << "---------" << endl); + //myDebug( << "Writing: " << qlist.first().mid(0,qlist.first().indexOf('\n'))); + myDebug( << "Writing: " << qlist.first()); + myDebug( << "---------"); writeChild((const char *)qlist.first(),qlist.first().length()); } } @@ -1270,7 +1254,7 @@ if (buflen <= 0) break; if (rawRead > 0) { - myDebug( << "processedSize " << dataRead << ", len " << buflen << "/" << rawRead << endl); + myDebug( << "processedSize " << dataRead << ", len " << buflen << "/" << rawRead); int dataSize = (rawRead > buflen?buflen:rawRead); if (!mimeTypeSent) { @@ -1284,10 +1268,12 @@ mimeBuffer.resize(dataRead); if (dataRead < (int)mimeBuffer.size()) { - myDebug( << "wait for more" << endl); + myDebug( << "wait for more"); break; } - sendmimeType(KMimeType::findByNameAndContent(url.path(), mimeBuffer)->name()); + + QMimeDatabase db; + sendmimeType(db.mimeTypeForFileNameAndData(url.path(), mimeBuffer).name()); mimeTypeSent = true; if (fishCommand != FISH_READ) { totalSize(dataRead + rawRead); @@ -1339,13 +1325,13 @@ } /** get a file */ void fishProtocol::get(const QUrl& u){ - myDebug( << "@@@@@@@@@ get " << u << endl); + myDebug( << "@@@@@@@@@ get " << u); setHostInternal(u); url = u; openConnection(); if (!isLoggedIn) return; - url.cleanPath(); - if (!url.hasPath()) { + url = url.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { recvLen = -1; @@ -1356,14 +1342,14 @@ /** put a file */ void fishProtocol::put(const QUrl& u, int permissions, KIO::JobFlags flags) { - myDebug( << "@@@@@@@@@ put " << u << " " << permissions << " " << (flags & KIO::Overwrite) << " " /* << resume */ << endl); + myDebug( << "@@@@@@@@@ put " << u << " " << permissions << " " << (flags & KIO::Overwrite) << " " /* << resume */); setHostInternal(u); url = u; openConnection(); if (!isLoggedIn) return; - url.cleanPath(); - if (!url.hasPath()) { + url = url.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { putPerm = permissions; @@ -1398,7 +1384,7 @@ commandList.erase(commandList.begin()); commandCodes.erase(commandCodes.begin()); } else { - myDebug( << "_______ emitting finished()" << endl); + myDebug( << "_______ emitting finished()"); SlaveBase::finished(); isRunning = false; } @@ -1408,7 +1394,7 @@ void fishProtocol::error(int type, const QString &detail) { commandList.clear(); commandCodes.clear(); - myDebug( << "ERROR: " << type << " - " << detail << endl); + myDebug( << "ERROR: " << type << " - " << detail); SlaveBase::error(type,detail); isRunning = false; } @@ -1441,7 +1427,7 @@ if (rc < 0) { if (errno == EINTR) continue; - myDebug( << "select failed, rc: " << rc << ", error: " << strerror(errno) << endl); + myDebug( << "select failed, rc: " << rc << ", error: " << strerror(errno)); error(ERR_CONNECTION_BROKEN,connectionHost); shutdownConnection(); return; @@ -1468,7 +1454,7 @@ #ifndef Q_OS_WIN if (errno == EINTR) continue; - myDebug( << "write failed, rc: " << rc << ", error: " << strerror(errno) << endl); + myDebug( << "write failed, rc: " << rc << ", error: " << strerror(errno)); #else myDebug( << "write failed, rc: " << rc); #endif @@ -1489,17 +1475,17 @@ else if (childPid->waitForReadyRead(1000)) { rc = childPid->read(buf + offset, sizeof(buf) - offset); #endif - //myDebug( << "read " << rc << " bytes" << endl); + //myDebug( << "read " << rc << " bytes"); if (rc > 0) { int noff = received(buf, rc + offset); if (noff > 0) memmove(buf, buf + offset + rc - noff, noff); - //myDebug( << "left " << noff << " bytes: " << QString::fromLatin1(buf,offset) << endl); + //myDebug( << "left " << noff << " bytes: " << QString::fromLatin1(buf,offset)); offset = noff; } else { #ifndef Q_OS_WIN if (errno == EINTR) continue; - myDebug( << "read failed, rc: " << rc << ", error: " << strerror(errno) << endl); + myDebug( << "read failed, rc: " << rc << ", error: " << strerror(errno)); #else myDebug( << "read failed, rc: " << rc ); #endif @@ -1516,30 +1502,30 @@ /** stat a file */ void fishProtocol::stat(const QUrl& u){ - myDebug( << "@@@@@@@@@ stat " << u << endl); + myDebug( << "@@@@@@@@@ stat " << u); setHostInternal(u); url = u; isStat = true; // FIXME: just a workaround for konq deficiencies openConnection(); isStat = false; // FIXME: just a workaround for konq deficiencies if (!isLoggedIn) return; - url.cleanPath(); - if (!url.hasPath()) { + url = url.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { - sendCommand(FISH_STAT,E(url.path(KUrl::RemoveTrailingSlash))); + sendCommand(FISH_STAT,E(url.adjusted(QUrl::StripTrailingSlash).path())); } run(); } /** find mimetype for a file */ void fishProtocol::mimetype(const QUrl& u){ - myDebug( << "@@@@@@@@@ mimetype " << u << endl); + myDebug( << "@@@@@@@@@ mimetype " << u); setHostInternal(u); url = u; openConnection(); if (!isLoggedIn) return; - url.cleanPath(); - if (!url.hasPath()) { + url = url.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { recvLen = 1024; @@ -1549,13 +1535,13 @@ } /** list a directory */ void fishProtocol::listDir(const QUrl& u){ - myDebug( << "@@@@@@@@@ listDir " << u << endl); + myDebug( << "@@@@@@@@@ listDir " << u); setHostInternal(u); url = u; openConnection(); if (!isLoggedIn) return; - url.cleanPath(); - if (!url.hasPath()) { + url = url.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { listReason = LIST; @@ -1565,13 +1551,13 @@ } /** create a directory */ void fishProtocol::mkdir(const QUrl& u, int permissions) { - myDebug( << "@@@@@@@@@ mkdir " << u << " " << permissions << endl); + myDebug( << "@@@@@@@@@ mkdir " << u << " " << permissions); setHostInternal(u); url = u; openConnection(); if (!isLoggedIn) return; - url.cleanPath(); - if (!url.hasPath()) { + url = url.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { sendCommand(FISH_MKD,E(url.path())); @@ -1581,19 +1567,19 @@ } /** rename a file */ void fishProtocol::rename(const QUrl& s, const QUrl& d, KIO::JobFlags flags) { - myDebug( << "@@@@@@@@@ rename " << s << " " << d << " " << (flags & KIO::Overwrite) << endl); + myDebug( << "@@@@@@@@@ rename " << s << " " << d << " " << (flags & KIO::Overwrite)); if (s.host() != d.host() || s.port() != d.port() || s.userName() != d.userName()) { error(ERR_UNSUPPORTED_ACTION,s.toDisplayString()); return; } setHostInternal(s); url = d; openConnection(); if (!isLoggedIn) return; - KUrl src = s; - url.cleanPath(); - src.cleanPath(); - if (!url.hasPath()) { + QUrl src = s; + url = url.adjusted(QUrl::NormalizePathSegments); + src = src.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { if (!(flags & KIO::Overwrite)) { @@ -1607,13 +1593,13 @@ } /** create a symlink */ void fishProtocol::symlink(const QString& target, const QUrl& u, KIO::JobFlags flags) { - myDebug( << "@@@@@@@@@ symlink " << target << " " << u << " " << (flags & KIO::Overwrite) << endl); + myDebug( << "@@@@@@@@@ symlink " << target << " " << u << " " << (flags & KIO::Overwrite)); setHostInternal(u); url = u; openConnection(); if (!isLoggedIn) return; - url.cleanPath(); - if (!url.hasPath()) { + url = url.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { if (!(flags & KIO::Overwrite)) { @@ -1627,35 +1613,35 @@ } /** change file permissions */ void fishProtocol::chmod(const QUrl& u, int permissions){ - myDebug( << "@@@@@@@@@ chmod " << u << " " << permissions << endl); + myDebug( << "@@@@@@@@@ chmod " << u << " " << permissions); setHostInternal(u); url = u; openConnection(); if (!isLoggedIn) return; - url.cleanPath(); - if (!url.hasPath()) { + url = url.adjusted(QUrl::NormalizePathSegments); + if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { if (permissions > -1) sendCommand(FISH_CHMOD,E(QString::number(permissions,8)),E(url.path())); } run(); } /** copies a file */ void fishProtocol::copy(const QUrl &s, const QUrl &d, int permissions, KIO::JobFlags flags) { - myDebug( << "@@@@@@@@@ copy " << s << " " << d << " " << permissions << " " << (flags & KIO::Overwrite) << endl); + myDebug( << "@@@@@@@@@ copy " << s << " " << d << " " << permissions << " " << (flags & KIO::Overwrite)); if (s.host() != d.host() || s.port() != d.port() || s.userName() != d.userName()) { error(ERR_UNSUPPORTED_ACTION,s.toDisplayString()); return; } - //myDebug( << s << endl << d << endl); + //myDebug( << s << endl << d); setHostInternal(s); url = d; openConnection(); if (!isLoggedIn) return; - KUrl src = s; - url.cleanPath(); - src.cleanPath(); - if (!src.hasPath()) { + QUrl src = s; + url = url.adjusted(QUrl::NormalizePathSegments); + src = src.adjusted(QUrl::NormalizePathSegments); + if (src.path().isEmpty()) { sendCommand(FISH_PWD); } else { if (!(flags & KIO::Overwrite)) { @@ -1670,12 +1656,12 @@ } /** removes a file or directory */ void fishProtocol::del(const QUrl &u, bool isFile){ - myDebug( << "@@@@@@@@@ del " << u << " " << isFile << endl); + myDebug( << "@@@@@@@@@ del " << u << " " << isFile); setHostInternal(u); url = u; openConnection(); if (!isLoggedIn) return; - url.cleanPath(); + url = url.adjusted(QUrl::NormalizePathSegments); if (url.path().isEmpty()) { sendCommand(FISH_PWD); } else { @@ -1693,12 +1679,12 @@ switch (tmp) { case FISH_EXEC_CMD: // SSH EXEC { - KUrl u; + QUrl u; QString command; QString tempfile; stream >> u; stream >> command; - myDebug( << "@@@@@@@@@ exec " << u << " " << command << endl); + myDebug( << "@@@@@@@@@ exec " << u << " " << command); setHostInternal(u); url = u; openConnection(); @@ -1715,7 +1701,7 @@ } /** report status */ void fishProtocol::slave_status() { - myDebug( << "@@@@@@@@@ slave_status" << endl); + myDebug( << "@@@@@@@@@ slave_status"); if (childPid > 0) slaveStatus(connectionHost,isLoggedIn); else diff --git a/fish/tests/CMakeLists.txt b/fish/tests/CMakeLists.txt --- a/fish/tests/CMakeLists.txt +++ b/fish/tests/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable( copytester main.cpp copytester.cpp) -target_link_libraries( copytester KF5::KDELibs4Support KF5::KIOCore ) +target_link_libraries( copytester KF5::KIOCore ) install( TARGETS copytester ${INSTALL_TARGETS_DEFAULT_ARGS} )