KNewStuff
installation.cpp
64 errorMessage = QStringLiteral("invalid Uncompress setting chosen, must be one of: subdir, always, archive, never, or kpackage");
71 errorMessage = QStringLiteral("kpackage uncompress setting chosen, but no KPackageStructure specified");
85 if (standardResourceDirectory.isEmpty() && targetDirectory.isEmpty() && xdgTargetDirectory.isEmpty() && installPath.isEmpty()
108 Q_EMIT signalInstallationFailed(i18n("Download of item failed: no download URL for \"%1\".", entry.name()), entry);
125 FileCopyJob *job = FileCopyJob::file_copy(source, destination, -1, JobFlag::Overwrite | JobFlag::HideProgressInfo);
139 const QString errorMessage = i18n("Download of \"%1\" failed, error: %2", entry.name(), job->errorString());
147 if (mimeType.inherits(QStringLiteral("text/html")) || mimeType.inherits(QStringLiteral("application/x-php"))) {
148 const auto error = i18n("Cannot install '%1' because it points to a web page. Click <a href='%2'>here</a> to finish the installation.",
176 QStringList installedFiles = installDownloadedFileAndUncompress(entry, downloadedFile, targetPath);
186 Q_EMIT signalInstallationFailed(i18n("Could not install \"%1\": file not found.", entry.name()), entry);
234 if (!standardResourceDirectory.isEmpty() && standardResourceDirectory != QLatin1String("wallpaper")) {
252 installdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + targetDirectory + QLatin1Char('/');
254 installdir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, targetDirectory, QStandardPaths::LocateDirectory) + QLatin1Char('/');
259 installdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + xdgTargetDirectory + QLatin1Char('/');
266 installdir = QString::fromUtf16((const char16_t *)wPath) + QLatin1Char('/') + installPath + QLatin1Char('/');
293QStringList Installation::installDownloadedFileAndUncompress(const KNSCore::Entry &entry, const QString &payloadfile, const QString installdir)
305 if (changedEntry.status() == KNSCore::Entry::Installing || changedEntry.status() == KNSCore::Entry::Installed) {
313 qCDebug(KNEWSTUFFCORE) << "About to attempt to install" << payloadfile << "as" << kpackageStructure;
315 connect(job, &KPackage::PackageJob::finished, this, [this, entry, payloadfile, resetEntryStatus, job]() {
329 // We can remove the downloaded file, because we don't save its location and don't need it to uninstall the entry
333 qCDebug(KNEWSTUFFCORE) << "Install job finished with no error and we now have files" << job->package().path();
348 qCDebug(KNEWSTUFFCORE) << "Install job finished telling us this item was already installed with this version, so... let's "
352 Q_EMIT signalInstallationFailed(i18n("Installation of %1 failed: %2", payloadfile, job->errorText()), entry);
354 qCDebug(KNEWSTUFFCORE) << "Install job finished with error state" << job->error() << "and description" << job->error();
359 if (uncompressionOpt == AlwaysUncompress || uncompressionOpt == UncompressIntoSubdirIfArchive || uncompressionOpt == UncompressIfArchive
386 Q_EMIT signalInstallationError(i18n("Could not determine the type of archive of the downloaded file %1", payloadfile), entry);
398 i18n("Failed to open the archive file %1. The reported error was: %2", payloadfile, archive->errorString()),
412 (uncompressionOpt == UncompressIntoSubdir || uncompressionOpt == UncompressIntoSubdirIfArchive) && dir->entries().count() > 1;
420 // If we extracted the subdir we want to save it using the /* notation like we would when using the "archive" option
421 // Also if we use an (un)install command we only call it once with the folder as argument and not for each file
441 || (uncompressionOpt == NeverUncompress || (uncompressionOpt == UncompressIfArchive && !isarchive)
446 // FIXME: make naming convention configurable through *.knsrc? e.g. for kde-look.org image names
459 const bool update = ((entry.status() == KNSCore::Entry::Updateable) || (entry.status() == KNSCore::Entry::Updating));
465 question.setQuestion(i18n("This file already exists on disk (possibly due to an earlier failed download attempt). Continuing means "
476 // remove in case it's already present and in a temporary directory, so we get to actually use the path again
487 Q_EMIT signalInstallationError(i18n("Unable to move the file %1 to the intended destination %2", payloadfile, installpath), entry);
488 qCCritical(KNEWSTUFFCORE) << "Cannot move file" << payloadfile << "to destination" << installpath;
498QProcess *Installation::runPostInstallationCommand(const QString &installPath, const KNSCore::Entry &entry)
507 auto onProcessFinished = [this, command, ret, entry](int exitcode, QProcess::ExitStatus status) {
510 QString errorMessage = i18n("The installation failed while attempting to run the command:\n%1\n\nThe returned output was:\n%2", command, output);
521 i18n("The installation failed with code %1 while attempting to run the command:\n%2\n\nThe returned output was:\n%3",
563 i18n("The removal of %1 failed, as the installed file %2 could not be automatically removed. You can attempt to manually delete "
599 Q_EMIT signalInstallationFailed(i18n("Installation of %1 failed: %2", installedFile, job->errorText()), entry);
628 auto onProcessFinished = [this, command, process, entry, deleteFilesAndMarkAsUninstalled](int, QProcess::ExitStatus status) {
658 // If the entry got deleted, but the RemoveDeadEntries option was not selected this case can happen
QString readEntry(const char *key, const char *aDefault=nullptr) const
virtual QString errorString() const
int error() const
void result(KJob *job)
void finished(KJob *job)
QString errorText() const
void setInstalledFiles(const QStringList &files)
Set the files that have been installed by the install command.
Definition entry.cpp:334
QString updateVersion() const
Retrieve the version string of the object that is available as update.
Definition entry.cpp:206
QDate updateReleaseDate() const
Retrieve the date of the newer version that is available as update.
Definition entry.cpp:196
A way to ask a user a question from inside a GUI-less library (like KNewStuffCore)
Definition question.h:47
static PackageJob * update(const QString &packageFormat, const QString &sourcePackage, const QString &packageRoot=QString())
static PackageJob * uninstall(const QString &packageFormat, const QString &pluginId, const QString &packageRoot=QString())
Q_SCRIPTABLE CaptureState status()
QString i18n(const char *text, const TYPE &arg...)
void update(Part *part, const QByteArray &data, qint64 dataSize)
KCALUTILS_EXPORT QString mimeType()
KCALUTILS_EXPORT QString errorMessage(const KCalendarCore::Exception &exception)
QVariant location(const QVariant &res)
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
KIOCORE_EXPORT QString dir(const QString &fileClass)
KCOREADDONS_EXPORT QStringList splitArgs(const QString &cmd, Options flags=NoOptions, Errors *err=nullptr)
KCOREADDONS_EXPORT QString quoteArg(const QString &arg)
bool isValid(int year, int month, int day)
QString absolutePath() const const
QString filePath(const QString &fileName) const const
QString homePath()
bool mkpath(const QString &dirPath) const const
bool rmdir(const QString &dirName) const const
QString tempPath()
bool exists() const const
bool remove()
QString baseName() const const
bool exists() const const
ReadOnly
const T & constLast() const const
T & first()
bool isEmpty() const const
value_type takeFirst()
QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const const
ExitStatus
void finished(int exitCode, QProcess::ExitStatus exitStatus)
QByteArray readAllStandardError()
void setArguments(const QStringList &arguments)
void setProgram(const QString &program)
void start(OpenMode mode)
void reset(T *other)
LocateDirectory
StandardLocation
QString locate(StandardLocation type, const QString &fileName, LocateOptions options)
QStringList standardLocations(StandardLocation type)
QString writableLocation(StandardLocation type)
qsizetype count() const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
QString fromLocal8Bit(QByteArrayView str)
QString fromUtf16(const char16_t *unicode, qsizetype size)
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString fileName(ComponentFormattingOptions options) const const
QUrl fromLocalFile(const QString &localFile)
bool isValid() const const
QString toLocalFile() const const
QString toString(FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:13:34 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:13:34 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.