summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/btconfigwidget.cpp140
-rw-r--r--noncore/apps/opie-console/btconfigwidget.h29
-rw-r--r--noncore/apps/opie-console/default.cpp14
-rw-r--r--noncore/apps/opie-console/io_irda.cpp60
-rw-r--r--noncore/apps/opie-console/io_irda.h46
-rw-r--r--noncore/apps/opie-console/iolayerbase.cpp16
-rw-r--r--noncore/apps/opie-console/iolayerbase.h4
-rw-r--r--noncore/apps/opie-console/irdaconfigwidget.cpp141
-rw-r--r--noncore/apps/opie-console/irdaconfigwidget.h29
-rw-r--r--noncore/apps/opie-console/opie-console.pro9
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp2
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.cpp21
-rw-r--r--noncore/apps/opie-console/serialconfigwidget.cpp14
-rw-r--r--noncore/apps/opie-console/widget_layer.h4
14 files changed, 498 insertions, 31 deletions
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp
new file mode 100644
index 0000000..acc4811
--- a/dev/null
+++ b/noncore/apps/opie-console/btconfigwidget.cpp
@@ -0,0 +1,140 @@
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcombobox.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++ ) {
+ if ( bo->text(i) == str ) {
+ bo->setCurrentItem( i );
+ return;
+ }
+ }
+ bo->insertItem( str );
+ bo->setCurrentItem( b );
+ }
+}
+
+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_deviceCmb->setEditable( TRUE );
+
+ m_base = new IOLayerBase(this, "base");
+
+ m_lay->addWidget( m_device );
+ m_lay->addWidget( m_deviceCmb );
+ m_lay->addWidget( m_base );
+
+ m_deviceCmb->insertItem( "/dev/ttyU0" );
+ m_deviceCmb->insertItem( "/dev/ttyU1" );
+}
+
+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");
+
+
+ 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 );
+ }
+
+ if (rad_parity == 1) {
+ m_base->setParity( IOLayerBase::Even );
+ } else {
+ m_base->setParity( IOLayerBase::Odd );
+ }
+
+ switch( speed ) {
+ case 115200:
+ m_base->setSpeed(IOLayerBase::Baud_115200 );
+ break;
+ case 57600:
+ m_base->setSpeed( IOLayerBase::Baud_57600 );
+ break;
+ case 38400:
+ m_base->setSpeed(IOLayerBase::Baud_38400 );
+ break;
+ case 19200:
+ m_base->setSpeed( IOLayerBase::Baud_19200 );
+ break;
+ case 9600:
+ default:
+ m_base->setSpeed(IOLayerBase::Baud_9600 );
+ break;
+ }
+
+ if ( prof.readEntry("Device").isEmpty() ) return;
+ setCurrent( prof.readEntry("Device"), m_deviceCmb );
+
+}
+/*
+ * save speed,
+ * flow,
+ * parity
+ */
+void BTConfigWidget::save( Profile& prof ) {
+ int flow, parity, speed;
+ prof.writeEntry("Device", m_deviceCmb->currentText() );
+
+
+ switch( m_base->flow() ) {
+ case IOLayerBase::None:
+ flow = 0;
+ break;
+ case IOLayerBase::Software:
+ flow = 2;
+ break;
+ case IOLayerBase::Hardware:
+ flow = 1;
+ break;
+ }
+
+ switch( m_base->parity() ) {
+ case IOLayerBase::Odd:
+ parity = 2;
+ break;
+ case IOLayerBase::Even:
+ parity = 1;
+ break;
+ }
+
+ switch( m_base->speed() ) {
+ case IOLayerBase::Baud_115200:
+ speed = 115200;
+ break;
+ case IOLayerBase::Baud_57600:
+ speed = 57600;
+ break;
+ case IOLayerBase::Baud_38400:
+ speed = 38400;
+ break;
+ case IOLayerBase::Baud_19200:
+ speed = 19200;
+ break;
+ case IOLayerBase::Baud_9600:
+ speed = 9600;
+ break;
+ }
+
+ prof.writeEntry("Flow", flow);
+ prof.writeEntry("Parity", parity);
+ prof.writeEntry("Speed", speed);
+}
diff --git a/noncore/apps/opie-console/btconfigwidget.h b/noncore/apps/opie-console/btconfigwidget.h
new file mode 100644
index 0000000..64190ad
--- a/dev/null
+++ b/noncore/apps/opie-console/btconfigwidget.h
@@ -0,0 +1,29 @@
+#ifndef OPIE_BT_CONFIG_WIDGET_H
+#define OPIE_BT_CONFIG_WIDGET_H
+
+#include "profiledialogwidget.h"
+
+class QVBoxLayout;
+class QLabel;
+class QComboBox;
+class IOLayerBase;
+class BTConfigWidget : public ProfileDialogConnectionWidget {
+
+ Q_OBJECT
+
+public:
+ BTConfigWidget( const QString& name, QWidget* parent, const char* name = 0l );
+ ~BTConfigWidget();
+
+ void load( const Profile& );
+ void save( Profile& );
+private:
+ QVBoxLayout* m_lay;
+ QLabel* m_device;
+ QComboBox* m_deviceCmb;
+ IOLayerBase* m_base;
+
+};
+
+
+#endif
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
index da6f3e2..62f02f5 100644
--- a/noncore/apps/opie-console/default.cpp
+++ b/noncore/apps/opie-console/default.cpp
@@ -1,74 +1,76 @@
#include "io_serial.h"
#include "sz_transfer.h"
#include "serialconfigwidget.h"
+#include "irdaconfigwidget.h"
+#include "btconfigwidget.h"
#include "terminalwidget.h"
#include "vt102emulation.h"
#include "default.h"
extern "C" {
// FILE Transfer Stuff
FileTransferLayer* newSZTransfer(IOLayer* lay) {
return new SzTransfer( SzTransfer::SZ, lay );
}
FileTransferLayer* newSYTransfer(IOLayer* lay) {
return new SzTransfer( SzTransfer::SY, lay );
}
FileTransferLayer* newSXTransfer(IOLayer* lay) {
return new SzTransfer( SzTransfer::SX, lay );
}
// Layer stuff
IOLayer* newSerialLayer( const Profile& prof) {
return new IOSerial( prof );
}
IOLayer* newBTLayer( const Profile& ) {
return 0l;
}
IOLayer* newIrDaLayer( const Profile& ) {
return 0l;
}
// Connection Widgets
- ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* wid) {
- return new SerialConfigWidget(str, wid );
+ ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) {
+ return new SerialConfigWidget( str, wid );
}
- ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) {
- return newSerialWidget(str, wid);
+ ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) {
+ return new IrdaConfigWidget( str, wid );
}
- ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) {
- return newSerialWidget(str, wid );
+ ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) {
+ return new BTConfigWidget(str, wid );
}
// Terminal Widget(s)
ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) {
return new TerminalWidget(na, wid,0 );
}
// VT Emulations
EmulationLayer* newVT102( Widget* wid ) {
return new Vt102Emulation( wid );
}
};
Default::Default( MetaFactory* fact ) {
fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer );
fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer );
fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer );
fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer );
fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 );
}
Default::~Default() {
}
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp
new file mode 100644
index 0000000..8e31e82
--- a/dev/null
+++ b/noncore/apps/opie-console/io_irda.cpp
@@ -0,0 +1,60 @@
+
+#include "io_irda.h"
+
+IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) {
+ m_attach = 0;
+}
+
+
+IOIrda::~IOIrda() {
+ if ( m_attach ) {
+ delete m_attach;
+ }
+}
+
+
+void IOIrda::close() {
+
+ IOSerial::close();
+ // still need error handling
+ delete m_attach;
+}
+
+bool IOIrda::open() {
+
+ // irdaattach here
+ m_attach = new OProcess();
+ *m_attach << "irattach /dev/ttyS2 -s";
+
+ 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;
+ }
+}
+
+void IOIrda::reload( const Profile &config ) {
+ m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE);
+ m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD);
+ m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY);
+ m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS);
+ m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS);
+ m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW);
+}
+
+
+QString IOIrda::identifier() const {
+ return "irda";
+}
+
+QString IOIrda::name() const {
+ return "Irda IO Layer";
+}
+
+void IOIrda::slotExited(OProcess* proc ){
+ close();
+}
diff --git a/noncore/apps/opie-console/io_irda.h b/noncore/apps/opie-console/io_irda.h
new file mode 100644
index 0000000..3aee951
--- a/dev/null
+++ b/noncore/apps/opie-console/io_irda.h
@@ -0,0 +1,46 @@
+#ifndef OPIE_IO_IRDA
+#define OPIE_IO_IRDA
+
+#include <opie/oprocess.h>
+#include "io_serial.h"
+
+/* Default values to be used if the profile information is incomplete */
+#define IRDA_DEFAULT_DEVICE "/dev/ircomm0"
+#define IRDA_DEFAULT_BAUD 9600
+#define IRDA_DEFAULT_PARITY 0
+#define IRDA_DEFAULT_DBITS 8
+#define IRDA_DEFAULT_SBITS 1
+#define IRDA_DEFAULT_FLOW 0
+
+/* IOSerial implements a RS232 IO Layer */
+
+class IOIrda : public IOSerial {
+
+ Q_OBJECT
+
+public:
+
+ IOIrda(const Profile &);
+ ~IOIrda();
+
+ QString identifier() const;
+ QString name() const;
+
+signals:
+ void received(const QByteArray &);
+ void error(int, const QString &);
+
+public slots:
+ bool open();
+ void close();
+ void reload(const Profile &);
+
+private:
+ OProcess *m_attach;
+
+private slots:
+ void slotExited(OProcess* proc);
+
+};
+
+#endif /* OPIE_IO_IRDA */
diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp
index 99b6cc1..ec88b49 100644
--- a/noncore/apps/opie-console/iolayerbase.cpp
+++ b/noncore/apps/opie-console/iolayerbase.cpp
@@ -1,149 +1,159 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qcombobox.h>
#include <qbuttongroup.h>
#include <qhbuttongroup.h>
#include <qradiobutton.h>
#include "iolayerbase.h"
namespace {
enum ParityIds {
id_parity_odd,
id_parity_even
};
enum FlowIds {
id_flow_hw,
- id_flow_sw
+ id_flow_sw,
+ id_flow_none,
};
enum SpeedIds {
id_baud_115200,
id_baud_57600,
id_baud_38400,
id_baud_19200,
id_baud_9600
};
}
IOLayerBase::IOLayerBase( QWidget* par, const char* name )
: QWidget( par, name )
{
m_speedLabel = new QLabel(tr("Speed"), this );
m_speedBox = new QComboBox(this );
m_groupFlow = new QButtonGroup(tr("Flow control"),this );
m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow );
m_flowSw = new QRadioButton(tr("Software"), m_groupFlow );
+ m_flowNone = new QRadioButton( tr("None"), m_groupFlow );
m_groupParity = new QButtonGroup(tr("Parity"), this );
m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity );
m_parityEven = new QRadioButton(tr("Even"), m_groupParity );
- m_lroot = new QVBoxLayout(this );
+ m_lroot = new QVBoxLayout( this );
m_lroot->add(m_speedLabel );
m_lroot->add(m_speedBox );
m_lroot->setStretchFactor(m_speedLabel, 1);
m_lroot->setStretchFactor(m_speedBox, 1 );
m_hbox = new QHBoxLayout(m_groupFlow, 2 );
m_hbox->add(m_flowHw );
m_hbox->add(m_flowSw );
+ m_hbox->add(m_flowNone );
m_lroot->add(m_groupFlow );
m_lroot->setStretchFactor(m_groupFlow, 2 );
m_hboxPar = new QHBoxLayout( m_groupParity, 2 );
m_hboxPar->add(m_parityOdd );
m_hboxPar->add(m_parityEven );
m_lroot->add(m_groupParity );
m_lroot->setStretchFactor(m_groupParity, 2 );
// profiles
m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 );
m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 );
m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 );
m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 );
m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 );
};
IOLayerBase::~IOLayerBase() {
}
void IOLayerBase::setFlow( Flow flo ) {
switch ( flo ) {
case Software:
m_flowSw->setChecked( true );
break;
case Hardware:
m_flowHw->setChecked( true );
break;
+ case None:
+ m_flowNone->setChecked( true );
+ break;
}
}
+
void IOLayerBase::setParity( Parity par ) {
switch( par ) {
case Odd:
m_parityOdd->setChecked( true );
break;
case Even:
m_parityEven->setChecked( true );
break;
}
}
void IOLayerBase::setSpeed( Speed sp ) {
int index;
switch( sp ) {
case Baud_115200:
index = id_baud_115200;
break;
case Baud_57600:
index = id_baud_57600;
break;
case Baud_38400:
index = id_baud_38400;
break;
case Baud_19200:
index = id_baud_19200;
break;
case Baud_9600:
index = id_baud_9600;
break;
}
m_speedBox->setCurrentItem(index );
}
IOLayerBase::Flow IOLayerBase::flow()const {
if (m_flowHw->isChecked() ) {
qWarning("Hardware flow");
return Hardware;
- }else {
+ }else if( m_flowSw->isChecked() ) {
qWarning("Software");
return Software;
+ } else {
+ qWarning("None");
+ return None;
}
}
IOLayerBase::Parity IOLayerBase::parity()const {
if (m_parityOdd->isChecked() )
return Odd;
else
return Even;
}
IOLayerBase::Speed IOLayerBase::speed()const{
switch( m_speedBox->currentItem() ) {
case id_baud_115200:
return Baud_115200;
break;
case id_baud_57600:
return Baud_57600;
break;
case id_baud_38400:
return Baud_38400;
break;
case id_baud_19200:
return Baud_19200;
break;
case id_baud_9600:
return Baud_9600;
break;
}
}
diff --git a/noncore/apps/opie-console/iolayerbase.h b/noncore/apps/opie-console/iolayerbase.h
index 151a04b..d14f334 100644
--- a/noncore/apps/opie-console/iolayerbase.h
+++ b/noncore/apps/opie-console/iolayerbase.h
@@ -1,47 +1,47 @@
#ifndef OPIE_IO_LAYER_BASE_H
#define OPIE_IO_LAYER_BASE_H
#include <qwidget.h>
class QLabel;
class QComboBox;
class QVBoxLayout;
class QButtonGroup;
class QRadioButton;
class QHBoxLayout;
class IOLayerBase : public QWidget {
Q_OBJECT
public:
- enum Flow { Hardware, Software };
+ enum Flow { Hardware, Software, None };
enum Parity{ Odd =2 , Even =1 };
enum Speed{ Baud_115200,
Baud_57600,
Baud_38400,
Baud_19200,
Baud_9600 };
IOLayerBase( QWidget* base, const char* name = 0l);
~IOLayerBase();
void setFlow( Flow flo );
void setParity( Parity par );
void setSpeed( Speed speed );
Flow flow()const;
Parity parity()const;
Speed speed()const;
private:
QVBoxLayout* m_lroot;
QLabel* m_speedLabel;
QComboBox* m_speedBox;
QButtonGroup* m_groupFlow;
- QRadioButton *m_flowHw, *m_flowSw;
+ QRadioButton *m_flowHw, *m_flowSw, *m_flowNone;
QButtonGroup* m_groupParity;
QRadioButton *m_parityOdd, *m_parityEven;
QHBoxLayout* m_hbox;
QHBoxLayout* m_hboxPar;
};
#endif
diff --git a/noncore/apps/opie-console/irdaconfigwidget.cpp b/noncore/apps/opie-console/irdaconfigwidget.cpp
new file mode 100644
index 0000000..1cc041b
--- a/dev/null
+++ b/noncore/apps/opie-console/irdaconfigwidget.cpp
@@ -0,0 +1,141 @@
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcombobox.h>
+
+#include "iolayerbase.h"
+#include "irdaconfigwidget.h"
+
+namespace {
+ void setCurrent( const QString& str, QComboBox* bo ) {
+ uint b = bo->count();
+ for (uint i = 0; i < bo->count(); i++ ) {
+ if ( bo->text(i) == str ) {
+ bo->setCurrentItem( i );
+ return;
+ }
+ }
+ bo->insertItem( str );
+ bo->setCurrentItem( b );
+ }
+
+
+}
+
+IrdaConfigWidget::IrdaConfigWidget( 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_deviceCmb->setEditable( TRUE );
+
+ m_base = new IOLayerBase(this, "base");
+
+ m_lay->addWidget( m_device );
+ m_lay->addWidget( m_deviceCmb );
+ m_lay->addWidget( m_base );
+
+ m_deviceCmb->insertItem( "/dev/ircomm0" );
+ m_deviceCmb->insertItem( "/dev/ircomm1" );
+}
+
+IrdaConfigWidget::~IrdaConfigWidget() {
+
+}
+void IrdaConfigWidget::load( const Profile& prof ) {
+ int rad_flow = prof.readNumEntry("Flow");
+ int rad_parity = prof.readNumEntry("Parity");
+ int speed = prof.readNumEntry("Speed");
+
+ 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 );
+ }
+
+ if (rad_parity == 1) {
+ m_base->setParity( IOLayerBase::Even );
+ } else {
+ m_base->setParity( IOLayerBase::Odd );
+ }
+
+ switch( speed ) {
+ case 115200:
+ m_base->setSpeed(IOLayerBase::Baud_115200 );
+ break;
+ case 57600:
+ m_base->setSpeed( IOLayerBase::Baud_57600 );
+ break;
+ case 38400:
+ m_base->setSpeed(IOLayerBase::Baud_38400 );
+ break;
+ case 19200:
+ m_base->setSpeed( IOLayerBase::Baud_19200 );
+ break;
+ case 9600:
+ default:
+ m_base->setSpeed(IOLayerBase::Baud_9600 );
+ break;
+ }
+
+ if ( prof.readEntry("Device").isEmpty() ) return;
+ setCurrent( prof.readEntry("Device"), m_deviceCmb );
+
+}
+/*
+ * save speed,
+ * flow,
+ * parity
+ */
+void IrdaConfigWidget::save( Profile& prof ) {
+ int flow, parity, speed;
+ prof.writeEntry("Device", m_deviceCmb->currentText() );
+
+ switch( m_base->flow() ) {
+ case IOLayerBase::None:
+ flow = 0;
+ break;
+ case IOLayerBase::Software:
+ flow = 2;
+ break;
+ case IOLayerBase::Hardware:
+ flow = 1;
+ break;
+ }
+
+
+ switch( m_base->parity() ) {
+ case IOLayerBase::Odd:
+ parity = 2;
+ break;
+ case IOLayerBase::Even:
+ parity = 1;
+ break;
+ }
+
+ switch( m_base->speed() ) {
+ case IOLayerBase::Baud_115200:
+ speed = 115200;
+ break;
+ case IOLayerBase::Baud_57600:
+ speed = 57600;
+ break;
+ case IOLayerBase::Baud_38400:
+ speed = 38400;
+ break;
+ case IOLayerBase::Baud_19200:
+ speed = 19200;
+ break;
+ case IOLayerBase::Baud_9600:
+ speed = 9600;
+ break;
+ }
+
+ prof.writeEntry("Flow", flow);
+ prof.writeEntry("Parity", parity);
+ prof.writeEntry("Speed", speed);
+}
diff --git a/noncore/apps/opie-console/irdaconfigwidget.h b/noncore/apps/opie-console/irdaconfigwidget.h
new file mode 100644
index 0000000..56d8089
--- a/dev/null
+++ b/noncore/apps/opie-console/irdaconfigwidget.h
@@ -0,0 +1,29 @@
+#ifndef OPIE_IRDA_CONFIG_WIDGET_H
+#define OPIE_IRDA_CONFIG_WIDGET_H
+
+#include "profiledialogwidget.h"
+
+class QVBoxLayout;
+class QLabel;
+class QComboBox;
+class IOLayerBase;
+class IrdaConfigWidget : public ProfileDialogConnectionWidget {
+
+ Q_OBJECT
+
+public:
+ IrdaConfigWidget( const QString& name, QWidget* parent, const char* name = 0l );
+ ~IrdaConfigWidget();
+
+ void load( const Profile& );
+ void save( Profile& );
+private:
+ QVBoxLayout* m_lay;
+ QLabel* m_device;
+ QComboBox* m_deviceCmb;
+ IOLayerBase* m_base;
+
+};
+
+
+#endif
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index ea6d759..e1e5248 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,63 +1,64 @@
TEMPLATE = app
#CONFIG = qt warn_on release
CONFIG = qt debug
DESTDIR = $(OPIEDIR)/bin
-HEADERS = io_layer.h io_serial.h \
+HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h \
file_layer.h sz_transfer.h \
metafactory.h \
session.h \
mainwindow.h \
profile.h \
profileconfig.h \
profilemanager.h \
configwidget.h \
tabwidget.h \
configdialog.h \
emulation_layer.h \
widget.h \
vt102emulation.h \
common.h \
history.h \
screen.h \
keytrans.h \
widget_layer.h \
transferdialog.h \
profiledialogwidget.h \
profileeditordialog.h \
default.h \
terminalwidget.h \
iolayerbase.h \
- serialconfigwidget.h
+ serialconfigwidget.h irdaconfigwidget.h btconfigwidget.h \
-SOURCES = io_layer.cpp io_serial.cpp \
+
+SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp \
file_layer.cpp sz_transfer.cpp \
main.cpp \
metafactory.cpp \
session.cpp \
mainwindow.cpp \
profile.cpp \
profileconfig.cpp \
profilemanager.cpp \
tabwidget.cpp \
configdialog.cpp \
emulation_layer.cpp \
widget.cpp \
vt102emulation.cpp \
history.cpp \
screen.cpp \
keytrans.cpp \
widget_layer.cpp \
transferdialog.cpp \
profiledialogwidget.cpp \
profileeditordialog.cpp \
default.cpp \
terminalwidget.cpp \
iolayerbase.cpp \
- serialconfigwidget.cpp
+ serialconfigwidget.cpp irdaconfigwidget.cpp btconfigwidget.cpp \
INTERFACES = configurebase.ui editbase.ui
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
TARGET = opie-console
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index faf9c39..914fd25 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -86,114 +86,114 @@ void ProfileEditorDialog::initUI()
vbox3->add(m_name);
vbox3->add(con );
vbox3->add(m_conCmb );
vbox3->add(term );
vbox3->add(m_termCmb );
vbox3->addStretch(1);
tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
tabWidget->setCurrentTab( tabprof );
// fill the comboboxes
QStringList list = m_fact->connectionWidgets();
QStringList::Iterator it;
for (it =list.begin(); it != list.end(); ++it ) {
m_conCmb->insertItem( (*it) );
}
list = m_fact->terminalWidgets();
for (it =list.begin(); it != list.end(); ++it ) {
m_termCmb->insertItem( (*it) );
}
// load profile values
m_name->setText(m_prof.name());
slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
slotTermActivated( m_fact->external(m_prof.terminalName() ) );
setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
qWarning("Layer: %s %s", m_prof.ioLayerName().data(),
m_fact->external(m_prof.ioLayerName() ).latin1() );
qWarning("Term: %s %s", m_prof.terminalName().data(),
m_fact->external(m_prof.terminalName() ).latin1() );
// signal and slots
connect(m_conCmb, SIGNAL(activated(const QString& ) ),
this, SLOT(slotConActivated(const QString&) ) );
connect(m_termCmb, SIGNAL(activated(const QString& ) ),
this, SLOT(slotTermActivated(const QString& ) ) );
}
ProfileEditorDialog::~ProfileEditorDialog() {
}
void ProfileEditorDialog::accept()
{
if(profName().isEmpty())
{
QMessageBox::information(this,
QObject::tr("Invalid profile"),
QObject::tr("Please enter a profile name."));
return;
}
// Save profile and plugin profile
//if(plugin_plugin) plugin_plugin->save();
// Save general values
m_prof.setName(profName());
m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(),
m_termCmb->currentText().latin1() );
if (m_con )
m_con->save( m_prof );
if (m_term )
m_term->save( m_prof );
QDialog::accept();
}
QString ProfileEditorDialog::profName()const
{
return m_name->text();
}
QCString ProfileEditorDialog::profType()const
{
/*QStringList w = m_fact->configWidgets();
for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
if(device_box->currentText() == m_fact->name((*it))) return (*it);
*/
return QCString();
}
/*
* we need to switch the widget
*/
void ProfileEditorDialog::slotConActivated( const QString& str ) {
delete m_con;
m_con = m_fact->newConnectionPlugin( str, m_tabCon );
if (m_con ) {
- m_con->load(m_prof );
+ m_con->load( m_prof );
m_layCon->addWidget( m_con );
}
}
/*
* we need to switch the widget
*/
void ProfileEditorDialog::slotTermActivated( const QString& str ) {
delete m_term;
m_term = m_fact->newTerminalPlugin( str, m_tabTerm );
qWarning("past");
if (m_term) {
m_term->load(m_prof );
m_layTerm->addWidget( m_term );
}
}
diff --git a/noncore/apps/opie-console/profileeditorplugins.cpp b/noncore/apps/opie-console/profileeditorplugins.cpp
index c11c854..937516c 100644
--- a/noncore/apps/opie-console/profileeditorplugins.cpp
+++ b/noncore/apps/opie-console/profileeditorplugins.cpp
@@ -101,201 +101,204 @@ QWidget *ProfileEditorPlugin::connection_widget()
QWidget *ProfileEditorPlugin::terminal_widget()
{
QWidget *root;
QVBoxLayout *lroot;
root = new QWidget();
// Build GUI
QLabel *terminal = new QLabel(QObject::tr("Terminal type"), root);
QComboBox *terminal_box = new QComboBox(root);
terminal_box->insertItem("VT 100", id_term_vt100);
terminal_box->insertItem("VT 220", id_term_vt220);
terminal_box->insertItem("ANSI", id_term_ansi);
QLabel *colourlabel = new QLabel(QObject::tr("Colour scheme"), root);
QComboBox *colour_box = new QComboBox(root);
colour_box->insertItem(QObject::tr("black on white"), id_term_black);
colour_box->insertItem(QObject::tr("white on black"), id_term_white);
QButtonGroup *group_size = new QButtonGroup( QObject::tr("Font size"), root );
QRadioButton *size_small = new QRadioButton(QObject::tr("small"), group_size );
QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), group_size );
QRadioButton *size_large = new QRadioButton(QObject::tr("large"), group_size );
QHGroupBox *group_conv = new QHGroupBox( QObject::tr("Line-break conversions"), root );
QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), group_conv);
QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), group_conv);
QHGroupBox *group_options = new QHGroupBox( QObject::tr("Options"), root );
QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), group_options);
QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), group_options);
// Build Layout
lroot = new QVBoxLayout(root, 2);
QVBoxLayout *typeBox = new QVBoxLayout( lroot );
typeBox->add(terminal);
typeBox->add(terminal_box);
QHBoxLayout *hbox = new QHBoxLayout( group_size, 2);
hbox->add(size_small);
hbox->add(size_medium);
hbox->add(size_large);
lroot->add( group_size );
QVBoxLayout *colourBox = new QVBoxLayout( lroot );
colourBox->add(colourlabel);
colourBox->add(colour_box);
lroot->add(group_conv);
lroot->add(group_options);
// Apply profile settings
int term = m_profile->readNumEntry("Terminal");
int colour = m_profile->readNumEntry("Colour");
int fontsize = m_profile->readNumEntry("Font");
int opt_echo = m_profile->readNumEntry("Echo");
int opt_wrap = m_profile->readNumEntry("Wrap");
int opt_inbound = m_profile->readNumEntry("Inbound");
int opt_outbound = m_profile->readNumEntry("Outbound");
if(term == Profile::VT102) terminal_box->setCurrentItem(id_term_vt100);
if(colour == Profile::Black) colour_box->setCurrentItem(id_term_black);
if(colour == Profile::White) colour_box->setCurrentItem(id_term_white);
if(fontsize == Profile::Micro) size_small->setChecked(true);
if(fontsize == Profile::Small) size_medium->setChecked(true);
if(fontsize == Profile::Medium) size_large->setChecked(true);
if(opt_echo) option_echo->setChecked(true);
if(opt_wrap) option_wrap->setChecked(true);
if(opt_inbound) conv_inbound->setChecked(true);
if(opt_outbound) conv_outbound->setChecked(true);
// Signals
connect(terminal_box, SIGNAL(activated(int)), SLOT(slotTermTerm(int)));
connect(colour_box, SIGNAL(activated(int)), SLOT(slotTermColour(int)));
connect(group_size, SIGNAL(clicked(int)), SLOT(slotTermFont(int)));
connect(option_echo, SIGNAL(toggled(bool)), SLOT(slotTermEcho(bool)));
connect(option_wrap, SIGNAL(toggled(bool)), SLOT(slotTermWrap(bool)));
connect(conv_inbound, SIGNAL(toggled(bool)), SLOT(slotTermInbound(bool)));
connect(conv_outbound, SIGNAL(toggled(bool)), SLOT(slotTermOutbound(bool)));
return root;
}
void ProfileEditorPlugin::slotConnFlow(int id)
{
- switch(id)
- {
- case id_flow_hw:
- m_profile->writeEntry("Flow", IOSerial::FlowHW);
- break;
- case id_flow_sw:
- m_profile->writeEntry("Flow", IOSerial::FlowSW);
- break;
- }
+ switch(id)
+ {
+ case id_flow_hw:
+ m_profile->writeEntry("Flow", IOSerial::FlowHW);
+ break;
+ case id_flow_sw:
+ m_profile->writeEntry("Flow", IOSerial::FlowSW);
+ break;
+ case id_flow_sw:
+ m_profile->writeEntry("None", IOSerial::None);
+ break;
+ }
}
void ProfileEditorPlugin::slotConnParity(int id)
{
switch(id)
{
case id_parity_odd:
m_profile->writeEntry("Parity", IOSerial::ParityEven);
break;
case id_parity_even:
m_profile->writeEntry("Parity", IOSerial::ParityOdd);
break;
}
}
void ProfileEditorPlugin::slotConnSpeed(int id)
{
switch(id)
{
case id_baud_115200:
m_profile->writeEntry("Speed", 115200);
break;
case id_baud_57600:
m_profile->writeEntry("Speed", 57600);
break;
case id_baud_38400:
m_profile->writeEntry("Speed", 38400);
break;
case id_baud_19200:
m_profile->writeEntry("Speed", 19200);
break;
case id_baud_9600:
m_profile->writeEntry("Speed", 9600);
break;
}
}
void ProfileEditorPlugin::slotTermTerm(int id)
{
switch(id)
{
case id_term_vt100:
m_profile->writeEntry("Terminal", Profile::VT102);
break;
case id_term_vt220:
m_profile->writeEntry("Terminal", Profile::VT102);
break;
case id_term_ansi:
m_profile->writeEntry("Terminal", Profile::VT102);
break;
}
}
void ProfileEditorPlugin::slotTermColour(int id)
{
switch(id)
{
case id_term_black:
m_profile->writeEntry("Colour", Profile::Black);
break;
case id_term_white:
m_profile->writeEntry("Colour", Profile::White);
break;
}
}
void ProfileEditorPlugin::slotTermFont(int id)
{
switch(id)
{
case id_size_small:
m_profile->writeEntry("Font", Profile::Micro);
break;
case id_size_medium:
m_profile->writeEntry("Font", Profile::Small);
break;
case id_size_large:
m_profile->writeEntry("Font", Profile::Medium);
break;
}
}
void ProfileEditorPlugin::slotTermEcho(bool on)
{
m_profile->writeEntry("Echo", on ? 1 : 0);
}
void ProfileEditorPlugin::slotTermWrap(bool on)
{
m_profile->writeEntry("Wrap", on ? 1 : 0);
}
void ProfileEditorPlugin::slotTermInbound(bool on)
{
m_profile->writeEntry("Inbound", on ? 1 : 0);
diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp
index a427302..b1ec408 100644
--- a/noncore/apps/opie-console/serialconfigwidget.cpp
+++ b/noncore/apps/opie-console/serialconfigwidget.cpp
@@ -1,135 +1,141 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qcombobox.h>
#include "iolayerbase.h"
#include "serialconfigwidget.h"
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
uint b = bo->count();
for (uint i = 0; i < bo->count(); i++ ) {
if ( bo->text(i) == str ) {
bo->setCurrentItem( i );
return;
}
}
bo->insertItem( str );
bo->setCurrentItem( b );
}
}
SerialConfigWidget::SerialConfigWidget( 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_deviceCmb->setEditable( TRUE );
m_base = new IOLayerBase(this, "base");
m_lay->addWidget( m_device );
m_lay->addWidget( m_deviceCmb );
m_lay->addWidget( m_base );
m_deviceCmb->insertItem( "/dev/ttyS0" );
m_deviceCmb->insertItem( "/dev/ttyS1" );
m_deviceCmb->insertItem( "/dev/ttySA0");
m_deviceCmb->insertItem( "/dev/ttySA1");
}
SerialConfigWidget::~SerialConfigWidget() {
}
void SerialConfigWidget::load( const Profile& prof ) {
int rad_flow = prof.readNumEntry("Flow");
int rad_parity = prof.readNumEntry("Parity");
int speed = prof.readNumEntry("Speed");
- if (rad_flow == 0)
+ if (rad_flow == 1) {
m_base->setFlow( IOLayerBase::Hardware );
- else
+ } else if (rad_flow == 2) {
m_base->setFlow( IOLayerBase::Software );
+ } else if (rad_flow == 0) {
+ m_base->setFlow( IOLayerBase::None );
+ }
if (rad_parity == 1)
m_base->setParity( IOLayerBase::Even );
else
m_base->setParity( IOLayerBase::Odd );
switch( speed ) {
case 115200:
m_base->setSpeed(IOLayerBase::Baud_115200 );
break;
case 57600:
m_base->setSpeed( IOLayerBase::Baud_57600 );
break;
case 38400:
m_base->setSpeed(IOLayerBase::Baud_38400 );
break;
case 19200:
m_base->setSpeed( IOLayerBase::Baud_19200 );
break;
case 9600:
default:
m_base->setSpeed(IOLayerBase::Baud_9600 );
break;
}
if ( prof.readEntry("Device").isEmpty() ) return;
setCurrent( prof.readEntry("Device"), m_deviceCmb );
}
/*
* save speed,
* flow,
* parity
*/
void SerialConfigWidget::save( Profile& prof ) {
int flow, parity, speed;
prof.writeEntry("Device", m_deviceCmb->currentText() );
switch( m_base->flow() ) {
+ case IOLayerBase::None:
+ flow = 0;
+ break;
case IOLayerBase::Software:
- flow = 1;
+ flow = 2;
break;
case IOLayerBase::Hardware:
- flow = 0;
+ flow = 1;
break;
}
switch( m_base->parity() ) {
case IOLayerBase::Odd:
parity = 2;
break;
case IOLayerBase::Even:
parity = 1;
break;
}
switch( m_base->speed() ) {
case IOLayerBase::Baud_115200:
speed = 115200;
break;
case IOLayerBase::Baud_57600:
speed = 57600;
break;
case IOLayerBase::Baud_38400:
speed = 38400;
break;
case IOLayerBase::Baud_19200:
speed = 19200;
break;
case IOLayerBase::Baud_9600:
speed = 9600;
break;
}
prof.writeEntry("Flow", flow);
prof.writeEntry("Parity", parity);
prof.writeEntry("Speed", speed);
}
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h
index c91a957..6e2e61e 100644
--- a/noncore/apps/opie-console/widget_layer.h
+++ b/noncore/apps/opie-console/widget_layer.h
@@ -1,202 +1,202 @@
/* -------------------------------------------------------------------------- */
/* */
/* [widget_layer.h] Widget Layer */
/* */
/* -------------------------------------------------------------------------- */
// proposal of a widget Layer in opie-console
//
// fellow devels:
// just mail me (ibotty@web.de), what you additionally need from the main widget
// (or say in chat)
#ifndef WIDGET_LAYER_H
#define WIDGET_LAYER_H
// qt includes
#include <qapplication.h>
#include <qframe.h>
#include <qarray.h>
#include <qtimer.h>
#include <qkeycode.h>
#include <qclipboard.h>
// opie-console includes
#include "session.h"
#include "common.h"
#include "profile.h"
/*
* given a pseudo location ( column, line ),
* returns the actual index, in the QArray<Character>
*/
#define loc(X,Y) ((Y)*m_columns+(X))
class WidgetLayer : public QFrame
{ Q_OBJECT
public:
/**
* constructor
* @param const Profile &config, the configuration for this widget
* @param QWidget *parent, the parent widget
* @param const char *name, the name of the widget, defaults to ""
*/
WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 );
/**
* destructor
*/
virtual ~WidgetLayer();
public:
/**
* sets the image
* @param QArray<Character> const newimg, the new image
* @param int lines, lines count of newimg
* @param int columns, columns count of newimg
*/
virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0;
/**
* annoy the user
*/
void bell();
/**
* @return int m_lines, the lines count
*/
int lines() { return m_lines; }
/**
* @return int m_columns, the columns count
*/
int columns() { return m_columns; }
/**
* insert current selection (currently this is only the clipboard)
*/
void insertSelection();
/**
* insert text
* @param QString text, the text to be inserted
*/
void insertText( QString text );
-
+
/**
* set selection (clipboard) to text
* @param const QString &text, the text to be selected
*/
void setSelection( const QString &text );
/**
* paste content of clipboard
*/
void pasteClipboard();
/**
* reload configuration
*/
- virtual void reloadConfig();
+ virtual void reloadConfig() = 0;
signals:
/**
* key was pressed
*/
void keyPressed( QKeyEvent *e );
/**
* whenever Mouse selects something
* @param int button, the button that us pressed :
* 0 left Button
* 3 Button released
* @param int x, x position
* @param int y, y position
*
* // numbering due to layout in old TEWidget
*/
void mousePressed( int button, int x, int y );
/**
* size of image changed
* @param int lines, line count of new size
* @param int columns, column count of new size
*/
void imageSizeChanged( int lines, int columns );
/**
* cursor in history changed
* @param int value, value of history cursor
*/
void historyCursorChanged( int value );
/**
* selection should be cleared
*/
void selectionCleared();
/**
* selection begin
* @param const int x, x position
* @param const int y, y position
*/
void selectionBegin( const int x, const int y );
/**
* selection extended
* (from begin (s.a.) to x, y)
* @param const int x, x position
* @param const int y, y position
*/
void selectionExtended( const int x, const int y );
/**
* selection end
* @param const bool lineBreakPreserve, preserve line breaks in selection
*/
void selectionEnd( const bool lineBreakPreserve );
// protected methods
protected:
// image operations
/**
* changes image, to suit new size
* TODO: find meaningful name!
*/
void propagateSize();
/**
*determines count of lines and columns
*/
virtual void calcGeometry() = 0;
/**
* makes an empty image
*/
void makeImage();
/**
* clears the image
*/
void clearImage();
protected slots:
/**
* clear selection
*/
void onClearSelection();