summaryrefslogtreecommitdiff
authorsandman <sandman>2002-12-10 22:15:30 (UTC)
committer sandman <sandman>2002-12-10 22:15:30 (UTC)
commit2173e57fcbd5d460fceb34a111845389dca56506 (patch) (side-by-side diff)
tree462b451f7c75e3960472468c55ae0037595d1af1
parent51f44c6a22971d6f60f5e36523d9efbeaa8aec55 (diff)
downloadopie-2173e57fcbd5d460fceb34a111845389dca56506.zip
opie-2173e57fcbd5d460fceb34a111845389dca56506.tar.gz
opie-2173e57fcbd5d460fceb34a111845389dca56506.tar.bz2
don't use atd anymore - our atd is only simple shell script, so better get
rid of it.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/alarmserver.cpp91
1 files changed, 74 insertions, 17 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp
index 5e4dd18..2ea4025 100644
--- a/library/alarmserver.cpp
+++ b/library/alarmserver.cpp
@@ -40,3 +40,8 @@
-struct timerEventItem {
+
+#undef USE_ATD // not used anymore -- we run opie-alarm on suspend/resume
+
+
+struct timerEventItem
+{
time_t UTCtime;
@@ -56,4 +61,6 @@ class TimerReceiverObject : public QObject
public:
- TimerReceiverObject() { }
- ~TimerReceiverObject() { }
+ TimerReceiverObject()
+ { }
+ ~TimerReceiverObject()
+ { }
void resetTimer();
@@ -63,4 +70,7 @@ protected:
void timerEvent( QTimerEvent *te );
+
+#ifdef USE_ATD
private:
QString atfilename;
+#endif
};
@@ -117,3 +127,4 @@ static void saveState()
unlink( savefilename );
- QDir d; d.rename(savefilename+".new",savefilename);
+ QDir d;
+ d.rename(savefilename + ".new", savefilename);
@@ -150,3 +161,3 @@ void AlarmServer::initialize()
-
+#ifdef USE_ATD
@@ -162,3 +173,4 @@ static bool triggerAtd( bool writeHWClock = FALSE )
trigger.close();
- QFile::remove( trigger.name() );
+ QFile::remove
+ ( trigger.name() );
return FALSE;
@@ -170,4 +182,23 @@ static bool triggerAtd( bool writeHWClock = FALSE )
+#else
+
+static bool writeResumeAt ( time_t wakeup )
+{
+ FILE *fp = ::fopen ( "/var/run/resumeat", "w" );
+
+ if ( fp ) {
+ ::fprintf ( fp, "%d\n", (int) wakeup );
+ ::fclose ( fp );
+ }
+ else
+ qWarning ( "Failed to write wakeup time to /var/run/resumeat" );
+
+ return ( fp );
+}
+
+#endif
+
void TimerReceiverObject::deleteTimer()
{
+#ifdef USE_ATD
if ( !atfilename.isEmpty() ) {
@@ -177,2 +208,5 @@ void TimerReceiverObject::deleteTimer()
}
+#else
+ writeResumeAt ( 0 );
+#endif
}
@@ -182,3 +216,2 @@ void TimerReceiverObject::resetTimer()
const int maxsecs = 2147000;
- int total_written;
QDateTime nearest = TimeConversion::fromUTC(nearestTimerEvent->UTCtime);
@@ -198,2 +231,5 @@ void TimerReceiverObject::resetTimer()
// qDebug("reset timer to %d seconds from Epoch",at_secs);
+
+#ifdef USE_ATD
+
QString fn = atdir + QString::number(at_secs) + "."
@@ -203,2 +239,4 @@ void TimerReceiverObject::resetTimer()
if ( atfile.open(IO_WriteOnly|IO_Raw) ) {
+ int total_written;
+
// just wake up and delete the at file
@@ -211,3 +249,4 @@ void TimerReceiverObject::resetTimer()
atfile.close();
- QFile::remove( atfile.name() );
+ QFile::remove
+ ( atfile.name() );
return;
@@ -216,3 +255,4 @@ void TimerReceiverObject::resetTimer()
unlink( atfilename );
- QDir d; d.rename(fn+".new",fn);
+ QDir d;
+ d.rename(fn + ".new", fn);
chmod(fn.latin1(),0755);
@@ -220,3 +260,4 @@ void TimerReceiverObject::resetTimer()
triggerAtd( FALSE );
- } else {
+ }
+ else {
qWarning("Cannot open atd file %s",fn.latin1());
@@ -224,2 +265,7 @@ void TimerReceiverObject::resetTimer()
}
+#else
+ writeResumeAt ( at_secs );
+
+#endif
+
// Qt timers (does the actual alarm)
@@ -244,2 +290,3 @@ void TimerReceiverObject::timerEvent( QTimerEvent * )
#endif
+
timerEventList.remove( nearestTimerEvent );
@@ -248,3 +295,4 @@ void TimerReceiverObject::timerEvent( QTimerEvent * )
setNearestTimerEvent();
- } else {
+ }
+ else {
resetTimer();
@@ -315,3 +363,4 @@ void AlarmServer::addAlarm ( QDateTime when, const QCString& channel,
}
- } else {
+ }
+ else {
nearestTimerEvent = newTimerEventItem;
@@ -321,3 +370,4 @@ void AlarmServer::addAlarm ( QDateTime when, const QCString& channel,
saveState();
- } else {
+ }
+ else {
#ifndef QT_NO_COP
@@ -326,2 +376,3 @@ void AlarmServer::addAlarm ( QDateTime when, const QCString& channel,
#endif
+
}
@@ -357,4 +408,3 @@ void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QC
&& ( message.isNull() || (*it)->message == message )
- && ( data==-1 || (*it)->data == data ) )
- {
+ && ( data == -1 || (*it)->data == data ) ) {
// if it's first, then we need to update the timer
@@ -363,3 +413,4 @@ void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QC
setNearestTimerEvent();
- } else {
+ }
+ else {
timerEventList.remove(*it);
@@ -374,3 +425,4 @@ void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QC
saveState();
- } else {
+ }
+ else {
#ifndef QT_NO_COP
@@ -379,2 +431,3 @@ void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QC
#endif
+
}
@@ -387,2 +440,3 @@ void Global::writeHWClock()
{
+#ifdef USE_ATD
if ( !triggerAtd( TRUE ) ) {
@@ -391,2 +445,5 @@ void Global::writeHWClock()
}
+#else
+ // hwclock is written on suspend
+#endif
}