diff options
Diffstat (limited to 'kalarm/kalarmd')
-rw-r--r-- | kalarm/kalarmd/Makefile.am | 4 | ||||
-rw-r--r-- | kalarm/kalarmd/adapp.cpp | 2 | ||||
-rw-r--r-- | kalarm/kalarmd/adapp.h | 6 | ||||
-rw-r--r-- | kalarm/kalarmd/adcalendar.cpp | 2 | ||||
-rw-r--r-- | kalarm/kalarmd/adcalendar.h | 2 | ||||
-rw-r--r-- | kalarm/kalarmd/adconfigdata.cpp | 2 | ||||
-rw-r--r-- | kalarm/kalarmd/admain.cpp | 2 | ||||
-rw-r--r-- | kalarm/kalarmd/alarmdaemon.cpp | 65 | ||||
-rw-r--r-- | kalarm/kalarmd/alarmdaemon.h | 2 |
9 files changed, 59 insertions, 28 deletions
diff --git a/kalarm/kalarmd/Makefile.am b/kalarm/kalarmd/Makefile.am index 3b8eafff..88520030 100644 --- a/kalarm/kalarmd/Makefile.am +++ b/kalarm/kalarmd/Makefile.am @@ -2,13 +2,13 @@ INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/kalarm $(all_includes) noinst_LTLIBRARIES = libkalarmd.la -libkalarmd_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +libkalarmd_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor libkalarmd_la_LIBADD = $(LIB_TDECORE) $(top_builddir)/libkcal/libkcal.la libkalarmd_la_SOURCES = alarmdaemoniface.stub alarmguiiface.stub bin_PROGRAMS = kalarmd -kalarmd_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +kalarmd_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor kalarmd_LDADD = $(LIB_TDEUI) $(top_builddir)/libkcal/libkcal.la libkalarmd.la kalarmd_SOURCES = alarmdaemon.cpp admain.cpp adapp.cpp \ adcalendar.cpp adconfigdata.cpp clientinfo.cpp \ diff --git a/kalarm/kalarmd/adapp.cpp b/kalarm/kalarmd/adapp.cpp index 2c9e09dc..3d5f2298 100644 --- a/kalarm/kalarmd/adapp.cpp +++ b/kalarm/kalarmd/adapp.cpp @@ -30,7 +30,7 @@ AlarmDaemonApp::AlarmDaemonApp() - : KUniqueApplication(false, false), + : TDEUniqueApplication(false, false), mAd(0) { disableSessionManagement(); diff --git a/kalarm/kalarmd/adapp.h b/kalarm/kalarmd/adapp.h index 96b24d92..c4a4188d 100644 --- a/kalarm/kalarmd/adapp.h +++ b/kalarm/kalarmd/adapp.h @@ -23,14 +23,14 @@ #ifndef ADAPP_H #define ADAPP_H -#include <kuniqueapplication.h> +#include <tdeuniqueapplication.h> class AlarmDaemon; -class AlarmDaemonApp : public KUniqueApplication +class AlarmDaemonApp : public TDEUniqueApplication { - Q_OBJECT + TQ_OBJECT public: AlarmDaemonApp(); diff --git a/kalarm/kalarmd/adcalendar.cpp b/kalarm/kalarmd/adcalendar.cpp index b1033eb0..699e9684 100644 --- a/kalarm/kalarmd/adcalendar.cpp +++ b/kalarm/kalarmd/adcalendar.cpp @@ -96,7 +96,7 @@ bool ADCalendar::loadFile(bool reset) KURL dest; dest.setPath(mTempFileName); TDEIO::FileCopyJob* job = TDEIO::file_copy(url, dest, -1, true); - connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotDownloadJobResult(TDEIO::Job*))); + connect(job, TQ_SIGNAL(result(TDEIO::Job*)), TQ_SLOT(slotDownloadJobResult(TDEIO::Job*))); } return true; } diff --git a/kalarm/kalarmd/adcalendar.h b/kalarm/kalarmd/adcalendar.h index bbc96214..3ba59978 100644 --- a/kalarm/kalarmd/adcalendar.h +++ b/kalarm/kalarmd/adcalendar.h @@ -29,7 +29,7 @@ class ADCalendar; // Alarm Daemon calendar access class ADCalendar : public KCal::CalendarLocal { - Q_OBJECT + TQ_OBJECT public: typedef TQValueList<ADCalendar*>::ConstIterator ConstIterator; diff --git a/kalarm/kalarmd/adconfigdata.cpp b/kalarm/kalarmd/adconfigdata.cpp index b0f7850d..75179185 100644 --- a/kalarm/kalarmd/adconfigdata.cpp +++ b/kalarm/kalarmd/adconfigdata.cpp @@ -24,7 +24,7 @@ #include <tqstringlist.h> #include <tdeconfig.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <kdebug.h> #include "adcalendar.h" diff --git a/kalarm/kalarmd/admain.cpp b/kalarm/kalarmd/admain.cpp index a5d9fd16..b1533e4a 100644 --- a/kalarm/kalarmd/admain.cpp +++ b/kalarm/kalarmd/admain.cpp @@ -49,7 +49,7 @@ int main(int argc, char** argv) TDECmdLineArgs::init(argc, argv, &aboutData); TDECmdLineArgs::addCmdLineOptions(options); - KUniqueApplication::addCmdLineOptions(); + TDEUniqueApplication::addCmdLineOptions(); TDEStartupInfo::disableAutoAppStartedSending(); if (!AlarmDaemonApp::start()) diff --git a/kalarm/kalarmd/alarmdaemon.cpp b/kalarm/kalarmd/alarmdaemon.cpp index 3b7f7456..8759c171 100644 --- a/kalarm/kalarmd/alarmdaemon.cpp +++ b/kalarm/kalarmd/alarmdaemon.cpp @@ -29,8 +29,8 @@ #include <tqdatetime.h> #include <tdeapplication.h> -#include <kstandarddirs.h> -#include <kprocess.h> +#include <tdestandarddirs.h> +#include <tdeprocess.h> #include <tdeio/netaccess.h> #include <dcopclient.h> #include <tdeconfig.h> @@ -73,23 +73,54 @@ AlarmDaemon::AlarmDaemon(bool autostart, TQObject *parent, const char *name) #ifdef AUTOSTART_KALARM if (autostart) { - /* The alarm daemon is being autostarted. - * Check if KAlarm needs to be autostarted in the system tray. + /* The alarm daemon has been autostarted. + * 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 - * for the following reason: - * KAlarm needs to be both session restored and autostarted, but KDE doesn't - * currently cater properly for this - there is no guarantee that the session - * restoration activation will come before the autostart activation. If they - * come in the wrong order, KAlarm won't know that it is supposed to restore - * itself and instead will simply open a new window. + * to correctly handle the cases when KAlarm is restored and when it is autostarted. + * If the autostart request comes before the restoring one, KAlarm would not know + * that it is supposed to restore itself and instead would simply open a new window. + * So we first check if the session has been fully restored by the session manager + * and if so we can continue safely. If the session hasn't yet been fully restored + * or created, we wait for up to 30 seconds and then continue as normal. */ TDEConfig kaconfig(locate("config", "kalarmrc")); kaconfig.setGroup(TQString::fromLatin1("General")); autostart = kaconfig.readBoolEntry(AUTOSTART_TRAY, false); if (autostart) { - kdDebug(5900) << "AlarmDaemon::AlarmDaemon(): wait to autostart KAlarm\n"; - TQTimer::singleShot(KALARM_AUTOSTART_TIMEOUT * 1000, this, TQT_SLOT(autostartKAlarm())); + bool done = false; + DCOPClient* client = tdeApp->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 (!tdeApp->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, TQ_SLOT(autostartKAlarm())); + } } } if (!autostart) @@ -137,7 +168,7 @@ void AlarmDaemon::startMonitoring() { // Set up the alarm timer mAlarmTimer = new TQTimer(this); - connect(mAlarmTimer, TQT_SIGNAL(timeout()), TQT_SLOT(checkAlarmsSlot())); + connect(mAlarmTimer, TQ_SIGNAL(timeout()), TQ_SLOT(checkAlarmsSlot())); setTimerStatus(); // Start monitoring calendar files. @@ -185,7 +216,7 @@ void AlarmDaemon::reloadCal(ADCalendar* cal, bool reset) { cal->close(); if (!cal->setLoadedConnected()) - connect(cal, TQT_SIGNAL(loaded(ADCalendar*, bool)), TQT_SLOT(calendarLoaded(ADCalendar*, bool))); + connect(cal, TQ_SIGNAL(loaded(ADCalendar*, bool)), TQ_SLOT(calendarLoaded(ADCalendar*, bool))); cal->loadFile(reset); } else if (reset) @@ -481,12 +512,12 @@ bool AlarmDaemon::notifyEvent(ADCalendar* calendar, const TQString& eventID) TQString id = TQString::fromLatin1("ad:") + eventID; // prefix to indicate that the notification if from the daemon // Check if the client application is running and ready to receive notification - bool registered = kapp->dcopClient()->isApplicationRegistered(static_cast<const char*>(appname)); + bool registered = tdeApp->dcopClient()->isApplicationRegistered(static_cast<const char*>(appname)); bool ready = registered; if (registered) { // It's running, but check if it has created our DCOP interface yet - QCStringList objects = kapp->dcopClient()->remoteObjects(appname); + QCStringList objects = tdeApp->dcopClient()->remoteObjects(appname); if (objects.find(client->dcopObject()) == objects.end()) ready = false; } @@ -575,7 +606,7 @@ void AlarmDaemon::notifyCalStatus(const ADCalendar* cal) if (!client) return; TQCString appname = client->appName(); - if (kapp->dcopClient()->isApplicationRegistered(static_cast<const char*>(appname))) + if (tdeApp->dcopClient()->isApplicationRegistered(static_cast<const char*>(appname))) { KAlarmd::CalendarStatus change = cal->available() ? (cal->enabled() ? KAlarmd::CALENDAR_ENABLED : KAlarmd::CALENDAR_DISABLED) : KAlarmd::CALENDAR_UNAVAILABLE; diff --git a/kalarm/kalarmd/alarmdaemon.h b/kalarm/kalarmd/alarmdaemon.h index a3260a58..85509ebd 100644 --- a/kalarm/kalarmd/alarmdaemon.h +++ b/kalarm/kalarmd/alarmdaemon.h @@ -31,7 +31,7 @@ class ADCalendar; class AlarmDaemon : public TQObject, virtual public AlarmDaemonIface { - Q_OBJECT + TQ_OBJECT public: AlarmDaemon(bool autostart, TQObject* parent = 0, const char* name = 0); |