-rw-r--r-- | library/alarmserver.cpp | 60 | ||||
-rw-r--r-- | library/dummy_api_docu.cpp | 58 |
2 files changed, 118 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 | |||
@@ -127,326 +127,386 @@ static void saveState() | |||
127 | unlink( savefilename ); | 127 | unlink( savefilename ); |
128 | QDir d; | 128 | QDir d; |
129 | d.rename(savefilename + ".new", savefilename); | 129 | d.rename(savefilename + ".new", savefilename); |
130 | 130 | ||
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | /*! | 134 | /*! |
135 | Sets up the alarm server. Restoring to previous state (session management). | 135 | Sets up the alarm server. Restoring to previous state (session management). |
136 | */ | 136 | */ |
137 | void AlarmServer::initialize() | 137 | void AlarmServer::initialize() |
138 | { | 138 | { |
139 | //read autosave file and put events in timerEventList | 139 | //read autosave file and put events in timerEventList |
140 | 140 | ||
141 | QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" ); | 141 | QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" ); |
142 | 142 | ||
143 | QFile savefile(savefilename); | 143 | QFile savefile(savefilename); |
144 | if ( savefile.open(IO_ReadOnly) ) { | 144 | if ( savefile.open(IO_ReadOnly) ) { |
145 | QDataStream ds( &savefile ); | 145 | QDataStream ds( &savefile ); |
146 | while ( !ds.atEnd() ) { | 146 | while ( !ds.atEnd() ) { |
147 | timerEventItem *newTimerEventItem = new timerEventItem; | 147 | timerEventItem *newTimerEventItem = new timerEventItem; |
148 | ds >> newTimerEventItem->UTCtime; | 148 | ds >> newTimerEventItem->UTCtime; |
149 | ds >> newTimerEventItem->channel; | 149 | ds >> newTimerEventItem->channel; |
150 | ds >> newTimerEventItem->message; | 150 | ds >> newTimerEventItem->message; |
151 | ds >> newTimerEventItem->data; | 151 | ds >> newTimerEventItem->data; |
152 | timerEventList.append( newTimerEventItem ); | 152 | timerEventList.append( newTimerEventItem ); |
153 | } | 153 | } |
154 | savefile.close(); | 154 | savefile.close(); |
155 | if (!timerEventReceiver) | 155 | if (!timerEventReceiver) |
156 | timerEventReceiver = new TimerReceiverObject; | 156 | timerEventReceiver = new TimerReceiverObject; |
157 | setNearestTimerEvent(); | 157 | setNearestTimerEvent(); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | #ifdef USE_ATD | 162 | #ifdef USE_ATD |
163 | 163 | ||
164 | static const char* atdir = "/var/spool/at/"; | 164 | static const char* atdir = "/var/spool/at/"; |
165 | 165 | ||
166 | static bool triggerAtd( bool writeHWClock = FALSE ) | 166 | static bool triggerAtd( bool writeHWClock = FALSE ) |
167 | { | 167 | { |
168 | QFile trigger(QString(atdir) + "trigger"); | 168 | QFile trigger(QString(atdir) + "trigger"); |
169 | if ( trigger.open(IO_WriteOnly | IO_Raw) ) { | 169 | if ( trigger.open(IO_WriteOnly | IO_Raw) ) { |
170 | if ( trigger.writeBlock("\n", 2) != 2 ) { | 170 | if ( trigger.writeBlock("\n", 2) != 2 ) { |
171 | QMessageBox::critical( 0, QObject::tr( "Out of Space" ), | 171 | QMessageBox::critical( 0, QObject::tr( "Out of Space" ), |
172 | QObject::tr( "Unable to schedule alarm.\nFree some memory and try again." ) ); | 172 | QObject::tr( "Unable to schedule alarm.\nFree some memory and try again." ) ); |
173 | trigger.close(); | 173 | trigger.close(); |
174 | QFile::remove | 174 | QFile::remove |
175 | ( trigger.name() ); | 175 | ( trigger.name() ); |
176 | return FALSE; | 176 | return FALSE; |
177 | } | 177 | } |
178 | return TRUE; | 178 | return TRUE; |
179 | } | 179 | } |
180 | return FALSE; | 180 | return FALSE; |
181 | } | 181 | } |
182 | 182 | ||
183 | #else | 183 | #else |
184 | 184 | ||
185 | static bool writeResumeAt ( time_t wakeup ) | 185 | static bool writeResumeAt ( time_t wakeup ) |
186 | { | 186 | { |
187 | FILE *fp = ::fopen ( "/var/run/resumeat", "w" ); | 187 | FILE *fp = ::fopen ( "/var/run/resumeat", "w" ); |
188 | 188 | ||
189 | if ( fp ) { | 189 | if ( fp ) { |
190 | ::fprintf ( fp, "%d\n", (int) wakeup ); | 190 | ::fprintf ( fp, "%d\n", (int) wakeup ); |
191 | ::fclose ( fp ); | 191 | ::fclose ( fp ); |
192 | } | 192 | } |
193 | else | 193 | else |
194 | qWarning ( "Failed to write wakeup time to /var/run/resumeat" ); | 194 | qWarning ( "Failed to write wakeup time to /var/run/resumeat" ); |
195 | 195 | ||
196 | return ( fp ); | 196 | return ( fp ); |
197 | } | 197 | } |
198 | 198 | ||
199 | #endif | 199 | #endif |
200 | 200 | ||
201 | void TimerReceiverObject::deleteTimer() | 201 | void TimerReceiverObject::deleteTimer() |
202 | { | 202 | { |
203 | #ifdef USE_ATD | 203 | #ifdef USE_ATD |
204 | if ( !atfilename.isEmpty() ) { | 204 | if ( !atfilename.isEmpty() ) { |
205 | unlink( atfilename ); | 205 | unlink( atfilename ); |
206 | atfilename = QString::null; | 206 | atfilename = QString::null; |
207 | triggerAtd( FALSE ); | 207 | triggerAtd( FALSE ); |
208 | } | 208 | } |
209 | #else | 209 | #else |
210 | writeResumeAt ( 0 ); | 210 | writeResumeAt ( 0 ); |
211 | #endif | 211 | #endif |
212 | } | 212 | } |
213 | 213 | ||
214 | void TimerReceiverObject::resetTimer() | 214 | void TimerReceiverObject::resetTimer() |
215 | { | 215 | { |
216 | const int maxsecs = 2147000; | 216 | const int maxsecs = 2147000; |
217 | QDateTime nearest = TimeConversion::fromUTC(nearestTimerEvent->UTCtime); | 217 | QDateTime nearest = TimeConversion::fromUTC(nearestTimerEvent->UTCtime); |
218 | QDateTime now = QDateTime::currentDateTime(); | 218 | QDateTime now = QDateTime::currentDateTime(); |
219 | if ( nearest < now ) | 219 | if ( nearest < now ) |
220 | nearest = now; | 220 | nearest = now; |
221 | int secs = TimeConversion::secsTo( now, nearest ); | 221 | int secs = TimeConversion::secsTo( now, nearest ); |
222 | if ( secs > maxsecs ) { | 222 | if ( secs > maxsecs ) { |
223 | // too far for millisecond timing | 223 | // too far for millisecond timing |
224 | secs = maxsecs; | 224 | secs = maxsecs; |
225 | } | 225 | } |
226 | 226 | ||
227 | // System timer (needed so that we wake from deep sleep), | 227 | // System timer (needed so that we wake from deep sleep), |
228 | // from the Epoch in seconds. | 228 | // from the Epoch in seconds. |
229 | // | 229 | // |
230 | int at_secs = TimeConversion::toUTC(nearest); | 230 | int at_secs = TimeConversion::toUTC(nearest); |
231 | // qDebug("reset timer to %d seconds from Epoch",at_secs); | 231 | // qDebug("reset timer to %d seconds from Epoch",at_secs); |
232 | 232 | ||
233 | #ifdef USE_ATD | 233 | #ifdef USE_ATD |
234 | 234 | ||
235 | QString fn = atdir + QString::number(at_secs) + "." | 235 | QString fn = atdir + QString::number(at_secs) + "." |
236 | + QString::number(getpid()); | 236 | + QString::number(getpid()); |
237 | if ( fn != atfilename ) { | 237 | if ( fn != atfilename ) { |
238 | QFile atfile(fn + ".new"); | 238 | QFile atfile(fn + ".new"); |
239 | if ( atfile.open(IO_WriteOnly | IO_Raw) ) { | 239 | if ( atfile.open(IO_WriteOnly | IO_Raw) ) { |
240 | int total_written; | 240 | int total_written; |
241 | 241 | ||
242 | // just wake up and delete the at file | 242 | // just wake up and delete the at file |
243 | QString cmd = "#!/bin/sh\nrm " + fn; | 243 | QString cmd = "#!/bin/sh\nrm " + fn; |
244 | total_written = atfile.writeBlock(cmd.latin1(), cmd.length()); | 244 | total_written = atfile.writeBlock(cmd.latin1(), cmd.length()); |
245 | if ( total_written != int(cmd.length()) ) { | 245 | if ( total_written != int(cmd.length()) ) { |
246 | QMessageBox::critical( 0, tr("Out of Space"), | 246 | QMessageBox::critical( 0, tr("Out of Space"), |
247 | tr("Unable to schedule alarm.\n" | 247 | tr("Unable to schedule alarm.\n" |
248 | "Please free up space and try again") ); | 248 | "Please free up space and try again") ); |
249 | atfile.close(); | 249 | atfile.close(); |
250 | QFile::remove | 250 | QFile::remove |
251 | ( atfile.name() ); | 251 | ( atfile.name() ); |
252 | return ; | 252 | return ; |
253 | } | 253 | } |
254 | atfile.close(); | 254 | atfile.close(); |
255 | unlink( atfilename ); | 255 | unlink( atfilename ); |
256 | QDir d; | 256 | QDir d; |
257 | d.rename(fn + ".new", fn); | 257 | d.rename(fn + ".new", fn); |
258 | chmod(fn.latin1(), 0755); | 258 | chmod(fn.latin1(), 0755); |
259 | atfilename = fn; | 259 | atfilename = fn; |
260 | triggerAtd( FALSE ); | 260 | triggerAtd( FALSE ); |
261 | } | 261 | } |
262 | else { | 262 | else { |
263 | qWarning("Cannot open atd file %s", fn.latin1()); | 263 | qWarning("Cannot open atd file %s", fn.latin1()); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | #else | 266 | #else |
267 | writeResumeAt ( at_secs ); | 267 | writeResumeAt ( at_secs ); |
268 | 268 | ||
269 | #endif | 269 | #endif |
270 | 270 | ||
271 | // Qt timers (does the actual alarm) | 271 | // Qt timers (does the actual alarm) |
272 | // from now in milliseconds | 272 | // from now in milliseconds |
273 | // | 273 | // |
274 | qDebug("AlarmServer waiting %d seconds", secs); | 274 | qDebug("AlarmServer waiting %d seconds", secs); |
275 | startTimer( 1000 * secs + 500 ); | 275 | startTimer( 1000 * secs + 500 ); |
276 | } | 276 | } |
277 | 277 | ||
278 | void TimerReceiverObject::timerEvent( QTimerEvent * ) | 278 | void TimerReceiverObject::timerEvent( QTimerEvent * ) |
279 | { | 279 | { |
280 | bool needSave = FALSE; | 280 | bool needSave = FALSE; |
281 | killTimers(); | 281 | killTimers(); |
282 | if (nearestTimerEvent) { | 282 | if (nearestTimerEvent) { |
283 | if ( nearestTimerEvent->UTCtime | 283 | if ( nearestTimerEvent->UTCtime |
284 | <= TimeConversion::toUTC(QDateTime::currentDateTime()) ) { | 284 | <= TimeConversion::toUTC(QDateTime::currentDateTime()) ) { |
285 | #ifndef QT_NO_COP | 285 | #ifndef QT_NO_COP |
286 | QCopEnvelope e( nearestTimerEvent->channel, | 286 | QCopEnvelope e( nearestTimerEvent->channel, |
287 | nearestTimerEvent->message ); | 287 | nearestTimerEvent->message ); |
288 | e << TimeConversion::fromUTC( nearestTimerEvent->UTCtime ) | 288 | e << TimeConversion::fromUTC( nearestTimerEvent->UTCtime ) |
289 | << nearestTimerEvent->data; | 289 | << nearestTimerEvent->data; |
290 | #endif | 290 | #endif |
291 | 291 | ||
292 | timerEventList.remove( nearestTimerEvent ); | 292 | timerEventList.remove( nearestTimerEvent ); |
293 | needSave = TRUE; | 293 | needSave = TRUE; |
294 | } | 294 | } |
295 | setNearestTimerEvent(); | 295 | setNearestTimerEvent(); |
296 | } | 296 | } |
297 | else { | 297 | else { |
298 | resetTimer(); | 298 | resetTimer(); |
299 | } | 299 | } |
300 | if ( needSave ) | 300 | if ( needSave ) |
301 | saveState(); | 301 | saveState(); |
302 | } | 302 | } |
303 | 303 | ||
304 | /*! | 304 | /*! |
305 | \class AlarmServer alarmserver.h | 305 | \class AlarmServer alarmserver.h |
306 | \brief The AlarmServer class allows alarms to be scheduled and unscheduled. | 306 | \brief The AlarmServer class allows alarms to be scheduled and unscheduled. |
307 | 307 | ||
308 | Applications can schedule alarms with addAlarm() and can | 308 | Applications can schedule alarms with addAlarm() and can |
309 | unschedule alarms with deleteAlarm(). When the time for an alarm | 309 | unschedule alarms with deleteAlarm(). When the time for an alarm |
310 | to go off is reached the specified \link qcop.html QCop\endlink | 310 | to go off is reached the specified \link qcop.html QCop\endlink |
311 | message is sent on the specified channel (optionally with | 311 | message is sent on the specified channel (optionally with |
312 | additional data). | 312 | additional data). |
313 | 313 | ||
314 | Scheduling an alarm using this class is important (rather just using | 314 | Scheduling an alarm using this class is important (rather just using |
315 | a QTimer) since the machine may be asleep and needs to get woken up using | 315 | a QTimer) since the machine may be asleep and needs to get woken up using |
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 | /*! |
324 | Schedules an alarm to go off at (or soon after) time \a when. When | 372 | Schedules an alarm to go off at (or soon after) time \a when. When |
325 | the alarm goes off, the \link qcop.html QCop\endlink \a message will | 373 | the alarm goes off, the \link qcop.html QCop\endlink \a message will |
326 | be sent to \a channel, with \a data as a parameter. | 374 | be sent to \a channel, with \a data as a parameter. |
327 | 375 | ||
328 | If this function is called with exactly the same data as a previous | 376 | If this function is called with exactly the same data as a previous |
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 | */ |
334 | void AlarmServer::addAlarm ( QDateTime when, const QCString& channel, | 394 | void AlarmServer::addAlarm ( QDateTime when, const QCString& channel, |
335 | const QCString& message, int data) | 395 | const QCString& message, int data) |
336 | { | 396 | { |
337 | if ( qApp->type() == QApplication::GuiServer ) { | 397 | if ( qApp->type() == QApplication::GuiServer ) { |
338 | bool needSave = FALSE; | 398 | bool needSave = FALSE; |
339 | // Here we are the server so either it has been directly called from | 399 | // Here we are the server so either it has been directly called from |
340 | // within the server or it has been sent to us from a client via QCop | 400 | // within the server or it has been sent to us from a client via QCop |
341 | if (!timerEventReceiver) | 401 | if (!timerEventReceiver) |
342 | timerEventReceiver = new TimerReceiverObject; | 402 | timerEventReceiver = new TimerReceiverObject; |
343 | 403 | ||
344 | timerEventItem *newTimerEventItem = new timerEventItem; | 404 | timerEventItem *newTimerEventItem = new timerEventItem; |
345 | newTimerEventItem->UTCtime = TimeConversion::toUTC( when ); | 405 | newTimerEventItem->UTCtime = TimeConversion::toUTC( when ); |
346 | newTimerEventItem->channel = channel; | 406 | newTimerEventItem->channel = channel; |
347 | newTimerEventItem->message = message; | 407 | newTimerEventItem->message = message; |
348 | newTimerEventItem->data = data; | 408 | newTimerEventItem->data = data; |
349 | // explore the case of already having the event in here... | 409 | // explore the case of already having the event in here... |
350 | QListIterator<timerEventItem> it( timerEventList ); | 410 | QListIterator<timerEventItem> it( timerEventList ); |
351 | for ( ; *it; ++it ) | 411 | for ( ; *it; ++it ) |
352 | if ( *(*it) == *newTimerEventItem ) | 412 | if ( *(*it) == *newTimerEventItem ) |
353 | return ; | 413 | return ; |
354 | // if we made it here, it is okay to add the item... | 414 | // if we made it here, it is okay to add the item... |
355 | timerEventList.append( newTimerEventItem ); | 415 | timerEventList.append( newTimerEventItem ); |
356 | needSave = TRUE; | 416 | needSave = TRUE; |
357 | // quicker than using setNearestTimerEvent() | 417 | // quicker than using setNearestTimerEvent() |
358 | if ( nearestTimerEvent ) { | 418 | if ( nearestTimerEvent ) { |
359 | if (newTimerEventItem->UTCtime < nearestTimerEvent->UTCtime) { | 419 | if (newTimerEventItem->UTCtime < nearestTimerEvent->UTCtime) { |
360 | nearestTimerEvent = newTimerEventItem; | 420 | nearestTimerEvent = newTimerEventItem; |
361 | timerEventReceiver->killTimers(); | 421 | timerEventReceiver->killTimers(); |
362 | timerEventReceiver->resetTimer(); | 422 | timerEventReceiver->resetTimer(); |
363 | } | 423 | } |
364 | } | 424 | } |
365 | else { | 425 | else { |
366 | nearestTimerEvent = newTimerEventItem; | 426 | nearestTimerEvent = newTimerEventItem; |
367 | timerEventReceiver->resetTimer(); | 427 | timerEventReceiver->resetTimer(); |
368 | } | 428 | } |
369 | if ( needSave ) | 429 | if ( needSave ) |
370 | saveState(); | 430 | saveState(); |
371 | } | 431 | } |
372 | else { | 432 | else { |
373 | #ifndef QT_NO_COP | 433 | #ifndef QT_NO_COP |
374 | QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" ); | 434 | QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" ); |
375 | e << when << channel << message << data; | 435 | e << when << channel << message << data; |
376 | #endif | 436 | #endif |
377 | 437 | ||
378 | } | 438 | } |
379 | } | 439 | } |
380 | 440 | ||
381 | /*! | 441 | /*! |
382 | Deletes previously scheduled alarms which match \a when, \a channel, | 442 | Deletes previously scheduled alarms which match \a when, \a channel, |
383 | \a message, and \a data. | 443 | \a message, and \a data. |
384 | 444 | ||
385 | Passing null values for \a when, \a channel, or for the \link | 445 | Passing null values for \a when, \a channel, or for the \link |
386 | qcop.html QCop\endlink \a message, acts as a wildcard meaning "any". | 446 | qcop.html QCop\endlink \a message, acts as a wildcard meaning "any". |
387 | Similarly, passing -1 for \a data indicates "any". | 447 | Similarly, passing -1 for \a data indicates "any". |
388 | 448 | ||
389 | If there is no matching alarm, nothing happens. | 449 | If there is no matching alarm, nothing happens. |
390 | 450 | ||
391 | \sa addAlarm() | 451 | \sa addAlarm() |
392 | 452 | ||
393 | */ | 453 | */ |
394 | void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QCString& message, int data) | 454 | void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QCString& message, int data) |
395 | { | 455 | { |
396 | if ( qApp->type() == QApplication::GuiServer) { | 456 | if ( qApp->type() == QApplication::GuiServer) { |
397 | bool needSave = FALSE; | 457 | bool needSave = FALSE; |
398 | if ( timerEventReceiver != NULL ) { | 458 | if ( timerEventReceiver != NULL ) { |
399 | timerEventReceiver->killTimers(); | 459 | timerEventReceiver->killTimers(); |
400 | 460 | ||
401 | // iterate over the list of events | 461 | // iterate over the list of events |
402 | QListIterator<timerEventItem> it( timerEventList ); | 462 | QListIterator<timerEventItem> it( timerEventList ); |
403 | time_t deleteTime = TimeConversion::toUTC( when ); | 463 | time_t deleteTime = TimeConversion::toUTC( when ); |
404 | for ( ; *it; ++it ) { | 464 | for ( ; *it; ++it ) { |
405 | // if its a match, delete it | 465 | // if its a match, delete it |
406 | if ( ( (*it)->UTCtime == deleteTime || when.isNull() ) | 466 | if ( ( (*it)->UTCtime == deleteTime || when.isNull() ) |
407 | && ( channel.isNull() || (*it)->channel == channel ) | 467 | && ( channel.isNull() || (*it)->channel == channel ) |
408 | && ( message.isNull() || (*it)->message == message ) | 468 | && ( message.isNull() || (*it)->message == message ) |
409 | && ( data == -1 || (*it)->data == data ) ) { | 469 | && ( data == -1 || (*it)->data == data ) ) { |
410 | // if it's first, then we need to update the timer | 470 | // if it's first, then we need to update the timer |
411 | if ( (*it) == nearestTimerEvent ) { | 471 | if ( (*it) == nearestTimerEvent ) { |
412 | timerEventList.remove(*it); | 472 | timerEventList.remove(*it); |
413 | setNearestTimerEvent(); | 473 | setNearestTimerEvent(); |
414 | } | 474 | } |
415 | else { | 475 | else { |
416 | timerEventList.remove(*it); | 476 | timerEventList.remove(*it); |
417 | } | 477 | } |
418 | needSave = TRUE; | 478 | needSave = TRUE; |
419 | } | 479 | } |
420 | } | 480 | } |
421 | if ( nearestTimerEvent ) | 481 | if ( nearestTimerEvent ) |
422 | timerEventReceiver->resetTimer(); | 482 | timerEventReceiver->resetTimer(); |
423 | } | 483 | } |
424 | if ( needSave ) | 484 | if ( needSave ) |
425 | saveState(); | 485 | saveState(); |
426 | } | 486 | } |
427 | else { | 487 | else { |
428 | #ifndef QT_NO_COP | 488 | #ifndef QT_NO_COP |
429 | QCopEnvelope e( "QPE/System", "deleteAlarm(QDateTime,QCString,QCString,int)" ); | 489 | QCopEnvelope e( "QPE/System", "deleteAlarm(QDateTime,QCString,QCString,int)" ); |
430 | e << when << channel << message << data; | 490 | e << when << channel << message << data; |
431 | #endif | 491 | #endif |
432 | 492 | ||
433 | } | 493 | } |
434 | } | 494 | } |
435 | 495 | ||
436 | /*! | 496 | /*! |
437 | The implementation depends on the mode of AlarmServer. If the AlarmServer | 497 | The implementation depends on the mode of AlarmServer. If the AlarmServer |
438 | uses atd the current system time will be written to the hardware clock. | 498 | uses atd the current system time will be written to the hardware clock. |
439 | If the AlarmServer relies on opie-alarm the time will be written once the | 499 | If the AlarmServer relies on opie-alarm the time will be written once the |
440 | device gets suspended. opie-alarm is used by the Zaurus, iPAQs and SIMpad | 500 | device gets suspended. opie-alarm is used by the Zaurus, iPAQs and SIMpad |
441 | */ | 501 | */ |
442 | void Global::writeHWClock() | 502 | void Global::writeHWClock() |
443 | { | 503 | { |
444 | #ifdef USE_ATD | 504 | #ifdef USE_ATD |
445 | if ( !triggerAtd( TRUE ) ) { | 505 | if ( !triggerAtd( TRUE ) ) { |
446 | // atd not running? set it ourselves | 506 | // atd not running? set it ourselves |
447 | system("/sbin/hwclock --systohc"); // ##### UTC? | 507 | system("/sbin/hwclock --systohc"); // ##### UTC? |
448 | } | 508 | } |
449 | #else | 509 | #else |
450 | // hwclock is written on suspend | 510 | // hwclock is written on suspend |
451 | #endif | 511 | #endif |
452 | } | 512 | } |
diff --git a/library/dummy_api_docu.cpp b/library/dummy_api_docu.cpp index 6b76401..f2153df 100644 --- a/library/dummy_api_docu.cpp +++ b/library/dummy_api_docu.cpp | |||
@@ -120,192 +120,250 @@ | |||
120 | * \brief create a new widget which should be used as input | 120 | * \brief create a new widget which should be used as input |
121 | * | 121 | * |
122 | * This method will be called if the inputmethod is to be shown. | 122 | * This method will be called if the inputmethod is to be shown. |
123 | * Make sure that your widget is not too large. As of Opie1.1 InputMethods | 123 | * Make sure that your widget is not too large. As of Opie1.1 InputMethods |
124 | * can be floating as well. | 124 | * can be floating as well. |
125 | * | 125 | * |
126 | * Delete the Widget yourself. | 126 | * Delete the Widget yourself. |
127 | * | 127 | * |
128 | * | 128 | * |
129 | * @param parent The parent of the to be created Input widget. | 129 | * @param parent The parent of the to be created Input widget. |
130 | * @param f The Qt::WFlags for the widget | 130 | * @param f The Qt::WFlags for the widget |
131 | */ | 131 | */ |
132 | 132 | ||
133 | /** | 133 | /** |
134 | * \fn void InputMethodInterface::resetState() | 134 | * \fn void InputMethodInterface::resetState() |
135 | * \brief Reset the state of the inputmethod | 135 | * \brief Reset the state of the inputmethod |
136 | * | 136 | * |
137 | * If you're shown reset the state of the keyboard to the | 137 | * If you're shown reset the state of the keyboard to the |
138 | * the default. | 138 | * the default. |
139 | */ | 139 | */ |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * \fn QPixmap* InputMethodInterface::icon() | 142 | * \fn QPixmap* InputMethodInterface::icon() |
143 | * \brief The icon of your Input method | 143 | * \brief The icon of your Input method |
144 | * | 144 | * |
145 | * Return a pointer to a QPixmap symboling your inputmethod | 145 | * Return a pointer to a QPixmap symboling your inputmethod |
146 | * You need to delete the pixmap later yourself. | 146 | * You need to delete the pixmap later yourself. |
147 | */ | 147 | */ |
148 | 148 | ||
149 | /** | 149 | /** |
150 | * \fn void InputMethodInterface::onKeyPress(QObject* receiver, const char* slot) | 150 | * \fn void InputMethodInterface::onKeyPress(QObject* receiver, const char* slot) |
151 | * \brief pass your key event through | 151 | * \brief pass your key event through |
152 | * | 152 | * |
153 | * In your actual Input Implementation you'll need a SIGNAL with this | 153 | * In your actual Input Implementation you'll need a SIGNAL with this |
154 | * void key(ushort,ushort,ushort,bool,bool) signal. The host of your input method | 154 | * void key(ushort,ushort,ushort,bool,bool) signal. The host of your input method |
155 | * requests you to connect your signal with the signal out of receiver and slot. | 155 | * requests you to connect your signal with the signal out of receiver and slot. |
156 | * | 156 | * |
157 | * ushort == unicode value | 157 | * ushort == unicode value |
158 | * ushort == keycode | 158 | * ushort == keycode |
159 | * ushort == modifiers from Qt::ButtonState | 159 | * ushort == modifiers from Qt::ButtonState |
160 | * bool == true if the key is pressed and false if released | 160 | * bool == true if the key is pressed and false if released |
161 | * bool == autorepeat on or off. | 161 | * bool == autorepeat on or off. |
162 | * | 162 | * |
163 | * See the QWSServer for more information about emitting keys | 163 | * See the QWSServer for more information about emitting keys |
164 | * | 164 | * |
165 | * | 165 | * |
166 | * @param receiver the receiver to QObject::connect to | 166 | * @param receiver the receiver to QObject::connect to |
167 | * @param slot the slot to QObject::connect to | 167 | * @param slot the slot to QObject::connect to |
168 | * | 168 | * |
169 | */ | 169 | */ |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * MediaPlayer Plugins | 172 | * MediaPlayer Plugins |
173 | */ | 173 | */ |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * \class MediaPlayerPluginInterface | 176 | * \class MediaPlayerPluginInterface |
177 | * \brief Plugins for the Opie Player I | 177 | * \brief Plugins for the Opie Player I |
178 | * | 178 | * |
179 | * You can extend the Opie Player I by plugins placed in | 179 | * You can extend the Opie Player I by plugins placed in |
180 | * OPIEDIR/plugins/codecs | 180 | * OPIEDIR/plugins/codecs |
181 | * | 181 | * |
182 | * | 182 | * |
183 | */ | 183 | */ |
184 | 184 | ||
185 | /** | 185 | /** |
186 | * \fn MediaPlayerDecoder MediaPlayerPluginInterface::decoder() | 186 | * \fn MediaPlayerDecoder MediaPlayerPluginInterface::decoder() |
187 | * | 187 | * |
188 | * Create a new MediaPlayerDecoder | 188 | * Create a new MediaPlayerDecoder |
189 | * | 189 | * |
190 | */ | 190 | */ |
191 | 191 | ||
192 | 192 | ||
193 | /* | 193 | /* |
194 | * MenuApplet Interface | 194 | * MenuApplet Interface |
195 | */ | 195 | */ |
196 | 196 | ||
197 | /** | 197 | /** |
198 | * \class MenuAppletInterface | 198 | * \class MenuAppletInterface |
199 | * \brief Plugins for the Menu Applet/StartMenu | 199 | * \brief Plugins for the Menu Applet/StartMenu |
200 | * | 200 | * |
201 | * You can extend the startmenu by plugins implementing this | 201 | * You can extend the startmenu by plugins implementing this |
202 | * interface. You need to place the plugin in plugins/applets | 202 | * interface. You need to place the plugin in plugins/applets |
203 | * from where they will be loaded. | 203 | * from where they will be loaded. |
204 | * | 204 | * |
205 | * | 205 | * |
206 | */ | 206 | */ |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * \fn QString MenuAppletInterface::name()const | 209 | * \fn QString MenuAppletInterface::name()const |
210 | * \brief Translated name of the Menu Applet | 210 | * \brief Translated name of the Menu Applet |
211 | * | 211 | * |
212 | * Return a translated name using QObject::tr of your plugin | 212 | * Return a translated name using QObject::tr of your plugin |
213 | */ | 213 | */ |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * \fn int MenuAppletInterface::position()const | 216 | * \fn int MenuAppletInterface::position()const |
217 | * \brief the wished position of this applet | 217 | * \brief the wished position of this applet |
218 | * | 218 | * |
219 | * The position where you want to be placed. 0 for the down most | 219 | * The position where you want to be placed. 0 for the down most |
220 | * | 220 | * |
221 | */ | 221 | */ |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * \fn QIconSet MenuAppletInterface::icon()const | 224 | * \fn QIconSet MenuAppletInterface::icon()const |
225 | * \brief return a QIconSet. | 225 | * \brief return a QIconSet. |
226 | * | 226 | * |
227 | * The returned icon set will be shown next | 227 | * The returned icon set will be shown next |
228 | * to text(). | 228 | * to text(). |
229 | * Make use of AppLnk::smallIconSize() | 229 | * Make use of AppLnk::smallIconSize() |
230 | */ | 230 | */ |
231 | 231 | ||
232 | /** | 232 | /** |
233 | * \fn QString MenuAppletInterface::text()const | 233 | * \fn QString MenuAppletInterface::text()const |
234 | * \brief return a Text shown to the user in the menu | 234 | * \brief return a Text shown to the user in the menu |
235 | */ | 235 | */ |
236 | 236 | ||
237 | /** | 237 | /** |
238 | * \fn QPopupMenu* MenuAppletInterface::popup( QWidget* parent)const | 238 | * \fn QPopupMenu* MenuAppletInterface::popup( QWidget* parent)const |
239 | * \brief Provide a SubMenu popup if you want | 239 | * \brief Provide a SubMenu popup if you want |
240 | * | 240 | * |
241 | * You can provide a Submenu popup for your item as well. If you return | 241 | * You can provide a Submenu popup for your item as well. If you return |
242 | * 0 no popup will be shown. | 242 | * 0 no popup will be shown. |
243 | * | 243 | * |
244 | * You can use the QPopupMenu::aboutToShow() signal to be informed before | 244 | * You can use the QPopupMenu::aboutToShow() signal to be informed before |
245 | * showing the popup | 245 | * showing the popup |
246 | * | 246 | * |
247 | * @param parent The parent of the to be created popup. | 247 | * @param parent The parent of the to be created popup. |
248 | * @see QPopupMenu | 248 | * @see QPopupMenu |
249 | */ | 249 | */ |
250 | 250 | ||
251 | 251 | ||
252 | /** | 252 | /** |
253 | * \fn void MenuAppletInterface::activated() | 253 | * \fn void MenuAppletInterface::activated() |
254 | * \brief This method gets called once the user clicked on the item | 254 | * \brief This method gets called once the user clicked on the item |
255 | * | 255 | * |
256 | * This is the way you get informed about user input. Your plugin | 256 | * This is the way you get informed about user input. Your plugin |
257 | * has just been clicked | 257 | * has just been clicked |
258 | */ | 258 | */ |
259 | 259 | ||
260 | /* | 260 | /* |
261 | * StyleInterface | 261 | * StyleInterface |
262 | */ | 262 | */ |
263 | 263 | ||
264 | /** | 264 | /** |
265 | * \class StyleInterface | 265 | * \class StyleInterface |
266 | * \brief StyleInterface base class | 266 | * \brief StyleInterface base class |
267 | * | 267 | * |
268 | * Opie styles should implement StyleExtendedInterface. | 268 | * Opie styles should implement StyleExtendedInterface. |
269 | * StyleInterface is only for compability reasons present and should | 269 | * StyleInterface is only for compability reasons present and should |
270 | * not be used for new styles. | 270 | * not be used for new styles. |
271 | * | 271 | * |
272 | * Styles need to be put into OPIEDIR/plugins/styles | 272 | * Styles need to be put into OPIEDIR/plugins/styles |
273 | */ | 273 | */ |
274 | 274 | ||
275 | 275 | ||
276 | /** | 276 | /** |
277 | * \class StyleExtendedInterface | 277 | * \class StyleExtendedInterface |
278 | * \brief The Plugin Interface for all Opie styles | 278 | * \brief The Plugin Interface for all Opie styles |
279 | * | 279 | * |
280 | * If you want to create a new QStyle for Opie use this class. | 280 | * If you want to create a new QStyle for Opie use this class. |
281 | * | 281 | * |
282 | * key(ushort,ushort,ushort,bool,bool) | 282 | * key(ushort,ushort,ushort,bool,bool) |
283 | */ | 283 | */ |
284 | 284 | ||
285 | /* | 285 | /* |
286 | * Taskbar Applets | 286 | * Taskbar Applets |
287 | */ | 287 | */ |
288 | 288 | ||
289 | 289 | ||
290 | /** | 290 | /** |
291 | * \class TaskbarAppletInterface | 291 | * \class TaskbarAppletInterface |
292 | * | 292 | * |
293 | * This is the base class of all Applets shown in the taskbar | 293 | * This is the base class of all Applets shown in the taskbar |
294 | * An applets need to provide a position and a widget. | 294 | * An applets need to provide a position and a widget. |
295 | * | 295 | * |
296 | * Applets need to be put into OPIEDIR/plugins/applets | 296 | * Applets need to be put into OPIEDIR/plugins/applets |
297 | * | 297 | * |
298 | */ | 298 | */ |
299 | /** | 299 | /** |
300 | * \fn QWidget* TaskbarAppletInterface::applet( QWidget* parent ) | 300 | * \fn QWidget* TaskbarAppletInterface::applet( QWidget* parent ) |
301 | * \brief return the new Applet Widget | 301 | * \brief return the new Applet Widget |
302 | * | 302 | * |
303 | * @param parent The parent of the Applet normally the taskbar | 303 | * @param parent The parent of the Applet normally the taskbar |
304 | */ | 304 | */ |
305 | 305 | ||
306 | /** | 306 | /** |
307 | * \fn int TaskbarAppletInterface::position()const; | 307 | * \fn int TaskbarAppletInterface::position()const; |
308 | * \brief the wished position | 308 | * \brief the wished position |
309 | * | 309 | * |
310 | * From left to right. 0 is left. The clock uses 10 | 310 | * From left to right. 0 is left. The clock uses 10 |
311 | */ | 311 | */ |
312 | |||
313 | |||
314 | /** | ||
315 | * \class WindowDecorationInterface | ||
316 | * | ||
317 | * Interface class for Window Decorations. Yu need to implement | ||
318 | * metric and drawing functions. | ||
319 | */ | ||
320 | |||
321 | /** | ||
322 | * \class WindowDecorationInterface::WindowData | ||
323 | * | ||
324 | * Window informations like the QRect, Palette, Caption | ||
325 | * and flag | ||
326 | */ | ||
327 | |||
328 | /** | ||
329 | * \fn int WindowDecorationInterface::metric(Metric m,const WindowData* ) | ||
330 | * | ||
331 | * Return the width for the item out of Metric. | ||
332 | * Normally you will case Metric and default: should call the interface | ||
333 | * method. Also return 0 | ||
334 | */ | ||
335 | |||
336 | /** | ||
337 | * \fn void WindowDecorationInterface::drawArea( Area a, QPainter* , const WindowData* )const | ||
338 | * | ||
339 | * draw the Area specefic in a to the QPainter | ||
340 | */ | ||
341 | |||
342 | /** | ||
343 | * \fn void WindowDecorationInterface::drawButton(Button b,QPainter*p ,const WindowData* d, int x, int y, int w,int h, QWSButton::State s)const | ||
344 | * | ||
345 | * @param b The Button to be drawn | ||
346 | * @param p The painter to draw at | ||
347 | * @param d The Window Data | ||
348 | * @param x The X position of the button | ||
349 | * @param y The Y position of the button | ||
350 | * @param w The width of the button | ||
351 | * @param h The height of the button | ||
352 | * @param s The state of the button | ||
353 | */ | ||
354 | |||
355 | /** | ||
356 | * \fn QRegion WindowDecorationInterface::mask( const WindowData* )const | ||
357 | * | ||
358 | * The mask of the Decoration. | ||
359 | * | ||
360 | * \code | ||
361 | * int th = metric(TitleHeight,wd); | ||
362 | * QRect rect( wd->rect ); | ||
363 | * QRect r(rect.left() - metric(LeftBorder,wd), | ||
364 | * rect.top() - th - metric(TopBorder,wd), | ||
365 | * rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), | ||
366 | * rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); | ||
367 | * return QRegion(r) - rect; | ||
368 | * \endcode | ||
369 | */ | ||