Portaway from ERR_SLAVE_DEFINED

wilder-5.26
Ömer Fadıl Usta 4 years ago
parent 6ee4f674e7
commit 107e5c235a
  1. 57
      kcms/kfontinst/kio/KioFonts.cpp
  2. 6
      kioslave/applications/kio_applications.cpp

@ -27,6 +27,7 @@
#include <pwd.h> #include <pwd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <kio_version.h>
static constexpr int s_MAX_IPC_SIZE = 1024 * 32; static constexpr int s_MAX_IPC_SIZE = 1024 * 32;
@ -202,7 +203,15 @@ void CKioFonts::put(const QUrl &url, int /*permissions*/, KIO::JobFlags /*flags*
qCDebug(KCM_KFONTINST_KIO) << url; qCDebug(KCM_KFONTINST_KIO) << url;
QStringList pathList(url.adjusted(QUrl::StripTrailingSlash).path().split(QLatin1Char('/'), Qt::SkipEmptyParts)); QStringList pathList(url.adjusted(QUrl::StripTrailingSlash).path().split(QLatin1Char('/'), Qt::SkipEmptyParts));
EFolder folder(getFolder(pathList)); EFolder folder(getFolder(pathList));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
if (!Misc::root() && FOLDER_ROOT == folder) {
error(KIO::ERR_WORKER_DEFINED, i18n("Can only install fonts to either \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString()));
} else if (Misc::isPackage(url.fileName())) {
error(KIO::ERR_WORKER_DEFINED,
i18n("You cannot install a fonts package directly.\n"
"Please extract %1, and install the components individually.",
url.toDisplayString()));
#else
if (!Misc::root() && FOLDER_ROOT == folder) { if (!Misc::root() && FOLDER_ROOT == folder) {
error(KIO::ERR_SLAVE_DEFINED, i18n("Can only install fonts to either \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString())); error(KIO::ERR_SLAVE_DEFINED, i18n("Can only install fonts to either \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString()));
} else if (Misc::isPackage(url.fileName())) { } else if (Misc::isPackage(url.fileName())) {
@ -210,6 +219,7 @@ void CKioFonts::put(const QUrl &url, int /*permissions*/, KIO::JobFlags /*flags*
i18n("You cannot install a fonts package directly.\n" i18n("You cannot install a fonts package directly.\n"
"Please extract %1, and install the components individually.", "Please extract %1, and install the components individually.",
url.toDisplayString())); url.toDisplayString()));
#endif
} else { } else {
if (!m_tempDir) { if (!m_tempDir) {
m_tempDir = new QTemporaryDir(QDir::tempPath() + QString::fromLatin1("/kio_fonts_") + QString::number(getpid())); m_tempDir = new QTemporaryDir(QDir::tempPath() + QString::fromLatin1("/kio_fonts_") + QString::number(getpid()));
@ -435,12 +445,20 @@ void CKioFonts::get(const QUrl &url)
void CKioFonts::copy(const QUrl &, const QUrl &, int, KIO::JobFlags) void CKioFonts::copy(const QUrl &, const QUrl &, int, KIO::JobFlags)
{ {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED, i18n("Cannot copy fonts"));
#else
error(KIO::ERR_SLAVE_DEFINED, i18n("Cannot copy fonts")); error(KIO::ERR_SLAVE_DEFINED, i18n("Cannot copy fonts"));
#endif
} }
void CKioFonts::rename(const QUrl &, const QUrl &, KIO::JobFlags) void CKioFonts::rename(const QUrl &, const QUrl &, KIO::JobFlags)
{ {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED, i18n("Cannot move fonts"));
#else
error(KIO::ERR_SLAVE_DEFINED, i18n("Cannot move fonts")); error(KIO::ERR_SLAVE_DEFINED, i18n("Cannot move fonts"));
#endif
} }
void CKioFonts::del(const QUrl &url, bool isFile) void CKioFonts::del(const QUrl &url, bool isFile)
@ -450,10 +468,17 @@ void CKioFonts::del(const QUrl &url, bool isFile)
EFolder folder(getFolder(pathList)); EFolder folder(getFolder(pathList));
QString name(removeKnownExtension(url)); QString name(removeKnownExtension(url));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
if (!isFile) {
error(KIO::ERR_WORKER_DEFINED, i18n("Only fonts may be deleted."));
} else if (!Misc::root() && FOLDER_ROOT == folder) {
error(KIO::ERR_WORKER_DEFINED, i18n("Can only remove fonts from either \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString()));
#else
if (!isFile) { if (!isFile) {
error(KIO::ERR_SLAVE_DEFINED, i18n("Only fonts may be deleted.")); error(KIO::ERR_SLAVE_DEFINED, i18n("Only fonts may be deleted."));
} else if (!Misc::root() && FOLDER_ROOT == folder) { } else if (!Misc::root() && FOLDER_ROOT == folder) {
error(KIO::ERR_SLAVE_DEFINED, i18n("Can only remove fonts from either \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString())); error(KIO::ERR_SLAVE_DEFINED, i18n("Can only remove fonts from either \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString()));
#endif
} else if (!name.isEmpty()) { } else if (!name.isEmpty()) {
handleResp(m_interface->uninstall(name, Misc::root() || FOLDER_SYS == folder), name); handleResp(m_interface->uninstall(name, Misc::root() || FOLDER_SYS == folder), name);
} else { } else {
@ -480,7 +505,11 @@ void CKioFonts::stat(const QUrl &url)
} else if (FOLDER_SYS == folder || FOLDER_USER == folder) { } else if (FOLDER_SYS == folder || FOLDER_USER == folder) {
createUDSEntry(entry, folder); createUDSEntry(entry, folder);
} else { } else {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED, i18n("Please specify \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString()));
#else
error(KIO::ERR_SLAVE_DEFINED, i18n("Please specify \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString())); error(KIO::ERR_SLAVE_DEFINED, i18n("Please specify \"%1\" or \"%2\".", KFI_KIO_FONTS_USER.toString(), KFI_KIO_FONTS_SYS.toString()));
#endif
return; return;
} }
break; break;
@ -702,6 +731,31 @@ Family CKioFonts::getFont(const QUrl &url, EFolder folder)
void CKioFonts::handleResp(int resp, const QString &file, const QString &tempFile, bool destIsSystem) void CKioFonts::handleResp(int resp, const QString &file, const QString &tempFile, bool destIsSystem)
{ {
switch (resp) { switch (resp) {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
case FontInst::STATUS_NO_SYS_CONNECTION:
error(KIO::ERR_WORKER_DEFINED, i18n("Failed to start the system daemon"));
break;
case FontInst::STATUS_SERVICE_DIED:
error(KIO::ERR_WORKER_DEFINED, i18n("Backend died"));
break;
case FontInst::STATUS_BITMAPS_DISABLED:
error(KIO::ERR_WORKER_DEFINED, i18n("%1 is a bitmap font, and these have been disabled on your system.", file));
break;
case FontInst::STATUS_ALREADY_INSTALLED:
error(KIO::ERR_WORKER_DEFINED, i18n("%1 contains the font <b>%2</b>, which is already installed on your system.", file, FC::getName(tempFile)));
break;
case FontInst::STATUS_NOT_FONT_FILE:
error(KIO::ERR_WORKER_DEFINED, i18n("%1 is not a font.", file));
break;
case FontInst::STATUS_PARTIAL_DELETE:
error(KIO::ERR_WORKER_DEFINED, i18n("Could not remove all files associated with %1", file));
break;
case KIO::ERR_FILE_ALREADY_EXIST: {
QString name(Misc::modifyName(file)), destFolder(Misc::getDestFolder(m_interface->folderName(destIsSystem), name));
error(KIO::ERR_WORKER_DEFINED, i18n("<i>%1</i> already exists.", destFolder + name));
break;
}
#else
case FontInst::STATUS_NO_SYS_CONNECTION: case FontInst::STATUS_NO_SYS_CONNECTION:
error(KIO::ERR_SLAVE_DEFINED, i18n("Failed to start the system daemon")); error(KIO::ERR_SLAVE_DEFINED, i18n("Failed to start the system daemon"));
break; break;
@ -725,6 +779,7 @@ void CKioFonts::handleResp(int resp, const QString &file, const QString &tempFil
error(KIO::ERR_SLAVE_DEFINED, i18n("<i>%1</i> already exists.", destFolder + name)); error(KIO::ERR_SLAVE_DEFINED, i18n("<i>%1</i> already exists.", destFolder + name));
break; break;
} }
#endif
case FontInst::STATUS_OK: case FontInst::STATUS_OK:
finished(); finished();
break; break;

@ -13,6 +13,7 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QUrl> #include <QUrl>
#include <kio_version.h>
// Pseudo plugin class to embed meta data // Pseudo plugin class to embed meta data
class KIOPluginForMetaData : public QObject class KIOPluginForMetaData : public QObject
@ -127,7 +128,12 @@ void ApplicationsProtocol::stat(const QUrl &url)
if (service && service->isValid()) { if (service && service->isValid()) {
createFileEntry(entry, service, url); createFileEntry(entry, service, url);
} else { } else {
#if KIO_VERSION >= QT_VERSION_CHECK(5, 96, 0)
error(KIO::ERR_WORKER_DEFINED, i18n("Unknown application folder"));
#else
error(KIO::ERR_SLAVE_DEFINED, i18n("Unknown application folder")); error(KIO::ERR_SLAVE_DEFINED, i18n("Unknown application folder"));
#endif
return; return;
} }
} }

Loading…
Cancel
Save