summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp57
-rw-r--r--libopie2/opiecore/device/odevice.h55
-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, 158 insertions, 175 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
@@ -47,2 +47,3 @@
#include <qpe/qcopenvelope_qws.h>
+#include <qpe/sound.h>
#include <opie2/okeyfilter.h>
@@ -173,2 +174,6 @@ ODevice::ODevice()
+
+ /* mixer */
+ d->m_sound = d->m_vol = d->m_mixer = -1;
+
// New distribution detection code first checks for legacy distributions,
@@ -707,2 +712,7 @@ void ODevice::virtual_hook(int, void* ){
+/**
+ * Sends a QCOP message to channel QPE/System
+ * with the message "aboutToSuspend()" if this
+ * is the windowing server
+ */
void ODevice::sendSuspendmsg()
@@ -715,2 +725,13 @@ void ODevice::sendSuspendmsg()
+/**
+ * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
+ *
+ * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
+ * Filters. This function is the only way to prepend a KeyFilter.
+ *
+ * @param aFilter The KeyFilter to be prepended to the list of filters
+ *
+ * @see Opie::Core::OKeyFilter
+ * @see Opie::Core::OKeyFilter::inst()
+ */
void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
@@ -720,2 +741,11 @@ void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
+/**
+ * \brief Remove the QWSServer::KeyboardFilter in the param from the list
+ *
+ * Remove the QWSServer::KeyboardFilter \par aFilter from the List
+ * of Keyfilters. Call this when you delete the KeyFilter!
+ *
+ * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
+ * @see Opie::Core::ODevice::addPreHandler
+ */
void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
@@ -725,2 +755,29 @@ void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
+void ODevice::playingStopped() {
+ const_cast<QObject*>(sender())->disconnect( this );
+ if ( d->m_sound >= 0 ) {
+ ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
+ ::close ( d->m_sound );
+ }
+}
+
+void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
+ if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
+ if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
+ Config cfg ( "qpe" );
+ cfg. setGroup ( "Volume" );
+
+ int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
+ if ( volalarm < 0 )
+ volalarm = 0;
+ else if ( volalarm > 100 )
+ volalarm = 100;
+ volalarm |= ( volalarm << 8 );
+
+ if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
+ register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
+ }
+ d->m_mixer = mixer;
+ }
+}
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,25 +1,25 @@
/*
- This file is part of the Opie Project
- Copyright (C) The Opie Team <opie-devel@handhelds.org>
+                 This file is part of the Opie Project
+              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
- .>+-=
-_;:, .> :=|. This program is free software; you can
-.> <`_, > . <= redistribute it and/or modify it under
-:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
-.="- .-=="i, .._ License as published by the Free Software
-- . .-<_> .<> Foundation; either version 2 of the License,
- ._= =} : or (at your option) any later version.
- .%`+i> _;_.
- .i_,=:_. -<s. This program is distributed in the hope that
- + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
- : .. .:, . . . without even the implied warranty of
- =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
- _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.= = ; Library General Public License for more
-++= -. .` .: details.
-: = ...= . :.=-
--. .:....=;==+<; You should have received a copy of the GNU
- -_. . . )=. = Library General Public License along with
- -- :-=` this library; see the file COPYING.LIB.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
@@ -40,2 +40,4 @@ _;:, .> :=|. This program is free software; you can
#include <qstring.h>
+
+
#include <qstrlist.h>
@@ -43,2 +45,5 @@ _;:, .> :=|. This program is free software; you can
+
+class Sound;
+
namespace Opie{
@@ -46,3 +51,3 @@ namespace Core{
- class ODeviceData;
+class ODeviceData;
/**
@@ -321,2 +326,3 @@ private slots:
void systemMessage ( const QCString &, const QByteArray & );
+ void playingStopped();
@@ -326,2 +332,4 @@ protected:
void reloadButtonMapping();
+ void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
+
/* ugly virtual hook */
@@ -350,2 +358,5 @@ class ODeviceData {
QStrList *m_cpu_frequencies;
+
+ /* values for changeMixerForAlarm */
+ int m_sound, m_vol, m_mixer;
};
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,25 +1,25 @@
/*
- This file is part of the Opie Project
- Copyright (C) The Opie Team <opie-devel@handhelds.org>
+                 This file is part of the Opie Project
+              Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org>
=.
.=l.
- .>+-=
-_;:, .> :=|. This program is free software; you can
-.> <`_, > . <= redistribute it and/or modify it under
-:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
-.="- .-=="i, .._ License as published by the Free Software
-- . .-<_> .<> Foundation; either version 2 of the License,
- ._= =} : or (at your option) any later version.
- .%`+i> _;_.
- .i_,=:_. -<s. This program is distributed in the hope that
- + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
- : .. .:, . . . without even the implied warranty of
- =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
- _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.= = ; Library General Public License for more
-++= -. .` .: details.
-: = ...= . :.=-
--. .:....=;==+<; You should have received a copy of the GNU
- -_. . . )=. = Library General Public License along with
- -- :-=` this library; see the file COPYING.LIB.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
@@ -333,32 +333,5 @@ void iPAQ::playAlarmSound()
static Sound snd ( "alarm" );
- int fd;
- int vol;
- bool vol_reset = false;
-
- if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
- if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
- Config cfg ( "qpe" );
- cfg. setGroup ( "Volume" );
-
- int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
- if ( volalarm < 0 )
- volalarm = 0;
- else if ( volalarm > 100 )
- volalarm = 100;
- volalarm |= ( volalarm << 8 );
-
- if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
- vol_reset = true;
- }
- }
+ changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
snd. play();
- while ( !snd. isFinished())
- qApp->processEvents();
-
- if ( fd >= 0 ) {
- if ( vol_reset )
- ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
- ::close ( fd );
- }
#endif
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
@@ -240,6 +240,7 @@ bool SIMpad::setLedState ( OLed l, OLedState st )
return true;
- }
- }
- }
-
+ // }
+// }
+#else
+ Q_UNUSED( l )
+ Q_UNUSED( st )
#endif
@@ -249,3 +250,3 @@ bool SIMpad::setLedState ( OLed l, OLedState st )
-bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
+bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ )
{
@@ -268,32 +269,6 @@ void SIMpad::playAlarmSound()
static Sound snd ( "alarm" );
- int fd;
- int vol;
- bool vol_reset = false;
-
- if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
- if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
- Config cfg ( "qpe" );
- cfg. setGroup ( "Volume" );
-
- int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
- if ( volalarm < 0 )
- volalarm = 0;
- else if ( volalarm > 100 )
- volalarm = 100;
- volalarm |= ( volalarm << 8 );
-
- if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
- vol_reset = true;
- }
- }
+ /* save as the Sound is static! */
+ changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
snd. play();
- while ( !snd. isFinished())
- qApp->processEvents();
-
- if ( fd >= 0 ) {
- if ( vol_reset )
- ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
- ::close ( fd );
- }
#endif
@@ -337,4 +312,2 @@ bool SIMpad::setDisplayStatus ( bool on )
- bool res = false;
- int fd;
@@ -342,5 +315,3 @@ bool SIMpad::setDisplayStatus ( bool on )
- res = ( ::system( (const char*) cmdline ) == 0 );
-
- return res;
+ return ( ::system( (const char*) cmdline ) == 0 );
}
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
@@ -2,3 +2,3 @@
                This file is part of the Opie Project
-              Copyright (C) The Opie Team <opie-devel@handhelds.org>
+              Copyright (C) 2003, 2004 The Opie Team <opie-devel@handhelds.org>
=.
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
@@ -145,2 +145,4 @@ bool Yopy::setDisplayBrightness( int bright )
}
+#else
+ Q_UNUSED( bright )
#endif
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,25 +1,25 @@
/*
- This file is part of the Opie Project
- Copyright (C) The Opie Team <opie-devel@handhelds.org>
+                 This file is part of the Opie Project
+              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
- .>+-=
-_;:, .> :=|. This program is free software; you can
-.> <`_, > . <= redistribute it and/or modify it under
-:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
-.="- .-=="i, .._ License as published by the Free Software
-- . .-<_> .<> Foundation; either version 2 of the License,
- ._= =} : or (at your option) any later version.
- .%`+i> _;_.
- .i_,=:_. -<s. This program is distributed in the hope that
- + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
- : .. .:, . . . without even the implied warranty of
- =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
- _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.= = ; Library General Public License for more
-++= -. .` .: details.
-: = ...= . :.=-
--. .:....=;==+<; You should have received a copy of the GNU
- -_. . . )=. = Library General Public License along with
- -- :-=` this library; see the file COPYING.LIB.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
@@ -185,4 +185,2 @@ void Zaurus::init(const QString& cpu_info)
// set initial rotation
-
- bool flipstate = false;
switch ( d->m_model ) {
@@ -320,3 +318,3 @@ void Zaurus::buzzer ( int sound )
#ifndef QT_NO_SOUND
- QString soundname;
+ Sound *snd = 0;
@@ -327,14 +325,15 @@ void Zaurus::buzzer ( int sound )
switch ( sound ){
- case SHARP_BUZ_SCHEDULE_ALARM:
- soundname = "alarm";
- break;
case SHARP_BUZ_TOUCHSOUND:
- soundname = "touchsound";
+ static Sound touch_sound("touchsound");
+ snd = &touch_sound;
break;
case SHARP_BUZ_KEYSOUND:
- soundname = "keysound";
+ static Sound key_sound( "keysound" );
+ snd = &key_sound;
break;
+ case SHARP_BUZ_SCHEDULE_ALARM:
default:
- soundname = "alarm";
-
+ static Sound alarm_sound("alarm");
+ snd = &alarm_sound;
+ break;
}
@@ -345,35 +344,5 @@ void Zaurus::buzzer ( int sound )
// device..
- if ( !soundname.isEmpty() ){
- int fd;
- int vol;
- bool vol_reset = false;
-
- Sound snd ( soundname );
-
- if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
- if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
- Config cfg ( "qpe" );
- cfg. setGroup ( "Volume" );
-
- int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
- if ( volalarm < 0 )
- volalarm = 0;
- else if ( volalarm > 100 )
- volalarm = 100;
- volalarm |= ( volalarm << 8 );
-
- if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
- vol_reset = true;
- }
- }
-
- snd. play();
- while ( !snd. isFinished())
- qApp->processEvents();
-
- if ( fd >= 0 ) {
- if ( vol_reset )
- ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
- ::close ( fd );
- }
+ if ( snd ){
+ changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
+ snd-> play();
} else {
@@ -516,3 +485,3 @@ bool Zaurus::setDisplayBrightness ( int bright )
{
- int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
+ int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
char writeCommand[100];