Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

main.cpp

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------- */
00002 /*                                                                        */
00003 /* [main.C]                        Konsole                                */
00004 /*                                                                        */
00005 /* ---------------------------------------------------------------------- */
00006 /*                                                                        */
00007 /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>        */
00008 /*                                                                        */
00009 /* This file is part of Konsole, an X terminal.                           */
00010 /*                                                                        */
00011 /* The material contained in here more or less directly orginates from    */
00012 /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
00013 /*                                                                        */
00014 /* ---------------------------------------------------------------------- */
00015 /*                        */
00016 /* Ported Konsole to Qt/Embedded                                              */
00017 /*                        */
00018 /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com>                  */
00019 /*                        */
00020 /* -------------------------------------------------------------------------- */
00021 
00022 #include "konsole.h"
00023 
00024 #ifdef QT_QWS_OPIE
00025 
00026 #include <opie2/oapplicationfactory.h>
00027 
00028 /* --| main |------------------------------------------------------ */
00029 using namespace Opie::Core;
00030 OPIE_EXPORT_APP( OApplicationFactory<Konsole> )
00031 
00032 #else //for non opie builds
00033 
00034 #include <qpe/qpeapplication.h>
00035 
00036 #include <qfile.h>
00037 
00038 #include <unistd.h>
00039 #include <stdio.h>
00040 #include <stdlib.h>
00041 
00042 #include <pwd.h>
00043 #include <sys/types.h>
00044 
00045 
00046 /* --| main |------------------------------------------------------ */
00047                 int main(int argc, char* argv[]) {
00048                 if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; 
00049                 if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl;  // drop privileges
00050 
00051                 QPEApplication a( argc, argv );
00052 #ifdef FAKE_CTRL_AND_ALT
00053     odebug << "Fake Ctrl and Alt defined" << oendl; 
00054                 QPEApplication::grabKeyboard(); // for CTRL and ALT
00055 #endif
00056 
00057                 QStrList tmp;
00058                 const char* shell = getenv("SHELL");
00059 
00060                 if (shell == NULL || *shell == '\0') {
00061                                 struct passwd *ent = 0;
00062                                 uid_t me = getuid();
00063                                 shell = "/bin/sh";
00064     
00065                                 while ( (ent = getpwent()) != 0 ) {
00066                                                 if (ent->pw_uid == me) {
00067                                                                 if (ent->pw_shell != "")
00068                                                                                 shell = ent->pw_shell;
00069                                                                 break;
00070                                                 }
00071                                 }
00072                                 endpwent();
00073                 }
00074 
00075                 if( putenv((char*)"COLORTERM=") !=0)
00076                                 odebug << "putenv failed" << oendl;  // to trigger mc's color detection
00077 
00078                 Konsole m( "test", shell, tmp, TRUE  );
00079                 m.setCaption( Konsole::tr("Terminal") );
00080                 a.showMainWidget( &m );
00081 
00082                 return a.exec();
00083 }
00084 
00085 #endif

Generated on Sat Nov 5 16:15:25 2005 for OPIE by  doxygen 1.4.2