diff --git a/CMakeLists.txt b/CMakeLists.txt index 29b461d4..91c624b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,7 +314,6 @@ add_subdirectory(kdeeject) add_subdirectory(kfile) add_subdirectory(kiconfinder) add_subdirectory(kioclient) -add_subdirectory(kioexec) add_subdirectory(ktraderclient) add_subdirectory(kreadconfig) add_subdirectory(kmimetypefinder) diff --git a/dolphin/src/dolphinapplication.cpp b/dolphin/src/dolphinapplication.cpp index da2e1b7a..968b65bd 100644 --- a/dolphin/src/dolphinapplication.cpp +++ b/dolphin/src/dolphinapplication.cpp @@ -24,7 +24,6 @@ #include #include -#include #include DolphinApplication::DolphinApplication() : diff --git a/dolphin/src/dolphinmainwindow.cpp b/dolphin/src/dolphinmainwindow.cpp index cbb3d6a1..50ea73cf 100644 --- a/dolphin/src/dolphinmainwindow.cpp +++ b/dolphin/src/dolphinmainwindow.cpp @@ -357,7 +357,7 @@ void DolphinMainWindow::updateFilterBarAction(bool show) void DolphinMainWindow::openNewMainWindow() { - KRun::run("dolphin %u", KUrl::List(), this); + KToolInvocation::self()->startServiceByStorageId("dolphin", QStringList(), this); } void DolphinMainWindow::openNewTab() @@ -468,7 +468,7 @@ void DolphinMainWindow::openInNewWindow() } if (!newWindowUrl.isEmpty()) { - KRun::run("dolphin %u", KUrl::List() << newWindowUrl, this); + KToolInvocation::self()->startServiceByStorageId("dolphin", QStringList() << newWindowUrl.url(), this); } } @@ -955,18 +955,15 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos) openNewTab(url); m_tabBar->setCurrentIndex(m_viewTab.count() - 1); } else if (selectedAction == detachTabAction) { - const QString separator(QLatin1Char(' ')); - QString command = QLatin1String("dolphin"); - + QStringList dolphinArgs; const DolphinTabPage* tabPage = m_viewTab.at(index); - - command += separator + tabPage->primaryViewContainer()->url().url(); + dolphinArgs << tabPage->primaryViewContainer()->url().url(); if (tabPage->splitViewEnabled()) { - command += separator + tabPage->secondaryViewContainer()->url().url(); - command += separator + QLatin1String("-split"); + dolphinArgs << tabPage->secondaryViewContainer()->url().url(); + dolphinArgs << QLatin1String("-split"); } - KRun::runCommand(command, this); + KToolInvocation::self()->startProgram("dolphin", dolphinArgs, this); closeTab(index); } else if (selectedAction == closeOtherTabsAction) { @@ -1010,7 +1007,7 @@ void DolphinMainWindow::handleUrl(const KUrl& url) this, SLOT(slotHandleUrlStatFinished(KJob*))); } else { - new KRun(url, this); // Automatically deletes itself after being finished + KToolInvocation::self()->startServiceForUrl(url.url(), this); } } @@ -1022,7 +1019,7 @@ void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job) if (entry.isDir()) { activeViewContainer()->setUrl(url); } else { - new KRun(url, this); // Automatically deletes itself after being finished + KToolInvocation::self()->startServiceForUrl(url.url(), this); } } @@ -1056,7 +1053,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, switch (command) { case DolphinContextMenu::OpenParentFolderInNewWindow: { - KRun::run("dolphin %u", KUrl::List() << item.url().upUrl(), this); + KToolInvocation::self()->startServiceByStorageId("dolphin", QStringList() << item.url().upUrl().url(), this); break; } diff --git a/dolphin/src/dolphinmainwindow.h b/dolphin/src/dolphinmainwindow.h index c9d4bb8b..7eca822c 100644 --- a/dolphin/src/dolphinmainwindow.h +++ b/dolphin/src/dolphinmainwindow.h @@ -405,7 +405,7 @@ private slots: /** * If the URL can be listed, open it in the current view, otherwise - * run it through KRun. + * run it through KToolInvocation. */ void handleUrl(const KUrl& url); diff --git a/dolphin/src/dolphinviewcontainer.cpp b/dolphin/src/dolphinviewcontainer.cpp index c1ca52c5..b1aa2817 100644 --- a/dolphin/src/dolphinviewcontainer.cpp +++ b/dolphin/src/dolphinviewcontainer.cpp @@ -43,8 +43,6 @@ #include #include #include -#include - #include "dolphin_generalsettings.h" #include "filterbar/filterbar.h" diff --git a/kate/addons/kate/project/kateprojecttreeviewcontextmenu.cpp b/kate/addons/kate/project/kateprojecttreeviewcontextmenu.cpp index aa3c6942..b82b7312 100644 --- a/kate/addons/kate/project/kateprojecttreeviewcontextmenu.cpp +++ b/kate/addons/kate/project/kateprojecttreeviewcontextmenu.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -152,19 +152,19 @@ void KateProjectTreeViewContextMenu::exec(const QString& filename, const QPoint& } else if(openDirectoryWithMenu == action->parentWidget()) { // handle open directory with const QString openDirWith = action->data().toString(); - if (KService::Ptr app = KService::serviceByDesktopPath(openDirWith)) { + if (!openDirWith.isEmpty()) { QFileInfo fi(filename); - QList list; - list << QUrl::fromLocalFile (fi.dir().absolutePath()); - KRun::run(*app, list, parent); + QStringList list; + list << fi.dir().absolutePath(); + KToolInvocation::self()->startServiceByStorageId(openDirWith, list, parent); } } else { // open with const QString openWith = action->data().toString(); - if (KService::Ptr app = KService::serviceByDesktopPath(openWith)) { - QList list; - list << QUrl::fromLocalFile (filename); - KRun::run(*app, list, parent); + if (!openWith.isEmpty()) { + QStringList list; + list << filename; + KToolInvocation::self()->startServiceByStorageId(openWith, list, parent); } } } diff --git a/kate/addons/plasma/session/katesessionapplet.cpp b/kate/addons/plasma/session/katesessionapplet.cpp index cbfcbddf..7baf38c5 100644 --- a/kate/addons/plasma/session/katesessionapplet.cpp +++ b/kate/addons/plasma/session/katesessionapplet.cpp @@ -202,7 +202,7 @@ void KateSessionApplet::slotOnItemClicked(const QModelIndex &index) else if ( id > 2 ) args <<"-n"<< "--start"<kdeinitExec("kate", args); + KToolInvocation::self()->startProgram("kate", args); } void KateSessionApplet::createConfigurationInterface(KConfigDialog *parent) diff --git a/kate/part/dialogs/katedialogs.cpp b/kate/part/dialogs/katedialogs.cpp index f99d6d74..8417e9e6 100644 --- a/kate/part/dialogs/katedialogs.cpp +++ b/kate/part/dialogs/katedialogs.cpp @@ -74,7 +74,7 @@ #include #include #include -#include +#include #include #include #include @@ -1250,12 +1250,11 @@ void KateModOnHdPrompt::slotPDone() } m_diffFile->setAutoRemove(false); - KUrl url = KUrl::fromPath(m_diffFile->fileName()); + QString url = m_diffFile->fileName(); delete m_diffFile; m_diffFile = 0; - // KRun::runUrl should delete the file, once the client exits - KRun::runUrl( url, "text/x-patch", this, true ); + KToolInvocation::self()->startServiceForUrl( url, this, true ); } void KateModOnHdPrompt::slotButtonClicked(int button) diff --git a/kate/part/dialogs/katedialogs.h b/kate/part/dialogs/katedialogs.h index 7ec1591b..f45098fd 100644 --- a/kate/part/dialogs/katedialogs.h +++ b/kate/part/dialogs/katedialogs.h @@ -343,7 +343,7 @@ class KatePartPluginConfigPage : public KateConfigPage * This dialog will prompt the user for what do with a file that is * modified on disk. * If the file wasn't deleted, it has a 'diff' button, which will create - * a diff file (uing diff(1)) and launch that using KRun. + * a diff file (uing diff(1)) and launch that using KToolInvocation. */ class KateModOnHdPrompt : public KDialog { diff --git a/kate/part/swapfile/kateswapdiffcreator.cpp b/kate/part/swapfile/kateswapdiffcreator.cpp index 9d7ac9d4..d512896b 100644 --- a/kate/part/swapfile/kateswapdiffcreator.cpp +++ b/kate/part/swapfile/kateswapdiffcreator.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include //BEGIN SwapDiffCreator @@ -149,12 +149,11 @@ void SwapDiffCreator::slotDiffFinished() return; } - // close diffFile and avoid removal, KRun will do that later! + // close diffFile and avoid removal m_diffFile.close (); m_diffFile.setAutoRemove (false); - // KRun::runUrl should delete the file, once the client exits - KRun::runUrl (KUrl::fromPath(m_diffFile.fileName()), "text/x-patch", m_swapFile->document()->activeView(), true ); + KToolInvocation::self()->startServiceForUrl (m_diffFile.fileName(), m_swapFile->document()->activeView(), true ); deleteLater(); } diff --git a/kate/src/app/katemainwindow.cpp b/kate/src/app/katemainwindow.cpp index c5a35ab6..f9ebda70 100644 --- a/kate/src/app/katemainwindow.cpp +++ b/kate/src/app/katemainwindow.cpp @@ -808,19 +808,11 @@ void KateMainWindow::slotOpenWithMenuAction(QAction* a) // display "open with" dialog KOpenWithDialog dlg(list); if (dlg.exec()) - KRun::run(*dlg.service(), list, this); + KToolInvocation::self()->startServiceByStorageId(dlg.service()->entryPath(), list.toStringList(), this); return; } - KService::Ptr app = KService::serviceByDesktopPath(openWith); - if (app) - { - KRun::run(*app, list, this); - } - else - { - KMessageBox::error(this, i18n("Application '%1' not found.", openWith), i18n("Application not found")); - } + KToolInvocation::self()->startServiceByStorageId(openWith, list.toStringList(), this); } void KateMainWindow::pluginHelp() diff --git a/kate/src/app/katemwmodonhddialog.cpp b/kate/src/app/katemwmodonhddialog.cpp index 4654e6ae..8ede5f68 100644 --- a/kate/src/app/katemwmodonhddialog.cpp +++ b/kate/src/app/katemwmodonhddialog.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -301,12 +301,11 @@ void KateMwModOnHdDialog::slotPDone() } m_diffFile->setAutoRemove(false); - KUrl url = KUrl::fromPath(m_diffFile->fileName()); + QString url = m_diffFile->fileName(); delete m_diffFile; m_diffFile = 0; - // KRun::runUrl should delete the file, once the client exits - KRun::runUrl( url, "text/x-patch", this, true ); + KToolInvocation::self()->startServiceForUrl( url, this, true ); } void KateMwModOnHdDialog::addDocument(KTextEditor::Document *doc) diff --git a/kate/src/filetree/katefiletree.cpp b/kate/src/filetree/katefiletree.cpp index 0569a5c9..3a4eb18e 100644 --- a/kate/src/filetree/katefiletree.cpp +++ b/kate/src/filetree/katefiletree.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -261,19 +261,11 @@ void KateFileTree::slotOpenWithMenuAction(QAction* a) // display "open with" dialog KOpenWithDialog dlg(list); if (dlg.exec()) - KRun::run(*dlg.service(), list, this); + KToolInvocation::self()->startServiceByStorageId(dlg.service()->entryPath(), list.toStringList(), this); return; } - KService::Ptr app = KService::serviceByDesktopPath(openWith); - if (app) - { - KRun::run(*app, list, this); - } - else - { - KMessageBox::error(this, i18n("Application '%1' not found.", openWith), i18n("Application not found")); - } + KToolInvocation::self()->startServiceByStorageId(openWith, list.toStringList(), this); } diff --git a/kcontrol/access/kcmaccess.cpp b/kcontrol/access/kcmaccess.cpp index 5b7119a1..89b907d6 100644 --- a/kcontrol/access/kcmaccess.cpp +++ b/kcontrol/access/kcmaccess.cpp @@ -672,7 +672,7 @@ void KAccessConfig::save() // make kaccess reread the configuration // turning a11y features off needs to be done by kaccess // so run it to clear any enabled features and it will exit if it should - KToolInvocation::self()->startServiceByDesktopName("kaccess"); + KToolInvocation::self()->startServiceByStorageId("kaccess"); emit changed(false); } diff --git a/kcontrol/colors/colorscm.cpp b/kcontrol/colors/colorscm.cpp index 00d892f9..d4a2ad94 100644 --- a/kcontrol/colors/colorscm.cpp +++ b/kcontrol/colors/colorscm.cpp @@ -1162,7 +1162,7 @@ void KColorCm::save() displayGroup.writeEntry("exportKDEColors", applyToAlien->isChecked()); cfg.sync(); - KToolInvocation::self()->startServiceByDesktopName("krdb"); + KToolInvocation::self()->startServiceByStorageId("krdb"); emit changed(false); } diff --git a/kcontrol/fonts/fonts.cpp b/kcontrol/fonts/fonts.cpp index 27e025b1..545a4d41 100644 --- a/kcontrol/fonts/fonts.cpp +++ b/kcontrol/fonts/fonts.cpp @@ -270,7 +270,7 @@ bool FontAASettings::load() xft.apply(); // Save this setting KConfigGroup(&kglobals, "General").writeEntry("XftHintStyle", KXftConfig::toStr(hStyle)); kglobals.sync(); - KToolInvocation::self()->startServiceByDesktopName("krdb"); + KToolInvocation::self()->startServiceByStorageId("krdb"); } hintingStyle->setCurrentIndex(getIndex(hStyle)); @@ -731,7 +731,7 @@ void KFonts::save() } #endif #endif - KToolInvocation::self()->startServiceByDesktopName("krdb"); + KToolInvocation::self()->startServiceByStorageId("krdb"); emit changed(false); } diff --git a/kcontrol/input/mouse.cpp b/kcontrol/input/mouse.cpp index 603bf3ce..cf78aa1f 100644 --- a/kcontrol/input/mouse.cpp +++ b/kcontrol/input/mouse.cpp @@ -551,7 +551,7 @@ void MouseConfig::save() group.writeEntry("MKCurve", mk_curve->value()); // restart kaccess - KToolInvocation::self()->startServiceByDesktopName("kaccess"); + KToolInvocation::self()->startServiceByStorageId("kaccess"); emit changed(false); } diff --git a/kcontrol/input/xcursor/themepage.cpp b/kcontrol/input/xcursor/themepage.cpp index ae63f950..d924ffbf 100644 --- a/kcontrol/input/xcursor/themepage.cpp +++ b/kcontrol/input/xcursor/themepage.cpp @@ -257,7 +257,7 @@ bool ThemePage::applyTheme(const CursorTheme *theme, const int size) KToolInvocation::self()->setLaunchEnv("XCURSOR_THEME", theme->name()); // Update the Xcursor X resources - KToolInvocation::self()->startServiceByDesktopName("krdb"); + KToolInvocation::self()->startServiceByStorageId("krdb"); // Notify all applications that the cursor theme has changed KGlobalSettings::self()->emitChange(KGlobalSettings::MouseChanged); diff --git a/kcontrol/randr/module/randrmonitor.cpp b/kcontrol/randr/module/randrmonitor.cpp index 3e98256c..1f83b2b4 100644 --- a/kcontrol/randr/module/randrmonitor.cpp +++ b/kcontrol/randr/module/randrmonitor.cpp @@ -162,7 +162,7 @@ void RandrMonitorModule::processX11Event( XEvent* e ) void RandrMonitorModule::showKcm() { - KToolInvocation::self()->kdeinitExec("kcmshell4", QStringList() << "randr"); + KToolInvocation::self()->startProgram("kcmshell4", QStringList() << "randr"); } void RandrMonitorModule::tryAutoConfig() @@ -244,7 +244,7 @@ void RandrMonitorModule::switchDisplay() return; } // no idea what to do here - KToolInvocation::self()->kdeinitExec( "kcmshell4", QStringList() << "randr" ); + KToolInvocation::self()->startProgram( "kcmshell4", QStringList() << "randr" ); } void RandrMonitorModule::resumedFromSuspend() diff --git a/kcontrol/style/kcmstyle.cpp b/kcontrol/style/kcmstyle.cpp index 57f6b9f7..27dbfa26 100644 --- a/kcontrol/style/kcmstyle.cpp +++ b/kcontrol/style/kcmstyle.cpp @@ -389,7 +389,7 @@ void KCMStyle::save() // export fonts/colors settings. if (m_bStyleDirty | m_bToolbarDirty) // Export only if necessary { - KToolInvocation::self()->startServiceByDesktopName("krdb"); + KToolInvocation::self()->startServiceByStorageId("krdb"); } // Clean up diff --git a/kcrash/kded/kded_kcrash.cpp b/kcrash/kded/kded_kcrash.cpp index 294315ee..74256dcc 100644 --- a/kcrash/kded/kded_kcrash.cpp +++ b/kcrash/kded/kded_kcrash.cpp @@ -176,7 +176,7 @@ void KCrashModule::slotDirty(const QString &path) kcrashargs.append(kcrashdisplay); } kDebug() << "Restarting" << kcrashfilepath << kcrashapppath << kcrashargs; - KToolInvocation::self()->kdeinitExec(kcrashapppath, kcrashargs); + KToolInvocation::self()->startProgram(kcrashapppath, kcrashargs); } } } diff --git a/keditbookmarks/actionsimpl.cpp b/keditbookmarks/actionsimpl.cpp index 08b72dfa..4ee0f26b 100644 --- a/keditbookmarks/actionsimpl.cpp +++ b/keditbookmarks/actionsimpl.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -407,7 +407,7 @@ void ActionsImpl::slotOpenLink() for (it = bookmarks.constBegin(); it != end; ++it) { if ((*it).isGroup() || (*it).isSeparator()) continue; - (void)new KRun((*it).url(), KEBApp::self()); + KToolInvocation::self()->startServiceForUrl((*it).url().url(), KEBApp::self()); } } diff --git a/kfind/kfindtreeview.cpp b/kfind/kfindtreeview.cpp index 0ea21f3d..fd8c636e 100644 --- a/kfind/kfindtreeview.cpp +++ b/kfind/kfindtreeview.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -520,7 +520,7 @@ void KFindTreeView::openContainingFolder() //TODO if >1 add a warn ? Q_FOREACH( const KUrl & url, folderMaps.keys() ) { - (void) new KRun(url, this); + KToolInvocation::self()->startServiceForUrl(url.url(), this); } } diff --git a/kioclient/kioclient.cpp b/kioclient/kioclient.cpp index cc4114f9..b29d1522 100644 --- a/kioclient/kioclient.cpp +++ b/kioclient/kioclient.cpp @@ -18,6 +18,8 @@ #include "kioclient.h" +#include +#include #include #include #include @@ -32,9 +34,7 @@ #include #include #include -#include -#include -#include +#include #include #include @@ -145,18 +145,6 @@ int main( int argc, char **argv ) return ClientApp::doIt() ? 0 /*no error*/ : 1 /*error*/; } -bool krun_has_error = false; - -void ClientApp::delayedQuit() -{ - // Quit in 2 seconds. This leaves time for KRun to pop up - // "app not found" in KProcessRunner, if that was the case. - QTimer::singleShot( 2000, this, SLOT(quit()) ); - // don't access the KRun instance later, it will be deleted after calling slots - if( static_cast< const KRun* >( sender())->hasError()) - krun_has_error = true; -} - static void checkArgumentCount(int count, int min, int max) { if (count < min) @@ -171,23 +159,22 @@ static void checkArgumentCount(int count, int min, int max) } } -bool ClientApp::kde_open(const KUrl& url, const QString& mimeType, bool allowExec) +bool ClientApp::kde_open(const KUrl& url, const QString& mimeType) { if ( mimeType.isEmpty() ) { kDebug() << url; - KRun * run = new KRun( url, 0 ); - run->setRunExecutables(allowExec); - QObject::connect( run, SIGNAL( finished() ), this, SLOT( delayedQuit() )); - QObject::connect( run, SIGNAL( error() ), this, SLOT( delayedQuit() )); + bool ok = KToolInvocation::self()->startServiceForUrl( url.url() ); + // Quit in 2 seconds. This leaves time for KToolInvocation to pop up + // "app not found", if that was the case. + QTimer::singleShot( 2000, this, SLOT(quit()) ); this->exec(); - return !krun_has_error; + return ok; } else { - const KUrl::List urls( url ); const KService::List offers = KMimeTypeTrader::self()->query( mimeType, QLatin1String( "Application" ) ); if (offers.isEmpty()) return 1; KService::Ptr serv = offers.first(); - return KRun::run( *serv, urls, 0 ); + return KToolInvocation::self()->startServiceByStorageId( serv->entryPath(), QStringList() << url.url() ); } } @@ -286,7 +273,7 @@ bool ClientApp::doIt() kFatal() << "Session bus not found" ; #ifdef KIOCLIENT_AS_KDEOPEN - return app.kde_open(args->url(0), QByteArray(), false); + return app.kde_open(args->url(0), QByteArray()); #elif defined(KIOCLIENT_AS_KDECP) checkArgumentCount(argc, 2, 0); return app.doCopy(0); @@ -321,8 +308,7 @@ bool ClientApp::doIt() { checkArgumentCount(argc, 2, 3); return app.kde_open( args->url( 1 ), - argc == 3 ? args->arg( 2 ) : QString(), - true ); + argc == 3 ? args->arg( 2 ) : QString()); } else if ( command == "download" ) { diff --git a/kioclient/kioclient.h b/kioclient/kioclient.h index 6158721f..091bc5a9 100644 --- a/kioclient/kioclient.h +++ b/kioclient/kioclient.h @@ -35,11 +35,10 @@ private Q_SLOTS: void slotPrintData(KIO::Job *job, const QByteArray &data); void slotEntries(KIO::Job* job, const KIO::UDSEntryList& ); void slotResult( KJob * ); - void delayedQuit(); void slotDialogCanceled(); private: - bool kde_open( const KUrl& url, const QString& mimeType, bool allowExec ); + bool kde_open( const KUrl& url, const QString& mimeType ); bool doCopy( int firstArg ); bool doMove( int firstArg ); bool doList( int firstArg ); diff --git a/kioexec/CMakeLists.txt b/kioexec/CMakeLists.txt deleted file mode 100644 index cd901618..00000000 --- a/kioexec/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(kioexec_SRCS main.cpp ) - -add_executable(kioexec ${kioexec_SRCS}) - -target_link_libraries(kioexec KDE4::kio) - -install( - TARGETS kioexec - DESTINATION ${KDE4_LIBEXEC_INSTALL_DIR} -) diff --git a/kioexec/Messages.sh b/kioexec/Messages.sh deleted file mode 100644 index 5f5edc4d..00000000 --- a/kioexec/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -$XGETTEXT *.cpp -o $podir/kioexec.pot diff --git a/kioexec/README b/kioexec/README deleted file mode 100644 index 78e0b3da..00000000 --- a/kioexec/README +++ /dev/null @@ -1,26 +0,0 @@ -kioexec is launched when the user wants to open a remote file with -an application that only supports local files. - -For this it does the following: -- downloads a remote file to a temp location -- starts a 'local' application with that temp file as argument -- wait fors application to be exited -- if the modification time of the file is different from the original one, -(because the file was modified) then it offers re-uploading the modified version. -This is how you offer network transparency to apps that don't have it. - -BUT: with KUniqueApplication, this breaks, because the app returns at once, -so we have no way to know when the user finished editing the file... - -Conclusion: if the application has network transparency built-in, it should -put "%u" in its desktop file - and kioexec isn't used -. If it doesn't, either -it's a KApplication and kiiooexec does its job, or it's a KUniqueApplication -and... kioexec can't see modifications to the file. Be warned. - -From Waldo: "The program doesn't return _at once_. It returns -after "newInstance()" returns. So if you open the file there it will still work. -(Or rename it)" - -David Faure -20-May-2000 - diff --git a/kioexec/main.cpp b/kioexec/main.cpp deleted file mode 100644 index 36cabe7a..00000000 --- a/kioexec/main.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999 Torben Weis - Copyright (C) 2000-2005 David Faure - Copyright (C) 2001 Waldo Bastian - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "main.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const char description[] = - I18N_NOOP("KIO Exec - Opens remote files, watches modifications, asks for upload"); - - -KIOExec::KIOExec() - : mExited(false) -{ - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - if (args->count() < 1) - KCmdLineArgs::usageError(i18n("'command' expected.\n")); - - tempfiles = args->isSet("tempfiles"); - if ( args->isSet( "suggestedfilename" ) ) - suggestedFileName = args->getOption( "suggestedfilename" ); - expectedCounter = 0; - jobCounter = 0; - command = args->arg(0); - kDebug() << "command=" << command; - - for ( int i = 1; i < args->count(); i++ ) - { - KUrl url = args->url(i); - url = KIO::NetAccess::mostLocalUrl( url, 0 ); - - //kDebug() << "url=" << url.url() << " filename=" << url.fileName(); - // A local file, not an URL ? - // => It is not encoded and not shell escaped, too. - if ( url.isLocalFile() ) - { - FileInfo file; - file.path = url.toLocalFile(); - file.url = url; - fileList.append(file); - } - // It is an URL - else - { - if ( !url.isValid() ) - KMessageBox::error( 0L, i18n( "The URL %1\nis malformed" , url.url() ) ); - else if ( tempfiles ) - KMessageBox::error( 0L, i18n( "Remote URL %1\nnot allowed with --tempfiles switch" , url.url() ) ); - else - // We must fetch the file - { - QString fileName = KIO::encodeFileName( url.fileName() ); - if ( !suggestedFileName.isEmpty() ) - fileName = suggestedFileName; - // Build the destination filename, in ~/.kde/cache-*/krun/ - // Unlike KDE-1.1, we put the filename at the end so that the extension is kept - // (Some programs rely on it) - QString tmp = KGlobal::dirs()->saveLocation( "cache", "krun/" ) + - QString("%1_%2_%3").arg(getpid()).arg(jobCounter++).arg(fileName); - FileInfo file; - file.path = tmp; - file.url = url; - fileList.append(file); - - expectedCounter++; - KUrl dest; - dest.setPath( tmp ); - kDebug() << "Copying " << url.prettyUrl() << " to " << dest; - KIO::Job *job = KIO::file_copy( url, dest ); - jobList.append( job ); - - connect( job, SIGNAL( result( KJob * ) ), SLOT( slotResult( KJob * ) ) ); - } - } - } - args->clear(); - - if ( tempfiles ) - { - slotRunApp(); - return; - } - - counter = 0; - if ( counter == expectedCounter ) - slotResult( 0L ); -} - -void KIOExec::slotResult( KJob * job ) -{ - if (job && job->error()) - { - // That error dialog would be queued, i.e. not immediate... - //job->showErrorDialog(); - if ( (job->error() != KIO::ERR_USER_CANCELED) ) - KMessageBox::error( 0L, job->errorString() ); - - QString path = static_cast(job)->destUrl().path(); - - QList::Iterator it = fileList.begin(); - for(;it != fileList.end(); ++it) - { - if ((*it).path == path) - break; - } - - if ( it != fileList.end() ) - fileList.erase( it ); - else - kDebug() << path << " not found in list"; - } - - counter++; - - if ( counter < expectedCounter ) - return; - - kDebug() << "All files downloaded, will call slotRunApp shortly"; - // We know we can run the app now - but let's finish the job properly first. - QTimer::singleShot( 0, this, SLOT( slotRunApp() ) ); - - jobList.clear(); -} - -void KIOExec::slotRunApp() -{ - if ( fileList.isEmpty() ) { - kDebug() << "No files downloaded -> exiting"; - mExited = true; - QApplication::exit(1); - return; - } - - KService service("dummy", command, QString()); - - KUrl::List list; - // Store modification times - QList::Iterator it = fileList.begin(); - for ( ; it != fileList.end() ; ++it ) - { - KDE_struct_stat buff; - (*it).time = KDE_stat( QFile::encodeName((*it).path), &buff ) ? 0 : buff.st_mtime; - KUrl url; - url.setPath((*it).path); - list << url; - } - - QStringList params = KRun::processDesktopExec(service, list); - - kDebug() << "EXEC " << KShell::joinArgs( params ); - -#ifdef Q_WS_X11 - // propagate the startup identification to the started process - KStartupInfoId id; - id.initId( kapp->startupId()); - id.setupStartupEnv(); -#endif - - QString exe( params.takeFirst() ); - const int exit_code = QProcess::execute( exe, params ); - -#ifdef Q_WS_X11 - KStartupInfo::resetStartupEnv(); -#endif - - kDebug() << "EXEC done"; - - // Test whether one of the files changed - it = fileList.begin(); - for( ;it != fileList.end(); ++it ) - { - KDE_struct_stat buff; - QString src = (*it).path; - KUrl dest = (*it).url; - if ( (KDE::stat( src, &buff ) == 0) && - ((*it).time != buff.st_mtime) ) - { - if ( tempfiles ) - { - if ( KMessageBox::questionYesNo( 0L, - i18n( "The supposedly temporary file\n%1\nhas been modified.\nDo you still want to delete it?" , dest.pathOrUrl()), - i18n( "File Changed" ), KStandardGuiItem::del(), KGuiItem(i18n("Do Not Delete")) ) != KMessageBox::Yes ) - continue; // don't delete the temp file - } - else if ( ! dest.isLocalFile() ) // no upload when it's already a local file - { - if ( KMessageBox::questionYesNo( 0L, - i18n( "The file\n%1\nhas been modified.\nDo you want to upload the changes?" , dest.prettyUrl()), - i18n( "File Changed" ), KGuiItem(i18n("Upload")), KGuiItem(i18n("Do Not Upload")) ) == KMessageBox::Yes ) - { - kDebug() << "src='" << src << "' dest='" << dest << "'"; - // Do it the synchronous way. - if ( !KIO::NetAccess::upload( src, dest, 0 ) ) - { - KMessageBox::error( 0L, KIO::NetAccess::lastErrorString() ); - continue; // don't delete the temp file - } - } - } - } - - if ((!dest.isLocalFile() || tempfiles) && exit_code == 0) { - // Wait for a reasonable time so that even if the application forks on startup (like OOo or amarok) - // it will have time to start up and read the file before it gets deleted. #130709. - kDebug() << "sleeping..."; - sleep(180); // 3 mn - kDebug() << "about to delete " << src; - unlink( QFile::encodeName(src) ); - } - } - - mExited = true; - QApplication::exit(exit_code); -} - -int main( int argc, char **argv ) -{ - KAboutData aboutData( "kioexec", "kioexec", ki18n("KIOExec"), - KDE_VERSION_STRING, ki18n(description), KAboutData::License_GPL, - ki18n("(c) 1998-2000,2003 The KFM/Konqueror Developers")); - aboutData.addAuthor(ki18n("David Faure"),KLocalizedString(), "faure@kde.org"); - aboutData.addAuthor(ki18n("Stephan Kulow"),KLocalizedString(), "coolo@kde.org"); - aboutData.addAuthor(ki18n("Bernhard Rosenkraenzer"),KLocalizedString(), "bero@arklinux.org"); - aboutData.addAuthor(ki18n("Waldo Bastian"),KLocalizedString(), "bastian@kde.org"); - aboutData.addAuthor(ki18n("Oswald Buddenhagen"),KLocalizedString(), "ossi@kde.org"); - aboutData.setProgramIconName("kde"); - KCmdLineArgs::init( argc, argv, &aboutData ); - - KCmdLineOptions options; - options.add("tempfiles", ki18n("Treat URLs as local files and delete them afterwards")); - options.add("suggestedfilename ", ki18n("Suggested file name for the downloaded file")); - options.add("+command", ki18n("Command to execute")); - options.add("+[URLs]", ki18n("URL(s) or local file(s) used for 'command'")); - KCmdLineArgs::addCmdLineOptions( options ); - - KApplication app; - app.setQuitOnLastWindowClosed(false); - - KIOExec exec; - - // Don't go into the event loop if we already want to exit (#172197) - if (exec.exited()) - return 0; - - return app.exec(); -} - -#include "moc_main.cpp" diff --git a/kioexec/main.h b/kioexec/main.h deleted file mode 100644 index d214189b..00000000 --- a/kioexec/main.h +++ /dev/null @@ -1,66 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999 Torben Weis - Copyright (C) 2000-2005 David Faure - Copyright (C) 2001 Waldo Bastian - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#ifndef KIOEXEC_MAIN_H -#define KIOEXEC_MAIN_H - -#include -#include -#include -#include - -#include - -namespace KIO { class Job; } - -class KJob; - -class KIOExec : public QObject -{ - Q_OBJECT -public: - KIOExec(); - - bool exited() const { return mExited; } - -public Q_SLOTS: - void slotResult( KJob * ); - void slotRunApp(); - -protected: - bool mExited; - bool tempfiles; - QString suggestedFileName; - int counter; - int expectedCounter; - QString command; - struct FileInfo { - QString path; - KUrl url; - int time; - }; - QList fileList; - int jobCounter; - QList jobList; -}; - -#endif diff --git a/knetattach/knetattach.cpp b/knetattach/knetattach.cpp index f9d3958c..80d63d60 100644 --- a/knetattach/knetattach.cpp +++ b/knetattach/knetattach.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -198,7 +197,7 @@ bool KNetAttach::validateCurrentPage() return false; } - KRun::runUrl(url, "inode/directory", this); + KToolInvocation::self()->startServiceForUrl(url.url(), this); QString name = _connectionName->text().trimmed(); diff --git a/konsole/src/Filter.cpp b/konsole/src/Filter.cpp index 63d45e13..86e19c53 100644 --- a/konsole/src/Filter.cpp +++ b/konsole/src/Filter.cpp @@ -20,7 +20,7 @@ // Own #include "Filter.h" -// Qt +// Katie #include #include #include @@ -29,7 +29,7 @@ // KDE #include -#include +#include // Konsole #include "TerminalCharacterDecoder.h" @@ -419,7 +419,7 @@ void UrlFilter::HotSpot::activate(QObject* object) url.prepend("mailto:"); } - new KRun(url, QApplication::activeWindow()); + KToolInvocation::self()->startServiceForUrl(url, QApplication::activeWindow()); } } diff --git a/konsole/src/SessionController.cpp b/konsole/src/SessionController.cpp index 458de8cc..15650ce2 100644 --- a/konsole/src/SessionController.cpp +++ b/konsole/src/SessionController.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -443,7 +442,7 @@ void SessionController::handleWebShortcutAction() if (KUriFilter::self()->filterUri(filterData, QStringList() << "kurisearchfilter")) { const KUrl& url = filterData.uri(); - new KRun(url, QApplication::activeWindow()); + KToolInvocation::self()->startServiceForUrl(url.url(), QApplication::activeWindow()); } } @@ -488,14 +487,14 @@ void SessionController::handleOpenWithAction() const QStringList actionData = action->data().toStringList(); Q_ASSERT(actionData.count() == 2); - KUrl::List actionUrls; + QStringList actionUrls; actionUrls << actionData.at(1); - KRun::run(actionData.at(0), actionUrls, QApplication::activeWindow()); + KToolInvocation::self()->startServiceByStorageId(actionData.at(0), actionUrls, QApplication::activeWindow()); } void SessionController::configureWebShortcuts() { - KToolInvocation::self()->kdeinitExec("kcmshell4", QStringList() << "ebrowsing"); + KToolInvocation::self()->startProgram("kcmshell4", QStringList() << "ebrowsing"); } void SessionController::sendSignal(QAction* action) @@ -973,9 +972,9 @@ void SessionController::openBrowser() KUrl currentUrl = url(); if (currentUrl.isLocalFile()) - new KRun(currentUrl, QApplication::activeWindow(), 0, true, true); + KToolInvocation::self()->startServiceForUrl(currentUrl.url(), QApplication::activeWindow()); else - new KRun(KUrl(QDir::homePath()), QApplication::activeWindow(), 0, true, true); + KToolInvocation::self()->startServiceForUrl(QDir::homePath(), QApplication::activeWindow()); } void SessionController::copy() diff --git a/kstart/kstart.cpp b/kstart/kstart.cpp index e5fa4dec..cfeaedcc 100644 --- a/kstart/kstart.cpp +++ b/kstart/kstart.cpp @@ -97,10 +97,7 @@ KStart::KStart() KStartupInfo::sendFinish(id); // failed to start } } else { - QString error; - if (KToolInvocation::self()->startServiceByDesktopPath(exe, url, &error) != 0) { - kError() << error; - } + KToolInvocation::self()->startServiceByStorageId(exe, QStringList() << url); } QTimer::singleShot(useRule ? 0 : 120 * 1000, qApp, SLOT(quit())); diff --git a/kwin/rules.cpp b/kwin/rules.cpp index da776abc..e892c530 100644 --- a/kwin/rules.cpp +++ b/kwin/rules.cpp @@ -968,7 +968,7 @@ void RuleBook::edit(Client* c, bool whole_app) args << "--wid" << QString::number(c->window()); if (whole_app) args << "--whole-app"; - KToolInvocation::self()->kdeinitExec("kwin_rules_dialog", args); + KToolInvocation::self()->startProgram("kwin_rules_dialog", args); } void RuleBook::load() diff --git a/kwin/useractions.cpp b/kwin/useractions.cpp index 60636eba..524a02b6 100755 --- a/kwin/useractions.cpp +++ b/kwin/useractions.cpp @@ -223,7 +223,7 @@ void UserActionsMenu::configureWM() { QStringList args; args << "--icon" << "preferences-system-windows" << configModules(); - KToolInvocation::self()->kdeinitExec("kcmshell4", args); + KToolInvocation::self()->startProgram("kcmshell4", args); } void UserActionsMenu::init() diff --git a/libs/konq/konq_operations.cpp b/libs/konq/konq_operations.cpp index 5980d503..a514c20d 100644 --- a/libs/konq/konq_operations.cpp +++ b/libs/konq/konq_operations.cpp @@ -89,11 +89,10 @@ KonqOperations::~KonqOperations() void KonqOperations::editMimeType( const QString & mimeType, QWidget* parent ) { - QString keditfiletype = QLatin1String("keditfiletype"); - KRun::runCommand( keditfiletype - + " --parent " + QString::number( (qptrdiff)parent->winId()) - + ' ' + KShell::quoteArg(mimeType), - keditfiletype, keditfiletype /*unused*/, parent ); + QStringList args; + args << "--parent" << QString::number( (qptrdiff)parent->winId()); + args << mimeType; + KToolInvocation::self()->startProgram( QLatin1String("keditfiletype"), args, parent ); } void KonqOperations::del( QWidget * parent, Operation method, const KUrl::List & selectedUrls ) @@ -381,10 +380,9 @@ void KonqOperations::asyncDrop( const KFileItem & destItem ) KConfigGroup desktopGroup = desktopFile.desktopGroup(); if ( desktopFile.hasApplicationType() ) { - QString error; - const QStringList urlStrList = m_info->urls.toStringList(); - if ( KToolInvocation::self()->startServiceByDesktopPath( m_destUrl.path(), urlStrList, &error ) > 0 ) - KMessageBox::error( parentWidget(), error ); + KToolInvocation::self()->startServiceByStorageId( + m_destUrl.path(), m_info->urls.toStringList(), parentWidget() + ); } else { diff --git a/libs/konq/konq_popupmenu.cpp b/libs/konq/konq_popupmenu.cpp index b868316b..95986b46 100644 --- a/libs/konq/konq_popupmenu.cpp +++ b/libs/konq/konq_popupmenu.cpp @@ -30,8 +30,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -44,6 +43,7 @@ #include #include #include +#include #include @@ -479,7 +479,7 @@ KFileItemActions* KonqPopupMenu::fileItemActions() const void KonqPopupMenuPrivate::slotPopupNewView() { Q_FOREACH(const KUrl& url, m_popupItemProperties.urlList()) { - (void) new KRun(url, m_parentWidget); + KToolInvocation::self()->startServiceForUrl(url.url(), m_parentWidget); } } @@ -498,7 +498,7 @@ void KonqPopupMenuPrivate::slotPopupEmptyTrashBin() void KonqPopupMenuPrivate::slotConfigTrashBin() { - KRun::run("kcmshell4 kcmtrash", KUrl::List(), m_parentWidget); + KToolInvocation::self()->startProgram("kcmshell4", QStringList() << "kcmtrash", m_parentWidget); } void KonqPopupMenuPrivate::slotPopupRestoreTrashedItems() @@ -580,7 +580,7 @@ void KonqPopupMenuPrivate::slotShowOriginalFile() } // Now destUrl points to the target file, let's go up to parent dir destUrl.setPath(destUrl.directory()); - KRun::runUrl(destUrl, "inode/directory", m_parentWidget); + KToolInvocation::self()->startServiceForUrl(destUrl.url(), m_parentWidget); } #include "moc_konq_popupmenu.cpp" diff --git a/plasma/applets/devicenotifier/devicenotifier.cpp b/plasma/applets/devicenotifier/devicenotifier.cpp index 441d69dd..ff0137b1 100644 --- a/plasma/applets/devicenotifier/devicenotifier.cpp +++ b/plasma/applets/devicenotifier/devicenotifier.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -308,7 +308,7 @@ void DeviceNotifierWidget::slotIconActivated() mountpoint = solidstorageacces->filePath(); } if (!mountpoint.isEmpty()) { - KRun::runUrl(KUrl(mountpoint), "inode/directory", nullptr); + KToolInvocation::self()->startServiceForUrl(mountpoint); } } diff --git a/plasma/applets/icon/icon.cpp b/plasma/applets/icon/icon.cpp index dd9aa767..cbd52c87 100644 --- a/plasma/applets/icon/icon.cpp +++ b/plasma/applets/icon/icon.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -258,11 +258,10 @@ void IconApplet::openUrl() { if (m_service) { emit releaseVisualFocus(); - KUrl::List urls; - KRun::run(*m_service, urls, 0); + KToolInvocation::self()->startServiceByStorageId(m_service->entryPath()); } else if (m_url.isValid()) { emit releaseVisualFocus(); - new KRun(m_url, 0); + KToolInvocation::self()->startServiceForUrl(m_url.url()); } } @@ -421,7 +420,7 @@ void IconApplet::dropEvent(QGraphicsSceneDragDropEvent *event) constraintsEvent(Plasma::FormFactorConstraint); return; } else if (m_service) { - KRun::run(*m_service, urls, 0); + KToolInvocation::self()->startServiceByStorageId(m_service->entryPath(), urls.toStringList()); return; } @@ -433,24 +432,21 @@ void IconApplet::dropEvent(QGraphicsSceneDragDropEvent *event) KDesktopFile::isDesktopFile(m_url.toLocalFile()))) { if (KDesktopFile::isDesktopFile(m_url.toLocalFile())) { - //Extract the command from the Desktop file - KService service(m_url.toLocalFile()); - KRun::run(service, urls, 0); + KToolInvocation::self()->startServiceByStorageId(m_url.toLocalFile(), urls.toStringList()); return; } // Just exec the local executable - QString params; + QStringList params; foreach (const KUrl &url, urls) { if (url.isLocalFile()) { - params += ' ' + KShell::quoteArg(url.toLocalFile()); + params << url.toLocalFile(); } else { - params += ' ' + KShell::quoteArg(url.prettyUrl()); + params << url.prettyUrl(); } } - QString commandStr = KShell::quoteArg(m_url.path()); - KRun::runCommand(commandStr + ' ' + params, 0); + KToolInvocation::self()->startProgram(m_url.path(), params); } else if (mimetype && mimetype->is("inode/directory")) { dropUrls(urls, m_url, event->modifiers()); } diff --git a/plasma/applets/launcher/launcher.cpp b/plasma/applets/launcher/launcher.cpp index bbcfe223..f8328fd1 100644 --- a/plasma/applets/launcher/launcher.cpp +++ b/plasma/applets/launcher/launcher.cpp @@ -102,20 +102,14 @@ static void kRunService(const QString &entrypath, LauncherApplet* launcherapplet { Q_ASSERT(launcherapplet != nullptr); launcherapplet->resetState(); - - KService::Ptr service = KService::serviceByDesktopPath(entrypath); - Q_ASSERT(!service.isNull()); - if (!KRun::run(*service.data(), KUrl::List(), nullptr)) { - kWarning() << "could not run" << entrypath; - } + KToolInvocation::self()->startServiceByStorageId(entrypath); } static void kRunUrl(const QString &urlpath, LauncherApplet* launcherapplet) { Q_ASSERT(launcherapplet != nullptr); launcherapplet->resetState(); - - (void)new KRun(KUrl(urlpath), nullptr); + KToolInvocation::self()->startServiceForUrl(urlpath); } static KIcon kGenericIcon(const QString &name) @@ -1827,11 +1821,8 @@ KBookmarkManager* LauncherApplet::bookmarkManager() const void LauncherApplet::slotEditMenu() { - if (KToolInvocation::self()->kdeinitExec("kmenuedit") == 0) { - hidePopup(); - } else { - showMessage(KIcon("dialog-error"), i18n("Failed to launch menu editor"), Plasma::MessageButton::ButtonOk); - } + hidePopup(); + KToolInvocation::self()->startServiceByStorageId("kmenuedit"); } void LauncherApplet::slotConfigAccepted() diff --git a/plasma/applets/notifications/jobswidget.cpp b/plasma/applets/notifications/jobswidget.cpp index 444ee3aa..4875f958 100644 --- a/plasma/applets/notifications/jobswidget.cpp +++ b/plasma/applets/notifications/jobswidget.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -224,9 +224,7 @@ void JobFrame::slotIcon0Activated() void JobFrame::slotIcon1Activated() { const KUrl desturl = KUrl(m_iconwidget1->property("_k_desturl").toString()); - const KMimeType::Ptr kmimetype = KMimeType::findByUrl(desturl); - Q_ASSERT(kmimetype); - KRun::runUrl(desturl, kmimetype->name(), nullptr); + KToolInvocation::self()->startServiceForUrl(desturl.url()); } diff --git a/plasma/applets/quicklaunch/launcher.cpp b/plasma/applets/quicklaunch/launcher.cpp index 75214a43..36897c9e 100644 --- a/plasma/applets/quicklaunch/launcher.cpp +++ b/plasma/applets/quicklaunch/launcher.cpp @@ -19,16 +19,13 @@ ***************************************************************************/ #include "launcher.h" -// Qt +// Katie #include #include #include -#include // KDE -#include - -// Plasma +#include #include #include @@ -97,7 +94,7 @@ KUrl Launcher::url() const void Launcher::execute() { - new KRun(m_data.url(), 0); + KToolInvocation::self()->startServiceForUrl(m_data.url().url()); } void Launcher::toolTipAboutToShow() diff --git a/plasma/applets/trash/trash.cpp b/plasma/applets/trash/trash.cpp index 692e1554..ae0d9549 100644 --- a/plasma/applets/trash/trash.cpp +++ b/plasma/applets/trash/trash.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -187,7 +187,7 @@ void Trash::constraintsEvent(Plasma::Constraints constraints) void Trash::open() { emit releaseVisualFocus(); - KRun::runUrl(KUrl("trash:/"), "inode/directory", 0); + KToolInvocation::self()->startServiceForUrl(QString::fromLatin1("trash:/")); } void Trash::empty() diff --git a/plasma/containmentactions/applauncher/launch.cpp b/plasma/containmentactions/applauncher/launch.cpp index cd294aa3..ee8a4308 100644 --- a/plasma/containmentactions/applauncher/launch.cpp +++ b/plasma/containmentactions/applauncher/launch.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include AppLauncher::AppLauncher(QObject *parent, const QVariantList &args) @@ -101,7 +101,7 @@ void AppLauncher::switchTo(QAction *action) { const QString entrypath = action->data().toString(); kDebug() << "running" << entrypath; - new KRun(KUrl(entrypath), nullptr); + KToolInvocation::self()->startServiceByStorageId(entrypath); } #include "moc_launch.cpp" diff --git a/plasma/runners/locations/locationrunner.cpp b/plasma/runners/locations/locationrunner.cpp index ffc10a26..980efeae 100644 --- a/plasma/runners/locations/locationrunner.cpp +++ b/plasma/runners/locations/locationrunner.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -30,8 +30,6 @@ #include #include -#include - LocationsRunner::LocationsRunner(QObject *parent, const QVariantList& args) : Plasma::AbstractRunner(parent, args) @@ -123,9 +121,8 @@ void LocationsRunner::run(const Plasma::QueryMatch &match) // kDebug() << "url: " << location << data; - KUrl urlToRun(KUriFilter::self()->filteredUri(location, QStringList() << QLatin1String("kshorturifilter"))); - - new KRun(urlToRun, nullptr); + KUrl urlToRun = KUriFilter::self()->filteredUri(location, QStringList() << QLatin1String("kshorturifilter")); + KToolInvocation::self()->startServiceForUrl(urlToRun.url()); } QMimeData* LocationsRunner::mimeDataForMatch(const Plasma::QueryMatch &match) diff --git a/plasma/runners/places/placesrunner.cpp b/plasma/runners/places/placesrunner.cpp index 5dd3d680..461a8c03 100644 --- a/plasma/runners/places/placesrunner.cpp +++ b/plasma/runners/places/placesrunner.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include //Q_DECLARE_METATYPE(Plasma::RunnerContext) @@ -127,7 +127,7 @@ void PlacesRunner::run(const Plasma::QueryMatch &action) { //I don't just pass the model index because the list could change before the user clicks on it, which would make everything go wrong. Ideally we don't want things to go wrong. if (action.data().canConvert()) { - new KRun(action.data().value().url(), 0); + KToolInvocation::self()->startServiceForUrl(action.data().value().url()); } else if (action.data().canConvert()) { //search our list for the device with the same udi, then set it up (mount it). QString deviceUdi = action.data().toString(); @@ -158,7 +158,7 @@ void PlacesRunner::setupComplete(QModelIndex index, bool success) KFilePlacesModel *places = qobject_cast(sender()); //kDebug() << "setup complete" << places << sender(); if (success && places) { - new KRun(places->url(index), 0); + KToolInvocation::self()->startServiceForUrl(places->url(index).url()); places->deleteLater(); } } diff --git a/plasma/runners/recentdocuments/recentdocuments.cpp b/plasma/runners/recentdocuments/recentdocuments.cpp index c7649f72..3e31ff07 100644 --- a/plasma/runners/recentdocuments/recentdocuments.cpp +++ b/plasma/runners/recentdocuments/recentdocuments.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include RecentDocuments::RecentDocuments(QObject *parent, const QVariantList &args) @@ -95,7 +95,7 @@ void RecentDocuments::run(const Plasma::QueryMatch &match) { const QString url = match.data().toString(); kDebug() << "Opening Recent Document" << url; - new KRun(url, 0); + KToolInvocation::self()->startServiceForUrl(url); } QMimeData* RecentDocuments::mimeDataForMatch(const Plasma::QueryMatch &match) diff --git a/plasma/runners/services/servicerunner.cpp b/plasma/runners/services/servicerunner.cpp index a3cc2e7f..27f22341 100644 --- a/plasma/runners/services/servicerunner.cpp +++ b/plasma/runners/services/servicerunner.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -191,10 +191,7 @@ void ServiceRunner::match(Plasma::RunnerContext &context) void ServiceRunner::run(const Plasma::QueryMatch &match) { - KService::Ptr service = KService::serviceByStorageId(match.data().toString()); - if (service) { - KRun::run(*service, KUrl::List(), nullptr); - } + KToolInvocation::self()->startServiceByStorageId(match.data().toString()); } QMimeData * ServiceRunner::mimeDataForMatch(const Plasma::QueryMatch &match) diff --git a/plasma/runners/shell/shellrunner.cpp b/plasma/runners/shell/shellrunner.cpp index 34f26743..e7ecd85c 100644 --- a/plasma/runners/shell/shellrunner.cpp +++ b/plasma/runners/shell/shellrunner.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -66,7 +65,7 @@ void ShellRunner::run(const Plasma::QueryMatch &match) if (interminal) { KToolInvocation::self()->invokeTerminal(command); } else { - KRun::runCommand(command, nullptr); + KToolInvocation::self()->startProgram(command); } } diff --git a/plasma/runners/solid/solidrunner.cpp b/plasma/runners/solid/solidrunner.cpp index b361878a..333ddd8f 100644 --- a/plasma/runners/solid/solidrunner.cpp +++ b/plasma/runners/solid/solidrunner.cpp @@ -233,7 +233,7 @@ void SolidRunner::run(const Plasma::QueryMatch &match) return; } const QString actionexe = actioncommand.takeFirst(); - const int actionresult = KToolInvocation::self()->kdeinitExec(actionexe, actioncommand); + const int actionresult = KToolInvocation::self()->startProgram(actionexe, actioncommand); if (actionresult != 0) { kWarning() << "could not execute action for" << actionname << "in" << actionfilepath << actionresult; } diff --git a/plasma/shells/plasma-desktop/plasmaapp.cpp b/plasma/shells/plasma-desktop/plasmaapp.cpp index fd670b47..babad619 100644 --- a/plasma/shells/plasma-desktop/plasmaapp.cpp +++ b/plasma/shells/plasma-desktop/plasmaapp.cpp @@ -1018,7 +1018,7 @@ void PlasmaApp::restoreClients() } QString program = restartcommand.takeFirst(); kDebug() << "restoring client" << program << restartcommand; - KToolInvocation::self()->kdeinitExec(program, restartcommand); + KToolInvocation::self()->startProgram(program, restartcommand); } sessiongroup.deleteGroup(); sessiongroup.sync(); @@ -1159,12 +1159,12 @@ void PlasmaApp::logout(int confirm, int sdtype) void PlasmaApp::captureDesktop() { - KToolInvocation::self()->kdeinitExec("ksnapshot", QStringList() << "--fullscreen"); + KToolInvocation::self()->startProgram("ksnapshot", QStringList() << "--fullscreen"); } void PlasmaApp::captureCurrentWindow() { - KToolInvocation::self()->kdeinitExec("ksnapshot", QStringList() << "--current"); + KToolInvocation::self()->startProgram("ksnapshot", QStringList() << "--current"); } void PlasmaApp::cleanup() diff --git a/plasma/wallpapers/image/image.cpp b/plasma/wallpapers/image/image.cpp index 84a8ef3d..bf6d118f 100644 --- a/plasma/wallpapers/image/image.cpp +++ b/plasma/wallpapers/image/image.cpp @@ -26,9 +26,9 @@ #include #include #include -#include - +#include #include + #include "backgroundlistmodel.h" #include "backgrounddelegate.h" #include "removebuttonmanager.h" @@ -751,9 +751,8 @@ void Image::openSlide() } // open in image viewer - KUrl filepath(m_wallpaperPackage->filePath("preferred")); - //kDebug() << "opening file " << filepath.path(); - new KRun(filepath, NULL); + //kDebug() << "opening file " << m_wallpaperPackage->filePath("preferred"); + KToolInvocation::self()->startServiceForUrl(m_wallpaperPackage->filePath("preferred")); } void Image::renderWallpaper(const QString& image) diff --git a/soliduiserver/soliduiserver_common.h b/soliduiserver/soliduiserver_common.h index 24182908..8b1d7eb6 100644 --- a/soliduiserver/soliduiserver_common.h +++ b/soliduiserver/soliduiserver_common.h @@ -111,9 +111,9 @@ static void kExecuteAction(const KServiceAction &kserviceaction, const Solid::De return; } const QString actionexe = actioncommand.takeFirst(); - const int actionresult = KToolInvocation::self()->kdeinitExec(actionexe, actioncommand); - if (actionresult != 0) { - kWarning() << "could not execute action for" << kserviceaction.name() << actionresult; + const bool actionresult = KToolInvocation::self()->startProgram(actionexe, actioncommand); + if (!actionresult) { + kWarning() << "could not execute action for" << kserviceaction.name(); } } diff --git a/systemsettings/core/ExternalAppModule.cpp b/systemsettings/core/ExternalAppModule.cpp index 400a360d..831afa05 100644 --- a/systemsettings/core/ExternalAppModule.cpp +++ b/systemsettings/core/ExternalAppModule.cpp @@ -19,10 +19,9 @@ #include "ExternalAppModule.h" -#include - +#include #include -#include +#include ExternalAppModule::ExternalAppModule(QWidget * parent, KCModuleInfo * module) { @@ -51,7 +50,9 @@ void ExternalAppModule::showEvent(QShowEvent * event) void ExternalAppModule::runExternal() { - KRun::run( *(moduleInfo->service()), KUrl::List(), qApp->activeWindow() ); // Launch it! + KToolInvocation::self()->startServiceByStorageId( + moduleInfo->service()->entryPath(), QStringList(), qApp->activeWindow() + ); } #include "moc_ExternalAppModule.cpp"