-rw-r--r-- | noncore/apps/opie-console/default.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.cpp | 34 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.cpp | 135 | ||||
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.h | 27 |
9 files changed, 212 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index 4ab4695..d9a0557 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp @@ -1,66 +1,67 @@ #include "io_serial.h" #include "sz_transfer.h" +#include "serialconfigwidget.h" #include "terminalwidget.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* ) { - return 0l; + ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* wid) { + return new SerialConfigWidget(str, wid ); } ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { return newSerialWidget(str, wid); } ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) { return newSerialWidget(str, wid ); } // Terminal Widget(s) ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { return new TerminalWidget(na, wid,0 ); } }; 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 ); } Default::~Default() { } diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp index 1e164fe..99b6cc1 100644 --- a/noncore/apps/opie-console/iolayerbase.cpp +++ b/noncore/apps/opie-console/iolayerbase.cpp @@ -1,123 +1,149 @@ #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 }; 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") ); + 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_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->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_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; } } 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 { - return Hardware; + if (m_flowHw->isChecked() ) { + qWarning("Hardware flow"); + return Hardware; + }else { + qWarning("Software"); + return Software; + } } IOLayerBase::Parity IOLayerBase::parity()const { - return Odd; + if (m_parityOdd->isChecked() ) + return Odd; + else + return Even; + } IOLayerBase::Speed IOLayerBase::speed()const{ - return Baud_9600; + 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 7ef3f4d..151a04b 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 { Software, Hardware }; - enum Parity{ Odd, Even }; + enum Flow { Hardware, Software }; + 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; QButtonGroup* m_groupParity; QRadioButton *m_parityOdd, *m_parityEven; QHBoxLayout* m_hbox; QHBoxLayout* m_hboxPar; }; #endif diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index a414bdb..3531478 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -120,60 +120,61 @@ void MainWindow::populateProfiles() { } MainWindow::~MainWindow() { delete m_factory; manager()->save(); } MetaFactory* MainWindow::factory() { return m_factory; } Session* MainWindow::currentSession() { return m_curSession; } QList<Session> MainWindow::sessions() { return m_sessions; } void MainWindow::slotNew() { qWarning("New Connection"); } void MainWindow::slotConnect() { if ( currentSession() ) currentSession()->layer()->open(); } void MainWindow::slotDisconnect() { if ( currentSession() ) currentSession()->layer()->close(); } void MainWindow::slotTerminate() { if ( currentSession() ) currentSession()->layer()->close(); delete m_curSession; m_curSession = 0l; /* FIXME move to the next session */ } void MainWindow::slotConfigure() { qWarning("configure"); ConfigDialog conf( manager()->all(), factory() ); conf.showMaximized(); int ret = conf.exec(); if ( QDialog::Accepted == ret ) { + qWarning("conf %d", conf.list().count() ); manager()->setProfiles( conf.list() ); populateProfiles(); } } void MainWindow::slotClose() { } void MainWindow::slotProfile( int ) { } diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 9e25e8f..ea6d759 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro @@ -1,61 +1,63 @@ TEMPLATE = app #CONFIG = qt warn_on release CONFIG = qt debug DESTDIR = $(OPIEDIR)/bin HEADERS = io_layer.h io_serial.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 + iolayerbase.h \ + serialconfigwidget.h SOURCES = io_layer.cpp io_serial.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 + iolayerbase.cpp \ + serialconfigwidget.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 c5c6248..faf9c39 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -133,65 +133,67 @@ 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 ) + if (m_con ) { + 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/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index 6ad08b5..e66ebcc 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp @@ -1,95 +1,100 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <qfile.h> #include <qpe/config.h> #include "metafactory.h" #include "profileconfig.h" #include "profilemanager.h" ProfileManager::ProfileManager( MetaFactory* fact ) : m_fact( fact ) { } ProfileManager::~ProfileManager() { } void ProfileManager::load() { m_list.clear(); qWarning("load"); ProfileConfig conf("opie-console-profiles"); QStringList groups = conf.groups(); QStringList::Iterator it; /* * for each profile */ for ( it = groups.begin(); it != groups.end(); ++it ) { qWarning("group " + (*it) ); conf.setGroup( (*it) ); Profile prof; prof.setName( conf.readEntry("name") ); prof.setIOLayer( conf.readEntry("iolayer").utf8() ); prof.setTerminalName( conf.readEntry("term").utf8() ); + qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); prof.setBackground( conf.readNumEntry("back") ); prof.setForeground( conf.readNumEntry("fore") ); prof.setTerminal( conf.readNumEntry("terminal") ); prof.setConf( conf.items( (*it) ) ); /* now add it */ m_list.append( prof ); } } void ProfileManager::clear() { m_list.clear(); } Profile::ValueList ProfileManager::all()const { return m_list; } Session* ProfileManager::fromProfile( const Profile& prof) { Session* session = new Session(); session->setName( prof.name() ); session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), prof) ); /* * FIXME * load emulation * load widget? * set colors + fonts */ return session; } void ProfileManager::save( ) { + QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); ProfileConfig conf("opie-console-profiles"); - conf.clearAll(); Profile::ValueList::Iterator it; for (it = m_list.begin(); it != m_list.end(); ++it ) { conf.setGroup( (*it).name() ); conf.writeEntry( "name", (*it).name() ); - conf.writeEntry( "ioplayer", QString::fromUtf8( (*it).ioLayerName() ) ); + conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); conf.writeEntry( "back", (*it).background() ); conf.writeEntry( "fore", (*it).foreground() ); conf.writeEntry( "terminal", (*it).terminal() ); /* now the config stuff */ QMap<QString, QString> map = (*it).conf(); QMap<QString, QString>::Iterator it; for ( it = map.begin(); it != map.end(); ++it ) { conf.writeEntry( it.key(), it.data() ); } } } void ProfileManager::setProfiles( const Profile::ValueList& list ) { m_list = list; }; Profile ProfileManager::profile( const QString& name )const { Profile prof; Profile::ValueList::ConstIterator it; for ( it = m_list.begin(); it != m_list.end(); ++it ) { if ( name == (*it).name() ) { prof = (*it); break; } } return prof; } diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp new file mode 100644 index 0000000..a427302 --- a/dev/null +++ b/noncore/apps/opie-console/serialconfigwidget.cpp @@ -0,0 +1,135 @@ +#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) + m_base->setFlow( IOLayerBase::Hardware ); + else + m_base->setFlow( IOLayerBase::Software ); + + 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::Software: + flow = 1; + break; + case IOLayerBase::Hardware: + flow = 0; + 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/serialconfigwidget.h b/noncore/apps/opie-console/serialconfigwidget.h new file mode 100644 index 0000000..8b5c8aa --- a/dev/null +++ b/noncore/apps/opie-console/serialconfigwidget.h @@ -0,0 +1,27 @@ +#ifndef OPIE_SERIAL_CONFIG_WIDGET_H +#define OPIE_SERIAL_CONFIG_WIDGET_H + +#include "profiledialogwidget.h" + +class QVBoxLayout; +class QLabel; +class QComboBox; +class IOLayerBase; +class SerialConfigWidget : public ProfileDialogConnectionWidget { + Q_OBJECT +public: + SerialConfigWidget( const QString& name, QWidget* parent, const char* name = 0l ); + ~SerialConfigWidget(); + + void load( const Profile& ); + void save( Profile& ); +private: + QVBoxLayout* m_lay; + QLabel* m_device; + QComboBox* m_deviceCmb; + IOLayerBase* m_base; + +}; + + +#endif |