-rwxr-xr-x | core/apps/embeddedkonsole/embeddedkonsole.pro | 4 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 74 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 14 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/main.cpp | 45 | ||||
-rw-r--r-- | core/apps/textedit/main.cpp | 13 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 3 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 4 |
7 files changed, 72 insertions, 85 deletions
diff --git a/core/apps/embeddedkonsole/embeddedkonsole.pro b/core/apps/embeddedkonsole/embeddedkonsole.pro index f8d2793..55a1bb4 100755 --- a/core/apps/embeddedkonsole/embeddedkonsole.pro +++ b/core/apps/embeddedkonsole/embeddedkonsole.pro @@ -1,22 +1,20 @@ QMAKE_CFLAGS = -DHAVE_OPENPTY TMAKE_FLAGS += -DHAVE_OPENPTY QMAKE_LIBS = -lutil -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn_on release quick-app HEADERS = TEWidget.h \ TEScreen.h \ TECommon.h \ TEHistory.h \ TEmulation.h \ TEmuVt102.h \ session.h \ keytrans.h \ konsole.h \ commandeditdialog.h \ commandeditwidget.h \ playlistselection.h \ MyPty.h SOURCES = TEScreen.cpp \ TEWidget.cpp \ TEHistory.cpp \ 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 @@ -33,32 +33,35 @@ #include <qfontdialog.h> #include <qglobal.h> #include <qpainter.h> #include <qpe/qpemenubar.h> #include <qmessagebox.h> #include <qaction.h> #include <qapplication.h> #include <qfontmetrics.h> #include <qcombobox.h> #include <qevent.h> #include <qtabwidget.h> #include <qtabbar.h> #include <qpe/config.h> #include <qstringlist.h> #include <qpalette.h> +#include <unistd.h> +#include <pwd.h> +#include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "konsole.h" #include "keytrans.h" #include "commandeditdialog.h" #ifdef QT_QWS_OPIE #include <opie/colorpopupmenu.h> #endif class EKNumTabBar : public QTabBar { public: void numberTabs() @@ -158,46 +161,83 @@ static const char *commonCmds[] = "killall", "ln", "ping", "mount", "more", "sort", "touch", "umount", "mknod", "netstat", */ "exit", NULL }; +static void konsoleInit(const char** shell) { + if(setuid(getuid()) !=0) qDebug("setuid failed"); + if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges + + +// QPEApplication::grabKeyboard(); // for CTRL and ALT + + qDebug("keyboard grabbed"); +#ifdef FAKE_CTRL_AND_ALT + qDebug("Fake Ctrl and Alt defined"); + QPEApplication::grabKeyboard(); // for CTRL and ALT +#endif + + *shell = getenv("SHELL"); + qWarning("SHell initially is %s", *shell ); + + if (shell == NULL || *shell == '\0') { + struct passwd *ent = 0; + uid_t me = getuid(); + *shell = "/bin/sh"; + + while ( (ent = getpwent()) != 0 ) { + if (ent->pw_uid == me) { + if (ent->pw_shell != "") + *shell = ent->pw_shell; + break; + } + } + endpwent(); + } + + qWarning("SHELL now is %s", *shell ); + + if( putenv((char*)"COLORTERM=") !=0) + qDebug("putenv failed"); // to trigger mc's color detection +} Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { - QStrList args; - init("/bin/sh",args); -} + QStrList tmp; const char* shell; -Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) - : QMainWindow(0, name) -{ - init(_pgm,_args); + setCaption( tr("Terminal") ); + + konsoleInit( &shell); + qWarning("Using shell %s", shell); + init(shell,tmp); } + + void Konsole::initCommandList() { // qDebug("Konsole::initCommandList"); Config cfg("Konsole"); cfg.setGroup("Commands"); commonCombo->setInsertionPolicy(QComboBox::AtCurrent); commonCombo->clear(); if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { for (int i = 0; commonCmds[i] != NULL; i++) { commonCombo->insertItem(commonCmds[i],i); } } else { for (int i = 0; i < 100; i++) { if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); } @@ -286,33 +326,33 @@ void Konsole::init(const char* _pgm, QStrList & _args) colorMenu->insertItem(tr( "Black on White")); colorMenu->insertItem(tr( "White on Black")); colorMenu->insertItem(tr( "Black on Transparent")); colorMenu->insertItem(tr( "Black on Red")); colorMenu->insertItem(tr( "Red on Black")); colorMenu->insertItem(tr( "Green on Yellow")); colorMenu->insertItem(tr( "Blue on Magenta")); colorMenu->insertItem(tr( "Magenta on Blue")); colorMenu->insertItem(tr( "Cyan on White")); colorMenu->insertItem(tr( "White on Cyan")); colorMenu->insertItem(tr( "Blue on Black")); colorMenu->insertItem(tr( "Amber on Black")); #ifdef QT_QWS_OPIE colorMenu->insertItem(tr( "Custom")); #endif - + configMenu->insertItem( tr("Font"), fontList ); configMenu->insertItem(tr( "Colors") ,colorMenu); connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); menuBar->insertItem( tr("Options"), configMenu ); QPEToolBar *toolbar = new QPEToolBar( this ); QAction *a; // Button Commands @@ -355,45 +395,45 @@ void Konsole::init(const char* _pgm, QStrList & _args) initCommandList(); // for (int i = 0; commonCmds[i] != NULL; i++) { // commonCombo->insertItem( commonCmds[i], i ); // tmp = cfg.readEntry( QString::number(i),""); // if(tmp != "") // commonCombo->changeItem( tmp,i ); // } connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); scrollMenu->insertItem(tr( "None" )); scrollMenu->insertItem(tr( "Left" )); scrollMenu->insertItem(tr( "Right" )); // scrollMenu->insertSeparator(4); // scrollMenu->insertItem(tr( "Horizontal" )); - + configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); int jut = configMenu->insertItem(tr( "Wrap" )); cfg.setGroup("ScrollBar"); configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); jut = configMenu->insertItem(tr( "Use Beep" )); cfg.setGroup("Menubar"); configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); - + //scrollMenuSelected(-29); // cfg.setGroup("ScrollBar"); // if(cfg.readBoolEntry("HorzScroll",0)) { // if(cfg.readNumEntry("Position",2) == 0) // te->setScrollbarLocation(1); // else // te->setScrollbarLocation(0); // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); // te->setWrapAt(120); // } // create applications ///////////////////////////////////////////////////// setCentralWidget(tab); // load keymaps //////////////////////////////////////////////////////////// KeyTrans::loadAll(); for (int i = 0; i < KeyTrans::count(); i++) @@ -405,33 +445,33 @@ void Konsole::init(const char* _pgm, QStrList & _args) se_args = _args; se_args.prepend("--login"); parseCommandLine(); // read and apply default values /////////////////////////////////////////// resize(321, 321); // Dummy. QSize currentSize = size(); if (currentSize != size()) defaultSize = size(); } void Konsole::show() { if ( !nsessions ) { newSession(); } QMainWindow::show(); - + } void Konsole::initSession(const char*, QStrList &) { QMainWindow::show(); } Konsole::~Konsole() { while (nsessions > 0) { doneSession(getTe()->currentSession, 0); } Config cfg("Konsole"); cfg.setGroup("Konsole"); cfg.writeEntry("FontID", cfont); @@ -528,33 +568,33 @@ QSize Konsole::calcSize(int columns, int lines) { QSize size = te->calcSize(columns, lines); return size; } else { QSize size; return size; } } /** sets application window to a size based on columns X lines of the te guest widget. Call with (0,0) for setting default size. */ void Konsole::setColLin(int columns, int lines) { qDebug("konsole::setColLin:: Columns %d", columns); - + if ((columns==0) || (lines==0)) { if (defaultSize.isEmpty()) // not in config file : set default value { defaultSize = calcSize(80,24); // notifySize(24,80); // set menu items (strange arg order !) } resize(defaultSize); } else { resize(calcSize(columns, lines)); // notifySize(lines,columns); // set menu items (strange arg order !) } } /* void Konsole::setFont(int fontno) @@ -750,33 +790,33 @@ void Konsole::colorMenuSelected(int iD) foreground.setRgb(0xFF,0xFF,0xFF); cfg.writeEntry("Schema","16"); colorMenu->setItemChecked(-16,TRUE); } if(iD==-17) {// Black, Blue background.setRgb(0x00,0x00,0x00); foreground.setRgb(0x18,0xB2,0xB2); cfg.writeEntry("Schema","17"); colorMenu->setItemChecked(-17,TRUE); } if(iD==-18) {// Black, Gold background.setRgb(0x00,0x00,0x00); foreground.setRgb(255,215,0); cfg.writeEntry("Schema","18"); colorMenu->setItemChecked(-18,TRUE); } -#ifdef QT_QWS_OPIE +#ifdef QT_QWS_OPIE if(iD==-19) { // Custom qDebug("do custom"); if(fromMenu) { OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color"); connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeForegroundColor(const QColor&))); penColorPopupMenu->exec(); } cfg.writeEntry("Schema","19"); if(!fromMenu) { foreground.setNamedColor(cfg.readEntry("foreground","")); background.setNamedColor(cfg.readEntry("background","")); } fromMenu=FALSE; colorMenu->setItemChecked(-19,TRUE); @@ -877,41 +917,41 @@ void Konsole::scrollMenuSelected(int index) // qDebug( "scrollbar menu %d",index); TEWidget* te = getTe(); Config cfg("Konsole"); cfg.setGroup("ScrollBar"); int i,j,k; #ifdef QT_QWS_OPIE i=-25;j=-26;k=-27; #else i=-24;j=-25;k=-26; #endif if(index == i) { te->setScrollbarLocation(0); cfg.writeEntry("Position",0); } else if(index == j) { - + te->setScrollbarLocation(1); cfg.writeEntry("Position",1); } else if(index == k) { te->setScrollbarLocation(2); cfg.writeEntry("Position",2); } - + // case -29: { // bool b=cfg.readBoolEntry("HorzScroll",0); // cfg.writeEntry("HorzScroll", !b ); // cfg.write(); // if(cfg.readNumEntry("Position",2) == 0) { // te->setScrollbarLocation(1); // te->setWrapAt(0); // } else { // te->setScrollbarLocation(0); // te->setWrapAt(120); // } // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); // } // break; } @@ -1034,29 +1074,29 @@ void Konsole::changeBackgroundColor(const QColor &color) { cfg.setGroup("Colors"); int r, g, b; color.rgb(&r,&g,&b); background.setRgb(r,g,b); cfg.writeEntry("background",color.name()); qDebug("background "+color.name()); cfg.write(); } void Konsole::doWrap() { int i; #ifdef QT_QWS_OPIE i=-29; #else i=-28; #endif - + Config cfg("Konsole"); cfg.setGroup("ScrollBar"); TEWidget* te = getTe(); if( !cfg.readBoolEntry("HorzScroll",0)) { te->setWrapAt(0); configMenu->setItemChecked( i,TRUE); } else { // te->setWrapAt(90); te->setWrapAt(120); configMenu->setItemChecked( i,FALSE); - } + } } diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index 4938159..e9d0e4b 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h @@ -30,41 +30,41 @@ #include <qintdict.h> #include <qptrdict.h> #include <qtabwidget.h> #include <qpe/qpetoolbar.h> #include <qcombobox.h> #include <qcolor.h> #include "MyPty.h" #include "TEWidget.h" #include "TEmuVt102.h" #include "session.h" class EKNumTabWidget; class Konsole : public QMainWindow { -Q_OBJECT + Q_OBJECT public: + static QString appName() { return QString::fromLatin1("embeddedkonsole"); } Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); - Konsole(const char * name, const char* pgm, QStrList & _args, int histon); ~Konsole(); void setColLin(int columns, int lines); - QPEToolBar *secondToolBar; + QPEToolBar *secondToolBar; void show(); void setColor(); int lastSelectedMenu; int startUp; private slots: void setDocument(const QString &); void doneSession(TESession*,int); void changeColumns(int); void fontChanged(int); void configMenuSelected(int ); void colorMenuSelected(int); void colorMenuIsSelected(int); void enterCommand(int); void hitEnter(); void hitSpace(); void hitTab(); @@ -81,47 +81,47 @@ private slots: void changeForegroundColor(const QColor &); void changeBackgroundColor(const QColor &); private: void doWrap(); void init(const char* _pgm, QStrList & _args); void initSession(const char* _pgm, QStrList & _args); void runSession(TESession* s); void setColorPixmaps(); void setHistory(bool); QSize calcSize(int columns, int lines); TEWidget* getTe(); QStringList commands; QLabel * msgLabel; QColor foreground, background; bool fromMenu; private: - class VTFont + class VTFont { public: - VTFont(QString name, QFont& font) + VTFont(QString name, QFont& font) { this->name = name; this->font = font; } - QFont& getFont() + QFont& getFont() { return font; } - QString getName() + QString getName() { return name; } private: QString name; QFont font; }; EKNumTabWidget* tab; int nsessions; QList<VTFont> fonts; int cfont; QCString se_pgm; QStrList se_args; diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp index 91199eb..f77fe24 100644 --- a/core/apps/embeddedkonsole/main.cpp +++ b/core/apps/embeddedkonsole/main.cpp @@ -9,71 +9,30 @@ /* This file is part of Konsole, an X terminal. */ /* */ /* The material contained in here more or less directly orginates from */ /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ /* */ /* ---------------------------------------------------------------------- */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ #include "konsole.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> #include <qfile.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <pwd.h> #include <sys/types.h> /* --| main |------------------------------------------------------ */ -int main(int argc, char* argv[]) -{ - if(setuid(getuid()) !=0) qDebug("setuid failed"); - if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges - - QPEApplication a( argc, argv ); - -// QPEApplication::grabKeyboard(); // for CTRL and ALT - - qDebug("keyboard grabbed"); -#ifdef FAKE_CTRL_AND_ALT - qDebug("Fake Ctrl and Alt defined"); - QPEApplication::grabKeyboard(); // for CTRL and ALT -#endif - - QStrList tmp; - const char* shell = getenv("SHELL"); - - if (shell == NULL || *shell == '\0') { - struct passwd *ent = 0; - uid_t me = getuid(); - shell = "/bin/sh"; - - while ( (ent = getpwent()) != 0 ) { - if (ent->pw_uid == me) { - if (ent->pw_shell != "") - shell = ent->pw_shell; - break; - } - } - endpwent(); - } - - if( putenv((char*)"COLORTERM=") !=0) - qDebug("putenv failed"); // to trigger mc's color detection - - Konsole m( "test", shell, tmp, TRUE ); - m.setCaption( Konsole::tr("Terminal") ); - a.showMainWidget( &m ); - - return a.exec(); -} - +OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) diff --git a/core/apps/textedit/main.cpp b/core/apps/textedit/main.cpp index f80c5d8..edab73d 100644 --- a/core/apps/textedit/main.cpp +++ b/core/apps/textedit/main.cpp @@ -8,28 +8,19 @@ ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "textedit.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main( int argc, char **argv ) -{ - QPEApplication a( argc, argv ); - - TextEdit e; - a.showMainDocumentWidget(&e); -// if ( argc == 3 && argv[1] == QCString("-f") ) -// e.openFile(argv[2]); - - return a.exec(); -} +OPIE_EXPORT_APP( OApplicationFactory<TextEdit> ) diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index e0cbea2..303b707 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h @@ -41,52 +41,53 @@ class QAction; class QWidgetStack; class QToolButton; class QPopupMenu; class QToolBar; class QLineEdit; class QAction; class FileSelector; class QpeEditor; class QPopupMenu; class QTimer; class TextEdit : public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("textedit"); } TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~TextEdit(); protected: QPopupMenu *font; QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction, *nAutoSave; bool edited, edited1; void openFile( const QString & ); QCopChannel * channel; bool featureAutoSave; void closeEvent( QCloseEvent *e ); void doSearchBar(); int savePrompt(); void setTimer(); private slots: void editorChanged(); void receive(const QCString&, const QByteArray&); void timerCrank(); - void doTimer(bool); + void doTimer(bool); void editPasteTimeDate(); void doPrompt(bool); void doDesktop(bool); void doFilePerms(bool); void doAbout(); void setDocument(const QString&); void changeFont(); void fileNew(); void fileRevert(); void fileOpen(); void changeStartConfig(bool); bool save(); bool saveAs(); void cleanUp(); void gotoLine(); diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro index 2577340..b958ff5 100644 --- a/core/apps/textedit/textedit.pro +++ b/core/apps/textedit/textedit.pro @@ -1,19 +1,17 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn_on release quick-app HEADERS = textedit.h filePermissions.h SOURCES = main.cpp textedit.cpp filePermissions.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = textedit TRANSLATIONS = ../../../i18n/de/textedit.ts \ ../../../i18n/nl/textedit.ts \ ../../../i18n/da/textedit.ts \ ../../../i18n/xx/textedit.ts \ ../../../i18n/en/textedit.ts \ ../../../i18n/es/textedit.ts \ ../../../i18n/fr/textedit.ts \ ../../../i18n/hu/textedit.ts \ ../../../i18n/ja/textedit.ts \ |