Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (show 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 | |||
@@ -42,12 +42,13 @@ | |||
42 | 42 | ||
43 | /* OPIE */ | 43 | /* OPIE */ |
44 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
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 */ |
51 | #include <fcntl.h> | 52 | #include <fcntl.h> |
52 | #include <math.h> | 53 | #include <math.h> |
53 | #include <stdlib.h> | 54 | #include <stdlib.h> |
@@ -168,12 +169,16 @@ ODevice::ODevice() | |||
168 | d->m_direction = CW; | 169 | d->m_direction = CW; |
169 | 170 | ||
170 | d->m_holdtime = 1000; // 1000ms | 171 | d->m_holdtime = 1000; // 1000ms |
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 |
177 | 182 | ||
178 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | 183 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) |
179 | { | 184 | { |
@@ -702,27 +707,79 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | |||
702 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 707 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
703 | } | 708 | } |
704 | void ODevice::virtual_hook(int, void* ){ | 709 | 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() ) |
711 | return; | 721 | return; |
712 | 722 | ||
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 | } |