[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kinit] src/klauncher: Lookup paths for kioslaves in KLauncher
From:       Alex Merry <alex.merry () kde ! org>
Date:       2014-03-22 14:58:30
Message-ID: E1WRNNW-0005Gd-5s () scm ! kde ! org
[Download RAW message or body]

Git commit a556c328ad4cf79a5ba037b492f9e55d2553bdae by Alex Merry.
Committed on 22/03/2014 at 13:11.
Pushed by alexmerry into branch 'master'.

Lookup paths for kioslaves in KLauncher

If you pass kdeinit anything other than an absolute path, it assumes it
is a normal kdeinit executable - ie, it is an executable <name> in
$PATH, optionally with a libkdeinit5_<name> in a library path.

kioslaves are actually installed as plugins, though, so we do the lookup
in klauncher's requestSlave() function and pass an absolute path to
kdeinit.

REVIEW: 116935

M  +14   -8    src/klauncher/klauncher.cpp

http://commits.kde.org/kinit/a556c328ad4cf79a5ba037b492f9e55d2553bdae

diff --git a/src/klauncher/klauncher.cpp b/src/klauncher/klauncher.cpp
index 1b02fa3..eeb1550 100644
--- a/src/klauncher/klauncher.cpp
+++ b/src/klauncher/klauncher.cpp
@@ -45,9 +45,9 @@
 
 #include <kconfig.h>
 #include <QDebug>
-#include <klibrary.h>
 #include <klocalizedstring.h>
 #include <kdesktopfile.h>
+#include <kpluginloader.h> // to find kioslave modules
 #include <kprotocolmanager.h>
 #include <kprotocolinfo.h>
 #include <krun.h> // TODO port away from kiofilewidgets
@@ -143,7 +143,7 @@ KLauncher::KLauncher()
         // Slave debug mode causes kdeinit to suspend the process waiting
         // for the developer to attach gdb to the process; we do not have
         // a good way of doing a similar thing if we are using QProcess.
-        mSlaveDebug = QString();
+        mSlaveDebug.clear();
         qWarning("slave-debug mode is not available as Klauncher is not using kdeinit");
 #endif
     }
@@ -1023,19 +1023,25 @@ KLauncher::requestSlave(const QString &protocol,
         return slave->pid();
     }
 
-    QString name = KProtocolInfo::exec(protocol);
-    if (name.isEmpty()) {
+    QString slaveModule = KProtocolInfo::exec(protocol);
+    if (slaveModule.isEmpty()) {
         error = i18n("Unknown protocol '%1'.\n", protocol);
         return 0;
     }
+    KPluginLoader loader(slaveModule);
+    QString slaveModulePath = loader.fileName();
+    if (slaveModulePath.isEmpty()) {
+        error = i18n("Could not find the '%1' plugin.\n", slaveModule);
+        return 0;
+    }
 
     QStringList arg_list;
 #ifdef USE_KPROCESS_FOR_KIOSLAVES
-    arg_list << name;
+    arg_list << slaveModulePath;
     arg_list << protocol;
     arg_list << mConnectionServer.address().toString();
     arg_list << app_socket;
-    name = QFile::decodeName(CMAKE_INSTALL_PREFIX "/" LIBEXEC_INSTALL_DIR "/kioslave");
+    QString name = QFile::decodeName(CMAKE_INSTALL_PREFIX "/" LIBEXEC_INSTALL_DIR "/kioslave");
 #else
     QString arg1 = protocol;
     QString arg2 = mConnectionServer.address().toString();
@@ -1043,6 +1049,7 @@ KLauncher::requestSlave(const QString &protocol,
     arg_list.append(arg1);
     arg_list.append(arg2);
     arg_list.append(arg3);
+    QString name = slaveModulePath;
 #endif
 
     // qDebug() << "KLauncher: launching new slave " << name << " with protocol=" << protocol
@@ -1059,8 +1066,7 @@ KLauncher::requestSlave(const QString &protocol,
     }
 #endif
     if (mSlaveValgrind == protocol) {
-        KLibrary lib(name);
-        arg_list.prepend(lib.fileName());
+        arg_list.prepend(name);
 #ifndef USE_KPROCESS_FOR_KIOSLAVES // otherwise we've already done this
         arg_list.prepend(QFile::decodeName(CMAKE_INSTALL_PREFIX "/" LIBEXEC_INSTALL_DIR "/kioslave"));
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic