-rw-r--r-- | library/alarmserver.cpp | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp index a1a7142..1ee05c6 100644 --- a/library/alarmserver.cpp +++ b/library/alarmserver.cpp @@ -1,5 +1,5 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** @@ -196,2 +196,4 @@ void TimerReceiverObject::resetTimer() QDateTime now = QDateTime::currentDateTime(); + if ( nearest < now ) + nearest = now; int secs = TimeConversion::secsTo( now, nearest ); @@ -247,2 +249,3 @@ void TimerReceiverObject::timerEvent( QTimerEvent * ) <= TimeConversion::toUTC(QDateTime::currentDateTime()) ) { +#ifndef QT_NO_COP QCopEnvelope e( nearestTimerEvent->channel, @@ -251,2 +254,3 @@ void TimerReceiverObject::timerEvent( QTimerEvent * ) << nearestTimerEvent->data; +#endif timerEventList.remove( nearestTimerEvent ); @@ -264,6 +268,17 @@ void TimerReceiverObject::timerEvent( QTimerEvent * ) \class AlarmServer alarmserver.h - \brief The AlarmServer class provides alarms to be scheduled. + \brief The AlarmServer class allows alarms to be scheduled and unscheduled. + + Applications can schedule alarms with addAlarm() and can + unschedule alarms with deleteAlarm(). When the time for an alarm + to go off is reached the specified \link qcop.html QCop\endlink + message is sent on the specified channel (optionally with + additional data). + + Scheduling an alarm using this class is important (rather just using + a QTimer) since the machine may be asleep and needs to get woken up using + the Linux kernel which implements this at the kernel level to minimize + battery usage while asleep. - Applications which wish to be informed when a certain time instant - passes use the functions of AlarmServer to request so. + \ingroup qtopiaemb + \sa QCopEnvelope */ @@ -271,5 +286,9 @@ void TimerReceiverObject::timerEvent( QTimerEvent * ) /*! - Schedules an alarm for \a when. Soon after this time, - \a message will be sent to \a channel, with \a data as - a parameter. \a message must be of the form "someMessage(int)". + Schedules an alarm to go off at (or soon after) time \a when. When + the alarm goes off, the \link qcop.html QCop\endlink \a message will + be sent to \a channel, with \a data as a parameter. + + If this function is called with exactly the same data as a previous + call the subsequent call is ignored, so there is only ever one alarm + with a given set of parameters. @@ -314,4 +333,6 @@ void AlarmServer::addAlarm ( QDateTime when, const QCString& channel, } else { +#ifndef QT_NO_COP QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" ); e << when << channel << message << data; +#endif } @@ -320,9 +341,13 @@ void AlarmServer::addAlarm ( QDateTime when, const QCString& channel, /*! - Deletes previously scheduled alarms which match \a when, \a channel, \a message, - and \a data. + Deletes previously scheduled alarms which match \a when, \a channel, + \a message, and \a data. - Passing null values for \a when, \a channel, or \a message indicates "any". - Passing -1 for \a data indicates "any". + Passing null values for \a when, \a channel, or for the \link + qcop.html QCop\endlink \a message, acts as a wildcard meaning "any". + Similarly, passing -1 for \a data indicates "any". + + If there is no matching alarm, nothing happens. + + \sa addAlarm() - \sa deleteAlarm() */ @@ -361,4 +386,6 @@ void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QC } else { +#ifndef QT_NO_COP QCopEnvelope e( "QPE/System", "deleteAlarm(QDateTime,QCString,QCString,int)" ); e << when << channel << message << data; +#endif } |