-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 27 | ||||
-rw-r--r-- | noncore/apps/opie-console/MyPty.h | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/PLANS | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/consoleconfigwidget.cpp | 95 | ||||
-rw-r--r-- | noncore/apps/opie-console/consoleconfigwidget.h | 34 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 6 |
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 | |||
@@ -144,10 +144,4 @@ void MyPty::error() | |||
144 | void MyPty::start() { | 144 | void MyPty::start() { |
145 | char* cmd = "/bin/sh"; | ||
146 | |||
147 | if ( QFile::exists( "/bin/bash" ) ) { | ||
148 | cmd = "/bin/bash"; | ||
149 | } | ||
150 | |||
151 | QStrList lis; | 145 | QStrList lis; |
152 | int r =run(cmd, lis, 0, 0); | 146 | int r =run(m_cmd.latin1(), lis, 0, 0); |
153 | r = r; | 147 | r = r; |
@@ -184,3 +178,6 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int) | |||
184 | setenv("COLORTERM","0",1); | 178 | setenv("COLORTERM","0",1); |
185 | 179 | EnvironmentMap::Iterator it; | |
180 | for (it = m_env.begin(); it != m_env.end(); it++) { | ||
181 | setenv(it.key().latin1(), it.data().latin1(), 1); | ||
182 | } | ||
186 | if (getuid() == 0) { | 183 | if (getuid() == 0) { |
@@ -265,2 +262,3 @@ MyPty::MyPty(const Profile& prof) : m_cpid(0) | |||
265 | Q_UNUSED(ctl); | 262 | Q_UNUSED(ctl); |
263 | reload(prof); | ||
266 | } | 264 | } |
@@ -293,4 +291,13 @@ void MyPty::close() { | |||
293 | } | 291 | } |
294 | void MyPty::reload( const Profile& ) { | 292 | void MyPty::reload( const Profile& prof) { |
295 | 293 | m_env.clear(); | |
294 | m_cmd = prof.readEntry("Command", "/bin/bash"); | ||
295 | int envcount = prof.readNumEntry("EnvVars", 0); | ||
296 | for (int i=0; i<envcount; i++) { | ||
297 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | ||
298 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | ||
299 | if (!(name.isEmpty() || value.isEmpty())) { | ||
300 | m_env.insert(name, value); | ||
301 | } | ||
302 | } | ||
296 | } | 303 | } |
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 | |||
@@ -25,2 +25,3 @@ | |||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qlist.h> | ||
26 | #include <qstrlist.h> | 27 | #include <qstrlist.h> |
@@ -29,2 +30,4 @@ | |||
29 | 30 | ||
31 | typedef QMap<QString, QString> EnvironmentMap; | ||
32 | |||
30 | class Profile; | 33 | class Profile; |
@@ -97,2 +100,5 @@ private: | |||
97 | char* m_term; | 100 | char* m_term; |
101 | |||
102 | QString m_cmd; | ||
103 | EnvironmentMap m_env; | ||
98 | }; | 104 | }; |
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 | |||
@@ -29,2 +29,3 @@ keyboard? | |||
29 | Keys - hash | 29 | Keys - hash |
30 | Scripting - wazlaf | ||
30 | 31 | ||
@@ -32,3 +33,2 @@ TASKS in progress: | |||
32 | Keys - hash | 33 | Keys - hash |
33 | Scripting - wazlaf | ||
34 | 34 | ||
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 @@ | |||
1 | #include <qlabel.h> | ||
2 | #include <qlayout.h> | ||
3 | #include <qcombobox.h> | ||
4 | #include <qlineedit.h> | ||
5 | #include <qpushbutton.h> | ||
6 | #include <qlistview.h> | ||
7 | #include <qhbox.h> | ||
8 | #include <qregexp.h> | ||
9 | #include <stdio.h> | ||
10 | |||
11 | #include "consoleconfigwidget.h" | ||
12 | |||
13 | ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, | ||
14 | const char* na ) | ||
15 | : ProfileDialogConnectionWidget( name, parent, na ) { | ||
16 | m_lay = new QVBoxLayout( this ); | ||
17 | QLabel *label = new QLabel(tr("Command to execute"), this); | ||
18 | m_lay->addWidget(label); | ||
19 | m_cmd = new QLineEdit(this); | ||
20 | m_lay->addWidget(m_cmd); | ||
21 | label = new QLabel(tr("Environment Variables"), this); | ||
22 | m_lay->addWidget(label); | ||
23 | m_env = new QListView(this); | ||
24 | m_env->addColumn(tr("Name")); | ||
25 | m_env->addColumn(tr("Value")); | ||
26 | m_lay->addWidget(m_env); | ||
27 | |||
28 | QHBox *hbox = new QHBox(this); | ||
29 | label = new QLabel(tr("Name :"), hbox); | ||
30 | m_name = new QLineEdit(hbox); | ||
31 | m_lay->addWidget(hbox); | ||
32 | |||
33 | hbox = new QHBox(this); | ||
34 | label = new QLabel(tr("Value :"), hbox); | ||
35 | m_value = new QLineEdit(hbox); | ||
36 | m_lay->addWidget(hbox); | ||
37 | |||
38 | hbox = new QHBox(this); | ||
39 | hbox->setSpacing(10); | ||
40 | m_remove = new QPushButton(tr("Remove"), hbox); | ||
41 | connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); | ||
42 | m_add = new QPushButton(tr("Add"), hbox); | ||
43 | connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); | ||
44 | m_lay->addWidget(hbox); | ||
45 | } | ||
46 | |||
47 | void ConsoleConfigWidget::slotAdd() { | ||
48 | if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { | ||
49 | QListViewItem *item = new QListViewItem(m_env); | ||
50 | item->setText(0, m_name->text()); | ||
51 | item->setText(1, m_value->text()); | ||
52 | m_env->insertItem(item); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | void ConsoleConfigWidget::slotRemove() { | ||
57 | QListViewItem *item = m_env->currentItem(); | ||
58 | if (item) { | ||
59 | m_env->takeItem(item); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | ConsoleConfigWidget::~ConsoleConfigWidget() { | ||
64 | } | ||
65 | |||
66 | void ConsoleConfigWidget::load( const Profile& prof ) { | ||
67 | m_cmd->setText(prof.readEntry("Command", "/bin/bash")); | ||
68 | int envcount = prof.readNumEntry("EnvVars", 0); | ||
69 | for (int i=0; i<envcount; i++) { | ||
70 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | ||
71 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | ||
72 | if (!(name.isEmpty() || value.isEmpty())) { | ||
73 | QListViewItem *item = new QListViewItem(m_env); | ||
74 | item->setText(0, name); | ||
75 | item->setText(1, value); | ||
76 | m_env->insertItem(item); | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void ConsoleConfigWidget::save( Profile& prof ) { | ||
82 | prof.writeEntry( "Command", m_cmd->text()); | ||
83 | QListViewItem *item = m_env->firstChild(); | ||
84 | int counter = 0; | ||
85 | while (item) { | ||
86 | QString name = item->text(0); | ||
87 | QString value = item->text(1); | ||
88 | prof.writeEntry("Env_Name_" + QString::number(counter), name); | ||
89 | prof.writeEntry("Env_Value_" + QString::number(counter), value); | ||
90 | item = item->nextSibling(); | ||
91 | counter++; | ||
92 | } | ||
93 | prof.writeEntry("EnvVars", QString::number(counter)); | ||
94 | } | ||
95 | |||
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 @@ | |||
1 | #ifndef OPIE_CONSOLE_CONFIG_WIDGET_H | ||
2 | #define OPIE_CONSOLE_CONFIG_WIDGET_H | ||
3 | |||
4 | #include "profiledialogwidget.h" | ||
5 | |||
6 | class QVBoxLayout; | ||
7 | class QLineEdit; | ||
8 | class QListView; | ||
9 | class QPushButton; | ||
10 | |||
11 | class ConsoleConfigWidget : public ProfileDialogConnectionWidget { | ||
12 | Q_OBJECT | ||
13 | public: | ||
14 | ConsoleConfigWidget( const QString& name, QWidget* parent, const char* name = 0l ); | ||
15 | ~ConsoleConfigWidget(); | ||
16 | |||
17 | void load( const Profile& ); | ||
18 | void save( Profile& ); | ||
19 | |||
20 | protected slots: | ||
21 | void slotAdd(); | ||
22 | void slotRemove(); | ||
23 | private: | ||
24 | QVBoxLayout *m_lay; | ||
25 | QLineEdit *m_cmd; | ||
26 | QLineEdit *m_name; | ||
27 | QLineEdit *m_value; | ||
28 | QListView *m_env; | ||
29 | QPushButton *m_add; | ||
30 | QPushButton *m_remove; | ||
31 | }; | ||
32 | |||
33 | |||
34 | #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 | |||
@@ -12,2 +12,3 @@ | |||
12 | #include "function_keyboard.h" | 12 | #include "function_keyboard.h" |
13 | #include "consoleconfigwidget.h" | ||
13 | #include "MyPty.h" | 14 | #include "MyPty.h" |
@@ -69,4 +70,4 @@ extern "C" { | |||
69 | } | 70 | } |
70 | ProfileDialogWidget* newConsoleWid( const QString& , QWidget* ) { | 71 | ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) { |
71 | return 0l; | 72 | return new ConsoleConfigWidget(str, wid ); |
72 | } | 73 | } |
@@ -104,3 +105,3 @@ Default::Default( MetaFactory* fact ) { | |||
104 | fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer ); | 105 | fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer ); |
105 | fact->addIOLayerFactory( "console", QObject::tr("local Console"), newConsole ); | 106 | fact->addIOLayerFactory( "console", QObject::tr("Local Console"), newConsole ); |
106 | 107 | ||
@@ -110,3 +111,3 @@ Default::Default( MetaFactory* fact ) { | |||
110 | // fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); | 111 | // fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); |
111 | fact->addConnectionWidgetFactory( "console", QObject::tr("local Console"), newConsoleWid ); | 112 | fact->addConnectionWidgetFactory( "console", QObject::tr("Local Console"), newConsoleWid ); |
112 | 113 | ||
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 | |||
@@ -32,3 +32,4 @@ HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ | |||
32 | TEHistroy.h TEScreen.h TEWidget.h \ | 32 | TEHistroy.h TEScreen.h TEWidget.h \ |
33 | TEmuVt102.h TEmulation.h MyPty.h | 33 | TEmuVt102.h TEmulation.h MyPty.h \ |
34 | consoleconfigwidget.h | ||
34 | 35 | ||
@@ -61,3 +62,4 @@ SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ | |||
61 | TEScreen.cpp TEWidget.cpp \ | 62 | TEScreen.cpp TEWidget.cpp \ |
62 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp | 63 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ |
64 | consoleconfigwidget.cpp | ||
63 | 65 | ||