-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 34 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 16 | ||||
-rw-r--r-- | noncore/apps/opie-console/fixit.cpp | 101 | ||||
-rw-r--r-- | noncore/apps/opie-console/fixit.h | 77 | ||||
-rw-r--r-- | noncore/apps/opie-console/logger.cpp | 20 | ||||
-rw-r--r-- | noncore/apps/opie-console/logger.h | 19 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 60 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console-embedix.control | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 14 |
11 files changed, 275 insertions, 81 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 6d57703..315ea4a 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -1,370 +1,371 @@ | |||
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 | #include "procctl.h" | 66 | #include "procctl.h" |
67 | #include "MyPty.h" | 67 | #include "MyPty.h" |
68 | 68 | ||
69 | /* OPIE */ | 69 | /* OPIE */ |
70 | #include <opie2/odebug.h> | 70 | #include <opie2/odebug.h> |
71 | using namespace Opie::Core; | 71 | using namespace Opie::Core; |
72 | 72 | ||
73 | /* QT */ | 73 | /* QT */ |
74 | #include <qsocketnotifier.h> | 74 | #include <qsocketnotifier.h> |
75 | #include <qfile.h> | 75 | #include <qfile.h> |
76 | 76 | ||
77 | /* STD */ | 77 | /* STD */ |
78 | #include <stdlib.h> | 78 | #include <stdlib.h> |
79 | #include <stdio.h> | 79 | #include <stdio.h> |
80 | #include <signal.h> | 80 | #include <signal.h> |
81 | #include <fcntl.h> | 81 | #include <fcntl.h> |
82 | #include <unistd.h> | 82 | #include <unistd.h> |
83 | #include <termios.h> | 83 | #include <termios.h> |
84 | #include <sys/types.h> | 84 | #include <sys/types.h> |
85 | #include <sys/ioctl.h> | 85 | #include <sys/ioctl.h> |
86 | #include <sys/wait.h> | 86 | #include <sys/wait.h> |
87 | 87 | ||
88 | |||
88 | #ifdef HAVE_OPENPTY | 89 | #ifdef HAVE_OPENPTY |
89 | #include <pty.h> | 90 | #include <pty.h> |
90 | #endif | 91 | #endif |
91 | 92 | ||
92 | #undef VERBOSE_DEBUG | 93 | #undef VERBOSE_DEBUG |
93 | 94 | ||
94 | 95 | ||
95 | /* -------------------------------------------------------------------------- */ | 96 | /* -------------------------------------------------------------------------- */ |
96 | 97 | ||
97 | /*! | 98 | /*! |
98 | Informs the client program about the | 99 | Informs the client program about the |
99 | actual size of the window. | 100 | actual size of the window. |
100 | */ | 101 | */ |
101 | 102 | ||
102 | void MyPty::setSize(int lines, int columns) | 103 | void MyPty::setSize(int lines, int columns) |
103 | { | 104 | { |
104 | owarn << "setting size" << oendl; | 105 | owarn << "setting size" << oendl; |
105 | struct winsize wsize; | 106 | struct winsize wsize; |
106 | wsize.ws_row = (unsigned short)lines; | 107 | wsize.ws_row = (unsigned short)lines; |
107 | wsize.ws_col = (unsigned short)columns; | 108 | wsize.ws_col = (unsigned short)columns; |
108 | if(m_fd < 0) return; | 109 | if(m_fd < 0) return; |
109 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); | 110 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); |
110 | } | 111 | } |
111 | 112 | ||
112 | 113 | ||
113 | void MyPty::donePty() | 114 | void MyPty::donePty() |
114 | { | 115 | { |
115 | // This is code from the Qt DumbTerminal example | 116 | // This is code from the Qt DumbTerminal example |
116 | 117 | ||
117 | ::close(m_fd); | 118 | ::close(m_fd); |
118 | 119 | ||
119 | if (m_cpid) { | 120 | if (m_cpid) { |
120 | kill(m_cpid, SIGHUP); | 121 | kill(m_cpid, SIGHUP); |
121 | //waitpid(m_cpid, &status, 0); | 122 | //waitpid(m_cpid, &status, 0); |
122 | delete m_sn_e; | 123 | delete m_sn_e; |
123 | delete m_sn_r; | 124 | delete m_sn_r; |
124 | m_sn_e = 0l; | 125 | m_sn_e = 0l; |
125 | m_sn_r = 0l; | 126 | m_sn_r = 0l; |
126 | } | 127 | } |
127 | 128 | ||
128 | m_cpid = 0; | 129 | m_cpid = 0; |
129 | m_fd = -1; | 130 | m_fd = -1; |
130 | // emit done(status); | 131 | // emit done(status); |
131 | } | 132 | } |
132 | 133 | ||
133 | 134 | ||
134 | const char* MyPty::deviceName() | 135 | const char* MyPty::deviceName() |
135 | { | 136 | { |
136 | return m_ttynam; | 137 | return m_ttynam; |
137 | } | 138 | } |
138 | 139 | ||
139 | 140 | ||
140 | void MyPty::error() | 141 | void MyPty::error() |
141 | { | 142 | { |
142 | // This is code from the Qt DumbTerminal example | 143 | // This is code from the Qt DumbTerminal example |
143 | donePty(); | 144 | donePty(); |
144 | } | 145 | } |
145 | 146 | ||
146 | void MyPty::start() { | 147 | void MyPty::start() { |
147 | QStrList lis; | 148 | QStrList lis; |
148 | int r =run(m_cmd.latin1(), lis, 0, 0); | 149 | int r =run(m_cmd.latin1(), lis, 0, 0); |
149 | r = r; | 150 | r = r; |
150 | } | 151 | } |
151 | /*! | 152 | /*! |
152 | start the client program. | 153 | start the client program. |
153 | */ | 154 | */ |
154 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 155 | int MyPty::run(const char* cmd, QStrList &, const char*, int) |
155 | { | 156 | { |
156 | // This is code from the Qt DumbTerminal example | 157 | // This is code from the Qt DumbTerminal example |
157 | m_cpid = fork(); | 158 | m_cpid = fork(); |
158 | 159 | ||
159 | if ( !m_cpid ) { | 160 | if ( !m_cpid ) { |
160 | // child - exec shell on tty | 161 | // child - exec shell on tty |
161 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); | 162 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); |
162 | int ttyfd = ::open(m_ttynam, O_RDWR); | 163 | int ttyfd = ::open(m_ttynam, O_RDWR); |
163 | dup2(ttyfd, STDIN_FILENO); | 164 | dup2(ttyfd, STDIN_FILENO); |
164 | dup2(ttyfd, STDOUT_FILENO); | 165 | dup2(ttyfd, STDOUT_FILENO); |
165 | dup2(ttyfd, STDERR_FILENO); | 166 | dup2(ttyfd, STDERR_FILENO); |
166 | // should be done with tty, so close it | 167 | // should be done with tty, so close it |
167 | ::close(ttyfd); | 168 | ::close(ttyfd); |
168 | static struct termios ttmode; | 169 | static struct termios ttmode; |
169 | if ( setsid() < 0 ) | 170 | if ( setsid() < 0 ) |
170 | perror( "failed to set process group" ); | 171 | perror( "failed to set process group" ); |
171 | #if defined (TIOCSCTTY) | 172 | #if defined (TIOCSCTTY) |
172 | // grabbed from APUE by Stevens | 173 | // grabbed from APUE by Stevens |
173 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 174 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
174 | #endif | 175 | #endif |
175 | tcgetattr( STDIN_FILENO, &ttmode ); | 176 | tcgetattr( STDIN_FILENO, &ttmode ); |
176 | ttmode.c_cc[VINTR] = 3; | 177 | ttmode.c_cc[VINTR] = 3; |
177 | ttmode.c_cc[VERASE] = 8; | 178 | ttmode.c_cc[VERASE] = 8; |
178 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 179 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
179 | setenv("TERM",m_term,1); | 180 | setenv("TERM",m_term,1); |
180 | setenv("COLORTERM","0",1); | 181 | setenv("COLORTERM","0",1); |
181 | EnvironmentMap::Iterator it; | 182 | EnvironmentMap::Iterator it; |
182 | for (it = m_env.begin(); it != m_env.end(); it++) { | 183 | for (it = m_env.begin(); it != m_env.end(); it++) { |
183 | setenv(it.key().latin1(), it.data().latin1(), 1); | 184 | setenv(it.key().latin1(), it.data().latin1(), 1); |
184 | } | 185 | } |
185 | if (getuid() == 0) { | 186 | if (getuid() == 0) { |
186 | char msg[] = "WARNING: You are running this shell as root!\n"; | 187 | char msg[] = "WARNING: You are running this shell as root!\n"; |
187 | write(ttyfd, msg, sizeof(msg)); | 188 | write(ttyfd, msg, sizeof(msg)); |
188 | } | 189 | } |
189 | execl(cmd, cmd, 0); | 190 | execl(cmd, cmd, 0); |
190 | 191 | ||
191 | donePty(); | 192 | donePty(); |
192 | exit(-1); | 193 | exit(-1); |
193 | } | 194 | } |
194 | 195 | ||
195 | // parent - continue as a widget | 196 | // parent - continue as a widget |
196 | delete m_sn_r; | 197 | delete m_sn_r; |
197 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); | 198 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); |
198 | delete m_sn_e; | 199 | delete m_sn_e; |
199 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); | 200 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); |
200 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); | 201 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); |
201 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); | 202 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); |
202 | 203 | ||
203 | return 0; | 204 | return 0; |
204 | } | 205 | } |
205 | 206 | ||
206 | int MyPty::openPty() | 207 | int MyPty::openPty() |
207 | { | 208 | { |
208 | // This is code from the Qt DumbTerminal example | 209 | // This is code from the Qt DumbTerminal example |
209 | int ptyfd = -1; | 210 | int ptyfd = -1; |
210 | 211 | ||
211 | #ifdef HAVE_OPENPTY | 212 | #ifdef HAVE_OPENPTY |
212 | int ttyfd; | 213 | int ttyfd; |
213 | if ( openpty(&ptyfd,&ttyfd,m_ttynam,0,0) ) | 214 | if ( openpty(&ptyfd,&ttyfd,m_ttynam,0,0) ) |
214 | ptyfd = -1; | 215 | ptyfd = -1; |
215 | else | 216 | else |
216 | ::close(ttyfd); // we open the ttynam ourselves. | 217 | ::close(ttyfd); // we open the ttynam ourselves. |
217 | #else | 218 | #else |
218 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { | 219 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { |
219 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { | 220 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { |
220 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); | 221 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); |
221 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); | 222 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); |
222 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { | 223 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { |
223 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { | 224 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { |
224 | ::close(ptyfd); | 225 | ::close(ptyfd); |
225 | ptyfd = -1; | 226 | ptyfd = -1; |
226 | } | 227 | } |
227 | } | 228 | } |
228 | } | 229 | } |
229 | } | 230 | } |
230 | #endif | 231 | #endif |
231 | 232 | ||
232 | if ( ptyfd < 0 ) { | 233 | if ( ptyfd < 0 ) { |
233 | //qApp->exit(1); | 234 | //qApp->exit(1); |
234 | return -1; | 235 | return -1; |
235 | } | 236 | } |
236 | 237 | ||
237 | return ptyfd; | 238 | return ptyfd; |
238 | } | 239 | } |
239 | 240 | ||
240 | /*! | 241 | /*! |
241 | Create an instance. | 242 | Create an instance. |
242 | */ | 243 | */ |
243 | MyPty::MyPty(const Profile& prof) : m_cpid(0) | 244 | MyPty::MyPty(const Profile& prof) : m_cpid(0) |
244 | { | 245 | { |
245 | 246 | ||
246 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); | 247 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); |
247 | switch( term ) { | 248 | switch( term ) { |
248 | default: | 249 | default: |
249 | case Profile::VT100: | 250 | case Profile::VT100: |
250 | case Profile::VT102: | 251 | case Profile::VT102: |
251 | m_term = "vt100"; | 252 | m_term = "vt100"; |
252 | break; | 253 | break; |
253 | case Profile::Linux: | 254 | case Profile::Linux: |
254 | m_term = "linux"; | 255 | m_term = "linux"; |
255 | break; | 256 | break; |
256 | case Profile::XTerm: | 257 | case Profile::XTerm: |
257 | m_term = "xterm"; | 258 | m_term = "xterm"; |
258 | break; | 259 | break; |
259 | } | 260 | } |
260 | m_sn_e = 0l; | 261 | m_sn_e = 0l; |
261 | m_sn_r = 0l; | 262 | m_sn_r = 0l; |
262 | m_fd = openPty(); | 263 | m_fd = openPty(); |
263 | ProcCtl* ctl = ProcCtl::self(); | 264 | ProcCtl* ctl = ProcCtl::self(); |
264 | Q_UNUSED(ctl); | 265 | Q_UNUSED(ctl); |
265 | reload(prof); | 266 | reload(prof); |
266 | } | 267 | } |
267 | 268 | ||
268 | /*! | 269 | /*! |
269 | Destructor. | 270 | Destructor. |
270 | Note that the related client program is not killed | 271 | Note that the related client program is not killed |
271 | (yet) when a instance is deleted. | 272 | (yet) when a instance is deleted. |
272 | */ | 273 | */ |
273 | MyPty::~MyPty() | 274 | MyPty::~MyPty() |
274 | { | 275 | { |
275 | donePty(); | 276 | donePty(); |
276 | } | 277 | } |
277 | QString MyPty::identifier()const { | 278 | QString MyPty::identifier()const { |
278 | return QString::fromLatin1("term"); | 279 | return QString::fromLatin1("term"); |
279 | } | 280 | } |
280 | QString MyPty::name()const{ | 281 | QString MyPty::name()const{ |
281 | return identifier(); | 282 | return identifier(); |
282 | } | 283 | } |
283 | bool MyPty::open() { | 284 | bool MyPty::open() { |
284 | if (m_fd < 0) | 285 | if (m_fd < 0) |
285 | m_fd = openPty(); | 286 | m_fd = openPty(); |
286 | 287 | ||
287 | start(); | 288 | start(); |
288 | return true; | 289 | return true; |
289 | } | 290 | } |
290 | void MyPty::close() { | 291 | void MyPty::close() { |
291 | donePty(); | 292 | donePty(); |
292 | m_fd = openPty(); | 293 | m_fd = openPty(); |
293 | } | 294 | } |
294 | void MyPty::reload( const Profile& prof) { | 295 | void MyPty::reload( const Profile& prof) { |
295 | m_env.clear(); | 296 | m_env.clear(); |
296 | m_cmd = prof.readEntry("Command", "/bin/sh"); | 297 | m_cmd = prof.readEntry("Command", "/bin/sh"); |
297 | 298 | ||
298 | /* | 299 | /* |
299 | * Lets check if m_cmd actually | 300 | * Lets check if m_cmd actually |
300 | * exists.... | 301 | * exists.... |
301 | * we try to use bin/bash and if | 302 | * we try to use bin/bash and if |
302 | * this fails we | 303 | * this fails we |
303 | * will fallback to /bin/sh | 304 | * will fallback to /bin/sh |
304 | * which should be there 100% | 305 | * which should be there 100% |
305 | */ | 306 | */ |
306 | if ( m_cmd.stripWhiteSpace() == "/bin/bash" && !QFile::exists(QFile::encodeName(m_cmd) ) ) | 307 | if ( m_cmd.stripWhiteSpace() == "/bin/bash" && !QFile::exists(QFile::encodeName(m_cmd) ) ) |
307 | m_cmd = "/bin/sh"; | 308 | m_cmd = "/bin/sh"; |
308 | 309 | ||
309 | 310 | ||
310 | int envcount = prof.readNumEntry("EnvVars", 0); | 311 | int envcount = prof.readNumEntry("EnvVars", 0); |
311 | for (int i=0; i<envcount; i++) { | 312 | for (int i=0; i<envcount; i++) { |
312 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | 313 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); |
313 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | 314 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); |
314 | if (!(name.isEmpty() || value.isEmpty())) { | 315 | if (!(name.isEmpty() || value.isEmpty())) { |
315 | m_env.insert(name, value); | 316 | m_env.insert(name, value); |
316 | } | 317 | } |
317 | } | 318 | } |
318 | } | 319 | } |
319 | /*! sends len bytes through the line */ | 320 | /*! sends len bytes through the line */ |
320 | void MyPty::send(const QByteArray& ar) | 321 | void MyPty::send(const QByteArray& ar) |
321 | { | 322 | { |
322 | #ifdef VERBOSE_DEBUG | 323 | #ifdef VERBOSE_DEBUG |
323 | // verbose debug | 324 | // verbose debug |
324 | printf("sending bytes:\n"); | 325 | printf("sending bytes:\n"); |
325 | for (uint i = 0; i < ar.count(); i++) | 326 | for (uint i = 0; i < ar.count(); i++) |
326 | printf("%c", ar[i]); | 327 | printf("%c", ar[i]); |
327 | printf("\n"); | 328 | printf("\n"); |
328 | #endif | 329 | #endif |
329 | 330 | ||
330 | ::write(m_fd, ar.data(), ar.count()); | 331 | ::write(m_fd, ar.data(), ar.count()); |
331 | } | 332 | } |
332 | 333 | ||
333 | /*! indicates that a block of data is received */ | 334 | /*! indicates that a block of data is received */ |
334 | void MyPty::readPty() | 335 | void MyPty::readPty() |
335 | { | 336 | { |
336 | QByteArray buf(4096); | 337 | QByteArray buf(4096); |
337 | 338 | ||
338 | int len = ::read( m_fd, buf.data(), 4096 ); | 339 | int len = ::read( m_fd, buf.data(), 4096 ); |
339 | 340 | ||
340 | if (len == -1 || len == 0) { | 341 | if (len == -1 || len == 0) { |
341 | donePty(); | 342 | donePty(); |
342 | return; | 343 | return; |
343 | } | 344 | } |
344 | 345 | ||
345 | if (len < 0) | 346 | if (len < 0) |
346 | return; | 347 | return; |
347 | 348 | ||
348 | 349 | ||
349 | buf.resize(len); | 350 | buf.resize(len); |
350 | emit received(buf); | 351 | emit received(buf); |
351 | 352 | ||
352 | #ifdef VERBOSE_DEBUG | 353 | #ifdef VERBOSE_DEBUG |
353 | // verbose debug | 354 | // verbose debug |
354 | printf("read bytes:\n"); | 355 | printf("read bytes:\n"); |
355 | for (uint i = 0; i < buf.count(); i++) | 356 | for (uint i = 0; i < buf.count(); i++) |
356 | printf("%c", buf[i]); | 357 | printf("%c", buf[i]); |
357 | printf("\n"); | 358 | printf("\n"); |
358 | #endif | 359 | #endif |
359 | 360 | ||
360 | } | 361 | } |
361 | QBitArray MyPty::supports()const { | 362 | QBitArray MyPty::supports()const { |
362 | QBitArray ar(3); | 363 | QBitArray ar(3); |
363 | //autoconnect | 364 | //autoconnect |
364 | ar[0] = 1; | 365 | ar[0] = 1; |
365 | // | 366 | // |
366 | ar[1] = 0; | 367 | ar[1] = 0; |
367 | ar[2] = 0; | 368 | ar[2] = 0; |
368 | 369 | ||
369 | return ar; | 370 | return ar; |
370 | } | 371 | } |
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 956ac76..e045aef 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -1,213 +1,247 @@ | |||
1 | #include "TEmuVt102.h" | 1 | #include "TEmuVt102.h" |
2 | #include "profile.h" | 2 | #include "profile.h" |
3 | #include "emulation_handler.h" | 3 | #include "emulation_handler.h" |
4 | #include "script.h" | 4 | #include "script.h" |
5 | #include "logger.h" | ||
5 | 6 | ||
6 | /* OPIE */ | 7 | /* OPIE */ |
7 | #include <opie2/odebug.h> | 8 | #include <opie2/odebug.h> |
9 | |||
10 | #include <qfile.h> | ||
11 | #include <qtextstream.h> | ||
12 | |||
8 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
9 | 14 | ||
10 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 15 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
11 | : QObject(0, name ) | 16 | : QObject(0, name ) |
12 | { | 17 | { |
13 | m_teWid = new TEWidget( parent, "TerminalMain"); | 18 | m_teWid = new TEWidget( parent, "TerminalMain"); |
14 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) | 19 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) |
15 | // use setWrapAt(80) for normal console with scrollbar | 20 | // use setWrapAt(80) for normal console with scrollbar |
16 | setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80); | 21 | setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80); |
17 | m_teWid->setMinimumSize(150, 70 ); | 22 | m_teWid->setMinimumSize(150, 70 ); |
18 | m_script = 0; | 23 | m_script = 0; |
24 | m_log = 0; | ||
19 | parent->resize( m_teWid->calcSize(80, 24 ) ); | 25 | parent->resize( m_teWid->calcSize(80, 24 ) ); |
20 | m_teEmu = new TEmuVt102(m_teWid ); | 26 | m_teEmu = new TEmuVt102(m_teWid ); |
21 | 27 | ||
22 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), | 28 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), |
23 | this, SIGNAL(changeSize(int,int) ) ); | 29 | this, SIGNAL(changeSize(int,int) ) ); |
24 | connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), | 30 | connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), |
25 | this, SLOT(recvEmulation(const char*,int) ) ); | 31 | this, SLOT(recvEmulation(const char*,int) ) ); |
26 | m_teEmu->setConnect( true ); | 32 | m_teEmu->setConnect( true ); |
27 | m_teEmu->setHistory( TRUE ); | 33 | m_teEmu->setHistory( TRUE ); |
28 | load( prof ); | 34 | load( prof ); |
29 | 35 | ||
30 | 36 | ||
31 | 37 | ||
32 | } | 38 | } |
33 | TEmulation* EmulationHandler::emulation() { | 39 | TEmulation* EmulationHandler::emulation() { |
34 | return m_teEmu; | 40 | return m_teEmu; |
35 | } | 41 | } |
36 | EmulationHandler::~EmulationHandler() { | 42 | EmulationHandler::~EmulationHandler() { |
37 | if (isRecording()) | 43 | if (isRecording()) |
38 | clearScript(); | 44 | clearScript(); |
39 | delete m_teEmu; | 45 | delete m_teEmu; |
40 | delete m_teWid; | 46 | delete m_teWid; |
47 | delete m_log; | ||
41 | } | 48 | } |
42 | 49 | ||
43 | void EmulationHandler::load( const Profile& prof) { | 50 | void EmulationHandler::load( const Profile& prof) { |
44 | 51 | ||
45 | // m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); | 52 | // m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); |
46 | QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal ); | 53 | QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal ); |
47 | font.setFixedPitch( TRUE ); | 54 | font.setFixedPitch( TRUE ); |
48 | m_teWid->setVTFont( font ); | 55 | m_teWid->setVTFont( font ); |
49 | 56 | ||
50 | int num = prof.readNumEntry("Color"); | 57 | int num = prof.readNumEntry("Color"); |
51 | setColor( foreColor(num), backColor(num) ); | 58 | setColor( foreColor(num), backColor(num) ); |
52 | m_teWid->setBackgroundColor(backColor(num) ); | 59 | m_teWid->setBackgroundColor(backColor(num) ); |
53 | 60 | ||
54 | int term = prof.readNumEntry("Terminal", 0) ; | 61 | int term = prof.readNumEntry("Terminal", 0) ; |
55 | switch(term) { | 62 | switch(term) { |
56 | default: | 63 | default: |
57 | case Profile::VT102: | 64 | case Profile::VT102: |
58 | case Profile::VT100: | 65 | case Profile::VT100: |
59 | m_teEmu->setKeytrans("vt100.keytab"); | 66 | m_teEmu->setKeytrans("vt100.keytab"); |
60 | break; | 67 | break; |
61 | case Profile::Linux: | 68 | case Profile::Linux: |
62 | m_teEmu->setKeytrans("linux.keytab"); | 69 | m_teEmu->setKeytrans("linux.keytab"); |
63 | break; | 70 | break; |
64 | case Profile::XTerm: | 71 | case Profile::XTerm: |
65 | m_teEmu->setKeytrans("default.Keytab"); | 72 | m_teEmu->setKeytrans("default.Keytab"); |
66 | break; | 73 | break; |
67 | } | 74 | } |
68 | } | 75 | } |
69 | void EmulationHandler::recv( const QByteArray& ar) { | 76 | void EmulationHandler::recv( const QByteArray& ar) { |
70 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | 77 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); |
78 | if ( isLogging() ) { | ||
79 | m_log->append( ar ); | ||
80 | } | ||
71 | } | 81 | } |
82 | |||
72 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 83 | void EmulationHandler::recvEmulation(const char* src, int len ) { |
73 | QByteArray ar(len); | 84 | QByteArray ar(len); |
74 | 85 | ||
75 | memcpy(ar.data(), src, sizeof(char) * len ); | 86 | memcpy(ar.data(), src, sizeof(char) * len ); |
76 | if (isRecording()) | 87 | if (isRecording()) |
77 | m_script->append(ar); | 88 | m_script->append(ar); |
78 | emit send(ar); | 89 | emit send(ar); |
79 | } | 90 | } |
91 | |||
92 | |||
80 | QWidget* EmulationHandler::widget() { | 93 | QWidget* EmulationHandler::widget() { |
81 | return m_teWid; | 94 | return m_teWid; |
82 | } | 95 | } |
83 | /* | 96 | /* |
84 | * allocate a new table of colors | 97 | * allocate a new table of colors |
85 | */ | 98 | */ |
86 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | 99 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { |
87 | ColorEntry table[TABLE_COLORS]; | 100 | ColorEntry table[TABLE_COLORS]; |
88 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); | 101 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); |
89 | 102 | ||
90 | for (int i = 0; i < TABLE_COLORS; i++ ) { | 103 | for (int i = 0; i < TABLE_COLORS; i++ ) { |
91 | if ( i == 0 || i == 10 ) { | 104 | if ( i == 0 || i == 10 ) { |
92 | table[i].color = fore; | 105 | table[i].color = fore; |
93 | }else if ( i == 1 || i == 11 ) { | 106 | }else if ( i == 1 || i == 11 ) { |
94 | table[i].color = back; | 107 | table[i].color = back; |
95 | table[i].transparent = 0; | 108 | table[i].transparent = 0; |
96 | }else { | 109 | }else { |
97 | table[i].color = defaultCt[i].color; | 110 | table[i].color = defaultCt[i].color; |
98 | } | 111 | } |
99 | } | 112 | } |
100 | m_teWid->setColorTable(table ); | 113 | m_teWid->setColorTable(table ); |
101 | m_teWid->update(); | 114 | m_teWid->update(); |
102 | } | 115 | } |
103 | QFont EmulationHandler::font( int id ) { | 116 | QFont EmulationHandler::font( int id ) { |
104 | QString name; | 117 | QString name; |
105 | int size = 0; | 118 | int size = 0; |
106 | switch(id ) { | 119 | switch(id ) { |
107 | default: // fall through | 120 | default: // fall through |
108 | case 0: | 121 | case 0: |
109 | name = QString::fromLatin1("Micro"); | 122 | name = QString::fromLatin1("Micro"); |
110 | size = 4; | 123 | size = 4; |
111 | break; | 124 | break; |
112 | case 1: | 125 | case 1: |
113 | name = QString::fromLatin1("Fixed"); | 126 | name = QString::fromLatin1("Fixed"); |
114 | size = 7; | 127 | size = 7; |
115 | break; | 128 | break; |
116 | case 2: | 129 | case 2: |
117 | name = QString::fromLatin1("Fixed"); | 130 | name = QString::fromLatin1("Fixed"); |
118 | size = 12; | 131 | size = 12; |
119 | break; | 132 | break; |
120 | } | 133 | } |
121 | QFont font(name, size, QFont::Normal ); | 134 | QFont font(name, size, QFont::Normal ); |
122 | font.setFixedPitch(TRUE ); | 135 | font.setFixedPitch(TRUE ); |
123 | return font; | 136 | return font; |
124 | } | 137 | } |
125 | QColor EmulationHandler::foreColor(int col) { | 138 | QColor EmulationHandler::foreColor(int col) { |
126 | QColor co; | 139 | QColor co; |
127 | /* we need to switch it */ | 140 | /* we need to switch it */ |
128 | switch( col ) { | 141 | switch( col ) { |
129 | default: | 142 | default: |
130 | case Profile::White: | 143 | case Profile::White: |
131 | /* color is black */ | 144 | /* color is black */ |
132 | co = Qt::white; | 145 | co = Qt::white; |
133 | break; | 146 | break; |
134 | case Profile::Black: | 147 | case Profile::Black: |
135 | co = Qt::black; | 148 | co = Qt::black; |
136 | break; | 149 | break; |
137 | case Profile::Green: | 150 | case Profile::Green: |
138 | owarn << "Foreground green" << oendl; | 151 | owarn << "Foreground green" << oendl; |
139 | co = Qt::green; | 152 | co = Qt::green; |
140 | break; | 153 | break; |
141 | case Profile::Orange: | 154 | case Profile::Orange: |
142 | owarn << "Foreground orange" << oendl; | 155 | owarn << "Foreground orange" << oendl; |
143 | co.setRgb( 231, 184, 98 ); | 156 | co.setRgb( 231, 184, 98 ); |
144 | break; | 157 | break; |
145 | } | 158 | } |
146 | 159 | ||
147 | return co; | 160 | return co; |
148 | } | 161 | } |
149 | QColor EmulationHandler::backColor(int col ) { | 162 | QColor EmulationHandler::backColor(int col ) { |
150 | QColor co; | 163 | QColor co; |
151 | /* we need to switch it */ | 164 | /* we need to switch it */ |
152 | switch( col ) { | 165 | switch( col ) { |
153 | default: | 166 | default: |
154 | case Profile::White: | 167 | case Profile::White: |
155 | /* color is white */ | 168 | /* color is white */ |
156 | co = Qt::black; | 169 | co = Qt::black; |
157 | break; | 170 | break; |
158 | case Profile::Black: | 171 | case Profile::Black: |
159 | co = Qt::white; | 172 | co = Qt::white; |
160 | break; | 173 | break; |
161 | case Profile::Green: | 174 | case Profile::Green: |
162 | owarn << "Background black" << oendl; | 175 | owarn << "Background black" << oendl; |
163 | co = Qt::black; | 176 | co = Qt::black; |
164 | break; | 177 | break; |
165 | case Profile::Orange: | 178 | case Profile::Orange: |
166 | owarn << "Background black" << oendl; | 179 | owarn << "Background black" << oendl; |
167 | co = Qt::black; | 180 | co = Qt::black; |
168 | break; | 181 | break; |
169 | } | 182 | } |
170 | 183 | ||
171 | return co; | 184 | return co; |
172 | } | 185 | } |
173 | 186 | ||
174 | QPushButton* EmulationHandler::cornerButton() { | 187 | QPushButton* EmulationHandler::cornerButton() { |
175 | return m_teWid->cornerButton(); | 188 | return m_teWid->cornerButton(); |
176 | } | 189 | } |
177 | 190 | ||
178 | 191 | ||
179 | Script *EmulationHandler::script() { | 192 | Script *EmulationHandler::script() { |
180 | return m_script; | 193 | return m_script; |
181 | } | 194 | } |
182 | 195 | ||
183 | bool EmulationHandler::isRecording() { | 196 | bool EmulationHandler::isRecording() { |
184 | return (m_script != 0); | 197 | return (m_script != 0); |
185 | } | 198 | } |
186 | 199 | ||
200 | bool EmulationHandler::isLogging() { | ||
201 | return (m_log != 0); | ||
202 | } | ||
203 | |||
187 | void EmulationHandler::startRecording() { | 204 | void EmulationHandler::startRecording() { |
188 | if (!isRecording()) | 205 | if (!isRecording()) |
189 | m_script = new Script(); | 206 | m_script = new Script(); |
190 | } | 207 | } |
191 | 208 | ||
209 | void EmulationHandler::startLogging(const QString fileName) { | ||
210 | m_logFileName = fileName; | ||
211 | if (!isLogging()) | ||
212 | m_log = new Logger(m_logFileName); | ||
213 | } | ||
214 | |||
215 | QString EmulationHandler::logFileName() { | ||
216 | return m_logFileName; | ||
217 | } | ||
218 | |||
192 | void EmulationHandler::clearScript() { | 219 | void EmulationHandler::clearScript() { |
193 | if (isRecording()) { | 220 | if (isRecording()) { |
194 | delete m_script; | 221 | delete m_script; |
195 | m_script = 0; | 222 | m_script = 0; |
196 | } | 223 | } |
197 | } | 224 | } |
198 | 225 | ||
226 | void EmulationHandler::clearLog() { | ||
227 | if (isLogging()) { | ||
228 | delete m_log; | ||
229 | m_log = 0; | ||
230 | } | ||
231 | } | ||
232 | |||
199 | void EmulationHandler::runScript(const Script *script) { | 233 | void EmulationHandler::runScript(const Script *script) { |
200 | emit send(script->script()); | 234 | emit send(script->script()); |
201 | } | 235 | } |
202 | 236 | ||
203 | void EmulationHandler::copy() { | 237 | void EmulationHandler::copy() { |
204 | m_teWid->emitSelection(); | 238 | m_teWid->emitSelection(); |
205 | } | 239 | } |
206 | void EmulationHandler::paste() { | 240 | void EmulationHandler::paste() { |
207 | m_teWid->pasteClipboard(); | 241 | m_teWid->pasteClipboard(); |
208 | } | 242 | } |
209 | 243 | ||
210 | void EmulationHandler::setWrap(int columns) { | 244 | void EmulationHandler::setWrap(int columns) { |
211 | m_teWid->setWrapAt(columns); | 245 | m_teWid->setWrapAt(columns); |
212 | } | 246 | } |
213 | 247 | ||
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h index 1338525..1092c82 100644 --- a/noncore/apps/opie-console/emulation_handler.h +++ b/noncore/apps/opie-console/emulation_handler.h | |||
@@ -1,95 +1,111 @@ | |||
1 | #ifndef OPIE_EMULATION_HANDLER_H | 1 | #ifndef OPIE_EMULATION_HANDLER_H |
2 | #define OPIE_EMULATION_HANDLER_H | 2 | #define OPIE_EMULATION_HANDLER_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #include <qcolor.h> | 5 | #include <qcolor.h> |
6 | #include <qcstring.h> | 6 | #include <qcstring.h> |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * Badly ibotty lacks the time to finish | 9 | * Badly ibotty lacks the time to finish |
10 | * his widget in time.. | 10 | * his widget in time.. |
11 | * Never the less we've to have an EmulationWidget | 11 | * Never the less we've to have an EmulationWidget |
12 | * This is why I'm taking the inferior not cleaned | 12 | * This is why I'm taking the inferior not cleaned |
13 | * up TE* KDE STUFF | 13 | * up TE* KDE STUFF |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * This is the layer above the IOLayer* | 17 | * This is the layer above the IOLayer* |
18 | * This nice QObject here will get stuff from | 18 | * This nice QObject here will get stuff from |
19 | * got a slot and a signal | 19 | * got a slot and a signal |
20 | * the signal for data | 20 | * the signal for data |
21 | * the slot for receiving | 21 | * the slot for receiving |
22 | * it'll set up the widget internally | 22 | * it'll set up the widget internally |
23 | * and manage the communication between | 23 | * and manage the communication between |
24 | * the pre QByteArray world! | 24 | * the pre QByteArray world! |
25 | */ | 25 | */ |
26 | class Profile; | 26 | class Profile; |
27 | class QWidget; | 27 | class QWidget; |
28 | class QPushButton; | 28 | class QPushButton; |
29 | class TEWidget; | 29 | class TEWidget; |
30 | class QFile; | ||
30 | class TEmulation; | 31 | class TEmulation; |
31 | class QFont; | 32 | class QFont; |
33 | class QTextStream; | ||
32 | class Script; | 34 | class Script; |
35 | class Logger; | ||
36 | |||
33 | class EmulationHandler : public QObject { | 37 | class EmulationHandler : public QObject { |
34 | Q_OBJECT | 38 | Q_OBJECT |
35 | public: | 39 | public: |
36 | /** | 40 | /** |
37 | * simple c'tor the parent of the TEWdiget | 41 | * simple c'tor the parent of the TEWdiget |
38 | * and a name | 42 | * and a name |
39 | * and a Profile | 43 | * and a Profile |
40 | */ | 44 | */ |
41 | EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); | 45 | EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); |
42 | 46 | ||
43 | /** | 47 | /** |
44 | * delete all components | 48 | * delete all components |
45 | */ | 49 | */ |
46 | ~EmulationHandler(); | 50 | ~EmulationHandler(); |
47 | 51 | ||
48 | void load( const Profile& ); | 52 | void load( const Profile& ); |
49 | QWidget* widget(); | 53 | QWidget* widget(); |
50 | TEmulation *emulation(); | 54 | TEmulation *emulation(); |
51 | void setColor( const QColor& fore, const QColor& back ); | 55 | void setColor( const QColor& fore, const QColor& back ); |
52 | QPushButton* cornerButton(); | 56 | QPushButton* cornerButton(); |
53 | 57 | ||
54 | /* Scripts */ | 58 | /* Scripts */ |
55 | /* Create a new script and record all typed characters */ | 59 | /* Create a new script and record all typed characters */ |
56 | void startRecording(); | 60 | void startRecording(); |
57 | 61 | ||
62 | void startLogging(const QString); | ||
63 | |||
58 | /* Return whether we are currently recording a script */ | 64 | /* Return whether we are currently recording a script */ |
59 | bool isRecording(); | 65 | bool isRecording(); |
60 | 66 | ||
67 | /* Return whether we are currently recording a log */ | ||
68 | bool isLogging(); | ||
69 | |||
70 | QString logFileName(); | ||
71 | |||
61 | /* Return the current script (or NULL) */ | 72 | /* Return the current script (or NULL) */ |
62 | Script *script(); | 73 | Script *script(); |
63 | 74 | ||
64 | /* Stop recording and remove the current script from memory */ | 75 | /* Stop recording and remove the current script from memory */ |
65 | void clearScript(); | 76 | void clearScript(); |
77 | |||
78 | /* Stop logging and remove the current log from memory */ | ||
79 | void clearLog(); | ||
66 | 80 | ||
67 | /* Run a script by forwarding its keys to the EmulationLayer */ | 81 | /* Run a script by forwarding its keys to the EmulationLayer */ |
68 | void runScript(const Script *); | 82 | void runScript(const Script *); |
69 | 83 | ||
70 | /* Propagate change to widget */ | 84 | /* Propagate change to widget */ |
71 | void setWrap(int columns); | 85 | void setWrap(int columns); |
72 | signals: | 86 | signals: |
73 | void send( const QByteArray& ); | 87 | void send( const QByteArray& ); |
74 | void changeSize(int rows, int cols ); | 88 | void changeSize(int rows, int cols ); |
75 | 89 | ||
76 | 90 | ||
77 | public slots: | 91 | public slots: |
78 | void recv( const QByteArray& ); | 92 | void recv( const QByteArray& ); |
79 | void paste(); | 93 | void paste(); |
80 | void copy(); | 94 | void copy(); |
81 | 95 | ||
82 | private slots: | 96 | private slots: |
83 | void recvEmulation( const char*, int len ); | 97 | void recvEmulation( const char*, int len ); |
84 | private: | 98 | private: |
85 | QFont font( int ); | 99 | QFont font( int ); |
86 | QColor foreColor(int ); | 100 | QColor foreColor(int ); |
87 | QColor backColor(int ); | 101 | QColor backColor(int ); |
88 | 102 | ||
89 | private: | 103 | private: |
90 | TEWidget* m_teWid; | 104 | TEWidget* m_teWid; |
91 | TEmulation* m_teEmu; | 105 | TEmulation* m_teEmu; |
92 | Script * m_script; | 106 | Script * m_script; |
107 | Logger *m_log; | ||
108 | QString m_logFileName; | ||
93 | }; | 109 | }; |
94 | 110 | ||
95 | #endif | 111 | #endif |
diff --git a/noncore/apps/opie-console/fixit.cpp b/noncore/apps/opie-console/fixit.cpp new file mode 100644 index 0000000..c14e35e --- a/dev/null +++ b/noncore/apps/opie-console/fixit.cpp | |||
@@ -0,0 +1,101 @@ | |||
1 | |||
2 | #include "fixit.h" | ||
3 | |||
4 | using namespace Opie::Core; | ||
5 | |||
6 | #ifdef FSCKED_DISTRI | ||
7 | FixIt::FixIt() : QObject() { | ||
8 | /* the new inittab */ | ||
9 | m_file = "#\n# /etc/inittab" | ||
10 | "#" | ||
11 | "" | ||
12 | "# 0 - halt (Do NOT set initdefault to this)" | ||
13 | "# 1 - Single user mode" | ||
14 | "# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)" | ||
15 | "# 3 - Full multiuser mode" | ||
16 | "# 4 - JavaVM(Intent) developer mode" | ||
17 | "# 5 - JavaVM(Intent)" | ||
18 | "# 6 - reboot (Do NOT set initdefault to this)" | ||
19 | "#" | ||
20 | "id:5:initdefault:" | ||
21 | "" | ||
22 | "# Specify things to do when starting" | ||
23 | "si::sysinit:/etc/rc.d/rc.sysinit" | ||
24 | "" | ||
25 | "l0:0:wait:/root/etc/rc.d/rc 0" | ||
26 | "l1:1:wait:/etc/rc.d/rc 1" | ||
27 | "l2:2:wait:/etc/rc.d/rc 2" | ||
28 | "l3:3:wait:/etc/rc.d/rc 3" | ||
29 | "l4:4:wait:/etc/rc.d/rc 4" | ||
30 | "l5:5:wait:/etc/rc.d/rc 5" | ||
31 | "l6:6:wait:/root/etc/rc.d/rc 6" | ||
32 | "" | ||
33 | "# Specify things to do before rebooting" | ||
34 | "um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" | ||
35 | "sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" | ||
36 | "" | ||
37 | "# Specify program to run on ttyS0" | ||
38 | "s0:24:respawn:/sbin/getty 9600 ttyS0" | ||
39 | "#pd:5:respawn:/etc/sync/serialctl" | ||
40 | "" | ||
41 | "# Specify program to run on tty1" | ||
42 | "1:2:respawn:/sbin/getty 9600 tty1" | ||
43 | "ln:345:respawn:survive -l 6 /sbin/launch" | ||
44 | "#qt:5:respawn:/sbin/qt" | ||
45 | "" | ||
46 | "# collie sp." | ||
47 | "sy::respawn:/sbin/shsync\n"; | ||
48 | } | ||
49 | |||
50 | FixIt::~FixIt() { | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * the retail Zaurus is broken in many ways | ||
55 | * one is that pppd is listening on our port... | ||
56 | * we've to stop it from that and then do kill(SIGHUP,1); | ||
57 | */ | ||
58 | void FixIt::fixIt() { | ||
59 | #ifndef EAST | ||
60 | ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); | ||
61 | QFile file( "/etc/inittab" ); | ||
62 | if ( file.open(IO_WriteOnly | IO_Raw ) ) { | ||
63 | file.writeBlock(m_file,strlen(m_file) ); | ||
64 | } | ||
65 | file.close(); | ||
66 | ::kill( SIGHUP, 1 ); | ||
67 | |||
68 | #else | ||
69 | |||
70 | OProcess m_kill; | ||
71 | m_kill << "sh"; | ||
72 | m_kill << "-c"; | ||
73 | m_kill << QString(QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_kill_0_1.sh"); | ||
74 | |||
75 | |||
76 | if ( !m_kill.start(OProcess::DontCare,OProcess::NoCommunication) ) { | ||
77 | owarn << "could not execute kill script" << oendl; | ||
78 | } else { | ||
79 | Global::statusMessage( tr("Fixing up Embedix")); | ||
80 | } | ||
81 | |||
82 | #endif | ||
83 | } | ||
84 | |||
85 | void FixIt::breakIt() { | ||
86 | #ifdef EAST | ||
87 | OProcess m_restart; | ||
88 | m_restart << "sh"; | ||
89 | m_restart << "-c"; | ||
90 | m_restart << QString(QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_restart_0_1.sh"); | ||
91 | |||
92 | |||
93 | if ( !m_restart.start() ) { | ||
94 | owarn << "could not execute restart script" << oendl; | ||
95 | } | ||
96 | |||
97 | #endif | ||
98 | } | ||
99 | |||
100 | |||
101 | #endif | ||
diff --git a/noncore/apps/opie-console/fixit.h b/noncore/apps/opie-console/fixit.h index 6a8a101..c9188cf 100644 --- a/noncore/apps/opie-console/fixit.h +++ b/noncore/apps/opie-console/fixit.h | |||
@@ -1,90 +1,35 @@ | |||
1 | #ifndef FIX_IT_H | 1 | #ifndef FIX_IT_H |
2 | #define FIX_IT_H | 2 | #define FIX_IT_H |
3 | 3 | ||
4 | #include <opie2/oprocess.h> | ||
5 | #include <opie2/odebug.h> | ||
6 | |||
7 | #include <qpe/global.h> | ||
8 | #include <qpe/qpeapplication.h> | ||
4 | 9 | ||
5 | #include <sys/types.h> | 10 | #include <sys/types.h> |
6 | 11 | ||
7 | #include <stdio.h> | 12 | #include <stdio.h> |
8 | #include <stdlib.h> | 13 | #include <stdlib.h> |
9 | #include <signal.h> | 14 | #include <signal.h> |
10 | #include <qfile.h> | 15 | |
11 | 16 | ||
12 | /* | 17 | /* |
13 | * The Zaurus rom | 18 | * The Zaurus rom |
14 | */ | 19 | */ |
15 | class FixIt { | 20 | class FixIt : public QObject { |
21 | |||
22 | Q_OBJECT | ||
23 | |||
16 | public: | 24 | public: |
17 | FixIt(); | 25 | FixIt(); |
18 | ~FixIt(); | 26 | ~FixIt(); |
19 | void fixIt(); | 27 | void fixIt(); |
20 | /* no real interested in implementing it */ | 28 | /* no real interested in implementing it */ |
21 | void breakIt() { | 29 | void breakIt(); |
22 | |||
23 | }; | ||
24 | char* m_file; | 30 | char* m_file; |
25 | }; | 31 | }; |
26 | 32 | ||
27 | #ifdef FSCKED_DISTRI | ||
28 | FixIt::FixIt() { | ||
29 | /* the new inittab */ | ||
30 | m_file = "#\n# /etc/inittab" | ||
31 | "#" | ||
32 | "" | ||
33 | "# 0 - halt (Do NOT set initdefault to this)" | ||
34 | "# 1 - Single user mode" | ||
35 | "# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)" | ||
36 | "# 3 - Full multiuser mode" | ||
37 | "# 4 - JavaVM(Intent) developer mode" | ||
38 | "# 5 - JavaVM(Intent)" | ||
39 | "# 6 - reboot (Do NOT set initdefault to this)" | ||
40 | "#" | ||
41 | "id:5:initdefault:" | ||
42 | "" | ||
43 | "# Specify things to do when starting" | ||
44 | "si::sysinit:/etc/rc.d/rc.sysinit" | ||
45 | "" | ||
46 | "l0:0:wait:/root/etc/rc.d/rc 0" | ||
47 | "l1:1:wait:/etc/rc.d/rc 1" | ||
48 | "l2:2:wait:/etc/rc.d/rc 2" | ||
49 | "l3:3:wait:/etc/rc.d/rc 3" | ||
50 | "l4:4:wait:/etc/rc.d/rc 4" | ||
51 | "l5:5:wait:/etc/rc.d/rc 5" | ||
52 | "l6:6:wait:/root/etc/rc.d/rc 6" | ||
53 | "" | ||
54 | "# Specify things to do before rebooting" | ||
55 | "um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" | ||
56 | "sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" | ||
57 | "" | ||
58 | "# Specify program to run on ttyS0" | ||
59 | "s0:24:respawn:/sbin/getty 9600 ttyS0" | ||
60 | "#pd:5:respawn:/etc/sync/serialctl" | ||
61 | "" | ||
62 | "# Specify program to run on tty1" | ||
63 | "1:2:respawn:/sbin/getty 9600 tty1" | ||
64 | "ln:345:respawn:survive -l 6 /sbin/launch" | ||
65 | "#qt:5:respawn:/sbin/qt" | ||
66 | "" | ||
67 | "# collie sp." | ||
68 | "sy::respawn:/sbin/shsync\n"; | ||
69 | |||
70 | } | ||
71 | FixIt::~FixIt() { | ||
72 | } | ||
73 | /* | ||
74 | * the retail Zaurus is broken in many ways | ||
75 | * one is that pppd is listening on our port... | ||
76 | * we've to stop it from that and then do kill(SIGHUP,1); | ||
77 | */ | ||
78 | void FixIt::fixIt() { | ||
79 | ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); | ||
80 | QFile file( "/etc/inittab" ); | ||
81 | if ( file.open(IO_WriteOnly | IO_Raw ) ) { | ||
82 | file.writeBlock(m_file,strlen(m_file) ); | ||
83 | } | ||
84 | file.close(); | ||
85 | ::kill( SIGHUP, 1 ); | ||
86 | } | ||
87 | 33 | ||
88 | #endif | 34 | #endif |
89 | 35 | ||
90 | #endif | ||
diff --git a/noncore/apps/opie-console/logger.cpp b/noncore/apps/opie-console/logger.cpp new file mode 100644 index 0000000..56557f3 --- a/dev/null +++ b/noncore/apps/opie-console/logger.cpp | |||
@@ -0,0 +1,20 @@ | |||
1 | #include <qfile.h> | ||
2 | #include <qtextstream.h> | ||
3 | |||
4 | #include "logger.h" | ||
5 | |||
6 | |||
7 | Logger::Logger() {} | ||
8 | |||
9 | Logger::Logger(const QString fileName) { | ||
10 | m_file.setName(fileName); | ||
11 | m_file.open(IO_ReadWrite); | ||
12 | } | ||
13 | |||
14 | Logger::~Logger() { | ||
15 | m_file.close(); | ||
16 | } | ||
17 | |||
18 | void Logger::append(QByteArray ar) { | ||
19 | m_file.writeBlock(ar); | ||
20 | } \ No newline at end of file | ||
diff --git a/noncore/apps/opie-console/logger.h b/noncore/apps/opie-console/logger.h new file mode 100644 index 0000000..cdc9f68 --- a/dev/null +++ b/noncore/apps/opie-console/logger.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef CONSOLE_LOGGER_H | ||
2 | #define CONSOLE_LOGGER_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qfile.h> | ||
6 | |||
7 | class Logger { | ||
8 | |||
9 | public: | ||
10 | Logger(); | ||
11 | Logger(const QString fileName); | ||
12 | void append(QByteArray ar); | ||
13 | ~Logger(); | ||
14 | |||
15 | private: | ||
16 | QFile m_file; | ||
17 | }; | ||
18 | |||
19 | #endif \ No newline at end of file | ||
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 1a5a59f..a0622d4 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,734 +1,778 @@ | |||
1 | #include "TEmulation.h" | 1 | #include "TEmulation.h" |
2 | #include "profileeditordialog.h" | 2 | #include "profileeditordialog.h" |
3 | #include "configdialog.h" | 3 | #include "configdialog.h" |
4 | #include "default.h" | 4 | #include "default.h" |
5 | #include "profilemanager.h" | 5 | #include "profilemanager.h" |
6 | #include "mainwindow.h" | 6 | #include "mainwindow.h" |
7 | #include "tabwidget.h" | 7 | #include "tabwidget.h" |
8 | #include "transferdialog.h" | 8 | #include "transferdialog.h" |
9 | #include "function_keyboard.h" | 9 | #include "function_keyboard.h" |
10 | #include "emulation_handler.h" | 10 | #include "emulation_handler.h" |
11 | #include "script.h" | 11 | #include "script.h" |
12 | #include "fixit.h" | 12 | #include "fixit.h" |
13 | 13 | ||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | #include <opie2/ofiledialog.h> | 16 | #include <opie2/ofiledialog.h> |
17 | #include <qpe/filemanager.h> | 17 | #include <qpe/filemanager.h> |
18 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
19 | using namespace Opie::Ui; | 19 | using namespace Opie::Ui; |
20 | 20 | ||
21 | /* QT */ | 21 | /* QT */ |
22 | #include <qaction.h> | 22 | #include <qaction.h> |
23 | #include <qmenubar.h> | 23 | #include <qmenubar.h> |
24 | #include <qtoolbar.h> | 24 | #include <qtoolbar.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qwhatsthis.h> | 26 | #include <qwhatsthis.h> |
27 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
28 | 28 | ||
29 | /* STD */ | 29 | /* STD */ |
30 | #include <assert.h> | 30 | #include <assert.h> |
31 | 31 | ||
32 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 32 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
33 | |||
33 | #ifdef FSCKED_DISTRI | 34 | #ifdef FSCKED_DISTRI |
34 | FixIt fix; | 35 | FixIt fix; |
35 | fix.fixIt(); | 36 | fix.fixIt(); |
36 | #endif | 37 | #endif |
37 | 38 | ||
38 | setCaption(QObject::tr("Opie Console") ); | 39 | setCaption(QObject::tr("Opie Console") ); |
39 | KeyTrans::loadAll(); | 40 | KeyTrans::loadAll(); |
40 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 41 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
41 | KeyTrans* s = KeyTrans::find(i ); | 42 | KeyTrans* s = KeyTrans::find(i ); |
42 | assert( s ); | 43 | assert( s ); |
43 | } | 44 | } |
44 | m_factory = new MetaFactory(); | 45 | m_factory = new MetaFactory(); |
45 | Default def(m_factory); | 46 | Default def(m_factory); |
46 | m_sessions.setAutoDelete( TRUE ); | 47 | m_sessions.setAutoDelete( TRUE ); |
47 | m_curSession = 0; | 48 | m_curSession = 0; |
48 | m_manager = new ProfileManager( m_factory ); | 49 | m_manager = new ProfileManager( m_factory ); |
49 | m_manager->load(); | 50 | m_manager->load(); |
50 | m_scriptsData.setAutoDelete(TRUE); | 51 | m_scriptsData.setAutoDelete(TRUE); |
51 | 52 | ||
52 | initUI(); | 53 | initUI(); |
53 | populateProfiles(); | 54 | populateProfiles(); |
54 | populateScripts(); | 55 | populateScripts(); |
55 | } | 56 | } |
56 | 57 | ||
57 | void MainWindow::initUI() { | 58 | void MainWindow::initUI() { |
58 | 59 | ||
59 | setToolBarsMovable( FALSE ); | 60 | setToolBarsMovable( FALSE ); |
60 | 61 | ||
61 | /* tool bar for the menu */ | 62 | /* tool bar for the menu */ |
62 | m_tool = new QToolBar( this ); | 63 | m_tool = new QToolBar( this ); |
63 | m_tool->setHorizontalStretchable( TRUE ); | 64 | m_tool->setHorizontalStretchable( TRUE ); |
64 | 65 | ||
65 | m_bar = new QMenuBar( m_tool ); | 66 | m_bar = new QMenuBar( m_tool ); |
66 | m_console = new QPopupMenu( this ); | 67 | m_console = new QPopupMenu( this ); |
67 | m_scripts = new QPopupMenu( this ); | 68 | m_scripts = new QPopupMenu( this ); |
68 | m_sessionsPop= new QPopupMenu( this ); | 69 | m_sessionsPop= new QPopupMenu( this ); |
69 | m_scriptsPop = new QPopupMenu( this ); | 70 | m_scriptsPop = new QPopupMenu( this ); |
70 | 71 | ||
71 | /* add a toolbar for icons */ | 72 | /* add a toolbar for icons */ |
72 | m_icons = new QToolBar(this); | 73 | m_icons = new QToolBar(this); |
73 | 74 | ||
74 | /* | 75 | /* |
75 | * the settings action | 76 | * the settings action |
76 | */ | 77 | */ |
77 | m_setProfiles = new QAction(tr("Configure Profiles"), | 78 | m_setProfiles = new QAction(tr("Configure Profiles"), |
78 | Resource::loadPixmap( "SettingsIcon" ), | 79 | Resource::loadPixmap( "SettingsIcon" ), |
79 | QString::null, 0, this, 0); | 80 | QString::null, 0, this, 0); |
80 | m_setProfiles->addTo( m_console ); | 81 | m_setProfiles->addTo( m_console ); |
81 | connect( m_setProfiles, SIGNAL(activated() ), | 82 | connect( m_setProfiles, SIGNAL(activated() ), |
82 | this, SLOT(slotConfigure() ) ); | 83 | this, SLOT(slotConfigure() ) ); |
83 | 84 | ||
84 | m_console->insertSeparator(); | 85 | m_console->insertSeparator(); |
85 | /* | 86 | /* |
86 | * new Action for new sessions | 87 | * new Action for new sessions |
87 | */ | 88 | */ |
88 | QAction* newCon = new QAction(tr("New Profile"), | 89 | QAction* newCon = new QAction(tr("New Profile"), |
89 | Resource::loadPixmap( "new" ), | 90 | Resource::loadPixmap( "new" ), |
90 | QString::null, 0, this, 0); | 91 | QString::null, 0, this, 0); |
91 | newCon->addTo( m_console ); | 92 | newCon->addTo( m_console ); |
92 | connect( newCon, SIGNAL(activated() ), | 93 | connect( newCon, SIGNAL(activated() ), |
93 | this, SLOT(slotNew() ) ); | 94 | this, SLOT(slotNew() ) ); |
94 | 95 | ||
95 | m_console->insertSeparator(); | 96 | m_console->insertSeparator(); |
96 | 97 | ||
97 | QAction *saveCon = new QAction( tr("Save Profile" ), | 98 | QAction *saveCon = new QAction( tr("Save Profile" ), |
98 | Resource::loadPixmap( "save" ), QString::null, | 99 | Resource::loadPixmap( "save" ), QString::null, |
99 | 0, this, 0 ); | 100 | 0, this, 0 ); |
100 | saveCon->addTo( m_console ); | 101 | saveCon->addTo( m_console ); |
101 | connect( saveCon, SIGNAL(activated() ), | 102 | connect( saveCon, SIGNAL(activated() ), |
102 | this, SLOT(slotSaveSession() ) ); | 103 | this, SLOT(slotSaveSession() ) ); |
103 | m_console->insertSeparator(); | 104 | m_console->insertSeparator(); |
104 | 105 | ||
105 | /* | 106 | /* |
106 | * connect action | 107 | * connect action |
107 | */ | 108 | */ |
108 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 109 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
109 | QString::null, 0, this, 0 ); | 110 | QString::null, 0, this, 0 ); |
110 | m_connect->addTo( m_console ); | 111 | m_connect->addTo( m_console ); |
111 | connect(m_connect, SIGNAL(activated() ), | 112 | connect(m_connect, SIGNAL(activated() ), |
112 | this, SLOT(slotConnect() ) ); | 113 | this, SLOT(slotConnect() ) ); |
113 | 114 | ||
114 | /* | 115 | /* |
115 | * disconnect action | 116 | * disconnect action |
116 | */ | 117 | */ |
117 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 118 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
118 | QString::null, 0, this, 0 ); | 119 | QString::null, 0, this, 0 ); |
119 | m_disconnect->addTo( m_console ); | 120 | m_disconnect->addTo( m_console ); |
120 | connect(m_disconnect, SIGNAL(activated() ), | 121 | connect(m_disconnect, SIGNAL(activated() ), |
121 | this, SLOT(slotDisconnect() ) ); | 122 | this, SLOT(slotDisconnect() ) ); |
122 | 123 | ||
123 | m_console->insertSeparator(); | 124 | m_console->insertSeparator(); |
124 | 125 | ||
125 | 126 | #ifndef EAST | |
126 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); | 127 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); |
127 | m_quickLaunch->addTo( m_icons ); | 128 | m_quickLaunch->addTo( m_icons ); |
128 | connect( m_quickLaunch, SIGNAL( activated() ), | 129 | connect( m_quickLaunch, SIGNAL( activated() ), |
129 | this, SLOT( slotQuickLaunch() ) ); | 130 | this, SLOT( slotQuickLaunch() ) ); |
131 | #endif | ||
130 | 132 | ||
131 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); | 133 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); |
132 | 134 | ||
133 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 135 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
134 | 0, this, 0 ); | 136 | 0, this, 0 ); |
135 | m_transfer->addTo( m_console ); | 137 | m_transfer->addTo( m_console ); |
136 | connect(m_transfer, SIGNAL(activated() ), | 138 | connect(m_transfer, SIGNAL(activated() ), |
137 | this, SLOT(slotTransfer() ) ); | 139 | this, SLOT(slotTransfer() ) ); |
138 | 140 | ||
139 | 141 | ||
140 | 142 | ||
141 | /* | 143 | /* |
142 | * immediate change of line wrap policy | 144 | * immediate change of line wrap policy |
143 | */ | 145 | */ |
144 | m_isWrapped = true; | 146 | m_isWrapped = true; |
145 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); | 147 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); |
146 | m_wrap->addTo( m_console ); | 148 | m_wrap->addTo( m_console ); |
147 | m_wrap->setOn( true ); | 149 | m_wrap->setOn( true ); |
148 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 150 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
149 | 151 | ||
150 | /* | 152 | /* |
151 | * fullscreen | 153 | * fullscreen |
152 | */ | 154 | */ |
153 | m_isFullscreen = false; | 155 | m_isFullscreen = false; |
154 | 156 | ||
155 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 157 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
156 | , QString::null, 0, this, 0 ); | 158 | , QString::null, 0, this, 0 ); |
157 | m_fullscreen->addTo( m_console ); | 159 | m_fullscreen->addTo( m_console ); |
158 | connect( m_fullscreen, SIGNAL( activated() ), | 160 | connect( m_fullscreen, SIGNAL( activated() ), |
159 | this, SLOT( slotFullscreen() ) ); | 161 | this, SLOT( slotFullscreen() ) ); |
160 | 162 | ||
161 | m_console->insertSeparator(); | 163 | m_console->insertSeparator(); |
162 | 164 | ||
165 | m_recordLog = new QAction(); | ||
166 | m_recordLog->setText( tr("Start log") ); | ||
167 | m_recordLog->addTo( m_console ); | ||
168 | connect(m_recordLog, SIGNAL(activated() ), | ||
169 | this, SLOT( slotSaveLog() ) ); | ||
170 | m_recordingLog = false; | ||
171 | |||
163 | QAction *a = new QAction(); | 172 | QAction *a = new QAction(); |
164 | a->setText( tr("Save history") ); | 173 | a->setText( tr("Save history") ); |
165 | a->addTo( m_console ); | 174 | a->addTo( m_console ); |
166 | connect(a, SIGNAL(activated() ), | 175 | connect(a, SIGNAL(activated() ), |
167 | this, SLOT(slotSaveHistory() ) ); | 176 | this, SLOT(slotSaveHistory() ) ); |
168 | /* | 177 | /* |
169 | * terminate action | 178 | * terminate action |
170 | */ | 179 | */ |
171 | m_terminate = new QAction(); | 180 | m_terminate = new QAction(); |
172 | m_terminate->setText( tr("Terminate") ); | 181 | m_terminate->setText( tr("Terminate") ); |
173 | m_terminate->addTo( m_console ); | 182 | m_terminate->addTo( m_console ); |
174 | connect(m_terminate, SIGNAL(activated() ), | 183 | connect(m_terminate, SIGNAL(activated() ), |
175 | this, SLOT(slotTerminate() ) ); | 184 | this, SLOT(slotTerminate() ) ); |
176 | 185 | ||
177 | m_closewindow = new QAction(); | 186 | m_closewindow = new QAction(); |
178 | m_closewindow->setText( tr("Close Window") ); | 187 | m_closewindow->setText( tr("Close Window") ); |
179 | m_closewindow->addTo( m_console ); | 188 | m_closewindow->addTo( m_console ); |
180 | connect( m_closewindow, SIGNAL(activated() ), | 189 | connect( m_closewindow, SIGNAL(activated() ), |
181 | this, SLOT(slotClose() ) ); | 190 | this, SLOT(slotClose() ) ); |
182 | 191 | ||
183 | 192 | ||
184 | /* | 193 | /* |
185 | * script actions | 194 | * script actions |
186 | */ | 195 | */ |
187 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 196 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
188 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 197 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
189 | 198 | ||
190 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 199 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
191 | m_recordScript->addTo(m_scripts); | 200 | m_recordScript->addTo(m_scripts); |
192 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 201 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
193 | 202 | ||
194 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 203 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
195 | m_saveScript->addTo(m_scripts); | 204 | m_saveScript->addTo(m_scripts); |
196 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 205 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
197 | 206 | ||
198 | 207 | ||
199 | /* | 208 | /* |
200 | * action that open/closes the keyboard | 209 | * action that open/closes the keyboard |
201 | */ | 210 | */ |
202 | m_openKeys = new QAction (tr("Open Keyboard..."), | 211 | m_openKeys = new QAction (tr("Open Keyboard..."), |
203 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 212 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
204 | QString::null, 0, this, 0); | 213 | QString::null, 0, this, 0); |
205 | m_openKeys->setToggleAction(true); | 214 | m_openKeys->setToggleAction(true); |
206 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 215 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
207 | 216 | ||
208 | /* insert the submenu */ | 217 | /* insert the submenu */ |
209 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 218 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
210 | -1, 0); | 219 | -1, 0); |
211 | 220 | ||
212 | /* insert the connection menu */ | 221 | /* insert the connection menu */ |
213 | m_bar->insertItem( tr("Connection"), m_console ); | 222 | m_bar->insertItem( tr("Connection"), m_console ); |
214 | 223 | ||
215 | /* the scripts menu */ | 224 | /* the scripts menu */ |
216 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 225 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
217 | 226 | ||
218 | /* and the keyboard */ | 227 | /* and the keyboard */ |
219 | m_keyBar = new QToolBar(this); | 228 | m_keyBar = new QToolBar(this); |
220 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 229 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
221 | m_keyBar->setHorizontalStretchable( TRUE ); | 230 | m_keyBar->setHorizontalStretchable( TRUE ); |
222 | m_keyBar->hide(); | 231 | m_keyBar->hide(); |
223 | 232 | ||
224 | m_kb = new FunctionKeyboard(m_keyBar); | 233 | m_kb = new FunctionKeyboard(m_keyBar); |
225 | connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), | 234 | connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), |
226 | this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); | 235 | this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); |
227 | 236 | ||
228 | 237 | ||
229 | a = new QAction(tr("Copy"), | 238 | a = new QAction(tr("Copy"), |
230 | Resource::loadPixmap("copy"), QString::null, | 239 | Resource::loadPixmap("copy"), QString::null, |
231 | 0, this, 0 ); | 240 | 0, this, 0 ); |
232 | //a->addTo( m_icons ); | 241 | //a->addTo( m_icons ); |
233 | connect( a, SIGNAL(activated() ), | 242 | connect( a, SIGNAL(activated() ), |
234 | this, SLOT(slotCopy() ) ); | 243 | this, SLOT(slotCopy() ) ); |
235 | 244 | ||
236 | QAction *paste = new QAction(tr("Paste"), | 245 | QAction *paste = new QAction(tr("Paste"), |
237 | Resource::loadPixmap("paste"), QString::null, | 246 | Resource::loadPixmap("paste"), QString::null, |
238 | 0, this, 0 ); | 247 | 0, this, 0 ); |
239 | connect( paste, SIGNAL(activated() ), | 248 | connect( paste, SIGNAL(activated() ), |
240 | this, SLOT(slotPaste() ) ); | 249 | this, SLOT(slotPaste() ) ); |
241 | 250 | ||
242 | 251 | ||
243 | newCon->addTo( m_icons ); | 252 | newCon->addTo( m_icons ); |
244 | //m_setProfiles->addTo( m_icons ); | 253 | //m_setProfiles->addTo( m_icons ); |
245 | paste->addTo( m_icons ); | 254 | paste->addTo( m_icons ); |
246 | m_openKeys->addTo(m_icons); | 255 | m_openKeys->addTo(m_icons); |
247 | m_fullscreen->addTo( m_icons ); | 256 | m_fullscreen->addTo( m_icons ); |
248 | 257 | ||
249 | m_connect->setEnabled( false ); | 258 | m_connect->setEnabled( false ); |
250 | m_disconnect->setEnabled( false ); | 259 | m_disconnect->setEnabled( false ); |
251 | m_terminate->setEnabled( false ); | 260 | m_terminate->setEnabled( false ); |
252 | m_transfer->setEnabled( false ); | 261 | m_transfer->setEnabled( false ); |
253 | m_scripts->setItemEnabled(m_runScript_id, false); | 262 | m_scripts->setItemEnabled(m_runScript_id, false); |
254 | m_recordScript->setEnabled( false ); | 263 | m_recordScript->setEnabled( false ); |
255 | m_saveScript->setEnabled( false ); | 264 | m_saveScript->setEnabled( false ); |
256 | m_fullscreen->setEnabled( false ); | 265 | m_fullscreen->setEnabled( false ); |
257 | m_closewindow->setEnabled( false ); | 266 | m_closewindow->setEnabled( false ); |
258 | m_wrap->setEnabled( false ); | 267 | m_wrap->setEnabled( false ); |
259 | 268 | ||
260 | /* | 269 | /* |
261 | * connect to the menu activation | 270 | * connect to the menu activation |
262 | */ | 271 | */ |
263 | connect( m_sessionsPop, SIGNAL(activated(int) ), | 272 | connect( m_sessionsPop, SIGNAL(activated(int) ), |
264 | this, SLOT(slotProfile(int) ) ); | 273 | this, SLOT(slotProfile(int) ) ); |
265 | 274 | ||
266 | m_consoleWindow = new TabWidget( this, "blah"); | 275 | m_consoleWindow = new TabWidget( this, "blah"); |
267 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 276 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
268 | this, SLOT(slotSessionChanged(Session*) ) ); | 277 | this, SLOT(slotSessionChanged(Session*) ) ); |
269 | setCentralWidget( m_consoleWindow ); | 278 | setCentralWidget( m_consoleWindow ); |
270 | 279 | ||
271 | slotQuickLaunch(); | 280 | slotQuickLaunch(); |
272 | } | 281 | } |
273 | 282 | ||
274 | ProfileManager* MainWindow::manager() { | 283 | ProfileManager* MainWindow::manager() { |
275 | return m_manager; | 284 | return m_manager; |
276 | } | 285 | } |
277 | TabWidget* MainWindow::tabWidget() { | 286 | TabWidget* MainWindow::tabWidget() { |
278 | return m_consoleWindow; | 287 | return m_consoleWindow; |
279 | } | 288 | } |
280 | void MainWindow::populateProfiles() { | 289 | void MainWindow::populateProfiles() { |
281 | m_sessionsPop->clear(); | 290 | m_sessionsPop->clear(); |
282 | Profile::ValueList list = manager()->all(); | 291 | Profile::ValueList list = manager()->all(); |
283 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 292 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
284 | m_sessionsPop->insertItem( (*it).name() ); | 293 | m_sessionsPop->insertItem( (*it).name() ); |
285 | } | 294 | } |
286 | 295 | ||
287 | } | 296 | } |
288 | 297 | ||
289 | void MainWindow::populateScripts() { | 298 | void MainWindow::populateScripts() { |
290 | m_scriptsPop->clear(); | 299 | m_scriptsPop->clear(); |
291 | m_scriptsData.clear(); | 300 | m_scriptsData.clear(); |
292 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 301 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
293 | QListIterator<DocLnk> dit(files.children()); | 302 | QListIterator<DocLnk> dit(files.children()); |
294 | for (; dit.current(); ++dit) { | 303 | for (; dit.current(); ++dit) { |
295 | if (*dit && (*dit)->name().length()>0) { | 304 | if (*dit && (*dit)->name().length()>0) { |
296 | QFileInfo info((*dit)->file()); | 305 | QFileInfo info((*dit)->file()); |
297 | if (info.extension(false) == "script") { | 306 | if (info.extension(false) == "script") { |
298 | m_scriptsData.append(new DocLnk(**dit)); | 307 | m_scriptsData.append(new DocLnk(**dit)); |
299 | m_scriptsPop->insertItem((*dit)->name()); | 308 | m_scriptsPop->insertItem((*dit)->name()); |
300 | } | 309 | } |
301 | } | 310 | } |
302 | } | 311 | } |
303 | 312 | ||
304 | } | 313 | } |
305 | 314 | ||
306 | MainWindow::~MainWindow() { | 315 | MainWindow::~MainWindow() { |
307 | delete m_factory; | 316 | delete m_factory; |
308 | manager()->save(); | 317 | manager()->save(); |
309 | #ifdef FSCKED_DISTRI | 318 | #ifdef FSCKED_DISTRI |
310 | FixIt fix; | 319 | FixIt fix; |
311 | fix.breakIt(); | 320 | fix.breakIt(); |
312 | #endif | 321 | #endif |
313 | } | 322 | } |
314 | 323 | ||
315 | MetaFactory* MainWindow::factory() { | 324 | MetaFactory* MainWindow::factory() { |
316 | return m_factory; | 325 | return m_factory; |
317 | } | 326 | } |
318 | 327 | ||
319 | Session* MainWindow::currentSession() { | 328 | Session* MainWindow::currentSession() { |
320 | return m_curSession; | 329 | return m_curSession; |
321 | } | 330 | } |
322 | 331 | ||
323 | QList<Session> MainWindow::sessions() { | 332 | QList<Session> MainWindow::sessions() { |
324 | return m_sessions; | 333 | return m_sessions; |
325 | } | 334 | } |
326 | 335 | ||
327 | void MainWindow::slotNew() { | 336 | void MainWindow::slotNew() { |
328 | ProfileEditorDialog dlg(factory() ); | 337 | ProfileEditorDialog dlg(factory() ); |
329 | dlg.setCaption( tr("New Connection") ); | 338 | dlg.setCaption( tr("New Connection") ); |
330 | int ret = QPEApplication::execDialog( &dlg ); | 339 | int ret = QPEApplication::execDialog( &dlg ); |
331 | 340 | ||
332 | if ( ret == QDialog::Accepted ) { | 341 | if ( ret == QDialog::Accepted ) { |
333 | create( dlg.profile() ); | 342 | create( dlg.profile() ); |
334 | } | 343 | } |
335 | } | 344 | } |
336 | 345 | ||
337 | void MainWindow::slotRecordScript() { | 346 | void MainWindow::slotRecordScript() { |
338 | if (currentSession()) { | 347 | if (currentSession()) { |
339 | currentSession()->emulationHandler()->startRecording(); | 348 | currentSession()->emulationHandler()->startRecording(); |
340 | m_saveScript->setEnabled(true); | 349 | m_saveScript->setEnabled(true); |
341 | m_recordScript->setEnabled(false); | 350 | m_recordScript->setEnabled(false); |
342 | } | 351 | } |
343 | } | 352 | } |
344 | 353 | ||
345 | void MainWindow::slotSaveScript() { | 354 | void MainWindow::slotSaveScript() { |
346 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 355 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
347 | QMap<QString, QStringList> map; | 356 | QMap<QString, QStringList> map; |
348 | QStringList text; | 357 | QStringList text; |
349 | text << "text/plain"; | 358 | text << "text/plain"; |
350 | map.insert(tr("Script"), text ); | 359 | map.insert(tr("Script"), text ); |
351 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 360 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
352 | if (!filename.isEmpty()) { | 361 | if (!filename.isEmpty()) { |
353 | QFileInfo info(filename); | 362 | QFileInfo info(filename); |
354 | if (info.extension(FALSE) != "script") | 363 | if (info.extension(FALSE) != "script") |
355 | filename += ".script"; | 364 | filename += ".script"; |
356 | DocLnk nf; | 365 | DocLnk nf; |
357 | nf.setType("text/plain"); | 366 | nf.setType("text/plain"); |
358 | nf.setFile(filename); | 367 | nf.setFile(filename); |
359 | nf.setName(info.fileName()); | 368 | nf.setName(info.fileName()); |
360 | FileManager fm; | 369 | FileManager fm; |
361 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 370 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
362 | currentSession()->emulationHandler()->clearScript(); | 371 | currentSession()->emulationHandler()->clearScript(); |
363 | m_saveScript->setEnabled(false); | 372 | m_saveScript->setEnabled(false); |
364 | m_recordScript->setEnabled(true); | 373 | m_recordScript->setEnabled(true); |
365 | populateScripts(); | 374 | populateScripts(); |
366 | } | 375 | } |
367 | } | 376 | } |
368 | } | 377 | } |
369 | 378 | ||
370 | void MainWindow::slotRunScript(int id) { | 379 | void MainWindow::slotRunScript(int id) { |
371 | if (currentSession()) { | 380 | if (currentSession()) { |
372 | int index = m_scriptsPop->indexOf(id); | 381 | int index = m_scriptsPop->indexOf(id); |
373 | DocLnk *lnk = m_scriptsData.at(index); | 382 | DocLnk *lnk = m_scriptsData.at(index); |
374 | QString filePath = lnk->file(); | 383 | QString filePath = lnk->file(); |
375 | Script script(filePath); | 384 | Script script(filePath); |
376 | currentSession()->emulationHandler()->runScript(&script); | 385 | currentSession()->emulationHandler()->runScript(&script); |
377 | } | 386 | } |
378 | } | 387 | } |
379 | 388 | ||
380 | void MainWindow::slotConnect() { | 389 | void MainWindow::slotConnect() { |
381 | if ( currentSession() ) { | 390 | if ( currentSession() ) { |
382 | bool ret = currentSession()->layer()->open(); | 391 | bool ret = currentSession()->layer()->open(); |
383 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 392 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
384 | QObject::tr("Failed"), | 393 | QObject::tr("Failed"), |
385 | QObject::tr("Connecting failed for this session.")); | 394 | QObject::tr("Connecting failed for this session.")); |
386 | else { | 395 | else { |
387 | m_connect->setEnabled( false ); | 396 | m_connect->setEnabled( false ); |
388 | m_disconnect->setEnabled( true ); | 397 | m_disconnect->setEnabled( true ); |
389 | 398 | ||
390 | // if it does not support file transfer, disable the menu entry | 399 | // if it does not support file transfer, disable the menu entry |
391 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 400 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
392 | m_transfer->setEnabled( false ); | 401 | m_transfer->setEnabled( false ); |
393 | } else { | 402 | } else { |
394 | m_transfer->setEnabled( true ); | 403 | m_transfer->setEnabled( true ); |
395 | } | 404 | } |
396 | 405 | ||
397 | m_recordScript->setEnabled( true ); | 406 | m_recordScript->setEnabled( true ); |
398 | m_scripts->setItemEnabled(m_runScript_id, true); | 407 | m_scripts->setItemEnabled(m_runScript_id, true); |
399 | } | 408 | } |
400 | } | 409 | } |
401 | } | 410 | } |
402 | 411 | ||
403 | void MainWindow::slotDisconnect() { | 412 | void MainWindow::slotDisconnect() { |
404 | if ( currentSession() ) { | 413 | if ( currentSession() ) { |
405 | currentSession()->layer()->close(); | 414 | currentSession()->layer()->close(); |
406 | m_connect->setEnabled( true ); | 415 | m_connect->setEnabled( true ); |
407 | m_disconnect->setEnabled( false ); | 416 | m_disconnect->setEnabled( false ); |
408 | m_transfer->setEnabled( false ); | 417 | m_transfer->setEnabled( false ); |
409 | m_recordScript->setEnabled( false); | 418 | m_recordScript->setEnabled( false); |
410 | m_saveScript->setEnabled( false ); | 419 | m_saveScript->setEnabled( false ); |
411 | m_scripts->setItemEnabled(m_runScript_id, false); | 420 | m_scripts->setItemEnabled(m_runScript_id, false); |
412 | } | 421 | } |
413 | } | 422 | } |
414 | 423 | ||
415 | void MainWindow::slotTerminate() { | 424 | void MainWindow::slotTerminate() { |
416 | if ( currentSession() ) | 425 | if ( currentSession() ) |
417 | currentSession()->layer()->close(); | 426 | currentSession()->layer()->close(); |
418 | 427 | ||
419 | slotClose(); | 428 | slotClose(); |
420 | /* FIXME move to the next session */ | 429 | /* FIXME move to the next session */ |
421 | } | 430 | } |
422 | 431 | ||
423 | 432 | ||
424 | 433 | ||
425 | |||
426 | |||
427 | |||
428 | void MainWindow::slotQuickLaunch() { | 434 | void MainWindow::slotQuickLaunch() { |
429 | Profile prof = manager()->profile( "default" ); | 435 | |
436 | Profile prof = manager()->profile( "default" ); | ||
430 | if ( prof.name() == "default" ) { | 437 | if ( prof.name() == "default" ) { |
431 | create( prof ); | 438 | create( prof ); |
432 | } else { | 439 | } else { |
440 | #ifndef EAST | ||
433 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); | 441 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); |
434 | newProf.setAutoConnect( true ); | 442 | newProf.setAutoConnect( true ); |
435 | create( newProf ); | 443 | create( newProf ); |
436 | slotSaveSession(); | 444 | slotSaveSession(); |
445 | #endif | ||
437 | } | 446 | } |
438 | |||
439 | } | 447 | } |
440 | 448 | ||
441 | void MainWindow::slotConfigure() { | 449 | void MainWindow::slotConfigure() { |
442 | ConfigDialog conf( manager()->all(), factory() ); | 450 | ConfigDialog conf( manager()->all(), factory() ); |
443 | 451 | ||
444 | int ret = QPEApplication::execDialog( &conf ); | 452 | int ret = QPEApplication::execDialog( &conf ); |
445 | 453 | ||
446 | if ( QDialog::Accepted == ret ) { | 454 | if ( QDialog::Accepted == ret ) { |
447 | manager()->setProfiles( conf.list() ); | 455 | manager()->setProfiles( conf.list() ); |
448 | manager()->save(); | 456 | manager()->save(); |
449 | populateProfiles(); | 457 | populateProfiles(); |
450 | } | 458 | } |
451 | } | 459 | } |
452 | /* | 460 | /* |
453 | * we will remove | 461 | * we will remove |
454 | * this window from the tabwidget | 462 | * this window from the tabwidget |
455 | * remove it from the list | 463 | * remove it from the list |
456 | * delete it | 464 | * delete it |
457 | * and set the currentSession() | 465 | * and set the currentSession() |
458 | */ | 466 | */ |
459 | void MainWindow::slotClose() { | 467 | void MainWindow::slotClose() { |
460 | if (!currentSession() ) | 468 | if (!currentSession() ) |
461 | return; | 469 | return; |
462 | 470 | ||
463 | Session* ses = currentSession(); | 471 | Session* ses = currentSession(); |
464 | owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl; | 472 | owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl; |
465 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 473 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
466 | m_curSession = NULL; | 474 | m_curSession = NULL; |
467 | tabWidget()->remove( /*currentSession()*/ses ); | 475 | tabWidget()->remove( /*currentSession()*/ses ); |
468 | /*it's autodelete */ | 476 | /*it's autodelete */ |
469 | m_sessions.remove( ses ); | 477 | m_sessions.remove( ses ); |
470 | owarn << "after remove!!" << oendl; | 478 | owarn << "after remove!!" << oendl; |
471 | 479 | ||
472 | if (!currentSession() ) { | 480 | if (!currentSession() ) { |
473 | m_connect->setEnabled( false ); | 481 | m_connect->setEnabled( false ); |
474 | m_disconnect->setEnabled( false ); | 482 | m_disconnect->setEnabled( false ); |
475 | m_terminate->setEnabled( false ); | 483 | m_terminate->setEnabled( false ); |
476 | m_transfer->setEnabled( false ); | 484 | m_transfer->setEnabled( false ); |
477 | m_recordScript->setEnabled( false ); | 485 | m_recordScript->setEnabled( false ); |
478 | m_saveScript->setEnabled( false ); | 486 | m_saveScript->setEnabled( false ); |
479 | m_scripts->setItemEnabled(m_runScript_id, false); | 487 | m_scripts->setItemEnabled(m_runScript_id, false); |
480 | m_fullscreen->setEnabled( false ); | 488 | m_fullscreen->setEnabled( false ); |
481 | m_wrap->setEnabled( false ); | 489 | m_wrap->setEnabled( false ); |
482 | m_closewindow->setEnabled( false ); | 490 | m_closewindow->setEnabled( false ); |
483 | } | 491 | } |
484 | 492 | ||
485 | m_kb->loadDefaults(); | 493 | m_kb->loadDefaults(); |
486 | } | 494 | } |
487 | 495 | ||
488 | /* | 496 | /* |
489 | * We will get the name | 497 | * We will get the name |
490 | * Then the profile | 498 | * Then the profile |
491 | * and then we will make a profile | 499 | * and then we will make a profile |
492 | */ | 500 | */ |
493 | void MainWindow::slotProfile( int id) { | 501 | void MainWindow::slotProfile( int id) { |
494 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 502 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
495 | create( prof ); | 503 | create( prof ); |
496 | } | 504 | } |
497 | 505 | ||
498 | 506 | ||
499 | 507 | ||
500 | void MainWindow::create( const Profile& prof ) { | 508 | void MainWindow::create( const Profile& prof ) { |
501 | if(m_curSession) | 509 | if(m_curSession) |
502 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 510 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
503 | 511 | ||
504 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 512 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
505 | 513 | ||
506 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 514 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
507 | { | 515 | { |
508 | QMessageBox::warning(this, | 516 | QMessageBox::warning(this, |
509 | QObject::tr("Session failed"), | 517 | QObject::tr("Session failed"), |
510 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 518 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
511 | //if(ses) delete ses; | 519 | //if(ses) delete ses; |
512 | return; | 520 | return; |
513 | } | 521 | } |
514 | 522 | ||
515 | m_sessions.append( ses ); | 523 | m_sessions.append( ses ); |
516 | tabWidget()->add( ses ); | 524 | tabWidget()->add( ses ); |
517 | tabWidget()->repaint(); | 525 | tabWidget()->repaint(); |
518 | m_curSession = ses; | 526 | m_curSession = ses; |
519 | 527 | ||
520 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 528 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
521 | m_connect->setEnabled( true ); | 529 | m_connect->setEnabled( true ); |
522 | m_disconnect->setEnabled( false ); | 530 | m_disconnect->setEnabled( false ); |
523 | m_terminate->setEnabled( true ); | 531 | m_terminate->setEnabled( true ); |
524 | m_fullscreen->setEnabled( true ); | 532 | m_fullscreen->setEnabled( true ); |
525 | m_wrap->setEnabled( true ); | 533 | m_wrap->setEnabled( true ); |
526 | m_closewindow->setEnabled( true ); | 534 | m_closewindow->setEnabled( true ); |
527 | m_transfer->setEnabled( false ); | 535 | m_transfer->setEnabled( false ); |
528 | m_recordScript->setEnabled( false ); | 536 | m_recordScript->setEnabled( false ); |
529 | m_saveScript->setEnabled( false ); | 537 | m_saveScript->setEnabled( false ); |
530 | m_scripts->setItemEnabled(m_runScript_id, false); | 538 | m_scripts->setItemEnabled(m_runScript_id, false); |
531 | 539 | ||
532 | // is io_layer wants direct connection, then autoconnect | 540 | // is io_layer wants direct connection, then autoconnect |
533 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 541 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
534 | if (prof.autoConnect()) { | 542 | if (prof.autoConnect()) { |
535 | slotConnect(); | 543 | slotConnect(); |
536 | } | 544 | } |
537 | 545 | ||
538 | QWidget *w = currentSession()->widget(); | 546 | QWidget *w = currentSession()->widget(); |
539 | if(w) w->setFocus(); | 547 | if(w) w->setFocus(); |
540 | 548 | ||
541 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 549 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
542 | m_isWrapped = true; | 550 | m_isWrapped = true; |
543 | } else { | 551 | } else { |
544 | m_isWrapped = false; | 552 | m_isWrapped = false; |
545 | } | 553 | } |
546 | 554 | ||
547 | m_kb->load(currentSession()->profile()); | 555 | m_kb->load(currentSession()->profile()); |
548 | } | 556 | } |
549 | 557 | ||
550 | void MainWindow::slotTransfer() | 558 | void MainWindow::slotTransfer() |
551 | { | 559 | { |
552 | if ( currentSession() ) { | 560 | if ( currentSession() ) { |
553 | Session *mysession = currentSession(); | 561 | Session *mysession = currentSession(); |
554 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); | 562 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
555 | mysession->setTransferDialog(&dlg); | 563 | mysession->setTransferDialog(&dlg); |
556 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); | 564 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
557 | //dlg.showMaximized(); | 565 | //dlg.showMaximized(); |
558 | currentSession()->widgetStack()->addWidget(&dlg, -1); | 566 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
559 | dlg.show(); | 567 | dlg.show(); |
560 | //dlg.exec(); | 568 | //dlg.exec(); |
561 | while(dlg.isRunning()) qApp->processEvents(); | 569 | while(dlg.isRunning()) qApp->processEvents(); |
562 | mysession->setTransferDialog(0l); | 570 | mysession->setTransferDialog(0l); |
563 | } | 571 | } |
564 | } | 572 | } |
565 | 573 | ||
566 | 574 | ||
567 | void MainWindow::slotOpenKeb(bool state) { | 575 | void MainWindow::slotOpenKeb(bool state) { |
568 | 576 | ||
569 | if (state) m_keyBar->show(); | 577 | if (state) m_keyBar->show(); |
570 | else m_keyBar->hide(); | 578 | else m_keyBar->hide(); |
571 | 579 | ||
572 | } | 580 | } |
573 | 581 | ||
574 | 582 | ||
575 | void MainWindow::slotOpenButtons( bool state ) { | 583 | void MainWindow::slotOpenButtons( bool state ) { |
576 | 584 | ||
577 | if ( state ) { | 585 | if ( state ) { |
578 | m_buttonBar->show(); | 586 | m_buttonBar->show(); |
579 | } else { | 587 | } else { |
580 | m_buttonBar->hide(); | 588 | m_buttonBar->hide(); |
581 | } | 589 | } |
582 | } | 590 | } |
583 | 591 | ||
584 | 592 | ||
585 | 593 | ||
586 | void MainWindow::slotSessionChanged( Session* ses ) { | 594 | void MainWindow::slotSessionChanged( Session* ses ) { |
587 | owarn << "changed!" << oendl; | 595 | owarn << "changed!" << oendl; |
588 | 596 | ||
589 | if(m_curSession) | 597 | if(m_curSession) |
590 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 598 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
591 | if(ses) | 599 | if(ses) |
592 | if(ses->transferDialog()) ses->transferDialog()->show(); | 600 | if(ses->transferDialog()) ses->transferDialog()->show(); |
593 | 601 | ||
594 | if ( ses ) { | 602 | if ( ses ) { |
595 | m_curSession = ses; | 603 | m_curSession = ses; |
596 | odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl; | 604 | odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl; |
597 | if ( m_curSession->layer()->isConnected() ) { | 605 | if ( m_curSession->layer()->isConnected() ) { |
598 | m_connect->setEnabled( false ); | 606 | m_connect->setEnabled( false ); |
599 | m_disconnect->setEnabled( true ); | 607 | m_disconnect->setEnabled( true ); |
600 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 608 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
601 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 609 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
602 | m_scripts->setItemEnabled(m_runScript_id, true); | 610 | m_scripts->setItemEnabled(m_runScript_id, true); |
603 | } else { | 611 | } else { |
604 | m_connect->setEnabled( true ); | 612 | m_connect->setEnabled( true ); |
605 | m_disconnect->setEnabled( false ); | 613 | m_disconnect->setEnabled( false ); |
606 | m_recordScript->setEnabled( false ); | 614 | m_recordScript->setEnabled( false ); |
607 | m_saveScript->setEnabled( false ); | 615 | m_saveScript->setEnabled( false ); |
608 | m_scripts->setItemEnabled(m_runScript_id, false); | 616 | m_scripts->setItemEnabled(m_runScript_id, false); |
609 | } | 617 | } |
610 | 618 | ||
619 | if ( ( currentSession()->emulationHandler()->isLogging() ) ) { | ||
620 | m_recordLog->setText( tr("Stop log") ); | ||
621 | } else { | ||
622 | m_recordLog->setText( tr("Start log") ); | ||
623 | } | ||
624 | |||
611 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 625 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
612 | m_transfer->setEnabled( false ); | 626 | m_transfer->setEnabled( false ); |
613 | } else { | 627 | } else { |
614 | m_transfer->setEnabled( true ); | 628 | m_transfer->setEnabled( true ); |
615 | } | 629 | } |
616 | 630 | ||
617 | QWidget *w = m_curSession->widget(); | 631 | QWidget *w = m_curSession->widget(); |
618 | if(w) w->setFocus(); | 632 | if(w) w->setFocus(); |
619 | 633 | ||
620 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 634 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
621 | m_isWrapped = true; | 635 | m_isWrapped = true; |
622 | } else { | 636 | } else { |
623 | m_isWrapped = false; | 637 | m_isWrapped = false; |
624 | } | 638 | } |
625 | 639 | ||
626 | m_kb->load(currentSession()->profile()); | 640 | m_kb->load(currentSession()->profile()); |
627 | } | 641 | } |
628 | } | 642 | } |
629 | 643 | ||
630 | void MainWindow::slotWrap() | 644 | void MainWindow::slotWrap() |
631 | { | 645 | { |
632 | if(m_curSession) | 646 | if(m_curSession) |
633 | { | 647 | { |
634 | EmulationHandler *e = m_curSession->emulationHandler(); | 648 | EmulationHandler *e = m_curSession->emulationHandler(); |
635 | if(e) | 649 | if(e) |
636 | { | 650 | { |
637 | e->setWrap( m_isWrapped ? 80:0 ); | 651 | e->setWrap( m_isWrapped ? 80:0 ); |
638 | m_isWrapped = !m_isWrapped; | 652 | m_isWrapped = !m_isWrapped; |
639 | } | 653 | } |
640 | } | 654 | } |
641 | } | 655 | } |
642 | 656 | ||
643 | void MainWindow::slotFullscreen() { | 657 | void MainWindow::slotFullscreen() { |
644 | 658 | ||
645 | 659 | ||
646 | 660 | ||
647 | if ( m_isFullscreen ) { | 661 | if ( m_isFullscreen ) { |
648 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 662 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
649 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 663 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
650 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 664 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
651 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 665 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
652 | 666 | ||
653 | } else { | 667 | } else { |
654 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 668 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
655 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 669 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
656 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 670 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
657 | , QPoint(0,0), false ); | 671 | , QPoint(0,0), false ); |
658 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 672 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
659 | ( m_curSession->widgetStack() )->setFocus(); | 673 | ( m_curSession->widgetStack() )->setFocus(); |
660 | ( m_curSession->widgetStack() )->show(); | 674 | ( m_curSession->widgetStack() )->show(); |
661 | 675 | ||
662 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 676 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
663 | 677 | ||
664 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 678 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
665 | } | 679 | } |
666 | 680 | ||
667 | m_isFullscreen = !m_isFullscreen; | 681 | m_isFullscreen = !m_isFullscreen; |
668 | } | 682 | } |
669 | 683 | ||
670 | 684 | ||
671 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 685 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
672 | 686 | ||
673 | if ( m_curSession ) { | 687 | if ( m_curSession ) { |
674 | 688 | ||
675 | QEvent::Type state; | 689 | QEvent::Type state; |
676 | 690 | ||
677 | if (pressed) state = QEvent::KeyPress; | 691 | if (pressed) state = QEvent::KeyPress; |
678 | else state = QEvent::KeyRelease; | 692 | else state = QEvent::KeyRelease; |
679 | 693 | ||
680 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 694 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
681 | 695 | ||
682 | // is this the best way to do this? cant figure out any other way to work | 696 | // is this the best way to do this? cant figure out any other way to work |
683 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 697 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
684 | ke.ignore(); | 698 | ke.ignore(); |
685 | } | 699 | } |
686 | } | 700 | } |
687 | void MainWindow::slotCopy() { | 701 | void MainWindow::slotCopy() { |
688 | if (!currentSession() ) return; | 702 | if (!currentSession() ) return; |
689 | currentSession()->emulationHandler()->copy(); | 703 | currentSession()->emulationHandler()->copy(); |
690 | } | 704 | } |
691 | void MainWindow::slotPaste() { | 705 | void MainWindow::slotPaste() { |
692 | if (!currentSession() ) return; | 706 | if (!currentSession() ) return; |
693 | currentSession()->emulationHandler()->paste(); | 707 | currentSession()->emulationHandler()->paste(); |
694 | } | 708 | } |
695 | 709 | ||
696 | /* | 710 | /* |
697 | * Save the session | 711 | * Save the session |
698 | */ | 712 | */ |
699 | 713 | ||
700 | void MainWindow::slotSaveSession() { | 714 | void MainWindow::slotSaveSession() { |
701 | if (!currentSession() ) { | 715 | if (!currentSession() ) { |
702 | QMessageBox::information(this, tr("Save Connection"), | 716 | QMessageBox::information(this, tr("Save Connection"), |
703 | tr("<qt>There is no Connection.</qt>"), 1 ); | 717 | tr("<qt>There is no Connection.</qt>"), 1 ); |
704 | return; | 718 | return; |
705 | } | 719 | } |
706 | manager()->add( currentSession()->profile() ); | 720 | manager()->add( currentSession()->profile() ); |
707 | manager()->save(); | 721 | manager()->save(); |
708 | populateProfiles(); | 722 | populateProfiles(); |
709 | } | 723 | } |
724 | |||
725 | |||
726 | |||
727 | void MainWindow::slotSaveLog() { | ||
728 | |||
729 | if( currentSession()->emulationHandler()->isLogging() ) { | ||
730 | DocLnk nf; | ||
731 | QString m_logName = currentSession()->emulationHandler()->logFileName(); | ||
732 | QFileInfo info(m_logName); | ||
733 | nf.setType("text/plain"); | ||
734 | nf.setFile(m_logName); | ||
735 | nf.setName(info.fileName()); | ||
736 | nf.writeLink(); | ||
737 | m_recordLog->setText( tr("Start log") ); | ||
738 | m_recordingLog = false; | ||
739 | currentSession()->emulationHandler()->clearLog(); | ||
740 | } else { | ||
741 | QMap<QString, QStringList> map; | ||
742 | QStringList text; | ||
743 | text << "text/plain"; | ||
744 | map.insert(tr("Log"), text ); | ||
745 | QString m_logName = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | ||
746 | if (m_logName.isEmpty() ) return; | ||
747 | |||
748 | m_recordLog->setText( tr("Stop log") ); | ||
749 | m_recordingLog = true; | ||
750 | currentSession()->emulationHandler()->startLogging(m_logName); | ||
751 | } | ||
752 | } | ||
753 | |||
710 | void MainWindow::slotSaveHistory() { | 754 | void MainWindow::slotSaveHistory() { |
711 | QMap<QString, QStringList> map; | 755 | QMap<QString, QStringList> map; |
712 | QStringList text; | 756 | QStringList text; |
713 | text << "text/plain"; | 757 | text << "text/plain"; |
714 | map.insert(tr("History"), text ); | 758 | map.insert(tr("History"), text ); |
715 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 759 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
716 | if (filename.isEmpty() ) return; | 760 | if (filename.isEmpty() ) return; |
717 | 761 | ||
718 | QFileInfo info(filename); | 762 | QFileInfo info(filename); |
719 | 763 | ||
720 | DocLnk nf; | 764 | DocLnk nf; |
721 | nf.setType("text/plain"); | 765 | nf.setType("text/plain"); |
722 | nf.setFile(filename); | 766 | nf.setFile(filename); |
723 | nf.setName(info.fileName()); | 767 | nf.setName(info.fileName()); |
724 | 768 | ||
725 | 769 | ||
726 | QFile file(filename); | 770 | QFile file(filename); |
727 | file.open(IO_WriteOnly ); | 771 | file.open(IO_WriteOnly ); |
728 | QTextStream str(&file ); | 772 | QTextStream str(&file ); |
729 | if ( currentSession() ) | 773 | if ( currentSession() ) |
730 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 774 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
731 | 775 | ||
732 | file.close(); | 776 | file.close(); |
733 | nf.writeLink(); | 777 | nf.writeLink(); |
734 | } | 778 | } |
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index db07f5a..f3c8b81 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -1,139 +1,143 @@ | |||
1 | #ifndef OPIE_MAIN_WINDOW_H | 1 | #ifndef OPIE_MAIN_WINDOW_H |
2 | #define OPIE_MAIN_WINDOW_H | 2 | #define OPIE_MAIN_WINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | #include <qfile.h> | ||
6 | 7 | ||
7 | #include "session.h" | 8 | #include "session.h" |
8 | 9 | ||
9 | /** | 10 | /** |
10 | * this is the MainWindow of the new opie console | 11 | * this is the MainWindow of the new opie console |
11 | * it's also the dispatcher between the different | 12 | * it's also the dispatcher between the different |
12 | * actions supported by the gui | 13 | * actions supported by the gui |
13 | */ | 14 | */ |
14 | class QToolBar; | 15 | class QToolBar; |
15 | class QToolButton; | 16 | class QToolButton; |
16 | class QMenuBar; | 17 | class QMenuBar; |
17 | class QAction; | 18 | class QAction; |
18 | class MetaFactory; | 19 | class MetaFactory; |
19 | class TabWidget; | 20 | class TabWidget; |
20 | class ProfileManager; | 21 | class ProfileManager; |
21 | class Profile; | 22 | class Profile; |
22 | class FunctionKeyboard; | 23 | class FunctionKeyboard; |
23 | class FKey; | 24 | class FKey; |
24 | class DocLnk; | 25 | class DocLnk; |
25 | 26 | ||
26 | class MainWindow : public QMainWindow { | 27 | class MainWindow : public QMainWindow { |
27 | Q_OBJECT | 28 | Q_OBJECT |
28 | public: | 29 | public: |
29 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); | 30 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); |
30 | ~MainWindow(); | 31 | ~MainWindow(); |
31 | static QString appName() {return QString::fromLatin1("opie-console"); } | 32 | static QString appName() {return QString::fromLatin1("opie-console"); } |
32 | 33 | ||
33 | /** | 34 | /** |
34 | * our factory to generate IOLayer and so on | 35 | * our factory to generate IOLayer and so on |
35 | * | 36 | * |
36 | */ | 37 | */ |
37 | MetaFactory* factory(); | 38 | MetaFactory* factory(); |
38 | 39 | ||
39 | /** | 40 | /** |
40 | * A session contains a QWidget*, | 41 | * A session contains a QWidget*, |
41 | * an IOLayer* and some infos for us | 42 | * an IOLayer* and some infos for us |
42 | */ | 43 | */ |
43 | Session* currentSession(); | 44 | Session* currentSession(); |
44 | 45 | ||
45 | /** | 46 | /** |
46 | * the session list | 47 | * the session list |
47 | */ | 48 | */ |
48 | QList<Session> sessions(); | 49 | QList<Session> sessions(); |
49 | 50 | ||
50 | /** | 51 | /** |
51 | * | 52 | * |
52 | */ | 53 | */ |
53 | ProfileManager* manager(); | 54 | ProfileManager* manager(); |
54 | TabWidget* tabWidget(); | 55 | TabWidget* tabWidget(); |
55 | 56 | ||
56 | private slots: | 57 | private slots: |
57 | void slotNew(); | 58 | void slotNew(); |
58 | void slotConnect(); | 59 | void slotConnect(); |
59 | void slotDisconnect(); | 60 | void slotDisconnect(); |
60 | void slotTerminate(); | 61 | void slotTerminate(); |
61 | void slotConfigure(); | 62 | void slotConfigure(); |
62 | void slotClose(); | 63 | void slotClose(); |
63 | void slotProfile(int); | 64 | void slotProfile(int); |
64 | void slotTransfer(); | 65 | void slotTransfer(); |
65 | void slotOpenKeb(bool); | 66 | void slotOpenKeb(bool); |
66 | void slotOpenButtons(bool); | 67 | void slotOpenButtons(bool); |
67 | void slotRecordScript(); | 68 | void slotRecordScript(); |
68 | void slotSaveScript(); | 69 | void slotSaveScript(); |
69 | void slotRunScript(int); | 70 | void slotRunScript(int); |
70 | void slotFullscreen(); | 71 | void slotFullscreen(); |
71 | void slotQuickLaunch(); | 72 | void slotQuickLaunch(); |
72 | void slotWrap(); | 73 | void slotWrap(); |
73 | void slotSessionChanged( Session* ); | 74 | void slotSessionChanged( Session* ); |
74 | void slotKeyReceived(FKey, ushort, ushort, bool); | 75 | void slotKeyReceived(FKey, ushort, ushort, bool); |
75 | void slotSaveHistory(); | 76 | void slotSaveHistory(); |
77 | void slotSaveLog(); | ||
76 | 78 | ||
77 | /* what could these both slot do? */ | 79 | /* what could these both slot do? */ |
78 | void slotCopy(); | 80 | void slotCopy(); |
79 | void slotPaste(); | 81 | void slotPaste(); |
80 | 82 | ||
81 | /* save the currentSession() to Profiles */ | 83 | /* save the currentSession() to Profiles */ |
82 | void slotSaveSession(); | 84 | void slotSaveSession(); |
83 | 85 | ||
84 | private: | 86 | private: |
85 | void initUI(); | 87 | void initUI(); |
86 | void populateProfiles(); | 88 | void populateProfiles(); |
87 | void populateScripts(); | 89 | void populateScripts(); |
88 | void create( const Profile& ); | 90 | void create( const Profile& ); |
89 | /** | 91 | /** |
90 | * the current session | 92 | * the current session |
91 | */ | 93 | */ |
92 | Session* m_curSession; | 94 | Session* m_curSession; |
93 | 95 | ||
94 | /** | 96 | /** |
95 | * the session list | 97 | * the session list |
96 | */ | 98 | */ |
97 | QList<Session> m_sessions; | 99 | QList<Session> m_sessions; |
98 | QList<DocLnk> m_scriptsData; | 100 | QList<DocLnk> m_scriptsData; |
99 | 101 | ||
100 | /** | 102 | /** |
101 | * the metafactory | 103 | * the metafactory |
102 | */ | 104 | */ |
103 | MetaFactory* m_factory; | 105 | MetaFactory* m_factory; |
104 | ProfileManager* m_manager; | 106 | ProfileManager* m_manager; |
105 | 107 | ||
106 | TabWidget* m_consoleWindow; | 108 | TabWidget* m_consoleWindow; |
107 | QToolBar* m_tool; | 109 | QToolBar* m_tool; |
108 | QToolBar* m_icons; | 110 | QToolBar* m_icons; |
109 | QToolBar* m_keyBar; | 111 | QToolBar* m_keyBar; |
110 | QToolBar* m_buttonBar; | 112 | QToolBar* m_buttonBar; |
111 | QMenuBar* m_bar; | 113 | QMenuBar* m_bar; |
112 | QPopupMenu* m_console; | 114 | QPopupMenu* m_console; |
113 | QPopupMenu* m_sessionsPop; | 115 | QPopupMenu* m_sessionsPop; |
114 | QPopupMenu* m_scriptsPop; | 116 | QPopupMenu* m_scriptsPop; |
115 | QPopupMenu* m_scripts; | 117 | QPopupMenu* m_scripts; |
116 | QAction* m_connect; | 118 | QAction* m_connect; |
117 | QAction* m_disconnect; | 119 | QAction* m_disconnect; |
118 | QAction* m_quickLaunch; | 120 | QAction* m_quickLaunch; |
119 | QAction* m_terminate; | 121 | QAction* m_terminate; |
120 | QAction* m_transfer; | 122 | QAction* m_transfer; |
121 | QAction* m_setProfiles; | 123 | QAction* m_setProfiles; |
122 | QAction* m_openKeys; | 124 | QAction* m_openKeys; |
123 | QAction* m_openButtons; | 125 | QAction* m_openButtons; |
124 | QAction* m_recordScript; | 126 | QAction* m_recordScript; |
125 | QAction* m_saveScript; | 127 | QAction* m_saveScript; |
126 | QAction* m_fullscreen; | 128 | QAction* m_fullscreen; |
127 | QAction* m_wrap; | 129 | QAction* m_wrap; |
128 | QAction* m_closewindow; | 130 | QAction* m_closewindow; |
131 | QAction* m_recordLog; | ||
129 | 132 | ||
130 | FunctionKeyboard *m_kb; | 133 | FunctionKeyboard *m_kb; |
131 | int m_runScript_id; | 134 | int m_runScript_id; |
132 | bool m_isFullscreen; | 135 | bool m_isFullscreen; |
133 | bool m_isWrapped; | 136 | bool m_isWrapped; |
137 | bool m_recordingLog; | ||
134 | 138 | ||
135 | QWidget* savedParentFullscreen; | 139 | QWidget* savedParentFullscreen; |
136 | }; | 140 | }; |
137 | 141 | ||
138 | 142 | ||
139 | #endif | 143 | #endif |
diff --git a/noncore/apps/opie-console/opie-console-embedix.control b/noncore/apps/opie-console/opie-console-embedix.control new file mode 100644 index 0000000..cf27554 --- a/dev/null +++ b/noncore/apps/opie-console/opie-console-embedix.control | |||
@@ -0,0 +1,10 @@ | |||
1 | Package: opie-console | ||
2 | Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* share/opie-console/* | ||
3 | Priority: optional | ||
4 | Section: opie/applications | ||
5 | Maintainer: Opie Team <opie@handhelds.org> | ||
6 | Architecture: arm | ||
7 | Version: 0.6-$SUB_VERSION | ||
8 | Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs | ||
9 | License: GPL | ||
10 | Description: Opie terminal app | ||
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 6bc42bd..223cb91 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -1,74 +1,74 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ | 3 | HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ |
4 | file_layer.h filetransfer.h \ | 4 | file_layer.h filetransfer.h \ |
5 | metafactory.h \ | 5 | metafactory.h \ |
6 | session.h \ | 6 | session.h \ |
7 | mainwindow.h \ | 7 | mainwindow.h \ |
8 | profile.h \ | 8 | profile.h \ |
9 | profileconfig.h \ | 9 | profileconfig.h \ |
10 | profilemanager.h \ | 10 | profilemanager.h \ |
11 | tabwidget.h \ | 11 | tabwidget.h \ |
12 | configdialog.h \ | 12 | configdialog.h \ |
13 | keytrans.h \ | 13 | keytrans.h \ |
14 | transferdialog.h \ | 14 | transferdialog.h \ |
15 | profiledialogwidget.h \ | 15 | profiledialogwidget.h \ |
16 | profileeditordialog.h \ | 16 | profileeditordialog.h \ |
17 | default.h \ | 17 | default.h \ |
18 | iolayerbase.h \ | 18 | iolayerbase.h \ |
19 | serialconfigwidget.h irdaconfigwidget.h \ | 19 | serialconfigwidget.h irdaconfigwidget.h \ |
20 | btconfigwidget.h modemconfigwidget.h \ | 20 | btconfigwidget.h modemconfigwidget.h \ |
21 | atconfigdialog.h dialdialog.h \ | 21 | atconfigdialog.h dialdialog.h \ |
22 | procctl.h \ | 22 | procctl.h \ |
23 | function_keyboard.h \ | 23 | function_keyboard.h \ |
24 | receive_layer.h filereceive.h \ | 24 | receive_layer.h filereceive.h \ |
25 | script.h \ | 25 | script.h \ |
26 | dialer.h \ | 26 | dialer.h logger.h \ |
27 | terminalwidget.h \ | 27 | terminalwidget.h \ |
28 | emulation_handler.h TECommon.h \ | 28 | emulation_handler.h TECommon.h \ |
29 | TEHistory.h TEScreen.h TEWidget.h \ | 29 | TEHistory.h TEScreen.h TEWidget.h \ |
30 | TEmuVt102.h TEmulation.h MyPty.h \ | 30 | TEmuVt102.h TEmulation.h MyPty.h \ |
31 | consoleconfigwidget.h | 31 | consoleconfigwidget.h fixit.h |
32 | 32 | ||
33 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ | 33 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ |
34 | file_layer.cpp filetransfer.cpp \ | 34 | file_layer.cpp filetransfer.cpp \ |
35 | main.cpp \ | 35 | main.cpp \ |
36 | metafactory.cpp \ | 36 | metafactory.cpp \ |
37 | session.cpp \ | 37 | session.cpp \ |
38 | mainwindow.cpp \ | 38 | mainwindow.cpp \ |
39 | profile.cpp \ | 39 | profile.cpp \ |
40 | profileconfig.cpp \ | 40 | profileconfig.cpp \ |
41 | profilemanager.cpp \ | 41 | profilemanager.cpp \ |
42 | tabwidget.cpp \ | 42 | tabwidget.cpp \ |
43 | configdialog.cpp \ | 43 | configdialog.cpp \ |
44 | keytrans.cpp \ | 44 | keytrans.cpp \ |
45 | transferdialog.cpp \ | 45 | transferdialog.cpp \ |
46 | profiledialogwidget.cpp \ | 46 | profiledialogwidget.cpp \ |
47 | profileeditordialog.cpp \ | 47 | profileeditordialog.cpp \ |
48 | iolayerbase.cpp \ | 48 | iolayerbase.cpp \ |
49 | serialconfigwidget.cpp irdaconfigwidget.cpp \ | 49 | serialconfigwidget.cpp irdaconfigwidget.cpp \ |
50 | btconfigwidget.cpp modemconfigwidget.cpp \ | 50 | btconfigwidget.cpp modemconfigwidget.cpp \ |
51 | atconfigdialog.cpp dialdialog.cpp \ | 51 | atconfigdialog.cpp dialdialog.cpp \ |
52 | default.cpp procctl.cpp \ | 52 | default.cpp procctl.cpp \ |
53 | function_keyboard.cpp \ | 53 | function_keyboard.cpp \ |
54 | receive_layer.cpp filereceive.cpp \ | 54 | receive_layer.cpp filereceive.cpp \ |
55 | script.cpp \ | 55 | script.cpp \ |
56 | dialer.cpp \ | 56 | dialer.cpp logger.cpp \ |
57 | terminalwidget.cpp \ | 57 | terminalwidget.cpp \ |
58 | emulation_handler.cpp TEHistory.cpp \ | 58 | emulation_handler.cpp TEHistory.cpp \ |
59 | TEScreen.cpp TEWidget.cpp \ | 59 | TEScreen.cpp TEWidget.cpp \ |
60 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ | 60 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ |
61 | consoleconfigwidget.cpp | 61 | consoleconfigwidget.cpp fixit.cpp |
62 | 62 | ||
63 | 63 | ||
64 | DESTDIR = $(OPIEDIR)/bin/ | 64 | DESTDIR = $(OPIEDIR)/bin/ |
65 | INTERFACES = configurebase.ui editbase.ui | 65 | INTERFACES = configurebase.ui editbase.ui |
66 | INCLUDEPATH += $(OPIEDIR)/include | 66 | INCLUDEPATH += $(OPIEDIR)/include |
67 | DEPENDPATH += $(OPIEDIR)/include | 67 | DEPENDPATH += $(OPIEDIR)/include |
68 | LIBS += -lqpe -lopiecore2 -lopieui2 -lutil | 68 | LIBS += -lqpe -lopiecore2 -lopieui2 |
69 | TARGET = opie-console | 69 | TARGET = opie-console |
70 | 70 | ||
71 | DEFINES += HAVE_OPENPTY | 71 | #DEFINES += HAVE_OPENPTY |
72 | 72 | #DEFINES += EAST FSCKED_DISTRI | |
73 | 73 | ||
74 | include ( $(OPIEDIR)/include.pro ) | 74 | include ( $(OPIEDIR)/include.pro ) |