summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 67cae1c..e57cdef 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -455,389 +455,389 @@ ODirection ODevice::direction() const
455/** 455/**
456* This plays an alarm sound 456* This plays an alarm sound
457*/ 457*/
458void ODevice::playAlarmSound() 458void ODevice::playAlarmSound()
459{ 459{
460#ifndef QT_NO_SOUND 460#ifndef QT_NO_SOUND
461 static Sound snd ( "alarm" ); 461 static Sound snd ( "alarm" );
462 462
463 if ( snd. isFinished()) 463 if ( snd. isFinished())
464 snd. play(); 464 snd. play();
465#endif 465#endif
466} 466}
467 467
468/** 468/**
469* This plays a key sound 469* This plays a key sound
470*/ 470*/
471void ODevice::playKeySound() 471void ODevice::playKeySound()
472{ 472{
473#ifndef QT_NO_SOUND 473#ifndef QT_NO_SOUND
474 static Sound snd ( "keysound" ); 474 static Sound snd ( "keysound" );
475 475
476 if ( snd. isFinished()) 476 if ( snd. isFinished())
477 snd. play(); 477 snd. play();
478#endif 478#endif
479} 479}
480 480
481/** 481/**
482* This plays a touch sound 482* This plays a touch sound
483*/ 483*/
484void ODevice::playTouchSound() 484void ODevice::playTouchSound()
485{ 485{
486#ifndef QT_NO_SOUND 486#ifndef QT_NO_SOUND
487 static Sound snd ( "touchsound" ); 487 static Sound snd ( "touchsound" );
488 488
489 if ( snd. isFinished()) 489 if ( snd. isFinished())
490 snd. play(); 490 snd. play();
491#endif 491#endif
492} 492}
493 493
494/** 494/**
495* This method will return a list of leds 495* This method will return a list of leds
496* available on this device 496* available on this device
497* @return a list of LEDs. 497* @return a list of LEDs.
498*/ 498*/
499QValueList <OLed> ODevice::ledList() const 499QValueList <OLed> ODevice::ledList() const
500{ 500{
501 return QValueList <OLed>(); 501 return QValueList <OLed>();
502} 502}
503 503
504/** 504/**
505* This does return the state of the LEDs 505* This does return the state of the LEDs
506*/ 506*/
507QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 507QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
508{ 508{
509 return QValueList <OLedState>(); 509 return QValueList <OLedState>();
510} 510}
511 511
512/** 512/**
513* @return the state for a given OLed 513* @return the state for a given OLed
514*/ 514*/
515OLedState ODevice::ledState ( OLed /*which*/ ) const 515OLedState ODevice::ledState ( OLed /*which*/ ) const
516{ 516{
517 return Led_Off; 517 return Led_Off;
518} 518}
519 519
520/** 520/**
521* Set the state for a LED 521* Set the state for a LED
522* @param which Which OLed to use 522* @param which Which OLed to use
523* @param st The state to set 523* @param st The state to set
524* @return success or failure 524* @return success or failure
525*/ 525*/
526bool ODevice::setLedState ( OLed which, OLedState st ) 526bool 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 if(!d->m_buttons)
648 initButtons();
648 649
649 if(!d->m_initializedButtonQcop) { 650 if(!d->m_initializedButtonQcop) {
650 QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); 651 connect(qApp,SIGNAL(systemMessageSignal(const QCString&,const QByteArray&)),
651 connect(chan,SIGNAL(received(const QCString&,const QByteArray&)),
652 this,SLOT(systemMessage(const QCString&,const QByteArray&))); 652 this,SLOT(systemMessage(const QCString&,const QByteArray&)));
653 d->m_initializedButtonQcop = true; 653 d->m_initializedButtonQcop = true;
654 } 654 }
655 655
656 Config cfg ( "ButtonSettings" ); 656 Config cfg ( "ButtonSettings" );
657 657
658 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 658 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
659 ODeviceButton &b = ( *d->m_buttons ) [i]; 659 ODeviceButton &b = ( *d->m_buttons ) [i];
660 QString group = "Button" + QString::number ( i ); 660 QString group = "Button" + QString::number ( i );
661 661
662 QCString pch, hch; 662 QCString pch, hch;
663 QCString pm, hm; 663 QCString pm, hm;
664 QByteArray pdata, hdata; 664 QByteArray pdata, hdata;
665 665
666 if ( cfg. hasGroup ( group )) { 666 if ( cfg. hasGroup ( group )) {
667 cfg. setGroup ( group ); 667 cfg. setGroup ( group );
668 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 668 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
669 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 669 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
670 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 670 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
671 671
672 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 672 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
673 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 673 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
674 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 674 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
675 } 675 }
676 676
677 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 677 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
678 678
679 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 679 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
680 } 680 }
681} 681}
682 682
683void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 683void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
684{ 684{
685 initButtons(); 685 initButtons();
686 686
687 QString mb_chan; 687 QString mb_chan;
688 688
689 if ( button >= (int) d->m_buttons->count()) 689 if ( button >= (int) d->m_buttons->count())
690 return; 690 return;
691 691
692 ODeviceButton &b = ( *d->m_buttons ) [button]; 692 ODeviceButton &b = ( *d->m_buttons ) [button];
693 b. setPressedAction ( action ); 693 b. setPressedAction ( action );
694 694
695 mb_chan=b. pressedAction(). channel(); 695 mb_chan=b. pressedAction(). channel();
696 696
697 Config buttonFile ( "ButtonSettings" ); 697 Config buttonFile ( "ButtonSettings" );
698 buttonFile. setGroup ( "Button" + QString::number ( button )); 698 buttonFile. setGroup ( "Button" + QString::number ( button ));
699 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 699 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
700 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 700 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
701 701
702// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 702// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
703 703
704 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 704 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
705} 705}
706 706
707void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 707void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
708{ 708{
709 initButtons(); 709 initButtons();
710 710
711 if ( button >= (int) d->m_buttons->count()) 711 if ( button >= (int) d->m_buttons->count())
712 return; 712 return;
713 713
714 ODeviceButton &b = ( *d->m_buttons ) [button]; 714 ODeviceButton &b = ( *d->m_buttons ) [button];
715 b. setHeldAction ( action ); 715 b. setHeldAction ( action );
716 716
717 Config buttonFile ( "ButtonSettings" ); 717 Config buttonFile ( "ButtonSettings" );
718 buttonFile. setGroup ( "Button" + QString::number ( button )); 718 buttonFile. setGroup ( "Button" + QString::number ( button ));
719 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 719 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
720 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 720 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
721 721
722// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 722// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
723 723
724 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 724 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
725} 725}
726 726
727/** 727/**
728 * @internal 728 * @internal
729 */ 729 */
730void ODevice::virtual_hook(int, void* ){ 730void ODevice::virtual_hook(int, void* ){
731 731
732} 732}
733 733
734/** 734/**
735 * \brief Send a QCOP Message before suspending 735 * \brief Send a QCOP Message before suspending
736 * 736 *
737 * Sends a QCOP message to channel QPE/System 737 * Sends a QCOP message to channel QPE/System
738 * with the message "aboutToSuspend()" if this 738 * with the message "aboutToSuspend()" if this
739 * is the windowing server. 739 * is the windowing server.
740 * 740 *
741 * Call this in your custom \sa suspend() Method 741 * Call this in your custom \sa suspend() Method
742 * before going to suspend. 742 * before going to suspend.
743 * 743 *
744 */ 744 */
745void ODevice::sendSuspendmsg() 745void ODevice::sendSuspendmsg()
746{ 746{
747 if ( isQWS() ) 747 if ( isQWS() )
748 return; 748 return;
749 749
750 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 750 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
751} 751}
752 752
753/** 753/**
754 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters 754 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
755 * 755 *
756 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard 756 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
757 * Filters. This function is the only way to prepend a KeyFilter. 757 * Filters. This function is the only way to prepend a KeyFilter.
758 * 758 *
759 * @param aFilter The KeyFilter to be prepended to the list of filters 759 * @param aFilter The KeyFilter to be prepended to the list of filters
760 * 760 *
761 * @see Opie::Core::OKeyFilter 761 * @see Opie::Core::OKeyFilter
762 * @see Opie::Core::OKeyFilter::inst() 762 * @see Opie::Core::OKeyFilter::inst()
763 */ 763 */
764void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 764void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
765{ 765{
766 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 766 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
767} 767}
768 768
769/** 769/**
770 * \brief Remove the QWSServer::KeyboardFilter in the param from the list 770 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
771 * 771 *
772 * Remove the QWSServer::KeyboardFilter \par aFilter from the List 772 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
773 * of Keyfilters. Call this when you delete the KeyFilter! 773 * of Keyfilters. Call this when you delete the KeyFilter!
774 * 774 *
775 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter 775 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
776 * @see Opie::Core::ODevice::addPreHandler 776 * @see Opie::Core::ODevice::addPreHandler
777 */ 777 */
778void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 778void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
779{ 779{
780 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 780 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
781} 781}
782 782
783 783
784/** 784/**
785 * @internal 785 * @internal
786 * 786 *
787 * @see changeMixerForAlarm 787 * @see changeMixerForAlarm
788 */ 788 */
789void ODevice::playingStopped() { 789void ODevice::playingStopped() {
790 if ( sender() ) 790 if ( sender() )
791 const_cast<QObject*>(sender())->disconnect( this ); 791 const_cast<QObject*>(sender())->disconnect( this );
792 792
793#ifndef QT_NO_SOUND 793#ifndef QT_NO_SOUND
794 if ( d->m_sound >= 0 ) { 794 if ( d->m_sound >= 0 ) {
795 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); 795 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
796 ::close ( d->m_sound ); 796 ::close ( d->m_sound );
797 } 797 }
798#endif 798#endif
799} 799}
800 800
801 801
802/** 802/**
803 * \brief Change the Volume for the Alarm and set it back after playing is finished 803 * \brief Change the Volume for the Alarm and set it back after playing is finished
804 * 804 *
805 * If you play an Alarm Sound you might want to change the Mixer to 805 * If you play an Alarm Sound you might want to change the Mixer to
806 * full volume and ignore the user setting. After it \sa Sound::isFinished 806 * full volume and ignore the user setting. After it \sa Sound::isFinished
807 * you would turn the volume back to the user preference. 807 * you would turn the volume back to the user preference.
808 * The problem is that we used to enter the event loop while waiting 808 * The problem is that we used to enter the event loop while waiting
809 * for the sound to be finished triggering all kind of reentrance 809 * for the sound to be finished triggering all kind of reentrance
810 * problems what a library shouldn't introduce. 810 * problems what a library shouldn't introduce.
811 * Instead of manually waiting for the sound to be finished use 811 * Instead of manually waiting for the sound to be finished use
812 * this Method and it will automatically restore the Mixer to 812 * this Method and it will automatically restore the Mixer to
813 * the user configuration after the sound finished playing. 813 * the user configuration after the sound finished playing.
814 * 814 *
815 * Note: The onwership of \param snd is not transfered and playing 815 * Note: The onwership of \param snd is not transfered and playing
816 * is not started in this method. If 'snd' gets deleted before 816 * is not started in this method. If 'snd' gets deleted before
817 * playing is finished the volume doesn't get set back to 817 * playing is finished the volume doesn't get set back to
818 * the user preference! 818 * the user preference!
819 * 819 *
820 * \code 820 * \code
821 * static Sound snd("alarm"); 821 * static Sound snd("alarm");
822 * if(!snd.isFinished()) 822 * if(!snd.isFinished())
823 * return; 823 * return;
824 * 824 *
825 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); 825 * changeMixerForAlarm( my_channel, "/dev/mixer", &snd );
826 * snd.play() 826 * snd.play()
827 * \endcode 827 * \endcode
828 * 828 *
829 * 829 *
830 * 830 *
831 * @param mixer The mixer number/channel to use 831 * @param mixer The mixer number/channel to use
832 * @param file The file name. If you convert from QString use QFile::encodeName 832 * @param file The file name. If you convert from QString use QFile::encodeName
833 * @param snd The sound to wait for finishing 833 * @param snd The sound to wait for finishing
834 * 834 *
835 */ 835 */
836void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { 836void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
837#ifndef QT_NO_SOUND 837#ifndef QT_NO_SOUND
838 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { 838 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
839 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { 839 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
840 Config cfg ( "qpe" ); 840 Config cfg ( "qpe" );
841 cfg. setGroup ( "Volume" ); 841 cfg. setGroup ( "Volume" );
842 842
843 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 843 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );