diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -74,7 +74,7 @@ if (TARGET KF5::KIOGui) ecm_add_tests( favicontest.cpp - processlauncherjobtest.cpp + applicationlauncherjobtest.cpp NAME_PREFIX "kiogui-" LINK_LIBRARIES KF5::KIOCore KF5::KIOGui Qt5::Test ) diff --git a/autotests/processlauncherjobtest.h b/autotests/applicationlauncherjobtest.h rename from autotests/processlauncherjobtest.h rename to autotests/applicationlauncherjobtest.h --- a/autotests/processlauncherjobtest.h +++ b/autotests/applicationlauncherjobtest.h @@ -19,13 +19,13 @@ Boston, MA 02110-1301, USA. */ -#ifndef PROCESSLAUNCHERJOBTEST_H -#define PROCESSLAUNCHERJOBTEST_H +#ifndef APPLICATIONLAUNCHERJOBTEST_H +#define APPLICATIONLAUNCHERJOBTEST_H #include #include -class ProcessLauncherJobTest : public QObject +class ApplicationLauncherJobTest : public QObject { Q_OBJECT @@ -49,5 +49,5 @@ }; -#endif /* PROCESSLAUNCHERJOBTEST_H */ +#endif /* APPLICATIONLAUNCHERJOBTEST_H */ diff --git a/autotests/processlauncherjobtest.cpp b/autotests/applicationlauncherjobtest.cpp rename from autotests/processlauncherjobtest.cpp rename to autotests/applicationlauncherjobtest.cpp --- a/autotests/processlauncherjobtest.cpp +++ b/autotests/applicationlauncherjobtest.cpp @@ -19,8 +19,8 @@ Boston, MA 02110-1301, USA. */ -#include "processlauncherjobtest.h" -#include "processlauncherjob.h" +#include "applicationlauncherjobtest.h" +#include "applicationlauncherjob.h" #include "kiotesthelper.h" // createTestFile etc. @@ -37,30 +37,30 @@ #include #include -QTEST_GUILESS_MAIN(ProcessLauncherJobTest) +QTEST_GUILESS_MAIN(ApplicationLauncherJobTest) -void ProcessLauncherJobTest::initTestCase() +void ApplicationLauncherJobTest::initTestCase() { QStandardPaths::setTestModeEnabled(true); } -void ProcessLauncherJobTest::cleanupTestCase() +void ApplicationLauncherJobTest::cleanupTestCase() { std::for_each(m_filesToRemove.begin(), m_filesToRemove.end(), [](const QString & f) { QFile::remove(f); }); } -static const char s_tempServiceName[] = "processlauncherjobtest_service.desktop"; +static const char s_tempServiceName[] = "applicationlauncherjobtest_service.desktop"; static void createSrcFile(const QString path) { QFile srcFile(path); QVERIFY2(srcFile.open(QFile::WriteOnly), qPrintable(srcFile.errorString())); srcFile.write("Hello world\n"); } -void ProcessLauncherJobTest::startProcess_data() +void ApplicationLauncherJobTest::startProcess_data() { QTest::addColumn("tempFile"); QTest::addColumn("useExec"); @@ -77,7 +77,7 @@ QTest::newRow("2_tempfiles_waitForStarted") << true << false << 2; } -void ProcessLauncherJobTest::startProcess() +void ApplicationLauncherJobTest::startProcess() { QFETCH(bool, tempFile); QFETCH(bool, useExec); @@ -95,12 +95,12 @@ urls.append(QUrl::fromLocalFile(srcFile)); } - // When running a ProcessLauncherJob + // When running a ApplicationLauncherJob KService::Ptr servicePtr(new KService(path)); - KIO::ProcessLauncherJob *job = new KIO::ProcessLauncherJob(servicePtr, this); + KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(servicePtr, this); job->setUrls(urls); if (tempFile) { - job->setRunFlags(KIO::ProcessLauncherJob::DeleteTemporaryFiles); + job->setRunFlags(KIO::ApplicationLauncherJob::DeleteTemporaryFiles); } if (useExec) { QVERIFY(job->exec()); @@ -133,7 +133,7 @@ QTRY_COMPARE(KProcessRunner::instanceCount(), 0); } -void ProcessLauncherJobTest::shouldFailOnNonExecutableDesktopFile() +void ApplicationLauncherJobTest::shouldFailOnNonExecutableDesktopFile() { // Given a .desktop file in a temporary directory (outside the trusted paths) QTemporaryDir tempDir; @@ -146,22 +146,22 @@ createSrcFile(srcFile); const QList urls{QUrl::fromLocalFile(srcFile)}; KService::Ptr servicePtr(new KService(desktopFilePath)); - KIO::ProcessLauncherJob *job = new KIO::ProcessLauncherJob(servicePtr, this); + KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(servicePtr, this); job->setUrls(urls); QVERIFY(!job->exec()); QCOMPARE(job->error(), KJob::UserDefinedError); QCOMPARE(job->errorString(), QStringLiteral("You are not authorized to execute this file.")); } -void ProcessLauncherJobTest::shouldFailOnNonExistingExecutable_data() +void ApplicationLauncherJobTest::shouldFailOnNonExistingExecutable_data() { QTest::addColumn("tempFile"); QTest::newRow("file") << false; QTest::newRow("tempFile") << true; } -void ProcessLauncherJobTest::shouldFailOnNonExistingExecutable() +void ApplicationLauncherJobTest::shouldFailOnNonExistingExecutable() { QFETCH(bool, tempFile); @@ -174,19 +174,19 @@ file.sync(); KService::Ptr servicePtr(new KService(desktopFilePath)); - KIO::ProcessLauncherJob *job = new KIO::ProcessLauncherJob(servicePtr, this); + KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(servicePtr, this); job->setUrls({QUrl::fromLocalFile(desktopFilePath)}); // just to have one URL as argument, as the desktop file expects if (tempFile) { - job->setRunFlags(KIO::ProcessLauncherJob::DeleteTemporaryFiles); + job->setRunFlags(KIO::ApplicationLauncherJob::DeleteTemporaryFiles); } QVERIFY(!job->exec()); QCOMPARE(job->error(), KJob::UserDefinedError); QCOMPARE(job->errorString(), QStringLiteral("Could not find the program 'does_not_exist'")); QFile::remove(desktopFilePath); } -void ProcessLauncherJobTest::writeTempServiceDesktopFile(const QString &filePath) +void ApplicationLauncherJobTest::writeTempServiceDesktopFile(const QString &filePath) { if (!QFile::exists(filePath)) { KDesktopFile file(filePath); @@ -202,7 +202,7 @@ } } -QString ProcessLauncherJobTest::createTempService() +QString ApplicationLauncherJobTest::createTempService() { const QString fileName = s_tempServiceName; const QString fakeService = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kservices5/") + fileName; diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -2,7 +2,7 @@ set(kiogui_SRCS faviconrequestjob.cpp - processlauncherjob.cpp + applicationlauncherjob.cpp kprocessrunner.cpp ) @@ -46,7 +46,7 @@ ecm_generate_headers(KIOGui_CamelCase_HEADERS HEADER_NAMES FavIconRequestJob - ProcessLauncherJob + ApplicationLauncherJob PREFIX KIO REQUIRED_HEADERS KIO_namespaced_gui_HEADERS diff --git a/src/gui/processlauncherjob.h b/src/gui/applicationlauncherjob.h rename from src/gui/processlauncherjob.h rename to src/gui/applicationlauncherjob.h --- a/src/gui/processlauncherjob.h +++ b/src/gui/applicationlauncherjob.h @@ -19,27 +19,27 @@ Boston, MA 02110-1301, USA. */ -#ifndef KIO_PROCESSLAUNCHERJOB_H -#define KIO_PROCESSLAUNCHERJOB_H +#ifndef KIO_APPLICATIONLAUNCHERJOB_H +#define KIO_APPLICATIONLAUNCHERJOB_H #include "kiogui_export.h" #include #include #include namespace KIO { -class ProcessLauncherJobPrivate; +class ApplicationLauncherJobPrivate; /** - * @brief ProcessLauncherJob runs a process (application) and watches it while running. + * @brief ApplicationLauncherJob runs an application and watches it while running. * * It creates a startup notification and finishes it on success or on error (for the taskbar). * It also emits an error message if necessary (e.g. "program not found"). * * Note that this class doesn't support warning the user if a desktop file or a binary * does not have the executable bit set and offering to make it so. Therefore file managers - * should use KRun::runApplication rather than using ProcessLauncherJob directly. + * should use KRun::runApplication rather than using ApplicationLauncherJob directly. * * When passing multiple URLs to an application that doesn't support opening * multiple files, the application will be launched once for each URL. @@ -49,22 +49,22 @@ * * @since 5.69 */ -class KIOGUI_EXPORT ProcessLauncherJob : public KJob +class KIOGUI_EXPORT ApplicationLauncherJob : public KJob { public: /** - * @brief Creates a ProcessLauncherJob + * @brief Creates a ApplicationLauncherJob * @param service the service (application desktop file) to run * @param parent the parent QObject */ - explicit ProcessLauncherJob(const KService::Ptr &service, QObject *parent = nullptr); + explicit ApplicationLauncherJob(const KService::Ptr &service, QObject *parent = nullptr); /** * Destructor. * Note that jobs auto-delete themselves after emitting result. * Deleting/killing the job will not stop the started application. */ - ~ProcessLauncherJob() override; + ~ApplicationLauncherJob() override; /** * @brief setUrls specifies the URLs to be passed to the application @@ -127,8 +127,8 @@ QVector pids() const; private: - friend class ProcessLauncherJobPrivate; - QScopedPointer d; + friend class ApplicationLauncherJobPrivate; + QScopedPointer d; }; } // namespace KIO diff --git a/src/gui/processlauncherjob.cpp b/src/gui/applicationlauncherjob.cpp rename from src/gui/processlauncherjob.cpp rename to src/gui/applicationlauncherjob.cpp --- a/src/gui/processlauncherjob.cpp +++ b/src/gui/applicationlauncherjob.cpp @@ -19,64 +19,64 @@ Boston, MA 02110-1301, USA. */ -#include "processlauncherjob.h" +#include "applicationlauncherjob.h" #include "kprocessrunner_p.h" #include "kiogui_debug.h" -class KIO::ProcessLauncherJobPrivate +class KIO::ApplicationLauncherJobPrivate { public: - explicit ProcessLauncherJobPrivate(const KService::Ptr &service) + explicit ApplicationLauncherJobPrivate(const KService::Ptr &service) : m_service(service) {} - void slotStarted(KIO::ProcessLauncherJob *q, KProcessRunner *processRunner) { + void slotStarted(KIO::ApplicationLauncherJob *q, KProcessRunner *processRunner) { m_pids.append(processRunner->pid()); if (--m_numProcessesPending == 0) { q->emitResult(); } } const KService::Ptr m_service; QList m_urls; - KIO::ProcessLauncherJob::RunFlags m_runFlags; + KIO::ApplicationLauncherJob::RunFlags m_runFlags; QString m_suggestedFileName; QByteArray m_startupId; QVector m_pids; QVector m_processRunners; int m_numProcessesPending = 0; }; -KIO::ProcessLauncherJob::ProcessLauncherJob(const KService::Ptr &service, QObject *parent) - : KJob(parent), d(new ProcessLauncherJobPrivate(service)) +KIO::ApplicationLauncherJob::ApplicationLauncherJob(const KService::Ptr &service, QObject *parent) + : KJob(parent), d(new ApplicationLauncherJobPrivate(service)) { } -KIO::ProcessLauncherJob::~ProcessLauncherJob() +KIO::ApplicationLauncherJob::~ApplicationLauncherJob() { // Do *NOT* delete the KProcessRunner instances here. // We need it to keep running so it can do terminate startup notification on process exit. } -void KIO::ProcessLauncherJob::setUrls(const QList &urls) +void KIO::ApplicationLauncherJob::setUrls(const QList &urls) { d->m_urls = urls; } -void KIO::ProcessLauncherJob::setRunFlags(RunFlags runFlags) +void KIO::ApplicationLauncherJob::setRunFlags(RunFlags runFlags) { d->m_runFlags = runFlags; } -void KIO::ProcessLauncherJob::setSuggestedFileName(const QString &suggestedFileName) +void KIO::ApplicationLauncherJob::setSuggestedFileName(const QString &suggestedFileName) { d->m_suggestedFileName = suggestedFileName; } -void KIO::ProcessLauncherJob::setStartupId(const QByteArray &startupId) +void KIO::ApplicationLauncherJob::setStartupId(const QByteArray &startupId) { d->m_startupId = startupId; } -void KIO::ProcessLauncherJob::start() +void KIO::ApplicationLauncherJob::start() { if (d->m_urls.count() > 1 && !d->m_service->allowMultipleFiles()) { // We need to launch the application N times. @@ -111,7 +111,7 @@ }); } -bool KIO::ProcessLauncherJob::waitForStarted() +bool KIO::ApplicationLauncherJob::waitForStarted() { const bool ret = std::all_of(d->m_processRunners.cbegin(), d->m_processRunners.cend(), @@ -122,12 +122,12 @@ return ret; } -qint64 KIO::ProcessLauncherJob::pid() const +qint64 KIO::ApplicationLauncherJob::pid() const { return d->m_pids.at(0); } -QVector KIO::ProcessLauncherJob::pids() const +QVector KIO::ApplicationLauncherJob::pids() const { return d->m_pids; } diff --git a/src/gui/kprocessrunner.cpp b/src/gui/kprocessrunner.cpp --- a/src/gui/kprocessrunner.cpp +++ b/src/gui/kprocessrunner.cpp @@ -39,7 +39,7 @@ static int s_instanceCount = 0; // for the unittest KProcessRunner::KProcessRunner(const KService::Ptr &service, const QList &urls, - KIO::ProcessLauncherJob::RunFlags flags, const QString &suggestedFileName, const QByteArray &asn) + KIO::ApplicationLauncherJob::RunFlags flags, const QString &suggestedFileName, const QByteArray &asn) : m_process{new KProcess}, m_executable(KIO::DesktopExecParser::executablePath(service->exec())) { @@ -52,7 +52,7 @@ return; } - execParser.setUrlsAreTempFiles(flags & KIO::ProcessLauncherJob::DeleteTemporaryFiles); + execParser.setUrlsAreTempFiles(flags & KIO::ApplicationLauncherJob::DeleteTemporaryFiles); execParser.setSuggestedFileName(suggestedFileName); const QStringList args = execParser.resultingArguments(); if (args.isEmpty()) { @@ -92,7 +92,7 @@ } m_process->setWorkingDirectory(workingDir); - if ((flags & KIO::ProcessLauncherJob::DeleteTemporaryFiles) == 0) { + if ((flags & KIO::ApplicationLauncherJob::DeleteTemporaryFiles) == 0) { // Remember we opened those urls, for the "recent documents" menu in kicker for (const QUrl &url : urls) { KRecentDocument::add(url, service->desktopEntryName()); @@ -194,7 +194,7 @@ void KProcessRunner::slotProcessError(QProcess::ProcessError errorCode) { // E.g. the process crashed. - // This is unlikely to happen while the ProcessLauncherJob is still connected to the KProcessRunner. + // This is unlikely to happen while the ApplicationLauncherJob is still connected to the KProcessRunner. // So the emit does nothing, this is really just for debugging. qCDebug(KIO_GUI) << m_executable << "error=" << errorCode << m_process->errorString(); Q_EMIT error(m_process->errorString()); diff --git a/src/gui/kprocessrunner_p.h b/src/gui/kprocessrunner_p.h --- a/src/gui/kprocessrunner_p.h +++ b/src/gui/kprocessrunner_p.h @@ -21,7 +21,7 @@ #ifndef KPROCESSRUNNER_P_H #define KPROCESSRUNNER_P_H -#include "processlauncherjob.h" +#include "applicationlauncherjob.h" #include "kiogui_export.h" #include @@ -59,7 +59,7 @@ */ KProcessRunner(const KService::Ptr &service, const QList &urls, - KIO::ProcessLauncherJob::RunFlags flags = {}, const QString &suggestedFileName = {}, const QByteArray &asn = {}); + KIO::ApplicationLauncherJob::RunFlags flags = {}, const QString &suggestedFileName = {}, const QByteArray &asn = {}); /** * Run a shell command diff --git a/src/widgets/krun.h b/src/widgets/krun.h --- a/src/widgets/krun.h +++ b/src/widgets/krun.h @@ -255,7 +255,7 @@ * If you need to wait for the application to register to D-Bus, use D-Bus activation instead. * * If you don't need the prompt for asking the user whether to add the executable bit for - * desktop files or binaries that don't have it, you can use KIO::ProcessLauncherJob from KIOGui directly. + * desktop files or binaries that don't have it, you can use KIO::ApplicationLauncherJob from KIOGui directly. * * @param service the service to run * @param urls the list of URLs, can be empty (app launched diff --git a/src/widgets/krun.cpp b/src/widgets/krun.cpp --- a/src/widgets/krun.cpp +++ b/src/widgets/krun.cpp @@ -56,7 +56,7 @@ #include "kdesktopfileactions.h" #include #include "kprocessrunner_p.h" -#include "processlauncherjob.h" +#include "applicationlauncherjob.h" #include #include @@ -117,7 +117,7 @@ return processRunner->pid(); } -static qint64 runProcessLauncherJob(KIO::ProcessLauncherJob *job, QWidget *widget) +static qint64 runApplicationLauncherJob(KIO::ApplicationLauncherJob *job, QWidget *widget) { QObject *receiver = widget ? static_cast(widget) : static_cast(qApp); QObject::connect(job, &KJob::result, receiver, [widget](KJob *job) { @@ -667,14 +667,14 @@ window = window->window(); } - KIO::ProcessLauncherJob *job = new KIO::ProcessLauncherJob(servicePtr); + KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(servicePtr); job->setUrls(urls); if (flags & DeleteTemporaryFiles) { - job->setRunFlags(KIO::ProcessLauncherJob::DeleteTemporaryFiles); + job->setRunFlags(KIO::ApplicationLauncherJob::DeleteTemporaryFiles); } job->setSuggestedFileName(suggestedFileName); job->setStartupId(asn); - return runProcessLauncherJob(job, window); + return runApplicationLauncherJob(job, window); } qint64 KRun::runService(const KService &_service, const QList &_urls, QWidget *window,