00001 /* -------------------------------------------------------------------------- */ 00002 /* */ 00003 /* [MyPty.h] Pseudo Terminal Device */ 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 for KDE */ 00010 /* */ 00011 /* -------------------------------------------------------------------------- */ 00012 /* */ 00013 /* Ported Konsole to Qt/Embedded */ 00014 /* */ 00015 /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 00016 /* */ 00017 /* -------------------------------------------------------------------------- */ 00018 00022 #ifndef MY_PTY_H 00023 #define MY_PTY_H 00024 00025 #include <qobject.h> 00026 #include <qlist.h> 00027 #include <qstrlist.h> 00028 00029 #include "io_layer.h" 00030 00031 typedef QMap<QString, QString> EnvironmentMap; 00032 00033 class Profile; 00034 class QSocketNotifier; 00035 class MyPty : public IOLayer 00036 { 00037 Q_OBJECT 00038 public: 00039 00040 MyPty(const Profile&); 00041 ~MyPty(); 00042 00043 00044 00045 QString identifier()const; 00046 QString name()const; 00047 QBitArray supports()const; 00048 00049 public slots: 00055 void start(); 00056 int run(const char* pgm, QStrList & args , const char* term, int addutmp); 00057 bool open(); 00058 void close(); 00059 void reload( const Profile& ); 00060 void setSize(int lines, int columns); 00061 void error(); 00062 bool isConnected() { return true; }; 00063 signals: 00064 00069 void done(int status); 00070 00076 void received(const QByteArray&); 00077 00078 public slots: 00079 00080 void send(const QByteArray& ); 00081 00082 private: 00083 const char* deviceName(); 00084 00085 protected slots: 00086 void readPty(); 00087 void donePty(); 00088 00089 private: 00090 int openPty(); 00091 00092 private: 00093 00094 char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" 00095 char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." 00096 int m_fd; 00097 int m_cpid; 00098 QSocketNotifier* m_sn_e; 00099 QSocketNotifier* m_sn_r; 00100 char* m_term; 00101 00102 QString m_cmd; 00103 EnvironmentMap m_env; 00104 }; 00105 00106 #endif
1.4.2