Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 0068d88..cd3a84c 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,95 +1,96 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
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_ipaq.h" | 30 | #include "odevice_ipaq.h" |
31 | #include "odevice_jornada.h" | 31 | #include "odevice_jornada.h" |
32 | #include "odevice_ramses.h" | 32 | #include "odevice_ramses.h" |
33 | #include "odevice_simpad.h" | 33 | #include "odevice_simpad.h" |
34 | #include "odevice_yopy.h" | 34 | #include "odevice_yopy.h" |
35 | #include "odevice_zaurus.h" | 35 | #include "odevice_zaurus.h" |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
42 | 42 | ||
43 | /* OPIE */ | 43 | /* OPIE */ |
44 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
45 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
46 | #include <qpe/sound.h> | 46 | #include <qpe/sound.h> |
47 | #include <qpe/qcopenvelope_qws.h> | 47 | #include <qpe/qcopenvelope_qws.h> |
48 | #include <opie2/okeyfilter.h> | ||
48 | 49 | ||
49 | /* STD */ | 50 | /* STD */ |
50 | #include <fcntl.h> | 51 | #include <fcntl.h> |
51 | #include <math.h> | 52 | #include <math.h> |
52 | #include <stdlib.h> | 53 | #include <stdlib.h> |
53 | #include <signal.h> | 54 | #include <signal.h> |
54 | #include <sys/ioctl.h> | 55 | #include <sys/ioctl.h> |
55 | #include <sys/time.h> | 56 | #include <sys/time.h> |
56 | #include <unistd.h> | 57 | #include <unistd.h> |
57 | #ifndef QT_NO_SOUND | 58 | #ifndef QT_NO_SOUND |
58 | #include <linux/soundcard.h> | 59 | #include <linux/soundcard.h> |
59 | #endif | 60 | #endif |
60 | 61 | ||
61 | namespace Opie { | 62 | namespace Opie { |
62 | namespace Core { | 63 | namespace Core { |
63 | 64 | ||
64 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 65 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
65 | 66 | ||
66 | 67 | ||
67 | /* STATIC and common implementation */ | 68 | /* STATIC and common implementation */ |
68 | /* EXPORT */ ODistribution distributions[] = { | 69 | /* EXPORT */ ODistribution distributions[] = { |
69 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 70 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
70 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | 71 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, |
71 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 72 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
72 | { System_Unknown, "Linux", "/etc/issue" }, | 73 | { System_Unknown, "Linux", "/etc/issue" }, |
73 | }; | 74 | }; |
74 | 75 | ||
75 | 76 | ||
76 | /* EXPORT */ bool isQWS(){ | 77 | /* EXPORT */ bool isQWS(){ |
77 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 78 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
78 | } | 79 | } |
79 | 80 | ||
80 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 81 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
81 | if ( str && !::strchr ( str, '/' )) | 82 | if ( str && !::strchr ( str, '/' )) |
82 | return QCString ( "QPE/Application/" ) + str; | 83 | return QCString ( "QPE/Application/" ) + str; |
83 | else | 84 | else |
84 | return str; | 85 | return str; |
85 | } | 86 | } |
86 | 87 | ||
87 | 88 | ||
88 | 89 | ||
89 | /* Now the default implementation of ODevice */ | 90 | /* Now the default implementation of ODevice */ |
90 | 91 | ||
91 | struct default_button default_buttons [] = { | 92 | struct default_button default_buttons [] = { |
92 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 93 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
93 | "devicebuttons/z_calendar", | 94 | "devicebuttons/z_calendar", |
94 | "datebook", "nextView()", | 95 | "datebook", "nextView()", |
95 | "today", "raise()" }, | 96 | "today", "raise()" }, |
@@ -631,87 +632,97 @@ void ODevice::reloadButtonMapping() | |||
631 | initButtons(); | 632 | initButtons(); |
632 | 633 | ||
633 | Config cfg ( "ButtonSettings" ); | 634 | Config cfg ( "ButtonSettings" ); |
634 | 635 | ||
635 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 636 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
636 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 637 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
637 | QString group = "Button" + QString::number ( i ); | 638 | QString group = "Button" + QString::number ( i ); |
638 | 639 | ||
639 | QCString pch, hch; | 640 | QCString pch, hch; |
640 | QCString pm, hm; | 641 | QCString pm, hm; |
641 | QByteArray pdata, hdata; | 642 | QByteArray pdata, hdata; |
642 | 643 | ||
643 | if ( cfg. hasGroup ( group )) { | 644 | if ( cfg. hasGroup ( group )) { |
644 | cfg. setGroup ( group ); | 645 | cfg. setGroup ( group ); |
645 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); | 646 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); |
646 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); | 647 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); |
647 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 648 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
648 | 649 | ||
649 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); | 650 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); |
650 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); | 651 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); |
651 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 652 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
652 | } | 653 | } |
653 | 654 | ||
654 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 655 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
655 | 656 | ||
656 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 657 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
657 | } | 658 | } |
658 | } | 659 | } |
659 | 660 | ||
660 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 661 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
661 | { | 662 | { |
662 | initButtons(); | 663 | initButtons(); |
663 | 664 | ||
664 | QString mb_chan; | 665 | QString mb_chan; |
665 | 666 | ||
666 | if ( button >= (int) d->m_buttons->count()) | 667 | if ( button >= (int) d->m_buttons->count()) |
667 | return; | 668 | return; |
668 | 669 | ||
669 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 670 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
670 | b. setPressedAction ( action ); | 671 | b. setPressedAction ( action ); |
671 | 672 | ||
672 | mb_chan=b. pressedAction(). channel(); | 673 | mb_chan=b. pressedAction(). channel(); |
673 | 674 | ||
674 | Config buttonFile ( "ButtonSettings" ); | 675 | Config buttonFile ( "ButtonSettings" ); |
675 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 676 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
676 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 677 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
677 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 678 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
678 | 679 | ||
679 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 680 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
680 | 681 | ||
681 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 682 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
682 | } | 683 | } |
683 | 684 | ||
684 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 685 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
685 | { | 686 | { |
686 | initButtons(); | 687 | initButtons(); |
687 | 688 | ||
688 | if ( button >= (int) d->m_buttons->count()) | 689 | if ( button >= (int) d->m_buttons->count()) |
689 | return; | 690 | return; |
690 | 691 | ||
691 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 692 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
692 | b. setHeldAction ( action ); | 693 | b. setHeldAction ( action ); |
693 | 694 | ||
694 | Config buttonFile ( "ButtonSettings" ); | 695 | Config buttonFile ( "ButtonSettings" ); |
695 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 696 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
696 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 697 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
697 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 698 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
698 | 699 | ||
699 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 700 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
700 | 701 | ||
701 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 702 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
702 | } | 703 | } |
703 | void ODevice::virtual_hook(int, void* ){ | 704 | void ODevice::virtual_hook(int, void* ){ |
704 | 705 | ||
705 | } | 706 | } |
706 | 707 | ||
707 | void ODevice::sendSuspendmsg() | 708 | void ODevice::sendSuspendmsg() |
708 | { | 709 | { |
709 | if ( isQWS() ) | 710 | if ( isQWS() ) |
710 | return; | 711 | return; |
711 | 712 | ||
712 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 713 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
713 | } | 714 | } |
714 | 715 | ||
716 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | ||
717 | { | ||
718 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); | ||
719 | } | ||
720 | |||
721 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | ||
722 | { | ||
723 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); | ||
724 | } | ||
725 | |||
715 | 726 | ||
716 | } | 727 | } |
717 | } | 728 | } |