author | erik <erik> | 2007-02-09 21:12:35 (UTC) |
---|---|---|
committer | erik <erik> | 2007-02-09 21:12:35 (UTC) |
commit | 2695f72652956e94e24611539579e7ff7899811e (patch) (unidiff) | |
tree | 0a2e73775f5b04da5950465f1c31e067256a266c /libopie2/opiecore/device/odevice.cpp | |
parent | 9abe862308081155837512dd5e6c581752c9ddb2 (diff) | |
download | opie-2695f72652956e94e24611539579e7ff7899811e.zip opie-2695f72652956e94e24611539579e7ff7899811e.tar.gz opie-2695f72652956e94e24611539579e7ff7899811e.tar.bz2 |
This commit fixes an issue where an ioctl call is made but the return
value is not checked. It isn't a big deal. But it would be nice if the
user knew that an ioctl to a device tanked.
Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 7 |
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 @@ | |||
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | 30 | ||
31 | #include "odevice_beagle.h" | 31 | #include "odevice_beagle.h" |
32 | #include "odevice_ipaq.h" | 32 | #include "odevice_ipaq.h" |
33 | #include "odevice_mypal.h" | 33 | #include "odevice_mypal.h" |
34 | #include "odevice_jornada.h" | 34 | #include "odevice_jornada.h" |
35 | #include "odevice_ramses.h" | 35 | #include "odevice_ramses.h" |
36 | #include "odevice_simpad.h" | 36 | #include "odevice_simpad.h" |
37 | #include "odevice_yopy.h" | 37 | #include "odevice_yopy.h" |
38 | #include "odevice_zaurus.h" | 38 | #include "odevice_zaurus.h" |
39 | #include "odevice_genuineintel.h" | 39 | #include "odevice_genuineintel.h" |
40 | #include "odevice_htc.h" | 40 | #include "odevice_htc.h" |
41 | #include "odevice_motorola_ezx.h" | 41 | #include "odevice_motorola_ezx.h" |
42 | #include "odevice_palm.h" | 42 | #include "odevice_palm.h" |
43 | 43 | ||
44 | /* QT */ | 44 | /* QT */ |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qfile.h> | 46 | #include <qfile.h> |
47 | #include <qtextstream.h> | 47 | #include <qtextstream.h> |
48 | #include <qwindowsystem_qws.h> | 48 | #include <qwindowsystem_qws.h> |
49 | 49 | ||
50 | /* OPIE */ | 50 | /* OPIE */ |
51 | #include <qpe/config.h> | 51 | #include <qpe/config.h> |
52 | #include <qpe/sound.h> | 52 | #include <qpe/sound.h> |
53 | #include <qpe/qcopenvelope_qws.h> | 53 | #include <qpe/qcopenvelope_qws.h> |
54 | #include <qpe/sound.h> | 54 | #include <qpe/sound.h> |
55 | 55 | ||
56 | #include <opie2/okeyfilter.h> | 56 | #include <opie2/okeyfilter.h> |
57 | #include <opie2/oresource.h> | 57 | #include <opie2/oresource.h> |
58 | 58 | ||
59 | /* STD */ | 59 | /* STD */ |
60 | #include <fcntl.h> | 60 | #include <fcntl.h> |
61 | #include <math.h> | 61 | #include <math.h> |
62 | #include <stdlib.h> | 62 | #include <stdlib.h> |
63 | #include <signal.h> | 63 | #include <signal.h> |
64 | #include <sys/ioctl.h> | 64 | #include <sys/ioctl.h> |
65 | #include <sys/time.h> | 65 | #include <sys/time.h> |
66 | #include <unistd.h> | 66 | #include <unistd.h> |
67 | #ifndef QT_NO_SOUND | 67 | #ifndef QT_NO_SOUND |
68 | #include <linux/soundcard.h> | 68 | #include <linux/soundcard.h> |
69 | #include <errno.h> | ||
69 | #endif | 70 | #endif |
70 | 71 | ||
71 | namespace Opie { | 72 | namespace Opie { |
72 | namespace Core { | 73 | namespace Core { |
73 | 74 | ||
74 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 75 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
75 | 76 | ||
76 | 77 | ||
77 | /* STATIC and common implementation */ | 78 | /* STATIC and common implementation */ |
78 | /* EXPORT */ ODistribution distributions[] = { | 79 | /* EXPORT */ ODistribution distributions[] = { |
79 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 80 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
80 | { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" }, | 81 | { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" }, |
81 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 82 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
82 | { System_Unknown, "Linux", "/etc/issue" }, | 83 | { System_Unknown, "Linux", "/etc/issue" }, |
83 | }; | 84 | }; |
84 | 85 | ||
85 | 86 | ||
86 | /* EXPORT */ bool isQWS(){ | 87 | /* EXPORT */ bool isQWS(){ |
87 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 88 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
88 | } | 89 | } |
89 | 90 | ||
90 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 91 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
91 | if ( str && !::strchr ( str, '/' )) | 92 | if ( str && !::strchr ( str, '/' )) |
92 | return QCString ( "QPE/Application/" ) + str; | 93 | return QCString ( "QPE/Application/" ) + str; |
93 | else | 94 | else |
94 | return str; | 95 | return str; |
95 | } | 96 | } |
96 | 97 | ||
97 | 98 | ||
98 | 99 | ||
99 | /* Now the default implementation of ODevice */ | 100 | /* Now the default implementation of ODevice */ |
100 | 101 | ||
101 | struct default_button default_buttons [] = { | 102 | struct default_button default_buttons [] = { |
102 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 103 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
103 | "devicebuttons/z_calendar", | 104 | "devicebuttons/z_calendar", |
104 | "datebook", "nextView()", | 105 | "datebook", "nextView()", |
105 | "today", "raise()" }, | 106 | "today", "raise()" }, |
106 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 107 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
107 | "devicebuttons/z_contact", | 108 | "devicebuttons/z_contact", |
108 | "addressbook", "raise()", | 109 | "addressbook", "raise()", |
109 | "addressbook", "beamBusinessCard()" }, | 110 | "addressbook", "beamBusinessCard()" }, |
110 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 111 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
111 | "devicebuttons/z_home", | 112 | "devicebuttons/z_home", |
112 | "QPE/Launcher", "home()", | 113 | "QPE/Launcher", "home()", |
113 | "buttonsettings", "raise()" }, | 114 | "buttonsettings", "raise()" }, |
114 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 115 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
115 | "devicebuttons/z_menu", | 116 | "devicebuttons/z_menu", |
116 | "QPE/TaskBar", "toggleMenu()", | 117 | "QPE/TaskBar", "toggleMenu()", |
@@ -704,105 +705,109 @@ void ODevice::virtual_hook(int, void* ){ | |||
704 | * is the windowing server. | 705 | * is the windowing server. |
705 | * | 706 | * |
706 | * Call this in your custom \sa suspend() Method | 707 | * Call this in your custom \sa suspend() Method |
707 | * before going to suspend. | 708 | * before going to suspend. |
708 | * | 709 | * |
709 | */ | 710 | */ |
710 | void ODevice::sendSuspendmsg() | 711 | void ODevice::sendSuspendmsg() |
711 | { | 712 | { |
712 | if ( !isQWS() ) | 713 | if ( !isQWS() ) |
713 | return; | 714 | return; |
714 | 715 | ||
715 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 716 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
716 | } | 717 | } |
717 | 718 | ||
718 | /** | 719 | /** |
719 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters | 720 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters |
720 | * | 721 | * |
721 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard | 722 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard |
722 | * Filters. This function is the only way to prepend a KeyFilter. | 723 | * Filters. This function is the only way to prepend a KeyFilter. |
723 | * | 724 | * |
724 | * @param aFilter The KeyFilter to be prepended to the list of filters | 725 | * @param aFilter The KeyFilter to be prepended to the list of filters |
725 | * | 726 | * |
726 | * @see Opie::Core::OKeyFilter | 727 | * @see Opie::Core::OKeyFilter |
727 | * @see Opie::Core::OKeyFilter::inst() | 728 | * @see Opie::Core::OKeyFilter::inst() |
728 | */ | 729 | */ |
729 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 730 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) |
730 | { | 731 | { |
731 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); | 732 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); |
732 | } | 733 | } |
733 | 734 | ||
734 | /** | 735 | /** |
735 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list | 736 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list |
736 | * | 737 | * |
737 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List | 738 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List |
738 | * of Keyfilters. Call this when you delete the KeyFilter! | 739 | * of Keyfilters. Call this when you delete the KeyFilter! |
739 | * | 740 | * |
740 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter | 741 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter |
741 | * @see Opie::Core::ODevice::addPreHandler | 742 | * @see Opie::Core::ODevice::addPreHandler |
742 | */ | 743 | */ |
743 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 744 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) |
744 | { | 745 | { |
745 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); | 746 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); |
746 | } | 747 | } |
747 | 748 | ||
748 | 749 | ||
749 | /** | 750 | /** |
750 | * @internal | 751 | * @internal |
751 | * | 752 | * |
753 | * Returns the volume back to the user preference after an alarm is finished. | ||
754 | * | ||
752 | * @see changeMixerForAlarm | 755 | * @see changeMixerForAlarm |
753 | */ | 756 | */ |
754 | void ODevice::playingStopped() { | 757 | void ODevice::playingStopped() { |
755 | if ( sender() ) | 758 | if ( sender() ) |
756 | const_cast<QObject*>(sender())->disconnect( this ); | 759 | const_cast<QObject*>(sender())->disconnect( this ); |
757 | 760 | ||
758 | #ifndef QT_NO_SOUND | 761 | #ifndef QT_NO_SOUND |
759 | if ( d->m_sound >= 0 ) { | 762 | if ( d->m_sound >= 0 ) { |
760 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); | 763 | if (::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ) == -1) |
764 | qWarning( "ODevice::playingStopped() - " | ||
765 | "unable to change volume back (%s)", strerror( errno ) ); | ||
761 | ::close ( d->m_sound ); | 766 | ::close ( d->m_sound ); |
762 | } | 767 | } |
763 | #endif | 768 | #endif |
764 | } | 769 | } |
765 | 770 | ||
766 | 771 | ||
767 | /** | 772 | /** |
768 | * \brief Change the Volume for the Alarm and set it back after playing is finished | 773 | * \brief Change the Volume for the Alarm and set it back after playing is finished |
769 | * | 774 | * |
770 | * If you play an Alarm Sound you might want to change the Mixer to | 775 | * If you play an Alarm Sound you might want to change the Mixer to |
771 | * full volume and ignore the user setting. After it \sa Sound::isFinished | 776 | * full volume and ignore the user setting. After it \sa Sound::isFinished |
772 | * you would turn the volume back to the user preference. | 777 | * you would turn the volume back to the user preference. |
773 | * The problem is that we used to enter the event loop while waiting | 778 | * The problem is that we used to enter the event loop while waiting |
774 | * for the sound to be finished triggering all kind of reentrance | 779 | * for the sound to be finished triggering all kind of reentrance |
775 | * problems what a library shouldn't introduce. | 780 | * problems what a library shouldn't introduce. |
776 | * Instead of manually waiting for the sound to be finished use | 781 | * Instead of manually waiting for the sound to be finished use |
777 | * this Method and it will automatically restore the Mixer to | 782 | * this Method and it will automatically restore the Mixer to |
778 | * the user configuration after the sound finished playing. | 783 | * the user configuration after the sound finished playing. |
779 | * | 784 | * |
780 | * Note: The onwership of \param snd is not transfered and playing | 785 | * Note: The onwership of \param snd is not transfered and playing |
781 | * is not started in this method. If 'snd' gets deleted before | 786 | * is not started in this method. If 'snd' gets deleted before |
782 | * playing is finished the volume doesn't get set back to | 787 | * playing is finished the volume doesn't get set back to |
783 | * the user preference! | 788 | * the user preference! |
784 | * | 789 | * |
785 | * \code | 790 | * \code |
786 | * static Sound snd("alarm"); | 791 | * static Sound snd("alarm"); |
787 | * if(!snd.isFinished()) | 792 | * if(!snd.isFinished()) |
788 | * return; | 793 | * return; |
789 | * | 794 | * |
790 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); | 795 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); |
791 | * snd.play() | 796 | * snd.play() |
792 | * \endcode | 797 | * \endcode |
793 | * | 798 | * |
794 | * | 799 | * |
795 | * | 800 | * |
796 | * @param mixer The mixer number/channel to use | 801 | * @param mixer The mixer number/channel to use |
797 | * @param file The file name. If you convert from QString use QFile::encodeName | 802 | * @param file The file name. If you convert from QString use QFile::encodeName |
798 | * @param snd The sound to wait for finishing | 803 | * @param snd The sound to wait for finishing |
799 | * | 804 | * |
800 | */ | 805 | */ |
801 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { | 806 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { |
802 | #ifndef QT_NO_SOUND | 807 | #ifndef QT_NO_SOUND |
803 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { | 808 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { |
804 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { | 809 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { |
805 | Config cfg ( "qpe" ); | 810 | Config cfg ( "qpe" ); |
806 | cfg. setGroup ( "Volume" ); | 811 | cfg. setGroup ( "Volume" ); |
807 | 812 | ||
808 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 813 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |