summaryrefslogtreecommitdiff
path: root/noncore
authorharlekin <harlekin>2002-10-17 14:16:03 (UTC)
committer harlekin <harlekin>2002-10-17 14:16:03 (UTC)
commit6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494 (patch) (side-by-side diff)
treed75fbc71ac5d7ae09ad97aacfcd33e43da664f7a /noncore
parente5d66ce2f5939eeae922c4fda9cad084320e647c (diff)
downloadopie-6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494.zip
opie-6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494.tar.gz
opie-6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494.tar.bz2
either device or mac address
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/btconfigwidget.cpp45
-rw-r--r--noncore/apps/opie-console/btconfigwidget.h6
-rw-r--r--noncore/apps/opie-console/io_bt.cpp38
-rw-r--r--noncore/apps/opie-console/io_serial.cpp1
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,12 +1,14 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qcombobox.h>
+#include <qhbox.h>
+#include <qradiobutton.h>
#include "iolayerbase.h"
#include "btconfigwidget.h"
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
uint b = bo->count();
for (uint i = 0; i < bo->count(); i++ ) {
@@ -20,31 +22,38 @@ namespace {
}
}
BTConfigWidget::BTConfigWidget( const QString& name,
QWidget* parent,
const char* na )
: ProfileDialogConnectionWidget( name, parent, na ) {
- m_lay = new QVBoxLayout(this );
- m_device = new QLabel(tr("Device"), this );
- m_deviceCmb = new QComboBox(this );
+ m_lay = new QVBoxLayout( this );
+
+ m_device = new QLabel( tr( "Device" ), this );
+ QHBox *deviceBox = new QHBox( this );
+ m_devRadio = new QRadioButton( deviceBox );
+ connect( m_devRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotDevRadio( bool ) ) );
+ m_deviceCmb = new QComboBox( deviceBox );
m_deviceCmb->setEditable( TRUE );
QLabel *macLabel = new QLabel( this );
- macLabel->setText( tr("Enter peer mac address here:") );
- m_mac = new QLineEdit( this );
+ macLabel->setText( tr( "Or peer mac address" ) );
+ QHBox *macBox = new QHBox( this );
+ m_macRadio = new QRadioButton( macBox );
+ connect( m_macRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotMacRadio( bool ) ) );
+ m_mac = new QLineEdit( macBox );
m_base = new IOLayerBase(this, "base");
m_lay->addWidget( m_device );
- m_lay->addWidget( m_deviceCmb );
+ m_lay->addWidget( deviceBox );
m_lay->addWidget( macLabel );
- m_lay->addWidget( m_mac );
+ m_lay->addWidget( macBox );
m_lay->addWidget( m_base );
m_deviceCmb->insertItem( "/dev/ttyU0" );
m_deviceCmb->insertItem( "/dev/ttyU1" );
}
BTConfigWidget::~BTConfigWidget() {
@@ -52,16 +61,18 @@ BTConfigWidget::~BTConfigWidget() {
void BTConfigWidget::load( const Profile& prof ) {
int rad_flow = prof.readNumEntry("Flow");
int rad_parity = prof.readNumEntry("Parity");
int speed = prof.readNumEntry("Speed");
QString mac = prof.readEntry("Mac");
if (!mac.isEmpty() ) {
m_mac->setText( mac );
+ } else {
+ m_devRadio->setChecked( true );
}
if (rad_flow == 1) {
m_base->setFlow( IOLayerBase::Hardware );
} else if (rad_flow == 2) {
m_base->setFlow( IOLayerBase::Software );
} else if (rad_flow == 0) {
m_base->setFlow( IOLayerBase::None );
@@ -150,8 +161,28 @@ void BTConfigWidget::save( Profile& prof ) {
break;
}
prof.writeEntry("Flow", flow);
prof.writeEntry("Parity", parity);
prof.writeEntry("Speed", speed);
prof.writeEntry("Mac", m_mac->text() );
}
+
+void BTConfigWidget::slotMacRadio( bool on ) {
+ if ( on ) {
+ m_devRadio->setChecked( false );
+ m_deviceCmb->setEnabled( false );
+ m_mac->setEnabled( true );
+ } else {
+ m_devRadio->setChecked( true );
+ }
+}
+
+void BTConfigWidget::slotDevRadio( bool on ) {
+ if ( on ) {
+ m_macRadio->setChecked( false );
+ m_deviceCmb->setEnabled( true );
+ m_mac->setEnabled( false );
+ } else {
+ m_macRadio->setChecked( true );
+ }
+}
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
@@ -2,16 +2,17 @@
#define OPIE_BT_CONFIG_WIDGET_H
#include "profiledialogwidget.h"
class QVBoxLayout;
class QLabel;
class QComboBox;
class QLineEdit;
+class QRadioButton;
class IOLayerBase;
class BTConfigWidget : public ProfileDialogConnectionWidget {
Q_OBJECT
public:
BTConfigWidget( const QString& name, QWidget* parent, const char* name = 0l );
~BTConfigWidget();
@@ -19,13 +20,18 @@ public:
void load( const Profile& );
void save( Profile& );
private:
QVBoxLayout* m_lay;
QLabel* m_device;
QComboBox* m_deviceCmb;
IOLayerBase* m_base;
QLineEdit* m_mac;
+ QRadioButton *m_macRadio;
+ QRadioButton *m_devRadio;
+private slots:
+ void slotMacRadio( bool on );
+ void slotDevRadio( bool on );
};
#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
@@ -12,36 +12,50 @@ IOBt::~IOBt() {
}
}
void IOBt::close() {
IOSerial::close();
// still need error handling
- delete m_attach;
+ if ( m_attach ) {
+ delete m_attach;
+ m_attach = 0;
+ }
}
bool IOBt::open() {
- // hciattach here
- m_attach = new OProcess();
- *m_attach << "hciattach /dev/ttyS2 any 57600";
+ // only set up bt stuff if mac address was set, otherwise use the device set
+ if ( !m_mac.isEmpty() ) {
- // then start hcid, then rcfomm handling (m_mac)
+ // now it should also be checked, if there is a connection to the device with that mac allready
- connect( m_attach, SIGNAL( processExited( OProcess* ) ),
- this, SLOT( slotExited( OProcess* ) ) );
+ // hciattach here
+ m_attach = new OProcess();
+ *m_attach << "hciattach /dev/ttyS2 any 57600";
- if ( m_attach->start() ) {
- IOSerial::open();
+ // then start hcid, then rcfomm handling (m_mac)
+
+ connect( m_attach, SIGNAL( processExited( OProcess* ) ),
+ this, SLOT( slotExited( OProcess* ) ) );
+
+ if ( m_attach->start() ) {
+ IOSerial::open();
+ } else {
+ qWarning("could not attach to device");
+ delete m_attach;
+ m_attach = 0;
+ }
} else {
- qWarning("could not attach to device");
- delete m_attach;
- m_attach = 0;
+ // directly to the normal serial
+ // TODO: look first if the connection really exists. ( is set up )
+
+ IOSerial::open();
}
}
void IOBt::reload( const Profile &config ) {
m_device = config.readEntry("Device", BT_DEFAULT_DEVICE);
m_mac = config.readEntry("Mac", BT_DEFAULT_MAC);
m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY);
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,8 +1,9 @@
+
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <unistd.h>
#include "io_serial.h"
IOSerial::IOSerial(const Profile &config) : IOLayer(config) {
m_read = 0l;