summaryrefslogtreecommitdiff
path: root/noncore
authorzecke <zecke>2002-10-22 14:25:05 (UTC)
committer zecke <zecke>2002-10-22 14:25:05 (UTC)
commit53a21f61d99d62e62412e1b5ca9bde085b25bde5 (patch) (side-by-side diff)
tree894a1162468586710213945647d835dd94a3f5f1 /noncore
parente006ea7655b455974ae64c30098eeecb7304508b (diff)
downloadopie-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
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp19
-rw-r--r--noncore/apps/opie-console/MyPty.h1
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp17
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp3
-rw-r--r--noncore/apps/opie-console/filetransfer.h8
-rw-r--r--noncore/apps/opie-console/profile.h5
-rw-r--r--noncore/apps/opie-console/terminalwidget.cpp24
7 files changed, 61 insertions, 16 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
@@ -166,25 +166,25 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int)
::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);
}
@@ -227,26 +227,41 @@ int MyPty::openPty()
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()
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
@@ -85,15 +85,16 @@ protected slots:
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
@@ -30,25 +30,40 @@ EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const c
}
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) );
+ 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);
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
@@ -51,24 +51,25 @@ void FileTransfer::sendFile( const QString& file ) {
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 */
@@ -223,25 +224,25 @@ void FileTransfer::slotProgress( const QStringList& list ) {
min = progi[0].toInt();
sec = progi[1].toInt();
if ( prog > m_prog ) {
m_prog = prog;
emit progress(m_file, m_prog, bps, -1, min , sec );
}
}
void FileTransfer::cancel() {
if(m_pid > 0) ::kill(m_pid,9 );
-
+
}
void FileTransfer::slotExec() {
char buf[2];
::read(m_term[0], buf, 1 );
delete m_proc;
delete m_not;
m_proc = m_not = 0l;
close( m_term[0] );
close( m_term[1] );
close( m_comm[0] );
close( m_comm[1] );
layer()->closeRawIO( m_fd );
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
@@ -24,31 +24,25 @@ public:
~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
@@ -11,25 +11,28 @@
* 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 );
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
@@ -3,27 +3,28 @@
#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,
@@ -65,26 +66,29 @@ TerminalWidget::TerminalWidget( const QString& name, QWidget* parent,
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) ),
@@ -111,24 +115,30 @@ void TerminalWidget::load( const Profile& prof ) {
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:
@@ -161,24 +171,30 @@ void TerminalWidget::load( const Profile& prof ) {
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;