Blob Blame History Raw
diff -ur kdelibs-4.0.99/kdecore/kernel/kstandarddirs.cpp kdelibs-4.0.99-kstandarddirs/kdecore/kernel/kstandarddirs.cpp
--- kdelibs-4.0.99/kdecore/kernel/kstandarddirs.cpp	2008-07-09 15:28:22.000000000 +0200
+++ kdelibs-4.0.99-kstandarddirs/kdecore/kernel/kstandarddirs.cpp	2008-07-20 18:13:28.000000000 +0200
@@ -75,9 +75,12 @@
     bool checkRestrictions : 1;
     QMap<QByteArray, bool> restrictions;
     QStringList xdgdata_prefixes;
+    QString localXdgdatahome;
     QStringList xdgconf_prefixes;
+    QString localXdgconfhome;
 
     QStringList prefixes;
+    QString localKdehome;
 
     // Directory dictionaries
     QMap<QByteArray, QStringList> absolutes;
@@ -953,12 +956,65 @@
                 restrictionActive = true;
             d->dataRestrictionActive = false; // Reset
         }
+        const QStringList *prefixList = 0;
+        QString home;
+        if (strncmp(type, "xdgdata-", 8) == 0)
+        {
+            prefixList = &(d->xdgdata_prefixes);
+            home=d->localXdgdatahome;
+        }
+            else if (strncmp(type, "xdgconf-", 8) == 0)
+        {
+            prefixList = &(d->xdgconf_prefixes);
+            home=d->localXdgconfhome;
+        }
+            else
+        {
+            prefixList = &d->prefixes;
+            home=d->localKdehome;
+        }
 
         QStringList dirs;
         dirs = d->relatives.value(type);
         QString installdir = installPath( type );
         QString installprefix = installPath("kdedir");
 
+        if(!home.isNull())
+        {
+                for (QStringList::ConstIterator it = dirs.begin();
+                     it != dirs.end(); ++it)
+                {
+                    if ( (*it).startsWith('%'))
+                        continue;
+                    QString path = realPath( home + *it );
+                    testdir.setPath(path);
+                    if (restrictionActive)
+                        continue;
+                    if (!candidates.contains(path))
+                        candidates.append(path);
+                }
+
+        }
+ 
+        // make sure we find the path where it's installed
+        // we want the installed path _first_, so /usr/share/kde4 takes precedence over /usr/share
+        // except for config files, so profiles take precedence
+        // except for exe files too, so /usr/libexec/kde4 takes precedence over /usr/bin
+        if (strcmp("config", type) && strcmp("exe", type)) {
+            if (!installdir.isEmpty()) {
+                bool ok = true;
+                foreach (const QString &s, candidates) {
+                    if (installdir.startsWith(s)) {
+                        ok = false;
+                        break;
+                    }
+                }
+                if (ok) {
+                        candidates.append(installdir);
+                }
+            }
+        }
+
         if (!dirs.isEmpty())
         {
             bool local = true;
@@ -984,45 +1040,34 @@
                 }
             }
 
-            const QStringList *prefixList = 0;
-            if (strncmp(type, "xdgdata-", 8) == 0)
-                prefixList = &(d->xdgdata_prefixes);
-            else if (strncmp(type, "xdgconf-", 8) == 0)
-                prefixList = &(d->xdgconf_prefixes);
-            else
-                prefixList = &d->prefixes;
 
             for (QStringList::ConstIterator pit = prefixList->begin();
                  pit != prefixList->end();
                  ++pit)
             {
-	        if((*pit)!=installprefix||installdir.isEmpty())
-	        {
-                    for (QStringList::ConstIterator it = dirs.begin();
-                         it != dirs.end(); ++it)
-                    {
-                        if ( (*it).startsWith('%'))
-                            continue;
-                        QString path = realPath( *pit + *it );
-                        testdir.setPath(path);
-                        if (local && restrictionActive)
-                            continue;
-                        if ((local || testdir.exists()) && !candidates.contains(path))
-                            candidates.append(path);
-                    }
-                    local = false;
+                for (QStringList::ConstIterator it = dirs.begin();
+                     it != dirs.end(); ++it)
+                {
+                    if ( (*it).startsWith('%'))
+                        continue;
+                    QString path = realPath( *pit + *it );
+                    testdir.setPath(path);
+                    if (local && restrictionActive)
+                        continue;
+                    if ((local || testdir.exists()) && !candidates.contains(path))
+                        candidates.append(path);
                 }
-	        else
-	        {
-                    // we have a custom install path, so use this instead of <installprefix>/<relative dir>
-	            testdir.setPath(installdir);
-                    if(testdir.exists() && ! candidates.contains(installdir))
-                        candidates.append(installdir);
-	        }
+                // UGLY HACK - forward porting Chris Cheney's HACK - Rex Dieter
+                if ( local && (!strcmp("config", type)))
+                   candidates.append("/etc/kde/");
+                //
+                local = false;
 	    }
         }
 
-        // make sure we find the path where it's installed
+        // find the installed path for all resource types
+        // some code expects it to always come last, so we list it again even if
+        // we had it already at the beginning
         if (!installdir.isEmpty()) {
             bool ok = true;
             foreach (const QString &s, candidates) {
@@ -1501,6 +1546,7 @@
     {
         localKdeDir = KShell::tildeExpand(localKdeDir);
         addPrefix(localKdeDir);
+        d->localKdehome=localKdeDir;
     }
 
 #ifdef Q_WS_MACX
@@ -1559,6 +1605,7 @@
 
     localXdgDir = KShell::tildeExpand(localXdgDir);
     addXdgConfigPrefix(localXdgDir);
+    d->localXdgconfhome=localXdgDir;
 
     for (QStringList::ConstIterator it = xdgdirList.begin();
          it != xdgdirList.end(); ++it)
@@ -1607,6 +1654,7 @@
 
     localXdgDir = KShell::tildeExpand(localXdgDir);
     addXdgDataPrefix(localXdgDir);
+    d->localXdgdatahome=localXdgDir;
 
     for (QStringList::ConstIterator it = xdgdirList.begin();
          it != xdgdirList.end(); ++it)