author | sandman <sandman> | 2002-08-06 21:46:30 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-06 21:46:30 (UTC) |
commit | 2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b (patch) (unidiff) | |
tree | ad84f4e405da51a6ca14ab4dd33bfd7c9f2a411e | |
parent | 8084d002de5e310491eec7fac0713ef29d0cf30f (diff) | |
download | opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.zip opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.tar.gz opie-2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b.tar.bz2 |
- Fix for the "iPAQ won't suspend until apm --suspend is called" problem
- Improved the resume delay until the LCD backlight is on again
-rw-r--r-- | core/launcher/desktop.cpp | 12 | ||||
-rw-r--r-- | libopie/odevice.cpp | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 7f24259..552c7c3 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -223,584 +223,588 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
223 | delete cardSendTimer; | 223 | delete cardSendTimer; |
224 | } else if ( press ) { | 224 | } else if ( press ) { |
225 | cardSendTimer = new QTimer(); | 225 | cardSendTimer = new QTimer(); |
226 | cardSendTimer->start( 2000, TRUE ); | 226 | cardSendTimer->start( 2000, TRUE ); |
227 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 227 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
228 | } | 228 | } |
229 | return TRUE; | 229 | return TRUE; |
230 | } | 230 | } |
231 | /* menu key now opens application menu/toolbar | 231 | /* menu key now opens application menu/toolbar |
232 | if ( ke->simpleData.keycode == Key_F11 ) { | 232 | if ( ke->simpleData.keycode == Key_F11 ) { |
233 | if ( press ) emit menu(); | 233 | if ( press ) emit menu(); |
234 | return TRUE; | 234 | return TRUE; |
235 | } | 235 | } |
236 | */ | 236 | */ |
237 | if ( ke->simpleData.keycode == Key_F12 ) { | 237 | if ( ke->simpleData.keycode == Key_F12 ) { |
238 | while( activePopupWidget() ) | 238 | while( activePopupWidget() ) |
239 | activePopupWidget()->close(); | 239 | activePopupWidget()->close(); |
240 | if ( press ) emit launch(); | 240 | if ( press ) emit launch(); |
241 | return TRUE; | 241 | return TRUE; |
242 | } | 242 | } |
243 | if ( ke->simpleData.keycode == Key_F13 ) { | 243 | if ( ke->simpleData.keycode == Key_F13 ) { |
244 | if ( press ) emit email(); | 244 | if ( press ) emit email(); |
245 | return TRUE; | 245 | return TRUE; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | if ( ke->simpleData.keycode == Key_F34 ) { | 249 | if ( ke->simpleData.keycode == Key_F34 ) { |
250 | if ( press ) emit power(); | 250 | if ( press ) emit power(); |
251 | return TRUE; | 251 | return TRUE; |
252 | } | 252 | } |
253 | // This was used for the iPAQ PowerButton | 253 | // This was used for the iPAQ PowerButton |
254 | // See main.cpp for new KeyboardFilter | 254 | // See main.cpp for new KeyboardFilter |
255 | // | 255 | // |
256 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 256 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
257 | // if ( press ) emit power(); | 257 | // if ( press ) emit power(); |
258 | // return TRUE; | 258 | // return TRUE; |
259 | // } | 259 | // } |
260 | if ( ke->simpleData.keycode == Key_F35 ) { | 260 | if ( ke->simpleData.keycode == Key_F35 ) { |
261 | if ( press ) emit backlight(); | 261 | if ( press ) emit backlight(); |
262 | return TRUE; | 262 | return TRUE; |
263 | } | 263 | } |
264 | if ( ke->simpleData.keycode == Key_F32 ) { | 264 | if ( ke->simpleData.keycode == Key_F32 ) { |
265 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 265 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
266 | return TRUE; | 266 | return TRUE; |
267 | } | 267 | } |
268 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 268 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
269 | if ( press ) emit symbol(); | 269 | if ( press ) emit symbol(); |
270 | return TRUE; | 270 | return TRUE; |
271 | } | 271 | } |
272 | if ( ke->simpleData.keycode == Key_NumLock ) { | 272 | if ( ke->simpleData.keycode == Key_NumLock ) { |
273 | if ( press ) emit numLockStateToggle(); | 273 | if ( press ) emit numLockStateToggle(); |
274 | } | 274 | } |
275 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 275 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
276 | if ( press ) emit capsLockStateToggle(); | 276 | if ( press ) emit capsLockStateToggle(); |
277 | } | 277 | } |
278 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) | 278 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) |
279 | qpedesktop->keyClick(); | 279 | qpedesktop->keyClick(); |
280 | } else { | 280 | } else { |
281 | if ( e->type == QWSEvent::Mouse ) { | 281 | if ( e->type == QWSEvent::Mouse ) { |
282 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 282 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
283 | static bool up = TRUE; | 283 | static bool up = TRUE; |
284 | if ( me->simpleData.state&LeftButton ) { | 284 | if ( me->simpleData.state&LeftButton ) { |
285 | if ( up ) { | 285 | if ( up ) { |
286 | up = FALSE; | 286 | up = FALSE; |
287 | qpedesktop->screenClick(); | 287 | qpedesktop->screenClick(); |
288 | } | 288 | } |
289 | } else { | 289 | } else { |
290 | up = TRUE; | 290 | up = TRUE; |
291 | } | 291 | } |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | return QPEApplication::qwsEventFilter( e ); | 295 | return QPEApplication::qwsEventFilter( e ); |
296 | } | 296 | } |
297 | #endif | 297 | #endif |
298 | 298 | ||
299 | void DesktopApplication::psTimeout() | 299 | void DesktopApplication::psTimeout() |
300 | { | 300 | { |
301 | qpedesktop->checkMemory(); // in case no events are being generated | 301 | qpedesktop->checkMemory(); // in case no events are being generated |
302 | 302 | ||
303 | *ps = PowerStatusManager::readStatus(); | 303 | *ps = PowerStatusManager::readStatus(); |
304 | 304 | ||
305 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 305 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
306 | pa->alert( tr( "Battery is running very low." ), 6 ); | 306 | pa->alert( tr( "Battery is running very low." ), 6 ); |
307 | } | 307 | } |
308 | 308 | ||
309 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 309 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
310 | pa->alert( tr( "Battery level is critical!\n" | 310 | pa->alert( tr( "Battery level is critical!\n" |
311 | "Keep power off until power restored!" ), 1 ); | 311 | "Keep power off until power restored!" ), 1 ); |
312 | } | 312 | } |
313 | 313 | ||
314 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 314 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
315 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 315 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | void DesktopApplication::sendCard() | 320 | void DesktopApplication::sendCard() |
321 | { | 321 | { |
322 | delete cardSendTimer; | 322 | delete cardSendTimer; |
323 | cardSendTimer = 0; | 323 | cardSendTimer = 0; |
324 | QString card = getenv("HOME"); | 324 | QString card = getenv("HOME"); |
325 | card += "/Applications/addressbook/businesscard.vcf"; | 325 | card += "/Applications/addressbook/businesscard.vcf"; |
326 | 326 | ||
327 | if ( QFile::exists( card ) ) { | 327 | if ( QFile::exists( card ) ) { |
328 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); | 328 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); |
329 | QString mimetype = "text/x-vCard"; | 329 | QString mimetype = "text/x-vCard"; |
330 | e << tr("business card") << card << mimetype; | 330 | e << tr("business card") << card << mimetype; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | #if defined(QPE_HAVE_MEMALERTER) | 334 | #if defined(QPE_HAVE_MEMALERTER) |
335 | QPE_MEMALERTER_IMPL | 335 | QPE_MEMALERTER_IMPL |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | //=========================================================================== | 338 | //=========================================================================== |
339 | 339 | ||
340 | Desktop::Desktop() : | 340 | Desktop::Desktop() : |
341 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 341 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
342 | qcopBridge( 0 ), | 342 | qcopBridge( 0 ), |
343 | transferServer( 0 ), | 343 | transferServer( 0 ), |
344 | packageSlave( 0 ) | 344 | packageSlave( 0 ) |
345 | { | 345 | { |
346 | qpedesktop = this; | 346 | qpedesktop = this; |
347 | 347 | ||
348 | // bg = new Info( this ); | 348 | // bg = new Info( this ); |
349 | tb = new TaskBar; | 349 | tb = new TaskBar; |
350 | 350 | ||
351 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 351 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
352 | 352 | ||
353 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); | 353 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); |
354 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); | 354 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); |
355 | 355 | ||
356 | int displayw = qApp->desktop()->width(); | 356 | int displayw = qApp->desktop()->width(); |
357 | int displayh = qApp->desktop()->height(); | 357 | int displayh = qApp->desktop()->height(); |
358 | 358 | ||
359 | 359 | ||
360 | QSize sz = tb->sizeHint(); | 360 | QSize sz = tb->sizeHint(); |
361 | 361 | ||
362 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 362 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
363 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 363 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
364 | 364 | ||
365 | tb->show(); | 365 | tb->show(); |
366 | launcher->showMaximized(); | 366 | launcher->showMaximized(); |
367 | launcher->show(); | 367 | launcher->show(); |
368 | launcher->raise(); | 368 | launcher->raise(); |
369 | #if defined(QPE_HAVE_MEMALERTER) | 369 | #if defined(QPE_HAVE_MEMALERTER) |
370 | initMemalerter(); | 370 | initMemalerter(); |
371 | #endif | 371 | #endif |
372 | // start services | 372 | // start services |
373 | startTransferServer(); | 373 | startTransferServer(); |
374 | (void) new IrServer( this ); | 374 | (void) new IrServer( this ); |
375 | rereadVolumes(); | 375 | rereadVolumes(); |
376 | 376 | ||
377 | packageSlave = new PackageSlave( this ); | 377 | packageSlave = new PackageSlave( this ); |
378 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); | 378 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); |
379 | 379 | ||
380 | qApp->installEventFilter( this ); | 380 | qApp->installEventFilter( this ); |
381 | } | 381 | } |
382 | 382 | ||
383 | void Desktop::show() | 383 | void Desktop::show() |
384 | { | 384 | { |
385 | login(TRUE); | 385 | login(TRUE); |
386 | QWidget::show(); | 386 | QWidget::show(); |
387 | } | 387 | } |
388 | 388 | ||
389 | Desktop::~Desktop() | 389 | Desktop::~Desktop() |
390 | { | 390 | { |
391 | delete launcher; | 391 | delete launcher; |
392 | delete tb; | 392 | delete tb; |
393 | delete qcopBridge; | 393 | delete qcopBridge; |
394 | delete transferServer; | 394 | delete transferServer; |
395 | } | 395 | } |
396 | 396 | ||
397 | bool Desktop::recoverMemory() | 397 | bool Desktop::recoverMemory() |
398 | { | 398 | { |
399 | return tb->recoverMemory(); | 399 | return tb->recoverMemory(); |
400 | } | 400 | } |
401 | 401 | ||
402 | void Desktop::checkMemory() | 402 | void Desktop::checkMemory() |
403 | { | 403 | { |
404 | #if defined(QPE_HAVE_MEMALERTER) | 404 | #if defined(QPE_HAVE_MEMALERTER) |
405 | static bool ignoreNormal=FALSE; | 405 | static bool ignoreNormal=FALSE; |
406 | static bool existingMessage=FALSE; | 406 | static bool existingMessage=FALSE; |
407 | 407 | ||
408 | if(existingMessage) | 408 | if(existingMessage) |
409 | return; // don't show a second message while still on first | 409 | return; // don't show a second message while still on first |
410 | 410 | ||
411 | existingMessage = TRUE; | 411 | existingMessage = TRUE; |
412 | switch ( memstate ) { | 412 | switch ( memstate ) { |
413 | case Unknown: | 413 | case Unknown: |
414 | break; | 414 | break; |
415 | case Low: | 415 | case Low: |
416 | memstate = Unknown; | 416 | memstate = Unknown; |
417 | if ( recoverMemory() ) | 417 | if ( recoverMemory() ) |
418 | ignoreNormal = TRUE; | 418 | ignoreNormal = TRUE; |
419 | else | 419 | else |
420 | QMessageBox::warning( 0 , "Memory Status", | 420 | QMessageBox::warning( 0 , "Memory Status", |
421 | "The memory smacks of shortage. \n" | 421 | "The memory smacks of shortage. \n" |
422 | "Please save data. " ); | 422 | "Please save data. " ); |
423 | break; | 423 | break; |
424 | case Normal: | 424 | case Normal: |
425 | memstate = Unknown; | 425 | memstate = Unknown; |
426 | if ( ignoreNormal ) | 426 | if ( ignoreNormal ) |
427 | ignoreNormal = FALSE; | 427 | ignoreNormal = FALSE; |
428 | else | 428 | else |
429 | QMessageBox::information ( 0 , "Memory Status", | 429 | QMessageBox::information ( 0 , "Memory Status", |
430 | "There is enough memory again." ); | 430 | "There is enough memory again." ); |
431 | break; | 431 | break; |
432 | case VeryLow: | 432 | case VeryLow: |
433 | memstate = Unknown; | 433 | memstate = Unknown; |
434 | QMessageBox::critical( 0 , "Memory Status", | 434 | QMessageBox::critical( 0 , "Memory Status", |
435 | "The memory is very low. \n" | 435 | "The memory is very low. \n" |
436 | "Please end this application \n" | 436 | "Please end this application \n" |
437 | "immediately." ); | 437 | "immediately." ); |
438 | recoverMemory(); | 438 | recoverMemory(); |
439 | } | 439 | } |
440 | existingMessage = FALSE; | 440 | existingMessage = FALSE; |
441 | #endif | 441 | #endif |
442 | } | 442 | } |
443 | 443 | ||
444 | static bool isVisibleWindow(int wid) | 444 | static bool isVisibleWindow(int wid) |
445 | { | 445 | { |
446 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 446 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
447 | QWSWindow* w; | 447 | QWSWindow* w; |
448 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 448 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
449 | if ( w->winId() == wid ) | 449 | if ( w->winId() == wid ) |
450 | return !w->isFullyObscured(); | 450 | return !w->isFullyObscured(); |
451 | } | 451 | } |
452 | return FALSE; | 452 | return FALSE; |
453 | } | 453 | } |
454 | 454 | ||
455 | static bool hasVisibleWindow(const QString& clientname) | 455 | static bool hasVisibleWindow(const QString& clientname) |
456 | { | 456 | { |
457 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 457 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
458 | QWSWindow* w; | 458 | QWSWindow* w; |
459 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 459 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
460 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) | 460 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) |
461 | return TRUE; | 461 | return TRUE; |
462 | } | 462 | } |
463 | return FALSE; | 463 | return FALSE; |
464 | } | 464 | } |
465 | 465 | ||
466 | void Desktop::raiseLauncher() | 466 | void Desktop::raiseLauncher() |
467 | { | 467 | { |
468 | Config cfg("qpe"); //F12 'Home' | 468 | Config cfg("qpe"); //F12 'Home' |
469 | cfg.setGroup("AppsKey"); | 469 | cfg.setGroup("AppsKey"); |
470 | QString tempItem; | 470 | QString tempItem; |
471 | tempItem = cfg.readEntry("Middle","Home"); | 471 | tempItem = cfg.readEntry("Middle","Home"); |
472 | if(tempItem == "Home" || tempItem.isEmpty()) { | 472 | if(tempItem == "Home" || tempItem.isEmpty()) { |
473 | if ( isVisibleWindow(launcher->winId()) ) | 473 | if ( isVisibleWindow(launcher->winId()) ) |
474 | launcher->nextView(); | 474 | launcher->nextView(); |
475 | else | 475 | else |
476 | launcher->raise(); | 476 | launcher->raise(); |
477 | } else { | 477 | } else { |
478 | QCopEnvelope e("QPE/System","execute(QString)"); | 478 | QCopEnvelope e("QPE/System","execute(QString)"); |
479 | e << tempItem; | 479 | e << tempItem; |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | void Desktop::executeOrModify(const QString& appLnkFile) | 483 | void Desktop::executeOrModify(const QString& appLnkFile) |
484 | { | 484 | { |
485 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); | 485 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); |
486 | if ( lnk.isValid() ) { | 486 | if ( lnk.isValid() ) { |
487 | QCString app = lnk.exec().utf8(); | 487 | QCString app = lnk.exec().utf8(); |
488 | Global::terminateBuiltin("calibrate"); | 488 | Global::terminateBuiltin("calibrate"); |
489 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { | 489 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { |
490 | MRUList::addTask(&lnk); | 490 | MRUList::addTask(&lnk); |
491 | if ( hasVisibleWindow(app) ) | 491 | if ( hasVisibleWindow(app) ) |
492 | QCopChannel::send("QPE/Application/" + app, "nextView()"); | 492 | QCopChannel::send("QPE/Application/" + app, "nextView()"); |
493 | else | 493 | else |
494 | QCopChannel::send("QPE/Application/" + app, "raise()"); | 494 | QCopChannel::send("QPE/Application/" + app, "raise()"); |
495 | } else { | 495 | } else { |
496 | lnk.execute(); | 496 | lnk.execute(); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | void Desktop::raiseDatebook() | 501 | void Desktop::raiseDatebook() |
502 | { | 502 | { |
503 | Config cfg("qpe"); //F9 'Activity' | 503 | Config cfg("qpe"); //F9 'Activity' |
504 | cfg.setGroup("AppsKey"); | 504 | cfg.setGroup("AppsKey"); |
505 | QString tempItem; | 505 | QString tempItem; |
506 | tempItem = cfg.readEntry("LeftEnd","Calender"); | 506 | tempItem = cfg.readEntry("LeftEnd","Calender"); |
507 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); | 507 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); |
508 | else { | 508 | else { |
509 | QCopEnvelope e("QPE/System","execute(QString)"); | 509 | QCopEnvelope e("QPE/System","execute(QString)"); |
510 | e << tempItem; | 510 | e << tempItem; |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | void Desktop::raiseContacts() | 514 | void Desktop::raiseContacts() |
515 | { | 515 | { |
516 | Config cfg("qpe"); //F10, 'Contacts' | 516 | Config cfg("qpe"); //F10, 'Contacts' |
517 | cfg.setGroup("AppsKey"); | 517 | cfg.setGroup("AppsKey"); |
518 | QString tempItem; | 518 | QString tempItem; |
519 | tempItem = cfg.readEntry("Left2nd","Address Book"); | 519 | tempItem = cfg.readEntry("Left2nd","Address Book"); |
520 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); | 520 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); |
521 | else { | 521 | else { |
522 | QCopEnvelope e("QPE/System","execute(QString)"); | 522 | QCopEnvelope e("QPE/System","execute(QString)"); |
523 | e << tempItem; | 523 | e << tempItem; |
524 | } | 524 | } |
525 | } | 525 | } |
526 | 526 | ||
527 | void Desktop::raiseMenu() | 527 | void Desktop::raiseMenu() |
528 | { | 528 | { |
529 | Config cfg("qpe"); //F11, 'Menu' | 529 | Config cfg("qpe"); //F11, 'Menu' |
530 | cfg.setGroup("AppsKey"); | 530 | cfg.setGroup("AppsKey"); |
531 | QString tempItem; | 531 | QString tempItem; |
532 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); | 532 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); |
533 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { | 533 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { |
534 | Global::terminateBuiltin("calibrate"); | 534 | Global::terminateBuiltin("calibrate"); |
535 | tb->startMenu()->launch(); | 535 | tb->startMenu()->launch(); |
536 | } else { | 536 | } else { |
537 | QCopEnvelope e("QPE/System","execute(QString)"); | 537 | QCopEnvelope e("QPE/System","execute(QString)"); |
538 | e << tempItem; | 538 | e << tempItem; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | void Desktop::raiseEmail() | 542 | void Desktop::raiseEmail() |
543 | { | 543 | { |
544 | Config cfg("qpe"); //F13, 'Mail' | 544 | Config cfg("qpe"); //F13, 'Mail' |
545 | cfg.setGroup("AppsKey"); | 545 | cfg.setGroup("AppsKey"); |
546 | QString tempItem; | 546 | QString tempItem; |
547 | tempItem = cfg.readEntry("RightEnd","Mail"); | 547 | tempItem = cfg.readEntry("RightEnd","Mail"); |
548 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); | 548 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); |
549 | else { | 549 | else { |
550 | QCopEnvelope e("QPE/System","execute(QString)"); | 550 | QCopEnvelope e("QPE/System","execute(QString)"); |
551 | e << tempItem; | 551 | e << tempItem; |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | // autoStarts apps on resume and start | 555 | // autoStarts apps on resume and start |
556 | void Desktop::execAutoStart() { | 556 | void Desktop::execAutoStart() { |
557 | QString appName; | 557 | QString appName; |
558 | int delay; | 558 | int delay; |
559 | QDateTime now = QDateTime::currentDateTime(); | 559 | QDateTime now = QDateTime::currentDateTime(); |
560 | Config cfg( "autostart" ); | 560 | Config cfg( "autostart" ); |
561 | cfg.setGroup( "AutoStart" ); | 561 | cfg.setGroup( "AutoStart" ); |
562 | appName = cfg.readEntry("Apps", ""); | 562 | appName = cfg.readEntry("Apps", ""); |
563 | delay = (cfg.readEntry("Delay", "0" )).toInt(); | 563 | delay = (cfg.readEntry("Delay", "0" )).toInt(); |
564 | // If the time between suspend and resume was longer then the | 564 | // If the time between suspend and resume was longer then the |
565 | // value saved as delay, start the app | 565 | // value saved as delay, start the app |
566 | if ( suspendTime.secsTo(now) >= (delay*60) ) { | 566 | if ( suspendTime.secsTo(now) >= (delay*60) ) { |
567 | QCopEnvelope e("QPE/System", "execute(QString)"); | 567 | QCopEnvelope e("QPE/System", "execute(QString)"); |
568 | e << QString(appName); | 568 | e << QString(appName); |
569 | } //else { | 569 | } //else { |
570 | //} | 570 | //} |
571 | } | 571 | } |
572 | 572 | ||
573 | #if defined(QPE_HAVE_TOGGLELIGHT) | 573 | #if defined(QPE_HAVE_TOGGLELIGHT) |
574 | #include <qpe/config.h> | 574 | #include <qpe/config.h> |
575 | 575 | ||
576 | #include <sys/ioctl.h> | 576 | #include <sys/ioctl.h> |
577 | #include <sys/types.h> | 577 | #include <sys/types.h> |
578 | #include <fcntl.h> | 578 | #include <fcntl.h> |
579 | #include <unistd.h> | 579 | #include <unistd.h> |
580 | #include <errno.h> | 580 | #include <errno.h> |
581 | #include <linux/ioctl.h> | 581 | #include <linux/ioctl.h> |
582 | #include <time.h> | 582 | #include <time.h> |
583 | #endif | 583 | #endif |
584 | 584 | ||
585 | static bool blanked=FALSE; | 585 | static bool blanked=FALSE; |
586 | 586 | ||
587 | static void blankScreen() | 587 | static void blankScreen() |
588 | { | 588 | { |
589 | if ( !qt_screen ) return; | 589 | if ( !qt_screen ) return; |
590 | /* Should use a big black window instead. | 590 | /* Should use a big black window instead. |
591 | QGfx* g = qt_screen->screenGfx(); | 591 | QGfx* g = qt_screen->screenGfx(); |
592 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); | 592 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); |
593 | delete g; | 593 | delete g; |
594 | */ | 594 | */ |
595 | blanked = TRUE; | 595 | blanked = TRUE; |
596 | } | 596 | } |
597 | 597 | ||
598 | static void darkScreen() | 598 | static void darkScreen() |
599 | { | 599 | { |
600 | extern void qpe_setBacklight(int); | 600 | extern void qpe_setBacklight(int); |
601 | qpe_setBacklight(0); // force off | 601 | qpe_setBacklight(0); // force off |
602 | } | 602 | } |
603 | 603 | ||
604 | 604 | ||
605 | void Desktop::togglePower() | 605 | void Desktop::togglePower() |
606 | { | 606 | { |
607 | extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop | ||
608 | |||
607 | static bool excllock = false; | 609 | static bool excllock = false; |
608 | 610 | ||
609 | if ( excllock ) | 611 | if ( excllock ) |
610 | return; | 612 | return; |
611 | 613 | ||
612 | excllock = true; | 614 | excllock = true; |
613 | 615 | ||
614 | bool wasloggedin = loggedin; | 616 | bool wasloggedin = loggedin; |
615 | loggedin=0; | 617 | loggedin=0; |
616 | suspendTime = QDateTime::currentDateTime(); | 618 | suspendTime = QDateTime::currentDateTime(); |
617 | darkScreen(); | 619 | |
620 | qpe_setBacklight ( 0 ); // force LCD off | ||
621 | |||
618 | if ( wasloggedin ) | 622 | if ( wasloggedin ) |
619 | blankScreen(); | 623 | blankScreen(); |
620 | 624 | ||
621 | ODevice::inst ( )-> suspend ( ); | 625 | ODevice::inst ( )-> suspend ( ); |
622 | 626 | ||
623 | QWSServer::screenSaverActivate( FALSE ); | 627 | QWSServer::screenSaverActivate ( false ); |
628 | |||
629 | qpe_setBacklight ( -3 ); // force LCD on | ||
624 | 630 | ||
625 | { | 631 | { |
626 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 632 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
627 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | ||
628 | e << -3; // Force on | ||
629 | } | 633 | } |
630 | 634 | ||
631 | if ( wasloggedin ) | 635 | if ( wasloggedin ) |
632 | login(TRUE); | 636 | login(TRUE); |
633 | 637 | ||
634 | execAutoStart(); | 638 | execAutoStart(); |
635 | //qcopBridge->closeOpenConnections(); | 639 | //qcopBridge->closeOpenConnections(); |
636 | //qDebug("called togglePower()!!!!!!"); | 640 | //qDebug("called togglePower()!!!!!!"); |
637 | 641 | ||
638 | qApp-> processEvents ( ); | 642 | qApp-> processEvents ( ); |
639 | 643 | ||
640 | excllock = false; | 644 | excllock = false; |
641 | } | 645 | } |
642 | 646 | ||
643 | void Desktop::toggleLight() | 647 | void Desktop::toggleLight() |
644 | { | 648 | { |
645 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 649 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
646 | e << -2; // toggle | 650 | e << -2; // toggle |
647 | } | 651 | } |
648 | 652 | ||
649 | void Desktop::toggleSymbolInput() | 653 | void Desktop::toggleSymbolInput() |
650 | { | 654 | { |
651 | tb->toggleSymbolInput(); | 655 | tb->toggleSymbolInput(); |
652 | } | 656 | } |
653 | 657 | ||
654 | void Desktop::toggleNumLockState() | 658 | void Desktop::toggleNumLockState() |
655 | { | 659 | { |
656 | tb->toggleNumLockState(); | 660 | tb->toggleNumLockState(); |
657 | } | 661 | } |
658 | 662 | ||
659 | void Desktop::toggleCapsLockState() | 663 | void Desktop::toggleCapsLockState() |
660 | { | 664 | { |
661 | tb->toggleCapsLockState(); | 665 | tb->toggleCapsLockState(); |
662 | } | 666 | } |
663 | 667 | ||
664 | void Desktop::styleChange( QStyle &s ) | 668 | void Desktop::styleChange( QStyle &s ) |
665 | { | 669 | { |
666 | QWidget::styleChange( s ); | 670 | QWidget::styleChange( s ); |
667 | int displayw = qApp->desktop()->width(); | 671 | int displayw = qApp->desktop()->width(); |
668 | int displayh = qApp->desktop()->height(); | 672 | int displayh = qApp->desktop()->height(); |
669 | 673 | ||
670 | QSize sz = tb->sizeHint(); | 674 | QSize sz = tb->sizeHint(); |
671 | 675 | ||
672 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 676 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
673 | } | 677 | } |
674 | 678 | ||
675 | void DesktopApplication::shutdown() | 679 | void DesktopApplication::shutdown() |
676 | { | 680 | { |
677 | if ( type() != GuiServer ) | 681 | if ( type() != GuiServer ) |
678 | return; | 682 | return; |
679 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 683 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
680 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 684 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
681 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 685 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
682 | sd->showMaximized(); | 686 | sd->showMaximized(); |
683 | } | 687 | } |
684 | 688 | ||
685 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 689 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
686 | { | 690 | { |
687 | switch ( t ) { | 691 | switch ( t ) { |
688 | case ShutdownImpl::ShutdownSystem: | 692 | case ShutdownImpl::ShutdownSystem: |
689 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); | 693 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); |
690 | break; | 694 | break; |
691 | case ShutdownImpl::RebootSystem: | 695 | case ShutdownImpl::RebootSystem: |
692 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); | 696 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); |
693 | break; | 697 | break; |
694 | case ShutdownImpl::RestartDesktop: | 698 | case ShutdownImpl::RestartDesktop: |
695 | restart(); | 699 | restart(); |
696 | break; | 700 | break; |
697 | case ShutdownImpl::TerminateDesktop: | 701 | case ShutdownImpl::TerminateDesktop: |
698 | prepareForTermination(FALSE); | 702 | prepareForTermination(FALSE); |
699 | 703 | ||
700 | // This is a workaround for a Qt bug | 704 | // This is a workaround for a Qt bug |
701 | // clipboard applet has to stop its poll timer, or Qt/E | 705 | // clipboard applet has to stop its poll timer, or Qt/E |
702 | // will hang on quit() right before it emits aboutToQuit() | 706 | // will hang on quit() right before it emits aboutToQuit() |
703 | emit aboutToQuit ( ); | 707 | emit aboutToQuit ( ); |
704 | 708 | ||
705 | quit(); | 709 | quit(); |
706 | break; | 710 | break; |
707 | } | 711 | } |
708 | } | 712 | } |
709 | 713 | ||
710 | void DesktopApplication::restart() | 714 | void DesktopApplication::restart() |
711 | { | 715 | { |
712 | prepareForTermination(TRUE); | 716 | prepareForTermination(TRUE); |
713 | 717 | ||
714 | #ifdef Q_WS_QWS | 718 | #ifdef Q_WS_QWS |
715 | for ( int fd = 3; fd < 100; fd++ ) | 719 | for ( int fd = 3; fd < 100; fd++ ) |
716 | close( fd ); | 720 | close( fd ); |
717 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 721 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
718 | execl( "/sbin/init", "qpe", 0 ); | 722 | execl( "/sbin/init", "qpe", 0 ); |
719 | #elif defined(QT_QWS_CASSIOPEIA) | 723 | #elif defined(QT_QWS_CASSIOPEIA) |
720 | execl( "/bin/sh", "sh", 0 ); | 724 | execl( "/bin/sh", "sh", 0 ); |
721 | #else | 725 | #else |
722 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); | 726 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); |
723 | #endif | 727 | #endif |
724 | exit(1); | 728 | exit(1); |
725 | #endif | 729 | #endif |
726 | } | 730 | } |
727 | 731 | ||
728 | void Desktop::startTransferServer() | 732 | void Desktop::startTransferServer() |
729 | { | 733 | { |
730 | // start qcop bridge server | 734 | // start qcop bridge server |
731 | qcopBridge = new QCopBridge( 4243 ); | 735 | qcopBridge = new QCopBridge( 4243 ); |
732 | if ( !qcopBridge->ok() ) { | 736 | if ( !qcopBridge->ok() ) { |
733 | delete qcopBridge; | 737 | delete qcopBridge; |
734 | qcopBridge = 0; | 738 | qcopBridge = 0; |
735 | } | 739 | } |
736 | // start transfer server | 740 | // start transfer server |
737 | transferServer = new TransferServer( 4242 ); | 741 | transferServer = new TransferServer( 4242 ); |
738 | if ( !transferServer->ok() ) { | 742 | if ( !transferServer->ok() ) { |
739 | delete transferServer; | 743 | delete transferServer; |
740 | transferServer = 0; | 744 | transferServer = 0; |
741 | } | 745 | } |
742 | if ( !transferServer || !qcopBridge ) | 746 | if ( !transferServer || !qcopBridge ) |
743 | startTimer( 2000 ); | 747 | startTimer( 2000 ); |
744 | } | 748 | } |
745 | 749 | ||
746 | void Desktop::timerEvent( QTimerEvent *e ) | 750 | void Desktop::timerEvent( QTimerEvent *e ) |
747 | { | 751 | { |
748 | killTimer( e->timerId() ); | 752 | killTimer( e->timerId() ); |
749 | startTransferServer(); | 753 | startTransferServer(); |
750 | } | 754 | } |
751 | 755 | ||
752 | void Desktop::terminateServers() | 756 | void Desktop::terminateServers() |
753 | { | 757 | { |
754 | delete transferServer; | 758 | delete transferServer; |
755 | delete qcopBridge; | 759 | delete qcopBridge; |
756 | transferServer = 0; | 760 | transferServer = 0; |
757 | qcopBridge = 0; | 761 | qcopBridge = 0; |
758 | } | 762 | } |
759 | 763 | ||
760 | void Desktop::rereadVolumes() | 764 | void Desktop::rereadVolumes() |
761 | { | 765 | { |
762 | Config cfg("qpe"); | 766 | Config cfg("qpe"); |
763 | cfg.setGroup("Volume"); | 767 | cfg.setGroup("Volume"); |
764 | touchclick = cfg.readBoolEntry("TouchSound"); | 768 | touchclick = cfg.readBoolEntry("TouchSound"); |
765 | keyclick = cfg.readBoolEntry("KeySound"); | 769 | keyclick = cfg.readBoolEntry("KeySound"); |
766 | alarmsound = cfg.readBoolEntry("AlarmSound"); | 770 | alarmsound = cfg.readBoolEntry("AlarmSound"); |
767 | // Config cfg("Sound"); | 771 | // Config cfg("Sound"); |
768 | // cfg.setGroup("System"); | 772 | // cfg.setGroup("System"); |
769 | // touchclick = cfg.readBoolEntry("Touch"); | 773 | // touchclick = cfg.readBoolEntry("Touch"); |
770 | // keyclick = cfg.readBoolEntry("Key"); | 774 | // keyclick = cfg.readBoolEntry("Key"); |
771 | } | 775 | } |
772 | 776 | ||
773 | void Desktop::keyClick() | 777 | void Desktop::keyClick() |
774 | { | 778 | { |
775 | if ( keyclick ) | 779 | if ( keyclick ) |
776 | ODevice::inst ( )-> keySound ( ); | 780 | ODevice::inst ( )-> keySound ( ); |
777 | } | 781 | } |
778 | 782 | ||
779 | void Desktop::screenClick() | 783 | void Desktop::screenClick() |
780 | { | 784 | { |
781 | if ( touchclick ) | 785 | if ( touchclick ) |
782 | ODevice::inst ( )-> touchSound ( ); | 786 | ODevice::inst ( )-> touchSound ( ); |
783 | } | 787 | } |
784 | 788 | ||
785 | void Desktop::soundAlarm() | 789 | void Desktop::soundAlarm() |
786 | { | 790 | { |
787 | if ( qpedesktop-> alarmsound ) | 791 | if ( qpedesktop-> alarmsound ) |
788 | ODevice::inst ( )-> alarmSound ( ); | 792 | ODevice::inst ( )-> alarmSound ( ); |
789 | } | 793 | } |
790 | 794 | ||
791 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | 795 | bool Desktop::eventFilter( QObject *, QEvent *ev ) |
792 | { | 796 | { |
793 | if ( ev-> type ( ) == QEvent::KeyPress ) { | 797 | if ( ev-> type ( ) == QEvent::KeyPress ) { |
794 | QKeyEvent *ke = (QKeyEvent *) ev; | 798 | QKeyEvent *ke = (QKeyEvent *) ev; |
795 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key | 799 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key |
796 | QWidget *active = qApp-> activeWindow ( ); | 800 | QWidget *active = qApp-> activeWindow ( ); |
797 | 801 | ||
798 | if ( active && active-> isPopup ( )) | 802 | if ( active && active-> isPopup ( )) |
799 | active->close(); | 803 | active->close(); |
800 | 804 | ||
801 | raiseMenu ( ); | 805 | raiseMenu ( ); |
802 | return true; | 806 | return true; |
803 | } | 807 | } |
804 | } | 808 | } |
805 | return false; | 809 | return false; |
806 | } | 810 | } |
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 057c344..bf64676 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,576 +1,578 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | 21 | ||
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qpe/sound.h> | 24 | #include <qpe/sound.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | 26 | ||
27 | 27 | ||
28 | #include "odevice.h" | 28 | #include "odevice.h" |
29 | 29 | ||
30 | 30 | ||
31 | class ODeviceData { | 31 | class ODeviceData { |
32 | public: | 32 | public: |
33 | QString m_vendorstr; | 33 | QString m_vendorstr; |
34 | OVendor m_vendor; | 34 | OVendor m_vendor; |
35 | 35 | ||
36 | QString m_modelstr; | 36 | QString m_modelstr; |
37 | OModel m_model; | 37 | OModel m_model; |
38 | 38 | ||
39 | QString m_systemstr; | 39 | QString m_systemstr; |
40 | OSystem m_system; | 40 | OSystem m_system; |
41 | 41 | ||
42 | QString m_sysverstr; | 42 | QString m_sysverstr; |
43 | 43 | ||
44 | OLedState m_leds [4]; // just for convenience ... | 44 | OLedState m_leds [4]; // just for convenience ... |
45 | }; | 45 | }; |
46 | 46 | ||
47 | class ODeviceIPAQ : public ODevice { | 47 | class ODeviceIPAQ : public ODevice { |
48 | protected: | 48 | protected: |
49 | virtual void init ( ); | 49 | virtual void init ( ); |
50 | 50 | ||
51 | public: | 51 | public: |
52 | virtual bool suspend ( ); | 52 | virtual bool suspend ( ); |
53 | 53 | ||
54 | virtual void alarmSound ( ); | 54 | virtual void alarmSound ( ); |
55 | 55 | ||
56 | virtual uint hasLeds ( ) const; | 56 | virtual uint hasLeds ( ) const; |
57 | virtual OLedState led ( uint which ) const; | 57 | virtual OLedState led ( uint which ) const; |
58 | virtual bool setLed ( uint which, OLedState st ); | 58 | virtual bool setLed ( uint which, OLedState st ); |
59 | 59 | ||
60 | private: | 60 | private: |
61 | static void tstp_sighandler ( int ); | 61 | static void tstp_sighandler ( int ); |
62 | }; | 62 | }; |
63 | 63 | ||
64 | class ODeviceZaurus : public ODevice { | 64 | class ODeviceZaurus : public ODevice { |
65 | protected: | 65 | protected: |
66 | virtual void init ( ); | 66 | virtual void init ( ); |
67 | 67 | ||
68 | public: | 68 | public: |
69 | virtual void alarmSound ( ); | 69 | virtual void alarmSound ( ); |
70 | virtual void keySound ( ); | 70 | virtual void keySound ( ); |
71 | virtual void touchSound ( ); | 71 | virtual void touchSound ( ); |
72 | 72 | ||
73 | virtual uint hasLeds ( ) const; | 73 | virtual uint hasLeds ( ) const; |
74 | virtual OLedState led ( uint which ) const; | 74 | virtual OLedState led ( uint which ) const; |
75 | virtual bool setLed ( uint which, OLedState st ); | 75 | virtual bool setLed ( uint which, OLedState st ); |
76 | 76 | ||
77 | protected: | 77 | protected: |
78 | virtual void buzzer ( int snd ); | 78 | virtual void buzzer ( int snd ); |
79 | }; | 79 | }; |
80 | 80 | ||
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | ODevice *ODevice::inst ( ) | 84 | ODevice *ODevice::inst ( ) |
85 | { | 85 | { |
86 | static ODevice *dev = 0; | 86 | static ODevice *dev = 0; |
87 | 87 | ||
88 | if ( !dev ) { | 88 | if ( !dev ) { |
89 | if ( QFile::exists ( "/proc/hal/model" )) | 89 | if ( QFile::exists ( "/proc/hal/model" )) |
90 | dev = new ODeviceIPAQ ( ); | 90 | dev = new ODeviceIPAQ ( ); |
91 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 91 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
92 | dev = new ODeviceZaurus ( ); | 92 | dev = new ODeviceZaurus ( ); |
93 | else | 93 | else |
94 | dev = new ODevice ( ); | 94 | dev = new ODevice ( ); |
95 | 95 | ||
96 | dev-> init ( ); | 96 | dev-> init ( ); |
97 | } | 97 | } |
98 | return dev; | 98 | return dev; |
99 | } | 99 | } |
100 | 100 | ||
101 | ODevice::ODevice ( ) | 101 | ODevice::ODevice ( ) |
102 | { | 102 | { |
103 | d = new ODeviceData; | 103 | d = new ODeviceData; |
104 | 104 | ||
105 | d-> m_modelstr = "Unknown"; | 105 | d-> m_modelstr = "Unknown"; |
106 | d-> m_model = OMODEL_Unknown; | 106 | d-> m_model = OMODEL_Unknown; |
107 | d-> m_vendorstr = "Unkown"; | 107 | d-> m_vendorstr = "Unkown"; |
108 | d-> m_vendor = OVENDOR_Unknown; | 108 | d-> m_vendor = OVENDOR_Unknown; |
109 | d-> m_systemstr = "Unkown"; | 109 | d-> m_systemstr = "Unkown"; |
110 | d-> m_system = OSYSTEM_Unknown; | 110 | d-> m_system = OSYSTEM_Unknown; |
111 | d-> m_sysverstr = "0.0"; | 111 | d-> m_sysverstr = "0.0"; |
112 | } | 112 | } |
113 | 113 | ||
114 | void ODevice::init ( ) | 114 | void ODevice::init ( ) |
115 | { | 115 | { |
116 | } | 116 | } |
117 | 117 | ||
118 | ODevice::~ODevice ( ) | 118 | ODevice::~ODevice ( ) |
119 | { | 119 | { |
120 | delete d; | 120 | delete d; |
121 | } | 121 | } |
122 | 122 | ||
123 | bool ODevice::suspend ( ) | 123 | bool ODevice::suspend ( ) |
124 | { | 124 | { |
125 | int rc = ::system ( "apm --suspend" ); | 125 | int rc = ::system ( "apm --suspend" ); |
126 | 126 | ||
127 | if (( rc == 127 ) || ( rc == -1 )) | 127 | if (( rc == 127 ) || ( rc == -1 )) |
128 | return false; | 128 | return false; |
129 | else | 129 | else |
130 | return true; | 130 | return true; |
131 | } | 131 | } |
132 | 132 | ||
133 | QString ODevice::vendorString ( ) | 133 | QString ODevice::vendorString ( ) |
134 | { | 134 | { |
135 | return d-> m_vendorstr; | 135 | return d-> m_vendorstr; |
136 | } | 136 | } |
137 | 137 | ||
138 | OVendor ODevice::vendor ( ) | 138 | OVendor ODevice::vendor ( ) |
139 | { | 139 | { |
140 | return d-> m_vendor; | 140 | return d-> m_vendor; |
141 | } | 141 | } |
142 | 142 | ||
143 | QString ODevice::modelString ( ) | 143 | QString ODevice::modelString ( ) |
144 | { | 144 | { |
145 | return d-> m_modelstr; | 145 | return d-> m_modelstr; |
146 | } | 146 | } |
147 | 147 | ||
148 | OModel ODevice::model ( ) | 148 | OModel ODevice::model ( ) |
149 | { | 149 | { |
150 | return d-> m_model; | 150 | return d-> m_model; |
151 | } | 151 | } |
152 | 152 | ||
153 | QString ODevice::systemString ( ) | 153 | QString ODevice::systemString ( ) |
154 | { | 154 | { |
155 | return d-> m_systemstr; | 155 | return d-> m_systemstr; |
156 | } | 156 | } |
157 | 157 | ||
158 | OSystem ODevice::system ( ) | 158 | OSystem ODevice::system ( ) |
159 | { | 159 | { |
160 | return d-> m_system; | 160 | return d-> m_system; |
161 | } | 161 | } |
162 | 162 | ||
163 | QString ODevice::systemVersionString ( ) | 163 | QString ODevice::systemVersionString ( ) |
164 | { | 164 | { |
165 | return d-> m_sysverstr; | 165 | return d-> m_sysverstr; |
166 | } | 166 | } |
167 | 167 | ||
168 | void ODevice::alarmSound ( ) | 168 | void ODevice::alarmSound ( ) |
169 | { | 169 | { |
170 | #ifndef QT_QWS_EBX | 170 | #ifndef QT_QWS_EBX |
171 | #ifndef QT_NO_SOUND | 171 | #ifndef QT_NO_SOUND |
172 | static Sound snd ( "alarm" ); | 172 | static Sound snd ( "alarm" ); |
173 | 173 | ||
174 | if ( snd. isFinished ( )) | 174 | if ( snd. isFinished ( )) |
175 | snd. play ( ); | 175 | snd. play ( ); |
176 | #endif | 176 | #endif |
177 | #endif | 177 | #endif |
178 | } | 178 | } |
179 | 179 | ||
180 | void ODevice::keySound ( ) | 180 | void ODevice::keySound ( ) |
181 | { | 181 | { |
182 | #ifndef QT_QWS_EBX | 182 | #ifndef QT_QWS_EBX |
183 | #ifndef QT_NO_SOUND | 183 | #ifndef QT_NO_SOUND |
184 | static Sound snd ( "keysound" ); | 184 | static Sound snd ( "keysound" ); |
185 | 185 | ||
186 | if ( snd. isFinished ( )) | 186 | if ( snd. isFinished ( )) |
187 | snd. play ( ); | 187 | snd. play ( ); |
188 | #endif | 188 | #endif |
189 | #endif | 189 | #endif |
190 | } | 190 | } |
191 | 191 | ||
192 | void ODevice::touchSound ( ) | 192 | void ODevice::touchSound ( ) |
193 | { | 193 | { |
194 | 194 | ||
195 | #ifndef QT_QWS_EBX | 195 | #ifndef QT_QWS_EBX |
196 | #ifndef QT_NO_SOUND | 196 | #ifndef QT_NO_SOUND |
197 | static Sound snd ( "touchsound" ); | 197 | static Sound snd ( "touchsound" ); |
198 | //qDebug("touchSound"); | 198 | //qDebug("touchSound"); |
199 | if ( snd. isFinished ( )) { | 199 | if ( snd. isFinished ( )) { |
200 | snd. play ( ); | 200 | snd. play ( ); |
201 | // qDebug("sound should play"); | 201 | // qDebug("sound should play"); |
202 | } | 202 | } |
203 | #endif | 203 | #endif |
204 | #endif | 204 | #endif |
205 | } | 205 | } |
206 | 206 | ||
207 | uint ODevice::hasLeds ( ) const | 207 | uint ODevice::hasLeds ( ) const |
208 | { | 208 | { |
209 | return 0; | 209 | return 0; |
210 | } | 210 | } |
211 | 211 | ||
212 | OLedState ODevice::led ( uint /*which*/ ) const | 212 | OLedState ODevice::led ( uint /*which*/ ) const |
213 | { | 213 | { |
214 | return OLED_Off; | 214 | return OLED_Off; |
215 | } | 215 | } |
216 | 216 | ||
217 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) | 217 | bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) |
218 | { | 218 | { |
219 | return false; | 219 | return false; |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | 223 | ||
224 | 224 | ||
225 | //#if defined( QT_QWS_IPAQ ) // IPAQ | 225 | //#if defined( QT_QWS_IPAQ ) // IPAQ |
226 | 226 | ||
227 | 227 | ||
228 | void ODeviceIPAQ::init ( ) | 228 | void ODeviceIPAQ::init ( ) |
229 | { | 229 | { |
230 | d-> m_vendorstr = "HP"; | 230 | d-> m_vendorstr = "HP"; |
231 | d-> m_vendor = OVENDOR_HP; | 231 | d-> m_vendor = OVENDOR_HP; |
232 | 232 | ||
233 | QFile f ( "/proc/hal/model" ); | 233 | QFile f ( "/proc/hal/model" ); |
234 | 234 | ||
235 | if ( f. open ( IO_ReadOnly )) { | 235 | if ( f. open ( IO_ReadOnly )) { |
236 | QTextStream ts ( &f ); | 236 | QTextStream ts ( &f ); |
237 | 237 | ||
238 | d-> m_modelstr = "H" + ts. readLine ( ); | 238 | d-> m_modelstr = "H" + ts. readLine ( ); |
239 | 239 | ||
240 | if ( d-> m_modelstr == "H3100" ) | 240 | if ( d-> m_modelstr == "H3100" ) |
241 | d-> m_model = OMODEL_iPAQ_H31xx; | 241 | d-> m_model = OMODEL_iPAQ_H31xx; |
242 | else if ( d-> m_modelstr == "H3600" ) | 242 | else if ( d-> m_modelstr == "H3600" ) |
243 | d-> m_model = OMODEL_iPAQ_H36xx; | 243 | d-> m_model = OMODEL_iPAQ_H36xx; |
244 | else if ( d-> m_modelstr == "H3700" ) | 244 | else if ( d-> m_modelstr == "H3700" ) |
245 | d-> m_model = OMODEL_iPAQ_H37xx; | 245 | d-> m_model = OMODEL_iPAQ_H37xx; |
246 | else if ( d-> m_modelstr == "H3800" ) | 246 | else if ( d-> m_modelstr == "H3800" ) |
247 | d-> m_model = OMODEL_iPAQ_H38xx; | 247 | d-> m_model = OMODEL_iPAQ_H38xx; |
248 | else | 248 | else |
249 | d-> m_model = OMODEL_Unknown; | 249 | d-> m_model = OMODEL_Unknown; |
250 | 250 | ||
251 | f. close ( ); | 251 | f. close ( ); |
252 | } | 252 | } |
253 | 253 | ||
254 | f. setName ( "/etc/familiar-version" ); | 254 | f. setName ( "/etc/familiar-version" ); |
255 | if ( f. open ( IO_ReadOnly )) { | 255 | if ( f. open ( IO_ReadOnly )) { |
256 | d-> m_systemstr = "Familiar"; | 256 | d-> m_systemstr = "Familiar"; |
257 | d-> m_system = OSYSTEM_Familiar; | 257 | d-> m_system = OSYSTEM_Familiar; |
258 | 258 | ||
259 | QTextStream ts ( &f ); | 259 | QTextStream ts ( &f ); |
260 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 260 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
261 | 261 | ||
262 | f. close ( ); | 262 | f. close ( ); |
263 | } | 263 | } |
264 | 264 | ||
265 | d-> m_leds [0] = OLED_Off; | 265 | d-> m_leds [0] = OLED_Off; |
266 | } | 266 | } |
267 | 267 | ||
268 | #include <unistd.h> | 268 | #include <unistd.h> |
269 | #include <fcntl.h> | 269 | #include <fcntl.h> |
270 | #include <sys/ioctl.h> | 270 | #include <sys/ioctl.h> |
271 | #include <signal.h> | 271 | #include <signal.h> |
272 | #include <sys/time.h> | 272 | #include <sys/time.h> |
273 | #include <linux/soundcard.h> | 273 | #include <linux/soundcard.h> |
274 | #include <qapplication.h> | 274 | #include <qapplication.h> |
275 | #include <qpe/config.h> | 275 | #include <qpe/config.h> |
276 | 276 | ||
277 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 277 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
278 | 278 | ||
279 | typedef struct h3600_ts_led { | 279 | typedef struct h3600_ts_led { |
280 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 280 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
281 | unsigned char TotalTime; /* Units of 5 seconds */ | 281 | unsigned char TotalTime; /* Units of 5 seconds */ |
282 | unsigned char OnTime; /* units of 100m/s */ | 282 | unsigned char OnTime; /* units of 100m/s */ |
283 | unsigned char OffTime; /* units of 100m/s */ | 283 | unsigned char OffTime; /* units of 100m/s */ |
284 | } LED_IN; | 284 | } LED_IN; |
285 | 285 | ||
286 | 286 | ||
287 | // #define IOC_H3600_TS_MAGIC 'f' | 287 | // #define IOC_H3600_TS_MAGIC 'f' |
288 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) | 288 | // #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) |
289 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( | 289 | #define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( |
290 | 290 | ||
291 | 291 | ||
292 | //#include <linux/apm_bios.h> | 292 | //#include <linux/apm_bios.h> |
293 | 293 | ||
294 | //#define APM_IOC_SUSPEND _IO('A',2) | 294 | //#define APM_IOC_SUSPEND _IO('A',2) |
295 | 295 | ||
296 | #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) | 296 | #define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) |
297 | 297 | ||
298 | 298 | ||
299 | void ODeviceIPAQ::tstp_sighandler ( int ) | 299 | void ODeviceIPAQ::tstp_sighandler ( int ) |
300 | { | 300 | { |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | bool ODeviceIPAQ::suspend ( ) | 304 | bool ODeviceIPAQ::suspend ( ) |
305 | { | 305 | { |
306 | int fd; | 306 | int fd; |
307 | bool res = false; | 307 | bool res = false; |
308 | 308 | ||
309 | if (( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) { | 309 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
310 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | ||
310 | struct timeval tvs, tvn; | 311 | struct timeval tvs, tvn; |
311 | 312 | ||
312 | ::signal ( SIGTSTP, tstp_sighandler ); | 313 | ::signal ( SIGTSTP, tstp_sighandler ); |
313 | ::gettimeofday ( &tvs, 0 ); | 314 | ::gettimeofday ( &tvs, 0 ); |
314 | 315 | ||
315 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); | 316 | res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); |
316 | ::close ( fd ); | 317 | ::close ( fd ); |
317 | 318 | ||
318 | if ( res ) { | 319 | if ( res ) { |
319 | ::kill ( -::getpid ( ), SIGTSTP ); | 320 | ::kill ( -::getpid ( ), SIGTSTP ); |
320 | 321 | ||
321 | do { | 322 | do { |
322 | ::usleep ( 200 * 1000 ); | 323 | ::usleep ( 200 * 1000 ); |
323 | ::gettimeofday ( &tvn, 0 ); | 324 | ::gettimeofday ( &tvn, 0 ); |
324 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 325 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
325 | 326 | ||
326 | ::kill ( -::getpid ( ), SIGCONT ); | 327 | ::kill ( -::getpid ( ), SIGCONT ); |
327 | } | 328 | } |
328 | 329 | ||
329 | ::signal ( SIGTSTP, SIG_DFL ); | 330 | ::signal ( SIGTSTP, SIG_DFL ); |
330 | } | 331 | } |
332 | |||
331 | return res; | 333 | return res; |
332 | } | 334 | } |
333 | 335 | ||
334 | 336 | ||
335 | void ODeviceIPAQ::alarmSound ( ) | 337 | void ODeviceIPAQ::alarmSound ( ) |
336 | { | 338 | { |
337 | #if defined( QT_QWS_IPAQ ) // IPAQ | 339 | #if defined( QT_QWS_IPAQ ) // IPAQ |
338 | #ifndef QT_NO_SOUND | 340 | #ifndef QT_NO_SOUND |
339 | static Sound snd ( "alarm" ); | 341 | static Sound snd ( "alarm" ); |
340 | int fd; | 342 | int fd; |
341 | int vol; | 343 | int vol; |
342 | bool vol_reset = false; | 344 | bool vol_reset = false; |
343 | 345 | ||
344 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || | 346 | if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || |
345 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { | 347 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { |
346 | 348 | ||
347 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 349 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
348 | Config cfg ( "qpe" ); | 350 | Config cfg ( "qpe" ); |
349 | cfg. setGroup ( "Volume" ); | 351 | cfg. setGroup ( "Volume" ); |
350 | 352 | ||
351 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 353 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
352 | if ( volalarm < 0 ) | 354 | if ( volalarm < 0 ) |
353 | volalarm = 0; | 355 | volalarm = 0; |
354 | else if ( volalarm > 100 ) | 356 | else if ( volalarm > 100 ) |
355 | volalarm = 100; | 357 | volalarm = 100; |
356 | volalarm |= ( volalarm << 8 ); | 358 | volalarm |= ( volalarm << 8 ); |
357 | 359 | ||
358 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 360 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
359 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 361 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
360 | vol_reset = true; | 362 | vol_reset = true; |
361 | } | 363 | } |
362 | } | 364 | } |
363 | } | 365 | } |
364 | 366 | ||
365 | snd. play ( ); | 367 | snd. play ( ); |
366 | while ( !snd. isFinished ( )) | 368 | while ( !snd. isFinished ( )) |
367 | qApp-> processEvents ( ); | 369 | qApp-> processEvents ( ); |
368 | 370 | ||
369 | if ( fd >= 0 ) { | 371 | if ( fd >= 0 ) { |
370 | if ( vol_reset ) | 372 | if ( vol_reset ) |
371 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 373 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
372 | ::close ( fd ); | 374 | ::close ( fd ); |
373 | } | 375 | } |
374 | #endif | 376 | #endif |
375 | #endif | 377 | #endif |
376 | } | 378 | } |
377 | 379 | ||
378 | uint ODeviceIPAQ::hasLeds ( ) const | 380 | uint ODeviceIPAQ::hasLeds ( ) const |
379 | { | 381 | { |
380 | return 1; | 382 | return 1; |
381 | } | 383 | } |
382 | 384 | ||
383 | OLedState ODeviceIPAQ::led ( uint which ) const | 385 | OLedState ODeviceIPAQ::led ( uint which ) const |
384 | { | 386 | { |
385 | if ( which == 0 ) | 387 | if ( which == 0 ) |
386 | return d-> m_leds [0]; | 388 | return d-> m_leds [0]; |
387 | else | 389 | else |
388 | return OLED_Off; | 390 | return OLED_Off; |
389 | } | 391 | } |
390 | 392 | ||
391 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) | 393 | bool ODeviceIPAQ::setLed ( uint which, OLedState st ) |
392 | { | 394 | { |
393 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); | 395 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); |
394 | 396 | ||
395 | if ( which == 0 ) { | 397 | if ( which == 0 ) { |
396 | if ( fd >= 0 ) { | 398 | if ( fd >= 0 ) { |
397 | struct h3600_ts_led leds; | 399 | struct h3600_ts_led leds; |
398 | ::memset ( &leds, 0, sizeof( leds )); | 400 | ::memset ( &leds, 0, sizeof( leds )); |
399 | leds. TotalTime = 0; | 401 | leds. TotalTime = 0; |
400 | leds. OnTime = 0; | 402 | leds. OnTime = 0; |
401 | leds. OffTime = 1; | 403 | leds. OffTime = 1; |
402 | leds. OffOnBlink = 2; | 404 | leds. OffOnBlink = 2; |
403 | 405 | ||
404 | switch ( st ) { | 406 | switch ( st ) { |
405 | case OLED_Off : leds. OffOnBlink = 0; break; | 407 | case OLED_Off : leds. OffOnBlink = 0; break; |
406 | case OLED_On : leds. OffOnBlink = 1; break; | 408 | case OLED_On : leds. OffOnBlink = 1; break; |
407 | case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 409 | case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
408 | case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 410 | case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
409 | } | 411 | } |
410 | 412 | ||
411 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 413 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
412 | d-> m_leds [0] = st; | 414 | d-> m_leds [0] = st; |
413 | return true; | 415 | return true; |
414 | } | 416 | } |
415 | } | 417 | } |
416 | } | 418 | } |
417 | return false; | 419 | return false; |
418 | } | 420 | } |
419 | 421 | ||
420 | 422 | ||
421 | //#endif | 423 | //#endif |
422 | 424 | ||
423 | 425 | ||
424 | 426 | ||
425 | 427 | ||
426 | 428 | ||
427 | //#if defined( QT_QWS_EBX ) // Zaurus | 429 | //#if defined( QT_QWS_EBX ) // Zaurus |
428 | 430 | ||
429 | void ODeviceZaurus::init ( ) | 431 | void ODeviceZaurus::init ( ) |
430 | { | 432 | { |
431 | d-> m_modelstr = "Zaurus SL5000"; | 433 | d-> m_modelstr = "Zaurus SL5000"; |
432 | d-> m_model = OMODEL_Zaurus_SL5000; | 434 | d-> m_model = OMODEL_Zaurus_SL5000; |
433 | d-> m_vendorstr = "Sharp"; | 435 | d-> m_vendorstr = "Sharp"; |
434 | d-> m_vendor = OVENDOR_Sharp; | 436 | d-> m_vendor = OVENDOR_Sharp; |
435 | 437 | ||
436 | QFile f ( "/proc/filesystems" ); | 438 | QFile f ( "/proc/filesystems" ); |
437 | 439 | ||
438 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 440 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
439 | d-> m_systemstr = "OpenZaurus"; | 441 | d-> m_systemstr = "OpenZaurus"; |
440 | d-> m_system = OSYSTEM_OpenZaurus; | 442 | d-> m_system = OSYSTEM_OpenZaurus; |
441 | 443 | ||
442 | f. close ( ); | 444 | f. close ( ); |
443 | } | 445 | } |
444 | else { | 446 | else { |
445 | d-> m_systemstr = "Zaurus"; | 447 | d-> m_systemstr = "Zaurus"; |
446 | d-> m_system = OSYSTEM_Zaurus; | 448 | d-> m_system = OSYSTEM_Zaurus; |
447 | } | 449 | } |
448 | 450 | ||
449 | d-> m_leds [0] = OLED_Off; | 451 | d-> m_leds [0] = OLED_Off; |
450 | } | 452 | } |
451 | 453 | ||
452 | #include <unistd.h> | 454 | #include <unistd.h> |
453 | #include <fcntl.h> | 455 | #include <fcntl.h> |
454 | #include <sys/ioctl.h> | 456 | #include <sys/ioctl.h> |
455 | 457 | ||
456 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 458 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
457 | 459 | ||
458 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 460 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
459 | 461 | ||
460 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 462 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
461 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 463 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
462 | 464 | ||
463 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 465 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
464 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 466 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
465 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 467 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
466 | 468 | ||
467 | /* --- for SHARP_BUZZER device --- */ | 469 | /* --- for SHARP_BUZZER device --- */ |
468 | 470 | ||
469 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 471 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
470 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 472 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
471 | 473 | ||
472 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 474 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
473 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 475 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
474 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 476 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
475 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 477 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
476 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 478 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
477 | 479 | ||
478 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 480 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
479 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 481 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
480 | 482 | ||
481 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 483 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
482 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 484 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
483 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 485 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
484 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 486 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
485 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 487 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
486 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 488 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
487 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 489 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
488 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 490 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
489 | 491 | ||
490 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 492 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
491 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 493 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
492 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 494 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
493 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 495 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
494 | // | 496 | // |
495 | 497 | ||
496 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 498 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
497 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 499 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
498 | 500 | ||
499 | typedef struct sharp_led_status { | 501 | typedef struct sharp_led_status { |
500 | int which; /* select which LED status is wanted. */ | 502 | int which; /* select which LED status is wanted. */ |
501 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 503 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
502 | } sharp_led_status; | 504 | } sharp_led_status; |
503 | 505 | ||
504 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 506 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
505 | 507 | ||
506 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 508 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
507 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 509 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
508 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 510 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
509 | 511 | ||
510 | 512 | ||
511 | 513 | ||
512 | void ODeviceZaurus::buzzer ( int sound ) | 514 | void ODeviceZaurus::buzzer ( int sound ) |
513 | { | 515 | { |
514 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 516 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); |
515 | 517 | ||
516 | if ( fd >= 0 ) | 518 | if ( fd >= 0 ) |
517 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 519 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
518 | } | 520 | } |
519 | 521 | ||
520 | 522 | ||
521 | void ODeviceZaurus::alarmSound ( ) | 523 | void ODeviceZaurus::alarmSound ( ) |
522 | { | 524 | { |
523 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 525 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
524 | } | 526 | } |
525 | 527 | ||
526 | void ODeviceZaurus::touchSound ( ) | 528 | void ODeviceZaurus::touchSound ( ) |
527 | { | 529 | { |
528 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 530 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
529 | } | 531 | } |
530 | 532 | ||
531 | void ODeviceZaurus::keySound ( ) | 533 | void ODeviceZaurus::keySound ( ) |
532 | { | 534 | { |
533 | buzzer ( SHARP_BUZ_KEYSOUND ); | 535 | buzzer ( SHARP_BUZ_KEYSOUND ); |
534 | } | 536 | } |
535 | 537 | ||
536 | 538 | ||
537 | uint ODeviceZaurus::hasLeds ( ) const | 539 | uint ODeviceZaurus::hasLeds ( ) const |
538 | { | 540 | { |
539 | return 1; | 541 | return 1; |
540 | } | 542 | } |
541 | 543 | ||
542 | OLedState ODeviceZaurus::led ( uint which ) const | 544 | OLedState ODeviceZaurus::led ( uint which ) const |
543 | { | 545 | { |
544 | if ( which == 0 ) | 546 | if ( which == 0 ) |
545 | return d-> m_leds [0]; | 547 | return d-> m_leds [0]; |
546 | else | 548 | else |
547 | return OLED_Off; | 549 | return OLED_Off; |
548 | } | 550 | } |
549 | 551 | ||
550 | bool ODeviceZaurus::setLed ( uint which, OLedState st ) | 552 | bool ODeviceZaurus::setLed ( uint which, OLedState st ) |
551 | { | 553 | { |
552 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 554 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
553 | 555 | ||
554 | if ( which == 0 ) { | 556 | if ( which == 0 ) { |
555 | if ( fd >= 0 ) { | 557 | if ( fd >= 0 ) { |
556 | struct sharp_led_status leds; | 558 | struct sharp_led_status leds; |
557 | ::memset ( &leds, 0, sizeof( leds )); | 559 | ::memset ( &leds, 0, sizeof( leds )); |
558 | leds. which = SHARP_LED_MAIL_EXISTS; | 560 | leds. which = SHARP_LED_MAIL_EXISTS; |
559 | 561 | ||
560 | switch ( st ) { | 562 | switch ( st ) { |
561 | case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 563 | case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
562 | case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 564 | case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
563 | case OLED_BlinkSlow: | 565 | case OLED_BlinkSlow: |
564 | case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 566 | case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
565 | } | 567 | } |
566 | 568 | ||
567 | if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { | 569 | if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { |
568 | d-> m_leds [0] = st; | 570 | d-> m_leds [0] = st; |
569 | return true; | 571 | return true; |
570 | } | 572 | } |
571 | } | 573 | } |
572 | } | 574 | } |
573 | return false; | 575 | return false; |
574 | } | 576 | } |
575 | 577 | ||
576 | //#endif | 578 | //#endif |