author | korovkin <korovkin> | 2006-04-14 19:22:37 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-04-14 19:22:37 (UTC) |
commit | a1bcbe41d45924713c4ead9b25ac5518473c9ca9 (patch) (side-by-side diff) | |
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) (show 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 @@ -23,2 +23,6 @@ #include "rfcommassigndialogimpl.h" +#include "forwarder.h" +#include <termios.h> +#include <string.h> +#include <errno.h> @@ -43,2 +47,3 @@ using namespace Opie::Core; #include <qmessagebox.h> +#include <qcombobox.h> #include <qcheckbox.h> @@ -57,2 +62,12 @@ using namespace Opie::Core; using namespace OpieTooth; +//Array of possible speeds of the serial port +struct SerSpeed { + const char* str; //string value + int val; //value itself +} speeds[] = { + { "150", B150 }, { "300", B300 }, { "600", B600 }, { "1200", B1200 }, + { "2400", B2400 }, { "4800", B4800 }, { "9600", B9600 }, + { "19200", B19200 }, { "38400", B38400 }, { "57600", B57600 }, + { "115200", B115200} +}; @@ -80,2 +95,3 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) this, SLOT( addSignalStrength(const QString&,const QString&) ) ); + connect(runButton, SIGNAL(clicked()), this, SLOT(doForward())); @@ -110,2 +126,8 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) QTimer::singleShot( 3000, this, SLOT( addServicesToDevices() ) ); + forwarder = NULL; + serDevName->setText(tr("/dev/ircomm0")); + for (unsigned int i = 0; i < (sizeof(speeds) / sizeof(speeds[0])); i++) { + serSpeed->insertItem(speeds[i].str); + } + serSpeed->setCurrentItem((sizeof(speeds) / sizeof(speeds[0])) - 1); } @@ -682 +704,40 @@ bool BlueBase::find( const RemoteDevice& rem ) } + +/** + * Start process of the cell phone forwarding + */ +void BlueBase::doForward() +{ + if (forwarder && forwarder->isRunning()) { + runButton->setText("start gateway"); + forwarder->stop(); + delete forwarder; + forwarder = NULL; + return; + } + QString str = serDevName->text(); + forwarder = new SerialForwarder(str, speeds[serSpeed->currentItem()].val); + connect(forwarder, SIGNAL(processExited(Opie::Core::OProcess*)), + this, SLOT(forwardExited(Opie::Core::OProcess*))); + if (forwarder->start(OProcess::NotifyOnExit) < 0) { + QMessageBox::critical(this, tr("Forwarder Error"), + tr("Forwarder start error:") + tr(strerror(errno))); + return; + } + runButton->setText("stop gateway"); +} + +/** + * React on the process end + */ +void BlueBase::forwardExit(Opie::Core::OProcess* proc) +{ + if (proc->exitStatus() != 0) + QMessageBox::critical(this, tr("Forwarder Error"), + tr("Forwarder start error")); + delete proc; + forwarder = NULL; + runButton->setText("start gateway"); +} + +//eof |