-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 34 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 21 |
2 files changed, 35 insertions, 20 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 5b73e59..0068d88 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,159 +1,185 @@ | |||
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 | 48 | ||
49 | /* STD */ | 49 | /* STD */ |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> |
51 | #include <math.h> | 51 | #include <math.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | #include <signal.h> | 53 | #include <signal.h> |
54 | #include <sys/ioctl.h> | 54 | #include <sys/ioctl.h> |
55 | #include <sys/time.h> | 55 | #include <sys/time.h> |
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #ifndef QT_NO_SOUND | 57 | #ifndef QT_NO_SOUND |
58 | #include <linux/soundcard.h> | 58 | #include <linux/soundcard.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 61 | namespace Opie { |
62 | namespace Core { | ||
62 | 63 | ||
63 | using namespace Opie::Core; | 64 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
65 | |||
66 | |||
67 | /* STATIC and common implementation */ | ||
68 | /* EXPORT */ ODistribution distributions[] = { | ||
69 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | ||
70 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | ||
71 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | ||
72 | { System_Unknown, "Linux", "/etc/issue" }, | ||
73 | }; | ||
74 | |||
75 | |||
76 | /* EXPORT */ bool isQWS(){ | ||
77 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | ||
78 | } | ||
79 | |||
80 | /* EXPORT */ QCString makeChannel ( const char *str ){ | ||
81 | if ( str && !::strchr ( str, '/' )) | ||
82 | return QCString ( "QPE/Application/" ) + str; | ||
83 | else | ||
84 | return str; | ||
85 | } | ||
86 | |||
87 | |||
88 | |||
89 | /* Now the default implementation of ODevice */ | ||
64 | 90 | ||
65 | struct default_button default_buttons [] = { | 91 | struct default_button default_buttons [] = { |
66 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 92 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
67 | "devicebuttons/z_calendar", | 93 | "devicebuttons/z_calendar", |
68 | "datebook", "nextView()", | 94 | "datebook", "nextView()", |
69 | "today", "raise()" }, | 95 | "today", "raise()" }, |
70 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 96 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
71 | "devicebuttons/z_contact", | 97 | "devicebuttons/z_contact", |
72 | "addressbook", "raise()", | 98 | "addressbook", "raise()", |
73 | "addressbook", "beamBusinessCard()" }, | 99 | "addressbook", "beamBusinessCard()" }, |
74 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 100 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
75 | "devicebuttons/z_home", | 101 | "devicebuttons/z_home", |
76 | "QPE/Launcher", "home()", | 102 | "QPE/Launcher", "home()", |
77 | "buttonsettings", "raise()" }, | 103 | "buttonsettings", "raise()" }, |
78 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 104 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
79 | "devicebuttons/z_menu", | 105 | "devicebuttons/z_menu", |
80 | "QPE/TaskBar", "toggleMenu()", | 106 | "QPE/TaskBar", "toggleMenu()", |
81 | "QPE/TaskBar", "toggleStartMenu()" }, | 107 | "QPE/TaskBar", "toggleStartMenu()" }, |
82 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 108 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
83 | "devicebuttons/z_mail", | 109 | "devicebuttons/z_mail", |
84 | "opiemail", "raise()", | 110 | "opiemail", "raise()", |
85 | "opiemail", "newMail()" }, | 111 | "opiemail", "newMail()" }, |
86 | }; | 112 | }; |
87 | 113 | ||
88 | ODevice *ODevice::inst() | 114 | ODevice *ODevice::inst() |
89 | { | 115 | { |
90 | static ODevice *dev = 0; | 116 | static ODevice *dev = 0; |
91 | 117 | ||
92 | // rewrite this to only use /proc/cpuinfo or so | 118 | // rewrite this to only use /proc/cpuinfo or so |
93 | QString cpu_info; | 119 | QString cpu_info; |
94 | 120 | ||
95 | if ( !dev ) | 121 | if ( !dev ) |
96 | { | 122 | { |
97 | QFile f( PATH_PROC_CPUINFO ); | 123 | QFile f( PATH_PROC_CPUINFO ); |
98 | if ( f.open( IO_ReadOnly ) ) | 124 | if ( f.open( IO_ReadOnly ) ) |
99 | { | 125 | { |
100 | QTextStream s( &f ); | 126 | QTextStream s( &f ); |
101 | while ( !s.atEnd() ) | 127 | while ( !s.atEnd() ) |
102 | { | 128 | { |
103 | QString line; | 129 | QString line; |
104 | line = s.readLine(); | 130 | line = s.readLine(); |
105 | if ( line.startsWith( "Hardware" ) ) | 131 | if ( line.startsWith( "Hardware" ) ) |
106 | { | 132 | { |
107 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 133 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
108 | cpu_info = line; | 134 | cpu_info = line; |
109 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 135 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
110 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 136 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
111 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 137 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
112 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 138 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
113 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 139 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
114 | else qWarning( "ODevice() - unknown hardware - using default." ); | 140 | else qWarning( "ODevice() - unknown hardware - using default." ); |
115 | break; | 141 | break; |
116 | } | 142 | } |
117 | } | 143 | } |
118 | } | 144 | } |
119 | else | 145 | else |
120 | { | 146 | { |
121 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 147 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
122 | } | 148 | } |
123 | if ( !dev ) dev = new ODevice(); | 149 | if ( !dev ) dev = new ODevice(); |
124 | dev->init(cpu_info); | 150 | dev->init(cpu_info); |
125 | } | 151 | } |
126 | return dev; | 152 | return dev; |
127 | } | 153 | } |
128 | 154 | ||
129 | ODevice::ODevice() | 155 | ODevice::ODevice() |
130 | { | 156 | { |
131 | d = new ODeviceData; | 157 | d = new ODeviceData; |
132 | 158 | ||
133 | d->m_modelstr = "Unknown"; | 159 | d->m_modelstr = "Unknown"; |
134 | d->m_model = Model_Unknown; | 160 | d->m_model = Model_Unknown; |
135 | d->m_vendorstr = "Unknown"; | 161 | d->m_vendorstr = "Unknown"; |
136 | d->m_vendor = Vendor_Unknown; | 162 | d->m_vendor = Vendor_Unknown; |
137 | d->m_systemstr = "Unknown"; | 163 | d->m_systemstr = "Unknown"; |
138 | d->m_system = System_Unknown; | 164 | d->m_system = System_Unknown; |
139 | d->m_sysverstr = "0.0"; | 165 | d->m_sysverstr = "0.0"; |
140 | d->m_rotation = Rot0; | 166 | d->m_rotation = Rot0; |
141 | d->m_direction = CW; | 167 | d->m_direction = CW; |
142 | 168 | ||
143 | d->m_holdtime = 1000; // 1000ms | 169 | d->m_holdtime = 1000; // 1000ms |
144 | d->m_buttons = 0; | 170 | d->m_buttons = 0; |
145 | d->m_cpu_frequencies = new QStrList; | 171 | d->m_cpu_frequencies = new QStrList; |
146 | 172 | ||
147 | // New distribution detection code first checks for legacy distributions, | 173 | // New distribution detection code first checks for legacy distributions, |
148 | // identified by /etc/familiar-version or /etc/oz_version. | 174 | // identified by /etc/familiar-version or /etc/oz_version. |
149 | // Then check for OpenEmbedded and lastly, read /etc/issue | 175 | // Then check for OpenEmbedded and lastly, read /etc/issue |
150 | 176 | ||
151 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | 177 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) |
152 | { | 178 | { |
153 | if ( QFile::exists( distributions[i].sysvfile ) ) | 179 | if ( QFile::exists( distributions[i].sysvfile ) ) |
154 | { | 180 | { |
155 | d->m_systemstr = distributions[i].sysstr; | 181 | d->m_systemstr = distributions[i].sysstr; |
156 | d->m_system = distributions[i].system; | 182 | d->m_system = distributions[i].system; |
157 | d->m_sysverstr = "<Unknown>"; | 183 | d->m_sysverstr = "<Unknown>"; |
158 | QFile f( distributions[i].sysvfile ); | 184 | QFile f( distributions[i].sysvfile ); |
159 | if ( f.open( IO_ReadOnly ) ) | 185 | if ( f.open( IO_ReadOnly ) ) |
@@ -592,96 +618,100 @@ uint ODevice::buttonHoldTime() const | |||
592 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 618 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
593 | { | 619 | { |
594 | initButtons(); | 620 | initButtons(); |
595 | 621 | ||
596 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { | 622 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { |
597 | if ( (*it). keycode() == code ) | 623 | if ( (*it). keycode() == code ) |
598 | return &(*it); | 624 | return &(*it); |
599 | } | 625 | } |
600 | return 0; | 626 | return 0; |
601 | } | 627 | } |
602 | 628 | ||
603 | void ODevice::reloadButtonMapping() | 629 | void ODevice::reloadButtonMapping() |
604 | { | 630 | { |
605 | initButtons(); | 631 | initButtons(); |
606 | 632 | ||
607 | Config cfg ( "ButtonSettings" ); | 633 | Config cfg ( "ButtonSettings" ); |
608 | 634 | ||
609 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 635 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
610 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 636 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
611 | QString group = "Button" + QString::number ( i ); | 637 | QString group = "Button" + QString::number ( i ); |
612 | 638 | ||
613 | QCString pch, hch; | 639 | QCString pch, hch; |
614 | QCString pm, hm; | 640 | QCString pm, hm; |
615 | QByteArray pdata, hdata; | 641 | QByteArray pdata, hdata; |
616 | 642 | ||
617 | if ( cfg. hasGroup ( group )) { | 643 | if ( cfg. hasGroup ( group )) { |
618 | cfg. setGroup ( group ); | 644 | cfg. setGroup ( group ); |
619 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); | 645 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); |
620 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); | 646 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); |
621 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 647 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
622 | 648 | ||
623 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); | 649 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); |
624 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); | 650 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); |
625 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 651 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
626 | } | 652 | } |
627 | 653 | ||
628 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 654 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
629 | 655 | ||
630 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 656 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
631 | } | 657 | } |
632 | } | 658 | } |
633 | 659 | ||
634 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 660 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
635 | { | 661 | { |
636 | initButtons(); | 662 | initButtons(); |
637 | 663 | ||
638 | QString mb_chan; | 664 | QString mb_chan; |
639 | 665 | ||
640 | if ( button >= (int) d->m_buttons->count()) | 666 | if ( button >= (int) d->m_buttons->count()) |
641 | return; | 667 | return; |
642 | 668 | ||
643 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 669 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
644 | b. setPressedAction ( action ); | 670 | b. setPressedAction ( action ); |
645 | 671 | ||
646 | mb_chan=b. pressedAction(). channel(); | 672 | mb_chan=b. pressedAction(). channel(); |
647 | 673 | ||
648 | Config buttonFile ( "ButtonSettings" ); | 674 | Config buttonFile ( "ButtonSettings" ); |
649 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 675 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
650 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 676 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
651 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 677 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
652 | 678 | ||
653 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 679 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
654 | 680 | ||
655 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 681 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
656 | } | 682 | } |
657 | 683 | ||
658 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 684 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
659 | { | 685 | { |
660 | initButtons(); | 686 | initButtons(); |
661 | 687 | ||
662 | if ( button >= (int) d->m_buttons->count()) | 688 | if ( button >= (int) d->m_buttons->count()) |
663 | return; | 689 | return; |
664 | 690 | ||
665 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 691 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
666 | b. setHeldAction ( action ); | 692 | b. setHeldAction ( action ); |
667 | 693 | ||
668 | Config buttonFile ( "ButtonSettings" ); | 694 | Config buttonFile ( "ButtonSettings" ); |
669 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 695 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
670 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 696 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
671 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 697 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
672 | 698 | ||
673 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 699 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
674 | 700 | ||
675 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 701 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
676 | } | 702 | } |
677 | void ODevice::virtual_hook(int, void* ){ | 703 | void ODevice::virtual_hook(int, void* ){ |
678 | 704 | ||
679 | } | 705 | } |
680 | 706 | ||
681 | void ODevice::sendSuspendmsg() | 707 | void ODevice::sendSuspendmsg() |
682 | { | 708 | { |
683 | if ( isQWS() ) | 709 | if ( isQWS() ) |
684 | return; | 710 | return; |
685 | 711 | ||
686 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 712 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
687 | } | 713 | } |
714 | |||
715 | |||
716 | } | ||
717 | } | ||
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 474d792..0465d7e 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -41,200 +41,194 @@ | |||
41 | #include <qstrlist.h> | 41 | #include <qstrlist.h> |
42 | 42 | ||
43 | namespace Opie{ | 43 | namespace Opie{ |
44 | namespace Core{ | 44 | namespace Core{ |
45 | 45 | ||
46 | class ODeviceData; | 46 | class ODeviceData; |
47 | /** | 47 | /** |
48 | * The available devices | 48 | * The available devices |
49 | */ | 49 | */ |
50 | enum OModel { | 50 | enum OModel { |
51 | Model_Unknown, // = 0 | 51 | Model_Unknown, // = 0 |
52 | 52 | ||
53 | Model_Series_Mask = 0xff000000, | 53 | Model_Series_Mask = 0xff000000, |
54 | 54 | ||
55 | Model_iPAQ = ( 1 << 24 ), | 55 | Model_iPAQ = ( 1 << 24 ), |
56 | 56 | ||
57 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 57 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
58 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 58 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
59 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 59 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
60 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 60 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
61 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 61 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
62 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 62 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
63 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), | 63 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), |
64 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), | 64 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), |
65 | 65 | ||
66 | Model_Jornada = ( 6 << 24 ), | 66 | Model_Jornada = ( 6 << 24 ), |
67 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), | 67 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), |
68 | 68 | ||
69 | Model_Zaurus = ( 2 << 24 ), | 69 | Model_Zaurus = ( 2 << 24 ), |
70 | 70 | ||
71 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 71 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
72 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 72 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
73 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 73 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
74 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 74 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
75 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), | 75 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), |
76 | 76 | ||
77 | Model_SIMpad = ( 3 << 24 ), | 77 | Model_SIMpad = ( 3 << 24 ), |
78 | 78 | ||
79 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | 79 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), |
80 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | 80 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), |
81 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | 81 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), |
82 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | 82 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), |
83 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | 83 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), |
84 | 84 | ||
85 | Model_Ramses = ( 4 << 24 ), | 85 | Model_Ramses = ( 4 << 24 ), |
86 | 86 | ||
87 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | 87 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), |
88 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | 88 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), |
89 | 89 | ||
90 | Model_Yopy = ( 5 << 24 ), | 90 | Model_Yopy = ( 5 << 24 ), |
91 | 91 | ||
92 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), | 92 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), |
93 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), | 93 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), |
94 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), | 94 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), |
95 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), | 95 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), |
96 | 96 | ||
97 | Model_Beagle = ( 6 << 24 ), | 97 | Model_Beagle = ( 6 << 24 ), |
98 | 98 | ||
99 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), | 99 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), |
100 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), | 100 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), |
101 | 101 | ||
102 | }; | 102 | }; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * The vendor of the device | 105 | * The vendor of the device |
106 | */ | 106 | */ |
107 | enum OVendor { | 107 | enum OVendor { |
108 | Vendor_Unknown, | 108 | Vendor_Unknown, |
109 | 109 | ||
110 | Vendor_HP, | 110 | Vendor_HP, |
111 | Vendor_Sharp, | 111 | Vendor_Sharp, |
112 | Vendor_SIEMENS, | 112 | Vendor_SIEMENS, |
113 | Vendor_MundN, | 113 | Vendor_MundN, |
114 | Vendor_GMate, | 114 | Vendor_GMate, |
115 | Vendor_MasterIA, | 115 | Vendor_MasterIA, |
116 | }; | 116 | }; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * The System used | 119 | * The System used |
120 | */ | 120 | */ |
121 | enum OSystem { | 121 | enum OSystem { |
122 | System_Unknown, | 122 | System_Unknown, |
123 | 123 | ||
124 | System_Familiar, | 124 | System_Familiar, |
125 | System_Zaurus, | 125 | System_Zaurus, |
126 | System_OpenZaurus, | 126 | System_OpenZaurus, |
127 | System_Linupy, | 127 | System_Linupy, |
128 | System_OpenEmbedded, | 128 | System_OpenEmbedded, |
129 | }; | 129 | }; |
130 | 130 | ||
131 | typedef struct { | 131 | typedef struct { |
132 | OSystem system; | 132 | OSystem system; |
133 | char* sysstr; | 133 | char* sysstr; |
134 | char* sysvfile; | 134 | char* sysvfile; |
135 | } ODistribution; | 135 | } ODistribution; |
136 | 136 | ||
137 | static ODistribution distributions[] = | 137 | extern ODistribution distributions[]; |
138 | { | ||
139 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | ||
140 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | ||
141 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | ||
142 | { System_Unknown, "Linux", "/etc/issue" }, | ||
143 | 138 | ||
144 | }; | ||
145 | 139 | ||
146 | enum OLedState { | 140 | enum OLedState { |
147 | Led_Off, | 141 | Led_Off, |
148 | Led_On, | 142 | Led_On, |
149 | Led_BlinkSlow, | 143 | Led_BlinkSlow, |
150 | Led_BlinkFast | 144 | Led_BlinkFast |
151 | }; | 145 | }; |
152 | 146 | ||
153 | enum OLed { | 147 | enum OLed { |
154 | Led_Mail, | 148 | Led_Mail, |
155 | Led_Power, | 149 | Led_Power, |
156 | Led_BlueTooth | 150 | Led_BlueTooth |
157 | }; | 151 | }; |
158 | 152 | ||
159 | enum OHardKey { | 153 | enum OHardKey { |
160 | HardKey_Datebook = Qt::Key_F9, | 154 | HardKey_Datebook = Qt::Key_F9, |
161 | HardKey_Contacts = Qt::Key_F10, | 155 | HardKey_Contacts = Qt::Key_F10, |
162 | HardKey_Menu = Qt::Key_F11, | 156 | HardKey_Menu = Qt::Key_F11, |
163 | HardKey_Home = Qt::Key_F12, | 157 | HardKey_Home = Qt::Key_F12, |
164 | HardKey_Mail = Qt::Key_F13, | 158 | HardKey_Mail = Qt::Key_F13, |
165 | HardKey_Record = Qt::Key_F24, | 159 | HardKey_Record = Qt::Key_F24, |
166 | HardKey_Suspend = Qt::Key_F34, | 160 | HardKey_Suspend = Qt::Key_F34, |
167 | HardKey_Backlight = Qt::Key_F35, | 161 | HardKey_Backlight = Qt::Key_F35, |
168 | HardKey_Action = Qt::Key_F10, | 162 | HardKey_Action = Qt::Key_F10, |
169 | HardKey_OK = Qt::Key_F11, | 163 | HardKey_OK = Qt::Key_F11, |
170 | HardKey_End = Qt::Key_F12, | 164 | HardKey_End = Qt::Key_F12, |
171 | }; | 165 | }; |
172 | 166 | ||
173 | enum ODirection { | 167 | enum ODirection { |
174 | CW = 0, | 168 | CW = 0, |
175 | CCW = 1, | 169 | CCW = 1, |
176 | Flip = 2, | 170 | Flip = 2, |
177 | }; | 171 | }; |
178 | 172 | ||
179 | enum OHingeStatus { | 173 | enum OHingeStatus { |
180 | CASE_CLOSED = 3, | 174 | CASE_CLOSED = 3, |
181 | CASE_PORTRAIT = 2, | 175 | CASE_PORTRAIT = 2, |
182 | CASE_LANDSCAPE = 0, | 176 | CASE_LANDSCAPE = 0, |
183 | CASE_UNKNOWN = 1, | 177 | CASE_UNKNOWN = 1, |
184 | }; | 178 | }; |
185 | 179 | ||
186 | /* default button for qvfb or such | 180 | /* default button for qvfb or such |
187 | * see odevice.cpp for details. | 181 | * see odevice.cpp for details. |
188 | * hint: manage a user defined button for qvfb? | 182 | * hint: manage a user defined button for qvfb? |
189 | * alwin | 183 | * alwin |
190 | */ | 184 | */ |
191 | struct default_button { | 185 | struct default_button { |
192 | Qt::Key code; | 186 | Qt::Key code; |
193 | char *utext; | 187 | char *utext; |
194 | char *pix; | 188 | char *pix; |
195 | char *fpressedservice; | 189 | char *fpressedservice; |
196 | char *fpressedaction; | 190 | char *fpressedaction; |
197 | char *fheldservice; | 191 | char *fheldservice; |
198 | char *fheldaction; | 192 | char *fheldaction; |
199 | }; | 193 | }; |
200 | 194 | ||
201 | /** | 195 | /** |
202 | * A singleton which gives informations about device specefic option | 196 | * A singleton which gives informations about device specefic option |
203 | * like the Hardware used, LEDs, the Base Distribution and | 197 | * like the Hardware used, LEDs, the Base Distribution and |
204 | * hardware key mappings. | 198 | * hardware key mappings. |
205 | * | 199 | * |
206 | * @short A small class for device specefic options | 200 | * @short A small class for device specefic options |
207 | * @see QObject | 201 | * @see QObject |
208 | * @author Robert Griebl | 202 | * @author Robert Griebl |
209 | * @version 1.0 | 203 | * @version 1.0 |
210 | */ | 204 | */ |
211 | class ODevice : public QObject | 205 | class ODevice : public QObject |
212 | { | 206 | { |
213 | Q_OBJECT | 207 | Q_OBJECT |
214 | 208 | ||
215 | private: | 209 | private: |
216 | /* disable copy */ | 210 | /* disable copy */ |
217 | ODevice ( const ODevice & ); | 211 | ODevice ( const ODevice & ); |
218 | 212 | ||
219 | protected: | 213 | protected: |
220 | ODevice(); | 214 | ODevice(); |
221 | virtual void init(const QString&); | 215 | virtual void init(const QString&); |
222 | virtual void initButtons(); | 216 | virtual void initButtons(); |
223 | static void sendSuspendmsg(); | 217 | static void sendSuspendmsg(); |
224 | 218 | ||
225 | ODeviceData *d; | 219 | ODeviceData *d; |
226 | 220 | ||
227 | public: | 221 | public: |
228 | // sandman do we want to allow destructions? -zecke? | 222 | // sandman do we want to allow destructions? -zecke? |
229 | virtual ~ODevice(); | 223 | virtual ~ODevice(); |
230 | 224 | ||
231 | static ODevice *inst(); | 225 | static ODevice *inst(); |
232 | 226 | ||
233 | // information | 227 | // information |
234 | 228 | ||
235 | QString modelString() const; | 229 | QString modelString() const; |
236 | OModel model() const; | 230 | OModel model() const; |
237 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } | 231 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } |
238 | 232 | ||
239 | QString vendorString() const; | 233 | QString vendorString() const; |
240 | OVendor vendor() const; | 234 | OVendor vendor() const; |
@@ -259,115 +253,106 @@ public: | |||
259 | virtual int displayContrastResolution() const; | 253 | virtual int displayContrastResolution() const; |
260 | 254 | ||
261 | // don't add new virtual methods, use this: | 255 | // don't add new virtual methods, use this: |
262 | ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; | 256 | ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; |
263 | // and in your subclass do do overwrite | 257 | // and in your subclass do do overwrite |
264 | //protected virtual int virtual_hook(int, void *) | 258 | //protected virtual int virtual_hook(int, void *) |
265 | // which is defined below | 259 | // which is defined below |
266 | 260 | ||
267 | // input / output | 261 | // input / output |
268 | virtual void playAlarmSound(); | 262 | virtual void playAlarmSound(); |
269 | virtual void playKeySound(); | 263 | virtual void playKeySound(); |
270 | virtual void playTouchSound(); | 264 | virtual void playTouchSound(); |
271 | 265 | ||
272 | virtual QValueList <OLed> ledList() const; | 266 | virtual QValueList <OLed> ledList() const; |
273 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 267 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
274 | virtual OLedState ledState ( OLed led ) const; | 268 | virtual OLedState ledState ( OLed led ) const; |
275 | virtual bool setLedState ( OLed led, OLedState st ); | 269 | virtual bool setLedState ( OLed led, OLedState st ); |
276 | 270 | ||
277 | virtual bool hasLightSensor() const; | 271 | virtual bool hasLightSensor() const; |
278 | virtual int readLightSensor(); | 272 | virtual int readLightSensor(); |
279 | virtual int lightSensorResolution() const; | 273 | virtual int lightSensorResolution() const; |
280 | 274 | ||
281 | virtual bool hasHingeSensor() const; | 275 | virtual bool hasHingeSensor() const; |
282 | virtual OHingeStatus readHingeSensor(); | 276 | virtual OHingeStatus readHingeSensor(); |
283 | 277 | ||
284 | const QStrList &allowedCpuFrequencies() const; | 278 | const QStrList &allowedCpuFrequencies() const; |
285 | bool setCurrentCpuFrequency(uint index); | 279 | bool setCurrentCpuFrequency(uint index); |
286 | 280 | ||
287 | /** | 281 | /** |
288 | * Returns the available buttons on this device. The number and location | 282 | * Returns the available buttons on this device. The number and location |
289 | * of buttons will vary depending on the device. Button numbers will be assigned | 283 | * of buttons will vary depending on the device. Button numbers will be assigned |
290 | * by the device manufacturer and will be from most preferred button to least preffered | 284 | * by the device manufacturer and will be from most preferred button to least preffered |
291 | * button. Note that this list only contains "user mappable" buttons. | 285 | * button. Note that this list only contains "user mappable" buttons. |
292 | * | 286 | * |
293 | * @todo Make method const and take care of calling initButtons or make that const too | 287 | * @todo Make method const and take care of calling initButtons or make that const too |
294 | * | 288 | * |
295 | */ | 289 | */ |
296 | const QValueList<ODeviceButton> &buttons(); | 290 | const QValueList<ODeviceButton> &buttons(); |
297 | 291 | ||
298 | /** | 292 | /** |
299 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 293 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
300 | * returns 0L | 294 | * returns 0L |
301 | */ | 295 | */ |
302 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 296 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
303 | 297 | ||
304 | /** | 298 | /** |
305 | * Reassigns the pressed action for \a button. To return to the factory | 299 | * Reassigns the pressed action for \a button. To return to the factory |
306 | * default pass an empty string as \a qcopMessage. | 300 | * default pass an empty string as \a qcopMessage. |
307 | */ | 301 | */ |
308 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 302 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
309 | 303 | ||
310 | /** | 304 | /** |
311 | * Reassigns the held action for \a button. To return to the factory | 305 | * Reassigns the held action for \a button. To return to the factory |
312 | * default pass an empty string as \a qcopMessage. | 306 | * default pass an empty string as \a qcopMessage. |
313 | */ | 307 | */ |
314 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 308 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
315 | 309 | ||
316 | /** | 310 | /** |
317 | * How long (in ms) you have to press a button for a "hold" action | 311 | * How long (in ms) you have to press a button for a "hold" action |
318 | */ | 312 | */ |
319 | uint buttonHoldTime() const; | 313 | uint buttonHoldTime() const; |
320 | 314 | ||
321 | signals: | 315 | signals: |
322 | void buttonMappingChanged(); | 316 | void buttonMappingChanged(); |
323 | 317 | ||
324 | private slots: | 318 | private slots: |
325 | void systemMessage ( const QCString &, const QByteArray & ); | 319 | void systemMessage ( const QCString &, const QByteArray & ); |
326 | 320 | ||
327 | protected: | 321 | protected: |
328 | void reloadButtonMapping(); | 322 | void reloadButtonMapping(); |
329 | /* ugly virtual hook */ | 323 | /* ugly virtual hook */ |
330 | virtual void virtual_hook( int id, void* data ); | 324 | virtual void virtual_hook( int id, void* data ); |
331 | }; | 325 | }; |
332 | 326 | ||
333 | class ODeviceData { | 327 | class ODeviceData { |
334 | 328 | ||
335 | public: | 329 | public: |
336 | QString m_vendorstr; | 330 | QString m_vendorstr; |
337 | OVendor m_vendor; | 331 | OVendor m_vendor; |
338 | 332 | ||
339 | QString m_modelstr; | 333 | QString m_modelstr; |
340 | OModel m_model; | 334 | OModel m_model; |
341 | 335 | ||
342 | QString m_systemstr; | 336 | QString m_systemstr; |
343 | OSystem m_system; | 337 | OSystem m_system; |
344 | 338 | ||
345 | QString m_sysverstr; | 339 | QString m_sysverstr; |
346 | 340 | ||
347 | Transformation m_rotation; | 341 | Transformation m_rotation; |
348 | ODirection m_direction; | 342 | ODirection m_direction; |
349 | 343 | ||
350 | QValueList <ODeviceButton> *m_buttons; | 344 | QValueList <ODeviceButton> *m_buttons; |
351 | uint m_holdtime; | 345 | uint m_holdtime; |
352 | QStrList *m_cpu_frequencies; | 346 | QStrList *m_cpu_frequencies; |
353 | }; | 347 | }; |
354 | 348 | ||
349 | extern bool isQWS(); | ||
350 | extern QCString makeChannel ( const char *str ); | ||
355 | } | 351 | } |
356 | } | 352 | } |
357 | 353 | ||
358 | static inline bool isQWS() | ||
359 | { | ||
360 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | ||
361 | } | ||
362 | 354 | ||
363 | static QCString makeChannel ( const char *str ) | ||
364 | { | ||
365 | if ( str && !::strchr ( str, '/' )) | ||
366 | return QCString ( "QPE/Application/" ) + str; | ||
367 | else | ||
368 | return str; | ||
369 | } | ||
370 | 355 | ||
371 | 356 | ||
372 | #endif | 357 | #endif |
373 | 358 | ||