summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console
authorkergoth <kergoth>2003-08-09 16:12:19 (UTC)
committer kergoth <kergoth>2003-08-09 16:12:19 (UTC)
commit1c58d1407f9584fedcdae390a04e2b37e5853361 (patch) (side-by-side diff)
tree3c6e741c4d382d1a53c182930052b684d6e35b91 /noncore/apps/opie-console
parente3f4607edd0c1ca1434adb446df1d4a1d27c6a86 (diff)
downloadopie-1c58d1407f9584fedcdae390a04e2b37e5853361.zip
opie-1c58d1407f9584fedcdae390a04e2b37e5853361.tar.gz
opie-1c58d1407f9584fedcdae390a04e2b37e5853361.tar.bz2
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/apps/opie-console') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/configdialog.cpp4
-rw-r--r--noncore/apps/opie-console/consoleconfigwidget.cpp19
-rw-r--r--noncore/apps/opie-console/main.cpp81
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp5
-rw-r--r--noncore/apps/opie-console/opie-console.control2
-rw-r--r--noncore/apps/opie-console/opie-console.pro1
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp21
7 files changed, 72 insertions, 61 deletions
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp
index 0bc6588..53b3853 100644
--- a/noncore/apps/opie-console/configdialog.cpp
+++ b/noncore/apps/opie-console/configdialog.cpp
@@ -54,61 +54,61 @@ Profile::ValueList ConfigDialog::list()const {
lst.append( item->profile() );
}
return lst;
}
/* our slots */
void ConfigDialog::slotRemove() {
ConfigListItem* item = (ConfigListItem*)lstView->currentItem();
if (!item )
return;
lstView->takeItem( item );
delete item;
}
void ConfigDialog::slotEdit() {
Profile p;
if(!lstView->currentItem()) return;
// Load profile
p = ((ConfigListItem*)lstView->currentItem())->profile();
ProfileEditorDialog dlg(m_fact, p);
- dlg.setCaption("Edit Connection Profile");
+ dlg.setCaption(tr("Edit Connection Profile"));
dlg.showMaximized();
int ret = dlg.exec();
if(ret == QDialog::Accepted)
{
if(lstView->currentItem()) delete lstView->currentItem();
// use dlg.terminal()!
Profile p = dlg.profile();
new ConfigListItem(lstView, p);
}
}
void ConfigDialog::slotAdd() {
ProfileEditorDialog dlg(m_fact);
- dlg.setCaption("New Connection");
+ dlg.setCaption(tr("New Connection"));
dlg.showMaximized();
int ret = dlg.exec();
if(ret == QDialog::Accepted)
{
// TODO: Move into general profile save part
// assignments
//QString type = dlg.term_type();
//if(type == "VT102") profile = Profile::VT102;
// get profile from editor
Profile p = dlg.profile();
new ConfigListItem(lstView, p);
}
}
diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp
index 3f2d154..faedc58 100644
--- a/noncore/apps/opie-console/consoleconfigwidget.cpp
+++ b/noncore/apps/opie-console/consoleconfigwidget.cpp
@@ -1,34 +1,38 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlistview.h>
#include <qhbox.h>
#include <qregexp.h>
#include <stdio.h>
+#include <pwd.h>
+#include <sys/types.h>
+
+
#include "consoleconfigwidget.h"
ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent,
const char* na )
: ProfileDialogConnectionWidget( name, parent, na ) {
m_lay = new QVBoxLayout( this );
QLabel *label = new QLabel(tr("Command to execute"), this);
m_lay->addWidget(label);
m_cmd = new QLineEdit(this);
m_lay->addWidget(m_cmd);
label = new QLabel(tr("Environment Variables"), this);
m_lay->addWidget(label);
m_env = new QListView(this);
m_env->addColumn(tr("Name"));
m_env->addColumn(tr("Value"));
m_lay->addWidget(m_env);
QHBox *hbox = new QHBox(this);
label = new QLabel(tr("Name :"), hbox);
m_name = new QLineEdit(hbox);
m_lay->addWidget(hbox);
hbox = new QHBox(this);
label = new QLabel(tr("Value :"), hbox);
@@ -44,53 +48,60 @@ ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent,
m_lay->addWidget(hbox);
}
void ConsoleConfigWidget::slotAdd() {
if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) {
QListViewItem *item = new QListViewItem(m_env);
item->setText(0, m_name->text());
item->setText(1, m_value->text());
m_env->insertItem(item);
}
}
void ConsoleConfigWidget::slotRemove() {
QListViewItem *item = m_env->currentItem();
if (item) {
m_env->takeItem(item);
}
}
ConsoleConfigWidget::~ConsoleConfigWidget() {
}
void ConsoleConfigWidget::load( const Profile& prof ) {
/*
- * we will use /bin/bash as default
- * but will fallback in MyPty to /bin/sh
- * if necessary
+ * default to the users default shell
*/
- m_cmd->setText(prof.readEntry("Command", "/bin/bash"));
+ struct passwd *ent = 0;
+ char *shell = "/bin/sh";
+
+ while ( (ent = getpwent()) != 0 ) {
+ if (ent->pw_shell != "") {
+ shell = ent->pw_shell;
+ }
+ }
+
+ m_cmd->setText(prof.readEntry("Command", shell ));
int envcount = prof.readNumEntry("EnvVars", 0);
for (int i=0; i<envcount; i++) {
QString name = prof.readEntry("Env_Name_" + QString::number(i), "");
QString value = prof.readEntry("Env_Value_" + QString::number(i), "");
if (!(name.isEmpty() || value.isEmpty())) {
QListViewItem *item = new QListViewItem(m_env);
item->setText(0, name);
item->setText(1, value);
m_env->insertItem(item);
}
}
}
void ConsoleConfigWidget::save( Profile& prof ) {
prof.writeEntry( "Command", m_cmd->text());
QListViewItem *item = m_env->firstChild();
int counter = 0;
while (item) {
QString name = item->text(0);
QString value = item->text(1);
prof.writeEntry("Env_Name_" + QString::number(counter), name);
prof.writeEntry("Env_Value_" + QString::number(counter), value);
item = item->nextSibling();
counter++;
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp
index b17f8e8..228db57 100644
--- a/noncore/apps/opie-console/main.cpp
+++ b/noncore/apps/opie-console/main.cpp
@@ -8,107 +8,104 @@
#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";
-
-
+ 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) {
// too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole";
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 );
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/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index c48116d..3c9603c 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -63,58 +63,58 @@ void MainWindow::initUI() {
m_bar = new QMenuBar( m_tool );
m_console = new QPopupMenu( this );
m_scripts = new QPopupMenu( this );
m_sessionsPop= new QPopupMenu( this );
m_scriptsPop = new QPopupMenu( this );
/* add a toolbar for icons */
m_icons = new QToolBar(this);
/*
* the settings action
*/
m_setProfiles = new QAction(tr("Configure Profiles"),
Resource::loadPixmap( "SettingsIcon" ),
QString::null, 0, this, 0);
m_setProfiles->addTo( m_console );
connect( m_setProfiles, SIGNAL(activated() ),
this, SLOT(slotConfigure() ) );
m_console->insertSeparator();
/*
* new Action for new sessions
*/
- QAction* newCon = new QAction(tr("New Connection"),
+ QAction* newCon = new QAction(tr("New Profile"),
Resource::loadPixmap( "new" ),
QString::null, 0, this, 0);
newCon->addTo( m_console );
connect( newCon, SIGNAL(activated() ),
this, SLOT(slotNew() ) );
m_console->insertSeparator();
- QAction *saveCon = new QAction(tr("Save Connection"),
+ QAction *saveCon = new QAction( tr("Save Profile" ),
Resource::loadPixmap( "save" ), QString::null,
0, this, 0 );
saveCon->addTo( m_console );
connect( saveCon, SIGNAL(activated() ),
this, SLOT(slotSaveSession() ) );
m_console->insertSeparator();
/*
* connect action
*/
m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
QString::null, 0, this, 0 );
m_connect->addTo( m_console );
connect(m_connect, SIGNAL(activated() ),
this, SLOT(slotConnect() ) );
/*
* disconnect action
*/
m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
QString::null, 0, this, 0 );
m_disconnect->addTo( m_console );
connect(m_disconnect, SIGNAL(activated() ),
this, SLOT(slotDisconnect() ) );
@@ -407,48 +407,49 @@ void MainWindow::slotDisconnect() {
}
}
void MainWindow::slotTerminate() {
if ( currentSession() )
currentSession()->layer()->close();
slotClose();
/* FIXME move to the next session */
}
void MainWindow::slotQuickLaunch() {
Profile prof = manager()->profile( "default" );
if ( prof.name() == "default" ) {
create( prof );
} else {
Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
newProf.setAutoConnect( true );
create( newProf );
+ slotSaveSession();
}
}
void MainWindow::slotConfigure() {
ConfigDialog conf( manager()->all(), factory() );
conf.showMaximized();
int ret = conf.exec();
if ( QDialog::Accepted == ret ) {
manager()->setProfiles( conf.list() );
manager()->save();
populateProfiles();
}
}
/*
* we will remove
* this window from the tabwidget
* remove it from the list
* delete it
* and set the currentSession()
*/
void MainWindow::slotClose() {
diff --git a/noncore/apps/opie-console/opie-console.control b/noncore/apps/opie-console/opie-console.control
index 693c72c..852451d 100644
--- a/noncore/apps/opie-console/opie-console.control
+++ b/noncore/apps/opie-console/opie-console.control
@@ -1,11 +1,11 @@
Package: opie-console
Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/*
Priority: optional
Section: opie/applications
Maintainer: Opie team <opie@handhelds.org>
Architecture: arm
Version: 0.6-$SUB_VERSION
-Depends: qpe-base, libopie1, lrzsz, opie-keytabs
+Depends: qpe-base, libopie1, opie-console-help-en, lrzsz, opie-keytabs
License: GPL
Description: Opie terminal app
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 58b29ca..ccf2e08 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,38 +1,37 @@
TEMPLATE = app
TMAKE_CXXFLAGS += -DHAVE_OPENPTY
CONFIG += qt warn_on release
#CONFIG = qt debug
DESTDIR = $(OPIEDIR)/bin
HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
file_layer.h filetransfer.h \
metafactory.h \
session.h \
mainwindow.h \
profile.h \
profileconfig.h \
profilemanager.h \
- configwidget.h \
tabwidget.h \
configdialog.h \
keytrans.h \
transferdialog.h \
profiledialogwidget.h \
profileeditordialog.h \
default.h \
iolayerbase.h \
serialconfigwidget.h irdaconfigwidget.h \
btconfigwidget.h modemconfigwidget.h \
atconfigdialog.h dialdialog.h \
procctl.h \
function_keyboard.h \
receive_layer.h filereceive.h \
script.h \
dialer.h \
terminalwidget.h \
emulation_handler.h TECommon.h \
TEHistory.h TEScreen.h TEWidget.h \
TEmuVt102.h TEmulation.h MyPty.h \
consoleconfigwidget.h
SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
file_layer.cpp filetransfer.cpp \
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 6b607df..e2501a6 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -13,55 +13,55 @@
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
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);
+ // Default profile
+ m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102);
- initUI();
+ initUI();
- // Apply current profile
- // plugin_plugin->load(profile);
+ // Apply current profile
+ // plugin_plugin->load(profile);
}
Profile ProfileEditorDialog::profile() const
{
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);
m_svCon = new QScrollView( m_tabCon );
@@ -102,53 +102,53 @@ void ProfileEditorDialog::initUI()
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"));
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() ) );
slotKeyActivated( "Default Keyboard" );
setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
+ slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
+ slotTermActivated( m_fact->external(m_prof.terminalName() ) );
m_autoConnect->setChecked(m_prof.autoConnect());
// 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
@@ -178,62 +178,65 @@ QString ProfileEditorDialog::profName()const
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_svCon->viewport() );
if ( !m_con ) {
m_con = new NoOptions( str, m_svCon->viewport(), "name");
}
// FIXME ugly hack right. Right solution would be to look into the layer and see if it
// supports auto connect and then set it as prefered
- //if ( ( )->layer()->supports()[0] == 1 ) {
if ( m_conCmb ->currentText() == tr("Local Console") ) {
m_autoConnect->setChecked( true );
+ m_prof.writeEntry("Terminal", Profile::Linux );
+ slotTermActivated( m_fact->external (m_prof.terminalName() ) );
} else {
+ m_prof.writeEntry("Terminal", Profile::VT102 );
+ slotTermActivated( m_fact->external (m_prof.terminalName() ) );
m_autoConnect->setChecked( false );
}
m_con->load( m_prof );
m_svCon->addChild( m_con );
}
/*
* we need to switch the widget
*/
void ProfileEditorDialog::slotTermActivated( const QString& str ) {
delete m_term;
m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() );
- if (m_term) {
+ if ( m_term ) {
m_term->load( m_prof );
m_svTerm->addChild( 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);
}
}