summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/bluebase.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp61
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 @@
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
@@ -43,2 +47,3 @@ using namespace Opie::Core;
43#include <qmessagebox.h> 47#include <qmessagebox.h>
48#include <qcombobox.h>
44#include <qcheckbox.h> 49#include <qcheckbox.h>
@@ -57,2 +62,12 @@ using namespace Opie::Core;
57using namespace OpieTooth; 62using namespace OpieTooth;
63//Array of possible speeds of the serial port
64struct 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
@@ -80,2 +95,3 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
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
@@ -110,2 +126,8 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
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}
@@ -682 +704,40 @@ bool BlueBase::find( const RemoteDevice& rem )
682} 704}
705
706/**
707 * Start process of the cell phone forwarding
708 */
709void 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 */
733void 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