summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp57
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
@@ -36,24 +36,25 @@
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
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>
54#include <signal.h> 55#include <signal.h>
55#include <sys/ioctl.h> 56#include <sys/ioctl.h>
56#include <sys/time.h> 57#include <sys/time.h>
57#include <unistd.h> 58#include <unistd.h>
58#ifndef QT_NO_SOUND 59#ifndef QT_NO_SOUND
59#include <linux/soundcard.h> 60#include <linux/soundcard.h>
@@ -162,24 +163,28 @@ ODevice::ODevice()
162 d->m_vendorstr = "Unknown"; 163 d->m_vendorstr = "Unknown";
163 d->m_vendor = Vendor_Unknown; 164 d->m_vendor = Vendor_Unknown;
164 d->m_systemstr = "Unknown"; 165 d->m_systemstr = "Unknown";
165 d->m_system = System_Unknown; 166 d->m_system = System_Unknown;
166 d->m_sysverstr = "0.0"; 167 d->m_sysverstr = "0.0";
167 d->m_rotation = Rot0; 168 d->m_rotation = Rot0;
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 {
180 if ( QFile::exists( distributions[i].sysvfile ) ) 185 if ( QFile::exists( distributions[i].sysvfile ) )
181 { 186 {
182 d->m_systemstr = distributions[i].sysstr; 187 d->m_systemstr = distributions[i].sysstr;
183 d->m_system = distributions[i].system; 188 d->m_system = distributions[i].system;
184 d->m_sysverstr = "<Unknown>"; 189 d->m_sysverstr = "<Unknown>";
185 QFile f( distributions[i].sysvfile ); 190 QFile f( distributions[i].sysvfile );
@@ -696,33 +701,85 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
696 buttonFile. setGroup ( "Button" + QString::number ( button )); 701 buttonFile. setGroup ( "Button" + QString::number ( button ));
697 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 702 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
698 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 703 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
699 704
700// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 705// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
701 706
702 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 707 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
703} 708}
704void ODevice::virtual_hook(int, void* ){ 709void 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 */
708void ODevice::sendSuspendmsg() 718void 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 */
716void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 737void 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 */
721void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 751void 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
756void 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
764void 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}