summaryrefslogtreecommitdiff
path: root/library/alarmserver.cpp
Unidiff
Diffstat (limited to 'library/alarmserver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/alarmserver.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp
index a75fc7e..6f6f32d 100644
--- a/library/alarmserver.cpp
+++ b/library/alarmserver.cpp
@@ -316,8 +316,56 @@ void TimerReceiverObject::timerEvent( QTimerEvent * )
316 the Linux kernel which implements this at the kernel level to minimize 316 the Linux kernel which implements this at the kernel level to minimize
317 battery usage while asleep. 317 battery usage while asleep.
318 318
319 A small example on how to use AlarmServer.
320
321 First we need to connect a slot the AppMessage QCOP call. appMessage
322 will be emitted if QPE/Application/appname gets called.
323
324 \code
325 TestApp::TestApp(QWidget *parent, const char* name, WFlags fl )
326 : QMainWindow(parent,name,fl){
327 connect(qApp,SIGNAL(appMessage(const QCString&,const QByteArray&)),
328 this,SLOT(slotAppMessage(const QCString&,const QByteArray&)));
329 }
330 \endcode
331
332 To add / delete an alarm, you can use the static method AlarmServer::addAlarm and
333 AlarmServer::deleteAlarm. Note that an old (expired) alarm will automatically be deleted
334 from the alarmserver list, but a change in timing will have the effect, that both
335 alarms will be emitted. So if you change an Alarm be sure to delete the old one!
336 @see addAlarm
337
338 \code
339 QDateTime oldDt = oldAlarmDateTime();
340 QPEApplication::execDialog(ourDlg);
341 QDateTime newDt = ourDlg->dateTime();
342 if(newDt == oldDt ) return;
343 @slash* code is missing for unsetting an alarm *@slash
344
345 AlarmServer::deleteAlarm(oldDt,"QPE/Application/appname","checkAlarm(QDateTime,int)",0);
346 AlarmServer::addAlarm( newDt,"QPE/AlarmServer/appname","checkAlarm(QDateTime,int)",0);
347
348 \endcode
349
350 Now once the Alarm is emitted you need to check the appMessage and then do what you want.
351 \code
352 void TestApp::slotAppMessage(const QCString& str, const QByteArray& ar ){
353 QDataStream stream(ar,IO_ReadOnly);
354 if(str == "checkAlarm(QDateTime,int)" ){
355 QDateTime dt;
356 int a;
357 stream >> dt >> a;
358 // fire up alarm
359 }
360 }
361 \endcode
362
319 \ingroup qtopiaemb 363 \ingroup qtopiaemb
320 \sa QCopEnvelope 364 \sa QCopEnvelope
365 @see QPEApplication::appMessage(const QCString&,const QByteArray&)
366 @see OPimMainWindow
367 @see ODevice::alarmSound()
368 @see Sound::soundAlarm()
321*/ 369*/
322 370
323/*! 371/*!
@@ -329,6 +377,18 @@ void TimerReceiverObject::timerEvent( QTimerEvent * )
329 call the subsequent call is ignored, so there is only ever one alarm 377 call the subsequent call is ignored, so there is only ever one alarm
330 with a given set of parameters. 378 with a given set of parameters.
331 379
380 Once an alarm is emitted. The \a channel with a \a message will be emitted
381 and data will be send.
382 The QDateTime and int are the two parameters included in the QCOP message.
383 You can specify channel, message and the integer parameter. QDateTime will be
384 the datetime of the QCop call.
385
386 @param when The QDateTime of the alarm
387 @param channel The channel which gets called once the alarm is emitted
388 @param message The message to be send to the channel
389 @param data Additional data as integer
390
391 @see QCopChannel
332 \sa deleteAlarm() 392 \sa deleteAlarm()
333*/ 393*/
334void AlarmServer::addAlarm ( QDateTime when, const QCString& channel, 394void AlarmServer::addAlarm ( QDateTime when, const QCString& channel,