File kde3-autostart.diff of Package kdelibs4

--- kinit/autostart.cpp.sav	2008-02-04 15:34:25.000000000 +0100
+++ kinit/autostart.cpp	2008-02-04 17:18:18.000000000 +0100
@@ -23,7 +23,10 @@
 #include <kconfiggroup.h>
 #include <kdesktopfile.h>
 #include <kglobal.h>
+#include <kshell.h>
 #include <kstandarddirs.h>
+#include <qdir.h>
+#include <stdlib.h>
 
 class AutoStartItem
 {
@@ -76,7 +79,7 @@ static QString extractName(QString path)
   return path;
 }
 
-static bool startCondition(const QString &condition)
+static bool startCondition(const QString &condition, const QString& file)
 {
   if (condition.isEmpty())
      return true;
@@ -87,6 +90,13 @@ static bool startCondition(const QString
   if (list[0].isEmpty() || list[2].isEmpty())
      return true;
 
+  if( file.startsWith( "/etc/opt/kde3/" ) || file.startsWith( "/opt/kde3/" ))
+  {
+    QString cmd = QString( "/opt/kde3/bin/kreadconfig --file %1 --group %2 --key %3 --default %4 --type bool" )
+        .arg( KShell::quoteArg( list[0] ), KShell::quoteArg( list[1] ), KShell::quoteArg( list[2] ),
+            KShell::quoteArg( list[3] ));
+    return system( cmd.toLocal8Bit()) == 0;
+  }
   KConfig config(list[0], KConfig::NoGlobals);
   KConfigGroup cg(&config, list[1]);
 
@@ -99,6 +109,8 @@ void
 AutoStart::loadAutoStartList()
 {
    QStringList files = KGlobal::dirs()->findAllResources("autostart", "*.desktop", KStandardDirs::NoDuplicates);
+   
+   files = mergeKDE3Autostart( files );
 
    for(QStringList::ConstIterator it = files.begin();
        it != files.end();
@@ -106,7 +118,7 @@ AutoStart::loadAutoStartList()
    {
        KDesktopFile config(*it);
        const KConfigGroup grp = config.desktopGroup();
-       if (!startCondition(grp.readEntry("X-KDE-autostart-condition")))
+       if (!startCondition(grp.readEntry("X-KDE-autostart-condition"), *it))
           continue;
        if (!config.tryExec())
           continue;
@@ -135,6 +147,30 @@ AutoStart::loadAutoStartList()
    }
 }
 
+// KStandardDirs cannot be used for KDE3, because it applies KDE4 prefixes,
+// so KDE3 files need to be found manually. Also, include only KDE3 autostart
+// items that don't have their normal equivalent - this way it is possible
+// for KDE4 to blacklist e.g. KDE3's Kicker by using its own .desktop
+// file with Hidden=true.
+QStringList
+AutoStart::mergeKDE3Autostart( QStringList autostart )
+{
+    QStringList dupecheck;
+    foreach( QString file, autostart )
+        dupecheck.append( QString( file ).mid( file.lastIndexOf( '/' ) + 1 ));
+    foreach( QString prefix, QStringList() << "/etc/opt/kde3/" << "/opt/kde3" )
+    {
+        foreach( QString name, QDir( prefix + "/share/autostart/" ).entryList( QStringList() << "*.desktop", QDir::Files ))
+        {
+            if( dupecheck.contains( name ))
+                continue;
+            autostart.append( prefix + "/share/autostart/" + name ); // add it to the list
+            dupecheck.append( name );
+        }
+    }
+    return autostart;
+}
+
 QString
 AutoStart::startService()
 {
--- kinit/autostart.h.sav	2007-02-28 17:19:10.000000000 +0100
+++ kinit/autostart.h	2008-02-04 16:23:17.000000000 +0100
@@ -39,6 +39,7 @@ public:
   bool    phaseDone() const { return m_phasedone; }
 
 private:
+  static QStringList mergeKDE3Autostart( QStringList autostart );
   AutoStartList *m_startList;  
   QStringList m_started;
   int m_phase;
openSUSE Build Service is sponsored by