summaryrefslogtreecommitdiff
authorzecke <zecke>2004-08-25 21:51:13 (UTC)
committer zecke <zecke>2004-08-25 21:51:13 (UTC)
commitdf3e4c8b13c16aeb96e70dbaa2d409f83eed988e (patch) (unidiff)
tree59b12028c6e8a53b99f1686278b6e9fdc57ab18e
parente4811064703ad34f42f15c3044cd8f63c0e7583c (diff)
downloadopie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.zip
opie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.tar.gz
opie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.tar.bz2
-Have a common implementation for reading the config value
and setting the Mixer. The mixer, sound and path is configurable -Restore the Opie HEADER (who is guilty? probably me) -Fix warnings -Port Zaurus,Simpad,Ipaq to configure the mixer
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp57
-rw-r--r--libopie2/opiecore/device/odevice.h53
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp71
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp47
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h2
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp99
7 files changed, 157 insertions, 174 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index b58f9eb..26c6dca 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -45,6 +45,7 @@
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48#include <qpe/sound.h>
48#include <opie2/okeyfilter.h> 49#include <opie2/okeyfilter.h>
49 50
50/* STD */ 51/* STD */
@@ -171,6 +172,10 @@ ODevice::ODevice()
171 d->m_buttons = 0; 172 d->m_buttons = 0;
172 d->m_cpu_frequencies = new QStrList; 173 d->m_cpu_frequencies = new QStrList;
173 174
175
176 /* mixer */
177 d->m_sound = d->m_vol = d->m_mixer = -1;
178
174 // New distribution detection code first checks for legacy distributions, 179 // New distribution detection code first checks for legacy distributions,
175 // identified by /etc/familiar-version or /etc/oz_version. 180 // identified by /etc/familiar-version or /etc/oz_version.
176 // Then check for OpenEmbedded and lastly, read /etc/issue 181 // Then check for OpenEmbedded and lastly, read /etc/issue
@@ -705,6 +710,11 @@ void ODevice::virtual_hook(int, void* ){
705 710
706} 711}
707 712
713/**
714 * Sends a QCOP message to channel QPE/System
715 * with the message "aboutToSuspend()" if this
716 * is the windowing server
717 */
708void ODevice::sendSuspendmsg() 718void ODevice::sendSuspendmsg()
709{ 719{
710 if ( isQWS() ) 720 if ( isQWS() )
@@ -713,16 +723,63 @@ void ODevice::sendSuspendmsg()
713 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 723 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
714} 724}
715 725
726/**
727 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
728 *
729 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
730 * Filters. This function is the only way to prepend a KeyFilter.
731 *
732 * @param aFilter The KeyFilter to be prepended to the list of filters
733 *
734 * @see Opie::Core::OKeyFilter
735 * @see Opie::Core::OKeyFilter::inst()
736 */
716void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 737void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
717{ 738{
718 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 739 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
719} 740}
720 741
742/**
743 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
744 *
745 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
746 * of Keyfilters. Call this when you delete the KeyFilter!
747 *
748 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
749 * @see Opie::Core::ODevice::addPreHandler
750 */
721void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 751void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
722{ 752{
723 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 753 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
724} 754}
725 755
756void ODevice::playingStopped() {
757 const_cast<QObject*>(sender())->disconnect( this );
758 if ( d->m_sound >= 0 ) {
759 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
760 ::close ( d->m_sound );
761 }
762}
763
764void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
765 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
766 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
767 Config cfg ( "qpe" );
768 cfg. setGroup ( "Volume" );
769
770 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
771 if ( volalarm < 0 )
772 volalarm = 0;
773 else if ( volalarm > 100 )
774 volalarm = 100;
775 volalarm |= ( volalarm << 8 );
776
777 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
778 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
779 }
780 d->m_mixer = mixer;
781 }
782}
726 783
727} 784}
728} 785}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index cb7a83f..f4b3e0e 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,27 +1,27 @@
1/* 1/*
2 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6           .>+-=
7_;:, .> :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13 .%`+i> _;_. 13    .%`+i>       _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++= -. .` .: details. 20++=   -.     .`     .: details.
21: = ...= . :.=- 21 :     =  ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
@@ -38,9 +38,14 @@ _;:, .> :=|. This program is free software; you can
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41
42
41#include <qstrlist.h> 43#include <qstrlist.h>
42#include <qwindowsystem_qws.h> 44#include <qwindowsystem_qws.h>
43 45
46
47class Sound;
48
44namespace Opie{ 49namespace Opie{
45namespace Core{ 50namespace Core{
46 51
@@ -319,11 +324,14 @@ signals:
319 324
320private slots: 325private slots:
321 void systemMessage ( const QCString &, const QByteArray & ); 326 void systemMessage ( const QCString &, const QByteArray & );
327 void playingStopped();
322 328
323protected: 329protected:
324 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 330 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
325 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 331 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
326 void reloadButtonMapping(); 332 void reloadButtonMapping();
333 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
334
327 /* ugly virtual hook */ 335 /* ugly virtual hook */
328 virtual void virtual_hook( int id, void* data ); 336 virtual void virtual_hook( int id, void* data );
329}; 337};
@@ -348,6 +356,9 @@ class ODeviceData {
348 QValueList <ODeviceButton> *m_buttons; 356 QValueList <ODeviceButton> *m_buttons;
349 uint m_holdtime; 357 uint m_holdtime;
350 QStrList *m_cpu_frequencies; 358 QStrList *m_cpu_frequencies;
359
360 /* values for changeMixerForAlarm */
361 int m_sound, m_vol, m_mixer;
351}; 362};
352 363
353extern bool isQWS(); 364extern bool isQWS();
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 21fed99..7f5aa7b 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,27 +1,27 @@
1/* 1/*
2 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6           .>+-=
7_;:, .> :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13 .%`+i> _;_. 13    .%`+i>       _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++= -. .` .: details. 20++=   -.     .`     .: details.
21: = ...= . :.=- 21 :     =  ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
@@ -331,36 +331,9 @@ void iPAQ::playAlarmSound()
331{ 331{
332#ifndef QT_NO_SOUND 332#ifndef QT_NO_SOUND
333 static Sound snd ( "alarm" ); 333 static Sound snd ( "alarm" );
334 int fd;
335 int vol;
336 bool vol_reset = false;
337
338 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
339 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
340 Config cfg ( "qpe" );
341 cfg. setGroup ( "Volume" );
342
343 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
344 if ( volalarm < 0 )
345 volalarm = 0;
346 else if ( volalarm > 100 )
347 volalarm = 100;
348 volalarm |= ( volalarm << 8 );
349
350 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
351 vol_reset = true;
352 }
353 }
354 334
335 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
355 snd. play(); 336 snd. play();
356 while ( !snd. isFinished())
357 qApp->processEvents();
358
359 if ( fd >= 0 ) {
360 if ( vol_reset )
361 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
362 ::close ( fd );
363 }
364#endif 337#endif
365} 338}
366 339
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index c6de614..2d0160d 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -238,16 +238,17 @@ bool SIMpad::setLedState ( OLed l, OLedState st )
238 write to cs3 */ 238 write to cs3 */
239 m_leds [0] = st; 239 m_leds [0] = st;
240 return true; 240 return true;
241 } 241 // }
242 } 242// }
243 } 243#else
244 244 Q_UNUSED( l )
245 Q_UNUSED( st )
245#endif 246#endif
246 return false; 247 return false;
247} 248}
248 249
249 250
250bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 251bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ )
251{ 252{
252 //TODO 253 //TODO
253 return false; 254 return false;
@@ -266,36 +267,10 @@ void SIMpad::playAlarmSound()
266{ 267{
267#ifndef QT_NO_SOUND 268#ifndef QT_NO_SOUND
268 static Sound snd ( "alarm" ); 269 static Sound snd ( "alarm" );
269 int fd;
270 int vol;
271 bool vol_reset = false;
272
273 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
274 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
275 Config cfg ( "qpe" );
276 cfg. setGroup ( "Volume" );
277
278 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
279 if ( volalarm < 0 )
280 volalarm = 0;
281 else if ( volalarm > 100 )
282 volalarm = 100;
283 volalarm |= ( volalarm << 8 );
284
285 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
286 vol_reset = true;
287 }
288 }
289 270
271 /* save as the Sound is static! */
272 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
290 snd. play(); 273 snd. play();
291 while ( !snd. isFinished())
292 qApp->processEvents();
293
294 if ( fd >= 0 ) {
295 if ( vol_reset )
296 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
297 ::close ( fd );
298 }
299#endif 274#endif
300} 275}
301 276
@@ -335,14 +310,10 @@ bool SIMpad::setDisplayStatus ( bool on )
335{ 310{
336 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 311 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
337 312
338 bool res = false;
339 int fd;
340 313
341 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 314 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
342 315
343 res = ( ::system( (const char*) cmdline ) == 0 ); 316 return ( ::system( (const char*) cmdline ) == 0 );
344
345 return res;
346} 317}
347 318
348 319
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index d9ae5a5..6c42be7 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,6 +1,6 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2003, 2004 The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index 223aa76..a06d7ec 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -143,6 +143,8 @@ bool Yopy::setDisplayBrightness( int bright )
143 return true; 143 return true;
144 } 144 }
145 } 145 }
146#else
147 Q_UNUSED( bright )
146#endif 148#endif
147 return false; 149 return false;
148} 150}
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 47682bb..127fee9 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,27 +1,27 @@
1/* 1/*
2 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6           .>+-=
7_;:, .> :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13 .%`+i> _;_. 13    .%`+i>       _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++= -. .` .: details. 20++=   -.     .`     .: details.
21: = ...= . :.=- 21 :     =  ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
@@ -183,8 +183,6 @@ void Zaurus::init(const QString& cpu_info)
183 } 183 }
184 184
185 // set initial rotation 185 // set initial rotation
186
187 bool flipstate = false;
188 switch ( d->m_model ) { 186 switch ( d->m_model ) {
189 case Model_Zaurus_SL6000: 187 case Model_Zaurus_SL6000:
190 case Model_Zaurus_SLA300: 188 case Model_Zaurus_SLA300:
@@ -318,64 +316,35 @@ int status; /* set new led status if you call SHARP_LED_SETSTATUS */
318void Zaurus::buzzer ( int sound ) 316void Zaurus::buzzer ( int sound )
319{ 317{
320#ifndef QT_NO_SOUND 318#ifndef QT_NO_SOUND
321 QString soundname; 319 Sound *snd = 0;
322 320
323 // Not all devices have real sound 321 // Not all devices have real sound
324 if ( d->m_model == Model_Zaurus_SLC7x0 322 if ( d->m_model == Model_Zaurus_SLC7x0
325 || d->m_model == Model_Zaurus_SLB600 ){ 323 || d->m_model == Model_Zaurus_SLB600 ){
326 324
327 switch ( sound ){ 325 switch ( sound ){
328 case SHARP_BUZ_SCHEDULE_ALARM:
329 soundname = "alarm";
330 break;
331 case SHARP_BUZ_TOUCHSOUND: 326 case SHARP_BUZ_TOUCHSOUND:
332 soundname = "touchsound"; 327 static Sound touch_sound("touchsound");
328 snd = &touch_sound;
333 break; 329 break;
334 case SHARP_BUZ_KEYSOUND: 330 case SHARP_BUZ_KEYSOUND:
335 soundname = "keysound"; 331 static Sound key_sound( "keysound" );
332 snd = &key_sound;
336 break; 333 break;
334 case SHARP_BUZ_SCHEDULE_ALARM:
337 default: 335 default:
338 soundname = "alarm"; 336 static Sound alarm_sound("alarm");
339 337 snd = &alarm_sound;
338 break;
340 } 339 }
341 } 340 }
342 341
343 // If a soundname is defined, we expect that this device has 342 // If a soundname is defined, we expect that this device has
344 // sound capabilities.. Otherwise we expect to have the buzzer 343 // sound capabilities.. Otherwise we expect to have the buzzer
345 // device.. 344 // device..
346 if ( !soundname.isEmpty() ){ 345 if ( snd ){
347 int fd; 346 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
348 int vol; 347 snd-> play();
349 bool vol_reset = false;
350
351 Sound snd ( soundname );
352
353 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
354 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
355 Config cfg ( "qpe" );
356 cfg. setGroup ( "Volume" );
357
358 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
359 if ( volalarm < 0 )
360 volalarm = 0;
361 else if ( volalarm > 100 )
362 volalarm = 100;
363 volalarm |= ( volalarm << 8 );
364
365 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
366 vol_reset = true;
367 }
368 }
369
370 snd. play();
371 while ( !snd. isFinished())
372 qApp->processEvents();
373
374 if ( fd >= 0 ) {
375 if ( vol_reset )
376 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
377 ::close ( fd );
378 }
379 } else { 348 } else {
380 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 349 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
381 350
@@ -514,7 +483,7 @@ bool Zaurus::setDisplayBrightness ( int bright )
514 // special treatment for devices with the corgi backlight interface 483 // special treatment for devices with the corgi backlight interface
515 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 484 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
516 { 485 {
517 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 486 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
518 char writeCommand[100]; 487 char writeCommand[100];
519 const int count = sprintf( writeCommand, "0x%x\n", value ); 488 const int count = sprintf( writeCommand, "0x%x\n", value );
520 res = ( ::write ( fd, writeCommand, count ) != -1 ); 489 res = ( ::write ( fd, writeCommand, count ) != -1 );