author | zecke <zecke> | 2002-10-21 21:43:43 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-21 21:43:43 (UTC) |
commit | 21d29dbf8a9c1a12c7c23f96b80307e87ffaa50a (patch) (side-by-side diff) | |
tree | 98586789ecce5eea1f1d3eb1e5a2184412f90a06 | |
parent | e2f94235dae5ec84a5e888e4114ce0bdd91db7e7 (diff) | |
download | opie-21d29dbf8a9c1a12c7c23f96b80307e87ffaa50a.zip opie-21d29dbf8a9c1a12c7c23f96b80307e87ffaa50a.tar.gz opie-21d29dbf8a9c1a12c7c23f96b80307e87ffaa50a.tar.bz2 |
add a quirk mode into main. if you -DFSCKED_DISTRIBUTION
opie-console will take care of some magic...
Add a No Configuration Widget instead of a big fat gray thing
above my beloved OTabWidget
Fix some compiler warning
-rw-r--r-- | noncore/apps/opie-console/file_layer.h | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/main.cpp | 102 | ||||
-rw-r--r-- | noncore/apps/opie-console/profiledialogwidget.cpp | 21 | ||||
-rw-r--r-- | noncore/apps/opie-console/profiledialogwidget.h | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 29 | ||||
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.cpp | 4 |
6 files changed, 147 insertions, 24 deletions
diff --git a/noncore/apps/opie-console/file_layer.h b/noncore/apps/opie-console/file_layer.h index edb30e1..caa7478 100644 --- a/noncore/apps/opie-console/file_layer.h +++ b/noncore/apps/opie-console/file_layer.h @@ -4,91 +4,91 @@ #include <qmap.h> #include "io_layer.h" class QFile; /** * this is the layer for sending files */ class FileTransferLayer : public QObject { Q_OBJECT public: enum Errors{ NotSupported, StartError, NoError, Unknown, Undefined, Incomplete }; enum Features { Append = 0, Twostop = 1, Escape = 2, Rename = 4, FullPath = 8, SendIfNewer = 16, SendIfLonger = 32, Resume = 64 }; enum Mode { Ascii = 0, Binary }; enum BlockSize { Block_1k, Block_4k, Block_8k }; /** *the io layer to be used */ FileTransferLayer( IOLayer* ); virtual ~FileTransferLayer(); public slots: - virtual void sendFile( const QString& file, - Mode mode, BlockSize blk, - Features feat ) {}; + virtual void sendFile( const QString&, + Mode, BlockSize, + Features ) {}; /** * send a file over the layer */ virtual void sendFile( const QString& file ) = 0; virtual void sendFile( const QFile& ) = 0; virtual void cancel() = 0; signals: /** * sent the file */ void sent(); /** * an error occured */ void error( int, const QString& ); /* * @param file The file to send * @param progress the progress made from 0-100 * @param speed Speed in bps * @param hours The hours it take to finish * @param minutes The minutes it takes to finish * @param send The seconds... * */ void progress( const QString& file, int progress, int speed, int hours, int minutes, int seconds ); protected: IOLayer* layer(); private: IOLayer* m_layer; }; #endif diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp index 350bb3e..78a91a2 100644 --- a/noncore/apps/opie-console/main.cpp +++ b/noncore/apps/opie-console/main.cpp @@ -1,13 +1,113 @@ +#include <sys/types.h> + +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> + +#include <qfile.h> + #include <qpe/qpeapplication.h> #include "mainwindow.h" +//#define FSCKED_DISTRIBUTION 1 +#ifdef FSCKED_DISTRIBUTION +/* + * The Zaurus rom + */ +class FixIt { +public: + FixIt(); + ~FixIt(); + void fixIt(); + /* no real interested in implementing it */ + void breakIt() { + + }; + char* m_file; +}; + +FixIt::FixIt() { + /* the new inittab */ + m_file = "#\n# /etc/inittab +# + +# 0 - halt (Do NOT set initdefault to this) +# 1 - Single user mode +# 2 - Multiuser, without NFS (The same as 3, if you do not have networking) +# 3 - Full multiuser mode +# 4 - JavaVM(Intent) developer mode +# 5 - JavaVM(Intent) +# 6 - reboot (Do NOT set initdefault to this) +# +id:5:initdefault: + +# Specify things to do when starting +si::sysinit:/etc/rc.d/rc.sysinit + +l0:0:wait:/root/etc/rc.d/rc 0 +l1:1:wait:/etc/rc.d/rc 1 +l2:2:wait:/etc/rc.d/rc 2 +l3:3:wait:/etc/rc.d/rc 3 +l4:4:wait:/etc/rc.d/rc 4 +l5:5:wait:/etc/rc.d/rc 5 +l6:6:wait:/root/etc/rc.d/rc 6 + +# Specify things to do before rebooting +um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1 +sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1 + +# Specify program to run on ttyS0 +s0:24:respawn:/sbin/getty 9600 ttyS0 +#pd:5:respawn:/etc/sync/serialctl + +# Specify program to run on tty1 +1:2:respawn:/sbin/getty 9600 tty1 +ln:345:respawn:survive -l 6 /sbin/launch +#qt:5:respawn:/sbin/qt + +# collie sp. +sy::respawn:/sbin/shsync\n"; + + +} +FixIt::~FixIt() { +} +/* + * the retail Zaurus is broken in many ways + * one is that pppd is listening on our port... + * we've to stop it from that and then do kill(SIGHUP,1); + */ +void FixIt::fixIt() { + ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); + QFile file( "/etc/inittab" ); + if ( file.open(IO_WriteOnly | IO_Raw ) ) { + file.writeBlock(m_file,strlen(m_file) ); + } + file.close(); + ::kill( SIGHUP, 1 ); +} +#endif + + int main(int argc, char **argv) { QPEApplication app( argc, argv ); +#ifdef FSCKED_DISTRIBUTION + qWarning("fscked"); + FixIt it; + it.fixIt(); +#endif + MainWindow mw; mw.setCaption(QObject::tr("Opie console") ); app.showMainWidget( &mw ); - return app.exec(); + int ap = app.exec(); + +#ifdef FSCKED_DISTRIBUTION + /* should add a signal handler too */ + it.breakIt(); +#endif + return ap; } diff --git a/noncore/apps/opie-console/profiledialogwidget.cpp b/noncore/apps/opie-console/profiledialogwidget.cpp index caad998..c356535 100644 --- a/noncore/apps/opie-console/profiledialogwidget.cpp +++ b/noncore/apps/opie-console/profiledialogwidget.cpp @@ -1,43 +1,62 @@ +#include <qlayout.h> +#include <qlabel.h> + #include "profiledialogwidget.h" ProfileDialogWidget::ProfileDialogWidget( const QString&, QWidget* parent, const char* name ) : QWidget( parent, name ) { } ProfileDialogWidget::~ProfileDialogWidget() { } ProfileDialogTerminalWidget::ProfileDialogTerminalWidget( const QString& na, QWidget* parent, const char* name ) : ProfileDialogWidget( na, parent, name ) { } ProfileDialogTerminalWidget::~ProfileDialogTerminalWidget() { } ProfileDialogWidget::Type ProfileDialogTerminalWidget::type()const { return Terminal; } ProfileDialogConnectionWidget::ProfileDialogConnectionWidget( const QString& na, QWidget* parent, const char* name ) : ProfileDialogWidget(na, parent, name ) { } ProfileDialogConnectionWidget::~ProfileDialogConnectionWidget() { } ProfileDialogWidget::Type ProfileDialogConnectionWidget::type()const { return Connection; } ProfileDialogKeyWidget::ProfileDialogKeyWidget( const QString &na, QWidget *parent, const char *name) - : ProfileDialogWidget(na, parent, name ) + : ProfileDialogWidget(na, parent, name ) { } ProfileDialogKeyWidget::~ProfileDialogKeyWidget() { } ProfileDialogWidget::Type ProfileDialogKeyWidget::type() const{ return Keyboard; } + +NoOptions::NoOptions( const QString& name, QWidget* parent, const char* na ) + : ProfileDialogWidget( name, parent, na ) { + QHBoxLayout* lay = new QHBoxLayout(this); + QLabel* lbl = new QLabel( this ); + lbl->setText( tr("This Plugin does not support any configurations") ); + lbl->setTextFormat( RichText ); + + lay->addWidget( lbl ); +} +void NoOptions::load( const Profile& ) { + +} +void NoOptions::save( Profile& ) { + +} diff --git a/noncore/apps/opie-console/profiledialogwidget.h b/noncore/apps/opie-console/profiledialogwidget.h index 9d2d5ec..68f2162 100644 --- a/noncore/apps/opie-console/profiledialogwidget.h +++ b/noncore/apps/opie-console/profiledialogwidget.h @@ -11,49 +11,58 @@ public: enum Type { Connection, Terminal, Keyboard }; ProfileDialogWidget( const QString& name, QWidget* parent, const char* name = 0l); ~ProfileDialogWidget(); /* * load data from a Profile into * the DialogWidget */ virtual void load( const Profile& ) = 0; /* * save data into a profile * from the DialogWidget */ virtual void save( Profile& ) = 0; virtual Type type()const = 0; }; class ProfileDialogTerminalWidget : public ProfileDialogWidget { Q_OBJECT public: ProfileDialogTerminalWidget( const QString& name, QWidget* widget, const char* name =0l); ~ProfileDialogTerminalWidget(); Type type()const; }; class ProfileDialogConnectionWidget : public ProfileDialogWidget { Q_OBJECT public: ProfileDialogConnectionWidget( const QString& name, QWidget* parent, const char* name =0l); ~ProfileDialogConnectionWidget(); Type type() const; }; class ProfileDialogKeyWidget : public ProfileDialogWidget { Q_OBJECT public: ProfileDialogKeyWidget( const QString &name, QWidget* parent, const char *name =0l); ~ProfileDialogKeyWidget(); Type type() const; }; +class NoOptions : public ProfileDialogWidget { + Q_OBJECT + public: + NoOptions( const QString& name, QWidget* parent, const char* na ); + ~NoOptions() {} + void load( const Profile& ); + void save( Profile& ); + Type type()const{ return Connection; }; +}; #endif diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 2dfc0fd..413e80b 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -1,99 +1,97 @@ #include <qlayout.h> #include <qlineedit.h> #include <qlabel.h> #include <qmessagebox.h> #include <qstringlist.h> #include <qcombobox.h> #include <qcheckbox.h> //#include "profileeditorplugins.h" #include "metafactory.h" #include "profileeditordialog.h" namespace { void setCurrent( const QString& str, QComboBox* bo ) { - for (uint i = 0; i < bo->count(); i++ ) { + for (int i = 0; i < bo->count(); i++ ) { if ( bo->text(i) == str ) { bo->setCurrentItem( i ); } } - } - - + }; } ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, const Profile& prof ) : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) { initUI(); // Apply current profile // plugin_plugin->load(profile); // ... (reset profile name line edit etc.) } ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) : QDialog(0, 0, TRUE), m_fact( fact ) { // Default profile m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); initUI(); // Apply current profile // plugin_plugin->load(profile); } Profile ProfileEditorDialog::profile() const { - return m_prof; + return m_prof; } void ProfileEditorDialog::initUI() { m_con = m_term = m_key = 0l; QVBoxLayout *mainLayout = new QVBoxLayout( this ); tabWidget = new OTabWidget( this ); tabWidget->setTabStyle(OTabWidget::TextTab); mainLayout->add(tabWidget); /* base tabs */ tabprof = new QWidget(this); m_tabTerm = new QWidget(this); m_tabCon = new QWidget(this); m_tabKey = new QWidget(this); /* base layout for tabs */ m_layCon = new QHBoxLayout( m_tabCon , 2 ); m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); m_layKey = new QHBoxLayout( m_tabKey, 2 ); // profile tab QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); m_name = new QLineEdit(tabprof); QLabel *con = new QLabel(tr("Connection"), tabprof ); QLabel *term = new QLabel(tr("Terminal"), tabprof ); m_conCmb = new QComboBox( tabprof ); m_termCmb = new QComboBox( tabprof ); m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); // layouting QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); vbox3->add(name); vbox3->add(m_name); vbox3->add(con ); vbox3->add(m_conCmb ); vbox3->add(term ); vbox3->add(m_termCmb ); vbox3->add(m_autoConnect); vbox3->addStretch(1); m_showconntab = 0; tabWidget->addTab(tabprof, "", QObject::tr("Profile")); //tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); @@ -136,87 +134,82 @@ 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() ) ); m_prof.setAutoConnect( m_autoConnect->isChecked() ); if (m_con ) m_con->save( m_prof ); if (m_term ) m_term->save( m_prof ); if (m_key) m_key->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_layCon->addWidget( m_con ); - - if(!m_showconntab) - { - tabWidget->addTab( m_tabCon, "", QObject::tr("Connection") ); - tabWidget->setCurrentTab( tabprof ); - m_showconntab = 1; - } - } else { - tabWidget->removePage( m_tabCon ); - m_showconntab = 0; + if ( !m_con ) { + m_con = new NoOptions( str, m_tabCon, "name"); } + m_con->load( m_prof ); + m_layCon->addWidget( m_con ); + + tabWidget->addTab( m_tabCon, "", QObject::tr("Connection") ); + tabWidget->setCurrentTab( tabprof ); + } /* * we need to switch the widget */ void ProfileEditorDialog::slotTermActivated( const QString& str ) { delete m_term; m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); if (m_term) { m_term->load(m_prof ); m_layTerm->addWidget( m_term ); } } void ProfileEditorDialog::slotKeyActivated(const QString &str) { delete m_key; m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); if (m_key) { m_key->load(m_prof); m_layKey->addWidget(m_key); } } diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp index 1e97a24..bd0312a 100644 --- a/noncore/apps/opie-console/serialconfigwidget.cpp +++ b/noncore/apps/opie-console/serialconfigwidget.cpp @@ -51,97 +51,99 @@ void SerialConfigWidget::load( const Profile& prof ) { 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 { m_base->setFlow( IOLayerBase::None ); } if (rad_parity == 1) { m_base->setParity( IOLayerBase::Even ); } else if ( rad_parity == 2 ) { m_base->setParity( IOLayerBase::Odd ); } else { m_base->setParity( IOLayerBase::NonePar ); } 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; + int flow, parity, speed ; + flow = parity = speed = 0; 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; case IOLayerBase::NonePar: parity = 0; 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; + default: case IOLayerBase::Baud_9600: speed = 9600; break; } prof.writeEntry("Flow", flow); prof.writeEntry("Parity", parity); prof.writeEntry("Speed", speed); } |