summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp27
-rw-r--r--noncore/apps/opie-console/MyPty.h6
-rw-r--r--noncore/apps/opie-console/PLANS2
-rw-r--r--noncore/apps/opie-console/consoleconfigwidget.cpp95
-rw-r--r--noncore/apps/opie-console/consoleconfigwidget.h34
-rw-r--r--noncore/apps/opie-console/default.cpp9
-rw-r--r--noncore/apps/opie-console/opie-console.pro6
7 files changed, 162 insertions, 17 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index 534f79a..b0f0275 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -142,14 +142,8 @@ void MyPty::error()
}
void MyPty::start() {
- char* cmd = "/bin/sh";
-
- if ( QFile::exists( "/bin/bash" ) ) {
- cmd = "/bin/bash";
- }
-
QStrList lis;
- int r =run(cmd, lis, 0, 0);
+ int r =run(m_cmd.latin1(), lis, 0, 0);
r = r;
}
/*!
@@ -182,7 +176,10 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int)
tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
setenv("TERM",m_term,1);
setenv("COLORTERM","0",1);
-
+ EnvironmentMap::Iterator it;
+ for (it = m_env.begin(); it != m_env.end(); it++) {
+ setenv(it.key().latin1(), it.data().latin1(), 1);
+ }
if (getuid() == 0) {
char msg[] = "WARNING: You are running this shell as root!\n";
write(ttyfd, msg, sizeof(msg));
@@ -263,6 +260,7 @@ MyPty::MyPty(const Profile& prof) : m_cpid(0)
m_fd = openPty();
ProcCtl* ctl = ProcCtl::self();
Q_UNUSED(ctl);
+ reload(prof);
}
/*!
@@ -291,8 +289,17 @@ void MyPty::close() {
donePty();
m_fd = openPty();
}
-void MyPty::reload( const Profile& ) {
-
+void MyPty::reload( const Profile& prof) {
+ m_env.clear();
+ m_cmd = prof.readEntry("Command", "/bin/bash");
+ 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())) {
+ m_env.insert(name, value);
+ }
+ }
}
/*! sends len bytes through the line */
void MyPty::send(const QByteArray& ar)
diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h
index 7561ca3..b292ce4 100644
--- a/noncore/apps/opie-console/MyPty.h
+++ b/noncore/apps/opie-console/MyPty.h
@@ -23,10 +23,13 @@
#define MY_PTY_H
#include <qobject.h>
+#include <qlist.h>
#include <qstrlist.h>
#include "io_layer.h"
+typedef QMap<QString, QString> EnvironmentMap;
+
class Profile;
class QSocketNotifier;
class MyPty : public IOLayer
@@ -95,6 +98,9 @@ private:
QSocketNotifier* m_sn_e;
QSocketNotifier* m_sn_r;
char* m_term;
+
+ QString m_cmd;
+ EnvironmentMap m_env;
};
#endif
diff --git a/noncore/apps/opie-console/PLANS b/noncore/apps/opie-console/PLANS
index 8e0bee4..a7c7578 100644
--- a/noncore/apps/opie-console/PLANS
+++ b/noncore/apps/opie-console/PLANS
@@ -27,10 +27,10 @@ keyboard?
Fullscreen
Modem - Josef
Keys - hash
+ Scripting - wazlaf
TASKS in progress:
Keys - hash
- Scripting - wazlaf
Session->Profile - hash => why is this needed? you can not change any settings
after you start the session, so all you would do is
diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp
new file mode 100644
index 0000000..70e2e78
--- a/dev/null
+++ b/noncore/apps/opie-console/consoleconfigwidget.cpp
@@ -0,0 +1,95 @@
+#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 "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);
+ m_value = new QLineEdit(hbox);
+ m_lay->addWidget(hbox);
+
+ hbox = new QHBox(this);
+ hbox->setSpacing(10);
+ m_remove = new QPushButton(tr("Remove"), hbox);
+ connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove()));
+ m_add = new QPushButton(tr("Add"), hbox);
+ connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd()));
+ 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 ) {
+ m_cmd->setText(prof.readEntry("Command", "/bin/bash"));
+ 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++;
+ }
+ prof.writeEntry("EnvVars", QString::number(counter));
+}
+
diff --git a/noncore/apps/opie-console/consoleconfigwidget.h b/noncore/apps/opie-console/consoleconfigwidget.h
new file mode 100644
index 0000000..c980cb4
--- a/dev/null
+++ b/noncore/apps/opie-console/consoleconfigwidget.h
@@ -0,0 +1,34 @@
+#ifndef OPIE_CONSOLE_CONFIG_WIDGET_H
+#define OPIE_CONSOLE_CONFIG_WIDGET_H
+
+#include "profiledialogwidget.h"
+
+class QVBoxLayout;
+class QLineEdit;
+class QListView;
+class QPushButton;
+
+class ConsoleConfigWidget : public ProfileDialogConnectionWidget {
+ Q_OBJECT
+public:
+ ConsoleConfigWidget( const QString& name, QWidget* parent, const char* name = 0l );
+ ~ConsoleConfigWidget();
+
+ void load( const Profile& );
+ void save( Profile& );
+
+protected slots:
+ void slotAdd();
+ void slotRemove();
+private:
+ QVBoxLayout *m_lay;
+ QLineEdit *m_cmd;
+ QLineEdit *m_name;
+ QLineEdit *m_value;
+ QListView *m_env;
+ QPushButton *m_add;
+ QPushButton *m_remove;
+};
+
+
+#endif
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
index 5d82c6a..b060139 100644
--- a/noncore/apps/opie-console/default.cpp
+++ b/noncore/apps/opie-console/default.cpp
@@ -10,6 +10,7 @@
#include "modemconfigwidget.h"
#include "terminalwidget.h"
#include "function_keyboard.h"
+#include "consoleconfigwidget.h"
#include "MyPty.h"
#include "default.h"
@@ -67,8 +68,8 @@ extern "C" {
ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) {
return new BTConfigWidget(str, wid );
}
- ProfileDialogWidget* newConsoleWid( const QString& , QWidget* ) {
- return 0l;
+ ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) {
+ return new ConsoleConfigWidget(str, wid );
}
@@ -102,13 +103,13 @@ Default::Default( MetaFactory* fact ) {
// fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
// fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer );
- fact->addIOLayerFactory( "console", QObject::tr("local Console"), newConsole );
+ fact->addIOLayerFactory( "console", QObject::tr("Local Console"), newConsole );
fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
// fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget );
// fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
- fact->addConnectionWidgetFactory( "console", QObject::tr("local Console"), newConsoleWid );
+ fact->addConnectionWidgetFactory( "console", QObject::tr("Local Console"), newConsoleWid );
fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
fact->addKeyboardWidgetFactory( "defaultKeys", QObject::tr("Default Keyboard"),
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index f5737d4..e3f92f0 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -30,7 +30,8 @@ HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
terminalwidget.h \
emulation_handler.h TECommon.h \
TEHistroy.h TEScreen.h TEWidget.h \
- TEmuVt102.h TEmulation.h MyPty.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 \
@@ -59,7 +60,8 @@ SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
terminalwidget.cpp \
emulation_handler.cpp TEHistory.cpp \
TEScreen.cpp TEWidget.cpp \
- TEmuVt102.cpp TEmulation.cpp MyPty.cpp
+ TEmuVt102.cpp TEmulation.cpp MyPty.cpp \
+ consoleconfigwidget.cpp
INTERFACES = configurebase.ui editbase.ui