Commit 28593aef authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port away from ERR_SLAVE_DEFINED

parent 53f575d7
Pipeline #199451 passed with stage
in 2 minutes and 44 seconds
......@@ -6,9 +6,10 @@
#include "kio_archivebase.h"
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <kio_version.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <KIO/StatJob>
......@@ -269,9 +270,12 @@ void ArchiveProtocolBase::listDir( const QUrl & url )
{
// If we cannot open, it might be a problem with the archive header (e.g. unsupported format)
// Therefore give a more specific error message
error( KIO::ERR_SLAVE_DEFINED,
i18n( "Could not open the file, probably due to an unsupported file format.\n%1",
url.toDisplayString() ) );
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED,
#else
error(KIO::ERR_SLAVE_DEFINED,
#endif
i18n("Could not open the file, probably due to an unsupported file format.\n%1", url.toDisplayString()));
return;
}
else if ( errorNum != ERR_IS_DIRECTORY )
......@@ -363,9 +367,12 @@ void ArchiveProtocolBase::stat( const QUrl & url )
{
// If we cannot open, it might be a problem with the archive header (e.g. unsupported format)
// Therefore give a more specific error message
error( KIO::ERR_SLAVE_DEFINED,
i18n( "Could not open the file, probably due to an unsupported file format.\n%1",
url.toDisplayString() ) );
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED,
#else
error(KIO::ERR_SLAVE_DEFINED,
#endif
i18n("Could not open the file, probably due to an unsupported file format.\n%1", url.toDisplayString()));
return;
}
else if ( errorNum != ERR_IS_DIRECTORY )
......@@ -450,9 +457,12 @@ void ArchiveProtocolBase::get( const QUrl & url )
{
// If we cannot open, it might be a problem with the archive header (e.g. unsupported format)
// Therefore give a more specific error message
error( KIO::ERR_SLAVE_DEFINED,
i18n( "Could not open the file, probably due to an unsupported file format.\n%1",
url.toDisplayString() ) );
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED,
#else
error(KIO::ERR_SLAVE_DEFINED,
#endif
i18n("Could not open the file, probably due to an unsupported file format.\n%1", url.toDisplayString()));
return;
}
else
......@@ -501,9 +511,12 @@ void ArchiveProtocolBase::get( const QUrl & url )
if (!io)
{
error( KIO::ERR_SLAVE_DEFINED,
i18n( "The archive file could not be opened, perhaps because the format is unsupported.\n%1",
url.toDisplayString() ) );
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED,
#else
error(KIO::ERR_SLAVE_DEFINED,
#endif
i18n("The archive file could not be opened, perhaps because the format is unsupported.\n%1", url.toDisplayString()));
return;
}
......
......@@ -14,6 +14,7 @@
#include <qtextdocument.h>
#include <qurlquery.h>
#include <kio_version.h>
#include <kshell.h>
#include <KLocalizedString>
......@@ -184,7 +185,12 @@ void BookmarksProtocol::get( const QUrl& url )
auto job = new KIO::ApplicationLauncherJob(bookmarksKCM);
job->start();
} else {
error(KIO::ERR_SLAVE_DEFINED, i18n("Could not find bookmarks config"));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED,
#else
error(KIO::ERR_SLAVE_DEFINED,
#endif
i18n("Could not find bookmarks config"));
}
echoHead("bookmarks:/");
} else if (path == "/editbookmarks") {
......@@ -193,7 +199,12 @@ void BookmarksProtocol::get( const QUrl& url )
auto job = new KIO::ApplicationLauncherJob(keditbookmarks);
job->start();
} else {
error(KIO::ERR_SLAVE_DEFINED, i18n("Could not find bookmarks editor"));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED,
#else
error(KIO::ERR_SLAVE_DEFINED,
#endif
i18n("Could not find bookmarks editor"));
}
echoHead("bookmarks:/");
} else if (path.indexOf(regexp, 0, &rmatch) >= 0) {
......
......@@ -16,16 +16,17 @@
#include "fish.h"
#include <config-runtime.h>
#include <config-fish.h>
#include <QFile>
#include <QDateTime>
#include <QRegularExpression>
#include <QCoreApplication>
#include <QDateTime>
#include <QDebug>
#include <QStandardPaths>
#include <QMimeType>
#include <QFile>
#include <QMimeDatabase>
#include <QMimeType>
#include <QRegularExpression>
#include <QStandardPaths>
#include <config-fish.h>
#include <config-runtime.h>
#include <kio_version.h>
#include <stdlib.h>
#include <sys/resource.h>
......@@ -1127,7 +1128,11 @@ void fishProtocol::manageConnection(const QString &l) {
break;
case FISH_FISH:
case FISH_VER:
error(ERR_SLAVE_DEFINED,line);
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED, line);
#else
error(KIO::ERR_SLAVE_DEFINED, line);
#endif
shutdownConnection();
break;
case FISH_PWD:
......
......@@ -2,6 +2,7 @@
#include "info.h"
#include <kio_version.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
......@@ -51,7 +52,11 @@ InfoProtocol::InfoProtocol( const QByteArray &pool, const QByteArray &app )
qCCritical(LOG_KIO_INFO) << "Cannot locate files for HTML conversion," << qPrintable(missingFiles.join(' '));
QString errorStr = i18n("Unable to locate files which are necessary to run this service:<br>%1<br>"
"Please check your software installation.", missingFiles.join(' '));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED, errorStr);
#else
error(KIO::ERR_SLAVE_DEFINED, errorStr);
#endif
exit();
}
......
......@@ -10,6 +10,7 @@
#include "kio_mtp.h"
#include "kio_mtp_debug.h"
#include <kio_version.h>
// #include <KComponentData>
#include <QTemporaryFile>
#include <QFileInfo>
......@@ -220,7 +221,14 @@ void MTPSlave::listDir(const QUrl &url)
finished();
qCDebug(LOG_KIO_MTP) << "[SUCCESS] :: Storage media:" << storages.count();
} else {
error(ERR_SLAVE_DEFINED, i18nc("Message shown when attempting to access an MTP device that is not fully accessible yet", "Could not access device. Make sure it is unlocked, and tap \"Allow\" on the popup on its screen. If that does not work, make sure MTP is enabled in its USB connection settings."));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED,
#else
error(KIO::ERR_SLAVE_DEFINED,
#endif
i18nc("Message shown when attempting to access an MTP device that is not fully accessible yet",
"Could not access device. Make sure it is unlocked, and tap \"Allow\" on the popup on its screen. If that does not work, make sure "
"MTP is enabled in its USB connection settings."));
}
} else {
// list files and folders
......
......@@ -7,12 +7,12 @@
*/
#include "kio_sftp.h"
#include <config-runtime.h>
#include <array>
#include <cerrno>
#include <config-runtime.h>
#include <cstring>
#include <kio_version.h>
#include <memory>
#include <array>
#include <QCoreApplication>
#include <QDateTime>
......@@ -620,7 +620,11 @@ Result SFTPWorker::sftpOpenConnection(const AuthInfo &info)
if (rc < 0) {
const QString errorString = QString::fromUtf8(ssh_get_error(mSession));
closeConnection();
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return Result::fail(KIO::ERR_WORKER_DEFINED, errorString);
#else
return Result::fail(KIO::ERR_SLAVE_DEFINED, errorString);
#endif
}
return Result::pass();
......@@ -648,12 +652,20 @@ Q_REQUIRED_RESULT ServerKeyInspection fingerpint(ssh_session session)
});
int rc = ssh_get_server_publickey(session, &srv_pubkey);
if (rc < 0) {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return inspection.withResult(Result::fail(KIO::ERR_WORKER_DEFINED, QString::fromUtf8(ssh_get_error(session))));
#else
return inspection.withResult(Result::fail(KIO::ERR_SLAVE_DEFINED, QString::fromUtf8(ssh_get_error(session))));
#endif
}
const char *srv_pubkey_type = ssh_key_type_to_char(ssh_key_type(srv_pubkey));
if (srv_pubkey_type == nullptr) {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return inspection.withResult(Result::fail(KIO::ERR_WORKER_DEFINED, i18n("Could not get server public key type name")));
#else
return inspection.withResult(Result::fail(KIO::ERR_SLAVE_DEFINED, i18n("Could not get server public key type name")));
#endif
}
inspection.serverPublicKeyType = QByteArray(srv_pubkey_type);
......@@ -666,7 +678,11 @@ Q_REQUIRED_RESULT ServerKeyInspection fingerpint(ssh_session session)
&hash,
&hlen);
if (rc != SSH_OK) {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return inspection.withResult(Result::fail(KIO::ERR_WORKER_DEFINED, i18n("Could not create hash from server public key")));
#else
return inspection.withResult(Result::fail(KIO::ERR_SLAVE_DEFINED, i18n("Could not create hash from server public key")));
#endif
}
char *fingerprint = ssh_get_fingerprint_hash(SSH_PUBLICKEY_HASH_SHA256, hash, hlen);
......@@ -675,7 +691,12 @@ Q_REQUIRED_RESULT ServerKeyInspection fingerpint(ssh_session session)
});
if (fingerprint == nullptr) {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return inspection.withResult(Result::fail(KIO::ERR_WORKER_DEFINED, i18n("Could not create hash from server public key")));
return inspection.withResult(Result::fail(KIO::ERR_WORKER_DEFINED, i18n("Could not create fingerprint for server public key")));
#else
return inspection.withResult(Result::fail(KIO::ERR_SLAVE_DEFINED, i18n("Could not create fingerprint for server public key")));
#endif
}
inspection.fingerprint = fingerprint;
......@@ -743,7 +764,11 @@ Result SFTPWorker::openConnectionWithoutCloseOnError()
"%2",
serverPublicKeyType,
QString::fromUtf8(ssh_get_error(mSession)));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return Result::fail(KIO::ERR_WORKER_DEFINED, errorString);
#else
return Result::fail(KIO::ERR_SLAVE_DEFINED, errorString);
#endif
}
case SSH_KNOWN_HOSTS_CHANGED: {
const QString errorString = i18n("The host key for the server %1 has changed.\n"
......@@ -756,7 +781,11 @@ Result SFTPWorker::openConnectionWithoutCloseOnError()
serverPublicKeyType,
fingerprint,
QString::fromUtf8(ssh_get_error(mSession)));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return Result::fail(KIO::ERR_WORKER_DEFINED, errorString);
#else
return Result::fail(KIO::ERR_SLAVE_DEFINED, errorString);
#endif
}
case SSH_KNOWN_HOSTS_NOT_FOUND:
case SSH_KNOWN_HOSTS_UNKNOWN: {
......@@ -782,7 +811,12 @@ Result SFTPWorker::openConnectionWithoutCloseOnError()
break;
}
case SSH_KNOWN_HOSTS_ERROR:
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return Result::fail(KIO::ERR_WORKER_DEFINED, QString::fromUtf8(ssh_get_error(mSession)));
#else
return Result::fail(KIO::ERR_SLAVE_DEFINED, QString::fromUtf8(ssh_get_error(mSession)));
#endif
case SSH_KNOWN_HOSTS_OK:
break;
}
......
......@@ -7,6 +7,7 @@
#include "kio_smb.h"
#include "smburl.h"
#include <kio_version.h>
#include <kdnssd_version.h>
#include <KDNSSD/RemoteService>
......@@ -277,18 +278,31 @@ SMBSlave::SMBError SMBSlave::errnumToKioError(const SMBUrl &url, const int errNu
switch (errNum) {
case ENOENT:
if (url.getType() == SMBURLTYPE_ENTIRE_NETWORK)
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return SMBError{ERR_WORKER_DEFINED, i18n("Unable to find any workgroups in your local network. This might be caused by an enabled firewall.")};
#else
return SMBError {ERR_SLAVE_DEFINED, i18n("Unable to find any workgroups in your local network. This might be caused by an enabled firewall.")};
#endif
else
return SMBError {ERR_DOES_NOT_EXIST, url.toDisplayString()};
#ifdef ENOMEDIUM
case ENOMEDIUM:
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return SMBError{ERR_WORKER_DEFINED, i18n("No media in device for %1", url.toDisplayString())};
#else
return SMBError {ERR_SLAVE_DEFINED, i18n("No media in device for %1", url.toDisplayString())};
#endif
#endif
#ifdef EHOSTDOWN
case EHOSTDOWN:
#endif
case ECONNREFUSED:
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return SMBError{ERR_WORKER_DEFINED, i18n("Could not connect to host for %1", url.toDisplayString())};
#else
return SMBError {ERR_SLAVE_DEFINED, i18n("Could not connect to host for %1", url.toDisplayString())};
#endif
case ENOTDIR:
return SMBError {ERR_CANNOT_ENTER_DIRECTORY, url.toDisplayString()};
case EFAULT:
......@@ -300,13 +314,21 @@ SMBSlave::SMBError SMBSlave::errnumToKioError(const SMBUrl &url, const int errNu
case EIO:
case ENETUNREACH:
if (url.getType() == SMBURLTYPE_ENTIRE_NETWORK || url.getType() == SMBURLTYPE_WORKGROUP_OR_SERVER)
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return SMBError{ERR_WORKER_DEFINED, i18n("Error while connecting to server responsible for %1", url.toDisplayString())};
#else
return SMBError {ERR_SLAVE_DEFINED, i18n("Error while connecting to server responsible for %1", url.toDisplayString())};
#endif
else
return SMBError {ERR_CONNECTION_BROKEN, url.toDisplayString()};
case ENOMEM:
return SMBError {ERR_OUT_OF_MEMORY, url.toDisplayString()};
case ENODEV:
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return SMBError{ERR_WORKER_DEFINED, i18n("Share could not be found on given server")};
#else
return SMBError {ERR_SLAVE_DEFINED, i18n("Share could not be found on given server")};
#endif
case EBADF:
return SMBError {ERR_INTERNAL, i18n("Bad file descriptor")};
case ETIMEDOUT:
......@@ -315,10 +337,18 @@ SMBSlave::SMBError SMBSlave::errnumToKioError(const SMBUrl &url, const int errNu
return SMBError {ERR_CANNOT_RMDIR, url.toDisplayString()};
#ifdef ENOTUNIQ
case ENOTUNIQ:
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
return SMBError
{
ERR_WORKER_DEFINED,
#else
return SMBError {ERR_SLAVE_DEFINED,
i18n("The given name could not be resolved to a unique server. "
"Make sure your network is setup without any name conflicts "
"between names used by Windows and by UNIX name resolution.")};
#endif
i18n(
"The given name could not be resolved to a unique server. "
"Make sure your network is setup without any name conflicts "
"between names used by Windows and by UNIX name resolution.")
};
#endif
case ECONNABORTED:
return SMBError {ERR_CONNECTION_BROKEN, url.host()};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment