author | korovkin <korovkin> | 2006-04-29 16:53:24 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-04-29 16:53:24 (UTC) |
commit | b91d3399fbd3178085e9d0fc5faeefbe31c674b7 (patch) (unidiff) | |
tree | 979c7b2c1af8bd31230d3c75b0d40e013a1ea75f | |
parent | 17191b7ae7929568b9ed87a427e2eaeb28377a00 (diff) | |
download | opie-b91d3399fbd3178085e9d0fc5faeefbe31c674b7.zip opie-b91d3399fbd3178085e9d0fc5faeefbe31c674b7.tar.gz opie-b91d3399fbd3178085e9d0fc5faeefbe31c674b7.tar.bz2 |
Disable screensaver when running BT gateway.
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 13954c5..58f97fa 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,82 +1,86 @@ | |||
1 | /* | 1 | /* |
2 | * bluebase.cpp * | 2 | * bluebase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * copyright : (c) 2002 by Maximilian Reiß | 5 | * copyright : (c) 2002 by Maximilian Reiß |
6 | * email : max.reiss@gmx.de | 6 | * email : max.reiss@gmx.de |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "bluebase.h" | 18 | #include "bluebase.h" |
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | #include "hciconfwrapper.h" | 20 | #include "hciconfwrapper.h" |
21 | #include "devicehandler.h" | 21 | #include "devicehandler.h" |
22 | #include "btconnectionitem.h" | 22 | #include "btconnectionitem.h" |
23 | #include "rfcommassigndialogimpl.h" | 23 | #include "rfcommassigndialogimpl.h" |
24 | #include "forwarder.h" | 24 | #include "forwarder.h" |
25 | #include "servicesdialog.h" | 25 | #include "servicesdialog.h" |
26 | #include <termios.h> | 26 | #include <termios.h> |
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | 29 | ||
30 | /* OPIE */ | 30 | /* OPIE */ |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #ifdef Q_WS_QWS | ||
36 | #include <qpe/qcopenvelope_qws.h> | ||
37 | #endif | ||
38 | |||
35 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
36 | 40 | ||
37 | /* QT */ | 41 | /* QT */ |
38 | #include <qframe.h> | 42 | #include <qframe.h> |
39 | #include <qlabel.h> | 43 | #include <qlabel.h> |
40 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
41 | #include <qlayout.h> | 45 | #include <qlayout.h> |
42 | #include <qvariant.h> | 46 | #include <qvariant.h> |
43 | #include <qimage.h> | 47 | #include <qimage.h> |
44 | #include <qpixmap.h> | 48 | #include <qpixmap.h> |
45 | #include <qtabwidget.h> | 49 | #include <qtabwidget.h> |
46 | #include <qscrollview.h> | 50 | #include <qscrollview.h> |
47 | #include <qvbox.h> | 51 | #include <qvbox.h> |
48 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
49 | #include <qcombobox.h> | 53 | #include <qcombobox.h> |
50 | #include <qcheckbox.h> | 54 | #include <qcheckbox.h> |
51 | #include <qlineedit.h> | 55 | #include <qlineedit.h> |
52 | #include <qlistview.h> | 56 | #include <qlistview.h> |
53 | #include <qdir.h> | 57 | #include <qdir.h> |
54 | #include <qpopupmenu.h> | 58 | #include <qpopupmenu.h> |
55 | #include <qtimer.h> | 59 | #include <qtimer.h> |
56 | #include <qlist.h> | 60 | #include <qlist.h> |
57 | #include <qfile.h> | 61 | #include <qfile.h> |
58 | 62 | ||
59 | /* STD */ | 63 | /* STD */ |
60 | #include <remotedevice.h> | 64 | #include <remotedevice.h> |
61 | #include <services.h> | 65 | #include <services.h> |
62 | #include <stdlib.h> | 66 | #include <stdlib.h> |
63 | 67 | ||
64 | using namespace OpieTooth; | 68 | using namespace OpieTooth; |
65 | //Array of possible speeds of the serial port | 69 | //Array of possible speeds of the serial port |
66 | struct SerSpeed { | 70 | struct SerSpeed { |
67 | const char* str; //string value | 71 | const char* str; //string value |
68 | int val; //value itself | 72 | int val; //value itself |
69 | } speeds[] = { | 73 | } speeds[] = { |
70 | { "150", B150 }, { "300", B300 }, { "600", B600 }, { "1200", B1200 }, | 74 | { "150", B150 }, { "300", B300 }, { "600", B600 }, { "1200", B1200 }, |
71 | { "2400", B2400 }, { "4800", B4800 }, { "9600", B9600 }, | 75 | { "2400", B2400 }, { "4800", B4800 }, { "9600", B9600 }, |
72 | { "19200", B19200 }, { "38400", B38400 }, { "57600", B57600 }, | 76 | { "19200", B19200 }, { "38400", B38400 }, { "57600", B57600 }, |
73 | { "115200", B115200} | 77 | { "115200", B115200} |
74 | }; | 78 | }; |
75 | 79 | ||
76 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 80 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
77 | : BluetoothBase( parent, name, fl ) | 81 | : BluetoothBase( parent, name, fl ) |
78 | { | 82 | { |
79 | m_localDevice = new Manager( "hci0" ); | 83 | m_localDevice = new Manager( "hci0" ); |
80 | 84 | ||
81 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 85 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
82 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 86 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
@@ -643,139 +647,155 @@ void BlueBase::deviceActive( const QString& device, bool connected ) | |||
643 | 647 | ||
644 | it = m_deviceList.find( device ); | 648 | it = m_deviceList.find( device ); |
645 | if( it == m_deviceList.end() ) | 649 | if( it == m_deviceList.end() ) |
646 | return; | 650 | return; |
647 | 651 | ||
648 | BTDeviceItem* deviceItem = it.data(); | 652 | BTDeviceItem* deviceItem = it.data(); |
649 | 653 | ||
650 | if ( connected ) | 654 | if ( connected ) |
651 | { | 655 | { |
652 | deviceItem->setPixmap( 1, m_onPix ); | 656 | deviceItem->setPixmap( 1, m_onPix ); |
653 | } | 657 | } |
654 | else | 658 | else |
655 | { | 659 | { |
656 | deviceItem->setPixmap( 1, m_offPix ); | 660 | deviceItem->setPixmap( 1, m_offPix ); |
657 | } | 661 | } |
658 | m_deviceList.remove( it ); | 662 | m_deviceList.remove( it ); |
659 | } | 663 | } |
660 | 664 | ||
661 | 665 | ||
662 | /** | 666 | /** |
663 | * Open the "scan for devices" dialog | 667 | * Open the "scan for devices" dialog |
664 | */ | 668 | */ |
665 | void BlueBase::startScan() | 669 | void BlueBase::startScan() |
666 | { | 670 | { |
667 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", | 671 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", |
668 | true, WDestructiveClose ); | 672 | true, WDestructiveClose ); |
669 | QObject::connect( scan, SIGNAL( selectedDevices(const QValueList<RemoteDevice>&) ), | 673 | QObject::connect( scan, SIGNAL( selectedDevices(const QValueList<RemoteDevice>&) ), |
670 | this, SLOT( addSearchedDevices(const QValueList<RemoteDevice>&) ) ); | 674 | this, SLOT( addSearchedDevices(const QValueList<RemoteDevice>&) ) ); |
671 | 675 | ||
672 | QPEApplication::showDialog( scan ); | 676 | QPEApplication::showDialog( scan ); |
673 | } | 677 | } |
674 | 678 | ||
675 | 679 | ||
676 | /** | 680 | /** |
677 | * Set the informations about the local device in information Tab | 681 | * Set the informations about the local device in information Tab |
678 | */ | 682 | */ |
679 | void BlueBase::setInfo() | 683 | void BlueBase::setInfo() |
680 | { | 684 | { |
681 | StatusLabel->setText( status() ); | 685 | StatusLabel->setText( status() ); |
682 | } | 686 | } |
683 | 687 | ||
684 | 688 | ||
685 | /** | 689 | /** |
686 | * Decontructor | 690 | * Decontructor |
687 | */ | 691 | */ |
688 | BlueBase::~BlueBase() | 692 | BlueBase::~BlueBase() |
689 | { | 693 | { |
690 | writeSavedDevices(); | 694 | writeSavedDevices(); |
695 | if (forwarder) { | ||
696 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
697 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | ||
698 | << QPEApplication::Enable; | ||
699 | #endif | ||
700 | delete forwarder; | ||
701 | forwarder = NULL; | ||
702 | } | ||
691 | delete m_iconLoader; | 703 | delete m_iconLoader; |
692 | } | 704 | } |
693 | 705 | ||
694 | 706 | ||
695 | /** | 707 | /** |
696 | * find searches the ListView for a BTDeviceItem containig | 708 | * find searches the ListView for a BTDeviceItem containig |
697 | * the same Device if found return true else false | 709 | * the same Device if found return true else false |
698 | * @param dev RemoteDevice to find | 710 | * @param dev RemoteDevice to find |
699 | * @return returns true if found | 711 | * @return returns true if found |
700 | */ | 712 | */ |
701 | bool BlueBase::find( const RemoteDevice& rem ) | 713 | bool BlueBase::find( const RemoteDevice& rem ) |
702 | { | 714 | { |
703 | QListViewItemIterator it( devicesView ); | 715 | QListViewItemIterator it( devicesView ); |
704 | BTListItem* item; | 716 | BTListItem* item; |
705 | BTDeviceItem* device; | 717 | BTDeviceItem* device; |
706 | for (; it.current(); ++it ) | 718 | for (; it.current(); ++it ) |
707 | { | 719 | { |
708 | item = (BTListItem*) it.current(); | 720 | item = (BTListItem*) it.current(); |
709 | if ( item->typeId() != BTListItem::Device ) | 721 | if ( item->typeId() != BTListItem::Device ) |
710 | continue; | 722 | continue; |
711 | 723 | ||
712 | device = (BTDeviceItem*)item; | 724 | device = (BTDeviceItem*)item; |
713 | if ( rem.equals( device->remoteDevice() ) ) | 725 | if ( rem.equals( device->remoteDevice() ) ) |
714 | return true; | 726 | return true; |
715 | } | 727 | } |
716 | return false; // not found | 728 | return false; // not found |
717 | } | 729 | } |
718 | 730 | ||
719 | /** | 731 | /** |
720 | * Start process of the cell phone forwarding | 732 | * Start process of the cell phone forwarding |
721 | */ | 733 | */ |
722 | void BlueBase::doForward() | 734 | void BlueBase::doForward() |
723 | { | 735 | { |
724 | if (forwarder && forwarder->isRunning()) { | 736 | if (forwarder && forwarder->isRunning()) { |
725 | runButton->setText("start gateway"); | 737 | runButton->setText("start gateway"); |
726 | forwarder->stop(); | 738 | forwarder->stop(); |
727 | delete forwarder; | 739 | delete forwarder; |
728 | forwarder = NULL; | 740 | forwarder = NULL; |
729 | return; | 741 | return; |
730 | } | 742 | } |
731 | QString str = serDevName->text(); | 743 | QString str = serDevName->text(); |
732 | forwarder = new SerialForwarder(str, speeds[serSpeed->currentItem()].val); | 744 | forwarder = new SerialForwarder(str, speeds[serSpeed->currentItem()].val); |
733 | connect(forwarder, SIGNAL(processExited(Opie::Core::OProcess*)), | 745 | connect(forwarder, SIGNAL(processExited(Opie::Core::OProcess*)), |
734 | this, SLOT(forwardExited(Opie::Core::OProcess*))); | 746 | this, SLOT(forwardExited(Opie::Core::OProcess*))); |
735 | if (forwarder->start(OProcess::NotifyOnExit) < 0) { | 747 | if (forwarder->start(OProcess::NotifyOnExit) < 0) { |
736 | QMessageBox::critical(this, tr("Forwarder Error"), | 748 | QMessageBox::critical(this, tr("Forwarder Error"), |
737 | tr("Forwarder start error:") + tr(strerror(errno))); | 749 | tr("Forwarder start error:") + tr(strerror(errno))); |
738 | return; | 750 | return; |
739 | } | 751 | } |
740 | runButton->setText("stop gateway"); | 752 | runButton->setText("stop gateway"); |
753 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
754 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)") | ||
755 | << QPEApplication::DisableSuspend; | ||
756 | #endif | ||
741 | } | 757 | } |
742 | 758 | ||
743 | /** | 759 | /** |
744 | * React on the process end | 760 | * React on the process end |
745 | */ | 761 | */ |
746 | void BlueBase::forwardExit(Opie::Core::OProcess* proc) | 762 | void BlueBase::forwardExit(Opie::Core::OProcess* proc) |
747 | { | 763 | { |
764 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
765 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | ||
766 | << QPEApplication::Enable; | ||
767 | #endif | ||
748 | if (proc->exitStatus() != 0) | 768 | if (proc->exitStatus() != 0) |
749 | QMessageBox::critical(this, tr("Forwarder Error"), | 769 | QMessageBox::critical(this, tr("Forwarder Error"), |
750 | tr("Forwarder start error")); | 770 | tr("Forwarder start error")); |
751 | delete proc; | 771 | delete proc; |
752 | forwarder = NULL; | 772 | forwarder = NULL; |
753 | runButton->setText("start gateway"); | 773 | runButton->setText("start gateway"); |
754 | } | 774 | } |
755 | 775 | ||
756 | /** | 776 | /** |
757 | * Encrypt entered passkey | 777 | * Encrypt entered passkey |
758 | * doit - do encryption of the key | 778 | * doit - do encryption of the key |
759 | */ | 779 | */ |
760 | void BlueBase::doEncrypt(bool doit) | 780 | void BlueBase::doEncrypt(bool doit) |
761 | { | 781 | { |
762 | passkeyLine->setEchoMode((doit)? QLineEdit::Password: QLineEdit::Normal); | 782 | passkeyLine->setEchoMode((doit)? QLineEdit::Password: QLineEdit::Normal); |
763 | } | 783 | } |
764 | 784 | ||
765 | /** | 785 | /** |
766 | * Start services edit dialog | 786 | * Start services edit dialog |
767 | */ | 787 | */ |
768 | void BlueBase::editServices() | 788 | void BlueBase::editServices() |
769 | { | 789 | { |
770 | QString conf = "/etc/default/bluetooth"; | 790 | QString conf = "/etc/default/bluetooth"; |
771 | //// Use for debugging purposes | 791 | //// Use for debugging purposes |
772 | //// QString conf = "/mnt/net/opie/bin/bluetooth"; | 792 | //// QString conf = "/mnt/net/opie/bin/bluetooth"; |
773 | ServicesDialog svcEdit(conf, this, "ServicesDialog", true, | 793 | ServicesDialog svcEdit(conf, this, "ServicesDialog", true, |
774 | WStyle_ContextHelp); | 794 | WStyle_ContextHelp); |
775 | 795 | ||
776 | if (QPEApplication::execDialog(&svcEdit) == QDialog::Accepted) | 796 | if (QPEApplication::execDialog(&svcEdit) == QDialog::Accepted) |
777 | { | 797 | { |
778 | } | 798 | } |
779 | } | 799 | } |
780 | 800 | ||
781 | //eof | 801 | //eof |