author | zecke <zecke> | 2004-09-21 00:21:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-21 00:21:17 (UTC) |
commit | ee21a12cded5c53f196a5183f39e8069a22ef835 (patch) (unidiff) | |
tree | 06141ef53b557986b5f70854f265e9460cda0962 | |
parent | 5c96d26bccfeeb34a639054bf8abe41af687d3c5 (diff) | |
download | opie-ee21a12cded5c53f196a5183f39e8069a22ef835.zip opie-ee21a12cded5c53f196a5183f39e8069a22ef835.tar.gz opie-ee21a12cded5c53f196a5183f39e8069a22ef835.tar.bz2 |
Update Opie Documentation
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 2b10034..ec861ee 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -323,51 +323,56 @@ bool ODevice::setDisplayStatus ( bool on ) | |||
323 | #ifdef QT_QWS_DEVFS | 323 | #ifdef QT_QWS_DEVFS |
324 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | 324 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { |
325 | #else | 325 | #else |
326 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 326 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
327 | #endif | 327 | #endif |
328 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 328 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
329 | ::close ( fd ); | 329 | ::close ( fd ); |
330 | } | 330 | } |
331 | return res; | 331 | return res; |
332 | } | 332 | } |
333 | 333 | ||
334 | /** | 334 | /** |
335 | * This sets the display brightness | 335 | * This sets the display brightness |
336 | * | 336 | * |
337 | * @param p The brightness to be set on a scale from 0 to 255 | 337 | * @param p The brightness to be set on a scale from 0 to 255 |
338 | * @return success or failure | 338 | * @return success or failure |
339 | */ | 339 | */ |
340 | bool ODevice::setDisplayBrightness ( int p) | 340 | bool ODevice::setDisplayBrightness ( int p) |
341 | { | 341 | { |
342 | Q_UNUSED( p ) | 342 | Q_UNUSED( p ) |
343 | return false; | 343 | return false; |
344 | } | 344 | } |
345 | 345 | ||
346 | /** | 346 | /** |
347 | * @return returns the number of steppings on the brightness slider | 347 | * |
348 | * in the Light-'n-Power settings. | 348 | * @return Returns the number of steppings on the brightness slider |
349 | */ | 349 | * in the Light-'n-Power settings. Values smaller zero and bigger |
350 | * than 255 do not make sense. | ||
351 | * | ||
352 | * \sa QSlider::setLineStep | ||
353 | * \sa QSlider::setPageStep | ||
354 | */ | ||
350 | int ODevice::displayBrightnessResolution() const | 355 | int ODevice::displayBrightnessResolution() const |
351 | { | 356 | { |
352 | return 16; | 357 | return 16; |
353 | } | 358 | } |
354 | 359 | ||
355 | /** | 360 | /** |
356 | * This sets the display contrast | 361 | * This sets the display contrast |
357 | * @param p The contrast to be set on a scale from 0 to 255 | 362 | * @param p The contrast to be set on a scale from 0 to 255 |
358 | * @return success or failure | 363 | * @return success or failure |
359 | */ | 364 | */ |
360 | bool ODevice::setDisplayContrast ( int p) | 365 | bool ODevice::setDisplayContrast ( int p) |
361 | { | 366 | { |
362 | Q_UNUSED( p ) | 367 | Q_UNUSED( p ) |
363 | return false; | 368 | return false; |
364 | } | 369 | } |
365 | 370 | ||
366 | /** | 371 | /** |
367 | * @return return the max value for the brightness settings slider | 372 | * @return return the max value for the brightness settings slider |
368 | * or 0 if the device doesn't support setting of a contrast | 373 | * or 0 if the device doesn't support setting of a contrast |
369 | */ | 374 | */ |
370 | int ODevice::displayContrastResolution() const | 375 | int ODevice::displayContrastResolution() const |
371 | { | 376 | { |
372 | return 0; | 377 | return 0; |
373 | } | 378 | } |
@@ -690,105 +695,156 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | |||
690 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 695 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
691 | 696 | ||
692 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 697 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
693 | } | 698 | } |
694 | 699 | ||
695 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 700 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
696 | { | 701 | { |
697 | initButtons(); | 702 | initButtons(); |
698 | 703 | ||
699 | if ( button >= (int) d->m_buttons->count()) | 704 | if ( button >= (int) d->m_buttons->count()) |
700 | return; | 705 | return; |
701 | 706 | ||
702 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 707 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
703 | b. setHeldAction ( action ); | 708 | b. setHeldAction ( action ); |
704 | 709 | ||
705 | Config buttonFile ( "ButtonSettings" ); | 710 | Config buttonFile ( "ButtonSettings" ); |
706 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 711 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
707 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 712 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
708 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 713 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
709 | 714 | ||
710 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 715 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
711 | 716 | ||
712 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 717 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
713 | } | 718 | } |
719 | |||
720 | /** | ||
721 | * @internal | ||
722 | */ | ||
714 | void ODevice::virtual_hook(int, void* ){ | 723 | void ODevice::virtual_hook(int, void* ){ |
715 | 724 | ||
716 | } | 725 | } |
717 | 726 | ||
718 | /** | 727 | /** |
728 | * \brief Send a QCOP Message before suspending | ||
729 | * | ||
719 | * Sends a QCOP message to channel QPE/System | 730 | * Sends a QCOP message to channel QPE/System |
720 | * with the message "aboutToSuspend()" if this | 731 | * with the message "aboutToSuspend()" if this |
721 | * is the windowing server | 732 | * is the windowing server. |
733 | * | ||
734 | * Call this in your custom \sa suspend() Method | ||
735 | * before going to suspend. | ||
736 | * | ||
722 | */ | 737 | */ |
723 | void ODevice::sendSuspendmsg() | 738 | void ODevice::sendSuspendmsg() |
724 | { | 739 | { |
725 | if ( isQWS() ) | 740 | if ( isQWS() ) |
726 | return; | 741 | return; |
727 | 742 | ||
728 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 743 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
729 | } | 744 | } |
730 | 745 | ||
731 | /** | 746 | /** |
732 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters | 747 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters |
733 | * | 748 | * |
734 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard | 749 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard |
735 | * Filters. This function is the only way to prepend a KeyFilter. | 750 | * Filters. This function is the only way to prepend a KeyFilter. |
736 | * | 751 | * |
737 | * @param aFilter The KeyFilter to be prepended to the list of filters | 752 | * @param aFilter The KeyFilter to be prepended to the list of filters |
738 | * | 753 | * |
739 | * @see Opie::Core::OKeyFilter | 754 | * @see Opie::Core::OKeyFilter |
740 | * @see Opie::Core::OKeyFilter::inst() | 755 | * @see Opie::Core::OKeyFilter::inst() |
741 | */ | 756 | */ |
742 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 757 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) |
743 | { | 758 | { |
744 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); | 759 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); |
745 | } | 760 | } |
746 | 761 | ||
747 | /** | 762 | /** |
748 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list | 763 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list |
749 | * | 764 | * |
750 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List | 765 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List |
751 | * of Keyfilters. Call this when you delete the KeyFilter! | 766 | * of Keyfilters. Call this when you delete the KeyFilter! |
752 | * | 767 | * |
753 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter | 768 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter |
754 | * @see Opie::Core::ODevice::addPreHandler | 769 | * @see Opie::Core::ODevice::addPreHandler |
755 | */ | 770 | */ |
756 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 771 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) |
757 | { | 772 | { |
758 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); | 773 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); |
759 | } | 774 | } |
760 | 775 | ||
776 | |||
777 | /** | ||
778 | * @internal | ||
779 | * | ||
780 | * @see changeMixerForAlarm | ||
781 | */ | ||
761 | void ODevice::playingStopped() { | 782 | void ODevice::playingStopped() { |
762 | const_cast<QObject*>(sender())->disconnect( this ); | 783 | const_cast<QObject*>(sender())->disconnect( this ); |
763 | #ifndef QT_NO_SOUND | 784 | #ifndef QT_NO_SOUND |
764 | if ( d->m_sound >= 0 ) { | 785 | if ( d->m_sound >= 0 ) { |
765 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); | 786 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); |
766 | ::close ( d->m_sound ); | 787 | ::close ( d->m_sound ); |
767 | } | 788 | } |
768 | #endif | 789 | #endif |
769 | } | 790 | } |
770 | 791 | ||
792 | |||
793 | /** | ||
794 | * \brief Change the Volume for the Alarm and set it back after playing is finished | ||
795 | * | ||
796 | * If you play an Alarm Sound you might want to change the Mixer to | ||
797 | * full volume and ignore the user setting. After it \sa Sound::isFinished | ||
798 | * you would turn the volume back to the user preference. | ||
799 | * The problem is that we used to enter the event loop while waiting | ||
800 | * for the sound to be finished triggering all kind of reentrance | ||
801 | * problems what a library shouldn't introduce. | ||
802 | * Instead of manually waiting for the sound to be finished use | ||
803 | * this Method and it will automatically restore the Mixer to | ||
804 | * the user configuration after the sound finished playing. | ||
805 | * | ||
806 | * Note: The onwership of \param snd is not transfered and playing | ||
807 | * is not started in this method. If 'snd' gets deleted before | ||
808 | * playing is finished the volume doesn't get set back to | ||
809 | * the user preference! | ||
810 | * | ||
811 | * \code | ||
812 | * static Sound snd("alarm"); | ||
813 | * if(!snd.isFinished()) | ||
814 | * return; | ||
815 | * | ||
816 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); | ||
817 | * snd.play() | ||
818 | * \endcode | ||
819 | * | ||
820 | * | ||
821 | * | ||
822 | * @param mixer The mixer number/channel to use | ||
823 | * @param file The file name. If you convert from QString use QFile::encodeName | ||
824 | * @param snd The sound to wait for finishing | ||
825 | * | ||
826 | */ | ||
771 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { | 827 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { |
772 | #ifndef QT_NO_SOUND | 828 | #ifndef QT_NO_SOUND |
773 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { | 829 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { |
774 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { | 830 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { |
775 | Config cfg ( "qpe" ); | 831 | Config cfg ( "qpe" ); |
776 | cfg. setGroup ( "Volume" ); | 832 | cfg. setGroup ( "Volume" ); |
777 | 833 | ||
778 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 834 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
779 | if ( volalarm < 0 ) | 835 | if ( volalarm < 0 ) |
780 | volalarm = 0; | 836 | volalarm = 0; |
781 | else if ( volalarm > 100 ) | 837 | else if ( volalarm > 100 ) |
782 | volalarm = 100; | 838 | volalarm = 100; |
783 | volalarm |= ( volalarm << 8 ); | 839 | volalarm |= ( volalarm << 8 ); |
784 | 840 | ||
785 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) | 841 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) |
786 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); | 842 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); |
787 | } | 843 | } |
788 | d->m_mixer = mixer; | 844 | d->m_mixer = mixer; |
789 | } | 845 | } |
790 | #endif | 846 | #endif |
791 | } | 847 | } |
792 | 848 | ||
793 | } | 849 | } |
794 | } | 850 | } |