$OpenBSD: patch-kdecore_kernel_kstandarddirs_cpp,v 1.1 2013/04/24 19:45:29 zhuk Exp $
Provide "libexec" resource type by default, and check for libexec items
first by default when searching for executables.
--- kdecore/kernel/kstandarddirs.cpp.orig	Mon Dec 17 18:14:17 2012
+++ kdecore/kernel/kstandarddirs.cpp	Mon Jan  7 19:03:17 2013
@@ -279,6 +279,7 @@ QStringList KStandardDirs::allTypes() const
         list.append(QLatin1String(types_string + types_indices[i]));
     // Those are added manually by addKDEDefaults
     list.append(QString::fromLatin1("lib"));
+    list.append(QString::fromLatin1("libexec"));
     //list.append(QString::fromLatin1("home")); // undocumented on purpose, said Waldo in r113855.
 
     // Those are handled by resourceDirs() itself
@@ -473,8 +474,12 @@ QString KStandardDirs::findResource( const char *type,
         filename += QLatin1String(".exe");
     }
 #endif
-    const QString dir = findResourceDir(type, filename);
+    QString dir;
+    if (!strcmp(type, "exe"))
+        dir = findResourceDir("libexec", filename);
     if (dir.isEmpty())
+        dir = findResourceDir(type, filename);
+    if (dir.isEmpty())
       return dir;
     else
       return !KGlobal::hasLocale() ? dir + filename
@@ -1341,7 +1346,7 @@ QString KStandardDirs::findExe( const QString& appname
                                 const QString& pstr,
                                 SearchOptions options )
 {
-    //kDebug(180) << "findExe(" << appname << ", pstr, " << ignoreExecBit << ") called";
+    kDebug(180) << "findExe(" << appname << ", pstr, " << options << ") called";
 
 #ifdef Q_OS_WIN
     QStringList executable_extensions = executableExtensions();
@@ -1371,7 +1376,7 @@ QString KStandardDirs::findExe( const QString& appname
     QString p = installPath("libexec") + appname;
     QString result = checkExecutable(p, options & IgnoreExecBit);
     if (!result.isEmpty()) {
-        //kDebug(180) << "findExe(): returning " << result;
+        kDebug(180) << "findExe(): returning libexec item " << result;
         return result;
     }
 
@@ -1385,7 +1390,7 @@ QString KStandardDirs::findExe( const QString& appname
         // Check for executable in this tokenized path
         result = checkExecutable(p, options & IgnoreExecBit);
         if (!result.isEmpty()) {
-            //kDebug(180) << "findExe(): returning " << result;
+            kDebug(180) << "findExe(): returning PATH item " << result;
             return result;
         }
     }
@@ -1395,14 +1400,14 @@ QString KStandardDirs::findExe( const QString& appname
     p += appname;
     result = checkExecutable(p, options & IgnoreExecBit);
     if (!result.isEmpty()) {
-        //kDebug(180) << "findExe(): returning " << result;
+        kDebug(180) << "findExe(): returning KDE bin " << result;
         return result;
     }
 
     // If we reach here, the executable wasn't found.
     // So return empty string.
 
-    //kDebug(180) << "findExe(): failed, nothing matched";
+    kDebug(180) << "findExe(): failed, nothing matched";
     return QString();
 }
 
