author | zecke <zecke> | 2004-08-25 21:51:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-08-25 21:51:13 (UTC) |
commit | df3e4c8b13c16aeb96e70dbaa2d409f83eed988e (patch) (unidiff) | |
tree | 59b12028c6e8a53b99f1686278b6e9fdc57ab18e /libopie2/opiecore/device/odevice.cpp | |
parent | e4811064703ad34f42f15c3044cd8f63c0e7583c (diff) | |
download | opie-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 (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 | |||
@@ -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 | */ | ||
708 | void ODevice::sendSuspendmsg() | 718 | void 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 | */ | ||
716 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 737 | void 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 | */ | ||
721 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 751 | void 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 | ||
756 | void 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 | |||
764 | void 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 | } |