Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 65 |
1 files changed, 43 insertions, 22 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index cef7f63..5b73e59 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,72 +1,72 @@ | |||
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 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
62 | 62 | ||
63 | using namespace Opie::Core; | 63 | using namespace Opie::Core; |
64 | 64 | ||
65 | struct default_button default_buttons [] = { | 65 | struct default_button default_buttons [] = { |
66 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 66 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
67 | "devicebuttons/z_calendar", | 67 | "devicebuttons/z_calendar", |
68 | "datebook", "nextView()", | 68 | "datebook", "nextView()", |
69 | "today", "raise()" }, | 69 | "today", "raise()" }, |
70 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 70 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
71 | "devicebuttons/z_contact", | 71 | "devicebuttons/z_contact", |
72 | "addressbook", "raise()", | 72 | "addressbook", "raise()", |
@@ -98,99 +98,120 @@ ODevice *ODevice::inst() | |||
98 | if ( f.open( IO_ReadOnly ) ) | 98 | if ( f.open( IO_ReadOnly ) ) |
99 | { | 99 | { |
100 | QTextStream s( &f ); | 100 | QTextStream s( &f ); |
101 | while ( !s.atEnd() ) | 101 | while ( !s.atEnd() ) |
102 | { | 102 | { |
103 | QString line; | 103 | QString line; |
104 | line = s.readLine(); | 104 | line = s.readLine(); |
105 | if ( line.startsWith( "Hardware" ) ) | 105 | if ( line.startsWith( "Hardware" ) ) |
106 | { | 106 | { |
107 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 107 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
108 | cpu_info = line; | 108 | cpu_info = line; |
109 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 109 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
110 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 110 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
111 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 111 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
112 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 112 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
113 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 113 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
114 | else qWarning( "ODevice() - unknown hardware - using default." ); | 114 | else qWarning( "ODevice() - unknown hardware - using default." ); |
115 | break; | 115 | break; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | else | 119 | else |
120 | { | 120 | { |
121 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 121 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
122 | } | 122 | } |
123 | if ( !dev ) dev = new ODevice(); | 123 | if ( !dev ) dev = new ODevice(); |
124 | dev->init(cpu_info); | 124 | dev->init(cpu_info); |
125 | } | 125 | } |
126 | return dev; | 126 | return dev; |
127 | } | 127 | } |
128 | 128 | ||
129 | ODevice::ODevice() | 129 | ODevice::ODevice() |
130 | { | 130 | { |
131 | d = new ODeviceData; | 131 | d = new ODeviceData; |
132 | 132 | ||
133 | d->m_modelstr = "Unknown"; | 133 | d->m_modelstr = "Unknown"; |
134 | d->m_model = Model_Unknown; | 134 | d->m_model = Model_Unknown; |
135 | d->m_vendorstr = "Unknown"; | 135 | d->m_vendorstr = "Unknown"; |
136 | d->m_vendor = Vendor_Unknown; | 136 | d->m_vendor = Vendor_Unknown; |
137 | d->m_systemstr = "Unknown"; | 137 | d->m_systemstr = "Unknown"; |
138 | d->m_system = System_Unknown; | 138 | d->m_system = System_Unknown; |
139 | d->m_sysverstr = "0.0"; | 139 | d->m_sysverstr = "0.0"; |
140 | d->m_rotation = Rot0; | 140 | d->m_rotation = Rot0; |
141 | d->m_direction = CW; | 141 | d->m_direction = CW; |
142 | 142 | ||
143 | d->m_holdtime = 1000; // 1000ms | 143 | d->m_holdtime = 1000; // 1000ms |
144 | d->m_buttons = 0; | 144 | d->m_buttons = 0; |
145 | d->m_cpu_frequencies = new QStrList; | 145 | d->m_cpu_frequencies = new QStrList; |
146 | |||
147 | // New distribution detection code first checks for legacy distributions, | ||
148 | // identified by /etc/familiar-version or /etc/oz_version. | ||
149 | // Then check for OpenEmbedded and lastly, read /etc/issue | ||
150 | |||
151 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | ||
152 | { | ||
153 | if ( QFile::exists( distributions[i].sysvfile ) ) | ||
154 | { | ||
155 | d->m_systemstr = distributions[i].sysstr; | ||
156 | d->m_system = distributions[i].system; | ||
157 | d->m_sysverstr = "<Unknown>"; | ||
158 | QFile f( distributions[i].sysvfile ); | ||
159 | if ( f.open( IO_ReadOnly ) ) | ||
160 | { | ||
161 | QTextStream ts( &f ); | ||
162 | d->m_sysverstr = ts.readLine(); | ||
163 | } | ||
164 | break; | ||
165 | } | ||
166 | } | ||
146 | } | 167 | } |
147 | 168 | ||
148 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 169 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
149 | { | 170 | { |
150 | if ( msg == "deviceButtonMappingChanged()" ) { | 171 | if ( msg == "deviceButtonMappingChanged()" ) { |
151 | reloadButtonMapping(); | 172 | reloadButtonMapping(); |
152 | } | 173 | } |
153 | } | 174 | } |
154 | 175 | ||
155 | void ODevice::init(const QString&) | 176 | void ODevice::init(const QString&) |
156 | { | 177 | { |
157 | } | 178 | } |
158 | 179 | ||
159 | /** | 180 | /** |
160 | * This method initialises the button mapping | 181 | * This method initialises the button mapping |
161 | */ | 182 | */ |
162 | void ODevice::initButtons() | 183 | void ODevice::initButtons() |
163 | { | 184 | { |
164 | if ( d->m_buttons ) | 185 | if ( d->m_buttons ) |
165 | return; | 186 | return; |
166 | 187 | ||
167 | qDebug ( "init Buttons" ); | 188 | qDebug ( "init Buttons" ); |
168 | d->m_buttons = new QValueList <ODeviceButton>; | 189 | d->m_buttons = new QValueList <ODeviceButton>; |
169 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 190 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
170 | default_button *db = default_buttons + i; | 191 | default_button *db = default_buttons + i; |
171 | ODeviceButton b; | 192 | ODeviceButton b; |
172 | b. setKeycode ( db->code ); | 193 | b. setKeycode ( db->code ); |
173 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 194 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
174 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 195 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
175 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 196 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
176 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 197 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
177 | d->m_buttons->append ( b ); | 198 | d->m_buttons->append ( b ); |
178 | } | 199 | } |
179 | 200 | ||
180 | reloadButtonMapping(); | 201 | reloadButtonMapping(); |
181 | 202 | ||
182 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 203 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
183 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 204 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
184 | } | 205 | } |
185 | 206 | ||
186 | ODevice::~ODevice() | 207 | ODevice::~ODevice() |
187 | { | 208 | { |
188 | // we leak m_devicebuttons and m_cpu_frequency | 209 | // we leak m_devicebuttons and m_cpu_frequency |
189 | // but it's a singleton and it is not so importantant | 210 | // but it's a singleton and it is not so importantant |
190 | // -zecke | 211 | // -zecke |
191 | delete d; | 212 | delete d; |
192 | } | 213 | } |
193 | 214 | ||
194 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 215 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
195 | { | 216 | { |
196 | return false; | 217 | return false; |