author | zecke <zecke> | 2002-10-20 13:52:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-20 13:52:13 (UTC) |
commit | 89ed0106d3de43c0f39250524bc80de00f2b596c (patch) (unidiff) | |
tree | 4354cc80f93f1a76caea30c350e4fc3350c32726 | |
parent | 4b27ac49b4027ffd59d2606f1aceea313446aede (diff) | |
download | opie-89ed0106d3de43c0f39250524bc80de00f2b596c.zip opie-89ed0106d3de43c0f39250524bc80de00f2b596c.tar.gz opie-89ed0106d3de43c0f39250524bc80de00f2b596c.tar.bz2 |
Enable setSize SIGNAL/SLOT conenction in session
Add some separators to m_console of mainwindow
-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEmulation.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_layer.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 2 |
5 files changed, 9 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index a2373bf..6b0d6f2 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -1,292 +1,293 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [MyPty.C] Pseudo Terminal Device */ | 3 | /* [MyPty.C] 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 | /* Ported Konsole to Qt/Embedded */ | 12 | /* Ported Konsole to Qt/Embedded */ |
13 | /* */ | 13 | /* */ |
14 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 14 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
15 | /* */ | 15 | /* */ |
16 | /* -------------------------------------------------------------------------- */ | 16 | /* -------------------------------------------------------------------------- */ |
17 | 17 | ||
18 | /* If you're compiling konsole on non-Linux platforms and find | 18 | /* If you're compiling konsole on non-Linux platforms and find |
19 | problems that you can track down to this file, please have | 19 | problems that you can track down to this file, please have |
20 | a look into ../README.ports, too. | 20 | a look into ../README.ports, too. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /*! \file | 23 | /*! \file |
24 | */ | 24 | */ |
25 | 25 | ||
26 | /*! \class TEPty | 26 | /*! \class TEPty |
27 | 27 | ||
28 | \brief Ptys provide a pseudo terminal connection to a program. | 28 | \brief Ptys provide a pseudo terminal connection to a program. |
29 | 29 | ||
30 | Although closely related to pipes, these pseudo terminal connections have | 30 | Although closely related to pipes, these pseudo terminal connections have |
31 | some ability, that makes it nessesary to uses them. Most importent, they | 31 | some ability, that makes it nessesary to uses them. Most importent, they |
32 | know about changing screen sizes and UNIX job control. | 32 | know about changing screen sizes and UNIX job control. |
33 | 33 | ||
34 | Within the terminal emulation framework, this class represents the | 34 | Within the terminal emulation framework, this class represents the |
35 | host side of the terminal together with the connecting serial line. | 35 | host side of the terminal together with the connecting serial line. |
36 | 36 | ||
37 | One can create many instances of this class within a program. | 37 | One can create many instances of this class within a program. |
38 | As a side effect of using this class, a signal(2) handler is | 38 | As a side effect of using this class, a signal(2) handler is |
39 | installed on SIGCHLD. | 39 | installed on SIGCHLD. |
40 | 40 | ||
41 | \par FIXME | 41 | \par FIXME |
42 | 42 | ||
43 | [NOTE: much of the technical stuff below will be replaced by forkpty.] | 43 | [NOTE: much of the technical stuff below will be replaced by forkpty.] |
44 | 44 | ||
45 | publish the SIGCHLD signal if not related to an instance. | 45 | publish the SIGCHLD signal if not related to an instance. |
46 | 46 | ||
47 | clearify TEPty::done vs. TEPty::~TEPty semantics. | 47 | clearify TEPty::done vs. TEPty::~TEPty semantics. |
48 | check if pty is restartable via run after done. | 48 | check if pty is restartable via run after done. |
49 | 49 | ||
50 | \par Pseudo terminals | 50 | \par Pseudo terminals |
51 | 51 | ||
52 | Pseudo terminals are a unique feature of UNIX, and always come in form of | 52 | Pseudo terminals are a unique feature of UNIX, and always come in form of |
53 | pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each | 53 | pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each |
54 | other by the operating system. One may think of them as two serial devices | 54 | other by the operating system. One may think of them as two serial devices |
55 | linked by a null-modem cable. Being based on devices the number of | 55 | linked by a null-modem cable. Being based on devices the number of |
56 | simultanous instances of this class is (globally) limited by the number of | 56 | simultanous instances of this class is (globally) limited by the number of |
57 | those device pairs, which is 256. | 57 | those device pairs, which is 256. |
58 | 58 | ||
59 | Another technic are UNIX 98 PTY's. These are supported also, and prefered | 59 | Another technic are UNIX 98 PTY's. These are supported also, and prefered |
60 | over the (obsolete) predecessor. | 60 | over the (obsolete) predecessor. |
61 | 61 | ||
62 | There's a sinister ioctl(2), signal(2) and job control stuff | 62 | There's a sinister ioctl(2), signal(2) and job control stuff |
63 | nessesary to make everything work as it should. | 63 | nessesary to make everything work as it should. |
64 | */ | 64 | */ |
65 | 65 | ||
66 | 66 | ||
67 | #include <qapplication.h> | 67 | #include <qapplication.h> |
68 | #include <qsocketnotifier.h> | 68 | #include <qsocketnotifier.h> |
69 | #include <qstring.h> | 69 | #include <qstring.h> |
70 | 70 | ||
71 | #include <stdlib.h> | 71 | #include <stdlib.h> |
72 | #include <stdio.h> | 72 | #include <stdio.h> |
73 | #include <signal.h> | 73 | #include <signal.h> |
74 | #include <fcntl.h> | 74 | #include <fcntl.h> |
75 | #include <unistd.h> | 75 | #include <unistd.h> |
76 | #include <termios.h> | 76 | #include <termios.h> |
77 | #include <sys/types.h> | 77 | #include <sys/types.h> |
78 | #include <sys/ioctl.h> | 78 | #include <sys/ioctl.h> |
79 | #include <sys/wait.h> | 79 | #include <sys/wait.h> |
80 | 80 | ||
81 | #ifdef HAVE_OPENPTY | 81 | #ifdef HAVE_OPENPTY |
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 | ||
99 | void MyPty::setSize(int lines, int columns) | 99 | void MyPty::setSize(int lines, int columns) |
100 | { | 100 | { |
101 | qWarning("setting size"); | ||
101 | struct winsize wsize; | 102 | struct winsize wsize; |
102 | wsize.ws_row = (unsigned short)lines; | 103 | wsize.ws_row = (unsigned short)lines; |
103 | wsize.ws_col = (unsigned short)columns; | 104 | wsize.ws_col = (unsigned short)columns; |
104 | if(m_fd < 0) return; | 105 | if(m_fd < 0) return; |
105 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); | 106 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); |
106 | } | 107 | } |
107 | 108 | ||
108 | 109 | ||
109 | void MyPty::donePty() | 110 | void MyPty::donePty() |
110 | { | 111 | { |
111 | // This is code from the Qt DumbTerminal example | 112 | // This is code from the Qt DumbTerminal example |
112 | int status = 0; | 113 | int status = 0; |
113 | 114 | ||
114 | ::close(m_fd); | 115 | ::close(m_fd); |
115 | 116 | ||
116 | if (m_cpid) { | 117 | if (m_cpid) { |
117 | kill(m_cpid, SIGHUP); | 118 | kill(m_cpid, SIGHUP); |
118 | //waitpid(m_cpid, &status, 0); | 119 | //waitpid(m_cpid, &status, 0); |
119 | delete m_sn_e; | 120 | delete m_sn_e; |
120 | delete m_sn_r; | 121 | delete m_sn_r; |
121 | m_sn_e = 0l; | 122 | m_sn_e = 0l; |
122 | m_sn_r = 0l; | 123 | m_sn_r = 0l; |
123 | } | 124 | } |
124 | 125 | ||
125 | m_cpid = 0; | 126 | m_cpid = 0; |
126 | m_fd = -1; | 127 | m_fd = -1; |
127 | // emit done(status); | 128 | // emit done(status); |
128 | } | 129 | } |
129 | 130 | ||
130 | 131 | ||
131 | const char* MyPty::deviceName() | 132 | const char* MyPty::deviceName() |
132 | { | 133 | { |
133 | return m_ttynam; | 134 | return m_ttynam; |
134 | } | 135 | } |
135 | 136 | ||
136 | 137 | ||
137 | void MyPty::error() | 138 | void MyPty::error() |
138 | { | 139 | { |
139 | // This is code from the Qt DumbTerminal example | 140 | // This is code from the Qt DumbTerminal example |
140 | donePty(); | 141 | donePty(); |
141 | } | 142 | } |
142 | 143 | ||
143 | void MyPty::start() { | 144 | void MyPty::start() { |
144 | char* cmd = "/bin/sh"; | 145 | char* cmd = "/bin/sh"; |
145 | QStrList lis; | 146 | QStrList lis; |
146 | int r =run(cmd, lis, 0, 0); | 147 | int r =run(cmd, lis, 0, 0); |
147 | r = r; | 148 | r = r; |
148 | } | 149 | } |
149 | /*! | 150 | /*! |
150 | start the client program. | 151 | start the client program. |
151 | */ | 152 | */ |
152 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 153 | int MyPty::run(const char* cmd, QStrList &, const char*, int) |
153 | { | 154 | { |
154 | // This is code from the Qt DumbTerminal example | 155 | // This is code from the Qt DumbTerminal example |
155 | m_cpid = fork(); | 156 | m_cpid = fork(); |
156 | 157 | ||
157 | if ( !m_cpid ) { | 158 | if ( !m_cpid ) { |
158 | // child - exec shell on tty | 159 | // child - exec shell on tty |
159 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); | 160 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); |
160 | int ttyfd = ::open(m_ttynam, O_RDWR); | 161 | int ttyfd = ::open(m_ttynam, O_RDWR); |
161 | dup2(ttyfd, STDIN_FILENO); | 162 | dup2(ttyfd, STDIN_FILENO); |
162 | dup2(ttyfd, STDOUT_FILENO); | 163 | dup2(ttyfd, STDOUT_FILENO); |
163 | dup2(ttyfd, STDERR_FILENO); | 164 | dup2(ttyfd, STDERR_FILENO); |
164 | // should be done with tty, so close it | 165 | // should be done with tty, so close it |
165 | ::close(ttyfd); | 166 | ::close(ttyfd); |
166 | static struct termios ttmode; | 167 | static struct termios ttmode; |
167 | if ( setsid() < 0 ) | 168 | if ( setsid() < 0 ) |
168 | perror( "failed to set process group" ); | 169 | perror( "failed to set process group" ); |
169 | #if defined (TIOCSCTTY) | 170 | #if defined (TIOCSCTTY) |
170 | // grabbed from APUE by Stevens | 171 | // grabbed from APUE by Stevens |
171 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 172 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
172 | #endif | 173 | #endif |
173 | tcgetattr( STDIN_FILENO, &ttmode ); | 174 | tcgetattr( STDIN_FILENO, &ttmode ); |
174 | ttmode.c_cc[VINTR] = 3; | 175 | ttmode.c_cc[VINTR] = 3; |
175 | ttmode.c_cc[VERASE] = 8; | 176 | ttmode.c_cc[VERASE] = 8; |
176 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 177 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
177 | setenv("TERM","vt100",1); | 178 | setenv("TERM","vt100",1); |
178 | setenv("COLORTERM","0",1); | 179 | setenv("COLORTERM","0",1); |
179 | 180 | ||
180 | if (getuid() == 0) { | 181 | if (getuid() == 0) { |
181 | char msg[] = "WARNING: You are running this shell as root!\n"; | 182 | char msg[] = "WARNING: You are running this shell as root!\n"; |
182 | write(ttyfd, msg, sizeof(msg)); | 183 | write(ttyfd, msg, sizeof(msg)); |
183 | } | 184 | } |
184 | execl(cmd, cmd, 0); | 185 | execl(cmd, cmd, 0); |
185 | 186 | ||
186 | donePty(); | 187 | donePty(); |
187 | exit(-1); | 188 | exit(-1); |
188 | } | 189 | } |
189 | 190 | ||
190 | // parent - continue as a widget | 191 | // parent - continue as a widget |
191 | delete m_sn_r; | 192 | delete m_sn_r; |
192 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); | 193 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); |
193 | delete m_sn_e; | 194 | delete m_sn_e; |
194 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); | 195 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); |
195 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); | 196 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); |
196 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); | 197 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); |
197 | 198 | ||
198 | return 0; | 199 | return 0; |
199 | } | 200 | } |
200 | 201 | ||
201 | int MyPty::openPty() | 202 | int MyPty::openPty() |
202 | { | 203 | { |
203 | // This is code from the Qt DumbTerminal example | 204 | // This is code from the Qt DumbTerminal example |
204 | int ptyfd = -1; | 205 | int ptyfd = -1; |
205 | 206 | ||
206 | #ifdef HAVE_OPENPTY | 207 | #ifdef HAVE_OPENPTY |
207 | int ttyfd; | 208 | int ttyfd; |
208 | if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) | 209 | if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) |
209 | ptyfd = -1; | 210 | ptyfd = -1; |
210 | else | 211 | else |
211 | close(ttyfd); // we open the ttynam ourselves. | 212 | close(ttyfd); // we open the ttynam ourselves. |
212 | #else | 213 | #else |
213 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { | 214 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { |
214 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { | 215 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { |
215 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); | 216 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); |
216 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); | 217 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); |
217 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { | 218 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { |
218 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { | 219 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { |
219 | ::close(ptyfd); | 220 | ::close(ptyfd); |
220 | ptyfd = -1; | 221 | ptyfd = -1; |
221 | } | 222 | } |
222 | } | 223 | } |
223 | } | 224 | } |
224 | } | 225 | } |
225 | #endif | 226 | #endif |
226 | 227 | ||
227 | if ( ptyfd < 0 ) { | 228 | if ( ptyfd < 0 ) { |
228 | //qApp->exit(1); | 229 | //qApp->exit(1); |
229 | return -1; | 230 | return -1; |
230 | } | 231 | } |
231 | 232 | ||
232 | return ptyfd; | 233 | return ptyfd; |
233 | } | 234 | } |
234 | 235 | ||
235 | /*! | 236 | /*! |
236 | Create an instance. | 237 | Create an instance. |
237 | */ | 238 | */ |
238 | MyPty::MyPty(const Profile&) : m_cpid(0) | 239 | MyPty::MyPty(const Profile&) : m_cpid(0) |
239 | { | 240 | { |
240 | m_sn_e = 0l; | 241 | m_sn_e = 0l; |
241 | m_sn_r = 0l; | 242 | m_sn_r = 0l; |
242 | m_fd = openPty(); | 243 | m_fd = openPty(); |
243 | ProcCtl* ctl = ProcCtl::self(); | 244 | ProcCtl* ctl = ProcCtl::self(); |
244 | } | 245 | } |
245 | 246 | ||
246 | /*! | 247 | /*! |
247 | Destructor. | 248 | Destructor. |
248 | Note that the related client program is not killed | 249 | Note that the related client program is not killed |
249 | (yet) when a instance is deleted. | 250 | (yet) when a instance is deleted. |
250 | */ | 251 | */ |
251 | MyPty::~MyPty() | 252 | MyPty::~MyPty() |
252 | { | 253 | { |
253 | donePty(); | 254 | donePty(); |
254 | } | 255 | } |
255 | QString MyPty::identifier()const { | 256 | QString MyPty::identifier()const { |
256 | return QString::fromLatin1("term"); | 257 | return QString::fromLatin1("term"); |
257 | } | 258 | } |
258 | QString MyPty::name()const{ | 259 | QString MyPty::name()const{ |
259 | return identifier(); | 260 | return identifier(); |
260 | } | 261 | } |
261 | bool MyPty::open() { | 262 | bool MyPty::open() { |
262 | if (m_fd < 0) | 263 | if (m_fd < 0) |
263 | m_fd = openPty(); | 264 | m_fd = openPty(); |
264 | 265 | ||
265 | start(); | 266 | start(); |
266 | return true; | 267 | return true; |
267 | } | 268 | } |
268 | void MyPty::close() { | 269 | void MyPty::close() { |
269 | donePty(); | 270 | donePty(); |
270 | m_fd = openPty(); | 271 | m_fd = openPty(); |
271 | } | 272 | } |
272 | void MyPty::reload( const Profile& ) { | 273 | void MyPty::reload( const Profile& ) { |
273 | 274 | ||
274 | } | 275 | } |
275 | /*! sends len bytes through the line */ | 276 | /*! sends len bytes through the line */ |
276 | void MyPty::send(const QByteArray& ar) | 277 | void MyPty::send(const QByteArray& ar) |
277 | { | 278 | { |
278 | #ifdef VERBOSE_DEBUG | 279 | #ifdef VERBOSE_DEBUG |
279 | // verbose debug | 280 | // verbose debug |
280 | printf("sending bytes:\n"); | 281 | printf("sending bytes:\n"); |
281 | for (uint i = 0; i < ar.count(); i++) | 282 | for (uint i = 0; i < ar.count(); i++) |
282 | printf("%c", ar[i]); | 283 | printf("%c", ar[i]); |
283 | printf("\n"); | 284 | printf("\n"); |
284 | #endif | 285 | #endif |
285 | 286 | ||
286 | ::write(m_fd, ar.data(), ar.count()); | 287 | ::write(m_fd, ar.data(), ar.count()); |
287 | } | 288 | } |
288 | 289 | ||
289 | /*! indicates that a block of data is received */ | 290 | /*! indicates that a block of data is received */ |
290 | void MyPty::readPty() | 291 | void MyPty::readPty() |
291 | { | 292 | { |
292 | QByteArray buf(4096); | 293 | QByteArray buf(4096); |
diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp index 6f3ad32..7a0c624 100644 --- a/noncore/apps/opie-console/TEmulation.cpp +++ b/noncore/apps/opie-console/TEmulation.cpp | |||
@@ -18,346 +18,347 @@ | |||
18 | 18 | ||
19 | /*! \class TEmulation | 19 | /*! \class TEmulation |
20 | 20 | ||
21 | \brief Mediator between TEWidget and TEScreen. | 21 | \brief Mediator between TEWidget and TEScreen. |
22 | 22 | ||
23 | This class is responsible to scan the escapes sequences of the terminal | 23 | This class is responsible to scan the escapes sequences of the terminal |
24 | emulation and to map it to their corresponding semantic complements. | 24 | emulation and to map it to their corresponding semantic complements. |
25 | Thus this module knows mainly about decoding escapes sequences and | 25 | Thus this module knows mainly about decoding escapes sequences and |
26 | is a stateless device w.r.t. the semantics. | 26 | is a stateless device w.r.t. the semantics. |
27 | 27 | ||
28 | It is also responsible to refresh the TEWidget by certain rules. | 28 | It is also responsible to refresh the TEWidget by certain rules. |
29 | 29 | ||
30 | \sa TEWidget \sa TEScreen | 30 | \sa TEWidget \sa TEScreen |
31 | 31 | ||
32 | \par A note on refreshing | 32 | \par A note on refreshing |
33 | 33 | ||
34 | Although the modifications to the current screen image could immediately | 34 | Although the modifications to the current screen image could immediately |
35 | be propagated via `TEWidget' to the graphical surface, we have chosen | 35 | be propagated via `TEWidget' to the graphical surface, we have chosen |
36 | another way here. | 36 | another way here. |
37 | 37 | ||
38 | The reason for doing so is twofold. | 38 | The reason for doing so is twofold. |
39 | 39 | ||
40 | First, experiments show that directly displaying the operation results | 40 | First, experiments show that directly displaying the operation results |
41 | in slowing down the overall performance of emulations. Displaying | 41 | in slowing down the overall performance of emulations. Displaying |
42 | individual characters using X11 creates a lot of overhead. | 42 | individual characters using X11 creates a lot of overhead. |
43 | 43 | ||
44 | Second, by using the following refreshing method, the screen operations | 44 | Second, by using the following refreshing method, the screen operations |
45 | can be completely separated from the displaying. This greatly simplifies | 45 | can be completely separated from the displaying. This greatly simplifies |
46 | the programmer's task of coding and maintaining the screen operations, | 46 | the programmer's task of coding and maintaining the screen operations, |
47 | since one need not worry about differential modifications on the | 47 | since one need not worry about differential modifications on the |
48 | display affecting the operation of concern. | 48 | display affecting the operation of concern. |
49 | 49 | ||
50 | We use a refreshing algorithm here that has been adoped from rxvt/kvt. | 50 | We use a refreshing algorithm here that has been adoped from rxvt/kvt. |
51 | 51 | ||
52 | By this, refreshing is driven by a timer, which is (re)started whenever | 52 | By this, refreshing is driven by a timer, which is (re)started whenever |
53 | a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. | 53 | a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. |
54 | As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger | 54 | As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger |
55 | refresh. This rule suits both bulk display operation as done by curses as | 55 | refresh. This rule suits both bulk display operation as done by curses as |
56 | well as individual characters typed. | 56 | well as individual characters typed. |
57 | (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). | 57 | (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). |
58 | 58 | ||
59 | Additionally, we trigger refreshing by newlines comming in to make visual | 59 | Additionally, we trigger refreshing by newlines comming in to make visual |
60 | snapshots of lists as produced by `cat', `ls' and likely programs, thereby | 60 | snapshots of lists as produced by `cat', `ls' and likely programs, thereby |
61 | producing the illusion of a permanent and immediate display operation. | 61 | producing the illusion of a permanent and immediate display operation. |
62 | 62 | ||
63 | As a sort of catch-all needed for cases where none of the above | 63 | As a sort of catch-all needed for cases where none of the above |
64 | conditions catch, the screen refresh is also triggered by a count | 64 | conditions catch, the screen refresh is also triggered by a count |
65 | of incoming bulks (`bulk_incnt'). | 65 | of incoming bulks (`bulk_incnt'). |
66 | */ | 66 | */ |
67 | 67 | ||
68 | /* FIXME | 68 | /* FIXME |
69 | - evtl. the bulk operations could be made more transparent. | 69 | - evtl. the bulk operations could be made more transparent. |
70 | */ | 70 | */ |
71 | 71 | ||
72 | #include "TEmulation.h" | 72 | #include "TEmulation.h" |
73 | #include "TEWidget.h" | 73 | #include "TEWidget.h" |
74 | #include "TEScreen.h" | 74 | #include "TEScreen.h" |
75 | #include <stdio.h> | 75 | #include <stdio.h> |
76 | #include <stdlib.h> | 76 | #include <stdlib.h> |
77 | #include <unistd.h> | 77 | #include <unistd.h> |
78 | #include <qkeycode.h> | 78 | #include <qkeycode.h> |
79 | 79 | ||
80 | 80 | ||
81 | /* ------------------------------------------------------------------------- */ | 81 | /* ------------------------------------------------------------------------- */ |
82 | /* */ | 82 | /* */ |
83 | /* TEmulation */ | 83 | /* TEmulation */ |
84 | /* */ | 84 | /* */ |
85 | /* ------------------------------------------------------------------------- */ | 85 | /* ------------------------------------------------------------------------- */ |
86 | 86 | ||
87 | #define CNTL(c) ((c)-'@') | 87 | #define CNTL(c) ((c)-'@') |
88 | 88 | ||
89 | /*! | 89 | /*! |
90 | */ | 90 | */ |
91 | 91 | ||
92 | TEmulation::TEmulation(TEWidget* gui) | 92 | TEmulation::TEmulation(TEWidget* gui) |
93 | : decoder((QTextDecoder*)NULL) | 93 | : decoder((QTextDecoder*)NULL) |
94 | { | 94 | { |
95 | this->gui = gui; | 95 | this->gui = gui; |
96 | 96 | ||
97 | screen[0] = new TEScreen(gui->Lines(),gui->Columns()); | 97 | screen[0] = new TEScreen(gui->Lines(),gui->Columns()); |
98 | screen[1] = new TEScreen(gui->Lines(),gui->Columns()); | 98 | screen[1] = new TEScreen(gui->Lines(),gui->Columns()); |
99 | scr = screen[0]; | 99 | scr = screen[0]; |
100 | 100 | ||
101 | bulk_nlcnt = 0; // reset bulk newline counter | 101 | bulk_nlcnt = 0; // reset bulk newline counter |
102 | bulk_incnt = 0; // reset bulk counter | 102 | bulk_incnt = 0; // reset bulk counter |
103 | connected = FALSE; | 103 | connected = FALSE; |
104 | 104 | ||
105 | QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); | 105 | QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); |
106 | QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), | 106 | QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), |
107 | this,SLOT(onImageSizeChange(int,int))); | 107 | this,SLOT(onImageSizeChange(int,int))); |
108 | QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), | 108 | QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), |
109 | this,SLOT(onHistoryCursorChange(int))); | 109 | this,SLOT(onHistoryCursorChange(int))); |
110 | QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), | 110 | QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), |
111 | this,SLOT(onKeyPress(QKeyEvent*))); | 111 | this,SLOT(onKeyPress(QKeyEvent*))); |
112 | QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), | 112 | QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), |
113 | this,SLOT(onSelectionBegin(const int,const int)) ); | 113 | this,SLOT(onSelectionBegin(const int,const int)) ); |
114 | QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), | 114 | QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), |
115 | this,SLOT(onSelectionExtend(const int,const int)) ); | 115 | this,SLOT(onSelectionExtend(const int,const int)) ); |
116 | QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), | 116 | QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), |
117 | this,SLOT(setSelection(const BOOL)) ); | 117 | this,SLOT(setSelection(const BOOL)) ); |
118 | QObject::connect(gui,SIGNAL(clearSelectionSignal()), | 118 | QObject::connect(gui,SIGNAL(clearSelectionSignal()), |
119 | this,SLOT(clearSelection()) ); | 119 | this,SLOT(clearSelection()) ); |
120 | } | 120 | } |
121 | 121 | ||
122 | /*! | 122 | /*! |
123 | */ | 123 | */ |
124 | 124 | ||
125 | TEmulation::~TEmulation() | 125 | TEmulation::~TEmulation() |
126 | { | 126 | { |
127 | delete screen[0]; | 127 | delete screen[0]; |
128 | delete screen[1]; | 128 | delete screen[1]; |
129 | bulk_timer.stop(); | 129 | bulk_timer.stop(); |
130 | } | 130 | } |
131 | 131 | ||
132 | /*! change between primary and alternate screen | 132 | /*! change between primary and alternate screen |
133 | */ | 133 | */ |
134 | 134 | ||
135 | void TEmulation::setScreen(int n) | 135 | void TEmulation::setScreen(int n) |
136 | { | 136 | { |
137 | scr = screen[n&1]; | 137 | scr = screen[n&1]; |
138 | } | 138 | } |
139 | 139 | ||
140 | void TEmulation::setHistory(bool on) | 140 | void TEmulation::setHistory(bool on) |
141 | { | 141 | { |
142 | screen[0]->setScroll(on); | 142 | screen[0]->setScroll(on); |
143 | if (!connected) return; | 143 | if (!connected) return; |
144 | showBulk(); | 144 | showBulk(); |
145 | } | 145 | } |
146 | 146 | ||
147 | bool TEmulation::history() | 147 | bool TEmulation::history() |
148 | { | 148 | { |
149 | return screen[0]->hasScroll(); | 149 | return screen[0]->hasScroll(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void TEmulation::setCodec(int c) | 152 | void TEmulation::setCodec(int c) |
153 | { | 153 | { |
154 | //FIXME: check whether we have to free codec | 154 | //FIXME: check whether we have to free codec |
155 | codec = c ? QTextCodec::codecForName("utf8") | 155 | codec = c ? QTextCodec::codecForName("utf8") |
156 | : QTextCodec::codecForLocale(); | 156 | : QTextCodec::codecForLocale(); |
157 | if (decoder) delete decoder; | 157 | if (decoder) delete decoder; |
158 | decoder = codec->makeDecoder(); | 158 | decoder = codec->makeDecoder(); |
159 | } | 159 | } |
160 | 160 | ||
161 | void TEmulation::setKeytrans(int no) | 161 | void TEmulation::setKeytrans(int no) |
162 | { | 162 | { |
163 | keytrans = KeyTrans::find(no); | 163 | keytrans = KeyTrans::find(no); |
164 | } | 164 | } |
165 | 165 | ||
166 | void TEmulation::setKeytrans(const char * no) | 166 | void TEmulation::setKeytrans(const char * no) |
167 | { | 167 | { |
168 | keytrans = KeyTrans::find(no); | 168 | keytrans = KeyTrans::find(no); |
169 | } | 169 | } |
170 | 170 | ||
171 | // Interpreting Codes --------------------------------------------------------- | 171 | // Interpreting Codes --------------------------------------------------------- |
172 | 172 | ||
173 | /* | 173 | /* |
174 | This section deals with decoding the incoming character stream. | 174 | This section deals with decoding the incoming character stream. |
175 | Decoding means here, that the stream is first seperated into `tokens' | 175 | Decoding means here, that the stream is first seperated into `tokens' |
176 | which are then mapped to a `meaning' provided as operations by the | 176 | which are then mapped to a `meaning' provided as operations by the |
177 | `Screen' class. | 177 | `Screen' class. |
178 | */ | 178 | */ |
179 | 179 | ||
180 | /*! | 180 | /*! |
181 | */ | 181 | */ |
182 | 182 | ||
183 | void TEmulation::onRcvChar(int c) | 183 | void TEmulation::onRcvChar(int c) |
184 | // process application unicode input to terminal | 184 | // process application unicode input to terminal |
185 | // this is a trivial scanner | 185 | // this is a trivial scanner |
186 | { | 186 | { |
187 | c &= 0xff; | 187 | c &= 0xff; |
188 | switch (c) | 188 | switch (c) |
189 | { | 189 | { |
190 | case '\b' : scr->BackSpace(); break; | 190 | case '\b' : scr->BackSpace(); break; |
191 | case '\t' : scr->Tabulate(); break; | 191 | case '\t' : scr->Tabulate(); break; |
192 | case '\n' : scr->NewLine(); break; | 192 | case '\n' : scr->NewLine(); break; |
193 | case '\r' : scr->Return(); break; | 193 | case '\r' : scr->Return(); break; |
194 | case 0x07 : gui->Bell(); break; | 194 | case 0x07 : gui->Bell(); break; |
195 | default : scr->ShowCharacter(c); break; | 195 | default : scr->ShowCharacter(c); break; |
196 | }; | 196 | }; |
197 | } | 197 | } |
198 | 198 | ||
199 | /* ------------------------------------------------------------------------- */ | 199 | /* ------------------------------------------------------------------------- */ |
200 | /* */ | 200 | /* */ |
201 | /* Keyboard Handling */ | 201 | /* Keyboard Handling */ |
202 | /* */ | 202 | /* */ |
203 | /* ------------------------------------------------------------------------- */ | 203 | /* ------------------------------------------------------------------------- */ |
204 | 204 | ||
205 | /*! | 205 | /*! |
206 | */ | 206 | */ |
207 | 207 | ||
208 | void TEmulation::onKeyPress( QKeyEvent* ev ) | 208 | void TEmulation::onKeyPress( QKeyEvent* ev ) |
209 | { | 209 | { |
210 | qWarning("onKeyPress,...."); | ||
210 | if (!connected) return; // someone else gets the keys | 211 | if (!connected) return; // someone else gets the keys |
211 | if (scr->getHistCursor() != scr->getHistLines()); | 212 | if (scr->getHistCursor() != scr->getHistLines()); |
212 | scr->setHistCursor(scr->getHistLines()); | 213 | scr->setHistCursor(scr->getHistLines()); |
213 | if (!ev->text().isEmpty()) | 214 | if (!ev->text().isEmpty()) |
214 | { // A block of text | 215 | { // A block of text |
215 | // Note that the text is proper unicode. | 216 | // Note that the text is proper unicode. |
216 | // We should do a conversion here, but since this | 217 | // We should do a conversion here, but since this |
217 | // routine will never be used, we simply emit plain ascii. | 218 | // routine will never be used, we simply emit plain ascii. |
218 | emit sndBlock(ev->text().ascii(),ev->text().length()); | 219 | emit sndBlock(ev->text().ascii(),ev->text().length()); |
219 | } | 220 | } |
220 | else if (ev->ascii()>0) | 221 | else if (ev->ascii()>0) |
221 | { unsigned char c[1]; | 222 | { unsigned char c[1]; |
222 | c[0] = ev->ascii(); | 223 | c[0] = ev->ascii(); |
223 | emit sndBlock((char*)c,1); | 224 | emit sndBlock((char*)c,1); |
224 | } | 225 | } |
225 | } | 226 | } |
226 | 227 | ||
227 | // Unblocking, Byte to Unicode translation --------------------------------- -- | 228 | // Unblocking, Byte to Unicode translation --------------------------------- -- |
228 | 229 | ||
229 | /* | 230 | /* |
230 | We are doing code conversion from locale to unicode first. | 231 | We are doing code conversion from locale to unicode first. |
231 | */ | 232 | */ |
232 | 233 | ||
233 | void TEmulation::onRcvBlock(const char *s, int len) | 234 | void TEmulation::onRcvBlock(const char *s, int len) |
234 | { | 235 | { |
235 | bulkStart(); | 236 | bulkStart(); |
236 | bulk_incnt += 1; | 237 | bulk_incnt += 1; |
237 | for (int i = 0; i < len; i++) | 238 | for (int i = 0; i < len; i++) |
238 | { | 239 | { |
239 | QString result = decoder->toUnicode(&s[i],1); | 240 | QString result = decoder->toUnicode(&s[i],1); |
240 | int reslen = result.length(); | 241 | int reslen = result.length(); |
241 | for (int j = 0; j < reslen; j++) | 242 | for (int j = 0; j < reslen; j++) |
242 | onRcvChar(result[j].unicode()); | 243 | onRcvChar(result[j].unicode()); |
243 | if (s[i] == '\n') bulkNewline(); | 244 | if (s[i] == '\n') bulkNewline(); |
244 | } | 245 | } |
245 | bulkEnd(); | 246 | bulkEnd(); |
246 | } | 247 | } |
247 | 248 | ||
248 | // Selection --------------------------------------------------------------- -- | 249 | // Selection --------------------------------------------------------------- -- |
249 | 250 | ||
250 | void TEmulation::onSelectionBegin(const int x, const int y) { | 251 | void TEmulation::onSelectionBegin(const int x, const int y) { |
251 | if (!connected) return; | 252 | if (!connected) return; |
252 | scr->setSelBeginXY(x,y); | 253 | scr->setSelBeginXY(x,y); |
253 | showBulk(); | 254 | showBulk(); |
254 | } | 255 | } |
255 | 256 | ||
256 | void TEmulation::onSelectionExtend(const int x, const int y) { | 257 | void TEmulation::onSelectionExtend(const int x, const int y) { |
257 | if (!connected) return; | 258 | if (!connected) return; |
258 | scr->setSelExtentXY(x,y); | 259 | scr->setSelExtentXY(x,y); |
259 | showBulk(); | 260 | showBulk(); |
260 | } | 261 | } |
261 | 262 | ||
262 | void TEmulation::setSelection(const BOOL preserve_line_breaks) { | 263 | void TEmulation::setSelection(const BOOL preserve_line_breaks) { |
263 | if (!connected) return; | 264 | if (!connected) return; |
264 | QString t = scr->getSelText(preserve_line_breaks); | 265 | QString t = scr->getSelText(preserve_line_breaks); |
265 | if (!t.isNull()) gui->setSelection(t); | 266 | if (!t.isNull()) gui->setSelection(t); |
266 | } | 267 | } |
267 | 268 | ||
268 | void TEmulation::clearSelection() { | 269 | void TEmulation::clearSelection() { |
269 | if (!connected) return; | 270 | if (!connected) return; |
270 | scr->clearSelection(); | 271 | scr->clearSelection(); |
271 | showBulk(); | 272 | showBulk(); |
272 | } | 273 | } |
273 | 274 | ||
274 | // Refreshing -------------------------------------------------------------- -- | 275 | // Refreshing -------------------------------------------------------------- -- |
275 | 276 | ||
276 | #define BULK_TIMEOUT 20 | 277 | #define BULK_TIMEOUT 20 |
277 | 278 | ||
278 | /*! | 279 | /*! |
279 | called when \n comes in. Evtl. triggers showBulk at endBulk | 280 | called when \n comes in. Evtl. triggers showBulk at endBulk |
280 | */ | 281 | */ |
281 | 282 | ||
282 | void TEmulation::bulkNewline() | 283 | void TEmulation::bulkNewline() |
283 | { | 284 | { |
284 | bulk_nlcnt += 1; | 285 | bulk_nlcnt += 1; |
285 | bulk_incnt = 0; // reset bulk counter since `nl' rule applies | 286 | bulk_incnt = 0; // reset bulk counter since `nl' rule applies |
286 | } | 287 | } |
287 | 288 | ||
288 | /*! | 289 | /*! |
289 | */ | 290 | */ |
290 | 291 | ||
291 | void TEmulation::showBulk() | 292 | void TEmulation::showBulk() |
292 | { | 293 | { |
293 | bulk_nlcnt = 0; // reset bulk newline counter | 294 | bulk_nlcnt = 0; // reset bulk newline counter |
294 | bulk_incnt = 0; // reset bulk counter | 295 | bulk_incnt = 0; // reset bulk counter |
295 | if (connected) | 296 | if (connected) |
296 | { | 297 | { |
297 | ca* image = scr->getCookedImage(); // get the image | 298 | ca* image = scr->getCookedImage(); // get the image |
298 | gui->setImage(image, | 299 | gui->setImage(image, |
299 | scr->getLines(), | 300 | scr->getLines(), |
300 | scr->getColumns()); // actual refresh | 301 | scr->getColumns()); // actual refresh |
301 | free(image); | 302 | free(image); |
302 | //FIXME: check that we do not trigger other draw event here. | 303 | //FIXME: check that we do not trigger other draw event here. |
303 | gui->setScroll(scr->getHistCursor(),scr->getHistLines()); | 304 | gui->setScroll(scr->getHistCursor(),scr->getHistLines()); |
304 | } | 305 | } |
305 | } | 306 | } |
306 | 307 | ||
307 | void TEmulation::bulkStart() | 308 | void TEmulation::bulkStart() |
308 | { | 309 | { |
309 | if (bulk_timer.isActive()) bulk_timer.stop(); | 310 | if (bulk_timer.isActive()) bulk_timer.stop(); |
310 | } | 311 | } |
311 | 312 | ||
312 | void TEmulation::bulkEnd() | 313 | void TEmulation::bulkEnd() |
313 | { | 314 | { |
314 | if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) | 315 | if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) |
315 | showBulk(); // resets bulk_??cnt to 0, too. | 316 | showBulk(); // resets bulk_??cnt to 0, too. |
316 | else | 317 | else |
317 | bulk_timer.start(BULK_TIMEOUT,TRUE); | 318 | bulk_timer.start(BULK_TIMEOUT,TRUE); |
318 | } | 319 | } |
319 | 320 | ||
320 | void TEmulation::setConnect(bool c) | 321 | void TEmulation::setConnect(bool c) |
321 | { | 322 | { |
322 | connected = c; | 323 | connected = c; |
323 | if ( connected) | 324 | if ( connected) |
324 | { | 325 | { |
325 | onImageSizeChange(gui->Lines(), gui->Columns()); | 326 | onImageSizeChange(gui->Lines(), gui->Columns()); |
326 | showBulk(); | 327 | showBulk(); |
327 | } | 328 | } |
328 | else | 329 | else |
329 | { | 330 | { |
330 | scr->clearSelection(); | 331 | scr->clearSelection(); |
331 | } | 332 | } |
332 | } | 333 | } |
333 | 334 | ||
334 | // --------------------------------------------------------------------------- | 335 | // --------------------------------------------------------------------------- |
335 | 336 | ||
336 | /*! triggered by image size change of the TEWidget `gui'. | 337 | /*! triggered by image size change of the TEWidget `gui'. |
337 | 338 | ||
338 | This event is simply propagated to the attached screens | 339 | This event is simply propagated to the attached screens |
339 | and to the related serial line. | 340 | and to the related serial line. |
340 | */ | 341 | */ |
341 | 342 | ||
342 | void TEmulation::onImageSizeChange(int lines, int columns) | 343 | void TEmulation::onImageSizeChange(int lines, int columns) |
343 | { | 344 | { |
344 | if (!connected) return; | 345 | if (!connected) return; |
345 | screen[0]->resizeImage(lines,columns); | 346 | screen[0]->resizeImage(lines,columns); |
346 | screen[1]->resizeImage(lines,columns); | 347 | screen[1]->resizeImage(lines,columns); |
347 | showBulk(); | 348 | showBulk(); |
348 | emit ImageSizeChanged(lines,columns); // propagate event to serial line | 349 | emit ImageSizeChanged(lines,columns); // propagate event to serial line |
349 | } | 350 | } |
350 | 351 | ||
351 | void TEmulation::onHistoryCursorChange(int cursor) | 352 | void TEmulation::onHistoryCursorChange(int cursor) |
352 | { | 353 | { |
353 | if (!connected) return; | 354 | if (!connected) return; |
354 | scr->setHistCursor(cursor); | 355 | scr->setHistCursor(cursor); |
355 | showBulk(); | 356 | showBulk(); |
356 | } | 357 | } |
357 | 358 | ||
358 | void TEmulation::setColumns(int columns) | 359 | void TEmulation::setColumns(int columns) |
359 | { | 360 | { |
360 | //FIXME: this goes strange ways. | 361 | //FIXME: this goes strange ways. |
361 | // Can we put this straight or explain it at least? | 362 | // Can we put this straight or explain it at least? |
362 | emit changeColumns(columns); | 363 | emit changeColumns(columns); |
363 | } | 364 | } |
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h index d5f7eab..97a1e1c 100644 --- a/noncore/apps/opie-console/io_layer.h +++ b/noncore/apps/opie-console/io_layer.h | |||
@@ -1,126 +1,126 @@ | |||
1 | #ifndef OPIE_IO_LAYER_H | 1 | #ifndef OPIE_IO_LAYER_H |
2 | #define OPIE_IO_LAYER_H | 2 | #define OPIE_IO_LAYER_H |
3 | 3 | ||
4 | #include <qbitarray.h> | 4 | #include <qbitarray.h> |
5 | #include <qobject.h> | 5 | #include <qobject.h> |
6 | 6 | ||
7 | 7 | ||
8 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
9 | 9 | ||
10 | #include "profile.h" | 10 | #include "profile.h" |
11 | 11 | ||
12 | /** | 12 | /** |
13 | * This is the base class for IO Layers | 13 | * This is the base class for IO Layers |
14 | * It will used to sent and recv data( QByteArray ) | 14 | * It will used to sent and recv data( QByteArray ) |
15 | * it | 15 | * it |
16 | */ | 16 | */ |
17 | class IOLayer : public QObject { | 17 | class IOLayer : public QObject { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | enum Error { | 20 | enum Error { |
21 | NoError = -1, | 21 | NoError = -1, |
22 | Refuse = 0, | 22 | Refuse = 0, |
23 | CouldNotOpen =1, | 23 | CouldNotOpen =1, |
24 | ClosedUnexpected =2, | 24 | ClosedUnexpected =2, |
25 | ClosedError =3, | 25 | ClosedError =3, |
26 | Terminate = 4 | 26 | Terminate = 4 |
27 | /* add more errors here */ | 27 | /* add more errors here */ |
28 | }; | 28 | }; |
29 | enum Feature { | 29 | enum Feature { |
30 | AutoConnect = 0, | 30 | AutoConnect = 0, |
31 | TransferFile =1, | 31 | TransferFile =1, |
32 | Close =2 | 32 | Close =2 |
33 | }; | 33 | }; |
34 | /** | 34 | /** |
35 | * a small c'tor | 35 | * a small c'tor |
36 | */ | 36 | */ |
37 | IOLayer(); | 37 | IOLayer(); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * create an IOLayer instance from a config file | 40 | * create an IOLayer instance from a config file |
41 | * the currently set group stores the profile/session | 41 | * the currently set group stores the profile/session |
42 | * information | 42 | * information |
43 | */ | 43 | */ |
44 | IOLayer( const Profile& ); | 44 | IOLayer( const Profile& ); |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * destructor | 47 | * destructor |
48 | */ | 48 | */ |
49 | virtual ~IOLayer(); | 49 | virtual ~IOLayer(); |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * a small internal identifier | 52 | * a small internal identifier |
53 | */ | 53 | */ |
54 | virtual QString identifier() const = 0; | 54 | virtual QString identifier() const = 0; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * a short name | 57 | * a short name |
58 | */ | 58 | */ |
59 | virtual QString name() const = 0; | 59 | virtual QString name() const = 0; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * a file descriptor which opens | 62 | * a file descriptor which opens |
63 | * the device for io but does not | 63 | * the device for io but does not |
64 | * do any ioctling on it... | 64 | * do any ioctling on it... |
65 | * and it'll stop listening to the before opened | 65 | * and it'll stop listening to the before opened |
66 | * device | 66 | * device |
67 | */ | 67 | */ |
68 | virtual int rawIO()const; | 68 | virtual int rawIO()const; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * will close the rawIO stuff | 71 | * will close the rawIO stuff |
72 | * and will listen to it's data again... | 72 | * and will listen to it's data again... |
73 | */ | 73 | */ |
74 | virtual void closeRawIO(int); | 74 | virtual void closeRawIO(int); |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * What does the IOLayer support? | 77 | * What does the IOLayer support? |
78 | * Bits are related to features | 78 | * Bits are related to features |
79 | */ | 79 | */ |
80 | virtual QBitArray supports()const = 0; | 80 | virtual QBitArray supports()const = 0; |
81 | 81 | ||
82 | virtual bool isConnected() = 0; | 82 | virtual bool isConnected() = 0; |
83 | 83 | ||
84 | signals: | 84 | signals: |
85 | /** | 85 | /** |
86 | * received input as QCString | 86 | * received input as QCString |
87 | */ | 87 | */ |
88 | virtual void received( const QByteArray& ); | 88 | virtual void received( const QByteArray& ); |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * an error occured | 91 | * an error occured |
92 | * int for the error number | 92 | * int for the error number |
93 | * and QString for a text | 93 | * and QString for a text |
94 | */ | 94 | */ |
95 | virtual void error( int, const QString& ); | 95 | virtual void error( int, const QString& ); |
96 | 96 | ||
97 | virtual void closed(); | 97 | virtual void closed(); |
98 | public slots: | 98 | public slots: |
99 | /** | 99 | /** |
100 | * send a QCString to the device | 100 | * send a QCString to the device |
101 | */ | 101 | */ |
102 | virtual void send( const QByteArray& ) = 0; | 102 | virtual void send( const QByteArray& ) = 0; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * bool open | 105 | * bool open |
106 | */ | 106 | */ |
107 | virtual bool open() = 0; | 107 | virtual bool open() = 0; |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * close the io | 110 | * close the io |
111 | */ | 111 | */ |
112 | virtual void close() = 0; | 112 | virtual void close() = 0; |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * closes and reloads the settings | 115 | * closes and reloads the settings |
116 | */ | 116 | */ |
117 | virtual void reload( const Profile& ) = 0; | 117 | virtual void reload( const Profile& ) = 0; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * set the size | 120 | * set the size |
121 | * needed for pty | 121 | * needed for pty |
122 | */ | 122 | */ |
123 | virtual void setSize(int rows, int cols ); | 123 | virtual void setSize(int lines, int cols ); |
124 | }; | 124 | }; |
125 | 125 | ||
126 | #endif | 126 | #endif |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 0c89620..a7541f0 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,320 +1,323 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | 11 | ||
12 | #include <qpe/resource.h> | 12 | #include <qpe/resource.h> |
13 | 13 | ||
14 | #include <opie/ofiledialog.h> | 14 | #include <opie/ofiledialog.h> |
15 | 15 | ||
16 | #include "keytrans.h" | 16 | #include "keytrans.h" |
17 | #include "profileeditordialog.h" | 17 | #include "profileeditordialog.h" |
18 | #include "configdialog.h" | 18 | #include "configdialog.h" |
19 | #include "default.h" | 19 | #include "default.h" |
20 | #include "metafactory.h" | 20 | #include "metafactory.h" |
21 | #include "profile.h" | 21 | #include "profile.h" |
22 | #include "profilemanager.h" | 22 | #include "profilemanager.h" |
23 | #include "mainwindow.h" | 23 | #include "mainwindow.h" |
24 | #include "tabwidget.h" | 24 | #include "tabwidget.h" |
25 | #include "transferdialog.h" | 25 | #include "transferdialog.h" |
26 | #include "function_keyboard.h" | 26 | #include "function_keyboard.h" |
27 | #include "emulation_handler.h" | 27 | #include "emulation_handler.h" |
28 | #include "script.h" | 28 | #include "script.h" |
29 | #include "quick_button.h" | 29 | #include "quick_button.h" |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 33 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
34 | KeyTrans::loadAll(); | 34 | KeyTrans::loadAll(); |
35 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 35 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
36 | KeyTrans* s = KeyTrans::find(i ); | 36 | KeyTrans* s = KeyTrans::find(i ); |
37 | assert( s ); | 37 | assert( s ); |
38 | } | 38 | } |
39 | m_factory = new MetaFactory(); | 39 | m_factory = new MetaFactory(); |
40 | Default def(m_factory); | 40 | Default def(m_factory); |
41 | m_sessions.setAutoDelete( TRUE ); | 41 | m_sessions.setAutoDelete( TRUE ); |
42 | m_curSession = 0; | 42 | m_curSession = 0; |
43 | m_manager = new ProfileManager( m_factory ); | 43 | m_manager = new ProfileManager( m_factory ); |
44 | m_manager->load(); | 44 | m_manager->load(); |
45 | 45 | ||
46 | initUI(); | 46 | initUI(); |
47 | populateProfiles(); | 47 | populateProfiles(); |
48 | } | 48 | } |
49 | void MainWindow::initUI() { | 49 | void MainWindow::initUI() { |
50 | setToolBarsMovable( FALSE ); | 50 | setToolBarsMovable( FALSE ); |
51 | 51 | ||
52 | /* tool bar for the menu */ | 52 | /* tool bar for the menu */ |
53 | m_tool = new QToolBar( this ); | 53 | m_tool = new QToolBar( this ); |
54 | m_tool->setHorizontalStretchable( TRUE ); | 54 | m_tool->setHorizontalStretchable( TRUE ); |
55 | 55 | ||
56 | m_bar = new QMenuBar( m_tool ); | 56 | m_bar = new QMenuBar( m_tool ); |
57 | m_console = new QPopupMenu( this ); | 57 | m_console = new QPopupMenu( this ); |
58 | m_scripts = new QPopupMenu( this ); | 58 | m_scripts = new QPopupMenu( this ); |
59 | m_sessionsPop= new QPopupMenu( this ); | 59 | m_sessionsPop= new QPopupMenu( this ); |
60 | //m_settings = new QPopupMenu( this ); | 60 | //m_settings = new QPopupMenu( this ); |
61 | 61 | ||
62 | /* add a toolbar for icons */ | 62 | /* add a toolbar for icons */ |
63 | m_icons = new QToolBar(this); | 63 | m_icons = new QToolBar(this); |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | /* | 68 | /* |
69 | * the settings action | 69 | * the settings action |
70 | */ | 70 | */ |
71 | m_setProfiles = new QAction(tr("Configure Profiles"), | 71 | m_setProfiles = new QAction(tr("Configure Profiles"), |
72 | Resource::loadPixmap( "SettingsIcon" ), | 72 | Resource::loadPixmap( "SettingsIcon" ), |
73 | QString::null, 0, this, 0); | 73 | QString::null, 0, this, 0); |
74 | // m_setProfiles->addTo( m_settings ); | 74 | // m_setProfiles->addTo( m_settings ); |
75 | m_setProfiles->addTo( m_icons ); | 75 | m_setProfiles->addTo( m_icons ); |
76 | m_setProfiles->addTo( m_console ); | 76 | m_setProfiles->addTo( m_console ); |
77 | connect( m_setProfiles, SIGNAL(activated() ), | 77 | connect( m_setProfiles, SIGNAL(activated() ), |
78 | this, SLOT(slotConfigure() ) ); | 78 | this, SLOT(slotConfigure() ) ); |
79 | 79 | ||
80 | 80 | m_console->insertSeparator(); | |
81 | /* | 81 | /* |
82 | * new Action for new sessions | 82 | * new Action for new sessions |
83 | */ | 83 | */ |
84 | QAction* a = new QAction(tr("New Connection"), | 84 | QAction* a = new QAction(tr("New Connection"), |
85 | Resource::loadPixmap( "new" ), | 85 | Resource::loadPixmap( "new" ), |
86 | QString::null, 0, this, 0); | 86 | QString::null, 0, this, 0); |
87 | a->addTo( m_console ); | 87 | a->addTo( m_console ); |
88 | a->addTo( m_icons ); | 88 | a->addTo( m_icons ); |
89 | connect(a, SIGNAL(activated() ), | 89 | connect(a, SIGNAL(activated() ), |
90 | this, SLOT(slotNew() ) ); | 90 | this, SLOT(slotNew() ) ); |
91 | 91 | ||
92 | /* | 92 | /* |
93 | * connect action | 93 | * connect action |
94 | */ | 94 | */ |
95 | m_connect = new QAction(); | 95 | m_connect = new QAction(); |
96 | m_connect->setText( tr("Connect") ); | 96 | m_connect->setText( tr("Connect") ); |
97 | m_connect->addTo( m_console ); | 97 | m_connect->addTo( m_console ); |
98 | connect(m_connect, SIGNAL(activated() ), | 98 | connect(m_connect, SIGNAL(activated() ), |
99 | this, SLOT(slotConnect() ) ); | 99 | this, SLOT(slotConnect() ) ); |
100 | 100 | ||
101 | /* | 101 | /* |
102 | * disconnect action | 102 | * disconnect action |
103 | */ | 103 | */ |
104 | m_disconnect = new QAction(); | 104 | m_disconnect = new QAction(); |
105 | m_disconnect->setText( tr("Disconnect") ); | 105 | m_disconnect->setText( tr("Disconnect") ); |
106 | m_disconnect->addTo( m_console ); | 106 | m_disconnect->addTo( m_console ); |
107 | connect(m_disconnect, SIGNAL(activated() ), | 107 | connect(m_disconnect, SIGNAL(activated() ), |
108 | this, SLOT(slotDisconnect() ) ); | 108 | this, SLOT(slotDisconnect() ) ); |
109 | 109 | ||
110 | m_console->insertSeparator(); | ||
111 | |||
110 | m_transfer = new QAction(); | 112 | m_transfer = new QAction(); |
111 | m_transfer->setText( tr("Transfer file...") ); | 113 | m_transfer->setText( tr("Transfer file...") ); |
112 | m_transfer->addTo( m_console ); | 114 | m_transfer->addTo( m_console ); |
113 | connect(m_transfer, SIGNAL(activated() ), | 115 | connect(m_transfer, SIGNAL(activated() ), |
114 | this, SLOT(slotTransfer() ) ); | 116 | this, SLOT(slotTransfer() ) ); |
115 | 117 | ||
116 | 118 | ||
117 | /* | 119 | /* |
118 | * fullscreen | 120 | * fullscreen |
119 | */ | 121 | */ |
120 | m_isFullscreen = false; | 122 | m_isFullscreen = false; |
121 | 123 | ||
122 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 124 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
123 | , QString::null, 0, this, 0); | 125 | , QString::null, 0, this, 0); |
124 | m_fullscreen->addTo( m_console ); | 126 | m_fullscreen->addTo( m_console ); |
125 | m_fullscreen->addTo( m_icons ); | 127 | m_fullscreen->addTo( m_icons ); |
126 | connect( m_fullscreen, SIGNAL( activated() ), | 128 | connect( m_fullscreen, SIGNAL( activated() ), |
127 | this, SLOT( slotFullscreen() ) ); | 129 | this, SLOT( slotFullscreen() ) ); |
128 | 130 | ||
131 | m_console->insertSeparator(); | ||
129 | /* | 132 | /* |
130 | * terminate action | 133 | * terminate action |
131 | */ | 134 | */ |
132 | m_terminate = new QAction(); | 135 | m_terminate = new QAction(); |
133 | m_terminate->setText( tr("Terminate") ); | 136 | m_terminate->setText( tr("Terminate") ); |
134 | m_terminate->addTo( m_console ); | 137 | m_terminate->addTo( m_console ); |
135 | connect(m_terminate, SIGNAL(activated() ), | 138 | connect(m_terminate, SIGNAL(activated() ), |
136 | this, SLOT(slotTerminate() ) ); | 139 | this, SLOT(slotTerminate() ) ); |
137 | 140 | ||
138 | m_closewindow = new QAction(); | 141 | m_closewindow = new QAction(); |
139 | m_closewindow->setText( tr("Close Window") ); | 142 | m_closewindow->setText( tr("Close Window") ); |
140 | m_closewindow->addTo( m_console ); | 143 | m_closewindow->addTo( m_console ); |
141 | connect( m_closewindow, SIGNAL(activated() ), | 144 | connect( m_closewindow, SIGNAL(activated() ), |
142 | this, SLOT(slotClose() ) ); | 145 | this, SLOT(slotClose() ) ); |
143 | 146 | ||
144 | 147 | ||
145 | /* | 148 | /* |
146 | * script actions | 149 | * script actions |
147 | */ | 150 | */ |
148 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 151 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
149 | m_recordScript->addTo(m_scripts); | 152 | m_recordScript->addTo(m_scripts); |
150 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 153 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
151 | 154 | ||
152 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 155 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
153 | m_saveScript->addTo(m_scripts); | 156 | m_saveScript->addTo(m_scripts); |
154 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 157 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
155 | 158 | ||
156 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | 159 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); |
157 | m_runScript->addTo(m_scripts); | 160 | m_runScript->addTo(m_scripts); |
158 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | 161 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); |
159 | 162 | ||
160 | /* | 163 | /* |
161 | * action that open/closes the keyboard | 164 | * action that open/closes the keyboard |
162 | */ | 165 | */ |
163 | m_openKeys = new QAction (tr("Open Keyboard..."), | 166 | m_openKeys = new QAction (tr("Open Keyboard..."), |
164 | Resource::loadPixmap( "console/keyboard_icon.png" ), | 167 | Resource::loadPixmap( "console/keyboard_icon.png" ), |
165 | QString::null, 0, this, 0); | 168 | QString::null, 0, this, 0); |
166 | 169 | ||
167 | m_openKeys->setToggleAction(true); | 170 | m_openKeys->setToggleAction(true); |
168 | 171 | ||
169 | connect (m_openKeys, SIGNAL(toggled(bool)), | 172 | connect (m_openKeys, SIGNAL(toggled(bool)), |
170 | this, SLOT(slotOpenKeb(bool))); | 173 | this, SLOT(slotOpenKeb(bool))); |
171 | m_openKeys->addTo(m_icons); | 174 | m_openKeys->addTo(m_icons); |
172 | 175 | ||
173 | 176 | ||
174 | /* | 177 | /* |
175 | * action that open/closes the keyboard | 178 | * action that open/closes the keyboard |
176 | */ | 179 | */ |
177 | m_openButtons = new QAction ( tr( "Open Buttons..." ), | 180 | m_openButtons = new QAction ( tr( "Open Buttons..." ), |
178 | Resource::loadPixmap( "down" ), | 181 | Resource::loadPixmap( "down" ), |
179 | QString::null, 0, this, 0 ); | 182 | QString::null, 0, this, 0 ); |
180 | 183 | ||
181 | m_openButtons->setToggleAction( true ); | 184 | m_openButtons->setToggleAction( true ); |
182 | 185 | ||
183 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), | 186 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), |
184 | this, SLOT( slotOpenButtons( bool ) ) ); | 187 | this, SLOT( slotOpenButtons( bool ) ) ); |
185 | m_openButtons->addTo( m_icons ); | 188 | m_openButtons->addTo( m_icons ); |
186 | 189 | ||
187 | 190 | ||
188 | /* insert the submenu */ | 191 | /* insert the submenu */ |
189 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 192 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
190 | -1, 0); | 193 | -1, 0); |
191 | 194 | ||
192 | /* insert the connection menu */ | 195 | /* insert the connection menu */ |
193 | m_bar->insertItem( tr("Connection"), m_console ); | 196 | m_bar->insertItem( tr("Connection"), m_console ); |
194 | 197 | ||
195 | /* the scripts menu */ | 198 | /* the scripts menu */ |
196 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 199 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
197 | 200 | ||
198 | /* the settings menu */ | 201 | /* the settings menu */ |
199 | // m_bar->insertItem( tr("Settings"), m_settings ); | 202 | // m_bar->insertItem( tr("Settings"), m_settings ); |
200 | 203 | ||
201 | /* and the keyboard */ | 204 | /* and the keyboard */ |
202 | m_keyBar = new QToolBar(this); | 205 | m_keyBar = new QToolBar(this); |
203 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 206 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
204 | m_keyBar->setHorizontalStretchable( TRUE ); | 207 | m_keyBar->setHorizontalStretchable( TRUE ); |
205 | m_keyBar->hide(); | 208 | m_keyBar->hide(); |
206 | 209 | ||
207 | m_kb = new FunctionKeyboard(m_keyBar); | 210 | m_kb = new FunctionKeyboard(m_keyBar); |
208 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), | 211 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), |
209 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); | 212 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); |
210 | 213 | ||
211 | m_buttonBar = new QToolBar( this ); | 214 | m_buttonBar = new QToolBar( this ); |
212 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); | 215 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); |
213 | m_buttonBar->setHorizontalStretchable( TRUE ); | 216 | m_buttonBar->setHorizontalStretchable( TRUE ); |
214 | m_buttonBar->hide(); | 217 | m_buttonBar->hide(); |
215 | 218 | ||
216 | m_qb = new QuickButton( m_buttonBar ); | 219 | m_qb = new QuickButton( m_buttonBar ); |
217 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), | 220 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), |
218 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); | 221 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); |
219 | 222 | ||
220 | 223 | ||
221 | m_connect->setEnabled( false ); | 224 | m_connect->setEnabled( false ); |
222 | m_disconnect->setEnabled( false ); | 225 | m_disconnect->setEnabled( false ); |
223 | m_terminate->setEnabled( false ); | 226 | m_terminate->setEnabled( false ); |
224 | m_transfer->setEnabled( false ); | 227 | m_transfer->setEnabled( false ); |
225 | m_recordScript->setEnabled( false ); | 228 | m_recordScript->setEnabled( false ); |
226 | m_saveScript->setEnabled( false ); | 229 | m_saveScript->setEnabled( false ); |
227 | m_runScript->setEnabled( false ); | 230 | m_runScript->setEnabled( false ); |
228 | m_fullscreen->setEnabled( false ); | 231 | m_fullscreen->setEnabled( false ); |
229 | m_closewindow->setEnabled( false ); | 232 | m_closewindow->setEnabled( false ); |
230 | 233 | ||
231 | /* | 234 | /* |
232 | * connect to the menu activation | 235 | * connect to the menu activation |
233 | */ | 236 | */ |
234 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 237 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
235 | this, SLOT(slotProfile( int ) ) ); | 238 | this, SLOT(slotProfile( int ) ) ); |
236 | 239 | ||
237 | m_consoleWindow = new TabWidget( this, "blah"); | 240 | m_consoleWindow = new TabWidget( this, "blah"); |
238 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 241 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
239 | this, SLOT(slotSessionChanged(Session*) ) ); | 242 | this, SLOT(slotSessionChanged(Session*) ) ); |
240 | setCentralWidget( m_consoleWindow ); | 243 | setCentralWidget( m_consoleWindow ); |
241 | 244 | ||
242 | } | 245 | } |
243 | 246 | ||
244 | ProfileManager* MainWindow::manager() { | 247 | ProfileManager* MainWindow::manager() { |
245 | return m_manager; | 248 | return m_manager; |
246 | } | 249 | } |
247 | TabWidget* MainWindow::tabWidget() { | 250 | TabWidget* MainWindow::tabWidget() { |
248 | return m_consoleWindow; | 251 | return m_consoleWindow; |
249 | } | 252 | } |
250 | void MainWindow::populateProfiles() { | 253 | void MainWindow::populateProfiles() { |
251 | m_sessionsPop->clear(); | 254 | m_sessionsPop->clear(); |
252 | Profile::ValueList list = manager()->all(); | 255 | Profile::ValueList list = manager()->all(); |
253 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 256 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
254 | m_sessionsPop->insertItem( (*it).name() ); | 257 | m_sessionsPop->insertItem( (*it).name() ); |
255 | } | 258 | } |
256 | 259 | ||
257 | } | 260 | } |
258 | MainWindow::~MainWindow() { | 261 | MainWindow::~MainWindow() { |
259 | delete m_factory; | 262 | delete m_factory; |
260 | manager()->save(); | 263 | manager()->save(); |
261 | } | 264 | } |
262 | 265 | ||
263 | MetaFactory* MainWindow::factory() { | 266 | MetaFactory* MainWindow::factory() { |
264 | return m_factory; | 267 | return m_factory; |
265 | } | 268 | } |
266 | 269 | ||
267 | Session* MainWindow::currentSession() { | 270 | Session* MainWindow::currentSession() { |
268 | return m_curSession; | 271 | return m_curSession; |
269 | } | 272 | } |
270 | 273 | ||
271 | QList<Session> MainWindow::sessions() { | 274 | QList<Session> MainWindow::sessions() { |
272 | return m_sessions; | 275 | return m_sessions; |
273 | } | 276 | } |
274 | 277 | ||
275 | void MainWindow::slotNew() { | 278 | void MainWindow::slotNew() { |
276 | ProfileEditorDialog dlg(factory() ); | 279 | ProfileEditorDialog dlg(factory() ); |
277 | dlg.showMaximized(); | 280 | dlg.showMaximized(); |
278 | int ret = dlg.exec(); | 281 | int ret = dlg.exec(); |
279 | 282 | ||
280 | if ( ret == QDialog::Accepted ) { | 283 | if ( ret == QDialog::Accepted ) { |
281 | create( dlg.profile() ); | 284 | create( dlg.profile() ); |
282 | } | 285 | } |
283 | } | 286 | } |
284 | 287 | ||
285 | void MainWindow::slotRecordScript() { | 288 | void MainWindow::slotRecordScript() { |
286 | /* if (currentSession()) { | 289 | /* if (currentSession()) { |
287 | currentSession()->emulationLayer()->startRecording(); | 290 | currentSession()->emulationLayer()->startRecording(); |
288 | } | 291 | } |
289 | */ | 292 | */ |
290 | } | 293 | } |
291 | 294 | ||
292 | void MainWindow::slotSaveScript() { | 295 | void MainWindow::slotSaveScript() { |
293 | /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { | 296 | /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { |
294 | MimeTypes types; | 297 | MimeTypes types; |
295 | QStringList script; | 298 | QStringList script; |
296 | script << "text/plain"; | 299 | script << "text/plain"; |
297 | types.insert("Script", script); | 300 | types.insert("Script", script); |
298 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | 301 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); |
299 | if (!filename.isEmpty()) { | 302 | if (!filename.isEmpty()) { |
300 | currentSession()->emulationLayer()->script()->saveTo(filename); | 303 | currentSession()->emulationLayer()->script()->saveTo(filename); |
301 | currentSession()->emulationLayer()->clearScript(); | 304 | currentSession()->emulationLayer()->clearScript(); |
302 | } | 305 | } |
303 | } | 306 | } |
304 | */ | 307 | */ |
305 | } | 308 | } |
306 | 309 | ||
307 | void MainWindow::slotRunScript() { | 310 | void MainWindow::slotRunScript() { |
308 | /* | 311 | /* |
309 | if (currentSession()) { | 312 | if (currentSession()) { |
310 | MimeTypes types; | 313 | MimeTypes types; |
311 | QStringList script; | 314 | QStringList script; |
312 | script << "text/plain"; | 315 | script << "text/plain"; |
313 | types.insert("Script", script); | 316 | types.insert("Script", script); |
314 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | 317 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); |
315 | if (!filename.isEmpty()) { | 318 | if (!filename.isEmpty()) { |
316 | Script script(DocLnk(filename).file()); | 319 | Script script(DocLnk(filename).file()); |
317 | currentSession()->emulationLayer()->runScript(&script); | 320 | currentSession()->emulationLayer()->runScript(&script); |
318 | } | 321 | } |
319 | } | 322 | } |
320 | */ | 323 | */ |
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index 2ce6872..03d0fcd 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp | |||
@@ -1,98 +1,100 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "io_layer.h" | 3 | #include "io_layer.h" |
4 | #include "file_layer.h" | 4 | #include "file_layer.h" |
5 | #include "emulation_handler.h" | 5 | #include "emulation_handler.h" |
6 | #include "session.h" | 6 | #include "session.h" |
7 | 7 | ||
8 | 8 | ||
9 | Session::Session() { | 9 | Session::Session() { |
10 | m_widget = 0l; | 10 | m_widget = 0l; |
11 | m_layer = 0l; | 11 | m_layer = 0l; |
12 | m_emu = 0l; | 12 | m_emu = 0l; |
13 | } | 13 | } |
14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) | 14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) |
15 | : m_name( na ), m_widget( widget ), m_layer( lay ) | 15 | : m_name( na ), m_widget( widget ), m_layer( lay ) |
16 | { | 16 | { |
17 | // m_widLay = 0l; | 17 | // m_widLay = 0l; |
18 | // m_emLay = 0l; | 18 | // m_emLay = 0l; |
19 | m_emu = 0l; | 19 | m_emu = 0l; |
20 | } | 20 | } |
21 | Session::~Session() { | 21 | Session::~Session() { |
22 | delete m_layer; | 22 | delete m_layer; |
23 | delete m_emu; | 23 | delete m_emu; |
24 | delete m_widget; | 24 | delete m_widget; |
25 | /* the widget layer should be deleted by the m_widget */ | 25 | /* the widget layer should be deleted by the m_widget */ |
26 | } | 26 | } |
27 | QString Session::name()const { | 27 | QString Session::name()const { |
28 | return m_name; | 28 | return m_name; |
29 | } | 29 | } |
30 | QWidgetStack* Session::widgetStack() { | 30 | QWidgetStack* Session::widgetStack() { |
31 | return m_widget; | 31 | return m_widget; |
32 | } | 32 | } |
33 | IOLayer* Session::layer() { | 33 | IOLayer* Session::layer() { |
34 | return m_layer; | 34 | return m_layer; |
35 | } | 35 | } |
36 | EmulationHandler* Session::emulationHandler() { | 36 | EmulationHandler* Session::emulationHandler() { |
37 | return m_emu; | 37 | return m_emu; |
38 | } | 38 | } |
39 | QWidget* Session::widget() { | 39 | QWidget* Session::widget() { |
40 | if (!m_emu ) | 40 | if (!m_emu ) |
41 | return 0l; | 41 | return 0l; |
42 | 42 | ||
43 | return m_emu->widget(); | 43 | return m_emu->widget(); |
44 | } | 44 | } |
45 | /* | 45 | /* |
46 | WidgetLayer* Session::emulationWidget() { | 46 | WidgetLayer* Session::emulationWidget() { |
47 | return m_widLay; | 47 | return m_widLay; |
48 | } | 48 | } |
49 | */ | 49 | */ |
50 | void Session::connect() { | 50 | void Session::connect() { |
51 | if ( !m_layer || !m_emu ) | 51 | if ( !m_layer || !m_emu ) |
52 | return; | 52 | return; |
53 | 53 | ||
54 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), | 54 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), |
55 | m_emu, SLOT(recv(const QByteArray&) ) ); | 55 | m_emu, SLOT(recv(const QByteArray&) ) ); |
56 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), | 56 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), |
57 | m_layer, SLOT(send(const QByteArray&) ) ); | 57 | m_layer, SLOT(send(const QByteArray&) ) ); |
58 | QObject::connect(m_emu, SIGNAL(changeSize(int, int) ), | ||
59 | m_layer, SLOT(setSize(int, int) ) ); | ||
58 | } | 60 | } |
59 | 61 | ||
60 | void Session::disconnect() { | 62 | void Session::disconnect() { |
61 | 63 | ||
62 | if ( !m_layer || !m_emu ) | 64 | if ( !m_layer || !m_emu ) |
63 | return; | 65 | return; |
64 | 66 | ||
65 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), | 67 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), |
66 | m_emu, SLOT(recv(const QByteArray&) ) ); | 68 | m_emu, SLOT(recv(const QByteArray&) ) ); |
67 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), | 69 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), |
68 | m_layer, SLOT(send(const QByteArray&) ) ); | 70 | m_layer, SLOT(send(const QByteArray&) ) ); |
69 | } | 71 | } |
70 | 72 | ||
71 | void Session::setName( const QString& na){ | 73 | void Session::setName( const QString& na){ |
72 | m_name = na; | 74 | m_name = na; |
73 | } | 75 | } |
74 | 76 | ||
75 | void Session::setWidgetStack( QWidgetStack* wid ) { | 77 | void Session::setWidgetStack( QWidgetStack* wid ) { |
76 | delete m_emu; | 78 | delete m_emu; |
77 | m_emu = 0l; | 79 | m_emu = 0l; |
78 | delete m_widget; | 80 | delete m_widget; |
79 | /* the EmulationLayer was destroyed... */ | 81 | /* the EmulationLayer was destroyed... */ |
80 | 82 | ||
81 | m_widget = wid; | 83 | m_widget = wid; |
82 | } | 84 | } |
83 | void Session::setIOLayer( IOLayer* lay ) { | 85 | void Session::setIOLayer( IOLayer* lay ) { |
84 | delete m_layer; | 86 | delete m_layer; |
85 | m_layer = lay; | 87 | m_layer = lay; |
86 | } | 88 | } |
87 | 89 | ||
88 | void Session::setEmulationHandler( EmulationHandler* lay ) { | 90 | void Session::setEmulationHandler( EmulationHandler* lay ) { |
89 | delete m_emu; | 91 | delete m_emu; |
90 | m_emu = lay; | 92 | m_emu = lay; |
91 | } | 93 | } |
92 | /* | 94 | /* |
93 | void Session::setEmulationWidget( WidgetLayer* lay ) { | 95 | void Session::setEmulationWidget( WidgetLayer* lay ) { |
94 | delete m_widLay; | 96 | delete m_widLay; |
95 | m_widLay = lay; | 97 | m_widLay = lay; |
96 | } | 98 | } |
97 | */ | 99 | */ |
98 | 100 | ||