summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager
Side-by-side diff
Diffstat (limited to 'noncore/net/opietooth/manager') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp61
-rw-r--r--noncore/net/opietooth/manager/bluebase.h4
-rw-r--r--noncore/net/opietooth/manager/bluetoothbase.ui182
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
@@ -21,6 +21,10 @@
#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>
@@ -41,6 +45,7 @@ using namespace Opie::Core;
#include <qscrollview.h>
#include <qvbox.h>
#include <qmessagebox.h>
+#include <qcombobox.h>
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qlistview.h>
@@ -55,6 +60,16 @@ using namespace Opie::Core;
#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 )
@@ -78,6 +93,7 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
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);
@@ -108,6 +124,12 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
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);
}
/**
@@ -680,3 +702,42 @@ bool BlueBase::find( const RemoteDevice& rem )
}
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
@@ -17,6 +17,7 @@
#include "popuphelper.h"
#include "bticonloader.h"
+#include "forwarder.h"
#include <remotedevice.h>
#include <manager.h>
@@ -79,6 +80,7 @@ namespace OpieTooth {
QPixmap m_findPix;
BTIconLoader *m_iconLoader;
+ SerialForwarder* forwarder;
private slots:
void addSearchedDevices( const QValueList<RemoteDevice> &newDevices );
@@ -91,6 +93,8 @@ namespace OpieTooth {
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
@@ -11,30 +11,24 @@
<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>
@@ -376,7 +370,169 @@
</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>
- </grid>
+ <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>
+ </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>