author | korovkin <korovkin> | 2006-04-14 19:22:37 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-04-14 19:22:37 (UTC) |
commit | a1bcbe41d45924713c4ead9b25ac5518473c9ca9 (patch) (unidiff) | |
tree | 3683eb401dd2d7cde4a7af15e72ecf7463b7208e /noncore/net/opietooth/manager/bluebase.cpp | |
parent | bca53498f37ade8101611fecde82202e9ee1a55c (diff) | |
download | opie-a1bcbe41d45924713c4ead9b25ac5518473c9ca9.zip opie-a1bcbe41d45924713c4ead9b25ac5518473c9ca9.tar.gz opie-a1bcbe41d45924713c4ead9b25ac5518473c9ca9.tar.bz2 |
Added RFCOMM <-> serial line forwarding functionality.
Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 0649514..9ec5bf8 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -21,6 +21,10 @@ | |||
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" | ||
25 | #include <termios.h> | ||
26 | #include <string.h> | ||
27 | #include <errno.h> | ||
24 | 28 | ||
25 | /* OPIE */ | 29 | /* OPIE */ |
26 | #include <qpe/qpeapplication.h> | 30 | #include <qpe/qpeapplication.h> |
@@ -41,6 +45,7 @@ using namespace Opie::Core; | |||
41 | #include <qscrollview.h> | 45 | #include <qscrollview.h> |
42 | #include <qvbox.h> | 46 | #include <qvbox.h> |
43 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | #include <qcombobox.h> | ||
44 | #include <qcheckbox.h> | 49 | #include <qcheckbox.h> |
45 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
46 | #include <qlistview.h> | 51 | #include <qlistview.h> |
@@ -55,6 +60,16 @@ using namespace Opie::Core; | |||
55 | #include <stdlib.h> | 60 | #include <stdlib.h> |
56 | 61 | ||
57 | using namespace OpieTooth; | 62 | using namespace OpieTooth; |
63 | //Array of possible speeds of the serial port | ||
64 | struct SerSpeed { | ||
65 | const char* str; //string value | ||
66 | int val; //value itself | ||
67 | } speeds[] = { | ||
68 | { "150", B150 }, { "300", B300 }, { "600", B600 }, { "1200", B1200 }, | ||
69 | { "2400", B2400 }, { "4800", B4800 }, { "9600", B9600 }, | ||
70 | { "19200", B19200 }, { "38400", B38400 }, { "57600", B57600 }, | ||
71 | { "115200", B115200} | ||
72 | }; | ||
58 | 73 | ||
59 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 74 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
60 | : BluetoothBase( parent, name, fl ) | 75 | : BluetoothBase( parent, name, fl ) |
@@ -78,6 +93,7 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
78 | this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); | 93 | this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); |
79 | connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), | 94 | connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), |
80 | this, SLOT( addSignalStrength(const QString&,const QString&) ) ); | 95 | this, SLOT( addSignalStrength(const QString&,const QString&) ) ); |
96 | connect(runButton, SIGNAL(clicked()), this, SLOT(doForward())); | ||
81 | 97 | ||
82 | // let hold be rightButtonClicked() | 98 | // let hold be rightButtonClicked() |
83 | QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); | 99 | QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); |
@@ -108,6 +124,12 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
108 | readSavedDevices(); | 124 | readSavedDevices(); |
109 | addServicesToDevices(); | 125 | addServicesToDevices(); |
110 | QTimer::singleShot( 3000, this, SLOT( addServicesToDevices() ) ); | 126 | QTimer::singleShot( 3000, this, SLOT( addServicesToDevices() ) ); |
127 | forwarder = NULL; | ||
128 | serDevName->setText(tr("/dev/ircomm0")); | ||
129 | for (unsigned int i = 0; i < (sizeof(speeds) / sizeof(speeds[0])); i++) { | ||
130 | serSpeed->insertItem(speeds[i].str); | ||
131 | } | ||
132 | serSpeed->setCurrentItem((sizeof(speeds) / sizeof(speeds[0])) - 1); | ||
111 | } | 133 | } |
112 | 134 | ||
113 | /** | 135 | /** |
@@ -680,3 +702,42 @@ bool BlueBase::find( const RemoteDevice& rem ) | |||
680 | } | 702 | } |
681 | return false; // not found | 703 | return false; // not found |
682 | } | 704 | } |
705 | |||
706 | /** | ||
707 | * Start process of the cell phone forwarding | ||
708 | */ | ||
709 | void BlueBase::doForward() | ||
710 | { | ||
711 | if (forwarder && forwarder->isRunning()) { | ||
712 | runButton->setText("start gateway"); | ||
713 | forwarder->stop(); | ||
714 | delete forwarder; | ||
715 | forwarder = NULL; | ||
716 | return; | ||
717 | } | ||
718 | QString str = serDevName->text(); | ||
719 | forwarder = new SerialForwarder(str, speeds[serSpeed->currentItem()].val); | ||
720 | connect(forwarder, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
721 | this, SLOT(forwardExited(Opie::Core::OProcess*))); | ||
722 | if (forwarder->start(OProcess::NotifyOnExit) < 0) { | ||
723 | QMessageBox::critical(this, tr("Forwarder Error"), | ||
724 | tr("Forwarder start error:") + tr(strerror(errno))); | ||
725 | return; | ||
726 | } | ||
727 | runButton->setText("stop gateway"); | ||
728 | } | ||
729 | |||
730 | /** | ||
731 | * React on the process end | ||
732 | */ | ||
733 | void BlueBase::forwardExit(Opie::Core::OProcess* proc) | ||
734 | { | ||
735 | if (proc->exitStatus() != 0) | ||
736 | QMessageBox::critical(this, tr("Forwarder Error"), | ||
737 | tr("Forwarder start error")); | ||
738 | delete proc; | ||
739 | forwarder = NULL; | ||
740 | runButton->setText("start gateway"); | ||
741 | } | ||
742 | |||
743 | //eof | ||