Diffstat (limited to 'noncore/apps/opie-console/consoleconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/consoleconfigwidget.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp index a6ad8d2..27d9a3f 100644 --- a/noncore/apps/opie-console/consoleconfigwidget.cpp +++ b/noncore/apps/opie-console/consoleconfigwidget.cpp | |||
@@ -1,35 +1,35 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qlineedit.h> | 3 | #include <qlineedit.h> |
4 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | #include <qhbox.h> | 6 | #include <qhbox.h> |
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | 8 | ||
9 | #include <pwd.h> | 9 | #include <pwd.h> |
10 | #include <sys/types.h> | 10 | #include <sys/types.h> |
11 | 11 | #include <unistd.h> | |
12 | 12 | ||
13 | #include "consoleconfigwidget.h" | 13 | #include "consoleconfigwidget.h" |
14 | 14 | ||
15 | ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, | 15 | ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, |
16 | const char* na ) | 16 | const char* na ) |
17 | : ProfileDialogConnectionWidget( name, parent, na ) { | 17 | : ProfileDialogConnectionWidget( name, parent, na ) { |
18 | m_lay = new QVBoxLayout( this ); | 18 | m_lay = new QVBoxLayout( this ); |
19 | QLabel *label = new QLabel(tr("Command to execute"), this); | 19 | QLabel *label = new QLabel(tr("Command to execute"), this); |
20 | m_lay->addWidget(label); | 20 | m_lay->addWidget(label); |
21 | m_cmd = new QLineEdit(this); | 21 | m_cmd = new QLineEdit(this); |
22 | m_lay->addWidget(m_cmd); | 22 | m_lay->addWidget(m_cmd); |
23 | label = new QLabel(tr("Environment Variables"), this); | 23 | label = new QLabel(tr("Environment Variables"), this); |
24 | m_lay->addWidget(label); | 24 | m_lay->addWidget(label); |
25 | m_env = new QListView(this); | 25 | m_env = new QListView(this); |
26 | m_env->addColumn(tr("Name")); | 26 | m_env->addColumn(tr("Name")); |
27 | m_env->addColumn(tr("Value")); | 27 | m_env->addColumn(tr("Value")); |
28 | m_lay->addWidget(m_env); | 28 | m_lay->addWidget(m_env); |
29 | 29 | ||
30 | QHBox *hbox = new QHBox(this); | 30 | QHBox *hbox = new QHBox(this); |
31 | label = new QLabel(tr("Name :"), hbox); | 31 | label = new QLabel(tr("Name :"), hbox); |
32 | m_name = new QLineEdit(hbox); | 32 | m_name = new QLineEdit(hbox); |
33 | m_lay->addWidget(hbox); | 33 | m_lay->addWidget(hbox); |
34 | 34 | ||
35 | hbox = new QHBox(this); | 35 | hbox = new QHBox(this); |
@@ -50,54 +50,54 @@ void ConsoleConfigWidget::slotAdd() { | |||
50 | if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { | 50 | if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { |
51 | QListViewItem *item = new QListViewItem(m_env); | 51 | QListViewItem *item = new QListViewItem(m_env); |
52 | item->setText(0, m_name->text()); | 52 | item->setText(0, m_name->text()); |
53 | item->setText(1, m_value->text()); | 53 | item->setText(1, m_value->text()); |
54 | m_env->insertItem(item); | 54 | m_env->insertItem(item); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | void ConsoleConfigWidget::slotRemove() { | 58 | void ConsoleConfigWidget::slotRemove() { |
59 | QListViewItem *item = m_env->currentItem(); | 59 | QListViewItem *item = m_env->currentItem(); |
60 | if (item) { | 60 | if (item) { |
61 | m_env->takeItem(item); | 61 | m_env->takeItem(item); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | ConsoleConfigWidget::~ConsoleConfigWidget() { | 65 | ConsoleConfigWidget::~ConsoleConfigWidget() { |
66 | } | 66 | } |
67 | 67 | ||
68 | void ConsoleConfigWidget::load( const Profile& prof ) { | 68 | void ConsoleConfigWidget::load( const Profile& prof ) { |
69 | /* | 69 | /* |
70 | * default to the users default shell | 70 | * default to the users default shell |
71 | */ | 71 | */ |
72 | struct passwd *ent = 0; | 72 | struct passwd *ent = 0; |
73 | char *shell = "/bin/sh"; | 73 | char *shell = "/bin/sh"; |
74 | int uid = getuid(); | ||
74 | 75 | ||
75 | while ( (ent = getpwent()) != 0 ) { | 76 | ent = getpwuid(uid); |
76 | if (ent->pw_shell != "") { | 77 | if (ent->pw_shell != "") { |
77 | shell = ent->pw_shell; | 78 | shell = ent->pw_shell; |
78 | } | 79 | } |
79 | } | ||
80 | 80 | ||
81 | m_cmd->setText(prof.readEntry("Command", shell )); | 81 | m_cmd->setText(prof.readEntry("Command", shell )); |
82 | int envcount = prof.readNumEntry("EnvVars", 0); | 82 | int envcount = prof.readNumEntry("EnvVars", 0); |
83 | for (int i=0; i<envcount; i++) { | 83 | for (int i=0; i<envcount; i++) { |
84 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | 84 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); |
85 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | 85 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); |
86 | if (!(name.isEmpty() || value.isEmpty())) { | 86 | if (!(name.isEmpty() || value.isEmpty())) { |
87 | QListViewItem *item = new QListViewItem(m_env); | 87 | QListViewItem *item = new QListViewItem(m_env); |
88 | item->setText(0, name); | 88 | item->setText(0, name); |
89 | item->setText(1, value); | 89 | item->setText(1, value); |
90 | m_env->insertItem(item); | 90 | m_env->insertItem(item); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | void ConsoleConfigWidget::save( Profile& prof ) { | 95 | void ConsoleConfigWidget::save( Profile& prof ) { |
96 | prof.writeEntry( "Command", m_cmd->text()); | 96 | prof.writeEntry( "Command", m_cmd->text()); |
97 | QListViewItem *item = m_env->firstChild(); | 97 | QListViewItem *item = m_env->firstChild(); |
98 | int counter = 0; | 98 | int counter = 0; |
99 | while (item) { | 99 | while (item) { |
100 | QString name = item->text(0); | 100 | QString name = item->text(0); |
101 | QString value = item->text(1); | 101 | QString value = item->text(1); |
102 | prof.writeEntry("Env_Name_" + QString::number(counter), name); | 102 | prof.writeEntry("Env_Name_" + QString::number(counter), name); |
103 | prof.writeEntry("Env_Value_" + QString::number(counter), value); | 103 | prof.writeEntry("Env_Value_" + QString::number(counter), value); |