-rw-r--r-- | core/apps/embeddedkonsole/main.cpp | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp index b456ce2..b851d3e 100644 --- a/core/apps/embeddedkonsole/main.cpp +++ b/core/apps/embeddedkonsole/main.cpp | |||
@@ -12,19 +12,74 @@ | |||
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | 21 | ||
22 | #include "konsole.h" | 22 | #include "konsole.h" |
23 | 23 | ||
24 | #include <opie2/oapplicationfactory.h> | 24 | #ifdef QT_QWS_OPIE |
25 | 25 | ||
26 | #include <opie2/oapplicationfactory.h> | ||
26 | 27 | ||
27 | /* --| main |------------------------------------------------------ */ | 28 | /* --| main |------------------------------------------------------ */ |
28 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
29 | OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) | 30 | OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) |
30 | 31 | ||
32 | #else //for non opie builds | ||
33 | |||
34 | #include <qpe/qpeapplication.h> | ||
35 | |||
36 | #include <qfile.h> | ||
37 | |||
38 | #include <unistd.h> | ||
39 | #include <stdio.h> | ||
40 | #include <stdlib.h> | ||
41 | |||
42 | #include <pwd.h> | ||
43 | #include <sys/types.h> | ||
44 | |||
45 | |||
46 | /* --| main |------------------------------------------------------ */ | ||
47 | int main(int argc, char* argv[]) { | ||
48 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | ||
49 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | ||
50 | |||
51 | QPEApplication a( argc, argv ); | ||
52 | #ifdef FAKE_CTRL_AND_ALT | ||
53 | qDebug("Fake Ctrl and Alt defined"); | ||
54 | QPEApplication::grabKeyboard(); // for CTRL and ALT | ||
55 | #endif | ||
56 | |||
57 | QStrList tmp; | ||
58 | const char* shell = getenv("SHELL"); | ||
59 | |||
60 | if (shell == NULL || *shell == '\0') { | ||
61 | struct passwd *ent = 0; | ||
62 | uid_t me = getuid(); | ||
63 | shell = "/bin/sh"; | ||
64 | |||
65 | while ( (ent = getpwent()) != 0 ) { | ||
66 | if (ent->pw_uid == me) { | ||
67 | if (ent->pw_shell != "") | ||
68 | shell = ent->pw_shell; | ||
69 | break; | ||
70 | } | ||
71 | } | ||
72 | endpwent(); | ||
73 | } | ||
74 | |||
75 | if( putenv((char*)"COLORTERM=") !=0) | ||
76 | qDebug("putenv failed"); // to trigger mc's color detection | ||
77 | |||
78 | Konsole m( "test", shell, tmp, TRUE ); | ||
79 | m.setCaption( Konsole::tr("Terminal") ); | ||
80 | a.showMainWidget( &m ); | ||
81 | |||
82 | return a.exec(); | ||
83 | } | ||
84 | |||
85 | #endif | ||