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
@@ -18,12 +18,16 @@
18#include "bluebase.h" 18#include "bluebase.h"
19#include "scandialog.h" 19#include "scandialog.h"
20#include "hciconfwrapper.h" 20#include "hciconfwrapper.h"
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>
27#include <qpe/resource.h> 31#include <qpe/resource.h>
28#include <qpe/config.h> 32#include <qpe/config.h>
29#include <opie2/odebug.h> 33#include <opie2/odebug.h>
@@ -38,12 +42,13 @@ using namespace Opie::Core;
38#include <qimage.h> 42#include <qimage.h>
39#include <qpixmap.h> 43#include <qpixmap.h>
40#include <qtabwidget.h> 44#include <qtabwidget.h>
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>
47#include <qdir.h> 52#include <qdir.h>
48#include <qpopupmenu.h> 53#include <qpopupmenu.h>
49#include <qtimer.h> 54#include <qtimer.h>
@@ -52,12 +57,22 @@ using namespace Opie::Core;
52/* STD */ 57/* STD */
53#include <remotedevice.h> 58#include <remotedevice.h>
54#include <services.h> 59#include <services.h>
55#include <stdlib.h> 60#include <stdlib.h>
56 61
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
59BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 74BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
60 : BluetoothBase( parent, name, fl ) 75 : BluetoothBase( parent, name, fl )
61{ 76{
62 m_localDevice = new Manager( "hci0" ); 77 m_localDevice = new Manager( "hci0" );
63 78
@@ -75,12 +90,13 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
75 connect( m_localDevice, SIGNAL( available(const QString&,bool) ), 90 connect( m_localDevice, SIGNAL( available(const QString&,bool) ),
76 this, SLOT( deviceActive(const QString&,bool) ) ); 91 this, SLOT( deviceActive(const QString&,bool) ) );
77 connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), 92 connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ),
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);
84 QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); 100 QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold);
85 101
86 //Load all icons needed 102 //Load all icons needed
@@ -105,12 +121,18 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
105 m_iconLoader = new BTIconLoader(); 121 m_iconLoader = new BTIconLoader();
106 writeToHciConfig(); 122 writeToHciConfig();
107 addConnectedDevices(); 123 addConnectedDevices();
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/**
114 * Reads all options from the config file 136 * Reads all options from the config file
115 */ 137 */
116void BlueBase::readConfig() 138void BlueBase::readConfig()
@@ -677,6 +699,45 @@ bool BlueBase::find( const RemoteDevice& rem )
677 device = (BTDeviceItem*)item; 699 device = (BTDeviceItem*)item;
678 if ( rem.equals( device->remoteDevice() ) ) 700 if ( rem.equals( device->remoteDevice() ) )
679 return true; 701 return true;
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 */
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