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