Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 57 |
1 files changed, 57 insertions, 0 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 @@ -24,48 +24,49 @@ -- :-=` 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_ipaq.h" #include "odevice_jornada.h" #include "odevice_ramses.h" #include "odevice_simpad.h" #include "odevice_yopy.h" #include "odevice_zaurus.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> +#include <qpe/sound.h> #include <opie2/okeyfilter.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> #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/oz_version" }, @@ -150,48 +151,52 @@ ODevice *ODevice::inst() if ( !dev ) dev = new ODevice(); dev->init(cpu_info); } return dev; } ODevice::ODevice() { d = new ODeviceData; d->m_modelstr = "Unknown"; d->m_model = Model_Unknown; d->m_vendorstr = "Unknown"; d->m_vendor = Vendor_Unknown; d->m_systemstr = "Unknown"; d->m_system = System_Unknown; d->m_sysverstr = "0.0"; d->m_rotation = Rot0; d->m_direction = CW; d->m_holdtime = 1000; // 1000ms d->m_buttons = 0; d->m_cpu_frequencies = new QStrList; + + /* mixer */ + d->m_sound = d->m_vol = d->m_mixer = -1; + // New distribution detection code first checks for legacy distributions, // identified by /etc/familiar-version or /etc/oz_version. // Then check for OpenEmbedded and lastly, read /etc/issue for ( unsigned int i = 0; i < sizeof distributions; ++i ) { if ( QFile::exists( distributions[i].sysvfile ) ) { d->m_systemstr = distributions[i].sysstr; d->m_system = distributions[i].system; d->m_sysverstr = "<Unknown>"; QFile f( distributions[i].sysvfile ); if ( f.open( IO_ReadOnly ) ) { QTextStream ts( &f ); d->m_sysverstr = ts.readLine(); } break; } } } void ODevice::systemMessage( const QCString &msg, const QByteArray & ) { @@ -684,45 +689,97 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) { initButtons(); if ( button >= (int) d->m_buttons->count()) return; ODeviceButton &b = ( *d->m_buttons ) [button]; b. setHeldAction ( action ); Config buttonFile ( "ButtonSettings" ); buttonFile. setGroup ( "Button" + QString::number ( button )); buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } 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() { 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); } +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; + } +} } } |