author | zecke <zecke> | 2002-10-22 14:25:05 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-22 14:25:05 (UTC) |
commit | 53a21f61d99d62e62412e1b5ca9bde085b25bde5 (patch) (side-by-side diff) | |
tree | 894a1162468586710213945647d835dd94a3f5f1 | |
parent | e006ea7655b455974ae64c30098eeecb7304508b (diff) | |
download | opie-53a21f61d99d62e62412e1b5ca9bde085b25bde5.zip opie-53a21f61d99d62e62412e1b5ca9bde085b25bde5.tar.gz opie-53a21f61d99d62e62412e1b5ca9bde085b25bde5.tar.bz2 |
set $TERM in MyPty according to the terminal type
emulation_handler set the keyfilter right for the right terminal
filetransfer fix warnings
profile add Linux, XTerm as Emulation options
TerminalWidget add Linux,XTerm
-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 19 | ||||
-rw-r--r-- | noncore/apps/opie-console/MyPty.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 15 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.h | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/terminalwidget.cpp | 24 |
7 files changed, 59 insertions, 14 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 6b0d6f2..16bb5ff 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp @@ -154,49 +154,49 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int) { // This is code from the Qt DumbTerminal example m_cpid = fork(); if ( !m_cpid ) { // child - exec shell on tty for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); int ttyfd = ::open(m_ttynam, O_RDWR); dup2(ttyfd, STDIN_FILENO); dup2(ttyfd, STDOUT_FILENO); dup2(ttyfd, STDERR_FILENO); // should be done with tty, so close it ::close(ttyfd); static struct termios ttmode; if ( setsid() < 0 ) perror( "failed to set process group" ); #if defined (TIOCSCTTY) // grabbed from APUE by Stevens ioctl(STDIN_FILENO, TIOCSCTTY, 0); #endif tcgetattr( STDIN_FILENO, &ttmode ); ttmode.c_cc[VINTR] = 3; ttmode.c_cc[VERASE] = 8; tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); - setenv("TERM","vt100",1); + setenv("TERM",m_term,1); setenv("COLORTERM","0",1); if (getuid() == 0) { char msg[] = "WARNING: You are running this shell as root!\n"; write(ttyfd, msg, sizeof(msg)); } execl(cmd, cmd, 0); donePty(); exit(-1); } // parent - continue as a widget delete m_sn_r; m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); delete m_sn_e; m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); return 0; } int MyPty::openPty() @@ -215,50 +215,65 @@ int MyPty::openPty() for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { ::close(ptyfd); ptyfd = -1; } } } } #endif if ( ptyfd < 0 ) { // qApp->exit(1); return -1; } return ptyfd; } /*! Create an instance. */ -MyPty::MyPty(const Profile&) : m_cpid(0) +MyPty::MyPty(const Profile& prof) : m_cpid(0) { + + int term = prof.readNumEntry("Terminal", Profile::VT100 ); + switch( term ) { + default: + case Profile::VT100: + case Profile::VT102: + m_term = "vt100"; + break; + case Profile::Linux: + m_term = "linux"; + break; + case Profile::XTerm: + m_term = "xterm"; + break; + } m_sn_e = 0l; m_sn_r = 0l; m_fd = openPty(); ProcCtl* ctl = ProcCtl::self(); } /*! Destructor. Note that the related client program is not killed (yet) when a instance is deleted. */ MyPty::~MyPty() { donePty(); } QString MyPty::identifier()const { return QString::fromLatin1("term"); } QString MyPty::name()const{ return identifier(); } bool MyPty::open() { if (m_fd < 0) m_fd = openPty(); diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h index 81abad5..7561ca3 100644 --- a/noncore/apps/opie-console/MyPty.h +++ b/noncore/apps/opie-console/MyPty.h @@ -73,27 +73,28 @@ public: void received(const QByteArray&); public slots: void send(const QByteArray& ); private: const char* deviceName(); protected slots: void readPty(); void donePty(); private: int openPty(); private: char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." int m_fd; int m_cpid; QSocketNotifier* m_sn_e; QSocketNotifier* m_sn_r; + char* m_term; }; #endif diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index df8e573..bdc8b43 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -19,48 +19,63 @@ EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const c connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), this, SIGNAL(changeSize(int, int) ) ); connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), this, SLOT(recvEmulation(const char*, int) ) ); m_teEmu->setConnect( true ); m_teEmu->setHistory( TRUE ); load( prof ); } EmulationHandler::~EmulationHandler() { if (isRecording()) clearScript(); delete m_teEmu; delete m_teWid; } void EmulationHandler::load( const Profile& prof) { m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); int num = prof.readNumEntry("Color"); setColor( foreColor(num), backColor(num) ); m_teWid->setBackgroundColor(backColor(num) ); + + int term = prof.readNumEntry("Terminal", 0) ; + switch(term) { + default: + case Profile::VT102: + case Profile::VT100: + m_teEmu->setKeytrans("vt100.keytab"); + break; + case Profile::Linux: + m_teEmu->setKeytrans("linux.keytab"); + break; + case Profile::XTerm: + m_teEmu->setKeytrans("default.Keytab"); + break; + } } void EmulationHandler::recv( const QByteArray& ar) { m_teEmu->onRcvBlock(ar.data(), ar.count() ); } void EmulationHandler::recvEmulation(const char* src, int len ) { QByteArray ar(len); memcpy(ar.data(), src, sizeof(char) * len ); if (isRecording()) m_script->append(ar); emit send(ar); } QWidget* EmulationHandler::widget() { return m_teWid; } /* * allocate a new table of colors */ void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { ColorEntry table[TABLE_COLORS]; const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); for (int i = 0; i < TABLE_COLORS; i++ ) { diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index b81c2a2..221838c 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp @@ -39,48 +39,49 @@ void FileTransfer::sendFile( const QString& file ) { // m_fd = ::open("/dev/ttyS0", O_RDWR); m_file = file; if ( pipe( m_comm ) < 0 ) m_comm[0] = m_comm[1] = 0; if ( pipe( m_info ) < 0 ) m_info[0] = m_info[1] = 0; m_pid = fork(); switch( m_pid ) { case -1: emit error( StartError, tr("Was not able to fork") ); slotExec(); break; case 0:{ setupChild(); /* exec */ char* verbose = "-vv"; char* binray = "-b"; char* typus; switch(m_type ) { + default: case SZ: typus = ""; break; case SX: typus = "-X"; break; case SY: typus = "--ymodem"; break; } /* we should never return from here */ execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); /* communication for error!*/ char resultByte =1; if (m_info[1] ) write(m_info[1], &resultByte, 1 ); _exit( -1 ); break; } default:{ if ( m_info[1] ) close( m_info[1] ); diff --git a/noncore/apps/opie-console/filetransfer.h b/noncore/apps/opie-console/filetransfer.h index 9cc1e8d..8f55041 100644 --- a/noncore/apps/opie-console/filetransfer.h +++ b/noncore/apps/opie-console/filetransfer.h @@ -12,43 +12,37 @@ class QSocketNotifier; class OProcess; class FileTransferControl; class FileTransfer : public FileTransferLayer{ Q_OBJECT friend class FileTransferControl; public: enum Type { SZ = 0, SX, SY }; FileTransfer( Type t, IOLayer* ); ~FileTransfer(); void sendFile( const QString& file ); void sendFile( const QFile& ); void cancel(); private slots: void setupChild(); void slotRead(); void slotProgress( const QStringList& ); void slotExec(); private: - /* - * FIXME? What does happen if we've - * two FileTransfers at a time? - * Have a procctl which does listen - * for termination and then send a signal - */ + Type m_type; pid_t m_pid; int m_fd; int m_prog; int m_info[2]; int m_comm[2]; int m_term[2]; QString m_file; - Type m_type; QSocketNotifier *m_not; QSocketNotifier* m_proc; }; #endif diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h index 4f9e9c2..eeda1b6 100644 --- a/noncore/apps/opie-console/profile.h +++ b/noncore/apps/opie-console/profile.h @@ -1,47 +1,50 @@ #ifndef OPIE_PROFILE_H #define OPIE_PROFILE_H #include <qmap.h> #include <qstring.h> #include <qstringlist.h> #include <qvaluelist.h> /** * A session will be generated from a saved * profile. A profile contains the iolayername * a name. * We can generate a Session from a Profile * Configuration is contained here too */ class Profile { public: typedef QValueList<Profile> ValueList; enum Color { Black = 0, White, Gray, Green, Orange}; - enum Terminal {VT102 = 0, VT100 }; + enum Terminal {VT102 = 0, VT100, + Ansi, + Linux, + XTerm }; enum Font { Micro = 0, Small, Medium }; Profile(); Profile( const QString& name, const QCString& iolayerName, const QCString& termName, int background, int foreground, int terminal); Profile( const Profile& ); Profile &operator=( const Profile& ); bool operator==( const Profile& prof ); ~Profile(); QString name()const; QCString ioLayerName()const; QCString terminalName()const; bool autoConnect()const; int foreground()const; int background()const; int terminal()const; /* * config stuff */ diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp index 8badf96..eae94c3 100644 --- a/noncore/apps/opie-console/terminalwidget.cpp +++ b/noncore/apps/opie-console/terminalwidget.cpp @@ -1,41 +1,42 @@ #include <qbuttongroup.h> #include <qlabel.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qradiobutton.h> #include <qgroupbox.h> #include <qvbox.h> #include <qhgroupbox.h> #include <qlayout.h> #include "terminalwidget.h" namespace { enum TermIds { - id_term_vt100, + id_term_vt100 = 0, id_term_vt102, - id_term_ansi + id_term_linux, + id_term_xterm }; enum ColourIds { id_term_black, id_term_white, id_term_green, id_term_orange }; enum FontIds { id_size_small, id_size_medium, id_size_large }; }; TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, const char* na ) : ProfileDialogTerminalWidget( name, parent, na ) { m_terminal = new QLabel(tr("Terminal Type"), this ); m_terminalBox = new QComboBox(this); m_colorLabel = new QLabel(tr("Color scheme"), this); m_colorCmb = new QComboBox(this ); @@ -53,94 +54,103 @@ TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, m_optionEcho = new QCheckBox(tr("Local echo"), m_groupOptions ); m_optionWrap = new QCheckBox(tr("Line wrap"), m_groupOptions ); m_lroot = new QVBoxLayout(this, 2 ); m_typeBox = new QVBoxLayout( m_lroot ); m_hbox = new QHBoxLayout( m_groupSize, 2 ); m_colorBox = new QVBoxLayout( m_lroot ); // Layout m_typeBox->add(m_terminal ); m_typeBox->add(m_terminalBox ); m_hbox->add(m_sizeSmall ); m_hbox->add(m_sizeMedium ); m_hbox->add(m_sizeLarge ); m_lroot->add(m_groupSize ); m_colorBox->add( m_colorLabel ); m_colorBox->add( m_colorCmb ); m_lroot->add(m_groupConv ); m_lroot->add(m_groupOptions ); // Fill in some options - m_terminalBox->insertItem( tr("VT 100"), id_term_vt100 ); - m_terminalBox->insertItem( tr("VT 102"), id_term_vt102 ); + qWarning("Options for terminal box"); + m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); + m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); + m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); + m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); m_colorCmb->insertItem( tr("black on white"), id_term_black ); m_colorCmb->insertItem( tr("white on black"), id_term_white ); m_colorCmb->insertItem( tr("green on black"), id_term_green ); m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); // signals + slots /* connect(m_terminalBox, SIGNAL(activated(int) ), this, SLOT(slotTermTerm(int) ) ); connect(m_colorBox, SIGNAL(activated(int) ), tis, SLOT(slotTermColor(int) ) ); connect(m_groupSize, SIGNAL(activated(int) ), this, SLOT(slotTermFont(int) ) ); connect(m_optionEcho, SIGNAL(toggled(bool) ), this, SLOT(slotTermEcho(bool) ) ); connect(m_optionWrap, SIGNAL(toggled(bool) ), this, SLOT(slotTermWrap(bool) ) ); connect(m_convInbound, SIGNAL(toggled(bool) ), this, SLOT(slotTermInbound(bool) ) ); connect(m_convOutbound, SIGNAL(toggled(bool) ), this, SLOT(slotTermOutbound(bool) ) ); */ } TerminalWidget::~TerminalWidget() { } void TerminalWidget::load( const Profile& prof ) { int term = prof.readNumEntry("Terminal"); int color = prof.readNumEntry("Color"); int fontsize = prof.readNumEntry("Font"); int opt_echo = prof.readNumEntry("Echo"); int opt_wrap = prof.readNumEntry("Wrap"); int opt_inbound = prof.readNumEntry("Inbound"); int opt_outbound = prof.readNumEntry("Outbound"); switch( term ) { case Profile::VT100: m_terminalBox->setCurrentItem(id_term_vt100 ); break; case Profile::VT102: m_terminalBox->setCurrentItem(id_term_vt102 ); break; + case Profile::Linux: + m_terminalBox->setCurrentItem(id_term_linux ); + break; + case Profile::XTerm: + m_terminalBox->setCurrentItem(id_term_xterm ); + break; default: break; }; switch( color ) { case Profile::Black: m_colorCmb->setCurrentItem(id_term_black ); break; case Profile::White: m_colorCmb->setCurrentItem(id_term_white ); break; case Profile::Green: m_colorCmb->setCurrentItem(id_term_green ); break; case Profile::Orange: m_colorCmb->setCurrentItem(id_term_orange ); break; default: break; }; switch( fontsize ) { case Profile::Micro: m_sizeSmall->setChecked(true ); @@ -149,48 +159,54 @@ void TerminalWidget::load( const Profile& prof ) { m_sizeMedium->setChecked(true ); break; case Profile::Medium: m_sizeLarge->setChecked( true ); break; m_sizeSmall->setChecked(true); default: break; }; if (opt_echo) m_optionEcho->setChecked( true ); if (opt_wrap) m_optionWrap->setChecked( true ); if (opt_inbound) m_convInbound->setChecked( true ); if (opt_outbound) m_convOutbound->setChecked( true ); } void TerminalWidget::save( Profile& profile ) { switch(m_terminalBox->currentItem() ) { case id_term_vt100: profile.writeEntry("Terminal", Profile::VT100 ); break; case id_term_vt102: profile.writeEntry("Terminal", Profile::VT102 ); break; + case id_term_linux: + profile.writeEntry("Terminal", Profile::Linux ); + break; + case id_term_xterm: + profile.writeEntry("Terminal", Profile::XTerm ); + break; //case id_term_ansi: // profile.writeEntry("Terminal", Profile::VT102 ); // break; default: break; }; // color switch(m_colorCmb->currentItem() ) { case id_term_black: profile.writeEntry("Color", Profile::Black ); break; case id_term_white: profile.writeEntry("Color", Profile::White ); break; case id_term_green: profile.writeEntry("Color", Profile::Green ); break; case id_term_orange: profile.writeEntry("Color", Profile::Orange ); break; default: break; }; |