author | mickeyl <mickeyl> | 2003-11-06 10:26:22 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-11-06 10:26:22 (UTC) |
commit | 8c283be8e455571a03f11035b23f649e49de726c (patch) (unidiff) | |
tree | 8213d1c2cbf06881649af936362d4035ee63ceed /core/apps/embeddedkonsole/konsole.cpp | |
parent | 55ea6367fba8a82fbdca74599422717e4b3c3ec6 (diff) | |
download | opie-8c283be8e455571a03f11035b23f649e49de726c.zip opie-8c283be8e455571a03f11035b23f649e49de726c.tar.gz opie-8c283be8e455571a03f11035b23f649e49de726c.tar.bz2 |
merge core/apps/*
Diffstat (limited to 'core/apps/embeddedkonsole/konsole.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 74 |
1 files changed, 57 insertions, 17 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index c324c35..ec438c3 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -47,4 +47,7 @@ | |||
47 | #include <qpalette.h> | 47 | #include <qpalette.h> |
48 | 48 | ||
49 | #include <unistd.h> | ||
50 | #include <pwd.h> | ||
51 | #include <sys/types.h> | ||
49 | #include <sys/wait.h> | 52 | #include <sys/wait.h> |
50 | #include <stdio.h> | 53 | #include <stdio.h> |
@@ -172,18 +175,55 @@ static const char *commonCmds[] = | |||
172 | }; | 175 | }; |
173 | 176 | ||
177 | static void konsoleInit(const char** shell) { | ||
178 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | ||
179 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | ||
180 | |||
181 | |||
182 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | ||
183 | |||
184 | qDebug("keyboard grabbed"); | ||
185 | #ifdef FAKE_CTRL_AND_ALT | ||
186 | qDebug("Fake Ctrl and Alt defined"); | ||
187 | QPEApplication::grabKeyboard(); // for CTRL and ALT | ||
188 | #endif | ||
189 | |||
190 | *shell = getenv("SHELL"); | ||
191 | qWarning("SHell initially is %s", *shell ); | ||
192 | |||
193 | if (shell == NULL || *shell == '\0') { | ||
194 | struct passwd *ent = 0; | ||
195 | uid_t me = getuid(); | ||
196 | *shell = "/bin/sh"; | ||
197 | |||
198 | while ( (ent = getpwent()) != 0 ) { | ||
199 | if (ent->pw_uid == me) { | ||
200 | if (ent->pw_shell != "") | ||
201 | *shell = ent->pw_shell; | ||
202 | break; | ||
203 | } | ||
204 | } | ||
205 | endpwent(); | ||
206 | } | ||
207 | |||
208 | qWarning("SHELL now is %s", *shell ); | ||
209 | |||
210 | if( putenv((char*)"COLORTERM=") !=0) | ||
211 | qDebug("putenv failed"); // to trigger mc's color detection | ||
212 | } | ||
174 | 213 | ||
175 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 214 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
176 | QMainWindow(parent, name, fl) | 215 | QMainWindow(parent, name, fl) |
177 | { | 216 | { |
178 | QStrList args; | 217 | QStrList tmp; const char* shell; |
179 | init("/bin/sh",args); | ||
180 | } | ||
181 | 218 | ||
182 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 219 | setCaption( tr("Terminal") ); |
183 | : QMainWindow(0, name) | 220 | |
184 | { | 221 | konsoleInit( &shell); |
185 | init(_pgm,_args); | 222 | qWarning("Using shell %s", shell); |
223 | init(shell,tmp); | ||
186 | } | 224 | } |
187 | 225 | ||
226 | |||
227 | |||
188 | void Konsole::initCommandList() | 228 | void Konsole::initCommandList() |
189 | { | 229 | { |
@@ -300,5 +340,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) | |||
300 | colorMenu->insertItem(tr( "Custom")); | 340 | colorMenu->insertItem(tr( "Custom")); |
301 | #endif | 341 | #endif |
302 | 342 | ||
303 | configMenu->insertItem( tr("Font"), fontList ); | 343 | configMenu->insertItem( tr("Font"), fontList ); |
304 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 344 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
@@ -369,5 +409,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) | |||
369 | // scrollMenu->insertSeparator(4); | 409 | // scrollMenu->insertSeparator(4); |
370 | // scrollMenu->insertItem(tr( "Horizontal" )); | 410 | // scrollMenu->insertItem(tr( "Horizontal" )); |
371 | 411 | ||
372 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 412 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
373 | 413 | ||
@@ -381,5 +421,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) | |||
381 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 421 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); |
382 | 422 | ||
383 | 423 | ||
384 | //scrollMenuSelected(-29); | 424 | //scrollMenuSelected(-29); |
385 | // cfg.setGroup("ScrollBar"); | 425 | // cfg.setGroup("ScrollBar"); |
@@ -419,5 +459,5 @@ void Konsole::show() | |||
419 | } | 459 | } |
420 | QMainWindow::show(); | 460 | QMainWindow::show(); |
421 | 461 | ||
422 | } | 462 | } |
423 | 463 | ||
@@ -542,5 +582,5 @@ void Konsole::setColLin(int columns, int lines) | |||
542 | { | 582 | { |
543 | qDebug("konsole::setColLin:: Columns %d", columns); | 583 | qDebug("konsole::setColLin:: Columns %d", columns); |
544 | 584 | ||
545 | if ((columns==0) || (lines==0)) | 585 | if ((columns==0) || (lines==0)) |
546 | { | 586 | { |
@@ -764,5 +804,5 @@ void Konsole::colorMenuSelected(int iD) | |||
764 | colorMenu->setItemChecked(-18,TRUE); | 804 | colorMenu->setItemChecked(-18,TRUE); |
765 | } | 805 | } |
766 | #ifdef QT_QWS_OPIE | 806 | #ifdef QT_QWS_OPIE |
767 | if(iD==-19) { | 807 | if(iD==-19) { |
768 | // Custom | 808 | // Custom |
@@ -891,5 +931,5 @@ i=-24;j=-25;k=-26; | |||
891 | cfg.writeEntry("Position",0); | 931 | cfg.writeEntry("Position",0); |
892 | } else if(index == j) { | 932 | } else if(index == j) { |
893 | 933 | ||
894 | te->setScrollbarLocation(1); | 934 | te->setScrollbarLocation(1); |
895 | cfg.writeEntry("Position",1); | 935 | cfg.writeEntry("Position",1); |
@@ -899,5 +939,5 @@ i=-24;j=-25;k=-26; | |||
899 | cfg.writeEntry("Position",2); | 939 | cfg.writeEntry("Position",2); |
900 | } | 940 | } |
901 | 941 | ||
902 | // case -29: { | 942 | // case -29: { |
903 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 943 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
@@ -1048,5 +1088,5 @@ i=-29; | |||
1048 | i=-28; | 1088 | i=-28; |
1049 | #endif | 1089 | #endif |
1050 | 1090 | ||
1051 | Config cfg("Konsole"); | 1091 | Config cfg("Konsole"); |
1052 | cfg.setGroup("ScrollBar"); | 1092 | cfg.setGroup("ScrollBar"); |
@@ -1059,4 +1099,4 @@ i=-28; | |||
1059 | te->setWrapAt(120); | 1099 | te->setWrapAt(120); |
1060 | configMenu->setItemChecked( i,FALSE); | 1100 | configMenu->setItemChecked( i,FALSE); |
1061 | } | 1101 | } |
1062 | } | 1102 | } |