author | zecke <zecke> | 2002-10-31 16:14:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-31 16:14:20 (UTC) |
commit | d2a79869efe8b18849e45b8e1beedb5108eba6ac (patch) (unidiff) | |
tree | 98b5d50f696d2d411cd287f4fe1bc7e1c0f7b7a2 | |
parent | c3a6f53669140cf9e3c953772c610cd91d69ab78 (diff) | |
download | opie-d2a79869efe8b18849e45b8e1beedb5108eba6ac.zip opie-d2a79869efe8b18849e45b8e1beedb5108eba6ac.tar.gz opie-d2a79869efe8b18849e45b8e1beedb5108eba6ac.tar.bz2 |
Auto connect on Locale Console again!
MyPty test if cmd is available(exists) and then
either use /bin/bash or /bin/sh
ConsoleConfigWidget added a comment about the expected behaviour
-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/opie-console/consoleconfigwidget.cpp | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 2 |
3 files changed, 25 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index b0f0275..c3c58be 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -270,49 +270,64 @@ MyPty::MyPty(const Profile& prof) : m_cpid(0) | |||
270 | */ | 270 | */ |
271 | MyPty::~MyPty() | 271 | MyPty::~MyPty() |
272 | { | 272 | { |
273 | donePty(); | 273 | donePty(); |
274 | } | 274 | } |
275 | QString MyPty::identifier()const { | 275 | QString MyPty::identifier()const { |
276 | return QString::fromLatin1("term"); | 276 | return QString::fromLatin1("term"); |
277 | } | 277 | } |
278 | QString MyPty::name()const{ | 278 | QString MyPty::name()const{ |
279 | return identifier(); | 279 | return identifier(); |
280 | } | 280 | } |
281 | bool MyPty::open() { | 281 | bool MyPty::open() { |
282 | if (m_fd < 0) | 282 | if (m_fd < 0) |
283 | m_fd = openPty(); | 283 | m_fd = openPty(); |
284 | 284 | ||
285 | start(); | 285 | start(); |
286 | return true; | 286 | return true; |
287 | } | 287 | } |
288 | void MyPty::close() { | 288 | void MyPty::close() { |
289 | donePty(); | 289 | donePty(); |
290 | m_fd = openPty(); | 290 | m_fd = openPty(); |
291 | } | 291 | } |
292 | void MyPty::reload( const Profile& prof) { | 292 | void MyPty::reload( const Profile& prof) { |
293 | m_env.clear(); | 293 | m_env.clear(); |
294 | m_cmd = prof.readEntry("Command", "/bin/bash"); | 294 | m_cmd = prof.readEntry("Command", "/bin/sh"); |
295 | |||
296 | /* | ||
297 | * Lets check if m_cmd actually | ||
298 | * exists.... | ||
299 | * we try to use bin/bash and if | ||
300 | * this fails we | ||
301 | * will fallback to /bin/sh | ||
302 | * which should be there 100% | ||
303 | */ | ||
304 | if ( !QFile::exists(QFile::encodeName(m_cmd) ) ) | ||
305 | if (QFile::exists("/bin/bash") ) | ||
306 | m_cmd = "/bin/bash"; | ||
307 | else | ||
308 | m_cmd = "/bin/sh"; | ||
309 | |||
295 | int envcount = prof.readNumEntry("EnvVars", 0); | 310 | int envcount = prof.readNumEntry("EnvVars", 0); |
296 | for (int i=0; i<envcount; i++) { | 311 | for (int i=0; i<envcount; i++) { |
297 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | 312 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); |
298 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | 313 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); |
299 | if (!(name.isEmpty() || value.isEmpty())) { | 314 | if (!(name.isEmpty() || value.isEmpty())) { |
300 | m_env.insert(name, value); | 315 | m_env.insert(name, value); |
301 | } | 316 | } |
302 | } | 317 | } |
303 | } | 318 | } |
304 | /*! sends len bytes through the line */ | 319 | /*! sends len bytes through the line */ |
305 | void MyPty::send(const QByteArray& ar) | 320 | void MyPty::send(const QByteArray& ar) |
306 | { | 321 | { |
307 | #ifdef VERBOSE_DEBUG | 322 | #ifdef VERBOSE_DEBUG |
308 | // verbose debug | 323 | // verbose debug |
309 | printf("sending bytes:\n"); | 324 | printf("sending bytes:\n"); |
310 | for (uint i = 0; i < ar.count(); i++) | 325 | for (uint i = 0; i < ar.count(); i++) |
311 | printf("%c", ar[i]); | 326 | printf("%c", ar[i]); |
312 | printf("\n"); | 327 | printf("\n"); |
313 | #endif | 328 | #endif |
314 | 329 | ||
315 | ::write(m_fd, ar.data(), ar.count()); | 330 | ::write(m_fd, ar.data(), ar.count()); |
316 | } | 331 | } |
317 | 332 | ||
318 | /*! indicates that a block of data is received */ | 333 | /*! indicates that a block of data is received */ |
diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp index 70e2e78..3f2d154 100644 --- a/noncore/apps/opie-console/consoleconfigwidget.cpp +++ b/noncore/apps/opie-console/consoleconfigwidget.cpp | |||
@@ -3,90 +3,95 @@ | |||
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qlistview.h> | 6 | #include <qlistview.h> |
7 | #include <qhbox.h> | 7 | #include <qhbox.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | 10 | ||
11 | #include "consoleconfigwidget.h" | 11 | #include "consoleconfigwidget.h" |
12 | 12 | ||
13 | ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, | 13 | ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, |
14 | const char* na ) | 14 | const char* na ) |
15 | : ProfileDialogConnectionWidget( name, parent, na ) { | 15 | : ProfileDialogConnectionWidget( name, parent, na ) { |
16 | m_lay = new QVBoxLayout( this ); | 16 | m_lay = new QVBoxLayout( this ); |
17 | QLabel *label = new QLabel(tr("Command to execute"), this); | 17 | QLabel *label = new QLabel(tr("Command to execute"), this); |
18 | m_lay->addWidget(label); | 18 | m_lay->addWidget(label); |
19 | m_cmd = new QLineEdit(this); | 19 | m_cmd = new QLineEdit(this); |
20 | m_lay->addWidget(m_cmd); | 20 | m_lay->addWidget(m_cmd); |
21 | label = new QLabel(tr("Environment Variables"), this); | 21 | label = new QLabel(tr("Environment Variables"), this); |
22 | m_lay->addWidget(label); | 22 | m_lay->addWidget(label); |
23 | m_env = new QListView(this); | 23 | m_env = new QListView(this); |
24 | m_env->addColumn(tr("Name")); | 24 | m_env->addColumn(tr("Name")); |
25 | m_env->addColumn(tr("Value")); | 25 | m_env->addColumn(tr("Value")); |
26 | m_lay->addWidget(m_env); | 26 | m_lay->addWidget(m_env); |
27 | 27 | ||
28 | QHBox *hbox = new QHBox(this); | 28 | QHBox *hbox = new QHBox(this); |
29 | label = new QLabel(tr("Name :"), hbox); | 29 | label = new QLabel(tr("Name :"), hbox); |
30 | m_name = new QLineEdit(hbox); | 30 | m_name = new QLineEdit(hbox); |
31 | m_lay->addWidget(hbox); | 31 | m_lay->addWidget(hbox); |
32 | 32 | ||
33 | hbox = new QHBox(this); | 33 | hbox = new QHBox(this); |
34 | label = new QLabel(tr("Value :"), hbox); | 34 | label = new QLabel(tr("Value :"), hbox); |
35 | m_value = new QLineEdit(hbox); | 35 | m_value = new QLineEdit(hbox); |
36 | m_lay->addWidget(hbox); | 36 | m_lay->addWidget(hbox); |
37 | 37 | ||
38 | hbox = new QHBox(this); | 38 | hbox = new QHBox(this); |
39 | hbox->setSpacing(10); | 39 | hbox->setSpacing(10); |
40 | m_remove = new QPushButton(tr("Remove"), hbox); | 40 | m_remove = new QPushButton(tr("Remove"), hbox); |
41 | connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); | 41 | connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); |
42 | m_add = new QPushButton(tr("Add"), hbox); | 42 | m_add = new QPushButton(tr("Add"), hbox); |
43 | connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); | 43 | connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); |
44 | m_lay->addWidget(hbox); | 44 | m_lay->addWidget(hbox); |
45 | } | 45 | } |
46 | 46 | ||
47 | void ConsoleConfigWidget::slotAdd() { | 47 | void ConsoleConfigWidget::slotAdd() { |
48 | if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { | 48 | if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { |
49 | QListViewItem *item = new QListViewItem(m_env); | 49 | QListViewItem *item = new QListViewItem(m_env); |
50 | item->setText(0, m_name->text()); | 50 | item->setText(0, m_name->text()); |
51 | item->setText(1, m_value->text()); | 51 | item->setText(1, m_value->text()); |
52 | m_env->insertItem(item); | 52 | m_env->insertItem(item); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | void ConsoleConfigWidget::slotRemove() { | 56 | void ConsoleConfigWidget::slotRemove() { |
57 | QListViewItem *item = m_env->currentItem(); | 57 | QListViewItem *item = m_env->currentItem(); |
58 | if (item) { | 58 | if (item) { |
59 | m_env->takeItem(item); | 59 | m_env->takeItem(item); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | ConsoleConfigWidget::~ConsoleConfigWidget() { | 63 | ConsoleConfigWidget::~ConsoleConfigWidget() { |
64 | } | 64 | } |
65 | 65 | ||
66 | void ConsoleConfigWidget::load( const Profile& prof ) { | 66 | void ConsoleConfigWidget::load( const Profile& prof ) { |
67 | /* | ||
68 | * we will use /bin/bash as default | ||
69 | * but will fallback in MyPty to /bin/sh | ||
70 | * if necessary | ||
71 | */ | ||
67 | m_cmd->setText(prof.readEntry("Command", "/bin/bash")); | 72 | m_cmd->setText(prof.readEntry("Command", "/bin/bash")); |
68 | int envcount = prof.readNumEntry("EnvVars", 0); | 73 | int envcount = prof.readNumEntry("EnvVars", 0); |
69 | for (int i=0; i<envcount; i++) { | 74 | for (int i=0; i<envcount; i++) { |
70 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | 75 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); |
71 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | 76 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); |
72 | if (!(name.isEmpty() || value.isEmpty())) { | 77 | if (!(name.isEmpty() || value.isEmpty())) { |
73 | QListViewItem *item = new QListViewItem(m_env); | 78 | QListViewItem *item = new QListViewItem(m_env); |
74 | item->setText(0, name); | 79 | item->setText(0, name); |
75 | item->setText(1, value); | 80 | item->setText(1, value); |
76 | m_env->insertItem(item); | 81 | m_env->insertItem(item); |
77 | } | 82 | } |
78 | } | 83 | } |
79 | } | 84 | } |
80 | 85 | ||
81 | void ConsoleConfigWidget::save( Profile& prof ) { | 86 | void ConsoleConfigWidget::save( Profile& prof ) { |
82 | prof.writeEntry( "Command", m_cmd->text()); | 87 | prof.writeEntry( "Command", m_cmd->text()); |
83 | QListViewItem *item = m_env->firstChild(); | 88 | QListViewItem *item = m_env->firstChild(); |
84 | int counter = 0; | 89 | int counter = 0; |
85 | while (item) { | 90 | while (item) { |
86 | QString name = item->text(0); | 91 | QString name = item->text(0); |
87 | QString value = item->text(1); | 92 | QString value = item->text(1); |
88 | prof.writeEntry("Env_Name_" + QString::number(counter), name); | 93 | prof.writeEntry("Env_Name_" + QString::number(counter), name); |
89 | prof.writeEntry("Env_Value_" + QString::number(counter), value); | 94 | prof.writeEntry("Env_Value_" + QString::number(counter), value); |
90 | item = item->nextSibling(); | 95 | item = item->nextSibling(); |
91 | counter++; | 96 | counter++; |
92 | } | 97 | } |
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index fd04b6b..6b607df 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -179,49 +179,49 @@ QString ProfileEditorDialog::profName()const | |||
179 | QCString ProfileEditorDialog::profType()const | 179 | QCString ProfileEditorDialog::profType()const |
180 | { | 180 | { |
181 | /*QStringList w = m_fact->configWidgets(); | 181 | /*QStringList w = m_fact->configWidgets(); |
182 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 182 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
183 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 183 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
184 | */ | 184 | */ |
185 | return QCString(); | 185 | return QCString(); |
186 | } | 186 | } |
187 | /* | 187 | /* |
188 | * we need to switch the widget | 188 | * we need to switch the widget |
189 | */ | 189 | */ |
190 | void ProfileEditorDialog::slotConActivated( const QString& str ) { | 190 | void ProfileEditorDialog::slotConActivated( const QString& str ) { |
191 | 191 | ||
192 | delete m_con; | 192 | delete m_con; |
193 | 193 | ||
194 | m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); | 194 | m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); |
195 | 195 | ||
196 | if ( !m_con ) { | 196 | if ( !m_con ) { |
197 | m_con = new NoOptions( str, m_svCon->viewport(), "name"); | 197 | m_con = new NoOptions( str, m_svCon->viewport(), "name"); |
198 | } | 198 | } |
199 | 199 | ||
200 | // FIXME ugly hack right. Right solution would be to look into the layer and see if it | 200 | // FIXME ugly hack right. Right solution would be to look into the layer and see if it |
201 | // supports auto connect and then set it as prefered | 201 | // supports auto connect and then set it as prefered |
202 | //if ( ( )->layer()->supports()[0] == 1 ) { | 202 | //if ( ( )->layer()->supports()[0] == 1 ) { |
203 | if ( m_conCmb ->currentText() == tr("local Console") ) { | 203 | if ( m_conCmb ->currentText() == tr("Local Console") ) { |
204 | m_autoConnect->setChecked( true ); | 204 | m_autoConnect->setChecked( true ); |
205 | } else { | 205 | } else { |
206 | m_autoConnect->setChecked( false ); | 206 | m_autoConnect->setChecked( false ); |
207 | } | 207 | } |
208 | 208 | ||
209 | m_con->load( m_prof ); | 209 | m_con->load( m_prof ); |
210 | m_svCon->addChild( m_con ); | 210 | m_svCon->addChild( m_con ); |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | /* | 214 | /* |
215 | * we need to switch the widget | 215 | * we need to switch the widget |
216 | */ | 216 | */ |
217 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { | 217 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { |
218 | 218 | ||
219 | delete m_term; | 219 | delete m_term; |
220 | 220 | ||
221 | m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); | 221 | m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); |
222 | 222 | ||
223 | if (m_term) { | 223 | if (m_term) { |
224 | m_term->load( m_prof ); | 224 | m_term->load( m_prof ); |
225 | m_svTerm->addChild( m_term ); | 225 | m_svTerm->addChild( m_term ); |
226 | } | 226 | } |
227 | } | 227 | } |