summaryrefslogtreecommitdiff
path: root/library/alarmserver.cpp
authorzecke <zecke>2003-10-02 19:48:14 (UTC)
committer zecke <zecke>2003-10-02 19:48:14 (UTC)
commitec63bc06518a70d56411291afab8f619b96e67f5 (patch) (side-by-side diff)
tree1013fe66686254cbed9af9198968ae195a2c292a /library/alarmserver.cpp
parent4c9bda8027049b7ea423471a213eca2068490b08 (diff)
downloadopie-ec63bc06518a70d56411291afab8f619b96e67f5.zip
opie-ec63bc06518a70d56411291afab8f619b96e67f5.tar.gz
opie-ec63bc06518a70d56411291afab8f619b96e67f5.tar.bz2
fix bug 0001185
and state that syncing system time depends on AlarmServer using atd or opie-alarm
Diffstat (limited to 'library/alarmserver.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/alarmserver.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp
index 2ea4025..a75fc7e 100644
--- a/library/alarmserver.cpp
+++ b/library/alarmserver.cpp
@@ -341,109 +341,112 @@ void AlarmServer::addAlarm ( QDateTime when, const QCString& channel,
if (!timerEventReceiver)
timerEventReceiver = new TimerReceiverObject;
timerEventItem *newTimerEventItem = new timerEventItem;
newTimerEventItem->UTCtime = TimeConversion::toUTC( when );
newTimerEventItem->channel = channel;
newTimerEventItem->message = message;
newTimerEventItem->data = data;
// explore the case of already having the event in here...
QListIterator<timerEventItem> it( timerEventList );
for ( ; *it; ++it )
if ( *(*it) == *newTimerEventItem )
return ;
// if we made it here, it is okay to add the item...
timerEventList.append( newTimerEventItem );
needSave = TRUE;
// quicker than using setNearestTimerEvent()
if ( nearestTimerEvent ) {
if (newTimerEventItem->UTCtime < nearestTimerEvent->UTCtime) {
nearestTimerEvent = newTimerEventItem;
timerEventReceiver->killTimers();
timerEventReceiver->resetTimer();
}
}
else {
nearestTimerEvent = newTimerEventItem;
timerEventReceiver->resetTimer();
}
if ( needSave )
saveState();
}
else {
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" );
e << when << channel << message << data;
#endif
}
}
/*!
Deletes previously scheduled alarms which match \a when, \a channel,
\a message, and \a data.
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()
*/
void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QCString& message, int data)
{
if ( qApp->type() == QApplication::GuiServer) {
bool needSave = FALSE;
if ( timerEventReceiver != NULL ) {
timerEventReceiver->killTimers();
// iterate over the list of events
QListIterator<timerEventItem> it( timerEventList );
time_t deleteTime = TimeConversion::toUTC( when );
for ( ; *it; ++it ) {
// if its a match, delete it
if ( ( (*it)->UTCtime == deleteTime || when.isNull() )
&& ( channel.isNull() || (*it)->channel == channel )
&& ( message.isNull() || (*it)->message == message )
&& ( data == -1 || (*it)->data == data ) ) {
// if it's first, then we need to update the timer
if ( (*it) == nearestTimerEvent ) {
timerEventList.remove(*it);
setNearestTimerEvent();
}
else {
timerEventList.remove(*it);
}
needSave = TRUE;
}
}
if ( nearestTimerEvent )
timerEventReceiver->resetTimer();
}
if ( needSave )
saveState();
}
else {
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/System", "deleteAlarm(QDateTime,QCString,QCString,int)" );
e << when << channel << message << data;
#endif
}
}
/*!
- Writes the system clock to the hardware clock.
+ The implementation depends on the mode of AlarmServer. If the AlarmServer
+ uses atd the current system time will be written to the hardware clock.
+ If the AlarmServer relies on opie-alarm the time will be written once the
+ device gets suspended. opie-alarm is used by the Zaurus, iPAQs and SIMpad
*/
void Global::writeHWClock()
{
#ifdef USE_ATD
if ( !triggerAtd( TRUE ) ) {
// atd not running? set it ourselves
system("/sbin/hwclock --systohc"); // ##### UTC?
}
#else
// hwclock is written on suspend
#endif
}