summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index e4233eb..aecccca 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -21,96 +21,97 @@
 -.   .:....=;==+<; 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,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_beagle.h"
#include "odevice_ipaq.h"
#include "odevice_mypal.h"
#include "odevice_jornada.h"
#include "odevice_ramses.h"
#include "odevice_simpad.h"
#include "odevice_yopy.h"
#include "odevice_zaurus.h"
#include "odevice_genuineintel.h"
#include "odevice_htc.h"
#include "odevice_motorola_ezx.h"
#include "odevice_palm.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/sound.h>
#include <opie2/okeyfilter.h>
#include <opie2/oresource.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
+#include <errno.h>
#endif
namespace Opie {
namespace Core {
static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
/* STATIC and common implementation */
/* EXPORT */ ODistribution distributions[] = {
{ System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
{ System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" },
{ System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
{ System_Unknown, "Linux", "/etc/issue" },
};
/* EXPORT */ bool isQWS(){
return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
}
/* EXPORT */ QCString makeChannel ( const char *str ){
if ( str && !::strchr ( str, '/' ))
return QCString ( "QPE/Application/" ) + str;
else
return str;
}
/* Now the default implementation of ODevice */
struct default_button default_buttons [] = {
{ Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
"devicebuttons/z_calendar",
"datebook", "nextView()",
"today", "raise()" },
{ Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
"devicebuttons/z_contact",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
"devicebuttons/z_home",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
"devicebuttons/z_menu",
"QPE/TaskBar", "toggleMenu()",
@@ -704,105 +705,109 @@ void ODevice::virtual_hook(int, void* ){
* is the windowing server.
*
* Call this in your custom \sa suspend() Method
* before going to suspend.
*
*/
void ODevice::sendSuspendmsg()
{
if ( !isQWS() )
return;
QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
}
/**
* \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)
{
Opie::Core::OKeyFilter::inst()->addPreHandler(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)
{
Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
}
/**
* @internal
*
+ * Returns the volume back to the user preference after an alarm is finished.
+ *
* @see changeMixerForAlarm
*/
void ODevice::playingStopped() {
if ( sender() )
const_cast<QObject*>(sender())->disconnect( this );
#ifndef QT_NO_SOUND
if ( d->m_sound >= 0 ) {
- ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
+ if (::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ) == -1)
+ qWarning( "ODevice::playingStopped() - "
+ "unable to change volume back (%s)", strerror( errno ) );
::close ( d->m_sound );
}
#endif
}
/**
* \brief Change the Volume for the Alarm and set it back after playing is finished
*
* If you play an Alarm Sound you might want to change the Mixer to
* full volume and ignore the user setting. After it \sa Sound::isFinished
* you would turn the volume back to the user preference.
* The problem is that we used to enter the event loop while waiting
* for the sound to be finished triggering all kind of reentrance
* problems what a library shouldn't introduce.
* Instead of manually waiting for the sound to be finished use
* this Method and it will automatically restore the Mixer to
* the user configuration after the sound finished playing.
*
* Note: The onwership of \param snd is not transfered and playing
* is not started in this method. If 'snd' gets deleted before
* playing is finished the volume doesn't get set back to
* the user preference!
*
* \code
* static Sound snd("alarm");
* if(!snd.isFinished())
* return;
*
* changeMixerForAlarm( my_channel, "/dev/mixer", &snd );
* snd.play()
* \endcode
*
*
*
* @param mixer The mixer number/channel to use
* @param file The file name. If you convert from QString use QFile::encodeName
* @param snd The sound to wait for finishing
*
*/
void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
#ifndef QT_NO_SOUND
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 );