author | harlekin <harlekin> | 2002-10-17 14:16:03 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-17 14:16:03 (UTC) |
commit | 6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494 (patch) (unidiff) | |
tree | d75fbc71ac5d7ae09ad97aacfcd33e43da664f7a | |
parent | e5d66ce2f5939eeae922c4fda9cad084320e647c (diff) | |
download | opie-6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494.zip opie-6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494.tar.gz opie-6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494.tar.bz2 |
either device or mac address
-rw-r--r-- | noncore/apps/opie-console/btconfigwidget.cpp | 45 | ||||
-rw-r--r-- | noncore/apps/opie-console/btconfigwidget.h | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_bt.cpp | 38 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 1 |
4 files changed, 71 insertions, 19 deletions
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp index 7673d0b..6246f92 100644 --- a/noncore/apps/opie-console/btconfigwidget.cpp +++ b/noncore/apps/opie-console/btconfigwidget.cpp | |||
@@ -1,75 +1,86 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qlineedit.h> | 3 | #include <qlineedit.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qhbox.h> | ||
6 | #include <qradiobutton.h> | ||
5 | 7 | ||
6 | #include "iolayerbase.h" | 8 | #include "iolayerbase.h" |
7 | #include "btconfigwidget.h" | 9 | #include "btconfigwidget.h" |
8 | 10 | ||
9 | namespace { | 11 | namespace { |
10 | void setCurrent( const QString& str, QComboBox* bo ) { | 12 | void setCurrent( const QString& str, QComboBox* bo ) { |
11 | uint b = bo->count(); | 13 | uint b = bo->count(); |
12 | for (uint i = 0; i < bo->count(); i++ ) { | 14 | for (uint i = 0; i < bo->count(); i++ ) { |
13 | if ( bo->text(i) == str ) { | 15 | if ( bo->text(i) == str ) { |
14 | bo->setCurrentItem( i ); | 16 | bo->setCurrentItem( i ); |
15 | return; | 17 | return; |
16 | } | 18 | } |
17 | } | 19 | } |
18 | bo->insertItem( str ); | 20 | bo->insertItem( str ); |
19 | bo->setCurrentItem( b ); | 21 | bo->setCurrentItem( b ); |
20 | } | 22 | } |
21 | } | 23 | } |
22 | 24 | ||
23 | BTConfigWidget::BTConfigWidget( const QString& name, | 25 | BTConfigWidget::BTConfigWidget( const QString& name, |
24 | QWidget* parent, | 26 | QWidget* parent, |
25 | const char* na ) | 27 | const char* na ) |
26 | : ProfileDialogConnectionWidget( name, parent, na ) { | 28 | : ProfileDialogConnectionWidget( name, parent, na ) { |
27 | 29 | ||
28 | m_lay = new QVBoxLayout(this ); | 30 | m_lay = new QVBoxLayout( this ); |
29 | m_device = new QLabel(tr("Device"), this ); | 31 | |
30 | m_deviceCmb = new QComboBox(this ); | 32 | m_device = new QLabel( tr( "Device" ), this ); |
33 | QHBox *deviceBox = new QHBox( this ); | ||
34 | m_devRadio = new QRadioButton( deviceBox ); | ||
35 | connect( m_devRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotDevRadio( bool ) ) ); | ||
36 | m_deviceCmb = new QComboBox( deviceBox ); | ||
31 | m_deviceCmb->setEditable( TRUE ); | 37 | m_deviceCmb->setEditable( TRUE ); |
32 | 38 | ||
33 | QLabel *macLabel = new QLabel( this ); | 39 | QLabel *macLabel = new QLabel( this ); |
34 | macLabel->setText( tr("Enter peer mac address here:") ); | 40 | macLabel->setText( tr( "Or peer mac address" ) ); |
35 | m_mac = new QLineEdit( this ); | 41 | QHBox *macBox = new QHBox( this ); |
42 | m_macRadio = new QRadioButton( macBox ); | ||
43 | connect( m_macRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotMacRadio( bool ) ) ); | ||
44 | m_mac = new QLineEdit( macBox ); | ||
36 | 45 | ||
37 | m_base = new IOLayerBase(this, "base"); | 46 | m_base = new IOLayerBase(this, "base"); |
38 | 47 | ||
39 | m_lay->addWidget( m_device ); | 48 | m_lay->addWidget( m_device ); |
40 | m_lay->addWidget( m_deviceCmb ); | 49 | m_lay->addWidget( deviceBox ); |
41 | m_lay->addWidget( macLabel ); | 50 | m_lay->addWidget( macLabel ); |
42 | m_lay->addWidget( m_mac ); | 51 | m_lay->addWidget( macBox ); |
43 | m_lay->addWidget( m_base ); | 52 | m_lay->addWidget( m_base ); |
44 | 53 | ||
45 | m_deviceCmb->insertItem( "/dev/ttyU0" ); | 54 | m_deviceCmb->insertItem( "/dev/ttyU0" ); |
46 | m_deviceCmb->insertItem( "/dev/ttyU1" ); | 55 | m_deviceCmb->insertItem( "/dev/ttyU1" ); |
47 | } | 56 | } |
48 | 57 | ||
49 | BTConfigWidget::~BTConfigWidget() { | 58 | BTConfigWidget::~BTConfigWidget() { |
50 | 59 | ||
51 | } | 60 | } |
52 | void BTConfigWidget::load( const Profile& prof ) { | 61 | void BTConfigWidget::load( const Profile& prof ) { |
53 | int rad_flow = prof.readNumEntry("Flow"); | 62 | int rad_flow = prof.readNumEntry("Flow"); |
54 | int rad_parity = prof.readNumEntry("Parity"); | 63 | int rad_parity = prof.readNumEntry("Parity"); |
55 | int speed = prof.readNumEntry("Speed"); | 64 | int speed = prof.readNumEntry("Speed"); |
56 | QString mac = prof.readEntry("Mac"); | 65 | QString mac = prof.readEntry("Mac"); |
57 | 66 | ||
58 | if (!mac.isEmpty() ) { | 67 | if (!mac.isEmpty() ) { |
59 | m_mac->setText( mac ); | 68 | m_mac->setText( mac ); |
69 | } else { | ||
70 | m_devRadio->setChecked( true ); | ||
60 | } | 71 | } |
61 | 72 | ||
62 | if (rad_flow == 1) { | 73 | if (rad_flow == 1) { |
63 | m_base->setFlow( IOLayerBase::Hardware ); | 74 | m_base->setFlow( IOLayerBase::Hardware ); |
64 | } else if (rad_flow == 2) { | 75 | } else if (rad_flow == 2) { |
65 | m_base->setFlow( IOLayerBase::Software ); | 76 | m_base->setFlow( IOLayerBase::Software ); |
66 | } else if (rad_flow == 0) { | 77 | } else if (rad_flow == 0) { |
67 | m_base->setFlow( IOLayerBase::None ); | 78 | m_base->setFlow( IOLayerBase::None ); |
68 | } | 79 | } |
69 | 80 | ||
70 | if (rad_parity == 1) { | 81 | if (rad_parity == 1) { |
71 | m_base->setParity( IOLayerBase::Even ); | 82 | m_base->setParity( IOLayerBase::Even ); |
72 | } else if ( rad_parity == 2 ) { | 83 | } else if ( rad_parity == 2 ) { |
73 | m_base->setParity( IOLayerBase::Odd ); | 84 | m_base->setParity( IOLayerBase::Odd ); |
74 | } else { | 85 | } else { |
75 | m_base->setParity( IOLayerBase::NonePar ); | 86 | m_base->setParity( IOLayerBase::NonePar ); |
@@ -142,16 +153,36 @@ void BTConfigWidget::save( Profile& prof ) { | |||
142 | case IOLayerBase::Baud_38400: | 153 | case IOLayerBase::Baud_38400: |
143 | speed = 38400; | 154 | speed = 38400; |
144 | break; | 155 | break; |
145 | case IOLayerBase::Baud_19200: | 156 | case IOLayerBase::Baud_19200: |
146 | speed = 19200; | 157 | speed = 19200; |
147 | break; | 158 | break; |
148 | case IOLayerBase::Baud_9600: | 159 | case IOLayerBase::Baud_9600: |
149 | speed = 9600; | 160 | speed = 9600; |
150 | break; | 161 | break; |
151 | } | 162 | } |
152 | 163 | ||
153 | prof.writeEntry("Flow", flow); | 164 | prof.writeEntry("Flow", flow); |
154 | prof.writeEntry("Parity", parity); | 165 | prof.writeEntry("Parity", parity); |
155 | prof.writeEntry("Speed", speed); | 166 | prof.writeEntry("Speed", speed); |
156 | prof.writeEntry("Mac", m_mac->text() ); | 167 | prof.writeEntry("Mac", m_mac->text() ); |
157 | } | 168 | } |
169 | |||
170 | void BTConfigWidget::slotMacRadio( bool on ) { | ||
171 | if ( on ) { | ||
172 | m_devRadio->setChecked( false ); | ||
173 | m_deviceCmb->setEnabled( false ); | ||
174 | m_mac->setEnabled( true ); | ||
175 | } else { | ||
176 | m_devRadio->setChecked( true ); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | void BTConfigWidget::slotDevRadio( bool on ) { | ||
181 | if ( on ) { | ||
182 | m_macRadio->setChecked( false ); | ||
183 | m_deviceCmb->setEnabled( true ); | ||
184 | m_mac->setEnabled( false ); | ||
185 | } else { | ||
186 | m_macRadio->setChecked( true ); | ||
187 | } | ||
188 | } | ||
diff --git a/noncore/apps/opie-console/btconfigwidget.h b/noncore/apps/opie-console/btconfigwidget.h index ceb13ee..d60d8a2 100644 --- a/noncore/apps/opie-console/btconfigwidget.h +++ b/noncore/apps/opie-console/btconfigwidget.h | |||
@@ -1,31 +1,37 @@ | |||
1 | #ifndef OPIE_BT_CONFIG_WIDGET_H | 1 | #ifndef OPIE_BT_CONFIG_WIDGET_H |
2 | #define OPIE_BT_CONFIG_WIDGET_H | 2 | #define OPIE_BT_CONFIG_WIDGET_H |
3 | 3 | ||
4 | #include "profiledialogwidget.h" | 4 | #include "profiledialogwidget.h" |
5 | 5 | ||
6 | class QVBoxLayout; | 6 | class QVBoxLayout; |
7 | class QLabel; | 7 | class QLabel; |
8 | class QComboBox; | 8 | class QComboBox; |
9 | class QLineEdit; | 9 | class QLineEdit; |
10 | class QRadioButton; | ||
10 | class IOLayerBase; | 11 | class IOLayerBase; |
11 | class BTConfigWidget : public ProfileDialogConnectionWidget { | 12 | class BTConfigWidget : public ProfileDialogConnectionWidget { |
12 | 13 | ||
13 | Q_OBJECT | 14 | Q_OBJECT |
14 | 15 | ||
15 | public: | 16 | public: |
16 | BTConfigWidget( const QString& name, QWidget* parent, const char* name = 0l ); | 17 | BTConfigWidget( const QString& name, QWidget* parent, const char* name = 0l ); |
17 | ~BTConfigWidget(); | 18 | ~BTConfigWidget(); |
18 | 19 | ||
19 | void load( const Profile& ); | 20 | void load( const Profile& ); |
20 | void save( Profile& ); | 21 | void save( Profile& ); |
21 | private: | 22 | private: |
22 | QVBoxLayout* m_lay; | 23 | QVBoxLayout* m_lay; |
23 | QLabel* m_device; | 24 | QLabel* m_device; |
24 | QComboBox* m_deviceCmb; | 25 | QComboBox* m_deviceCmb; |
25 | IOLayerBase* m_base; | 26 | IOLayerBase* m_base; |
26 | QLineEdit* m_mac; | 27 | QLineEdit* m_mac; |
28 | QRadioButton *m_macRadio; | ||
29 | QRadioButton *m_devRadio; | ||
27 | 30 | ||
31 | private slots: | ||
32 | void slotMacRadio( bool on ); | ||
33 | void slotDevRadio( bool on ); | ||
28 | }; | 34 | }; |
29 | 35 | ||
30 | 36 | ||
31 | #endif | 37 | #endif |
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index 0831faf..d71aacc 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp | |||
@@ -4,52 +4,66 @@ | |||
4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { | 4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { |
5 | m_attach = 0; | 5 | m_attach = 0; |
6 | } | 6 | } |
7 | 7 | ||
8 | 8 | ||
9 | IOBt::~IOBt() { | 9 | IOBt::~IOBt() { |
10 | if ( m_attach ) { | 10 | if ( m_attach ) { |
11 | delete m_attach; | 11 | delete m_attach; |
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | 15 | ||
16 | void IOBt::close() { | 16 | void IOBt::close() { |
17 | 17 | ||
18 | IOSerial::close(); | 18 | IOSerial::close(); |
19 | // still need error handling | 19 | // still need error handling |
20 | delete m_attach; | 20 | if ( m_attach ) { |
21 | delete m_attach; | ||
22 | m_attach = 0; | ||
23 | } | ||
21 | } | 24 | } |
22 | 25 | ||
23 | bool IOBt::open() { | 26 | bool IOBt::open() { |
24 | 27 | ||
25 | // hciattach here | 28 | // only set up bt stuff if mac address was set, otherwise use the device set |
26 | m_attach = new OProcess(); | 29 | if ( !m_mac.isEmpty() ) { |
27 | *m_attach << "hciattach /dev/ttyS2 any 57600"; | ||
28 | 30 | ||
29 | // then start hcid, then rcfomm handling (m_mac) | 31 | // now it should also be checked, if there is a connection to the device with that mac allready |
30 | 32 | ||
31 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), | 33 | // hciattach here |
32 | this, SLOT( slotExited( OProcess* ) ) ); | 34 | m_attach = new OProcess(); |
35 | *m_attach << "hciattach /dev/ttyS2 any 57600"; | ||
33 | 36 | ||
34 | if ( m_attach->start() ) { | 37 | // then start hcid, then rcfomm handling (m_mac) |
35 | IOSerial::open(); | 38 | |
39 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), | ||
40 | this, SLOT( slotExited( OProcess* ) ) ); | ||
41 | |||
42 | if ( m_attach->start() ) { | ||
43 | IOSerial::open(); | ||
44 | } else { | ||
45 | qWarning("could not attach to device"); | ||
46 | delete m_attach; | ||
47 | m_attach = 0; | ||
48 | } | ||
36 | } else { | 49 | } else { |
37 | qWarning("could not attach to device"); | 50 | // directly to the normal serial |
38 | delete m_attach; | 51 | // TODO: look first if the connection really exists. ( is set up ) |
39 | m_attach = 0; | 52 | |
53 | IOSerial::open(); | ||
40 | } | 54 | } |
41 | } | 55 | } |
42 | 56 | ||
43 | void IOBt::reload( const Profile &config ) { | 57 | void IOBt::reload( const Profile &config ) { |
44 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); | 58 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); |
45 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); | 59 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); |
46 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); | 60 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); |
47 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); | 61 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); |
48 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); | 62 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); |
49 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); | 63 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); |
50 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); | 64 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); |
51 | } | 65 | } |
52 | 66 | ||
53 | 67 | ||
54 | QString IOBt::identifier() const { | 68 | QString IOBt::identifier() const { |
55 | return "bluetooth"; | 69 | return "bluetooth"; |
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index cc63c58..e6d1688 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -1,16 +1,17 @@ | |||
1 | |||
1 | #include <fcntl.h> | 2 | #include <fcntl.h> |
2 | #include <termios.h> | 3 | #include <termios.h> |
3 | #include <errno.h> | 4 | #include <errno.h> |
4 | #include <unistd.h> | 5 | #include <unistd.h> |
5 | #include "io_serial.h" | 6 | #include "io_serial.h" |
6 | 7 | ||
7 | IOSerial::IOSerial(const Profile &config) : IOLayer(config) { | 8 | IOSerial::IOSerial(const Profile &config) : IOLayer(config) { |
8 | m_read = 0l; | 9 | m_read = 0l; |
9 | m_error = 0l; | 10 | m_error = 0l; |
10 | m_fd = 0; | 11 | m_fd = 0; |
11 | m_connected = false; | 12 | m_connected = false; |
12 | reload(config); | 13 | reload(config); |
13 | } | 14 | } |
14 | 15 | ||
15 | 16 | ||
16 | IOSerial::~IOSerial() { | 17 | IOSerial::~IOSerial() { |