summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/MyPty.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-console/MyPty.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp27
1 files changed, 17 insertions, 10 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
@@ -139,20 +139,14 @@ void MyPty::error()
{
// This is code from the Qt DumbTerminal example
donePty();
}
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;
}
/*!
start the client program.
*/
int MyPty::run(const char* cmd, QStrList &, const char*, int)
@@ -179,13 +173,16 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int)
tcgetattr( STDIN_FILENO, &ttmode );
ttmode.c_cc[VINTR] = 3;
ttmode.c_cc[VERASE] = 8;
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));
}
execl(cmd, cmd, 0);
@@ -260,12 +257,13 @@ MyPty::MyPty(const Profile& prof) : m_cpid(0)
}
m_sn_e = 0l;
m_sn_r = 0l;
m_fd = openPty();
ProcCtl* ctl = ProcCtl::self();
Q_UNUSED(ctl);
+ reload(prof);
}
/*!
Destructor.
Note that the related client program is not killed
(yet) when a instance is deleted.
@@ -288,14 +286,23 @@ bool MyPty::open() {
return true;
}
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)
{
#ifdef VERBOSE_DEBUG
// verbose debug