summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -82,246 +82,261 @@
82#include <pty.h> 82#include <pty.h>
83#endif 83#endif
84 84
85#include "procctl.h" 85#include "procctl.h"
86#include "MyPty.h" 86#include "MyPty.h"
87 87
88 88
89#undef VERBOSE_DEBUG 89#undef VERBOSE_DEBUG
90 90
91 91
92/* -------------------------------------------------------------------------- */ 92/* -------------------------------------------------------------------------- */
93 93
94/*! 94/*!
95 Informs the client program about the 95 Informs the client program about the
96 actual size of the window. 96 actual size of the window.
97*/ 97*/
98 98
99void MyPty::setSize(int lines, int columns) 99void MyPty::setSize(int lines, int columns)
100{ 100{
101 qWarning("setting size"); 101 qWarning("setting size");
102 struct winsize wsize; 102 struct winsize wsize;
103 wsize.ws_row = (unsigned short)lines; 103 wsize.ws_row = (unsigned short)lines;
104 wsize.ws_col = (unsigned short)columns; 104 wsize.ws_col = (unsigned short)columns;
105 if(m_fd < 0) return; 105 if(m_fd < 0) return;
106 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); 106 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
107} 107}
108 108
109 109
110void MyPty::donePty() 110void MyPty::donePty()
111{ 111{
112 // This is code from the Qt DumbTerminal example 112 // This is code from the Qt DumbTerminal example
113 int status = 0; 113 int status = 0;
114 114
115 ::close(m_fd); 115 ::close(m_fd);
116 116
117 if (m_cpid) { 117 if (m_cpid) {
118 kill(m_cpid, SIGHUP); 118 kill(m_cpid, SIGHUP);
119 //waitpid(m_cpid, &status, 0); 119 //waitpid(m_cpid, &status, 0);
120 delete m_sn_e; 120 delete m_sn_e;
121 delete m_sn_r; 121 delete m_sn_r;
122 m_sn_e = 0l; 122 m_sn_e = 0l;
123 m_sn_r = 0l; 123 m_sn_r = 0l;
124 } 124 }
125 125
126 m_cpid = 0; 126 m_cpid = 0;
127 m_fd = -1; 127 m_fd = -1;
128// emit done(status); 128// emit done(status);
129} 129}
130 130
131 131
132const char* MyPty::deviceName() 132const char* MyPty::deviceName()
133{ 133{
134 return m_ttynam; 134 return m_ttynam;
135} 135}
136 136
137 137
138void MyPty::error() 138void MyPty::error()
139{ 139{
140 // This is code from the Qt DumbTerminal example 140 // This is code from the Qt DumbTerminal example
141 donePty(); 141 donePty();
142} 142}
143 143
144void MyPty::start() { 144void MyPty::start() {
145 char* cmd = "/bin/sh"; 145 char* cmd = "/bin/sh";
146 QStrList lis; 146 QStrList lis;
147 int r =run(cmd, lis, 0, 0); 147 int r =run(cmd, lis, 0, 0);
148 r = r; 148 r = r;
149} 149}
150/*! 150/*!
151 start the client program. 151 start the client program.
152*/ 152*/
153int MyPty::run(const char* cmd, QStrList &, const char*, int) 153int MyPty::run(const char* cmd, QStrList &, const char*, int)
154{ 154{
155 // This is code from the Qt DumbTerminal example 155 // This is code from the Qt DumbTerminal example
156 m_cpid = fork(); 156 m_cpid = fork();
157 157
158 if ( !m_cpid ) { 158 if ( !m_cpid ) {
159 // child - exec shell on tty 159 // child - exec shell on tty
160 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); 160 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
161 int ttyfd = ::open(m_ttynam, O_RDWR); 161 int ttyfd = ::open(m_ttynam, O_RDWR);
162 dup2(ttyfd, STDIN_FILENO); 162 dup2(ttyfd, STDIN_FILENO);
163 dup2(ttyfd, STDOUT_FILENO); 163 dup2(ttyfd, STDOUT_FILENO);
164 dup2(ttyfd, STDERR_FILENO); 164 dup2(ttyfd, STDERR_FILENO);
165 // should be done with tty, so close it 165 // should be done with tty, so close it
166 ::close(ttyfd); 166 ::close(ttyfd);
167 static struct termios ttmode; 167 static struct termios ttmode;
168 if ( setsid() < 0 ) 168 if ( setsid() < 0 )
169 perror( "failed to set process group" ); 169 perror( "failed to set process group" );
170#if defined (TIOCSCTTY) 170#if defined (TIOCSCTTY)
171 // grabbed from APUE by Stevens 171 // grabbed from APUE by Stevens
172 ioctl(STDIN_FILENO, TIOCSCTTY, 0); 172 ioctl(STDIN_FILENO, TIOCSCTTY, 0);
173#endif 173#endif
174 tcgetattr( STDIN_FILENO, &ttmode ); 174 tcgetattr( STDIN_FILENO, &ttmode );
175 ttmode.c_cc[VINTR] = 3; 175 ttmode.c_cc[VINTR] = 3;
176 ttmode.c_cc[VERASE] = 8; 176 ttmode.c_cc[VERASE] = 8;
177 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); 177 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
178 setenv("TERM","vt100",1); 178 setenv("TERM",m_term,1);
179 setenv("COLORTERM","0",1); 179 setenv("COLORTERM","0",1);
180 180
181 if (getuid() == 0) { 181 if (getuid() == 0) {
182 char msg[] = "WARNING: You are running this shell as root!\n"; 182 char msg[] = "WARNING: You are running this shell as root!\n";
183 write(ttyfd, msg, sizeof(msg)); 183 write(ttyfd, msg, sizeof(msg));
184 } 184 }
185 execl(cmd, cmd, 0); 185 execl(cmd, cmd, 0);
186 186
187 donePty(); 187 donePty();
188 exit(-1); 188 exit(-1);
189 } 189 }
190 190
191 // parent - continue as a widget 191 // parent - continue as a widget
192 delete m_sn_r; 192 delete m_sn_r;
193 m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); 193 m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this);
194 delete m_sn_e; 194 delete m_sn_e;
195 m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); 195 m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this);
196 connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); 196 connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
197 connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); 197 connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error()));
198 198
199 return 0; 199 return 0;
200} 200}
201 201
202int MyPty::openPty() 202int MyPty::openPty()
203{ 203{
204 // This is code from the Qt DumbTerminal example 204 // This is code from the Qt DumbTerminal example
205 int ptyfd = -1; 205 int ptyfd = -1;
206 206
207#ifdef HAVE_OPENPTY 207#ifdef HAVE_OPENPTY
208 int ttyfd; 208 int ttyfd;
209 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) 209 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) )
210 ptyfd = -1; 210 ptyfd = -1;
211 else 211 else
212 close(ttyfd); // we open the ttynam ourselves. 212 close(ttyfd); // we open the ttynam ourselves.
213#else 213#else
214 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { 214 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) {
215 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { 215 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) {
216 sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); 216 sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1);
217 sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); 217 sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1);
218 if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { 218 if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) {
219 if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { 219 if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) {
220 ::close(ptyfd); 220 ::close(ptyfd);
221 ptyfd = -1; 221 ptyfd = -1;
222 } 222 }
223 } 223 }
224 } 224 }
225 } 225 }
226#endif 226#endif
227 227
228 if ( ptyfd < 0 ) { 228 if ( ptyfd < 0 ) {
229 //qApp->exit(1); 229 //qApp->exit(1);
230 return -1; 230 return -1;
231 } 231 }
232 232
233 return ptyfd; 233 return ptyfd;
234} 234}
235 235
236/*! 236/*!
237 Create an instance. 237 Create an instance.
238*/ 238*/
239MyPty::MyPty(const Profile&) : m_cpid(0) 239MyPty::MyPty(const Profile& prof) : m_cpid(0)
240{ 240{
241
242 int term = prof.readNumEntry("Terminal", Profile::VT100 );
243 switch( term ) {
244 default:
245 case Profile::VT100:
246 case Profile::VT102:
247 m_term = "vt100";
248 break;
249 case Profile::Linux:
250 m_term = "linux";
251 break;
252 case Profile::XTerm:
253 m_term = "xterm";
254 break;
255 }
241 m_sn_e = 0l; 256 m_sn_e = 0l;
242 m_sn_r = 0l; 257 m_sn_r = 0l;
243 m_fd = openPty(); 258 m_fd = openPty();
244 ProcCtl* ctl = ProcCtl::self(); 259 ProcCtl* ctl = ProcCtl::self();
245} 260}
246 261
247/*! 262/*!
248 Destructor. 263 Destructor.
249 Note that the related client program is not killed 264 Note that the related client program is not killed
250 (yet) when a instance is deleted. 265 (yet) when a instance is deleted.
251*/ 266*/
252MyPty::~MyPty() 267MyPty::~MyPty()
253{ 268{
254 donePty(); 269 donePty();
255} 270}
256QString MyPty::identifier()const { 271QString MyPty::identifier()const {
257 return QString::fromLatin1("term"); 272 return QString::fromLatin1("term");
258} 273}
259QString MyPty::name()const{ 274QString MyPty::name()const{
260 return identifier(); 275 return identifier();
261} 276}
262bool MyPty::open() { 277bool MyPty::open() {
263 if (m_fd < 0) 278 if (m_fd < 0)
264 m_fd = openPty(); 279 m_fd = openPty();
265 280
266 start(); 281 start();
267 return true; 282 return true;
268} 283}
269void MyPty::close() { 284void MyPty::close() {
270 donePty(); 285 donePty();
271 m_fd = openPty(); 286 m_fd = openPty();
272} 287}
273void MyPty::reload( const Profile& ) { 288void MyPty::reload( const Profile& ) {
274 289
275} 290}
276/*! sends len bytes through the line */ 291/*! sends len bytes through the line */
277void MyPty::send(const QByteArray& ar) 292void MyPty::send(const QByteArray& ar)
278{ 293{
279#ifdef VERBOSE_DEBUG 294#ifdef VERBOSE_DEBUG
280 // verbose debug 295 // verbose debug
281 printf("sending bytes:\n"); 296 printf("sending bytes:\n");
282 for (uint i = 0; i < ar.count(); i++) 297 for (uint i = 0; i < ar.count(); i++)
283 printf("%c", ar[i]); 298 printf("%c", ar[i]);
284 printf("\n"); 299 printf("\n");
285#endif 300#endif
286 301
287 ::write(m_fd, ar.data(), ar.count()); 302 ::write(m_fd, ar.data(), ar.count());
288} 303}
289 304
290/*! indicates that a block of data is received */ 305/*! indicates that a block of data is received */
291void MyPty::readPty() 306void MyPty::readPty()
292{ 307{
293 QByteArray buf(4096); 308 QByteArray buf(4096);
294 309
295 int len = ::read( m_fd, buf.data(), 4096 ); 310 int len = ::read( m_fd, buf.data(), 4096 );
296 311
297 if (len == -1 || len == 0) { 312 if (len == -1 || len == 0) {
298 donePty(); 313 donePty();
299 return; 314 return;
300 } 315 }
301 316
302 if (len < 0) 317 if (len < 0)
303 return; 318 return;
304 319
305 320
306 buf.resize(len); 321 buf.resize(len);
307 emit received(buf); 322 emit received(buf);
308 323
309#ifdef VERBOSE_DEBUG 324#ifdef VERBOSE_DEBUG
310 // verbose debug 325 // verbose debug
311 printf("read bytes:\n"); 326 printf("read bytes:\n");
312 for (uint i = 0; i < buf.count(); i++) 327 for (uint i = 0; i < buf.count(); i++)
313 printf("%c", buf[i]); 328 printf("%c", buf[i]);
314 printf("\n"); 329 printf("\n");
315#endif 330#endif
316 331
317} 332}
318QBitArray MyPty::supports()const { 333QBitArray MyPty::supports()const {
319 QBitArray ar(3); 334 QBitArray ar(3);
320 //autoconnect 335 //autoconnect
321 ar[0] = 1; 336 ar[0] = 1;
322 // 337 //
323 ar[1] = 0; 338 ar[1] = 0;
324 ar[2] = 0; 339 ar[2] = 0;
325 340
326 return ar; 341 return ar;
327} 342}
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
@@ -1,99 +1,100 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [MyPty.h] Pseudo Terminal Device */ 3/* [MyPty.h] Pseudo Terminal Device */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12 /* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14 /* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16 /* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19/*! \file 19/*! \file
20*/ 20*/
21 21
22#ifndef MY_PTY_H 22#ifndef MY_PTY_H
23#define MY_PTY_H 23#define MY_PTY_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstrlist.h> 26#include <qstrlist.h>
27 27
28#include "io_layer.h" 28#include "io_layer.h"
29 29
30class Profile; 30class Profile;
31class QSocketNotifier; 31class QSocketNotifier;
32class MyPty : public IOLayer 32class MyPty : public IOLayer
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 36
37 MyPty(const Profile&); 37 MyPty(const Profile&);
38 ~MyPty(); 38 ~MyPty();
39 39
40 40
41 41
42 QString identifier()const; 42 QString identifier()const;
43 QString name()const; 43 QString name()const;
44 QBitArray supports()const; 44 QBitArray supports()const;
45 45
46 public slots: 46 public slots:
47 /*! 47 /*!
48 having a `run' separate from the constructor allows to make 48 having a `run' separate from the constructor allows to make
49 the necessary connections to the signals and slots of the 49 the necessary connections to the signals and slots of the
50 instance before starting the execution of the client. 50 instance before starting the execution of the client.
51 */ 51 */
52 void start(); 52 void start();
53 int run(const char* pgm, QStrList & args , const char* term, int addutmp); 53 int run(const char* pgm, QStrList & args , const char* term, int addutmp);
54 bool open(); 54 bool open();
55 void close(); 55 void close();
56 void reload( const Profile& ); 56 void reload( const Profile& );
57 void setSize(int lines, int columns); 57 void setSize(int lines, int columns);
58 void error(); 58 void error();
59 bool isConnected() { return true; }; 59 bool isConnected() { return true; };
60 signals: 60 signals:
61 61
62 /*! 62 /*!
63 emitted when the client program terminates. 63 emitted when the client program terminates.
64 \param status the wait(2) status code of the terminated client program. 64 \param status the wait(2) status code of the terminated client program.
65 */ 65 */
66 void done(int status); 66 void done(int status);
67 67
68 /*! 68 /*!
69 emitted when a new block of data comes in. 69 emitted when a new block of data comes in.
70 \param s - the data 70 \param s - the data
71 \param len - the length of the block 71 \param len - the length of the block
72 */ 72 */
73 void received(const QByteArray&); 73 void received(const QByteArray&);
74 74
75 public slots: 75 public slots:
76 76
77 void send(const QByteArray& ); 77 void send(const QByteArray& );
78 78
79private: 79private:
80 const char* deviceName(); 80 const char* deviceName();
81 81
82protected slots: 82protected slots:
83 void readPty(); 83 void readPty();
84 void donePty(); 84 void donePty();
85 85
86private: 86private:
87 int openPty(); 87 int openPty();
88 88
89private: 89private:
90 90
91 char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" 91 char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx"
92 char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." 92 char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..."
93 int m_fd; 93 int m_fd;
94 int m_cpid; 94 int m_cpid;
95 QSocketNotifier* m_sn_e; 95 QSocketNotifier* m_sn_e;
96 QSocketNotifier* m_sn_r; 96 QSocketNotifier* m_sn_r;
97 char* m_term;
97}; 98};
98 99
99#endif 100#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
@@ -1,138 +1,153 @@
1#include <qwidget.h> 1#include <qwidget.h>
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3 3
4#include "TEWidget.h" 4#include "TEWidget.h"
5#include "TEmuVt102.h" 5#include "TEmuVt102.h"
6 6
7#include "profile.h" 7#include "profile.h"
8#include "emulation_handler.h" 8#include "emulation_handler.h"
9#include "script.h" 9#include "script.h"
10 10
11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
12 : QObject(0, name ) 12 : QObject(0, name )
13{ 13{
14 m_teWid = new TEWidget( parent, "TerminalMain"); 14 m_teWid = new TEWidget( parent, "TerminalMain");
15 m_teWid->setMinimumSize(150, 70 ); 15 m_teWid->setMinimumSize(150, 70 );
16 m_script = 0; 16 m_script = 0;
17 parent->resize( m_teWid->calcSize(80, 24 ) ); 17 parent->resize( m_teWid->calcSize(80, 24 ) );
18 m_teEmu = new TEmuVt102(m_teWid ); 18 m_teEmu = new TEmuVt102(m_teWid );
19 19
20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
21 this, SIGNAL(changeSize(int, int) ) ); 21 this, SIGNAL(changeSize(int, int) ) );
22 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 22 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
23 this, SLOT(recvEmulation(const char*, int) ) ); 23 this, SLOT(recvEmulation(const char*, int) ) );
24 m_teEmu->setConnect( true ); 24 m_teEmu->setConnect( true );
25 m_teEmu->setHistory( TRUE ); 25 m_teEmu->setHistory( TRUE );
26 load( prof ); 26 load( prof );
27 27
28 28
29 29
30} 30}
31EmulationHandler::~EmulationHandler() { 31EmulationHandler::~EmulationHandler() {
32 if (isRecording()) 32 if (isRecording())
33 clearScript(); 33 clearScript();
34 delete m_teEmu; 34 delete m_teEmu;
35 delete m_teWid; 35 delete m_teWid;
36} 36}
37 37
38void EmulationHandler::load( const Profile& prof) { 38void EmulationHandler::load( const Profile& prof) {
39 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 39 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
40 int num = prof.readNumEntry("Color"); 40 int num = prof.readNumEntry("Color");
41 setColor( foreColor(num), backColor(num) ); 41 setColor( foreColor(num), backColor(num) );
42 m_teWid->setBackgroundColor(backColor(num) ); 42 m_teWid->setBackgroundColor(backColor(num) );
43
44 int term = prof.readNumEntry("Terminal", 0) ;
45 switch(term) {
46 default:
47 case Profile::VT102:
48 case Profile::VT100:
49 m_teEmu->setKeytrans("vt100.keytab");
50 break;
51 case Profile::Linux:
52 m_teEmu->setKeytrans("linux.keytab");
53 break;
54 case Profile::XTerm:
55 m_teEmu->setKeytrans("default.Keytab");
56 break;
57 }
43} 58}
44void EmulationHandler::recv( const QByteArray& ar) { 59void EmulationHandler::recv( const QByteArray& ar) {
45 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 60 m_teEmu->onRcvBlock(ar.data(), ar.count() );
46} 61}
47void EmulationHandler::recvEmulation(const char* src, int len ) { 62void EmulationHandler::recvEmulation(const char* src, int len ) {
48 QByteArray ar(len); 63 QByteArray ar(len);
49 64
50 memcpy(ar.data(), src, sizeof(char) * len ); 65 memcpy(ar.data(), src, sizeof(char) * len );
51 66
52 if (isRecording()) 67 if (isRecording())
53 m_script->append(ar); 68 m_script->append(ar);
54 emit send(ar); 69 emit send(ar);
55} 70}
56QWidget* EmulationHandler::widget() { 71QWidget* EmulationHandler::widget() {
57 return m_teWid; 72 return m_teWid;
58} 73}
59/* 74/*
60 * allocate a new table of colors 75 * allocate a new table of colors
61 */ 76 */
62void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 77void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
63 ColorEntry table[TABLE_COLORS]; 78 ColorEntry table[TABLE_COLORS];
64 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 79 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
65 80
66 for (int i = 0; i < TABLE_COLORS; i++ ) { 81 for (int i = 0; i < TABLE_COLORS; i++ ) {
67 if ( i == 0 || i == 10 ) { 82 if ( i == 0 || i == 10 ) {
68 table[i].color = fore; 83 table[i].color = fore;
69 }else if ( i == 1 || i == 11 ) { 84 }else if ( i == 1 || i == 11 ) {
70 table[i].color = back; 85 table[i].color = back;
71 table[i].transparent = 0; 86 table[i].transparent = 0;
72 }else { 87 }else {
73 table[i].color = defaultCt[i].color; 88 table[i].color = defaultCt[i].color;
74 } 89 }
75 } 90 }
76 m_teWid->setColorTable(table ); 91 m_teWid->setColorTable(table );
77 m_teWid->update(); 92 m_teWid->update();
78} 93}
79QFont EmulationHandler::font( int id ) { 94QFont EmulationHandler::font( int id ) {
80 QString name; 95 QString name;
81 int size = 0; 96 int size = 0;
82 switch(id ) { 97 switch(id ) {
83 default: // fall through 98 default: // fall through
84 case 0: 99 case 0:
85 name = QString::fromLatin1("Micro"); 100 name = QString::fromLatin1("Micro");
86 size = 4; 101 size = 4;
87 break; 102 break;
88 case 1: 103 case 1:
89 name = QString::fromLatin1("Fixed"); 104 name = QString::fromLatin1("Fixed");
90 size = 7; 105 size = 7;
91 break; 106 break;
92 case 2: 107 case 2:
93 name = QString::fromLatin1("Fixed"); 108 name = QString::fromLatin1("Fixed");
94 size = 12; 109 size = 12;
95 break; 110 break;
96 } 111 }
97 QFont font(name, size, QFont::Normal ); 112 QFont font(name, size, QFont::Normal );
98 font.setFixedPitch(TRUE ); 113 font.setFixedPitch(TRUE );
99 return font; 114 return font;
100} 115}
101QColor EmulationHandler::foreColor(int col) { 116QColor EmulationHandler::foreColor(int col) {
102 QColor co; 117 QColor co;
103 /* we need to switch it */ 118 /* we need to switch it */
104 switch( col ) { 119 switch( col ) {
105 default: 120 default:
106 case Profile::White: 121 case Profile::White:
107 /* color is black */ 122 /* color is black */
108 co = Qt::white; 123 co = Qt::white;
109 break; 124 break;
110 case Profile::Black: 125 case Profile::Black:
111 co = Qt::black; 126 co = Qt::black;
112 break; 127 break;
113 case Profile::Green: 128 case Profile::Green:
114 qWarning("Foreground green"); 129 qWarning("Foreground green");
115 co = Qt::green; 130 co = Qt::green;
116 break; 131 break;
117 case Profile::Orange: 132 case Profile::Orange:
118 qWarning("Foreground orange"); 133 qWarning("Foreground orange");
119 // FIXME needs better color here 134 // FIXME needs better color here
120 co = Qt::darkYellow; 135 co = Qt::darkYellow;
121 break; 136 break;
122 } 137 }
123 138
124 return co; 139 return co;
125} 140}
126QColor EmulationHandler::backColor(int col ) { 141QColor EmulationHandler::backColor(int col ) {
127 QColor co; 142 QColor co;
128 /* we need to switch it */ 143 /* we need to switch it */
129 switch( col ) { 144 switch( col ) {
130 default: 145 default:
131 case Profile::White: 146 case Profile::White:
132 /* color is white */ 147 /* color is white */
133 co = Qt::black; 148 co = Qt::black;
134 break; 149 break;
135 case Profile::Black: 150 case Profile::Black:
136 co = Qt::white; 151 co = Qt::white;
137 break; 152 break;
138 case Profile::Green: 153 case Profile::Green:
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
@@ -1,250 +1,251 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <errno.h> 3#include <errno.h>
4#include <fcntl.h> 4#include <fcntl.h>
5#include <unistd.h> 5#include <unistd.h>
6 6
7#include <qcstring.h> 7#include <qcstring.h>
8#include <qsocketnotifier.h> 8#include <qsocketnotifier.h>
9 9
10#include <opie/oprocess.h> 10#include <opie/oprocess.h>
11 11
12#include "procctl.h" 12#include "procctl.h"
13#include "filetransfer.h" 13#include "filetransfer.h"
14 14
15 15
16FileTransfer::FileTransfer( Type t, IOLayer* lay ) 16FileTransfer::FileTransfer( Type t, IOLayer* lay )
17 : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { 17 : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) {
18 signal(SIGPIPE, SIG_IGN ); 18 signal(SIGPIPE, SIG_IGN );
19 19
20 m_pid = 0; 20 m_pid = 0;
21 m_not = 0l; 21 m_not = 0l;
22 m_proc = 0l; 22 m_proc = 0l;
23} 23}
24FileTransfer::~FileTransfer() { 24FileTransfer::~FileTransfer() {
25} 25}
26 26
27/** 27/**
28 * now we will send the file. 28 * now we will send the file.
29 * 29 *
30 * we request an fd. The IOLayer should be closed 30 * we request an fd. The IOLayer should be closed
31 * then we will setup a pipe for progress communication 31 * then we will setup a pipe for progress communication
32 * then we will dup2 the m_fd in the forked process 32 * then we will dup2 the m_fd in the forked process
33 * to do direct IO from and to the fd 33 * to do direct IO from and to the fd
34 */ 34 */
35void FileTransfer::sendFile( const QString& file ) { 35void FileTransfer::sendFile( const QString& file ) {
36 m_prog =-1; 36 m_prog =-1;
37 m_fd = layer()->rawIO(); 37 m_fd = layer()->rawIO();
38// 38//
39// m_fd = ::open("/dev/ttyS0", O_RDWR); 39// m_fd = ::open("/dev/ttyS0", O_RDWR);
40 40
41 m_file = file; 41 m_file = file;
42 if ( pipe( m_comm ) < 0 ) 42 if ( pipe( m_comm ) < 0 )
43 m_comm[0] = m_comm[1] = 0; 43 m_comm[0] = m_comm[1] = 0;
44 if ( pipe( m_info ) < 0 ) 44 if ( pipe( m_info ) < 0 )
45 m_info[0] = m_info[1] = 0; 45 m_info[0] = m_info[1] = 0;
46 46
47 47
48 m_pid = fork(); 48 m_pid = fork();
49 switch( m_pid ) { 49 switch( m_pid ) {
50 case -1: 50 case -1:
51 emit error( StartError, tr("Was not able to fork") ); 51 emit error( StartError, tr("Was not able to fork") );
52 slotExec(); 52 slotExec();
53 break; 53 break;
54 case 0:{ 54 case 0:{
55 setupChild(); 55 setupChild();
56 /* exec */ 56 /* exec */
57 char* verbose = "-vv"; 57 char* verbose = "-vv";
58 char* binray = "-b"; 58 char* binray = "-b";
59 59
60 60
61 char* typus; 61 char* typus;
62 switch(m_type ) { 62 switch(m_type ) {
63 default:
63 case SZ: 64 case SZ:
64 typus = ""; 65 typus = "";
65 break; 66 break;
66 case SX: 67 case SX:
67 typus = "-X"; 68 typus = "-X";
68 break; 69 break;
69 case SY: 70 case SY:
70 typus = "--ymodem"; 71 typus = "--ymodem";
71 break; 72 break;
72 } 73 }
73 74
74 /* we should never return from here */ 75 /* we should never return from here */
75 execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); 76 execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL );
76 77
77 /* communication for error!*/ 78 /* communication for error!*/
78 char resultByte =1; 79 char resultByte =1;
79 if (m_info[1] ) 80 if (m_info[1] )
80 write(m_info[1], &resultByte, 1 ); 81 write(m_info[1], &resultByte, 1 );
81 _exit( -1 ); 82 _exit( -1 );
82 break; 83 break;
83 } 84 }
84 default:{ 85 default:{
85 if ( m_info[1] ) 86 if ( m_info[1] )
86 close( m_info[1] ); 87 close( m_info[1] );
87 if ( m_info[0] ) for (;;) { 88 if ( m_info[0] ) for (;;) {
88 char resultByte; int len; 89 char resultByte; int len;
89 len = read(m_info[0], &resultByte, 1 ); 90 len = read(m_info[0], &resultByte, 1 );
90 /* len == 1 start up failed */ 91 /* len == 1 start up failed */
91 if ( len == 1 ) { 92 if ( len == 1 ) {
92 emit error( StartError, tr("Could not start") ); 93 emit error( StartError, tr("Could not start") );
93 return; 94 return;
94 } 95 }
95 if ( len == -1 ) 96 if ( len == -1 )
96 if ( (errno == ECHILD ) || (errno == EINTR ) ) 97 if ( (errno == ECHILD ) || (errno == EINTR ) )
97 continue; 98 continue;
98 99
99 // len == 0 or something like this 100 // len == 0 or something like this
100 break; 101 break;
101 } 102 }
102 if ( m_info[0] ) 103 if ( m_info[0] )
103 close( m_info[0] ); 104 close( m_info[0] );
104 105
105 106
106 107
107 /* replace by QSocketNotifier!!! */ 108 /* replace by QSocketNotifier!!! */
108 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); 109 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read );
109 connect(m_not, SIGNAL(activated(int) ), 110 connect(m_not, SIGNAL(activated(int) ),
110 this, SLOT(slotRead() ) ); 111 this, SLOT(slotRead() ) );
111 if ( pipe(m_term) < 0 ) 112 if ( pipe(m_term) < 0 )
112 m_term[0] = m_term[1] = 0; 113 m_term[0] = m_term[1] = 0;
113 114
114 ProcCtl::self()->add(m_pid, m_term[1] ); 115 ProcCtl::self()->add(m_pid, m_term[1] );
115 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); 116 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read );
116 connect(m_proc, SIGNAL(activated(int) ), 117 connect(m_proc, SIGNAL(activated(int) ),
117 this, SLOT(slotExec() ) ); 118 this, SLOT(slotExec() ) );
118 119
119 } 120 }
120 break; 121 break;
121 } 122 }
122} 123}
123/* 124/*
124 * let's call the one with the filename 125 * let's call the one with the filename
125 */ 126 */
126void FileTransfer::sendFile( const QFile& file ) { 127void FileTransfer::sendFile( const QFile& file ) {
127 sendFile( file.name() ); 128 sendFile( file.name() );
128} 129}
129 130
130/* 131/*
131 * setting up communication 132 * setting up communication
132 * between parent child and ioLayer 133 * between parent child and ioLayer
133 */ 134 */
134void FileTransfer::setupChild() { 135void FileTransfer::setupChild() {
135 /* 136 /*
136 * we do not want to read from our 137 * we do not want to read from our
137 * information channel 138 * information channel
138 */ 139 */
139 if (m_info[0] ) 140 if (m_info[0] )
140 close(m_info[0] ); 141 close(m_info[0] );
141 /* 142 /*
142 * FD_CLOEXEC will close the 143 * FD_CLOEXEC will close the
143 * fd on successfull exec 144 * fd on successfull exec
144 */ 145 */
145 if (m_info[1] ) 146 if (m_info[1] )
146 fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); 147 fcntl(m_info[1], F_SETFD, FD_CLOEXEC );
147 148
148 if (m_comm[0] ) 149 if (m_comm[0] )
149 close( m_comm[0] ); 150 close( m_comm[0] );
150 /* 151 /*
151 * now set the communication 152 * now set the communication
152 * m_fd STDIN_FILENO 153 * m_fd STDIN_FILENO
153 * STDOUT_FILENO 154 * STDOUT_FILENO
154 * STDERR_FILENO 155 * STDERR_FILENO
155 */ 156 */
156 dup2( m_fd, STDIN_FILENO ); 157 dup2( m_fd, STDIN_FILENO );
157 dup2( m_fd, STDOUT_FILENO ); 158 dup2( m_fd, STDOUT_FILENO );
158 dup2( m_comm[1], STDERR_FILENO ); 159 dup2( m_comm[1], STDERR_FILENO );
159} 160}
160 161
161/* 162/*
162 * read from the stderr of the child 163 * read from the stderr of the child
163 * process 164 * process
164 */ 165 */
165void FileTransfer::slotRead() { 166void FileTransfer::slotRead() {
166 QByteArray ar(4096); 167 QByteArray ar(4096);
167 int len = read(m_comm[0], ar.data(), 4096 ); 168 int len = read(m_comm[0], ar.data(), 4096 );
168 for (int i = 0; i < len; i++ ) { 169 for (int i = 0; i < len; i++ ) {
169 // printf("%c", ar[i] ); 170 // printf("%c", ar[i] );
170 } 171 }
171 ar.resize( len ); 172 ar.resize( len );
172 QString str( ar ); 173 QString str( ar );
173 QStringList lis = QStringList::split(' ', str ); 174 QStringList lis = QStringList::split(' ', str );
174 /* 175 /*
175 * Transfer finished.. either complete or incomplete 176 * Transfer finished.. either complete or incomplete
176 */ 177 */
177 if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { 178 if ( lis[0].simplifyWhiteSpace() == "Transfer" ) {
178 return; 179 return;
179 } 180 }
180 /* 181 /*
181 * do progress reading 182 * do progress reading
182 */ 183 */
183 slotProgress( lis ); 184 slotProgress( lis );
184 185
185 186
186} 187}
187/* 188/*
188 * find the progress 189 * find the progress
189 */ 190 */
190void FileTransfer::slotProgress( const QStringList& list ) { 191void FileTransfer::slotProgress( const QStringList& list ) {
191 if ( m_type != SZ ) 192 if ( m_type != SZ )
192 return; 193 return;
193 bool complete = true; 194 bool complete = true;
194 int min, sec; 195 int min, sec;
195 int bps; 196 int bps;
196 unsigned long sent, total; 197 unsigned long sent, total;
197 198
198 min = sec = bps = -1; 199 min = sec = bps = -1;
199 sent = total = 0; 200 sent = total = 0;
200 201
201 // Data looks like this 202 // Data looks like this
202 // 0 1 2 3 4 5 203 // 0 1 2 3 4 5
203 // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 204 // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33
204 QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); 205 QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() );
205 sent = progi[0].toULong(&complete ); 206 sent = progi[0].toULong(&complete );
206 if (!complete ) return; 207 if (!complete ) return;
207 208
208 total = progi[1].toULong(&complete ); 209 total = progi[1].toULong(&complete );
209 if (!complete || total == 0) { 210 if (!complete || total == 0) {
210 return; 211 return;
211 } 212 }
212 213
213 214
214 double pro = (double)sent/total; 215 double pro = (double)sent/total;
215 int prog = pro * 100; 216 int prog = pro * 100;
216 217
217 // speed 218 // speed
218 progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); 219 progi = QStringList::split(':', list[3].simplifyWhiteSpace() );
219 bps = progi[1].toInt(); 220 bps = progi[1].toInt();
220 221
221 // time 222 // time
222 progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); 223 progi = QStringList::split(':', list[5].simplifyWhiteSpace() );
223 min = progi[0].toInt(); 224 min = progi[0].toInt();
224 sec = progi[1].toInt(); 225 sec = progi[1].toInt();
225 226
226 227
227 if ( prog > m_prog ) { 228 if ( prog > m_prog ) {
228 m_prog = prog; 229 m_prog = prog;
229 emit progress(m_file, m_prog, bps, -1, min , sec ); 230 emit progress(m_file, m_prog, bps, -1, min , sec );
230 } 231 }
231 232
232} 233}
233void FileTransfer::cancel() { 234void FileTransfer::cancel() {
234 if(m_pid > 0) ::kill(m_pid,9 ); 235 if(m_pid > 0) ::kill(m_pid,9 );
235 236
236} 237}
237void FileTransfer::slotExec() { 238void FileTransfer::slotExec() {
238 char buf[2]; 239 char buf[2];
239 ::read(m_term[0], buf, 1 ); 240 ::read(m_term[0], buf, 1 );
240 delete m_proc; 241 delete m_proc;
241 delete m_not; 242 delete m_not;
242 m_proc = m_not = 0l; 243 m_proc = m_not = 0l;
243 close( m_term[0] ); 244 close( m_term[0] );
244 close( m_term[1] ); 245 close( m_term[1] );
245 close( m_comm[0] ); 246 close( m_comm[0] );
246 close( m_comm[1] ); 247 close( m_comm[1] );
247 layer()->closeRawIO( m_fd ); 248 layer()->closeRawIO( m_fd );
248 emit sent(); 249 emit sent();
249 m_pid = 0; 250 m_pid = 0;
250} 251}
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
@@ -1,54 +1,48 @@
1#ifndef OPIE_FILE_TRANSFER_H 1#ifndef OPIE_FILE_TRANSFER_H
2#define OPIE_FILE_TRANSFER_H 2#define OPIE_FILE_TRANSFER_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5 5
6#include <qfile.h> 6#include <qfile.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9#include "file_layer.h" 9#include "file_layer.h"
10 10
11class QSocketNotifier; 11class QSocketNotifier;
12class OProcess; 12class OProcess;
13class FileTransferControl; 13class FileTransferControl;
14class FileTransfer : public FileTransferLayer{ 14class FileTransfer : public FileTransferLayer{
15 Q_OBJECT 15 Q_OBJECT
16 friend class FileTransferControl; 16 friend class FileTransferControl;
17public: 17public:
18 enum Type { 18 enum Type {
19 SZ = 0, 19 SZ = 0,
20 SX, 20 SX,
21 SY 21 SY
22 }; 22 };
23 FileTransfer( Type t, IOLayer* ); 23 FileTransfer( Type t, IOLayer* );
24 ~FileTransfer(); 24 ~FileTransfer();
25 25
26 void sendFile( const QString& file ); 26 void sendFile( const QString& file );
27 void sendFile( const QFile& ); 27 void sendFile( const QFile& );
28 void cancel(); 28 void cancel();
29 29
30private slots: 30private slots:
31 void setupChild(); 31 void setupChild();
32 void slotRead(); 32 void slotRead();
33 void slotProgress( const QStringList& ); 33 void slotProgress( const QStringList& );
34 void slotExec(); 34 void slotExec();
35private: 35private:
36 /* 36 Type m_type;
37 * FIXME? What does happen if we've
38 * two FileTransfers at a time?
39 * Have a procctl which does listen
40 * for termination and then send a signal
41 */
42 pid_t m_pid; 37 pid_t m_pid;
43 int m_fd; 38 int m_fd;
44 int m_prog; 39 int m_prog;
45 int m_info[2]; 40 int m_info[2];
46 int m_comm[2]; 41 int m_comm[2];
47 int m_term[2]; 42 int m_term[2];
48 QString m_file; 43 QString m_file;
49 Type m_type;
50 QSocketNotifier *m_not; 44 QSocketNotifier *m_not;
51 QSocketNotifier* m_proc; 45 QSocketNotifier* m_proc;
52}; 46};
53 47
54#endif 48#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,76 +1,79 @@
1#ifndef OPIE_PROFILE_H 1#ifndef OPIE_PROFILE_H
2#define OPIE_PROFILE_H 2#define OPIE_PROFILE_H
3 3
4#include <qmap.h> 4#include <qmap.h>
5#include <qstring.h> 5#include <qstring.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7#include <qvaluelist.h> 7#include <qvaluelist.h>
8/** 8/**
9 * A session will be generated from a saved 9 * A session will be generated from a saved
10 * profile. A profile contains the iolayername 10 * profile. A profile contains the iolayername
11 * a name. 11 * a name.
12 * We can generate a Session from a Profile 12 * We can generate a Session from a Profile
13 * Configuration is contained here too 13 * Configuration is contained here too
14 */ 14 */
15class Profile { 15class Profile {
16public: 16public:
17 typedef QValueList<Profile> ValueList; 17 typedef QValueList<Profile> ValueList;
18 enum Color { Black = 0, 18 enum Color { Black = 0,
19 White, 19 White,
20 Gray, 20 Gray,
21 Green, 21 Green,
22 Orange}; 22 Orange};
23 enum Terminal {VT102 = 0, VT100 }; 23 enum Terminal {VT102 = 0, VT100,
24 Ansi,
25 Linux,
26 XTerm };
24 enum Font { Micro = 0, Small, Medium }; 27 enum Font { Micro = 0, Small, Medium };
25 Profile(); 28 Profile();
26 Profile( const QString& name, 29 Profile( const QString& name,
27 const QCString& iolayerName, 30 const QCString& iolayerName,
28 const QCString& termName, 31 const QCString& termName,
29 int background, 32 int background,
30 int foreground, 33 int foreground,
31 int terminal); 34 int terminal);
32 Profile( const Profile& ); 35 Profile( const Profile& );
33 Profile &operator=( const Profile& ); 36 Profile &operator=( const Profile& );
34 bool operator==( const Profile& prof ); 37 bool operator==( const Profile& prof );
35 38
36 ~Profile(); 39 ~Profile();
37 QString name()const; 40 QString name()const;
38 QCString ioLayerName()const; 41 QCString ioLayerName()const;
39 QCString terminalName()const; 42 QCString terminalName()const;
40 bool autoConnect()const; 43 bool autoConnect()const;
41 int foreground()const; 44 int foreground()const;
42 int background()const; 45 int background()const;
43 int terminal()const; 46 int terminal()const;
44 47
45 /* 48 /*
46 * config stuff 49 * config stuff
47 */ 50 */
48 QMap<QString, QString> conf()const; 51 QMap<QString, QString> conf()const;
49 void clearConf(); 52 void clearConf();
50 void writeEntry( const QString& key, const QString& value ); 53 void writeEntry( const QString& key, const QString& value );
51 void writeEntry( const QString& key, int num ); 54 void writeEntry( const QString& key, int num );
52 void writeEntry( const QString& key, bool b ); 55 void writeEntry( const QString& key, bool b );
53 void writeEntry( const QString& key, const QStringList&, const QChar& ); 56 void writeEntry( const QString& key, const QStringList&, const QChar& );
54 QString readEntry( const QString& key, const QString& deflt = QString::null)const; 57 QString readEntry( const QString& key, const QString& deflt = QString::null)const;
55 int readNumEntry( const QString& key, int = -1 )const; 58 int readNumEntry( const QString& key, int = -1 )const;
56 bool readBoolEntry( const QString& key, bool = FALSE )const; 59 bool readBoolEntry( const QString& key, bool = FALSE )const;
57 60
58 void setName( const QString& ); 61 void setName( const QString& );
59 void setIOLayer( const QCString& ); 62 void setIOLayer( const QCString& );
60 void setTerminalName( const QCString& ); 63 void setTerminalName( const QCString& );
61 void setAutoConnect( const bool ); 64 void setAutoConnect( const bool );
62 void setBackground( int back ); 65 void setBackground( int back );
63 void setForeground( int fore ); 66 void setForeground( int fore );
64 void setTerminal( int term ); 67 void setTerminal( int term );
65 void setConf( const QMap<QString, QString>& ); 68 void setConf( const QMap<QString, QString>& );
66private: 69private:
67 QMap<QString, QString> m_conf; 70 QMap<QString, QString> m_conf;
68 QString m_name; 71 QString m_name;
69 QCString m_ioLayer, m_term; 72 QCString m_ioLayer, m_term;
70 bool m_autoConnect; 73 bool m_autoConnect;
71 int m_back; 74 int m_back;
72 int m_fore; 75 int m_fore;
73 int m_terminal; 76 int m_terminal;
74}; 77};
75 78
76#endif 79#endif
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,210 +1,226 @@
1#include <qbuttongroup.h> 1#include <qbuttongroup.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qcombobox.h> 4#include <qcombobox.h>
5#include <qradiobutton.h> 5#include <qradiobutton.h>
6#include <qgroupbox.h> 6#include <qgroupbox.h>
7#include <qvbox.h> 7#include <qvbox.h>
8#include <qhgroupbox.h> 8#include <qhgroupbox.h>
9#include <qlayout.h> 9#include <qlayout.h>
10 10
11#include "terminalwidget.h" 11#include "terminalwidget.h"
12 12
13namespace { 13namespace {
14 enum TermIds { 14 enum TermIds {
15 id_term_vt100, 15 id_term_vt100 = 0,
16 id_term_vt102, 16 id_term_vt102,
17 id_term_ansi 17 id_term_linux,
18 id_term_xterm
18 }; 19 };
19 20
20 enum ColourIds { 21 enum ColourIds {
21 id_term_black, 22 id_term_black,
22 id_term_white, 23 id_term_white,
23 id_term_green, 24 id_term_green,
24 id_term_orange 25 id_term_orange
25 }; 26 };
26 27
27 enum FontIds { 28 enum FontIds {
28 id_size_small, 29 id_size_small,
29 id_size_medium, 30 id_size_medium,
30 id_size_large 31 id_size_large
31 }; 32 };
32}; 33};
33 34
34TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, 35TerminalWidget::TerminalWidget( const QString& name, QWidget* parent,
35 const char* na ) 36 const char* na )
36 : ProfileDialogTerminalWidget( name, parent, na ) { 37 : ProfileDialogTerminalWidget( name, parent, na ) {
37 38
38 m_terminal = new QLabel(tr("Terminal Type"), this ); 39 m_terminal = new QLabel(tr("Terminal Type"), this );
39 m_terminalBox = new QComboBox(this); 40 m_terminalBox = new QComboBox(this);
40 m_colorLabel = new QLabel(tr("Color scheme"), this); 41 m_colorLabel = new QLabel(tr("Color scheme"), this);
41 m_colorCmb = new QComboBox(this ); 42 m_colorCmb = new QComboBox(this );
42 43
43 m_groupSize = new QButtonGroup(tr("Font size"), this ); 44 m_groupSize = new QButtonGroup(tr("Font size"), this );
44 m_sizeSmall = new QRadioButton(tr("small"), m_groupSize ); 45 m_sizeSmall = new QRadioButton(tr("small"), m_groupSize );
45 m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize ); 46 m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize );
46 m_sizeLarge = new QRadioButton(tr("large"), m_groupSize ); 47 m_sizeLarge = new QRadioButton(tr("large"), m_groupSize );
47 48
48 m_groupConv = new QHGroupBox(tr("Line-break conversions"), this ); 49 m_groupConv = new QHGroupBox(tr("Line-break conversions"), this );
49 m_convInbound = new QCheckBox(tr("Inbound"), m_groupConv ); 50 m_convInbound = new QCheckBox(tr("Inbound"), m_groupConv );
50 m_convOutbound = new QCheckBox(tr("Outbound"), m_groupConv ); 51 m_convOutbound = new QCheckBox(tr("Outbound"), m_groupConv );
51 52
52 m_groupOptions = new QHGroupBox( tr("Options"), this ); 53 m_groupOptions = new QHGroupBox( tr("Options"), this );
53 m_optionEcho = new QCheckBox(tr("Local echo"), m_groupOptions ); 54 m_optionEcho = new QCheckBox(tr("Local echo"), m_groupOptions );
54 m_optionWrap = new QCheckBox(tr("Line wrap"), m_groupOptions ); 55 m_optionWrap = new QCheckBox(tr("Line wrap"), m_groupOptions );
55 56
56 m_lroot = new QVBoxLayout(this, 2 ); 57 m_lroot = new QVBoxLayout(this, 2 );
57 m_typeBox = new QVBoxLayout( m_lroot ); 58 m_typeBox = new QVBoxLayout( m_lroot );
58 m_hbox = new QHBoxLayout( m_groupSize, 2 ); 59 m_hbox = new QHBoxLayout( m_groupSize, 2 );
59 m_colorBox = new QVBoxLayout( m_lroot ); 60 m_colorBox = new QVBoxLayout( m_lroot );
60 61
61 // Layout 62 // Layout
62 m_typeBox->add(m_terminal ); 63 m_typeBox->add(m_terminal );
63 m_typeBox->add(m_terminalBox ); 64 m_typeBox->add(m_terminalBox );
64 65
65 m_hbox->add(m_sizeSmall ); 66 m_hbox->add(m_sizeSmall );
66 m_hbox->add(m_sizeMedium ); 67 m_hbox->add(m_sizeMedium );
67 m_hbox->add(m_sizeLarge ); 68 m_hbox->add(m_sizeLarge );
68 m_lroot->add(m_groupSize ); 69 m_lroot->add(m_groupSize );
69 70
70 m_colorBox->add( m_colorLabel ); 71 m_colorBox->add( m_colorLabel );
71 m_colorBox->add( m_colorCmb ); 72 m_colorBox->add( m_colorCmb );
72 73
73 m_lroot->add(m_groupConv ); 74 m_lroot->add(m_groupConv );
74 m_lroot->add(m_groupOptions ); 75 m_lroot->add(m_groupOptions );
75 76
76 // Fill in some options 77 // Fill in some options
77 m_terminalBox->insertItem( tr("VT 100"), id_term_vt100 ); 78 qWarning("Options for terminal box");
78 m_terminalBox->insertItem( tr("VT 102"), id_term_vt102 ); 79 m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ );
80 m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */);
81 m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux );
82 m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm );
79 //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); 83 //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi );
80 84
81 m_colorCmb->insertItem( tr("black on white"), id_term_black ); 85 m_colorCmb->insertItem( tr("black on white"), id_term_black );
82 m_colorCmb->insertItem( tr("white on black"), id_term_white ); 86 m_colorCmb->insertItem( tr("white on black"), id_term_white );
83 m_colorCmb->insertItem( tr("green on black"), id_term_green ); 87 m_colorCmb->insertItem( tr("green on black"), id_term_green );
84 m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); 88 m_colorCmb->insertItem( tr("orange on black"), id_term_orange );
85 89
86 // signals + slots 90 // signals + slots
87 /* 91 /*
88 connect(m_terminalBox, SIGNAL(activated(int) ), 92 connect(m_terminalBox, SIGNAL(activated(int) ),
89 this, SLOT(slotTermTerm(int) ) ); 93 this, SLOT(slotTermTerm(int) ) );
90 connect(m_colorBox, SIGNAL(activated(int) ), 94 connect(m_colorBox, SIGNAL(activated(int) ),
91 tis, SLOT(slotTermColor(int) ) ); 95 tis, SLOT(slotTermColor(int) ) );
92 connect(m_groupSize, SIGNAL(activated(int) ), 96 connect(m_groupSize, SIGNAL(activated(int) ),
93 this, SLOT(slotTermFont(int) ) ); 97 this, SLOT(slotTermFont(int) ) );
94 98
95 connect(m_optionEcho, SIGNAL(toggled(bool) ), 99 connect(m_optionEcho, SIGNAL(toggled(bool) ),
96 this, SLOT(slotTermEcho(bool) ) ); 100 this, SLOT(slotTermEcho(bool) ) );
97 connect(m_optionWrap, SIGNAL(toggled(bool) ), 101 connect(m_optionWrap, SIGNAL(toggled(bool) ),
98 this, SLOT(slotTermWrap(bool) ) ); 102 this, SLOT(slotTermWrap(bool) ) );
99 connect(m_convInbound, SIGNAL(toggled(bool) ), 103 connect(m_convInbound, SIGNAL(toggled(bool) ),
100 this, SLOT(slotTermInbound(bool) ) ); 104 this, SLOT(slotTermInbound(bool) ) );
101 connect(m_convOutbound, SIGNAL(toggled(bool) ), 105 connect(m_convOutbound, SIGNAL(toggled(bool) ),
102 this, SLOT(slotTermOutbound(bool) ) ); 106 this, SLOT(slotTermOutbound(bool) ) );
103*/ 107*/
104} 108}
105TerminalWidget::~TerminalWidget() { 109TerminalWidget::~TerminalWidget() {
106} 110}
107void TerminalWidget::load( const Profile& prof ) { 111void TerminalWidget::load( const Profile& prof ) {
108 int term = prof.readNumEntry("Terminal"); 112 int term = prof.readNumEntry("Terminal");
109 int color = prof.readNumEntry("Color"); 113 int color = prof.readNumEntry("Color");
110 int fontsize = prof.readNumEntry("Font"); 114 int fontsize = prof.readNumEntry("Font");
111 int opt_echo = prof.readNumEntry("Echo"); 115 int opt_echo = prof.readNumEntry("Echo");
112 int opt_wrap = prof.readNumEntry("Wrap"); 116 int opt_wrap = prof.readNumEntry("Wrap");
113 int opt_inbound = prof.readNumEntry("Inbound"); 117 int opt_inbound = prof.readNumEntry("Inbound");
114 int opt_outbound = prof.readNumEntry("Outbound"); 118 int opt_outbound = prof.readNumEntry("Outbound");
115 119
116 switch( term ) { 120 switch( term ) {
117 case Profile::VT100: 121 case Profile::VT100:
118 m_terminalBox->setCurrentItem(id_term_vt100 ); 122 m_terminalBox->setCurrentItem(id_term_vt100 );
119 break; 123 break;
120 case Profile::VT102: 124 case Profile::VT102:
121 m_terminalBox->setCurrentItem(id_term_vt102 ); 125 m_terminalBox->setCurrentItem(id_term_vt102 );
122 break; 126 break;
127 case Profile::Linux:
128 m_terminalBox->setCurrentItem(id_term_linux );
129 break;
130 case Profile::XTerm:
131 m_terminalBox->setCurrentItem(id_term_xterm );
132 break;
123 default: 133 default:
124 break; 134 break;
125 }; 135 };
126 136
127 switch( color ) { 137 switch( color ) {
128 case Profile::Black: 138 case Profile::Black:
129 m_colorCmb->setCurrentItem(id_term_black ); 139 m_colorCmb->setCurrentItem(id_term_black );
130 break; 140 break;
131 case Profile::White: 141 case Profile::White:
132 m_colorCmb->setCurrentItem(id_term_white ); 142 m_colorCmb->setCurrentItem(id_term_white );
133 break; 143 break;
134 case Profile::Green: 144 case Profile::Green:
135 m_colorCmb->setCurrentItem(id_term_green ); 145 m_colorCmb->setCurrentItem(id_term_green );
136 break; 146 break;
137 case Profile::Orange: 147 case Profile::Orange:
138 m_colorCmb->setCurrentItem(id_term_orange ); 148 m_colorCmb->setCurrentItem(id_term_orange );
139 break; 149 break;
140 default: 150 default:
141 break; 151 break;
142 }; 152 };
143 153
144 switch( fontsize ) { 154 switch( fontsize ) {
145 case Profile::Micro: 155 case Profile::Micro:
146 m_sizeSmall->setChecked(true ); 156 m_sizeSmall->setChecked(true );
147 break; 157 break;
148 case Profile::Small: 158 case Profile::Small:
149 m_sizeMedium->setChecked(true ); 159 m_sizeMedium->setChecked(true );
150 break; 160 break;
151 case Profile::Medium: 161 case Profile::Medium:
152 m_sizeLarge->setChecked( true ); 162 m_sizeLarge->setChecked( true );
153 break; 163 break;
154 m_sizeSmall->setChecked(true); 164 m_sizeSmall->setChecked(true);
155 default: 165 default:
156 break; 166 break;
157 }; 167 };
158 168
159 if (opt_echo) m_optionEcho->setChecked( true ); 169 if (opt_echo) m_optionEcho->setChecked( true );
160 if (opt_wrap) m_optionWrap->setChecked( true ); 170 if (opt_wrap) m_optionWrap->setChecked( true );
161 if (opt_inbound) m_convInbound->setChecked( true ); 171 if (opt_inbound) m_convInbound->setChecked( true );
162 if (opt_outbound) m_convOutbound->setChecked( true ); 172 if (opt_outbound) m_convOutbound->setChecked( true );
163 173
164} 174}
165void TerminalWidget::save( Profile& profile ) { 175void TerminalWidget::save( Profile& profile ) {
166 switch(m_terminalBox->currentItem() ) { 176 switch(m_terminalBox->currentItem() ) {
167 case id_term_vt100: 177 case id_term_vt100:
168 profile.writeEntry("Terminal", Profile::VT100 ); 178 profile.writeEntry("Terminal", Profile::VT100 );
169 break; 179 break;
170 case id_term_vt102: 180 case id_term_vt102:
171 profile.writeEntry("Terminal", Profile::VT102 ); 181 profile.writeEntry("Terminal", Profile::VT102 );
172 break; 182 break;
183 case id_term_linux:
184 profile.writeEntry("Terminal", Profile::Linux );
185 break;
186 case id_term_xterm:
187 profile.writeEntry("Terminal", Profile::XTerm );
188 break;
173 //case id_term_ansi: 189 //case id_term_ansi:
174 // profile.writeEntry("Terminal", Profile::VT102 ); 190 // profile.writeEntry("Terminal", Profile::VT102 );
175 // break; 191 // break;
176 default: 192 default:
177 break; 193 break;
178 }; 194 };
179 195
180 // color 196 // color
181 switch(m_colorCmb->currentItem() ) { 197 switch(m_colorCmb->currentItem() ) {
182 case id_term_black: 198 case id_term_black:
183 profile.writeEntry("Color", Profile::Black ); 199 profile.writeEntry("Color", Profile::Black );
184 break; 200 break;
185 case id_term_white: 201 case id_term_white:
186 profile.writeEntry("Color", Profile::White ); 202 profile.writeEntry("Color", Profile::White );
187 break; 203 break;
188 case id_term_green: 204 case id_term_green:
189 profile.writeEntry("Color", Profile::Green ); 205 profile.writeEntry("Color", Profile::Green );
190 break; 206 break;
191 case id_term_orange: 207 case id_term_orange:
192 profile.writeEntry("Color", Profile::Orange ); 208 profile.writeEntry("Color", Profile::Orange );
193 break; 209 break;
194 default: 210 default:
195 break; 211 break;
196 }; 212 };
197 213
198 if (m_sizeSmall->isChecked() ) { 214 if (m_sizeSmall->isChecked() ) {
199 profile.writeEntry("Font", Profile::Micro ); 215 profile.writeEntry("Font", Profile::Micro );
200 }else if (m_sizeMedium->isChecked() ) { 216 }else if (m_sizeMedium->isChecked() ) {
201 profile.writeEntry("Font", Profile::Small ); 217 profile.writeEntry("Font", Profile::Small );
202 }else { 218 }else {
203 profile.writeEntry("Font", Profile::Medium ); 219 profile.writeEntry("Font", Profile::Medium );
204 } 220 }
205 221
206 profile.writeEntry("Echo", m_optionEcho->isChecked() ); 222 profile.writeEntry("Echo", m_optionEcho->isChecked() );
207 profile.writeEntry("Wrap", m_optionWrap->isChecked() ); 223 profile.writeEntry("Wrap", m_optionWrap->isChecked() );
208 profile.writeEntry("Inbound", m_convInbound->isChecked() ); 224 profile.writeEntry("Inbound", m_convInbound->isChecked() );
209 profile.writeEntry("Outbound",m_convOutbound->isChecked() ); 225 profile.writeEntry("Outbound",m_convOutbound->isChecked() );
210} 226}