Diffstat (limited to 'noncore/net/opietooth/manager') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 61 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluetoothbase.ui | 182 |
3 files changed, 234 insertions, 13 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 @@ -20,8 +20,12 @@ #include "hciconfwrapper.h" #include "devicehandler.h" #include "btconnectionitem.h" #include "rfcommassigndialogimpl.h" +#include "forwarder.h" +#include <termios.h> +#include <string.h> +#include <errno.h> /* OPIE */ #include <qpe/qpeapplication.h> #include <qpe/resource.h> @@ -40,8 +44,9 @@ using namespace Opie::Core; #include <qtabwidget.h> #include <qscrollview.h> #include <qvbox.h> #include <qmessagebox.h> +#include <qcombobox.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qlistview.h> #include <qdir.h> @@ -54,8 +59,18 @@ using namespace Opie::Core; #include <services.h> #include <stdlib.h> 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} +}; BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) : BluetoothBase( parent, name, fl ) { @@ -77,8 +92,9 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), this, SLOT( addSignalStrength(const QString&,const QString&) ) ); + connect(runButton, SIGNAL(clicked()), this, SLOT(doForward())); // let hold be rightButtonClicked() QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); @@ -107,8 +123,14 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) addConnectedDevices(); readSavedDevices(); addServicesToDevices(); 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); } /** * Reads all options from the config file @@ -679,4 +701,43 @@ bool BlueBase::find( const RemoteDevice& rem ) return true; } return false; // not found } + +/** + * 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 diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 48883d2..0128a88 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h @@ -16,8 +16,9 @@ #include "popuphelper.h" #include "bticonloader.h" +#include "forwarder.h" #include <remotedevice.h> #include <manager.h> @@ -78,8 +79,9 @@ namespace OpieTooth { QPixmap m_onPix; QPixmap m_findPix; BTIconLoader *m_iconLoader; + SerialForwarder* forwarder; private slots: void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); void addServicesToDevices(); @@ -90,8 +92,10 @@ namespace OpieTooth { void startServiceActionClicked( QListViewItem *item ); void startServiceActionHold( QListViewItem *, const QPoint &, int ); void deviceActive( const QString& mac, bool connected ); void applyConfigChanges(); + void doForward(); + void forwardExit(Opie::Core::OProcess* proc); void addSignalStrength(); void addSignalStrength( const QString& mac, const QString& strengh ); void rfcommDialog(); diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index cbde3c6..a5e2c6f 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui @@ -10,32 +10,26 @@ <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>293</width> - <height>382</height> + <width>268</width> + <height>368</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Form1</string> </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> - </property> - <grid> + <vbox> <property stdset="1"> <name>margin</name> - <number>4</number> + <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>2</number> + <number>0</number> </property> - <widget row="0" column="0" > + <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>Status</cstring> @@ -375,8 +369,170 @@ </property> </widget> </vbox> </widget> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>tab</cstring> + </property> + <attribute> + <name>title</name> + <string>Phone</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>0</number> + </property> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>cellForwarder</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Cell Forwarder</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout9</cstring> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout5</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>serDevLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Serial device:</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>serDevName</cstring> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout6</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>serSpeedLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Speed:</string> + </property> + </widget> + <widget> + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>serSpeed</cstring> + </property> + </widget> + </hbox> + </widget> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>runButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>start gateway</string> + </property> + </widget> + </vbox> + </widget> + </vbox> + </widget> + </vbox> + </widget> </widget> - </grid> + </vbox> </widget> +<customwidgets> + <customwidget> + <class>QWidget</class> + <header location="local">qwidget.h</header> + <sizehint> + <width>100</width> + <height>100</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>7</hordata> + <verdata>7</verdata> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> +</customwidgets> +<images> + <image> + <name>image0</name> + <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> + </image> +</images> </UI> |