Sped up KAlarm startup mechanism. This resolves bug 1610.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/21/head
Michele Calgaro 9 years ago
parent c036d97d35
commit c2ad4a056c

@ -64,21 +64,21 @@ class NotificationHandler : public TQObject, virtual public AlarmGuiIface
}; };
Daemon* Daemon::mInstance = 0; Daemon* Daemon::mInstance = 0;
NotificationHandler* Daemon::mDcopHandler = 0; NotificationHandler* Daemon::mDcopHandler = 0;
TQValueList<TQString> Daemon::mQueuedEvents; TQValueList<TQString> Daemon::mQueuedEvents;
TQValueList<TQString> Daemon::mSavingEvents; TQValueList<TQString> Daemon::mSavingEvents;
TQTimer* Daemon::mStartTimer = 0; TQTimer* Daemon::mStartTimer = 0;
TQTimer* Daemon::mRegisterTimer = 0; TQTimer* Daemon::mRegisterTimer = 0;
TQTimer* Daemon::mStatusTimer = 0; TQTimer* Daemon::mStatusTimer = 0;
int Daemon::mStatusTimerCount = 0; int Daemon::mStatusTimerCount = 0;
int Daemon::mStatusTimerInterval; int Daemon::mStatusTimerInterval;
int Daemon::mStartTimeout = 0; int Daemon::mStartTimeout = 0;
Daemon::Status Daemon::mStatus = Daemon::STOPPED; Daemon::Status Daemon::mStatus = Daemon::STOPPED;
bool Daemon::mRunning = false; bool Daemon::mRunning = false;
bool Daemon::mCalendarDisabled = false; bool Daemon::mCalendarDisabled = false;
bool Daemon::mEnableCalPending = false; bool Daemon::mEnableCalPending = false;
bool Daemon::mRegisterFailMsg = false; bool Daemon::mRegisterFailMsg = false;
// How frequently to check the daemon's status after starting it. // How frequently to check the daemon's status after starting it.
// This is equal to the length of time we wait after the daemon is registered with DCOP // This is equal to the length of time we wait after the daemon is registered with DCOP
@ -655,7 +655,7 @@ int Daemon::maxTimeSinceCheck()
=============================================================================*/ =============================================================================*/
NotificationHandler::NotificationHandler() NotificationHandler::NotificationHandler()
: DCOPObject(NOTIFY_DCOP_OBJECT), : DCOPObject(NOTIFY_DCOP_OBJECT),
TQObject() TQObject()
{ {
kdDebug(5950) << "NotificationHandler::NotificationHandler()\n"; kdDebug(5950) << "NotificationHandler::NotificationHandler()\n";

@ -73,23 +73,54 @@ AlarmDaemon::AlarmDaemon(bool autostart, TQObject *parent, const char *name)
#ifdef AUTOSTART_KALARM #ifdef AUTOSTART_KALARM
if (autostart) if (autostart)
{ {
/* The alarm daemon is being autostarted. /* The alarm daemon has been autostarted.
* Check if KAlarm needs to be autostarted in the system tray. * Check if also KAlarm needs to be autostarted (by the daemon) in the system tray.
* This should ideally be handled internally by KAlarm, but is done by kalarmd * This should ideally be handled internally by KAlarm, but is done by kalarmd
* for the following reason: * to correctly handle the cases when KAlarm is restored and when it is autostarted.
* KAlarm needs to be both session restored and autostarted, but KDE doesn't * If the autostart request comes before the restoring one, KAlarm would not know
* currently cater properly for this - there is no guarantee that the session * that it is supposed to restore itself and instead would simply open a new window.
* restoration activation will come before the autostart activation. If they * So we first check if the session has been fully restored by the session manager
* come in the wrong order, KAlarm won't know that it is supposed to restore * and if so we can continue safely. If the session hasn't yet been fully restored
* itself and instead will simply open a new window. * or created, we wait for up to 30 seconds and then continue as normal.
*/ */
TDEConfig kaconfig(locate("config", "kalarmrc")); TDEConfig kaconfig(locate("config", "kalarmrc"));
kaconfig.setGroup(TQString::fromLatin1("General")); kaconfig.setGroup(TQString::fromLatin1("General"));
autostart = kaconfig.readBoolEntry(AUTOSTART_TRAY, false); autostart = kaconfig.readBoolEntry(AUTOSTART_TRAY, false);
if (autostart) if (autostart)
{ {
kdDebug(5900) << "AlarmDaemon::AlarmDaemon(): wait to autostart KAlarm\n"; bool done = false;
TQTimer::singleShot(KALARM_AUTOSTART_TIMEOUT * 1000, this, TQT_SLOT(autostartKAlarm())); DCOPClient* client = kapp->dcopClient();
if (client->isApplicationRegistered("ksmserver"))
{
TQByteArray callData;
TQCString replyType;
TQByteArray replyData;
for (int i=0; !done && i<KALARM_AUTOSTART_TIMEOUT; ++i)
{
// Check if the session has been fully created/restored. If not, wait a little and try again
if (!kapp->dcopClient()->call("ksmserver", "ksmserver", "startupCompleted()", callData, replyType, replyData) ||
replyType != "bool")
{
done = true; // In case of DCOP call error, just continue normally
}
else
{
bool result;
TQDataStream replyStream(replyData, IO_ReadOnly);
replyStream >> result;
if (result)
{
done = true; // Session created/restored ==> continue
}
else
{
sleep(1); // Session not yet fully created/restored ==> wait and retry
}
}
}
// Give some extra time to KAlarm to be fully restored, then proceed as usual
TQTimer::singleShot(3000, this, TQT_SLOT(autostartKAlarm()));
}
} }
} }
if (!autostart) if (!autostart)

Loading…
Cancel
Save