-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 6 |
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 | |||
@@ -583,133 +583,133 @@ const QStrList &ODevice::allowedCpuFrequencies() const | |||
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 | */ |
587 | bool ODevice::setCurrentCpuFrequency(uint index) | 587 | bool 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 | */ |
612 | const QValueList <ODeviceButton> &ODevice::buttons() | 612 | const 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 | */ |
622 | uint ODevice::buttonHoldTime() const | 622 | uint 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 | */ |
634 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 634 | const 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 | ||
645 | void ODevice::reloadButtonMapping() | 645 | void 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 | ||
683 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 683 | void 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 | ||
707 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 707 | void 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 ); |