Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index c6e031f..8f5be8b 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,820 +1,822 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> | 3 | =. (C) 2002-2006 The Opie Team <opie-devel@handhelds.org> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ._= =} : | 11 | ._= =} : |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | 30 | ||
31 | #include "odevice_beagle.h" | 31 | #include "odevice_beagle.h" |
32 | #include "odevice_ipaq.h" | 32 | #include "odevice_ipaq.h" |
33 | #include "odevice_mypal.h" | 33 | #include "odevice_mypal.h" |
34 | #include "odevice_jornada.h" | 34 | #include "odevice_jornada.h" |
35 | #include "odevice_ramses.h" | 35 | #include "odevice_ramses.h" |
36 | #include "odevice_simpad.h" | 36 | #include "odevice_simpad.h" |
37 | #include "odevice_yopy.h" | 37 | #include "odevice_yopy.h" |
38 | #include "odevice_zaurus.h" | 38 | #include "odevice_zaurus.h" |
39 | #include "odevice_genuineintel.h" | 39 | #include "odevice_genuineintel.h" |
40 | #include "odevice_htc.h" | 40 | #include "odevice_htc.h" |
41 | #include "odevice_motorola_ezx.h" | ||
41 | 42 | ||
42 | /* QT */ | 43 | /* QT */ |
43 | #include <qapplication.h> | 44 | #include <qapplication.h> |
44 | #include <qfile.h> | 45 | #include <qfile.h> |
45 | #include <qtextstream.h> | 46 | #include <qtextstream.h> |
46 | #include <qwindowsystem_qws.h> | 47 | #include <qwindowsystem_qws.h> |
47 | 48 | ||
48 | /* OPIE */ | 49 | /* OPIE */ |
49 | #include <qpe/config.h> | 50 | #include <qpe/config.h> |
50 | #include <qpe/sound.h> | 51 | #include <qpe/sound.h> |
51 | #include <qpe/qcopenvelope_qws.h> | 52 | #include <qpe/qcopenvelope_qws.h> |
52 | #include <qpe/sound.h> | 53 | #include <qpe/sound.h> |
53 | 54 | ||
54 | #include <opie2/okeyfilter.h> | 55 | #include <opie2/okeyfilter.h> |
55 | #include <opie2/oresource.h> | 56 | #include <opie2/oresource.h> |
56 | 57 | ||
57 | /* STD */ | 58 | /* STD */ |
58 | #include <fcntl.h> | 59 | #include <fcntl.h> |
59 | #include <math.h> | 60 | #include <math.h> |
60 | #include <stdlib.h> | 61 | #include <stdlib.h> |
61 | #include <signal.h> | 62 | #include <signal.h> |
62 | #include <sys/ioctl.h> | 63 | #include <sys/ioctl.h> |
63 | #include <sys/time.h> | 64 | #include <sys/time.h> |
64 | #include <unistd.h> | 65 | #include <unistd.h> |
65 | #ifndef QT_NO_SOUND | 66 | #ifndef QT_NO_SOUND |
66 | #include <linux/soundcard.h> | 67 | #include <linux/soundcard.h> |
67 | #endif | 68 | #endif |
68 | 69 | ||
69 | namespace Opie { | 70 | namespace Opie { |
70 | namespace Core { | 71 | namespace Core { |
71 | 72 | ||
72 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 73 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
73 | 74 | ||
74 | 75 | ||
75 | /* STATIC and common implementation */ | 76 | /* STATIC and common implementation */ |
76 | /* EXPORT */ ODistribution distributions[] = { | 77 | /* EXPORT */ ODistribution distributions[] = { |
77 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 78 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
78 | { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" }, | 79 | { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" }, |
79 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 80 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
80 | { System_Unknown, "Linux", "/etc/issue" }, | 81 | { System_Unknown, "Linux", "/etc/issue" }, |
81 | }; | 82 | }; |
82 | 83 | ||
83 | 84 | ||
84 | /* EXPORT */ bool isQWS(){ | 85 | /* EXPORT */ bool isQWS(){ |
85 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 86 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
86 | } | 87 | } |
87 | 88 | ||
88 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 89 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
89 | if ( str && !::strchr ( str, '/' )) | 90 | if ( str && !::strchr ( str, '/' )) |
90 | return QCString ( "QPE/Application/" ) + str; | 91 | return QCString ( "QPE/Application/" ) + str; |
91 | else | 92 | else |
92 | return str; | 93 | return str; |
93 | } | 94 | } |
94 | 95 | ||
95 | 96 | ||
96 | 97 | ||
97 | /* Now the default implementation of ODevice */ | 98 | /* Now the default implementation of ODevice */ |
98 | 99 | ||
99 | struct default_button default_buttons [] = { | 100 | struct default_button default_buttons [] = { |
100 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 101 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
101 | "devicebuttons/z_calendar", | 102 | "devicebuttons/z_calendar", |
102 | "datebook", "nextView()", | 103 | "datebook", "nextView()", |
103 | "today", "raise()" }, | 104 | "today", "raise()" }, |
104 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 105 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
105 | "devicebuttons/z_contact", | 106 | "devicebuttons/z_contact", |
106 | "addressbook", "raise()", | 107 | "addressbook", "raise()", |
107 | "addressbook", "beamBusinessCard()" }, | 108 | "addressbook", "beamBusinessCard()" }, |
108 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 109 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
109 | "devicebuttons/z_home", | 110 | "devicebuttons/z_home", |
110 | "QPE/Launcher", "home()", | 111 | "QPE/Launcher", "home()", |
111 | "buttonsettings", "raise()" }, | 112 | "buttonsettings", "raise()" }, |
112 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 113 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
113 | "devicebuttons/z_menu", | 114 | "devicebuttons/z_menu", |
114 | "QPE/TaskBar", "toggleMenu()", | 115 | "QPE/TaskBar", "toggleMenu()", |
115 | "QPE/TaskBar", "toggleStartMenu()" }, | 116 | "QPE/TaskBar", "toggleStartMenu()" }, |
116 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 117 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
117 | "devicebuttons/z_mail", | 118 | "devicebuttons/z_mail", |
118 | "opiemail", "raise()", | 119 | "opiemail", "raise()", |
119 | "opiemail", "newMail()" }, | 120 | "opiemail", "newMail()" }, |
120 | }; | 121 | }; |
121 | 122 | ||
122 | ODevice *ODevice::inst() | 123 | ODevice *ODevice::inst() |
123 | { | 124 | { |
124 | static ODevice *dev = 0; | 125 | static ODevice *dev = 0; |
125 | QString cpu_info; | 126 | QString cpu_info; |
126 | 127 | ||
127 | if ( !dev ) | 128 | if ( !dev ) |
128 | { | 129 | { |
129 | QFile f( PATH_PROC_CPUINFO ); | 130 | QFile f( PATH_PROC_CPUINFO ); |
130 | if ( f.open( IO_ReadOnly ) ) | 131 | if ( f.open( IO_ReadOnly ) ) |
131 | { | 132 | { |
132 | QTextStream s( &f ); | 133 | QTextStream s( &f ); |
133 | while ( !s.atEnd() ) | 134 | while ( !s.atEnd() ) |
134 | { | 135 | { |
135 | QString line; | 136 | QString line; |
136 | line = s.readLine(); | 137 | line = s.readLine(); |
137 | if ( line.startsWith( "Hardware" ) ) | 138 | if ( line.startsWith( "Hardware" ) ) |
138 | { | 139 | { |
139 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 140 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
140 | cpu_info = line; | 141 | cpu_info = line; |
141 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 142 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
142 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 143 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
143 | else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal(); | 144 | else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal(); |
144 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 145 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
145 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 146 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
146 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 147 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
147 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); | 148 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); |
148 | else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC(); | 149 | else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC(); |
150 | else if ( line.contains( "Motorola", false ) ) dev = new Internal::Motorola_EZX(); | ||
149 | 151 | ||
150 | else qWarning( "ODevice() - unknown hardware - using default." ); | 152 | else qWarning( "ODevice() - unknown hardware - using default." ); |
151 | break; | 153 | break; |
152 | } else if ( line.startsWith( "vendor_id" ) ) { | 154 | } else if ( line.startsWith( "vendor_id" ) ) { |
153 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 155 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
154 | cpu_info = line; | 156 | cpu_info = line; |
155 | if( line.contains( "genuineintel", false ) ) { | 157 | if( line.contains( "genuineintel", false ) ) { |
156 | dev = new Internal::GenuineIntel(); | 158 | dev = new Internal::GenuineIntel(); |
157 | break; | 159 | break; |
158 | } | 160 | } |
159 | } | 161 | } |
160 | } | 162 | } |
161 | } | 163 | } |
162 | else | 164 | else |
163 | { | 165 | { |
164 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 166 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
165 | } | 167 | } |
166 | if ( !dev ) dev = new ODevice(); | 168 | if ( !dev ) dev = new ODevice(); |
167 | dev->init(cpu_info); | 169 | dev->init(cpu_info); |
168 | } | 170 | } |
169 | return dev; | 171 | return dev; |
170 | } | 172 | } |
171 | 173 | ||
172 | ODevice::ODevice() | 174 | ODevice::ODevice() |
173 | { | 175 | { |
174 | d = new ODeviceData; | 176 | d = new ODeviceData; |
175 | 177 | ||
176 | d->m_modelstr = "Unknown"; | 178 | d->m_modelstr = "Unknown"; |
177 | d->m_model = Model_Unknown; | 179 | d->m_model = Model_Unknown; |
178 | d->m_vendorstr = "Unknown"; | 180 | d->m_vendorstr = "Unknown"; |
179 | d->m_vendor = Vendor_Unknown; | 181 | d->m_vendor = Vendor_Unknown; |
180 | d->m_systemstr = "Unknown"; | 182 | d->m_systemstr = "Unknown"; |
181 | d->m_system = System_Unknown; | 183 | d->m_system = System_Unknown; |
182 | d->m_sysverstr = "0.0"; | 184 | d->m_sysverstr = "0.0"; |
183 | d->m_rotation = Rot0; | 185 | d->m_rotation = Rot0; |
184 | d->m_direction = CW; | 186 | d->m_direction = CW; |
185 | d->m_qteDriver = "Transformed"; | 187 | d->m_qteDriver = "Transformed"; |
186 | 188 | ||
187 | d->m_holdtime = 1000; // 1000ms | 189 | d->m_holdtime = 1000; // 1000ms |
188 | d->m_buttons = 0; | 190 | d->m_buttons = 0; |
189 | d->m_cpu_frequencies = new QStrList; | 191 | d->m_cpu_frequencies = new QStrList; |
190 | 192 | ||
191 | 193 | ||
192 | /* mixer */ | 194 | /* mixer */ |
193 | d->m_sound = d->m_vol = d->m_mixer = -1; | 195 | d->m_sound = d->m_vol = d->m_mixer = -1; |
194 | 196 | ||
195 | /* System QCopChannel created */ | 197 | /* System QCopChannel created */ |
196 | d->m_initializedButtonQcop = false; | 198 | d->m_initializedButtonQcop = false; |
197 | 199 | ||
198 | // New distribution detection code first checks for legacy distributions, | 200 | // New distribution detection code first checks for legacy distributions, |
199 | // identified by /etc/familiar-version or /etc/oz_version. | 201 | // identified by /etc/familiar-version or /etc/oz_version. |
200 | // Then check for OpenEmbedded and lastly, read /etc/issue | 202 | // Then check for OpenEmbedded and lastly, read /etc/issue |
201 | 203 | ||
202 | for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) | 204 | for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) |
203 | { | 205 | { |
204 | if ( QFile::exists( distributions[i].sysvfile ) ) | 206 | if ( QFile::exists( distributions[i].sysvfile ) ) |
205 | { | 207 | { |
206 | d->m_systemstr = distributions[i].sysstr; | 208 | d->m_systemstr = distributions[i].sysstr; |
207 | d->m_system = distributions[i].system; | 209 | d->m_system = distributions[i].system; |
208 | d->m_sysverstr = "<Unknown>"; | 210 | d->m_sysverstr = "<Unknown>"; |
209 | QFile f( distributions[i].sysvfile ); | 211 | QFile f( distributions[i].sysvfile ); |
210 | if ( f.open( IO_ReadOnly ) ) | 212 | if ( f.open( IO_ReadOnly ) ) |
211 | { | 213 | { |
212 | QTextStream ts( &f ); | 214 | QTextStream ts( &f ); |
213 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 215 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
214 | } | 216 | } |
215 | break; | 217 | break; |
216 | } | 218 | } |
217 | } | 219 | } |
218 | } | 220 | } |
219 | 221 | ||
220 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 222 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
221 | { | 223 | { |
222 | if ( msg == "deviceButtonMappingChanged()" ) { | 224 | if ( msg == "deviceButtonMappingChanged()" ) { |
223 | reloadButtonMapping(); | 225 | reloadButtonMapping(); |
224 | } | 226 | } |
225 | } | 227 | } |
226 | 228 | ||
227 | void ODevice::init(const QString&) | 229 | void ODevice::init(const QString&) |
228 | { | 230 | { |
229 | } | 231 | } |
230 | 232 | ||
231 | /** | 233 | /** |
232 | * This method initialises the button mapping | 234 | * This method initialises the button mapping |
233 | */ | 235 | */ |
234 | void ODevice::initButtons() | 236 | void ODevice::initButtons() |
235 | { | 237 | { |
236 | if ( d->m_buttons ) | 238 | if ( d->m_buttons ) |
237 | return; | 239 | return; |
238 | 240 | ||
239 | qDebug ( "init Buttons" ); | 241 | qDebug ( "init Buttons" ); |
240 | d->m_buttons = new QValueList <ODeviceButton>; | 242 | d->m_buttons = new QValueList <ODeviceButton>; |
241 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 243 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
242 | default_button *db = default_buttons + i; | 244 | default_button *db = default_buttons + i; |
243 | ODeviceButton b; | 245 | ODeviceButton b; |
244 | b. setKeycode ( db->code ); | 246 | b. setKeycode ( db->code ); |
245 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 247 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
246 | b. setPixmap ( OResource::loadPixmap ( db->pix )); | 248 | b. setPixmap ( OResource::loadPixmap ( db->pix )); |
247 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 249 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
248 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 250 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
249 | d->m_buttons->append ( b ); | 251 | d->m_buttons->append ( b ); |
250 | } | 252 | } |
251 | 253 | ||
252 | reloadButtonMapping(); | 254 | reloadButtonMapping(); |
253 | } | 255 | } |
254 | 256 | ||
255 | ODevice::~ODevice() | 257 | ODevice::~ODevice() |
256 | { | 258 | { |
257 | // we leak m_devicebuttons and m_cpu_frequency | 259 | // we leak m_devicebuttons and m_cpu_frequency |
258 | // but it's a singleton and it is not so importantant | 260 | // but it's a singleton and it is not so importantant |
259 | // -zecke | 261 | // -zecke |
260 | delete d; | 262 | delete d; |
261 | } | 263 | } |
262 | 264 | ||
263 | /** | 265 | /** |
264 | * This method will try to suspend the device | 266 | * This method will try to suspend the device |
265 | * It only works if the user is the QWS Server and the apm application | 267 | * It only works if the user is the QWS Server and the apm application |
266 | * is installed. | 268 | * is installed. |
267 | * It tries to suspend and then waits some time cause some distributions | 269 | * It tries to suspend and then waits some time cause some distributions |
268 | * do have asynchronus apm implementations. | 270 | * do have asynchronus apm implementations. |
269 | * This method will either fail and return false or it'll suspend the | 271 | * This method will either fail and return false or it'll suspend the |
270 | * device and return once the device got woken up | 272 | * device and return once the device got woken up |
271 | * | 273 | * |
272 | * @return if the device got suspended | 274 | * @return if the device got suspended |
273 | */ | 275 | */ |
274 | bool ODevice::suspend() | 276 | bool ODevice::suspend() |
275 | { | 277 | { |
276 | return false; // default implementation == unknown device or qvfb | 278 | return false; // default implementation == unknown device or qvfb |
277 | } | 279 | } |
278 | 280 | ||
279 | /** | 281 | /** |
280 | * This sets the display on or off | 282 | * This sets the display on or off |
281 | */ | 283 | */ |
282 | bool ODevice::setDisplayStatus( bool on ) | 284 | bool ODevice::setDisplayStatus( bool on ) |
283 | { | 285 | { |
284 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); | 286 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); |
285 | return false; // don't do anything for unknown models | 287 | return false; // don't do anything for unknown models |
286 | } | 288 | } |
287 | 289 | ||
288 | /** | 290 | /** |
289 | * This sets the display brightness | 291 | * This sets the display brightness |
290 | * | 292 | * |
291 | * @param b The brightness to be set on a scale from 0 to 255 | 293 | * @param b The brightness to be set on a scale from 0 to 255 |
292 | * @return success or failure | 294 | * @return success or failure |
293 | */ | 295 | */ |
294 | bool ODevice::setDisplayBrightness( int b ) | 296 | bool ODevice::setDisplayBrightness( int b ) |
295 | { | 297 | { |
296 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); | 298 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); |
297 | return false; | 299 | return false; |
298 | } | 300 | } |
299 | 301 | ||
300 | /** | 302 | /** |
301 | * | 303 | * |
302 | * @returns the number of steppings on the brightness slider | 304 | * @returns the number of steppings on the brightness slider |
303 | * in the Light-'n-Power settings. Values smaller than zero and bigger | 305 | * in the Light-'n-Power settings. Values smaller than zero and bigger |
304 | * than 255 do not make sense. | 306 | * than 255 do not make sense. |
305 | * | 307 | * |
306 | * \sa QSlider::setLineStep | 308 | * \sa QSlider::setLineStep |
307 | * \sa QSlider::setPageStep | 309 | * \sa QSlider::setPageStep |
308 | */ | 310 | */ |
309 | int ODevice::displayBrightnessResolution() const | 311 | int ODevice::displayBrightnessResolution() const |
310 | { | 312 | { |
311 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | 313 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); |
312 | return 16; | 314 | return 16; |
313 | } | 315 | } |
314 | 316 | ||
315 | /** | 317 | /** |
316 | * This sets the display contrast | 318 | * This sets the display contrast |
317 | * @param p The contrast to be set on a scale from 0 to 255 | 319 | * @param p The contrast to be set on a scale from 0 to 255 |
318 | * @returns success or failure | 320 | * @returns success or failure |
319 | */ | 321 | */ |
320 | bool ODevice::setDisplayContrast( int p ) | 322 | bool ODevice::setDisplayContrast( int p ) |
321 | { | 323 | { |
322 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); | 324 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); |
323 | return false; | 325 | return false; |
324 | } | 326 | } |
325 | 327 | ||
326 | /** | 328 | /** |
327 | * @returns the maximum value for the contrast settings slider | 329 | * @returns the maximum value for the contrast settings slider |
328 | * or 0 if the device doesn't support setting of a contrast | 330 | * or 0 if the device doesn't support setting of a contrast |
329 | */ | 331 | */ |
330 | int ODevice::displayContrastResolution() const | 332 | int ODevice::displayContrastResolution() const |
331 | { | 333 | { |
332 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | 334 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); |
333 | return 0; | 335 | return 0; |
334 | } | 336 | } |
335 | 337 | ||
336 | /** | 338 | /** |
337 | * This returns the vendor as string | 339 | * This returns the vendor as string |
338 | * @return Vendor as QString | 340 | * @return Vendor as QString |
339 | */ | 341 | */ |
340 | QString ODevice::vendorString() const | 342 | QString ODevice::vendorString() const |
341 | { | 343 | { |
342 | return d->m_vendorstr; | 344 | return d->m_vendorstr; |
343 | } | 345 | } |
344 | 346 | ||
345 | /** | 347 | /** |
346 | * This returns the vendor as one of the values of OVendor | 348 | * This returns the vendor as one of the values of OVendor |
347 | * @return OVendor | 349 | * @return OVendor |
348 | */ | 350 | */ |
349 | OVendor ODevice::vendor() const | 351 | OVendor ODevice::vendor() const |
350 | { | 352 | { |
351 | return d->m_vendor; | 353 | return d->m_vendor; |
352 | } | 354 | } |
353 | 355 | ||
354 | /** | 356 | /** |
355 | * This returns the model as a string | 357 | * This returns the model as a string |
356 | * @return A string representing the model | 358 | * @return A string representing the model |
357 | */ | 359 | */ |
358 | QString ODevice::modelString() const | 360 | QString ODevice::modelString() const |
359 | { | 361 | { |
360 | return d->m_modelstr; | 362 | return d->m_modelstr; |
361 | } | 363 | } |
362 | 364 | ||
363 | /** | 365 | /** |
364 | * This does return the OModel used | 366 | * This does return the OModel used |
365 | */ | 367 | */ |
366 | OModel ODevice::model() const | 368 | OModel ODevice::model() const |
367 | { | 369 | { |
368 | return d->m_model; | 370 | return d->m_model; |
369 | } | 371 | } |
370 | 372 | ||
371 | /** | 373 | /** |
372 | * This does return the systen name | 374 | * This does return the systen name |
373 | */ | 375 | */ |
374 | QString ODevice::systemString() const | 376 | QString ODevice::systemString() const |
375 | { | 377 | { |
376 | return d->m_systemstr; | 378 | return d->m_systemstr; |
377 | } | 379 | } |
378 | 380 | ||
379 | /** | 381 | /** |
380 | * Return System as OSystem value | 382 | * Return System as OSystem value |
381 | */ | 383 | */ |
382 | OSystem ODevice::system() const | 384 | OSystem ODevice::system() const |
383 | { | 385 | { |
384 | return d->m_system; | 386 | return d->m_system; |
385 | } | 387 | } |
386 | 388 | ||
387 | /** | 389 | /** |
388 | * @return the version string of the base system | 390 | * @return the version string of the base system |
389 | */ | 391 | */ |
390 | QString ODevice::systemVersionString() const | 392 | QString ODevice::systemVersionString() const |
391 | { | 393 | { |
392 | return d->m_sysverstr; | 394 | return d->m_sysverstr; |
393 | } | 395 | } |
394 | 396 | ||
395 | /** | 397 | /** |
396 | * @return the current Transformation | 398 | * @return the current Transformation |
397 | */ | 399 | */ |
398 | Transformation ODevice::rotation() const | 400 | Transformation ODevice::rotation() const |
399 | { | 401 | { |
400 | return d->m_rotation; | 402 | return d->m_rotation; |
401 | } | 403 | } |
402 | 404 | ||
403 | /** | 405 | /** |
404 | * @return the current rotation direction | 406 | * @return the current rotation direction |
405 | */ | 407 | */ |
406 | ODirection ODevice::direction() const | 408 | ODirection ODevice::direction() const |
407 | { | 409 | { |
408 | return d->m_direction; | 410 | return d->m_direction; |
409 | } | 411 | } |
410 | 412 | ||
411 | QString ODevice::qteDriver() const | 413 | QString ODevice::qteDriver() const |
412 | { | 414 | { |
413 | return d->m_qteDriver; | 415 | return d->m_qteDriver; |
414 | } | 416 | } |
415 | 417 | ||
416 | /** | 418 | /** |
417 | * This plays an alarm sound | 419 | * This plays an alarm sound |
418 | */ | 420 | */ |
419 | void ODevice::playAlarmSound() | 421 | void ODevice::playAlarmSound() |
420 | { | 422 | { |
421 | #ifndef QT_NO_SOUND | 423 | #ifndef QT_NO_SOUND |
422 | static Sound snd ( "alarm" ); | 424 | static Sound snd ( "alarm" ); |
423 | 425 | ||
424 | if ( snd. isFinished()) | 426 | if ( snd. isFinished()) |
425 | snd. play(); | 427 | snd. play(); |
426 | #endif | 428 | #endif |
427 | } | 429 | } |
428 | 430 | ||
429 | /** | 431 | /** |
430 | * This plays a key sound | 432 | * This plays a key sound |
431 | */ | 433 | */ |
432 | void ODevice::playKeySound() | 434 | void ODevice::playKeySound() |
433 | { | 435 | { |
434 | #ifndef QT_NO_SOUND | 436 | #ifndef QT_NO_SOUND |
435 | static Sound snd ( "keysound" ); | 437 | static Sound snd ( "keysound" ); |
436 | 438 | ||
437 | if ( snd. isFinished()) | 439 | if ( snd. isFinished()) |
438 | snd. play(); | 440 | snd. play(); |
439 | #endif | 441 | #endif |
440 | } | 442 | } |
441 | 443 | ||
442 | /** | 444 | /** |
443 | * This plays a touch sound | 445 | * This plays a touch sound |
444 | */ | 446 | */ |
445 | void ODevice::playTouchSound() | 447 | void ODevice::playTouchSound() |
446 | { | 448 | { |
447 | #ifndef QT_NO_SOUND | 449 | #ifndef QT_NO_SOUND |
448 | static Sound snd ( "touchsound" ); | 450 | static Sound snd ( "touchsound" ); |
449 | 451 | ||
450 | if ( snd. isFinished()) | 452 | if ( snd. isFinished()) |
451 | snd. play(); | 453 | snd. play(); |
452 | #endif | 454 | #endif |
453 | } | 455 | } |
454 | 456 | ||
455 | /** | 457 | /** |
456 | * This method will return a list of leds | 458 | * This method will return a list of leds |
457 | * available on this device | 459 | * available on this device |
458 | * @return a list of LEDs. | 460 | * @return a list of LEDs. |
459 | */ | 461 | */ |
460 | QValueList <OLed> ODevice::ledList() const | 462 | QValueList <OLed> ODevice::ledList() const |
461 | { | 463 | { |
462 | return QValueList <OLed>(); | 464 | return QValueList <OLed>(); |
463 | } | 465 | } |
464 | 466 | ||
465 | /** | 467 | /** |
466 | * This does return the state of the LEDs | 468 | * This does return the state of the LEDs |
467 | */ | 469 | */ |
468 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 470 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
469 | { | 471 | { |
470 | return QValueList <OLedState>(); | 472 | return QValueList <OLedState>(); |
471 | } | 473 | } |
472 | 474 | ||
473 | /** | 475 | /** |
474 | * @return the state for a given OLed | 476 | * @return the state for a given OLed |
475 | */ | 477 | */ |
476 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 478 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
477 | { | 479 | { |
478 | return Led_Off; | 480 | return Led_Off; |
479 | } | 481 | } |
480 | 482 | ||
481 | /** | 483 | /** |
482 | * Set the state for a LED | 484 | * Set the state for a LED |
483 | * @param which Which OLed to use | 485 | * @param which Which OLed to use |
484 | * @param st The state to set | 486 | * @param st The state to set |
485 | * @return success or failure | 487 | * @return success or failure |
486 | */ | 488 | */ |
487 | bool ODevice::setLedState ( OLed which, OLedState st ) | 489 | bool ODevice::setLedState ( OLed which, OLedState st ) |
488 | { | 490 | { |
489 | Q_UNUSED( which ) | 491 | Q_UNUSED( which ) |
490 | Q_UNUSED( st ) | 492 | Q_UNUSED( st ) |
491 | return false; | 493 | return false; |
492 | } | 494 | } |
493 | 495 | ||
494 | /** | 496 | /** |
495 | * @return if the device has a light sensor | 497 | * @return if the device has a light sensor |
496 | */ | 498 | */ |
497 | bool ODevice::hasLightSensor() const | 499 | bool ODevice::hasLightSensor() const |
498 | { | 500 | { |
499 | return false; | 501 | return false; |
500 | } | 502 | } |
501 | 503 | ||
502 | /** | 504 | /** |
503 | * @return a value from the light sensor | 505 | * @return a value from the light sensor |
504 | */ | 506 | */ |
505 | int ODevice::readLightSensor() | 507 | int ODevice::readLightSensor() |
506 | { | 508 | { |
507 | return -1; | 509 | return -1; |
508 | } | 510 | } |
509 | 511 | ||
510 | /** | 512 | /** |
511 | * @return the light sensor resolution | 513 | * @return the light sensor resolution |
512 | */ | 514 | */ |
513 | int ODevice::lightSensorResolution() const | 515 | int ODevice::lightSensorResolution() const |
514 | { | 516 | { |
515 | return 0; | 517 | return 0; |
516 | } | 518 | } |
517 | 519 | ||
518 | /** | 520 | /** |
519 | * @return if the device has a hinge sensor | 521 | * @return if the device has a hinge sensor |
520 | */ | 522 | */ |
521 | bool ODevice::hasHingeSensor() const | 523 | bool ODevice::hasHingeSensor() const |
522 | { | 524 | { |
523 | return false; | 525 | return false; |
524 | } | 526 | } |
525 | 527 | ||
526 | /** | 528 | /** |
527 | * @return a value from the hinge sensor | 529 | * @return a value from the hinge sensor |
528 | */ | 530 | */ |
529 | OHingeStatus ODevice::readHingeSensor()const | 531 | OHingeStatus ODevice::readHingeSensor()const |
530 | { | 532 | { |
531 | return CASE_UNKNOWN; | 533 | return CASE_UNKNOWN; |
532 | } | 534 | } |
533 | 535 | ||
534 | /** | 536 | /** |
535 | * @return a list with CPU frequencies supported by the hardware | 537 | * @return a list with CPU frequencies supported by the hardware |
536 | */ | 538 | */ |
537 | const QStrList &ODevice::allowedCpuFrequencies() const | 539 | const QStrList &ODevice::allowedCpuFrequencies() const |
538 | { | 540 | { |
539 | return *d->m_cpu_frequencies; | 541 | return *d->m_cpu_frequencies; |
540 | } | 542 | } |
541 | 543 | ||
542 | 544 | ||
543 | /** | 545 | /** |
544 | * Set desired CPU frequency | 546 | * Set desired CPU frequency |
545 | * | 547 | * |
546 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 548 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
547 | */ | 549 | */ |
548 | bool ODevice::setCurrentCpuFrequency(uint index) | 550 | bool ODevice::setCurrentCpuFrequency(uint index) |
549 | { | 551 | { |
550 | if (index >= d->m_cpu_frequencies->count()) | 552 | if (index >= d->m_cpu_frequencies->count()) |
551 | return false; | 553 | return false; |
552 | 554 | ||
553 | char *freq = d->m_cpu_frequencies->at(index); | 555 | char *freq = d->m_cpu_frequencies->at(index); |
554 | qWarning("set freq to %s", freq); | 556 | qWarning("set freq to %s", freq); |
555 | 557 | ||
556 | int fd; | 558 | int fd; |
557 | 559 | ||
558 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 560 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
559 | char writeCommand[50]; | 561 | char writeCommand[50]; |
560 | const int count = sprintf(writeCommand, "%s\n", freq); | 562 | const int count = sprintf(writeCommand, "%s\n", freq); |
561 | int res = (::write(fd, writeCommand, count) != -1); | 563 | int res = (::write(fd, writeCommand, count) != -1); |
562 | ::close(fd); | 564 | ::close(fd); |
563 | return res; | 565 | return res; |
564 | } | 566 | } |
565 | 567 | ||
566 | return false; | 568 | return false; |
567 | } | 569 | } |
568 | 570 | ||
569 | 571 | ||
570 | /** | 572 | /** |
571 | * @return a list of hardware buttons | 573 | * @return a list of hardware buttons |
572 | */ | 574 | */ |
573 | const QValueList <ODeviceButton> &ODevice::buttons() | 575 | const QValueList <ODeviceButton> &ODevice::buttons() |
574 | { | 576 | { |
575 | initButtons(); | 577 | initButtons(); |
576 | 578 | ||
577 | return *d->m_buttons; | 579 | return *d->m_buttons; |
578 | } | 580 | } |
579 | 581 | ||
580 | /** | 582 | /** |
581 | * @return The amount of time that would count as a hold | 583 | * @return The amount of time that would count as a hold |
582 | */ | 584 | */ |
583 | uint ODevice::buttonHoldTime() const | 585 | uint ODevice::buttonHoldTime() const |
584 | { | 586 | { |
585 | return d->m_holdtime; | 587 | return d->m_holdtime; |
586 | } | 588 | } |
587 | 589 | ||
588 | /** | 590 | /** |
589 | * This method return a ODeviceButton for a key code | 591 | * This method return a ODeviceButton for a key code |
590 | * or 0 if no special hardware button is available for the device | 592 | * or 0 if no special hardware button is available for the device |
591 | * | 593 | * |
592 | * @return The devicebutton or 0l | 594 | * @return The devicebutton or 0l |
593 | * @see ODeviceButton | 595 | * @see ODeviceButton |
594 | */ | 596 | */ |
595 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 597 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
596 | { | 598 | { |
597 | initButtons(); | 599 | initButtons(); |
598 | 600 | ||
599 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { | 601 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { |
600 | if ( (*it).keycode() == code ) | 602 | if ( (*it).keycode() == code ) |
601 | return &(*it); | 603 | return &(*it); |
602 | } | 604 | } |
603 | return 0; | 605 | return 0; |
604 | } | 606 | } |
605 | 607 | ||
606 | void ODevice::reloadButtonMapping() | 608 | void ODevice::reloadButtonMapping() |
607 | { | 609 | { |
608 | if(!d->m_buttons) | 610 | if(!d->m_buttons) |
609 | initButtons(); | 611 | initButtons(); |
610 | 612 | ||
611 | if(!d->m_initializedButtonQcop) { | 613 | if(!d->m_initializedButtonQcop) { |
612 | QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); | 614 | QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); |
613 | connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), | 615 | connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), |
614 | this,SLOT(systemMessage(const QCString&,const QByteArray&))); | 616 | this,SLOT(systemMessage(const QCString&,const QByteArray&))); |
615 | d->m_initializedButtonQcop = true; | 617 | d->m_initializedButtonQcop = true; |
616 | } | 618 | } |
617 | 619 | ||
618 | Config cfg ( "ButtonSettings" ); | 620 | Config cfg ( "ButtonSettings" ); |
619 | 621 | ||
620 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 622 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
621 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 623 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
622 | QString group = "Button" + QString::number ( i ); | 624 | QString group = "Button" + QString::number ( i ); |
623 | 625 | ||
624 | QCString pch, hch; | 626 | QCString pch, hch; |
625 | QCString pm, hm; | 627 | QCString pm, hm; |
626 | QByteArray pdata, hdata; | 628 | QByteArray pdata, hdata; |
627 | 629 | ||
628 | if ( cfg. hasGroup ( group )) { | 630 | if ( cfg. hasGroup ( group )) { |
629 | cfg. setGroup ( group ); | 631 | cfg. setGroup ( group ); |
630 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); | 632 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); |
631 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); | 633 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); |
632 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 634 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
633 | 635 | ||
634 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); | 636 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); |
635 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); | 637 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); |
636 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 638 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
637 | } | 639 | } |
638 | 640 | ||
639 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 641 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
640 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 642 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
641 | } | 643 | } |
642 | } | 644 | } |
643 | 645 | ||
644 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 646 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
645 | { | 647 | { |
646 | initButtons(); | 648 | initButtons(); |
647 | 649 | ||
648 | QString mb_chan; | 650 | QString mb_chan; |
649 | 651 | ||
650 | if ( button >= (int) d->m_buttons->count()) | 652 | if ( button >= (int) d->m_buttons->count()) |
651 | return; | 653 | return; |
652 | 654 | ||
653 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 655 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
654 | b. setPressedAction ( action ); | 656 | b. setPressedAction ( action ); |
655 | 657 | ||
656 | mb_chan=b. pressedAction(). channel(); | 658 | mb_chan=b. pressedAction(). channel(); |
657 | 659 | ||
658 | Config buttonFile ( "ButtonSettings" ); | 660 | Config buttonFile ( "ButtonSettings" ); |
659 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 661 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
660 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 662 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
661 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 663 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
662 | 664 | ||
663 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 665 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
664 | 666 | ||
665 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 667 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
666 | } | 668 | } |
667 | 669 | ||
668 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 670 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
669 | { | 671 | { |
670 | initButtons(); | 672 | initButtons(); |
671 | 673 | ||
672 | if ( button >= (int) d->m_buttons->count()) | 674 | if ( button >= (int) d->m_buttons->count()) |
673 | return; | 675 | return; |
674 | 676 | ||
675 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 677 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
676 | b. setHeldAction ( action ); | 678 | b. setHeldAction ( action ); |
677 | 679 | ||
678 | Config buttonFile ( "ButtonSettings" ); | 680 | Config buttonFile ( "ButtonSettings" ); |
679 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 681 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
680 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 682 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
681 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 683 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
682 | 684 | ||
683 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 685 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
684 | 686 | ||
685 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 687 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
686 | } | 688 | } |
687 | 689 | ||
688 | /** | 690 | /** |
689 | * @internal | 691 | * @internal |
690 | */ | 692 | */ |
691 | void ODevice::virtual_hook(int, void* ){ | 693 | void ODevice::virtual_hook(int, void* ){ |
692 | 694 | ||
693 | } | 695 | } |
694 | 696 | ||
695 | /** | 697 | /** |
696 | * \brief Send a QCOP Message before suspending | 698 | * \brief Send a QCOP Message before suspending |
697 | * | 699 | * |
698 | * Sends a QCOP message to channel QPE/System | 700 | * Sends a QCOP message to channel QPE/System |
699 | * with the message "aboutToSuspend()" if this | 701 | * with the message "aboutToSuspend()" if this |
700 | * is the windowing server. | 702 | * is the windowing server. |
701 | * | 703 | * |
702 | * Call this in your custom \sa suspend() Method | 704 | * Call this in your custom \sa suspend() Method |
703 | * before going to suspend. | 705 | * before going to suspend. |
704 | * | 706 | * |
705 | */ | 707 | */ |
706 | void ODevice::sendSuspendmsg() | 708 | void ODevice::sendSuspendmsg() |
707 | { | 709 | { |
708 | if ( !isQWS() ) | 710 | if ( !isQWS() ) |
709 | return; | 711 | return; |
710 | 712 | ||
711 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 713 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
712 | } | 714 | } |
713 | 715 | ||
714 | /** | 716 | /** |
715 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters | 717 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters |
716 | * | 718 | * |
717 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard | 719 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard |
718 | * Filters. This function is the only way to prepend a KeyFilter. | 720 | * Filters. This function is the only way to prepend a KeyFilter. |
719 | * | 721 | * |
720 | * @param aFilter The KeyFilter to be prepended to the list of filters | 722 | * @param aFilter The KeyFilter to be prepended to the list of filters |
721 | * | 723 | * |
722 | * @see Opie::Core::OKeyFilter | 724 | * @see Opie::Core::OKeyFilter |
723 | * @see Opie::Core::OKeyFilter::inst() | 725 | * @see Opie::Core::OKeyFilter::inst() |
724 | */ | 726 | */ |
725 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 727 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) |
726 | { | 728 | { |
727 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); | 729 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); |
728 | } | 730 | } |
729 | 731 | ||
730 | /** | 732 | /** |
731 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list | 733 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list |
732 | * | 734 | * |
733 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List | 735 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List |
734 | * of Keyfilters. Call this when you delete the KeyFilter! | 736 | * of Keyfilters. Call this when you delete the KeyFilter! |
735 | * | 737 | * |
736 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter | 738 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter |
737 | * @see Opie::Core::ODevice::addPreHandler | 739 | * @see Opie::Core::ODevice::addPreHandler |
738 | */ | 740 | */ |
739 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 741 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) |
740 | { | 742 | { |
741 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); | 743 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); |
742 | } | 744 | } |
743 | 745 | ||
744 | 746 | ||
745 | /** | 747 | /** |
746 | * @internal | 748 | * @internal |
747 | * | 749 | * |
748 | * @see changeMixerForAlarm | 750 | * @see changeMixerForAlarm |
749 | */ | 751 | */ |
750 | void ODevice::playingStopped() { | 752 | void ODevice::playingStopped() { |
751 | if ( sender() ) | 753 | if ( sender() ) |
752 | const_cast<QObject*>(sender())->disconnect( this ); | 754 | const_cast<QObject*>(sender())->disconnect( this ); |
753 | 755 | ||
754 | #ifndef QT_NO_SOUND | 756 | #ifndef QT_NO_SOUND |
755 | if ( d->m_sound >= 0 ) { | 757 | if ( d->m_sound >= 0 ) { |
756 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); | 758 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); |
757 | ::close ( d->m_sound ); | 759 | ::close ( d->m_sound ); |
758 | } | 760 | } |
759 | #endif | 761 | #endif |
760 | } | 762 | } |
761 | 763 | ||
762 | 764 | ||
763 | /** | 765 | /** |
764 | * \brief Change the Volume for the Alarm and set it back after playing is finished | 766 | * \brief Change the Volume for the Alarm and set it back after playing is finished |
765 | * | 767 | * |
766 | * If you play an Alarm Sound you might want to change the Mixer to | 768 | * If you play an Alarm Sound you might want to change the Mixer to |
767 | * full volume and ignore the user setting. After it \sa Sound::isFinished | 769 | * full volume and ignore the user setting. After it \sa Sound::isFinished |
768 | * you would turn the volume back to the user preference. | 770 | * you would turn the volume back to the user preference. |
769 | * The problem is that we used to enter the event loop while waiting | 771 | * The problem is that we used to enter the event loop while waiting |
770 | * for the sound to be finished triggering all kind of reentrance | 772 | * for the sound to be finished triggering all kind of reentrance |
771 | * problems what a library shouldn't introduce. | 773 | * problems what a library shouldn't introduce. |
772 | * Instead of manually waiting for the sound to be finished use | 774 | * Instead of manually waiting for the sound to be finished use |
773 | * this Method and it will automatically restore the Mixer to | 775 | * this Method and it will automatically restore the Mixer to |
774 | * the user configuration after the sound finished playing. | 776 | * the user configuration after the sound finished playing. |
775 | * | 777 | * |
776 | * Note: The onwership of \param snd is not transfered and playing | 778 | * Note: The onwership of \param snd is not transfered and playing |
777 | * is not started in this method. If 'snd' gets deleted before | 779 | * is not started in this method. If 'snd' gets deleted before |
778 | * playing is finished the volume doesn't get set back to | 780 | * playing is finished the volume doesn't get set back to |
779 | * the user preference! | 781 | * the user preference! |
780 | * | 782 | * |
781 | * \code | 783 | * \code |
782 | * static Sound snd("alarm"); | 784 | * static Sound snd("alarm"); |
783 | * if(!snd.isFinished()) | 785 | * if(!snd.isFinished()) |
784 | * return; | 786 | * return; |
785 | * | 787 | * |
786 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); | 788 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); |
787 | * snd.play() | 789 | * snd.play() |
788 | * \endcode | 790 | * \endcode |
789 | * | 791 | * |
790 | * | 792 | * |
791 | * | 793 | * |
792 | * @param mixer The mixer number/channel to use | 794 | * @param mixer The mixer number/channel to use |
793 | * @param file The file name. If you convert from QString use QFile::encodeName | 795 | * @param file The file name. If you convert from QString use QFile::encodeName |
794 | * @param snd The sound to wait for finishing | 796 | * @param snd The sound to wait for finishing |
795 | * | 797 | * |
796 | */ | 798 | */ |
797 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { | 799 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { |
798 | #ifndef QT_NO_SOUND | 800 | #ifndef QT_NO_SOUND |
799 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { | 801 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { |
800 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { | 802 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { |
801 | Config cfg ( "qpe" ); | 803 | Config cfg ( "qpe" ); |
802 | cfg. setGroup ( "Volume" ); | 804 | cfg. setGroup ( "Volume" ); |
803 | 805 | ||
804 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 806 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
805 | if ( volalarm < 0 ) | 807 | if ( volalarm < 0 ) |
806 | volalarm = 0; | 808 | volalarm = 0; |
807 | else if ( volalarm > 100 ) | 809 | else if ( volalarm > 100 ) |
808 | volalarm = 100; | 810 | volalarm = 100; |
809 | volalarm |= ( volalarm << 8 ); | 811 | volalarm |= ( volalarm << 8 ); |
810 | 812 | ||
811 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) | 813 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) |
812 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); | 814 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); |
813 | } | 815 | } |
814 | d->m_mixer = mixer; | 816 | d->m_mixer = mixer; |
815 | } | 817 | } |
816 | #endif | 818 | #endif |
817 | } | 819 | } |
818 | 820 | ||
819 | } | 821 | } |
820 | } | 822 | } |