summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index ec861ee..b5ae4e5 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -527,324 +527,326 @@ bool ODevice::setLedState ( OLed which, OLedState st )
527{ 527{
528 Q_UNUSED( which ) 528 Q_UNUSED( which )
529 Q_UNUSED( st ) 529 Q_UNUSED( st )
530 return false; 530 return false;
531} 531}
532 532
533/** 533/**
534* @return if the device has a light sensor 534* @return if the device has a light sensor
535*/ 535*/
536bool ODevice::hasLightSensor() const 536bool ODevice::hasLightSensor() const
537{ 537{
538 return false; 538 return false;
539} 539}
540 540
541/** 541/**
542* @return a value from the light sensor 542* @return a value from the light sensor
543*/ 543*/
544int ODevice::readLightSensor() 544int ODevice::readLightSensor()
545{ 545{
546 return -1; 546 return -1;
547} 547}
548 548
549/** 549/**
550* @return the light sensor resolution 550* @return the light sensor resolution
551*/ 551*/
552int ODevice::lightSensorResolution() const 552int ODevice::lightSensorResolution() const
553{ 553{
554 return 0; 554 return 0;
555} 555}
556 556
557/** 557/**
558* @return if the device has a hinge sensor 558* @return if the device has a hinge sensor
559*/ 559*/
560bool ODevice::hasHingeSensor() const 560bool ODevice::hasHingeSensor() const
561{ 561{
562 return false; 562 return false;
563} 563}
564 564
565/** 565/**
566* @return a value from the hinge sensor 566* @return a value from the hinge sensor
567*/ 567*/
568OHingeStatus ODevice::readHingeSensor() 568OHingeStatus ODevice::readHingeSensor()
569{ 569{
570 return CASE_UNKNOWN; 570 return CASE_UNKNOWN;
571} 571}
572 572
573/** 573/**
574* @return a list with CPU frequencies supported by the hardware 574* @return a list with CPU frequencies supported by the hardware
575*/ 575*/
576const QStrList &ODevice::allowedCpuFrequencies() const 576const QStrList &ODevice::allowedCpuFrequencies() const
577{ 577{
578 return *d->m_cpu_frequencies; 578 return *d->m_cpu_frequencies;
579} 579}
580 580
581 581
582/** 582/**
583* Set desired CPU frequency 583* Set desired CPU frequency
584* 584*
585* @param index index into d->m_cpu_frequencies of the frequency to be set 585* @param index index into d->m_cpu_frequencies of the frequency to be set
586*/ 586*/
587bool ODevice::setCurrentCpuFrequency(uint index) 587bool ODevice::setCurrentCpuFrequency(uint index)
588{ 588{
589 if (index >= d->m_cpu_frequencies->count()) 589 if (index >= d->m_cpu_frequencies->count())
590 return false; 590 return false;
591 591
592 char *freq = d->m_cpu_frequencies->at(index); 592 char *freq = d->m_cpu_frequencies->at(index);
593 qWarning("set freq to %s", freq); 593 qWarning("set freq to %s", freq);
594 594
595 int fd; 595 int fd;
596 596
597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 597 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
598 char writeCommand[50]; 598 char writeCommand[50];
599 const int count = sprintf(writeCommand, "%s\n", freq); 599 const int count = sprintf(writeCommand, "%s\n", freq);
600 int res = (::write(fd, writeCommand, count) != -1); 600 int res = (::write(fd, writeCommand, count) != -1);
601 ::close(fd); 601 ::close(fd);
602 return res; 602 return res;
603 } 603 }
604 604
605 return false; 605 return false;
606} 606}
607 607
608 608
609/** 609/**
610* @return a list of hardware buttons 610* @return a list of hardware buttons
611*/ 611*/
612const QValueList <ODeviceButton> &ODevice::buttons() 612const QValueList <ODeviceButton> &ODevice::buttons()
613{ 613{
614 initButtons(); 614 initButtons();
615 615
616 return *d->m_buttons; 616 return *d->m_buttons;
617} 617}
618 618
619/** 619/**
620* @return The amount of time that would count as a hold 620* @return The amount of time that would count as a hold
621*/ 621*/
622uint ODevice::buttonHoldTime() const 622uint ODevice::buttonHoldTime() const
623{ 623{
624 return d->m_holdtime; 624 return d->m_holdtime;
625} 625}
626 626
627/** 627/**
628* This method return a ODeviceButton for a key code 628* This method return a ODeviceButton for a key code
629* or 0 if no special hardware button is available for the device 629* or 0 if no special hardware button is available for the device
630* 630*
631* @return The devicebutton or 0l 631* @return The devicebutton or 0l
632* @see ODeviceButton 632* @see ODeviceButton
633*/ 633*/
634const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 634const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
635{ 635{
636 initButtons(); 636 initButtons();
637 637
638 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 638 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
639 if ( (*it). keycode() == code ) 639 if ( (*it). keycode() == code )
640 return &(*it); 640 return &(*it);
641 } 641 }
642 return 0; 642 return 0;
643} 643}
644 644
645void ODevice::reloadButtonMapping() 645void ODevice::reloadButtonMapping()
646{ 646{
647 initButtons(); 647 initButtons();
648 648
649 Config cfg ( "ButtonSettings" ); 649 Config cfg ( "ButtonSettings" );
650 650
651 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 651 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
652 ODeviceButton &b = ( *d->m_buttons ) [i]; 652 ODeviceButton &b = ( *d->m_buttons ) [i];
653 QString group = "Button" + QString::number ( i ); 653 QString group = "Button" + QString::number ( i );
654 654
655 QCString pch, hch; 655 QCString pch, hch;
656 QCString pm, hm; 656 QCString pm, hm;
657 QByteArray pdata, hdata; 657 QByteArray pdata, hdata;
658 658
659 if ( cfg. hasGroup ( group )) { 659 if ( cfg. hasGroup ( group )) {
660 cfg. setGroup ( group ); 660 cfg. setGroup ( group );
661 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 661 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
662 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 662 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
663 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 663 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
664 664
665 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 665 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
666 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 666 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
667 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 667 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
668 } 668 }
669 669
670 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 670 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
671 671
672 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 672 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
673 } 673 }
674} 674}
675 675
676void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 676void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
677{ 677{
678 initButtons(); 678 initButtons();
679 679
680 QString mb_chan; 680 QString mb_chan;
681 681
682 if ( button >= (int) d->m_buttons->count()) 682 if ( button >= (int) d->m_buttons->count())
683 return; 683 return;
684 684
685 ODeviceButton &b = ( *d->m_buttons ) [button]; 685 ODeviceButton &b = ( *d->m_buttons ) [button];
686 b. setPressedAction ( action ); 686 b. setPressedAction ( action );
687 687
688 mb_chan=b. pressedAction(). channel(); 688 mb_chan=b. pressedAction(). channel();
689 689
690 Config buttonFile ( "ButtonSettings" ); 690 Config buttonFile ( "ButtonSettings" );
691 buttonFile. setGroup ( "Button" + QString::number ( button )); 691 buttonFile. setGroup ( "Button" + QString::number ( button ));
692 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 692 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
693 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 693 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
694 694
695// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 695// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
696 696
697 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 697 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
698} 698}
699 699
700void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 700void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
701{ 701{
702 initButtons(); 702 initButtons();
703 703
704 if ( button >= (int) d->m_buttons->count()) 704 if ( button >= (int) d->m_buttons->count())
705 return; 705 return;
706 706
707 ODeviceButton &b = ( *d->m_buttons ) [button]; 707 ODeviceButton &b = ( *d->m_buttons ) [button];
708 b. setHeldAction ( action ); 708 b. setHeldAction ( action );
709 709
710 Config buttonFile ( "ButtonSettings" ); 710 Config buttonFile ( "ButtonSettings" );
711 buttonFile. setGroup ( "Button" + QString::number ( button )); 711 buttonFile. setGroup ( "Button" + QString::number ( button ));
712 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 712 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
713 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 713 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
714 714
715// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 715// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
716 716
717 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 717 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
718} 718}
719 719
720/** 720/**
721 * @internal 721 * @internal
722 */ 722 */
723void ODevice::virtual_hook(int, void* ){ 723void ODevice::virtual_hook(int, void* ){
724 724
725} 725}
726 726
727/** 727/**
728 * \brief Send a QCOP Message before suspending 728 * \brief Send a QCOP Message before suspending
729 * 729 *
730 * Sends a QCOP message to channel QPE/System 730 * Sends a QCOP message to channel QPE/System
731 * with the message "aboutToSuspend()" if this 731 * with the message "aboutToSuspend()" if this
732 * is the windowing server. 732 * is the windowing server.
733 * 733 *
734 * Call this in your custom \sa suspend() Method 734 * Call this in your custom \sa suspend() Method
735 * before going to suspend. 735 * before going to suspend.
736 * 736 *
737 */ 737 */
738void ODevice::sendSuspendmsg() 738void ODevice::sendSuspendmsg()
739{ 739{
740 if ( isQWS() ) 740 if ( isQWS() )
741 return; 741 return;
742 742
743 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 743 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
744} 744}
745 745
746/** 746/**
747 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters 747 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
748 * 748 *
749 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard 749 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
750 * Filters. This function is the only way to prepend a KeyFilter. 750 * Filters. This function is the only way to prepend a KeyFilter.
751 * 751 *
752 * @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
753 * 753 *
754 * @see Opie::Core::OKeyFilter 754 * @see Opie::Core::OKeyFilter
755 * @see Opie::Core::OKeyFilter::inst() 755 * @see Opie::Core::OKeyFilter::inst()
756 */ 756 */
757void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 757void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
758{ 758{
759 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 759 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
760} 760}
761 761
762/** 762/**
763 * \brief Remove the QWSServer::KeyboardFilter in the param from the list 763 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
764 * 764 *
765 * Remove the QWSServer::KeyboardFilter \par aFilter from the List 765 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
766 * of Keyfilters. Call this when you delete the KeyFilter! 766 * of Keyfilters. Call this when you delete the KeyFilter!
767 * 767 *
768 * @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
769 * @see Opie::Core::ODevice::addPreHandler 769 * @see Opie::Core::ODevice::addPreHandler
770 */ 770 */
771void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 771void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
772{ 772{
773 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 773 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
774} 774}
775 775
776 776
777/** 777/**
778 * @internal 778 * @internal
779 * 779 *
780 * @see changeMixerForAlarm 780 * @see changeMixerForAlarm
781 */ 781 */
782void ODevice::playingStopped() { 782void ODevice::playingStopped() {
783 const_cast<QObject*>(sender())->disconnect( this ); 783 if ( sender() )
784 const_cast<QObject*>(sender())->disconnect( this );
785
784#ifndef QT_NO_SOUND 786#ifndef QT_NO_SOUND
785 if ( d->m_sound >= 0 ) { 787 if ( d->m_sound >= 0 ) {
786 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); 788 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
787 ::close ( d->m_sound ); 789 ::close ( d->m_sound );
788 } 790 }
789#endif 791#endif
790} 792}
791 793
792 794
793/** 795/**
794 * \brief Change the Volume for the Alarm and set it back after playing is finished 796 * \brief Change the Volume for the Alarm and set it back after playing is finished
795 * 797 *
796 * If you play an Alarm Sound you might want to change the Mixer to 798 * 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 799 * full volume and ignore the user setting. After it \sa Sound::isFinished
798 * you would turn the volume back to the user preference. 800 * you would turn the volume back to the user preference.
799 * The problem is that we used to enter the event loop while waiting 801 * 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 802 * for the sound to be finished triggering all kind of reentrance
801 * problems what a library shouldn't introduce. 803 * problems what a library shouldn't introduce.
802 * Instead of manually waiting for the sound to be finished use 804 * Instead of manually waiting for the sound to be finished use
803 * this Method and it will automatically restore the Mixer to 805 * this Method and it will automatically restore the Mixer to
804 * the user configuration after the sound finished playing. 806 * the user configuration after the sound finished playing.
805 * 807 *
806 * Note: The onwership of \param snd is not transfered and playing 808 * Note: The onwership of \param snd is not transfered and playing
807 * is not started in this method. If 'snd' gets deleted before 809 * is not started in this method. If 'snd' gets deleted before
808 * playing is finished the volume doesn't get set back to 810 * playing is finished the volume doesn't get set back to
809 * the user preference! 811 * the user preference!
810 * 812 *
811 * \code 813 * \code
812 * static Sound snd("alarm"); 814 * static Sound snd("alarm");
813 * if(!snd.isFinished()) 815 * if(!snd.isFinished())
814 * return; 816 * return;
815 * 817 *
816 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); 818 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd );
817 * snd.play() 819 * snd.play()
818 * \endcode 820 * \endcode
819 * 821 *
820 * 822 *
821 * 823 *
822 * @param mixer The mixer number/channel to use 824 * @param mixer The mixer number/channel to use
823 * @param file The file name. If you convert from QString use QFile::encodeName 825 * @param file The file name. If you convert from QString use QFile::encodeName
824 * @param snd The sound to wait for finishing 826 * @param snd The sound to wait for finishing
825 * 827 *
826 */ 828 */
827void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { 829void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
828#ifndef QT_NO_SOUND 830#ifndef QT_NO_SOUND
829 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { 831 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
830 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { 832 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
831 Config cfg ( "qpe" ); 833 Config cfg ( "qpe" );
832 cfg. setGroup ( "Volume" ); 834 cfg. setGroup ( "Volume" );
833 835
834 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 836 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
835 if ( volalarm < 0 ) 837 if ( volalarm < 0 )
836 volalarm = 0; 838 volalarm = 0;
837 else if ( volalarm > 100 ) 839 else if ( volalarm > 100 )
838 volalarm = 100; 840 volalarm = 100;
839 volalarm |= ( volalarm << 8 ); 841 volalarm |= ( volalarm << 8 );
840 842
841 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) 843 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
842 register_qpe_sound_finished(snd, this, SLOT(playingStopped())); 844 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
843 } 845 }
844 d->m_mixer = mixer; 846 d->m_mixer = mixer;
845 } 847 }
846#endif 848#endif
847} 849}
848 850
849} 851}
850} 852}