summaryrefslogtreecommitdiff
authorsandman <sandman>2002-08-06 21:46:30 (UTC)
committer sandman <sandman>2002-08-06 21:46:30 (UTC)
commit2ac1e6ec5a97d3721a3d6513ea68e4e21da1d40b (patch) (unidiff)
treead84f4e405da51a6ca14ab4dd33bfd7c9f2a411e
parent8084d002de5e310491eec7fac0713ef29d0cf30f (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp12
-rw-r--r--libopie/odevice.cpp4
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
@@ -479,278 +479,282 @@ void Desktop::raiseLauncher()
479 e << tempItem; 479 e << tempItem;
480 } 480 }
481} 481}
482 482
483void Desktop::executeOrModify(const QString& appLnkFile) 483void 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
501void Desktop::raiseDatebook() 501void 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
514void Desktop::raiseContacts() 514void 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
527void Desktop::raiseMenu() 527void 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
542void Desktop::raiseEmail() 542void 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
556void Desktop::execAutoStart() { 556void 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
585static bool blanked=FALSE; 585static bool blanked=FALSE;
586 586
587static void blankScreen() 587static 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
598static void darkScreen() 598static 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
605void Desktop::togglePower() 605void 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
643void Desktop::toggleLight() 647void 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
649void Desktop::toggleSymbolInput() 653void Desktop::toggleSymbolInput()
650{ 654{
651 tb->toggleSymbolInput(); 655 tb->toggleSymbolInput();
652} 656}
653 657
654void Desktop::toggleNumLockState() 658void Desktop::toggleNumLockState()
655{ 659{
656 tb->toggleNumLockState(); 660 tb->toggleNumLockState();
657} 661}
658 662
659void Desktop::toggleCapsLockState() 663void Desktop::toggleCapsLockState()
660{ 664{
661 tb->toggleCapsLockState(); 665 tb->toggleCapsLockState();
662} 666}
663 667
664void Desktop::styleChange( QStyle &s ) 668void 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
675void DesktopApplication::shutdown() 679void 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
685void DesktopApplication::shutdown( ShutdownImpl::Type t ) 689void 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
710void DesktopApplication::restart() 714void 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
728void Desktop::startTransferServer() 732void 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
746void Desktop::timerEvent( QTimerEvent *e ) 750void Desktop::timerEvent( QTimerEvent *e )
747{ 751{
748 killTimer( e->timerId() ); 752 killTimer( e->timerId() );
749 startTransferServer(); 753 startTransferServer();
750} 754}
751 755
752void Desktop::terminateServers() 756void Desktop::terminateServers()
753{ 757{
754 delete transferServer; 758 delete transferServer;
755 delete qcopBridge; 759 delete qcopBridge;
756 transferServer = 0; 760 transferServer = 0;
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 057c344..bf64676 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -181,278 +181,280 @@ 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
192void ODevice::touchSound ( ) 192void 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
207uint ODevice::hasLeds ( ) const 207uint ODevice::hasLeds ( ) const
208{ 208{
209 return 0; 209 return 0;
210} 210}
211 211
212OLedState ODevice::led ( uint /*which*/ ) const 212OLedState ODevice::led ( uint /*which*/ ) const
213{ 213{
214 return OLED_Off; 214 return OLED_Off;
215} 215}
216 216
217bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) 217bool 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
228void ODeviceIPAQ::init ( ) 228void 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
279typedef struct h3600_ts_led { 279typedef 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
299void ODeviceIPAQ::tstp_sighandler ( int ) 299void ODeviceIPAQ::tstp_sighandler ( int )
300{ 300{
301} 301}
302 302
303 303
304bool ODeviceIPAQ::suspend ( ) 304bool 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
335void ODeviceIPAQ::alarmSound ( ) 337void 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
378uint ODeviceIPAQ::hasLeds ( ) const 380uint ODeviceIPAQ::hasLeds ( ) const
379{ 381{
380 return 1; 382 return 1;
381} 383}
382 384
383OLedState ODeviceIPAQ::led ( uint which ) const 385OLedState 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
391bool ODeviceIPAQ::setLed ( uint which, OLedState st ) 393bool 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
429void ODeviceZaurus::init ( ) 431void 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