summaryrefslogtreecommitdiff
authorzecke <zecke>2003-10-02 19:48:14 (UTC)
committer zecke <zecke>2003-10-02 19:48:14 (UTC)
commitec63bc06518a70d56411291afab8f619b96e67f5 (patch) (unidiff)
tree1013fe66686254cbed9af9198968ae195a2c292a
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 (more/less context) (ignore whitespace changes)
-rw-r--r--library/alarmserver.cpp23
-rw-r--r--library/global.cpp6
2 files changed, 17 insertions, 12 deletions
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp
index 2ea4025..a75fc7e 100644
--- a/library/alarmserver.cpp
+++ b/library/alarmserver.cpp
@@ -259,191 +259,194 @@ void TimerReceiverObject::resetTimer()
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
278void TimerReceiverObject::timerEvent( QTimerEvent * ) 278void 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 \ingroup qtopiaemb 319 \ingroup qtopiaemb
320 \sa QCopEnvelope 320 \sa QCopEnvelope
321*/ 321*/
322 322
323/*! 323/*!
324 Schedules an alarm to go off at (or soon after) time \a when. When 324 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 325 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. 326 be sent to \a channel, with \a data as a parameter.
327 327
328 If this function is called with exactly the same data as a previous 328 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 329 call the subsequent call is ignored, so there is only ever one alarm
330 with a given set of parameters. 330 with a given set of parameters.
331 331
332 \sa deleteAlarm() 332 \sa deleteAlarm()
333*/ 333*/
334void AlarmServer::addAlarm ( QDateTime when, const QCString& channel, 334void AlarmServer::addAlarm ( QDateTime when, const QCString& channel,
335 const QCString& message, int data) 335 const QCString& message, int data)
336{ 336{
337 if ( qApp->type() == QApplication::GuiServer ) { 337 if ( qApp->type() == QApplication::GuiServer ) {
338 bool needSave = FALSE; 338 bool needSave = FALSE;
339 // Here we are the server so either it has been directly called from 339 // 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 340 // within the server or it has been sent to us from a client via QCop
341 if (!timerEventReceiver) 341 if (!timerEventReceiver)
342 timerEventReceiver = new TimerReceiverObject; 342 timerEventReceiver = new TimerReceiverObject;
343 343
344 timerEventItem *newTimerEventItem = new timerEventItem; 344 timerEventItem *newTimerEventItem = new timerEventItem;
345 newTimerEventItem->UTCtime = TimeConversion::toUTC( when ); 345 newTimerEventItem->UTCtime = TimeConversion::toUTC( when );
346 newTimerEventItem->channel = channel; 346 newTimerEventItem->channel = channel;
347 newTimerEventItem->message = message; 347 newTimerEventItem->message = message;
348 newTimerEventItem->data = data; 348 newTimerEventItem->data = data;
349 // explore the case of already having the event in here... 349 // explore the case of already having the event in here...
350 QListIterator<timerEventItem> it( timerEventList ); 350 QListIterator<timerEventItem> it( timerEventList );
351 for ( ; *it; ++it ) 351 for ( ; *it; ++it )
352 if ( *(*it) == *newTimerEventItem ) 352 if ( *(*it) == *newTimerEventItem )
353 return ; 353 return ;
354 // if we made it here, it is okay to add the item... 354 // if we made it here, it is okay to add the item...
355 timerEventList.append( newTimerEventItem ); 355 timerEventList.append( newTimerEventItem );
356 needSave = TRUE; 356 needSave = TRUE;
357 // quicker than using setNearestTimerEvent() 357 // quicker than using setNearestTimerEvent()
358 if ( nearestTimerEvent ) { 358 if ( nearestTimerEvent ) {
359 if (newTimerEventItem->UTCtime < nearestTimerEvent->UTCtime) { 359 if (newTimerEventItem->UTCtime < nearestTimerEvent->UTCtime) {
360 nearestTimerEvent = newTimerEventItem; 360 nearestTimerEvent = newTimerEventItem;
361 timerEventReceiver->killTimers(); 361 timerEventReceiver->killTimers();
362 timerEventReceiver->resetTimer(); 362 timerEventReceiver->resetTimer();
363 } 363 }
364 } 364 }
365 else { 365 else {
366 nearestTimerEvent = newTimerEventItem; 366 nearestTimerEvent = newTimerEventItem;
367 timerEventReceiver->resetTimer(); 367 timerEventReceiver->resetTimer();
368 } 368 }
369 if ( needSave ) 369 if ( needSave )
370 saveState(); 370 saveState();
371 } 371 }
372 else { 372 else {
373#ifndef QT_NO_COP 373#ifndef QT_NO_COP
374 QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" ); 374 QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" );
375 e << when << channel << message << data; 375 e << when << channel << message << data;
376#endif 376#endif
377 377
378 } 378 }
379} 379}
380 380
381/*! 381/*!
382 Deletes previously scheduled alarms which match \a when, \a channel, 382 Deletes previously scheduled alarms which match \a when, \a channel,
383 \a message, and \a data. 383 \a message, and \a data.
384 384
385 Passing null values for \a when, \a channel, or for the \link 385 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". 386 qcop.html QCop\endlink \a message, acts as a wildcard meaning "any".
387 Similarly, passing -1 for \a data indicates "any". 387 Similarly, passing -1 for \a data indicates "any".
388 388
389 If there is no matching alarm, nothing happens. 389 If there is no matching alarm, nothing happens.
390 390
391 \sa addAlarm() 391 \sa addAlarm()
392 392
393*/ 393*/
394void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QCString& message, int data) 394void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QCString& message, int data)
395{ 395{
396 if ( qApp->type() == QApplication::GuiServer) { 396 if ( qApp->type() == QApplication::GuiServer) {
397 bool needSave = FALSE; 397 bool needSave = FALSE;
398 if ( timerEventReceiver != NULL ) { 398 if ( timerEventReceiver != NULL ) {
399 timerEventReceiver->killTimers(); 399 timerEventReceiver->killTimers();
400 400
401 // iterate over the list of events 401 // iterate over the list of events
402 QListIterator<timerEventItem> it( timerEventList ); 402 QListIterator<timerEventItem> it( timerEventList );
403 time_t deleteTime = TimeConversion::toUTC( when ); 403 time_t deleteTime = TimeConversion::toUTC( when );
404 for ( ; *it; ++it ) { 404 for ( ; *it; ++it ) {
405 // if its a match, delete it 405 // if its a match, delete it
406 if ( ( (*it)->UTCtime == deleteTime || when.isNull() ) 406 if ( ( (*it)->UTCtime == deleteTime || when.isNull() )
407 && ( channel.isNull() || (*it)->channel == channel ) 407 && ( channel.isNull() || (*it)->channel == channel )
408 && ( message.isNull() || (*it)->message == message ) 408 && ( message.isNull() || (*it)->message == message )
409 && ( data == -1 || (*it)->data == data ) ) { 409 && ( data == -1 || (*it)->data == data ) ) {
410 // if it's first, then we need to update the timer 410 // if it's first, then we need to update the timer
411 if ( (*it) == nearestTimerEvent ) { 411 if ( (*it) == nearestTimerEvent ) {
412 timerEventList.remove(*it); 412 timerEventList.remove(*it);
413 setNearestTimerEvent(); 413 setNearestTimerEvent();
414 } 414 }
415 else { 415 else {
416 timerEventList.remove(*it); 416 timerEventList.remove(*it);
417 } 417 }
418 needSave = TRUE; 418 needSave = TRUE;
419 } 419 }
420 } 420 }
421 if ( nearestTimerEvent ) 421 if ( nearestTimerEvent )
422 timerEventReceiver->resetTimer(); 422 timerEventReceiver->resetTimer();
423 } 423 }
424 if ( needSave ) 424 if ( needSave )
425 saveState(); 425 saveState();
426 } 426 }
427 else { 427 else {
428#ifndef QT_NO_COP 428#ifndef QT_NO_COP
429 QCopEnvelope e( "QPE/System", "deleteAlarm(QDateTime,QCString,QCString,int)" ); 429 QCopEnvelope e( "QPE/System", "deleteAlarm(QDateTime,QCString,QCString,int)" );
430 e << when << channel << message << data; 430 e << when << channel << message << data;
431#endif 431#endif
432 432
433 } 433 }
434} 434}
435 435
436/*! 436/*!
437 Writes the system clock to the hardware clock. 437 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.
439 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
438*/ 441*/
439void Global::writeHWClock() 442void Global::writeHWClock()
440{ 443{
441#ifdef USE_ATD 444#ifdef USE_ATD
442 if ( !triggerAtd( TRUE ) ) { 445 if ( !triggerAtd( TRUE ) ) {
443 // atd not running? set it ourselves 446 // atd not running? set it ourselves
444 system("/sbin/hwclock --systohc"); // ##### UTC? 447 system("/sbin/hwclock --systohc"); // ##### UTC?
445 } 448 }
446#else 449#else
447 // hwclock is written on suspend 450 // hwclock is written on suspend
448#endif 451#endif
449} 452}
diff --git a/library/global.cpp b/library/global.cpp
index 5c89430..90954fe 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -168,98 +168,100 @@ static QString dictDir()
168 168
169/*! 169/*!
170 \class Global global.h 170 \class Global global.h
171 \brief The Global class provides application-wide global functions. 171 \brief The Global class provides application-wide global functions.
172 172
173 The Global functions are grouped as follows: 173 The Global functions are grouped as follows:
174 \tableofcontents 174 \tableofcontents
175 175
176 \section1 User Interface 176 \section1 User Interface
177 177
178 The statusMessage() function provides short-duration messages to the 178 The statusMessage() function provides short-duration messages to the
179 user. The showInputMethod() function shows the current input method, 179 user. The showInputMethod() function shows the current input method,
180 and hideInputMethod() hides the input method. 180 and hideInputMethod() hides the input method.
181 181
182 \section1 Document related 182 \section1 Document related
183 183
184 The findDocuments() function creates a set of \link doclnk.html 184 The findDocuments() function creates a set of \link doclnk.html
185 DocLnk\endlink objects in a particular folder. 185 DocLnk\endlink objects in a particular folder.
186 186
187 \section1 Filesystem related 187 \section1 Filesystem related
188 188
189 Global provides an applicationFileName() function that returns the 189 Global provides an applicationFileName() function that returns the
190 full path of an application-specific file. 190 full path of an application-specific file.
191 191
192 The execute() function runs an application. 192 The execute() function runs an application.
193 193
194 \section1 Word list related 194 \section1 Word list related
195 195
196 A list of words relevant to the current locale is maintained by the 196 A list of words relevant to the current locale is maintained by the
197 system. The list is held in a \link qdawg.html DAWG\endlink 197 system. The list is held in a \link qdawg.html DAWG\endlink
198 (implemented by the QDawg class). This list is used, for example, by 198 (implemented by the QDawg class). This list is used, for example, by
199 the pickboard input method. 199 the pickboard input method.
200 200
201 The global QDawg is returned by fixedDawg(); this cannot be updated. 201 The global QDawg is returned by fixedDawg(); this cannot be updated.
202 An updatable copy of the global QDawg is returned by addedDawg(). 202 An updatable copy of the global QDawg is returned by addedDawg().
203 Applications may have their own word lists stored in \l{QDawg}s 203 Applications may have their own word lists stored in \l{QDawg}s
204 which are returned by dawg(). Use addWords() to add words to the 204 which are returned by dawg(). Use addWords() to add words to the
205 updateable copy of the global QDawg or to named application 205 updateable copy of the global QDawg or to named application
206 \l{QDawg}s. 206 \l{QDawg}s.
207 207
208 \section1 Quoting 208 \section1 Quoting
209 209
210 The shellQuote() function quotes a string suitable for passing to a 210 The shellQuote() function quotes a string suitable for passing to a
211 shell. The stringQuote() function backslash escapes '\' and '"' 211 shell. The stringQuote() function backslash escapes '\' and '"'
212 characters. 212 characters.
213 213
214 \section1 Hardware 214 \section1 Hardware
215 215
216 The writeHWClock() function sets the hardware clock to the system 216 The implementation of the writeHWClock() function depends on the AlarmServer
217 clock's date and time. 217 implementation. If the AlarmServer is using atd the clock will be synced to
218 hardware. If opie-alarm is used the hardware clock will be synced before
219 suspending the device. opie-alarm is used by iPAQ and Zaurii implementation
218 220
219 \ingroup qtopiaemb 221 \ingroup qtopiaemb
220*/ 222*/
221 223
222/*! 224/*!
223 \internal 225 \internal
224*/ 226*/
225Global::Global() 227Global::Global()
226{ 228{
227} 229}
228 230
229/*! 231/*!
230 Returns the unchangeable QDawg that contains general 232 Returns the unchangeable QDawg that contains general
231 words for the current locale. 233 words for the current locale.
232 234
233 \sa addedDawg() 235 \sa addedDawg()
234*/ 236*/
235const QDawg& Global::fixedDawg() 237const QDawg& Global::fixedDawg()
236{ 238{
237 if ( !fixed_dawg ) { 239 if ( !fixed_dawg ) {
238 if ( !docDirCreated ) 240 if ( !docDirCreated )
239 createDocDir(); 241 createDocDir();
240 242
241 fixed_dawg = new QDawg; 243 fixed_dawg = new QDawg;
242 QString dawgfilename = dictDir() + "/dawg"; 244 QString dawgfilename = dictDir() + "/dawg";
243 QString words_lang; 245 QString words_lang;
244 QStringList langs = Global::languageList(); 246 QStringList langs = Global::languageList();
245 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 247 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
246 QString lang = *it; 248 QString lang = *it;
247 words_lang = dictDir() + "/words." + lang; 249 words_lang = dictDir() + "/words." + lang;
248 QString dawgfilename_lang = dawgfilename + "." + lang; 250 QString dawgfilename_lang = dawgfilename + "." + lang;
249 if ( QFile::exists(dawgfilename_lang) || 251 if ( QFile::exists(dawgfilename_lang) ||
250 QFile::exists(words_lang) ) { 252 QFile::exists(words_lang) ) {
251 dawgfilename = dawgfilename_lang; 253 dawgfilename = dawgfilename_lang;
252 break; 254 break;
253 } 255 }
254 } 256 }
255 QFile dawgfile(dawgfilename); 257 QFile dawgfile(dawgfilename);
256 258
257 if ( !dawgfile.exists() ) { 259 if ( !dawgfile.exists() ) {
258 QString fn = dictDir() + "/words"; 260 QString fn = dictDir() + "/words";
259 if ( QFile::exists(words_lang) ) 261 if ( QFile::exists(words_lang) )
260 fn = words_lang; 262 fn = words_lang;
261 QFile in(fn); 263 QFile in(fn);
262 if ( in.open(IO_ReadOnly) ) { 264 if ( in.open(IO_ReadOnly) ) {
263 fixed_dawg->createFromWords(&in); 265 fixed_dawg->createFromWords(&in);
264 dawgfile.open(IO_WriteOnly); 266 dawgfile.open(IO_WriteOnly);
265 fixed_dawg->write(&dawgfile); 267 fixed_dawg->write(&dawgfile);