File 04_startup_phases_kdelibs.patch of Package kdelibs3

diff -u -p -d -N -r kdelibs.sav/kded/kded.cpp kdelibs/kded/kded.cpp
--- kdelibs.sav/kded/kded.cpp	2005-10-10 17:19:52.000000000 +0200
+++ kdelibs/kded/kded.cpp	2005-11-30 17:10:16.000000000 +0100
@@ -162,7 +162,24 @@ void Kded::initModules()
          bool autoload = service->property("X-KDE-Kded-autoload", QVariant::Bool).toBool();
          config->setGroup(QString("Module-%1").arg(service->desktopEntryName()));
          autoload = config->readBoolEntry("autoload", autoload);
-         if (autoload && kde_running)
+         // see ksmserver's README for description of the phases
+         QVariant phasev = service->property("X-KDE-Kded-phase", QVariant::Int );
+         int phase = phasev.isValid() ? phasev.toInt() : 2;
+         bool prevent_autoload = false;
+         switch( phase )
+         {
+             case 0: // always autoload
+                 break;
+             case 1: // autoload only in KDE
+                 if( !kde_running )
+                     prevent_autoload = true;
+                 break;
+             case 2: // autoload delayed, only in KDE
+             default:
+                 prevent_autoload = true;
+                 break;
+         }
+         if (autoload && !prevent_autoload)
             loadModule(service, false);
 
          bool dontLoad = false;
@@ -177,6 +194,23 @@ void Kded::initModules()
      }
 }
 
+void Kded::loadSecondPhase()
+{
+     kdDebug(7020) << "Loading second phase autoload" << endl;
+     KConfig *config = kapp->config();
+     KService::List kdedModules = KServiceType::offers("KDEDModule");
+     for(KService::List::ConstIterator it = kdedModules.begin(); it != kdedModules.end(); ++it)
+     {
+         KService::Ptr service = *it;
+         bool autoload = service->property("X-KDE-Kded-autoload", QVariant::Bool).toBool();
+         config->setGroup(QString("Module-%1").arg(service->desktopEntryName()));
+         autoload = config->readBoolEntry("autoload", autoload);
+         QVariant phasev = service->property("X-KDE-Kded-phase", QVariant::Int );
+         int phase = phasev.isValid() ? phasev.toInt() : 2;
+         if( phase == 2 && autoload )
+            loadModule(service, false);
+     }
+}
 
 void Kded::noDemandLoad(const QString &obj)
 {
@@ -713,7 +747,7 @@ public:
     {
        if (startup) {
           startup = false;
-	  QTimer::singleShot(500, Kded::self(), SLOT(initModules()));
+          Kded::self()->initModules();
        } else 
           runBuildSycoca();
 
@@ -729,6 +763,7 @@ public:
        res += "void unregisterWindowId(long int)";
        res += "QCStringList loadedModules()";
        res += "void reconfigure()";
+       res += "void loadSecondPhase()";
        res += "void quit()";
        return res;
     }
@@ -786,6 +821,11 @@ public:
       replyType = "void";
       return true;
     }
+    else if (fun == "loadSecondPhase()") {
+      Kded::self()->loadSecondPhase();
+      replyType = "void";
+      return true;
+    }
     else if (fun == "quit()") {
       quit();
       replyType = "void";
diff -u -p -d -N -r kdelibs.sav/kded/kded.h kdelibs/kded/kded.h
--- kdelibs.sav/kded/kded.h	2005-09-29 21:32:19.000000000 +0200
+++ kdelibs/kded/kded.h	2005-11-30 17:10:16.000000000 +0100
@@ -72,6 +72,7 @@ public:
    void registerWindowId(long windowId);
    void unregisterWindowId(long windowId);
    void recreate(bool initial);
+   void loadSecondPhase();
 
 public slots:
    /**
diff -u -p -d -N -r kdelibs.sav/kinit/autostart.cpp kdelibs/kinit/autostart.cpp
--- kdelibs.sav/kinit/autostart.cpp	2005-09-29 21:31:28.000000000 +0200
+++ kdelibs/kinit/autostart.cpp	2005-11-30 17:10:21.000000000 +0100
@@ -43,7 +43,7 @@ public:
 };
 
 AutoStart::AutoStart()
-  : m_phase(0), m_phasedone(false)
+  : m_phase(-1), m_phasedone(false)
 {
   m_startList = new AutoStartList;
   m_startList->setAutoDelete(true);
@@ -122,9 +122,9 @@ AutoStart::loadAutoStartList()
        item->name = extractName(*it);
        item->service = *it;
        item->startAfter = config.readEntry("X-KDE-autostart-after");
-       item->phase = config.readNumEntry("X-KDE-autostart-phase", 1);
-       if (item->phase < 1)
-          item->phase = 1;
+       item->phase = config.readNumEntry("X-KDE-autostart-phase", 2);
+       if (item->phase < 0)
+          item->phase = 0;
        m_startList->append(item);
    }
 } 
diff -u -p -d -N -r kdelibs.sav/kinit/klauncher.cpp kdelibs/kinit/klauncher.cpp
--- kdelibs.sav/kinit/klauncher.cpp	2005-10-10 17:19:25.000000000 +0200
+++ kdelibs/kinit/klauncher.cpp	2005-11-30 17:10:21.000000000 +0100
@@ -674,7 +674,7 @@ KLauncher::autoStart(int phase)
    if( mAutoStart.phase() >= phase )
        return;
    mAutoStart.setPhase(phase);
-   if (phase == 1)
+   if (phase == 0)
       mAutoStart.loadAutoStartList();
    mAutoTimer.start(0, true);
 }
@@ -693,10 +693,8 @@ KLauncher::slotAutoStart()
 	 {
 	    mAutoStart.setPhaseDone();
 	    // Emit signal
-	    QCString autoStartSignal( "autoStartDone()" );
-	    int phase = mAutoStart.phase();
-	    if ( phase > 1 )
-	        autoStartSignal.sprintf( "autoStart%dDone()", phase );
+	    QCString autoStartSignal;
+            autoStartSignal.sprintf( "autoStart%dDone()", mAutoStart.phase());
             emitDCOPSignal(autoStartSignal, QByteArray());
 	 }
          return;
openSUSE Build Service is sponsored by