author | schurig <schurig> | 2004-09-09 09:08:36 (UTC) |
---|---|---|
committer | schurig <schurig> | 2004-09-09 09:08:36 (UTC) |
commit | 8df28401db620a01144ca45988837583f55e15c3 (patch) (unidiff) | |
tree | 7024a45504623a81abbf58c7ab0cae08d7870bd2 | |
parent | 739d8dc8d4aed25e09d43805c802e9836240655b (diff) | |
download | opie-8df28401db620a01144ca45988837583f55e15c3.zip opie-8df28401db620a01144ca45988837583f55e15c3.tar.gz opie-8df28401db620a01144ca45988837583f55e15c3.tar.bz2 |
support for devfs
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 280b0c5..2355621 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,789 +1,793 @@ | |||
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 <qpe/sound.h> | 48 | #include <qpe/sound.h> |
49 | #include <opie2/okeyfilter.h> | 49 | #include <opie2/okeyfilter.h> |
50 | 50 | ||
51 | /* STD */ | 51 | /* STD */ |
52 | #include <fcntl.h> | 52 | #include <fcntl.h> |
53 | #include <math.h> | 53 | #include <math.h> |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <signal.h> | 55 | #include <signal.h> |
56 | #include <sys/ioctl.h> | 56 | #include <sys/ioctl.h> |
57 | #include <sys/time.h> | 57 | #include <sys/time.h> |
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #ifndef QT_NO_SOUND | 59 | #ifndef QT_NO_SOUND |
60 | #include <linux/soundcard.h> | 60 | #include <linux/soundcard.h> |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | namespace Opie { | 63 | namespace Opie { |
64 | namespace Core { | 64 | namespace Core { |
65 | 65 | ||
66 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 66 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
67 | 67 | ||
68 | 68 | ||
69 | /* STATIC and common implementation */ | 69 | /* STATIC and common implementation */ |
70 | /* EXPORT */ ODistribution distributions[] = { | 70 | /* EXPORT */ ODistribution distributions[] = { |
71 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 71 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
72 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | 72 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, |
73 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 73 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
74 | { System_Unknown, "Linux", "/etc/issue" }, | 74 | { System_Unknown, "Linux", "/etc/issue" }, |
75 | }; | 75 | }; |
76 | 76 | ||
77 | 77 | ||
78 | /* EXPORT */ bool isQWS(){ | 78 | /* EXPORT */ bool isQWS(){ |
79 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 79 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
80 | } | 80 | } |
81 | 81 | ||
82 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 82 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
83 | if ( str && !::strchr ( str, '/' )) | 83 | if ( str && !::strchr ( str, '/' )) |
84 | return QCString ( "QPE/Application/" ) + str; | 84 | return QCString ( "QPE/Application/" ) + str; |
85 | else | 85 | else |
86 | return str; | 86 | return str; |
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | ||
90 | 90 | ||
91 | /* Now the default implementation of ODevice */ | 91 | /* Now the default implementation of ODevice */ |
92 | 92 | ||
93 | struct default_button default_buttons [] = { | 93 | struct default_button default_buttons [] = { |
94 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 94 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
95 | "devicebuttons/z_calendar", | 95 | "devicebuttons/z_calendar", |
96 | "datebook", "nextView()", | 96 | "datebook", "nextView()", |
97 | "today", "raise()" }, | 97 | "today", "raise()" }, |
98 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 98 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
99 | "devicebuttons/z_contact", | 99 | "devicebuttons/z_contact", |
100 | "addressbook", "raise()", | 100 | "addressbook", "raise()", |
101 | "addressbook", "beamBusinessCard()" }, | 101 | "addressbook", "beamBusinessCard()" }, |
102 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 102 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
103 | "devicebuttons/z_home", | 103 | "devicebuttons/z_home", |
104 | "QPE/Launcher", "home()", | 104 | "QPE/Launcher", "home()", |
105 | "buttonsettings", "raise()" }, | 105 | "buttonsettings", "raise()" }, |
106 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 106 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
107 | "devicebuttons/z_menu", | 107 | "devicebuttons/z_menu", |
108 | "QPE/TaskBar", "toggleMenu()", | 108 | "QPE/TaskBar", "toggleMenu()", |
109 | "QPE/TaskBar", "toggleStartMenu()" }, | 109 | "QPE/TaskBar", "toggleStartMenu()" }, |
110 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 110 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
111 | "devicebuttons/z_mail", | 111 | "devicebuttons/z_mail", |
112 | "opiemail", "raise()", | 112 | "opiemail", "raise()", |
113 | "opiemail", "newMail()" }, | 113 | "opiemail", "newMail()" }, |
114 | }; | 114 | }; |
115 | 115 | ||
116 | ODevice *ODevice::inst() | 116 | ODevice *ODevice::inst() |
117 | { | 117 | { |
118 | static ODevice *dev = 0; | 118 | static ODevice *dev = 0; |
119 | 119 | ||
120 | // rewrite this to only use /proc/cpuinfo or so | 120 | // rewrite this to only use /proc/cpuinfo or so |
121 | QString cpu_info; | 121 | QString cpu_info; |
122 | 122 | ||
123 | if ( !dev ) | 123 | if ( !dev ) |
124 | { | 124 | { |
125 | QFile f( PATH_PROC_CPUINFO ); | 125 | QFile f( PATH_PROC_CPUINFO ); |
126 | if ( f.open( IO_ReadOnly ) ) | 126 | if ( f.open( IO_ReadOnly ) ) |
127 | { | 127 | { |
128 | QTextStream s( &f ); | 128 | QTextStream s( &f ); |
129 | while ( !s.atEnd() ) | 129 | while ( !s.atEnd() ) |
130 | { | 130 | { |
131 | QString line; | 131 | QString line; |
132 | line = s.readLine(); | 132 | line = s.readLine(); |
133 | if ( line.startsWith( "Hardware" ) ) | 133 | if ( line.startsWith( "Hardware" ) ) |
134 | { | 134 | { |
135 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 135 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
136 | cpu_info = line; | 136 | cpu_info = line; |
137 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 137 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
138 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 138 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
139 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 139 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
140 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 140 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
141 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 141 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
142 | else qWarning( "ODevice() - unknown hardware - using default." ); | 142 | else qWarning( "ODevice() - unknown hardware - using default." ); |
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | } | 146 | } |
147 | else | 147 | else |
148 | { | 148 | { |
149 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 149 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
150 | } | 150 | } |
151 | if ( !dev ) dev = new ODevice(); | 151 | if ( !dev ) dev = new ODevice(); |
152 | dev->init(cpu_info); | 152 | dev->init(cpu_info); |
153 | } | 153 | } |
154 | return dev; | 154 | return dev; |
155 | } | 155 | } |
156 | 156 | ||
157 | ODevice::ODevice() | 157 | ODevice::ODevice() |
158 | { | 158 | { |
159 | d = new ODeviceData; | 159 | d = new ODeviceData; |
160 | 160 | ||
161 | d->m_modelstr = "Unknown"; | 161 | d->m_modelstr = "Unknown"; |
162 | d->m_model = Model_Unknown; | 162 | d->m_model = Model_Unknown; |
163 | d->m_vendorstr = "Unknown"; | 163 | d->m_vendorstr = "Unknown"; |
164 | d->m_vendor = Vendor_Unknown; | 164 | d->m_vendor = Vendor_Unknown; |
165 | d->m_systemstr = "Unknown"; | 165 | d->m_systemstr = "Unknown"; |
166 | d->m_system = System_Unknown; | 166 | d->m_system = System_Unknown; |
167 | d->m_sysverstr = "0.0"; | 167 | d->m_sysverstr = "0.0"; |
168 | d->m_rotation = Rot0; | 168 | d->m_rotation = Rot0; |
169 | d->m_direction = CW; | 169 | d->m_direction = CW; |
170 | 170 | ||
171 | d->m_holdtime = 1000; // 1000ms | 171 | d->m_holdtime = 1000; // 1000ms |
172 | d->m_buttons = 0; | 172 | d->m_buttons = 0; |
173 | d->m_cpu_frequencies = new QStrList; | 173 | d->m_cpu_frequencies = new QStrList; |
174 | 174 | ||
175 | 175 | ||
176 | /* mixer */ | 176 | /* mixer */ |
177 | d->m_sound = d->m_vol = d->m_mixer = -1; | 177 | d->m_sound = d->m_vol = d->m_mixer = -1; |
178 | 178 | ||
179 | // New distribution detection code first checks for legacy distributions, | 179 | // New distribution detection code first checks for legacy distributions, |
180 | // identified by /etc/familiar-version or /etc/oz_version. | 180 | // identified by /etc/familiar-version or /etc/oz_version. |
181 | // Then check for OpenEmbedded and lastly, read /etc/issue | 181 | // Then check for OpenEmbedded and lastly, read /etc/issue |
182 | 182 | ||
183 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | 183 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) |
184 | { | 184 | { |
185 | if ( QFile::exists( distributions[i].sysvfile ) ) | 185 | if ( QFile::exists( distributions[i].sysvfile ) ) |
186 | { | 186 | { |
187 | d->m_systemstr = distributions[i].sysstr; | 187 | d->m_systemstr = distributions[i].sysstr; |
188 | d->m_system = distributions[i].system; | 188 | d->m_system = distributions[i].system; |
189 | d->m_sysverstr = "<Unknown>"; | 189 | d->m_sysverstr = "<Unknown>"; |
190 | QFile f( distributions[i].sysvfile ); | 190 | QFile f( distributions[i].sysvfile ); |
191 | if ( f.open( IO_ReadOnly ) ) | 191 | if ( f.open( IO_ReadOnly ) ) |
192 | { | 192 | { |
193 | QTextStream ts( &f ); | 193 | QTextStream ts( &f ); |
194 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 194 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
195 | } | 195 | } |
196 | break; | 196 | break; |
197 | } | 197 | } |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 201 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
202 | { | 202 | { |
203 | if ( msg == "deviceButtonMappingChanged()" ) { | 203 | if ( msg == "deviceButtonMappingChanged()" ) { |
204 | reloadButtonMapping(); | 204 | reloadButtonMapping(); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void ODevice::init(const QString&) | 208 | void ODevice::init(const QString&) |
209 | { | 209 | { |
210 | } | 210 | } |
211 | 211 | ||
212 | /** | 212 | /** |
213 | * This method initialises the button mapping | 213 | * This method initialises the button mapping |
214 | */ | 214 | */ |
215 | void ODevice::initButtons() | 215 | void ODevice::initButtons() |
216 | { | 216 | { |
217 | if ( d->m_buttons ) | 217 | if ( d->m_buttons ) |
218 | return; | 218 | return; |
219 | 219 | ||
220 | qDebug ( "init Buttons" ); | 220 | qDebug ( "init Buttons" ); |
221 | d->m_buttons = new QValueList <ODeviceButton>; | 221 | d->m_buttons = new QValueList <ODeviceButton>; |
222 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 222 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
223 | default_button *db = default_buttons + i; | 223 | default_button *db = default_buttons + i; |
224 | ODeviceButton b; | 224 | ODeviceButton b; |
225 | b. setKeycode ( db->code ); | 225 | b. setKeycode ( db->code ); |
226 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 226 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
227 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 227 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
228 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 228 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
229 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 229 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
230 | d->m_buttons->append ( b ); | 230 | d->m_buttons->append ( b ); |
231 | } | 231 | } |
232 | 232 | ||
233 | reloadButtonMapping(); | 233 | reloadButtonMapping(); |
234 | 234 | ||
235 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 235 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
236 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 236 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
237 | } | 237 | } |
238 | 238 | ||
239 | ODevice::~ODevice() | 239 | ODevice::~ODevice() |
240 | { | 240 | { |
241 | // we leak m_devicebuttons and m_cpu_frequency | 241 | // we leak m_devicebuttons and m_cpu_frequency |
242 | // but it's a singleton and it is not so importantant | 242 | // but it's a singleton and it is not so importantant |
243 | // -zecke | 243 | // -zecke |
244 | delete d; | 244 | delete d; |
245 | } | 245 | } |
246 | 246 | ||
247 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 247 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
248 | { | 248 | { |
249 | return false; | 249 | return false; |
250 | } | 250 | } |
251 | 251 | ||
252 | //#include <linux/apm_bios.h> | 252 | //#include <linux/apm_bios.h> |
253 | 253 | ||
254 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 254 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * This method will try to suspend the device | 257 | * This method will try to suspend the device |
258 | * It only works if the user is the QWS Server and the apm application | 258 | * It only works if the user is the QWS Server and the apm application |
259 | * is installed. | 259 | * is installed. |
260 | * It tries to suspend and then waits some time cause some distributions | 260 | * It tries to suspend and then waits some time cause some distributions |
261 | * do have asynchronus apm implementations. | 261 | * do have asynchronus apm implementations. |
262 | * This method will either fail and return false or it'll suspend the | 262 | * This method will either fail and return false or it'll suspend the |
263 | * device and return once the device got woken up | 263 | * device and return once the device got woken up |
264 | * | 264 | * |
265 | * @return if the device got suspended | 265 | * @return if the device got suspended |
266 | */ | 266 | */ |
267 | bool ODevice::suspend() | 267 | bool ODevice::suspend() |
268 | { | 268 | { |
269 | qDebug("ODevice::suspend"); | 269 | qDebug("ODevice::suspend"); |
270 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 270 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
271 | return false; | 271 | return false; |
272 | 272 | ||
273 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 273 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
274 | return false; | 274 | return false; |
275 | 275 | ||
276 | bool res = false; | 276 | bool res = false; |
277 | ODevice::sendSuspendmsg(); | 277 | ODevice::sendSuspendmsg(); |
278 | 278 | ||
279 | struct timeval tvs, tvn; | 279 | struct timeval tvs, tvn; |
280 | ::gettimeofday ( &tvs, 0 ); | 280 | ::gettimeofday ( &tvs, 0 ); |
281 | 281 | ||
282 | ::sync(); // flush fs caches | 282 | ::sync(); // flush fs caches |
283 | res = ( ::system ( "apm --suspend" ) == 0 ); | 283 | res = ( ::system ( "apm --suspend" ) == 0 ); |
284 | 284 | ||
285 | // This is needed because the iPAQ apm implementation is asynchronous and we | 285 | // This is needed because the iPAQ apm implementation is asynchronous and we |
286 | // can not be sure when exactly the device is really suspended | 286 | // can not be sure when exactly the device is really suspended |
287 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 287 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
288 | 288 | ||
289 | if ( res ) { | 289 | if ( res ) { |
290 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 290 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
291 | ::usleep ( 200 * 1000 ); | 291 | ::usleep ( 200 * 1000 ); |
292 | ::gettimeofday ( &tvn, 0 ); | 292 | ::gettimeofday ( &tvn, 0 ); |
293 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 293 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
294 | } | 294 | } |
295 | 295 | ||
296 | return res; | 296 | return res; |
297 | } | 297 | } |
298 | 298 | ||
299 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 299 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
300 | 300 | ||
301 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 301 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
302 | 302 | ||
303 | /* VESA Blanking Levels */ | 303 | /* VESA Blanking Levels */ |
304 | #define VESA_NO_BLANKING 0 | 304 | #define VESA_NO_BLANKING 0 |
305 | #define VESA_VSYNC_SUSPEND 1 | 305 | #define VESA_VSYNC_SUSPEND 1 |
306 | #define VESA_HSYNC_SUSPEND 2 | 306 | #define VESA_HSYNC_SUSPEND 2 |
307 | #define VESA_POWERDOWN 3 | 307 | #define VESA_POWERDOWN 3 |
308 | 308 | ||
309 | /** | 309 | /** |
310 | * This sets the display on or off | 310 | * This sets the display on or off |
311 | */ | 311 | */ |
312 | bool ODevice::setDisplayStatus ( bool on ) | 312 | bool ODevice::setDisplayStatus ( bool on ) |
313 | { | 313 | { |
314 | qDebug("ODevice::setDisplayStatus(%d)", on); | 314 | qDebug("ODevice::setDisplayStatus(%d)", on); |
315 | 315 | ||
316 | if ( d->m_model == Model_Unknown ) | 316 | if ( d->m_model == Model_Unknown ) |
317 | return false; | 317 | return false; |
318 | 318 | ||
319 | bool res = false; | 319 | bool res = false; |
320 | int fd; | 320 | int fd; |
321 | 321 | ||
322 | #ifdef QT_QWS_DEVFS | ||
323 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | ||
324 | #else | ||
322 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 325 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
326 | #endif | ||
323 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 327 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
324 | ::close ( fd ); | 328 | ::close ( fd ); |
325 | } | 329 | } |
326 | return res; | 330 | return res; |
327 | } | 331 | } |
328 | 332 | ||
329 | /** | 333 | /** |
330 | * This sets the display brightness | 334 | * This sets the display brightness |
331 | * | 335 | * |
332 | * @param p The brightness to be set on a scale from 0 to 255 | 336 | * @param p The brightness to be set on a scale from 0 to 255 |
333 | * @return success or failure | 337 | * @return success or failure |
334 | */ | 338 | */ |
335 | bool ODevice::setDisplayBrightness ( int p) | 339 | bool ODevice::setDisplayBrightness ( int p) |
336 | { | 340 | { |
337 | Q_UNUSED( p ) | 341 | Q_UNUSED( p ) |
338 | return false; | 342 | return false; |
339 | } | 343 | } |
340 | 344 | ||
341 | /** | 345 | /** |
342 | * @return returns the number of steppings on the brightness slider | 346 | * @return returns the number of steppings on the brightness slider |
343 | * in the Light-'n-Power settings. | 347 | * in the Light-'n-Power settings. |
344 | */ | 348 | */ |
345 | int ODevice::displayBrightnessResolution() const | 349 | int ODevice::displayBrightnessResolution() const |
346 | { | 350 | { |
347 | return 16; | 351 | return 16; |
348 | } | 352 | } |
349 | 353 | ||
350 | /** | 354 | /** |
351 | * This sets the display contrast | 355 | * This sets the display contrast |
352 | * @param p The contrast to be set on a scale from 0 to 255 | 356 | * @param p The contrast to be set on a scale from 0 to 255 |
353 | * @return success or failure | 357 | * @return success or failure |
354 | */ | 358 | */ |
355 | bool ODevice::setDisplayContrast ( int p) | 359 | bool ODevice::setDisplayContrast ( int p) |
356 | { | 360 | { |
357 | Q_UNUSED( p ) | 361 | Q_UNUSED( p ) |
358 | return false; | 362 | return false; |
359 | } | 363 | } |
360 | 364 | ||
361 | /** | 365 | /** |
362 | * @return return the max value for the brightness settings slider | 366 | * @return return the max value for the brightness settings slider |
363 | * or 0 if the device doesn't support setting of a contrast | 367 | * or 0 if the device doesn't support setting of a contrast |
364 | */ | 368 | */ |
365 | int ODevice::displayContrastResolution() const | 369 | int ODevice::displayContrastResolution() const |
366 | { | 370 | { |
367 | return 0; | 371 | return 0; |
368 | } | 372 | } |
369 | 373 | ||
370 | /** | 374 | /** |
371 | * This returns the vendor as string | 375 | * This returns the vendor as string |
372 | * @return Vendor as QString | 376 | * @return Vendor as QString |
373 | */ | 377 | */ |
374 | QString ODevice::vendorString() const | 378 | QString ODevice::vendorString() const |
375 | { | 379 | { |
376 | return d->m_vendorstr; | 380 | return d->m_vendorstr; |
377 | } | 381 | } |
378 | 382 | ||
379 | /** | 383 | /** |
380 | * This returns the vendor as one of the values of OVendor | 384 | * This returns the vendor as one of the values of OVendor |
381 | * @return OVendor | 385 | * @return OVendor |
382 | */ | 386 | */ |
383 | OVendor ODevice::vendor() const | 387 | OVendor ODevice::vendor() const |
384 | { | 388 | { |
385 | return d->m_vendor; | 389 | return d->m_vendor; |
386 | } | 390 | } |
387 | 391 | ||
388 | /** | 392 | /** |
389 | * This returns the model as a string | 393 | * This returns the model as a string |
390 | * @return A string representing the model | 394 | * @return A string representing the model |
391 | */ | 395 | */ |
392 | QString ODevice::modelString() const | 396 | QString ODevice::modelString() const |
393 | { | 397 | { |
394 | return d->m_modelstr; | 398 | return d->m_modelstr; |
395 | } | 399 | } |
396 | 400 | ||
397 | /** | 401 | /** |
398 | * This does return the OModel used | 402 | * This does return the OModel used |
399 | */ | 403 | */ |
400 | OModel ODevice::model() const | 404 | OModel ODevice::model() const |
401 | { | 405 | { |
402 | return d->m_model; | 406 | return d->m_model; |
403 | } | 407 | } |
404 | 408 | ||
405 | /** | 409 | /** |
406 | * This does return the systen name | 410 | * This does return the systen name |
407 | */ | 411 | */ |
408 | QString ODevice::systemString() const | 412 | QString ODevice::systemString() const |
409 | { | 413 | { |
410 | return d->m_systemstr; | 414 | return d->m_systemstr; |
411 | } | 415 | } |
412 | 416 | ||
413 | /** | 417 | /** |
414 | * Return System as OSystem value | 418 | * Return System as OSystem value |
415 | */ | 419 | */ |
416 | OSystem ODevice::system() const | 420 | OSystem ODevice::system() const |
417 | { | 421 | { |
418 | return d->m_system; | 422 | return d->m_system; |
419 | } | 423 | } |
420 | 424 | ||
421 | /** | 425 | /** |
422 | * @return the version string of the base system | 426 | * @return the version string of the base system |
423 | */ | 427 | */ |
424 | QString ODevice::systemVersionString() const | 428 | QString ODevice::systemVersionString() const |
425 | { | 429 | { |
426 | return d->m_sysverstr; | 430 | return d->m_sysverstr; |
427 | } | 431 | } |
428 | 432 | ||
429 | /** | 433 | /** |
430 | * @return the current Transformation | 434 | * @return the current Transformation |
431 | */ | 435 | */ |
432 | Transformation ODevice::rotation() const | 436 | Transformation ODevice::rotation() const |
433 | { | 437 | { |
434 | return d->m_rotation; | 438 | return d->m_rotation; |
435 | } | 439 | } |
436 | 440 | ||
437 | /** | 441 | /** |
438 | * @return the current rotation direction | 442 | * @return the current rotation direction |
439 | */ | 443 | */ |
440 | ODirection ODevice::direction() const | 444 | ODirection ODevice::direction() const |
441 | { | 445 | { |
442 | return d->m_direction; | 446 | return d->m_direction; |
443 | } | 447 | } |
444 | 448 | ||
445 | /** | 449 | /** |
446 | * This plays an alarm sound | 450 | * This plays an alarm sound |
447 | */ | 451 | */ |
448 | void ODevice::playAlarmSound() | 452 | void ODevice::playAlarmSound() |
449 | { | 453 | { |
450 | #ifndef QT_NO_SOUND | 454 | #ifndef QT_NO_SOUND |
451 | static Sound snd ( "alarm" ); | 455 | static Sound snd ( "alarm" ); |
452 | 456 | ||
453 | if ( snd. isFinished()) | 457 | if ( snd. isFinished()) |
454 | snd. play(); | 458 | snd. play(); |
455 | #endif | 459 | #endif |
456 | } | 460 | } |
457 | 461 | ||
458 | /** | 462 | /** |
459 | * This plays a key sound | 463 | * This plays a key sound |
460 | */ | 464 | */ |
461 | void ODevice::playKeySound() | 465 | void ODevice::playKeySound() |
462 | { | 466 | { |
463 | #ifndef QT_NO_SOUND | 467 | #ifndef QT_NO_SOUND |
464 | static Sound snd ( "keysound" ); | 468 | static Sound snd ( "keysound" ); |
465 | 469 | ||
466 | if ( snd. isFinished()) | 470 | if ( snd. isFinished()) |
467 | snd. play(); | 471 | snd. play(); |
468 | #endif | 472 | #endif |
469 | } | 473 | } |
470 | 474 | ||
471 | /** | 475 | /** |
472 | * This plays a touch sound | 476 | * This plays a touch sound |
473 | */ | 477 | */ |
474 | void ODevice::playTouchSound() | 478 | void ODevice::playTouchSound() |
475 | { | 479 | { |
476 | #ifndef QT_NO_SOUND | 480 | #ifndef QT_NO_SOUND |
477 | static Sound snd ( "touchsound" ); | 481 | static Sound snd ( "touchsound" ); |
478 | 482 | ||
479 | if ( snd. isFinished()) | 483 | if ( snd. isFinished()) |
480 | snd. play(); | 484 | snd. play(); |
481 | #endif | 485 | #endif |
482 | } | 486 | } |
483 | 487 | ||
484 | /** | 488 | /** |
485 | * This method will return a list of leds | 489 | * This method will return a list of leds |
486 | * available on this device | 490 | * available on this device |
487 | * @return a list of LEDs. | 491 | * @return a list of LEDs. |
488 | */ | 492 | */ |
489 | QValueList <OLed> ODevice::ledList() const | 493 | QValueList <OLed> ODevice::ledList() const |
490 | { | 494 | { |
491 | return QValueList <OLed>(); | 495 | return QValueList <OLed>(); |
492 | } | 496 | } |
493 | 497 | ||
494 | /** | 498 | /** |
495 | * This does return the state of the LEDs | 499 | * This does return the state of the LEDs |
496 | */ | 500 | */ |
497 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 501 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
498 | { | 502 | { |
499 | return QValueList <OLedState>(); | 503 | return QValueList <OLedState>(); |
500 | } | 504 | } |
501 | 505 | ||
502 | /** | 506 | /** |
503 | * @return the state for a given OLed | 507 | * @return the state for a given OLed |
504 | */ | 508 | */ |
505 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 509 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
506 | { | 510 | { |
507 | return Led_Off; | 511 | return Led_Off; |
508 | } | 512 | } |
509 | 513 | ||
510 | /** | 514 | /** |
511 | * Set the state for a LED | 515 | * Set the state for a LED |
512 | * @param which Which OLed to use | 516 | * @param which Which OLed to use |
513 | * @param st The state to set | 517 | * @param st The state to set |
514 | * @return success or failure | 518 | * @return success or failure |
515 | */ | 519 | */ |
516 | bool ODevice::setLedState ( OLed which, OLedState st ) | 520 | bool ODevice::setLedState ( OLed which, OLedState st ) |
517 | { | 521 | { |
518 | Q_UNUSED( which ) | 522 | Q_UNUSED( which ) |
519 | Q_UNUSED( st ) | 523 | Q_UNUSED( st ) |
520 | return false; | 524 | return false; |
521 | } | 525 | } |
522 | 526 | ||
523 | /** | 527 | /** |
524 | * @return if the device has a light sensor | 528 | * @return if the device has a light sensor |
525 | */ | 529 | */ |
526 | bool ODevice::hasLightSensor() const | 530 | bool ODevice::hasLightSensor() const |
527 | { | 531 | { |
528 | return false; | 532 | return false; |
529 | } | 533 | } |
530 | 534 | ||
531 | /** | 535 | /** |
532 | * @return a value from the light sensor | 536 | * @return a value from the light sensor |
533 | */ | 537 | */ |
534 | int ODevice::readLightSensor() | 538 | int ODevice::readLightSensor() |
535 | { | 539 | { |
536 | return -1; | 540 | return -1; |
537 | } | 541 | } |
538 | 542 | ||
539 | /** | 543 | /** |
540 | * @return the light sensor resolution | 544 | * @return the light sensor resolution |
541 | */ | 545 | */ |
542 | int ODevice::lightSensorResolution() const | 546 | int ODevice::lightSensorResolution() const |
543 | { | 547 | { |
544 | return 0; | 548 | return 0; |
545 | } | 549 | } |
546 | 550 | ||
547 | /** | 551 | /** |
548 | * @return if the device has a hinge sensor | 552 | * @return if the device has a hinge sensor |
549 | */ | 553 | */ |
550 | bool ODevice::hasHingeSensor() const | 554 | bool ODevice::hasHingeSensor() const |
551 | { | 555 | { |
552 | return false; | 556 | return false; |
553 | } | 557 | } |
554 | 558 | ||
555 | /** | 559 | /** |
556 | * @return a value from the hinge sensor | 560 | * @return a value from the hinge sensor |
557 | */ | 561 | */ |
558 | OHingeStatus ODevice::readHingeSensor() | 562 | OHingeStatus ODevice::readHingeSensor() |
559 | { | 563 | { |
560 | return CASE_UNKNOWN; | 564 | return CASE_UNKNOWN; |
561 | } | 565 | } |
562 | 566 | ||
563 | /** | 567 | /** |
564 | * @return a list with CPU frequencies supported by the hardware | 568 | * @return a list with CPU frequencies supported by the hardware |
565 | */ | 569 | */ |
566 | const QStrList &ODevice::allowedCpuFrequencies() const | 570 | const QStrList &ODevice::allowedCpuFrequencies() const |
567 | { | 571 | { |
568 | return *d->m_cpu_frequencies; | 572 | return *d->m_cpu_frequencies; |
569 | } | 573 | } |
570 | 574 | ||
571 | 575 | ||
572 | /** | 576 | /** |
573 | * Set desired CPU frequency | 577 | * Set desired CPU frequency |
574 | * | 578 | * |
575 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 579 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
576 | */ | 580 | */ |
577 | bool ODevice::setCurrentCpuFrequency(uint index) | 581 | bool ODevice::setCurrentCpuFrequency(uint index) |
578 | { | 582 | { |
579 | if (index >= d->m_cpu_frequencies->count()) | 583 | if (index >= d->m_cpu_frequencies->count()) |
580 | return false; | 584 | return false; |
581 | 585 | ||
582 | char *freq = d->m_cpu_frequencies->at(index); | 586 | char *freq = d->m_cpu_frequencies->at(index); |
583 | qWarning("set freq to %s", freq); | 587 | qWarning("set freq to %s", freq); |
584 | 588 | ||
585 | int fd; | 589 | int fd; |
586 | 590 | ||
587 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 591 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
588 | char writeCommand[50]; | 592 | char writeCommand[50]; |
589 | const int count = sprintf(writeCommand, "%s\n", freq); | 593 | const int count = sprintf(writeCommand, "%s\n", freq); |
590 | int res = (::write(fd, writeCommand, count) != -1); | 594 | int res = (::write(fd, writeCommand, count) != -1); |
591 | ::close(fd); | 595 | ::close(fd); |
592 | return res; | 596 | return res; |
593 | } | 597 | } |
594 | 598 | ||
595 | return false; | 599 | return false; |
596 | } | 600 | } |
597 | 601 | ||
598 | 602 | ||
599 | /** | 603 | /** |
600 | * @return a list of hardware buttons | 604 | * @return a list of hardware buttons |
601 | */ | 605 | */ |
602 | const QValueList <ODeviceButton> &ODevice::buttons() | 606 | const QValueList <ODeviceButton> &ODevice::buttons() |
603 | { | 607 | { |
604 | initButtons(); | 608 | initButtons(); |
605 | 609 | ||
606 | return *d->m_buttons; | 610 | return *d->m_buttons; |
607 | } | 611 | } |
608 | 612 | ||
609 | /** | 613 | /** |
610 | * @return The amount of time that would count as a hold | 614 | * @return The amount of time that would count as a hold |
611 | */ | 615 | */ |
612 | uint ODevice::buttonHoldTime() const | 616 | uint ODevice::buttonHoldTime() const |
613 | { | 617 | { |
614 | return d->m_holdtime; | 618 | return d->m_holdtime; |
615 | } | 619 | } |
616 | 620 | ||
617 | /** | 621 | /** |
618 | * This method return a ODeviceButton for a key code | 622 | * This method return a ODeviceButton for a key code |
619 | * or 0 if no special hardware button is available for the device | 623 | * or 0 if no special hardware button is available for the device |
620 | * | 624 | * |
621 | * @return The devicebutton or 0l | 625 | * @return The devicebutton or 0l |
622 | * @see ODeviceButton | 626 | * @see ODeviceButton |
623 | */ | 627 | */ |
624 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 628 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
625 | { | 629 | { |
626 | initButtons(); | 630 | initButtons(); |
627 | 631 | ||
628 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { | 632 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { |
629 | if ( (*it). keycode() == code ) | 633 | if ( (*it). keycode() == code ) |
630 | return &(*it); | 634 | return &(*it); |
631 | } | 635 | } |
632 | return 0; | 636 | return 0; |
633 | } | 637 | } |
634 | 638 | ||
635 | void ODevice::reloadButtonMapping() | 639 | void ODevice::reloadButtonMapping() |
636 | { | 640 | { |
637 | initButtons(); | 641 | initButtons(); |
638 | 642 | ||
639 | Config cfg ( "ButtonSettings" ); | 643 | Config cfg ( "ButtonSettings" ); |
640 | 644 | ||
641 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 645 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
642 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 646 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
643 | QString group = "Button" + QString::number ( i ); | 647 | QString group = "Button" + QString::number ( i ); |
644 | 648 | ||
645 | QCString pch, hch; | 649 | QCString pch, hch; |
646 | QCString pm, hm; | 650 | QCString pm, hm; |
647 | QByteArray pdata, hdata; | 651 | QByteArray pdata, hdata; |
648 | 652 | ||
649 | if ( cfg. hasGroup ( group )) { | 653 | if ( cfg. hasGroup ( group )) { |
650 | cfg. setGroup ( group ); | 654 | cfg. setGroup ( group ); |
651 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); | 655 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); |
652 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); | 656 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); |
653 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 657 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
654 | 658 | ||
655 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); | 659 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); |
656 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); | 660 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); |
657 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 661 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
658 | } | 662 | } |
659 | 663 | ||
660 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 664 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
661 | 665 | ||
662 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 666 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
663 | } | 667 | } |
664 | } | 668 | } |
665 | 669 | ||
666 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 670 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
667 | { | 671 | { |
668 | initButtons(); | 672 | initButtons(); |
669 | 673 | ||
670 | QString mb_chan; | 674 | QString mb_chan; |
671 | 675 | ||
672 | if ( button >= (int) d->m_buttons->count()) | 676 | if ( button >= (int) d->m_buttons->count()) |
673 | return; | 677 | return; |
674 | 678 | ||
675 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 679 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
676 | b. setPressedAction ( action ); | 680 | b. setPressedAction ( action ); |
677 | 681 | ||
678 | mb_chan=b. pressedAction(). channel(); | 682 | mb_chan=b. pressedAction(). channel(); |
679 | 683 | ||
680 | Config buttonFile ( "ButtonSettings" ); | 684 | Config buttonFile ( "ButtonSettings" ); |
681 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 685 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
682 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 686 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
683 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 687 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
684 | 688 | ||
685 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 689 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
686 | 690 | ||
687 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 691 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
688 | } | 692 | } |
689 | 693 | ||
690 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 694 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
691 | { | 695 | { |
692 | initButtons(); | 696 | initButtons(); |
693 | 697 | ||
694 | if ( button >= (int) d->m_buttons->count()) | 698 | if ( button >= (int) d->m_buttons->count()) |
695 | return; | 699 | return; |
696 | 700 | ||
697 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 701 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
698 | b. setHeldAction ( action ); | 702 | b. setHeldAction ( action ); |
699 | 703 | ||
700 | Config buttonFile ( "ButtonSettings" ); | 704 | Config buttonFile ( "ButtonSettings" ); |
701 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 705 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
702 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 706 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
703 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 707 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
704 | 708 | ||
705 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 709 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
706 | 710 | ||
707 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 711 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
708 | } | 712 | } |
709 | void ODevice::virtual_hook(int, void* ){ | 713 | void ODevice::virtual_hook(int, void* ){ |
710 | 714 | ||
711 | } | 715 | } |
712 | 716 | ||
713 | /** | 717 | /** |
714 | * Sends a QCOP message to channel QPE/System | 718 | * Sends a QCOP message to channel QPE/System |
715 | * with the message "aboutToSuspend()" if this | 719 | * with the message "aboutToSuspend()" if this |
716 | * is the windowing server | 720 | * is the windowing server |
717 | */ | 721 | */ |
718 | void ODevice::sendSuspendmsg() | 722 | void ODevice::sendSuspendmsg() |
719 | { | 723 | { |
720 | if ( isQWS() ) | 724 | if ( isQWS() ) |
721 | return; | 725 | return; |
722 | 726 | ||
723 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 727 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
724 | } | 728 | } |
725 | 729 | ||
726 | /** | 730 | /** |
727 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters | 731 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters |
728 | * | 732 | * |
729 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard | 733 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard |
730 | * Filters. This function is the only way to prepend a KeyFilter. | 734 | * Filters. This function is the only way to prepend a KeyFilter. |
731 | * | 735 | * |
732 | * @param aFilter The KeyFilter to be prepended to the list of filters | 736 | * @param aFilter The KeyFilter to be prepended to the list of filters |
733 | * | 737 | * |
734 | * @see Opie::Core::OKeyFilter | 738 | * @see Opie::Core::OKeyFilter |
735 | * @see Opie::Core::OKeyFilter::inst() | 739 | * @see Opie::Core::OKeyFilter::inst() |
736 | */ | 740 | */ |
737 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 741 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) |
738 | { | 742 | { |
739 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); | 743 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); |
740 | } | 744 | } |
741 | 745 | ||
742 | /** | 746 | /** |
743 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list | 747 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list |
744 | * | 748 | * |
745 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List | 749 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List |
746 | * of Keyfilters. Call this when you delete the KeyFilter! | 750 | * of Keyfilters. Call this when you delete the KeyFilter! |
747 | * | 751 | * |
748 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter | 752 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter |
749 | * @see Opie::Core::ODevice::addPreHandler | 753 | * @see Opie::Core::ODevice::addPreHandler |
750 | */ | 754 | */ |
751 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 755 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) |
752 | { | 756 | { |
753 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); | 757 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); |
754 | } | 758 | } |
755 | 759 | ||
756 | void ODevice::playingStopped() { | 760 | void ODevice::playingStopped() { |
757 | const_cast<QObject*>(sender())->disconnect( this ); | 761 | const_cast<QObject*>(sender())->disconnect( this ); |
758 | #ifndef QT_NO_SOUND | 762 | #ifndef QT_NO_SOUND |
759 | if ( d->m_sound >= 0 ) { | 763 | if ( d->m_sound >= 0 ) { |
760 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); | 764 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); |
761 | ::close ( d->m_sound ); | 765 | ::close ( d->m_sound ); |
762 | } | 766 | } |
763 | #endif | 767 | #endif |
764 | } | 768 | } |
765 | 769 | ||
766 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { | 770 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { |
767 | #ifndef QT_NO_SOUND | 771 | #ifndef QT_NO_SOUND |
768 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { | 772 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { |
769 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { | 773 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { |
770 | Config cfg ( "qpe" ); | 774 | Config cfg ( "qpe" ); |
771 | cfg. setGroup ( "Volume" ); | 775 | cfg. setGroup ( "Volume" ); |
772 | 776 | ||
773 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 777 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
774 | if ( volalarm < 0 ) | 778 | if ( volalarm < 0 ) |
775 | volalarm = 0; | 779 | volalarm = 0; |
776 | else if ( volalarm > 100 ) | 780 | else if ( volalarm > 100 ) |
777 | volalarm = 100; | 781 | volalarm = 100; |
778 | volalarm |= ( volalarm << 8 ); | 782 | volalarm |= ( volalarm << 8 ); |
779 | 783 | ||
780 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) | 784 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) |
781 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); | 785 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); |
782 | } | 786 | } |
783 | d->m_mixer = mixer; | 787 | d->m_mixer = mixer; |
784 | } | 788 | } |
785 | #endif | 789 | #endif |
786 | } | 790 | } |
787 | 791 | ||
788 | } | 792 | } |
789 | } | 793 | } |