summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_zaurus.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 0d21f26..000d29c 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -9,97 +9,97 @@ _;:, .> :=|. This program is free software; you can
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Private; 57using namespace Opie::Core::Internal;
58 58
59struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
61 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
65 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
69 "devicebuttons/z_home", 69 "devicebuttons/z_home",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
73 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
77 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
78 "mail", "raise()", 78 "mail", "raise()",
79 "mail", "newMail()" }, 79 "mail", "newMail()" },
80}; 80};
81 81
82struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
84 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
85 "datebook", "nextView()", 85 "datebook", "nextView()",
86 "today", "raise()" }, 86 "today", "raise()" },
87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
92 "devicebuttons/z_home", 92 "devicebuttons/z_home",
93 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
94 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
96 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
97 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
98 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
100 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
101 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
102 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
103}; 103};
104 104
105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
@@ -342,105 +342,105 @@ void Zaurus::buzzer ( int sound )
342 case SHARP_BUZ_TOUCHSOUND: 342 case SHARP_BUZ_TOUCHSOUND:
343 soundname = "touchsound"; 343 soundname = "touchsound";
344 break; 344 break;
345 case SHARP_BUZ_KEYSOUND: 345 case SHARP_BUZ_KEYSOUND:
346 soundname = "keysound"; 346 soundname = "keysound";
347 break; 347 break;
348 default: 348 default:
349 soundname = "alarm"; 349 soundname = "alarm";
350 350
351 } 351 }
352 } 352 }
353 353
354 // If a soundname is defined, we expect that this device has 354 // If a soundname is defined, we expect that this device has
355 // sound capabilities.. Otherwise we expect to have the buzzer 355 // sound capabilities.. Otherwise we expect to have the buzzer
356 // device.. 356 // device..
357 if ( !soundname.isEmpty() ){ 357 if ( !soundname.isEmpty() ){
358 int fd; 358 int fd;
359 int vol; 359 int vol;
360 bool vol_reset = false; 360 bool vol_reset = false;
361 361
362 Sound snd ( soundname ); 362 Sound snd ( soundname );
363 363
364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
366 Config cfg ( "qpe" ); 366 Config cfg ( "qpe" );
367 cfg. setGroup ( "Volume" ); 367 cfg. setGroup ( "Volume" );
368 368
369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
370 if ( volalarm < 0 ) 370 if ( volalarm < 0 )
371 volalarm = 0; 371 volalarm = 0;
372 else if ( volalarm > 100 ) 372 else if ( volalarm > 100 )
373 volalarm = 100; 373 volalarm = 100;
374 volalarm |= ( volalarm << 8 ); 374 volalarm |= ( volalarm << 8 );
375 375
376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
377 vol_reset = true; 377 vol_reset = true;
378 } 378 }
379 } 379 }
380 380
381 snd. play(); 381 snd. play();
382 while ( !snd. isFinished()) 382 while ( !snd. isFinished())
383 qApp->processEvents(); 383 qApp->processEvents();
384 384
385 if ( fd >= 0 ) { 385 if ( fd >= 0 ) {
386 if ( vol_reset ) 386 if ( vol_reset )
387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
388 ::close ( fd ); 388 ::close ( fd );
389 } 389 }
390 } else { 390 } else {
391 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 391 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
392 392
393 if ( fd >= 0 ) { 393 if ( fd >= 0 ) {
394 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 394 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
395 ::close ( fd ); 395 ::close ( fd );
396 } 396 }
397 397
398 } 398 }
399#endif 399#endif
400} 400}
401 401
402 402
403void Zaurus::playAlarmSound() 403void Zaurus::playAlarmSound()
404{ 404{
405 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 405 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
406} 406}
407 407
408void Zaurus::playTouchSound() 408void Zaurus::playTouchSound()
409{ 409{
410 buzzer ( SHARP_BUZ_TOUCHSOUND ); 410 buzzer ( SHARP_BUZ_TOUCHSOUND );
411} 411}
412 412
413void Zaurus::playKeySound() 413void Zaurus::playKeySound()
414{ 414{
415 buzzer ( SHARP_BUZ_KEYSOUND ); 415 buzzer ( SHARP_BUZ_KEYSOUND );
416} 416}
417 417
418 418
419QValueList <OLed> Zaurus::ledList() const 419QValueList <OLed> Zaurus::ledList() const
420{ 420{
421 QValueList <OLed> vl; 421 QValueList <OLed> vl;
422 vl << Led_Mail; 422 vl << Led_Mail;
423 return vl; 423 return vl;
424} 424}
425 425
426QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 426QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
427{ 427{
428 QValueList <OLedState> vl; 428 QValueList <OLedState> vl;
429 429
430 if ( l == Led_Mail ) 430 if ( l == Led_Mail )
431 vl << Led_Off << Led_On << Led_BlinkSlow; 431 vl << Led_Off << Led_On << Led_BlinkSlow;
432 return vl; 432 return vl;
433} 433}
434 434
435OLedState Zaurus::ledState ( OLed which ) const 435OLedState Zaurus::ledState ( OLed which ) const
436{ 436{
437 if ( which == Led_Mail ) 437 if ( which == Led_Mail )
438 return m_leds [0]; 438 return m_leds [0];
439 else 439 else
440 return Led_Off; 440 return Led_Off;
441} 441}
442 442
443bool Zaurus::setLedState ( OLed which, OLedState st ) 443bool Zaurus::setLedState ( OLed which, OLedState st )
444{ 444{
445 if (!m_embedix) // Currently not supported on non_embedix kernels 445 if (!m_embedix) // Currently not supported on non_embedix kernels
446 return false; 446 return false;
@@ -561,99 +561,99 @@ bool Zaurus::suspend()
561{ 561{
562 qDebug("ODevice::suspend"); 562 qDebug("ODevice::suspend");
563 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 563 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
564 return false; 564 return false;
565 565
566 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 566 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
567 return false; 567 return false;
568 568
569 bool res = false; 569 bool res = false;
570 ODevice::sendSuspendmsg(); 570 ODevice::sendSuspendmsg();
571 571
572 struct timeval tvs, tvn; 572 struct timeval tvs, tvn;
573 ::gettimeofday ( &tvs, 0 ); 573 ::gettimeofday ( &tvs, 0 );
574 574
575 ::sync(); // flush fs caches 575 ::sync(); // flush fs caches
576 res = ( ::system ( "apm --suspend" ) == 0 ); 576 res = ( ::system ( "apm --suspend" ) == 0 );
577 577
578 // This is needed because the iPAQ apm implementation is asynchronous and we 578 // This is needed because the iPAQ apm implementation is asynchronous and we
579 // can not be sure when exactly the device is really suspended 579 // can not be sure when exactly the device is really suspended
580 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 580 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
581 581
582 if ( res ) { 582 if ( res ) {
583 do { // Yes, wait 15 seconds. This APM bug sucks big time. 583 do { // Yes, wait 15 seconds. This APM bug sucks big time.
584 ::usleep ( 200 * 1000 ); 584 ::usleep ( 200 * 1000 );
585 ::gettimeofday ( &tvn, 0 ); 585 ::gettimeofday ( &tvn, 0 );
586 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 586 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
587 } 587 }
588 588
589 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 589 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
590 return res; 590 return res;
591} 591}
592 592
593 593
594Transformation Zaurus::rotation() const 594Transformation Zaurus::rotation() const
595{ 595{
596 Transformation rot; 596 Transformation rot;
597 int handle = 0; 597 int handle = 0;
598 int retval = 0; 598 int retval = 0;
599 599
600 switch ( d->m_model ) { 600 switch ( d->m_model ) {
601 case Model_Zaurus_SLC7x0: 601 case Model_Zaurus_SLC7x0:
602 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 602 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
603 if (handle == -1) { 603 if (handle == -1) {
604 return Rot270; 604 return Rot270;
605 } else { 605 } else {
606 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 606 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
607 ::close (handle); 607 ::close (handle);
608 608
609 if (retval == 2 ) 609 if (retval == 2 )
610 rot = Rot0; 610 rot = Rot0;
611 else 611 else
612 rot = Rot270; 612 rot = Rot270;
613 } 613 }
614 break; 614 break;
615 case Model_Zaurus_SLA300: 615 case Model_Zaurus_SLA300:
616 case Model_Zaurus_SLB600: 616 case Model_Zaurus_SLB600:
617 case Model_Zaurus_SL5500: 617 case Model_Zaurus_SL5500:
618 case Model_Zaurus_SL5000: 618 case Model_Zaurus_SL5000:
619 default: 619 default:
620 rot = d->m_rotation; 620 rot = d->m_rotation;
621 break; 621 break;
622 } 622 }
623 623
624 return rot; 624 return rot;
625} 625}
626ODirection Zaurus::direction() const 626ODirection Zaurus::direction() const
627{ 627{
628 ODirection dir; 628 ODirection dir;
629 int handle = 0; 629 int handle = 0;
630 int retval = 0; 630 int retval = 0;
631 switch ( d->m_model ) { 631 switch ( d->m_model ) {
632 case Model_Zaurus_SLC7x0: 632 case Model_Zaurus_SLC7x0:
633 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 633 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
634 if (handle == -1) { 634 if (handle == -1) {
635 dir = CW; 635 dir = CW;
636 } else { 636 } else {
637 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 637 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
638 ::close (handle); 638 ::close (handle);
639 if (retval == 2 ) 639 if (retval == 2 )
640 dir = CCW; 640 dir = CCW;
641 else 641 else
642 dir = CW; 642 dir = CW;
643 } 643 }
644 break; 644 break;
645 case Model_Zaurus_SLA300: 645 case Model_Zaurus_SLA300:
646 case Model_Zaurus_SLB600: 646 case Model_Zaurus_SLB600:
647 case Model_Zaurus_SL5500: 647 case Model_Zaurus_SL5500:
648 case Model_Zaurus_SL5000: 648 case Model_Zaurus_SL5000:
649 default: 649 default:
650 dir = d->m_direction; 650 dir = d->m_direction;
651 break; 651 break;
652 } 652 }
653 return dir; 653 return dir;
654 654
655} 655}
656 656
657int Zaurus::displayBrightnessResolution() const 657int Zaurus::displayBrightnessResolution() const
658{ 658{
659 if (m_embedix) 659 if (m_embedix)