-rw-r--r-- | noncore/apps/opie-console/BUGS | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 23 | ||||
-rw-r--r-- | noncore/apps/opie-console/MyPty.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_layer.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 15 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.cpp | 1 |
11 files changed, 72 insertions, 20 deletions
diff --git a/noncore/apps/opie-console/BUGS b/noncore/apps/opie-console/BUGS new file mode 100644 index 0000000..ffaceef --- a/dev/null +++ b/noncore/apps/opie-console/BUGS | |||
@@ -0,0 +1,9 @@ | |||
1 | Ok we all know we write perfect code | ||
2 | but sometimes the compiler produces bad code | ||
3 | and we need to work around some compiler bugs!! -zecke | ||
4 | |||
5 | MyPty is broken in some ways | ||
6 | if you do connect/disconnect/connect sh will be executed in the | ||
7 | process of opie-console.... funny aye? | ||
8 | |||
9 | OTabWidget seems to give us problems too | ||
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index b6ae1d9..565d03f 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -88,222 +88,237 @@ | |||
88 | 88 | ||
89 | #undef VERBOSE_DEBUG | 89 | #undef VERBOSE_DEBUG |
90 | 90 | ||
91 | 91 | ||
92 | /* -------------------------------------------------------------------------- */ | 92 | /* -------------------------------------------------------------------------- */ |
93 | 93 | ||
94 | /*! | 94 | /*! |
95 | Informs the client program about the | 95 | Informs the client program about the |
96 | actual size of the window. | 96 | actual size of the window. |
97 | */ | 97 | */ |
98 | 98 | ||
99 | void MyPty::setSize(int lines, int columns) | 99 | void MyPty::setSize(int lines, int columns) |
100 | { | 100 | { |
101 | struct winsize wsize; | 101 | struct winsize wsize; |
102 | wsize.ws_row = (unsigned short)lines; | 102 | wsize.ws_row = (unsigned short)lines; |
103 | wsize.ws_col = (unsigned short)columns; | 103 | wsize.ws_col = (unsigned short)columns; |
104 | if(m_fd < 0) return; | 104 | if(m_fd < 0) return; |
105 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); | 105 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | void MyPty::donePty() | 109 | void MyPty::donePty() |
110 | { | 110 | { |
111 | // This is code from the Qt DumbTerminal example | 111 | // This is code from the Qt DumbTerminal example |
112 | int status = 0; | 112 | int status = 0; |
113 | 113 | ||
114 | ::close(m_fd); | 114 | ::close(m_fd); |
115 | 115 | ||
116 | if (m_cpid) { | 116 | if (m_cpid) { |
117 | kill(m_cpid, SIGHUP); | 117 | kill(m_cpid, SIGHUP); |
118 | //waitpid(m_cpid, &status, 0); | 118 | //waitpid(m_cpid, &status, 0); |
119 | delete m_sn_e; | 119 | delete m_sn_e; |
120 | delete m_sn_r; | ||
120 | m_sn_e = 0l; | 121 | m_sn_e = 0l; |
122 | m_sn_r = 0l; | ||
121 | } | 123 | } |
122 | 124 | ||
123 | m_cpid = 0; | 125 | m_cpid = 0; |
126 | m_fd = -1; | ||
124 | // emit done(status); | 127 | // emit done(status); |
125 | } | 128 | } |
126 | 129 | ||
127 | 130 | ||
128 | const char* MyPty::deviceName() | 131 | const char* MyPty::deviceName() |
129 | { | 132 | { |
130 | return m_ttynam; | 133 | return m_ttynam; |
131 | } | 134 | } |
132 | 135 | ||
133 | 136 | ||
134 | void MyPty::error() | 137 | void MyPty::error() |
135 | { | 138 | { |
136 | // This is code from the Qt DumbTerminal example | 139 | // This is code from the Qt DumbTerminal example |
137 | donePty(); | 140 | donePty(); |
138 | } | 141 | } |
139 | 142 | ||
140 | void MyPty::start() { | 143 | void MyPty::start() { |
141 | char* cmd = "/bin/sh"; | 144 | char* cmd = "/bin/sh"; |
142 | QStrList lis; | 145 | QStrList lis; |
143 | int r =run(cmd, lis, 0, 0); | 146 | int r =run(cmd, lis, 0, 0); |
144 | r = r; | 147 | r = r; |
145 | } | 148 | } |
146 | /*! | 149 | /*! |
147 | start the client program. | 150 | start the client program. |
148 | */ | 151 | */ |
149 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 152 | int MyPty::run(const char* cmd, QStrList &, const char*, int) |
150 | { | 153 | { |
151 | // This is code from the Qt DumbTerminal example | 154 | // This is code from the Qt DumbTerminal example |
152 | m_cpid = fork(); | 155 | m_cpid = fork(); |
153 | 156 | ||
154 | if ( !m_cpid ) { | 157 | if ( !m_cpid ) { |
155 | // child - exec shell on tty | 158 | // child - exec shell on tty |
156 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); | 159 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); |
157 | int ttyfd = ::open(m_ttynam, O_RDWR); | 160 | int ttyfd = ::open(m_ttynam, O_RDWR); |
158 | dup2(ttyfd, STDIN_FILENO); | 161 | dup2(ttyfd, STDIN_FILENO); |
159 | dup2(ttyfd, STDOUT_FILENO); | 162 | dup2(ttyfd, STDOUT_FILENO); |
160 | dup2(ttyfd, STDERR_FILENO); | 163 | dup2(ttyfd, STDERR_FILENO); |
161 | // should be done with tty, so close it | 164 | // should be done with tty, so close it |
162 | ::close(ttyfd); | 165 | ::close(ttyfd); |
163 | static struct termios ttmode; | 166 | static struct termios ttmode; |
164 | if ( setsid() < 0 ) | 167 | if ( setsid() < 0 ) |
165 | perror( "failed to set process group" ); | 168 | perror( "failed to set process group" ); |
166 | #if defined (TIOCSCTTY) | 169 | #if defined (TIOCSCTTY) |
167 | // grabbed from APUE by Stevens | 170 | // grabbed from APUE by Stevens |
168 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 171 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
169 | #endif | 172 | #endif |
170 | tcgetattr( STDIN_FILENO, &ttmode ); | 173 | tcgetattr( STDIN_FILENO, &ttmode ); |
171 | ttmode.c_cc[VINTR] = 3; | 174 | ttmode.c_cc[VINTR] = 3; |
172 | ttmode.c_cc[VERASE] = 8; | 175 | ttmode.c_cc[VERASE] = 8; |
173 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 176 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
174 | setenv("TERM","vt100",1); | 177 | setenv("TERM","vt100",1); |
175 | setenv("COLORTERM","0",1); | 178 | setenv("COLORTERM","0",1); |
176 | 179 | ||
177 | if (getuid() == 0) { | 180 | if (getuid() == 0) { |
178 | char msg[] = "WARNING: You are running this shell as root!\n"; | 181 | char msg[] = "WARNING: You are running this shell as root!\n"; |
179 | write(ttyfd, msg, sizeof(msg)); | 182 | write(ttyfd, msg, sizeof(msg)); |
180 | } | 183 | } |
181 | execl(cmd, cmd, 0); | 184 | execl(cmd, cmd, 0); |
182 | 185 | ||
183 | donePty(); | 186 | donePty(); |
184 | exit(-1); | 187 | exit(-1); |
185 | } | 188 | } |
186 | 189 | ||
187 | // parent - continue as a widget | 190 | // parent - continue as a widget |
188 | QSocketNotifier* sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); | 191 | delete m_sn_r; |
192 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); | ||
189 | delete m_sn_e; | 193 | delete m_sn_e; |
190 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); | 194 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); |
191 | connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); | 195 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); |
192 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); | 196 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); |
193 | 197 | ||
194 | return 0; | 198 | return 0; |
195 | } | 199 | } |
196 | 200 | ||
197 | int MyPty::openPty() | 201 | int MyPty::openPty() |
198 | { | 202 | { |
199 | // This is code from the Qt DumbTerminal example | 203 | // This is code from the Qt DumbTerminal example |
200 | int ptyfd = -1; | 204 | int ptyfd = -1; |
201 | 205 | ||
202 | #ifdef HAVE_OPENPTY | 206 | #ifdef HAVE_OPENPTY |
203 | int ttyfd; | 207 | int ttyfd; |
204 | if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) | 208 | if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) |
205 | ptyfd = -1; | 209 | ptyfd = -1; |
206 | else | 210 | else |
207 | close(ttyfd); // we open the ttynam ourselves. | 211 | close(ttyfd); // we open the ttynam ourselves. |
208 | #else | 212 | #else |
209 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { | 213 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { |
210 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { | 214 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { |
211 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); | 215 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); |
212 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); | 216 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); |
213 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { | 217 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { |
214 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { | 218 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { |
215 | ::close(ptyfd); | 219 | ::close(ptyfd); |
216 | ptyfd = -1; | 220 | ptyfd = -1; |
217 | } | 221 | } |
218 | } | 222 | } |
219 | } | 223 | } |
220 | } | 224 | } |
221 | #endif | 225 | #endif |
222 | 226 | ||
223 | if ( ptyfd < 0 ) { | 227 | if ( ptyfd < 0 ) { |
224 | qApp->exit(1); | 228 | //qApp->exit(1); |
225 | return -1; | 229 | return -1; |
226 | } | 230 | } |
227 | 231 | ||
228 | return ptyfd; | 232 | return ptyfd; |
229 | } | 233 | } |
230 | 234 | ||
231 | /*! | 235 | /*! |
232 | Create an instance. | 236 | Create an instance. |
233 | */ | 237 | */ |
234 | MyPty::MyPty(const Profile&) : m_cpid(0) | 238 | MyPty::MyPty(const Profile&) : m_cpid(0) |
235 | { | 239 | { |
236 | m_sn_e = 0l; | 240 | m_sn_e = 0l; |
241 | m_sn_r = 0l; | ||
237 | m_fd = openPty(); | 242 | m_fd = openPty(); |
238 | ProcCtl* ctl = ProcCtl::self(); | 243 | ProcCtl* ctl = ProcCtl::self(); |
239 | } | 244 | } |
240 | 245 | ||
241 | /*! | 246 | /*! |
242 | Destructor. | 247 | Destructor. |
243 | Note that the related client program is not killed | 248 | Note that the related client program is not killed |
244 | (yet) when a instance is deleted. | 249 | (yet) when a instance is deleted. |
245 | */ | 250 | */ |
246 | MyPty::~MyPty() | 251 | MyPty::~MyPty() |
247 | { | 252 | { |
248 | donePty(); | 253 | donePty(); |
249 | } | 254 | } |
250 | QString MyPty::identifier()const { | 255 | QString MyPty::identifier()const { |
251 | return QString::fromLatin1("term"); | 256 | return QString::fromLatin1("term"); |
252 | } | 257 | } |
253 | QString MyPty::name()const{ | 258 | QString MyPty::name()const{ |
254 | return identifier(); | 259 | return identifier(); |
255 | } | 260 | } |
256 | bool MyPty::open() { | 261 | bool MyPty::open() { |
262 | if (m_fd < 0) | ||
263 | m_fd = openPty(); | ||
264 | |||
257 | start(); | 265 | start(); |
258 | return true; | 266 | return true; |
259 | } | 267 | } |
260 | void MyPty::close() { | 268 | void MyPty::close() { |
261 | donePty(); | 269 | donePty(); |
270 | m_fd = openPty(); | ||
262 | } | 271 | } |
263 | void MyPty::reload( const Profile& ) { | 272 | void MyPty::reload( const Profile& ) { |
264 | 273 | ||
265 | } | 274 | } |
266 | /*! sends len bytes through the line */ | 275 | /*! sends len bytes through the line */ |
267 | void MyPty::send(const QByteArray& ar) | 276 | void MyPty::send(const QByteArray& ar) |
268 | { | 277 | { |
269 | #ifdef VERBOSE_DEBUG | 278 | #ifdef VERBOSE_DEBUG |
270 | // verbose debug | 279 | // verbose debug |
271 | printf("sending bytes:\n"); | 280 | printf("sending bytes:\n"); |
272 | for (uint i = 0; i < ar.count(); i++) | 281 | for (uint i = 0; i < ar.count(); i++) |
273 | printf("%c", ar[i]); | 282 | printf("%c", ar[i]); |
274 | printf("\n"); | 283 | printf("\n"); |
275 | #endif | 284 | #endif |
276 | 285 | ||
277 | ::write(m_fd, ar.data(), ar.count()); | 286 | ::write(m_fd, ar.data(), ar.count()); |
278 | } | 287 | } |
279 | 288 | ||
280 | /*! indicates that a block of data is received */ | 289 | /*! indicates that a block of data is received */ |
281 | void MyPty::readPty() | 290 | void MyPty::readPty() |
282 | { | 291 | { |
283 | QByteArray buf(4096); | 292 | QByteArray buf(4096); |
284 | 293 | ||
285 | int len = ::read( m_fd, buf.data(), 4096 ); | 294 | int len = ::read( m_fd, buf.data(), 4096 ); |
286 | 295 | ||
287 | if (len == -1 || len == 0) { | 296 | if (len == -1 || len == 0) { |
288 | donePty(); | 297 | donePty(); |
289 | delete sender(); | ||
290 | return; | 298 | return; |
291 | } | 299 | } |
292 | 300 | ||
293 | if (len < 0) | 301 | if (len < 0) |
294 | return; | 302 | return; |
295 | 303 | ||
296 | 304 | ||
297 | buf.resize(len); | 305 | buf.resize(len); |
298 | emit received(buf); | 306 | emit received(buf); |
299 | 307 | ||
300 | #ifdef VERBOSE_DEBUG | 308 | #ifdef VERBOSE_DEBUG |
301 | // verbose debug | 309 | // verbose debug |
302 | printf("read bytes:\n"); | 310 | printf("read bytes:\n"); |
303 | for (uint i = 0; i < buf.count(); i++) | 311 | for (uint i = 0; i < buf.count(); i++) |
304 | printf("%c", buf[i]); | 312 | printf("%c", buf[i]); |
305 | printf("\n"); | 313 | printf("\n"); |
306 | #endif | 314 | #endif |
307 | 315 | ||
308 | } | 316 | } |
317 | QBitArray MyPty::supports()const { | ||
318 | QBitArray ar(3); | ||
319 | ar[0] = 1; | ||
320 | ar[1] = 0; | ||
321 | ar[2] = 0; | ||
309 | 322 | ||
323 | return ar; | ||
324 | } | ||
diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h index 3166fa0..ad271df 100644 --- a/noncore/apps/opie-console/MyPty.h +++ b/noncore/apps/opie-console/MyPty.h | |||
@@ -12,86 +12,88 @@ | |||
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /*! \file | 19 | /*! \file |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef MY_PTY_H | 22 | #ifndef MY_PTY_H |
23 | #define MY_PTY_H | 23 | #define MY_PTY_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstrlist.h> | 26 | #include <qstrlist.h> |
27 | 27 | ||
28 | #include "io_layer.h" | 28 | #include "io_layer.h" |
29 | 29 | ||
30 | class Profile; | 30 | class Profile; |
31 | class QSocketNotifier; | 31 | class QSocketNotifier; |
32 | class MyPty : public IOLayer | 32 | class MyPty : public IOLayer |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | 36 | ||
37 | MyPty(const Profile&); | 37 | MyPty(const Profile&); |
38 | ~MyPty(); | 38 | ~MyPty(); |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | QString identifier()const; | 42 | QString identifier()const; |
43 | QString name()const; | 43 | QString name()const; |
44 | QBitArray supports()const; | ||
44 | 45 | ||
45 | public slots: | 46 | public slots: |
46 | /*! | 47 | /*! |
47 | having a `run' separate from the constructor allows to make | 48 | having a `run' separate from the constructor allows to make |
48 | the necessary connections to the signals and slots of the | 49 | the necessary connections to the signals and slots of the |
49 | instance before starting the execution of the client. | 50 | instance before starting the execution of the client. |
50 | */ | 51 | */ |
51 | void start(); | 52 | void start(); |
52 | int run(const char* pgm, QStrList & args , const char* term, int addutmp); | 53 | int run(const char* pgm, QStrList & args , const char* term, int addutmp); |
53 | bool open(); | 54 | bool open(); |
54 | void close(); | 55 | void close(); |
55 | void reload( const Profile& ); | 56 | void reload( const Profile& ); |
56 | void setSize(int lines, int columns); | 57 | void setSize(int lines, int columns); |
57 | void error(); | 58 | void error(); |
58 | 59 | ||
59 | signals: | 60 | signals: |
60 | 61 | ||
61 | /*! | 62 | /*! |
62 | emitted when the client program terminates. | 63 | emitted when the client program terminates. |
63 | \param status the wait(2) status code of the terminated client program. | 64 | \param status the wait(2) status code of the terminated client program. |
64 | */ | 65 | */ |
65 | void done(int status); | 66 | void done(int status); |
66 | 67 | ||
67 | /*! | 68 | /*! |
68 | emitted when a new block of data comes in. | 69 | emitted when a new block of data comes in. |
69 | \param s - the data | 70 | \param s - the data |
70 | \param len - the length of the block | 71 | \param len - the length of the block |
71 | */ | 72 | */ |
72 | void received(const QByteArray&); | 73 | void received(const QByteArray&); |
73 | 74 | ||
74 | public slots: | 75 | public slots: |
75 | 76 | ||
76 | void send(const QByteArray& ); | 77 | void send(const QByteArray& ); |
77 | 78 | ||
78 | private: | 79 | private: |
79 | const char* deviceName(); | 80 | const char* deviceName(); |
80 | 81 | ||
81 | protected slots: | 82 | protected slots: |
82 | void readPty(); | 83 | void readPty(); |
83 | void donePty(); | 84 | void donePty(); |
84 | 85 | ||
85 | private: | 86 | private: |
86 | int openPty(); | 87 | int openPty(); |
87 | 88 | ||
88 | private: | 89 | private: |
89 | 90 | ||
90 | char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" | 91 | char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" |
91 | char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." | 92 | char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." |
92 | int m_fd; | 93 | int m_fd; |
93 | int m_cpid; | 94 | int m_cpid; |
94 | QSocketNotifier* m_sn_e; | 95 | QSocketNotifier* m_sn_e; |
96 | QSocketNotifier* m_sn_r; | ||
95 | }; | 97 | }; |
96 | 98 | ||
97 | #endif | 99 | #endif |
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h index 5f2fa3c..4977e94 100644 --- a/noncore/apps/opie-console/io_layer.h +++ b/noncore/apps/opie-console/io_layer.h | |||
@@ -1,110 +1,124 @@ | |||
1 | #ifndef OPIE_IO_LAYER_H | 1 | #ifndef OPIE_IO_LAYER_H |
2 | #define OPIE_IO_LAYER_H | 2 | #define OPIE_IO_LAYER_H |
3 | 3 | ||
4 | #include <qbitarray.h> | ||
4 | #include <qobject.h> | 5 | #include <qobject.h> |
6 | |||
7 | |||
5 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
6 | 9 | ||
7 | #include "profile.h" | 10 | #include "profile.h" |
8 | 11 | ||
9 | /** | 12 | /** |
10 | * This is the base class for IO Layers | 13 | * This is the base class for IO Layers |
11 | * It will used to sent and recv data( QByteArray ) | 14 | * It will used to sent and recv data( QByteArray ) |
12 | * it | 15 | * it |
13 | */ | 16 | */ |
14 | class IOLayer : public QObject { | 17 | class IOLayer : public QObject { |
15 | Q_OBJECT | 18 | Q_OBJECT |
16 | public: | 19 | public: |
17 | enum Error { | 20 | enum Error { |
18 | NoError = -1, | 21 | NoError = -1, |
19 | Refuse = 0, | 22 | Refuse = 0, |
20 | CouldNotOpen =1, | 23 | CouldNotOpen =1, |
21 | ClosedUnexpected =2, | 24 | ClosedUnexpected =2, |
22 | ClosedError =3, | 25 | ClosedError =3, |
23 | Terminate = 4 | 26 | Terminate = 4 |
24 | /* add more errors here */ | 27 | /* add more errors here */ |
25 | }; | 28 | }; |
29 | enum Feature { | ||
30 | AutoConnect = 0, | ||
31 | TransferFile =1, | ||
32 | Close =2 | ||
33 | }; | ||
26 | /** | 34 | /** |
27 | * a small c'tor | 35 | * a small c'tor |
28 | */ | 36 | */ |
29 | IOLayer(); | 37 | IOLayer(); |
30 | 38 | ||
31 | /** | 39 | /** |
32 | * create an IOLayer instance from a config file | 40 | * create an IOLayer instance from a config file |
33 | * the currently set group stores the profile/session | 41 | * the currently set group stores the profile/session |
34 | * information | 42 | * information |
35 | */ | 43 | */ |
36 | IOLayer( const Profile& ); | 44 | IOLayer( const Profile& ); |
37 | 45 | ||
38 | /** | 46 | /** |
39 | * destructor | 47 | * destructor |
40 | */ | 48 | */ |
41 | virtual ~IOLayer(); | 49 | virtual ~IOLayer(); |
42 | 50 | ||
43 | /** | 51 | /** |
44 | * a small internal identifier | 52 | * a small internal identifier |
45 | */ | 53 | */ |
46 | virtual QString identifier() const = 0; | 54 | virtual QString identifier() const = 0; |
47 | 55 | ||
48 | /** | 56 | /** |
49 | * a short name | 57 | * a short name |
50 | */ | 58 | */ |
51 | virtual QString name() const = 0; | 59 | virtual QString name() const = 0; |
52 | 60 | ||
53 | /** | 61 | /** |
54 | * a file descriptor which opens | 62 | * a file descriptor which opens |
55 | * the device for io but does not | 63 | * the device for io but does not |
56 | * do any ioctling on it... | 64 | * do any ioctling on it... |
57 | * and it'll stop listening to the before opened | 65 | * and it'll stop listening to the before opened |
58 | * device | 66 | * device |
59 | */ | 67 | */ |
60 | virtual int rawIO()const; | 68 | virtual int rawIO()const; |
61 | 69 | ||
62 | /** | 70 | /** |
63 | * will close the rawIO stuff | 71 | * will close the rawIO stuff |
64 | * and will listen to it's data again... | 72 | * and will listen to it's data again... |
65 | */ | 73 | */ |
66 | virtual void closeRawIO(int); | 74 | virtual void closeRawIO(int); |
67 | 75 | ||
76 | /** | ||
77 | * What does the IOLayer support? | ||
78 | * Bits are related to features | ||
79 | */ | ||
80 | virtual QBitArray supports()const = 0; | ||
68 | 81 | ||
69 | signals: | 82 | signals: |
70 | /** | 83 | /** |
71 | * received input as QCString | 84 | * received input as QCString |
72 | */ | 85 | */ |
73 | virtual void received( const QByteArray& ); | 86 | virtual void received( const QByteArray& ); |
74 | 87 | ||
75 | /** | 88 | /** |
76 | * an error occured | 89 | * an error occured |
77 | * int for the error number | 90 | * int for the error number |
78 | * and QString for a text | 91 | * and QString for a text |
79 | */ | 92 | */ |
80 | virtual void error( int, const QString& ); | 93 | virtual void error( int, const QString& ); |
81 | 94 | ||
95 | virtual void closed(); | ||
82 | public slots: | 96 | public slots: |
83 | /** | 97 | /** |
84 | * send a QCString to the device | 98 | * send a QCString to the device |
85 | */ | 99 | */ |
86 | virtual void send( const QByteArray& ) = 0; | 100 | virtual void send( const QByteArray& ) = 0; |
87 | 101 | ||
88 | /** | 102 | /** |
89 | * bool open | 103 | * bool open |
90 | */ | 104 | */ |
91 | virtual bool open() = 0; | 105 | virtual bool open() = 0; |
92 | 106 | ||
93 | /** | 107 | /** |
94 | * close the io | 108 | * close the io |
95 | */ | 109 | */ |
96 | virtual void close() = 0; | 110 | virtual void close() = 0; |
97 | 111 | ||
98 | /** | 112 | /** |
99 | * closes and reloads the settings | 113 | * closes and reloads the settings |
100 | */ | 114 | */ |
101 | virtual void reload( const Profile& ) = 0; | 115 | virtual void reload( const Profile& ) = 0; |
102 | 116 | ||
103 | /** | 117 | /** |
104 | * set the size | 118 | * set the size |
105 | * needed for pty | 119 | * needed for pty |
106 | */ | 120 | */ |
107 | virtual void setSize(int rows, int cols ); | 121 | virtual void setSize(int rows, int cols ); |
108 | }; | 122 | }; |
109 | 123 | ||
110 | #endif | 124 | #endif |
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index a4a6f0b..c10d5a8 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -158,32 +158,39 @@ void IOSerial::dataArrived() { | |||
158 | close(); | 158 | close(); |
159 | if (len < 0) | 159 | if (len < 0) |
160 | return; | 160 | return; |
161 | array.resize( len ); | 161 | array.resize( len ); |
162 | emit received(array); | 162 | emit received(array); |
163 | } | 163 | } |
164 | 164 | ||
165 | QString IOSerial::identifier() const { | 165 | QString IOSerial::identifier() const { |
166 | return "serial"; | 166 | return "serial"; |
167 | } | 167 | } |
168 | 168 | ||
169 | QString IOSerial::name() const { | 169 | QString IOSerial::name() const { |
170 | return "RS232 Serial IO Layer"; | 170 | return "RS232 Serial IO Layer"; |
171 | } | 171 | } |
172 | int IOSerial::rawIO()const { | 172 | int IOSerial::rawIO()const { |
173 | if (m_read ) | 173 | if (m_read ) |
174 | disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | 174 | disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); |
175 | if (m_error ) | 175 | if (m_error ) |
176 | disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | 176 | disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); |
177 | 177 | ||
178 | int fd = ::open(m_device, O_RDWR ); | 178 | int fd = ::open(m_device, O_RDWR ); |
179 | 179 | ||
180 | return fd; | 180 | return fd; |
181 | }; | 181 | }; |
182 | void IOSerial::closeRawIO(int fd) { | 182 | void IOSerial::closeRawIO(int fd) { |
183 | if (m_read ) | 183 | if (m_read ) |
184 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | 184 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); |
185 | if (m_error ) | 185 | if (m_error ) |
186 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | 186 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); |
187 | 187 | ||
188 | ::close( fd ); | 188 | ::close( fd ); |
189 | } | 189 | } |
190 | QBitArray IOSerial::supports()const { | ||
191 | QBitArray ar(3); | ||
192 | ar[0] = ar[2] = 0; | ||
193 | ar[1] = 1; | ||
194 | |||
195 | return ar; | ||
196 | } | ||
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h index facbbc1..b1d1be1 100644 --- a/noncore/apps/opie-console/io_serial.h +++ b/noncore/apps/opie-console/io_serial.h | |||
@@ -8,58 +8,60 @@ | |||
8 | #define SERIAL_DEFAULT_DEVICE "/dev/ttyS0" | 8 | #define SERIAL_DEFAULT_DEVICE "/dev/ttyS0" |
9 | #define SERIAL_DEFAULT_BAUD 9600 | 9 | #define SERIAL_DEFAULT_BAUD 9600 |
10 | #define SERIAL_DEFAULT_PARITY 0 | 10 | #define SERIAL_DEFAULT_PARITY 0 |
11 | #define SERIAL_DEFAULT_DBITS 8 | 11 | #define SERIAL_DEFAULT_DBITS 8 |
12 | #define SERIAL_DEFAULT_SBITS 1 | 12 | #define SERIAL_DEFAULT_SBITS 1 |
13 | #define SERIAL_DEFAULT_FLOW 0 | 13 | #define SERIAL_DEFAULT_FLOW 0 |
14 | 14 | ||
15 | /* IOSerial implements a RS232 IO Layer */ | 15 | /* IOSerial implements a RS232 IO Layer */ |
16 | 16 | ||
17 | class IOSerial : public IOLayer { | 17 | class IOSerial : public IOLayer { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | enum Parity { | 20 | enum Parity { |
21 | ParityNone = 0, | 21 | ParityNone = 0, |
22 | ParityEven, | 22 | ParityEven, |
23 | ParityOdd, | 23 | ParityOdd, |
24 | ParitySpace, | 24 | ParitySpace, |
25 | ParityMark | 25 | ParityMark |
26 | }; | 26 | }; |
27 | 27 | ||
28 | enum Flow { | 28 | enum Flow { |
29 | FlowHW = 0x01, | 29 | FlowHW = 0x01, |
30 | FlowSW = 0x02 | 30 | FlowSW = 0x02 |
31 | }; | 31 | }; |
32 | 32 | ||
33 | IOSerial(const Profile &); | 33 | IOSerial(const Profile &); |
34 | ~IOSerial(); | 34 | ~IOSerial(); |
35 | 35 | ||
36 | QString identifier() const; | 36 | QString identifier() const; |
37 | QString name() const; | 37 | QString name() const; |
38 | int rawIO()const; | 38 | int rawIO()const; |
39 | void closeRawIO(int fd ); | 39 | void closeRawIO(int fd ); |
40 | signals: | 40 | QBitArray supports()const; |
41 | /*signals: | ||
41 | void received(const QByteArray &); | 42 | void received(const QByteArray &); |
42 | void error(int, const QString &); | 43 | void error(int, const QString &); |
44 | */ | ||
43 | public slots: | 45 | public slots: |
44 | void send(const QByteArray &); | 46 | void send(const QByteArray &); |
45 | bool open(); | 47 | bool open(); |
46 | void close(); | 48 | void close(); |
47 | void reload(const Profile &); | 49 | void reload(const Profile &); |
48 | protected: | 50 | protected: |
49 | int baud(int baud) const; | 51 | int baud(int baud) const; |
50 | protected slots: | 52 | protected slots: |
51 | void dataArrived(); | 53 | void dataArrived(); |
52 | void errorOccured(); | 54 | void errorOccured(); |
53 | protected: | 55 | protected: |
54 | QSocketNotifier *m_read; | 56 | QSocketNotifier *m_read; |
55 | QSocketNotifier *m_error; | 57 | QSocketNotifier *m_error; |
56 | QString m_device; | 58 | QString m_device; |
57 | int m_baud; | 59 | int m_baud; |
58 | int m_parity; | 60 | int m_parity; |
59 | int m_dbits; | 61 | int m_dbits; |
60 | int m_sbits; | 62 | int m_sbits; |
61 | int m_flow; | 63 | int m_flow; |
62 | int m_fd; | 64 | int m_fd; |
63 | }; | 65 | }; |
64 | 66 | ||
65 | #endif /* OPIE_IO_SERIAL */ | 67 | #endif /* OPIE_IO_SERIAL */ |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 94c99bc..29dbcf3 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -331,137 +331,139 @@ void MainWindow::slotDisconnect() { | |||
331 | 331 | ||
332 | void MainWindow::slotTerminate() { | 332 | void MainWindow::slotTerminate() { |
333 | if ( currentSession() ) | 333 | if ( currentSession() ) |
334 | currentSession()->layer()->close(); | 334 | currentSession()->layer()->close(); |
335 | 335 | ||
336 | slotClose(); | 336 | slotClose(); |
337 | /* FIXME move to the next session */ | 337 | /* FIXME move to the next session */ |
338 | } | 338 | } |
339 | 339 | ||
340 | void MainWindow::slotConfigure() { | 340 | void MainWindow::slotConfigure() { |
341 | ConfigDialog conf( manager()->all(), factory() ); | 341 | ConfigDialog conf( manager()->all(), factory() ); |
342 | conf.showMaximized(); | 342 | conf.showMaximized(); |
343 | 343 | ||
344 | int ret = conf.exec(); | 344 | int ret = conf.exec(); |
345 | 345 | ||
346 | if ( QDialog::Accepted == ret ) { | 346 | if ( QDialog::Accepted == ret ) { |
347 | manager()->setProfiles( conf.list() ); | 347 | manager()->setProfiles( conf.list() ); |
348 | manager()->save(); | 348 | manager()->save(); |
349 | populateProfiles(); | 349 | populateProfiles(); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | /* | 352 | /* |
353 | * we will remove | 353 | * we will remove |
354 | * this window from the tabwidget | 354 | * this window from the tabwidget |
355 | * remove it from the list | 355 | * remove it from the list |
356 | * delete it | 356 | * delete it |
357 | * and set the currentSession() | 357 | * and set the currentSession() |
358 | */ | 358 | */ |
359 | void MainWindow::slotClose() { | 359 | void MainWindow::slotClose() { |
360 | if (!currentSession() ) | 360 | if (!currentSession() ) |
361 | return; | 361 | return; |
362 | 362 | ||
363 | Session* ses = currentSession(); | ||
364 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | ||
363 | tabWidget()->remove( currentSession() ); | 365 | tabWidget()->remove( currentSession() ); |
364 | /*it's autodelete */ | 366 | /*it's autodelete */ |
365 | m_sessions.remove( m_curSession ); | 367 | m_sessions.remove( ses ); |
366 | m_curSession = m_sessions.first(); | 368 | qWarning("after remove!!"); |
367 | tabWidget()->setCurrent( m_curSession ); | ||
368 | 369 | ||
369 | if (!currentSession() ) { | 370 | if (!currentSession() ) { |
370 | m_connect->setEnabled( false ); | 371 | m_connect->setEnabled( false ); |
371 | m_disconnect->setEnabled( false ); | 372 | m_disconnect->setEnabled( false ); |
372 | m_terminate->setEnabled( false ); | 373 | m_terminate->setEnabled( false ); |
373 | m_transfer->setEnabled( false ); | 374 | m_transfer->setEnabled( false ); |
374 | m_recordScript->setEnabled( false ); | 375 | m_recordScript->setEnabled( false ); |
375 | m_saveScript->setEnabled( false ); | 376 | m_saveScript->setEnabled( false ); |
376 | m_runScript->setEnabled( false ); | 377 | m_runScript->setEnabled( false ); |
377 | m_fullscreen->setEnabled( false ); | 378 | m_fullscreen->setEnabled( false ); |
378 | m_closewindow->setEnabled( false ); | 379 | m_closewindow->setEnabled( false ); |
379 | } | 380 | } |
380 | } | 381 | } |
381 | 382 | ||
382 | /* | 383 | /* |
383 | * We will get the name | 384 | * We will get the name |
384 | * Then the profile | 385 | * Then the profile |
385 | * and then we will make a profile | 386 | * and then we will make a profile |
386 | */ | 387 | */ |
387 | void MainWindow::slotProfile( int id) { | 388 | void MainWindow::slotProfile( int id) { |
388 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 389 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
389 | create( prof ); | 390 | create( prof ); |
390 | } | 391 | } |
391 | void MainWindow::create( const Profile& prof ) { | 392 | void MainWindow::create( const Profile& prof ) { |
392 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 393 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
393 | 394 | ||
394 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 395 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
395 | { | 396 | { |
396 | QMessageBox::warning(this, | 397 | QMessageBox::warning(this, |
397 | QObject::tr("Session failed"), | 398 | QObject::tr("Session failed"), |
398 | QObject::tr("Cannot open session: Not all components were found.")); | 399 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
399 | //if(ses) delete ses; | 400 | //if(ses) delete ses; |
400 | return; | 401 | return; |
401 | } | 402 | } |
402 | 403 | ||
403 | m_sessions.append( ses ); | 404 | m_sessions.append( ses ); |
404 | tabWidget()->add( ses ); | 405 | tabWidget()->add( ses ); |
405 | m_curSession = ses; | 406 | m_curSession = ses; |
406 | 407 | ||
407 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 408 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
408 | m_connect->setEnabled( true ); | 409 | m_connect->setEnabled( true ); |
409 | m_disconnect->setEnabled( false ); | 410 | m_disconnect->setEnabled( false ); |
410 | m_terminate->setEnabled( true ); | 411 | m_terminate->setEnabled( true ); |
411 | m_transfer->setEnabled( true ); | 412 | m_transfer->setEnabled( true ); |
412 | m_recordScript->setEnabled( true ); | 413 | m_recordScript->setEnabled( true ); |
413 | m_saveScript->setEnabled( true ); | 414 | m_saveScript->setEnabled( true ); |
414 | m_runScript->setEnabled( true ); | 415 | m_runScript->setEnabled( true ); |
415 | m_fullscreen->setEnabled( true ); | 416 | m_fullscreen->setEnabled( true ); |
416 | m_closewindow->setEnabled( true ); | 417 | m_closewindow->setEnabled( true ); |
417 | } | 418 | } |
418 | 419 | ||
419 | void MainWindow::slotTransfer() | 420 | void MainWindow::slotTransfer() |
420 | { | 421 | { |
421 | if ( currentSession() ) { | 422 | if ( currentSession() ) { |
422 | TransferDialog dlg(this); | 423 | TransferDialog dlg(this); |
423 | dlg.showMaximized(); | 424 | dlg.showMaximized(); |
424 | dlg.exec(); | 425 | dlg.exec(); |
425 | } | 426 | } |
426 | } | 427 | } |
427 | 428 | ||
428 | 429 | ||
429 | void MainWindow::slotOpenKeb(bool state) { | 430 | void MainWindow::slotOpenKeb(bool state) { |
430 | 431 | ||
431 | if (state) m_keyBar->show(); | 432 | if (state) m_keyBar->show(); |
432 | else m_keyBar->hide(); | 433 | else m_keyBar->hide(); |
433 | 434 | ||
434 | } | 435 | } |
435 | void MainWindow::slotSessionChanged( Session* ses ) { | 436 | void MainWindow::slotSessionChanged( Session* ses ) { |
437 | qWarning("changed!"); | ||
436 | if ( ses ) { | 438 | if ( ses ) { |
437 | m_curSession = ses; | 439 | m_curSession = ses; |
438 | 440 | ||
439 | if ( m_curSession->isConnected() ) { | 441 | if ( m_curSession->isConnected() ) { |
440 | m_connect->setEnabled( false ); | 442 | m_connect->setEnabled( false ); |
441 | m_disconnect->setEnabled( true ); | 443 | m_disconnect->setEnabled( true ); |
442 | } else { | 444 | } else { |
443 | m_connect->setEnabled( true ); | 445 | m_connect->setEnabled( true ); |
444 | m_disconnect->setEnabled( false ); | 446 | m_disconnect->setEnabled( false ); |
445 | } | 447 | } |
446 | } | 448 | } |
447 | } | 449 | } |
448 | 450 | ||
449 | void MainWindow::slotFullscreen() { | 451 | void MainWindow::slotFullscreen() { |
450 | 452 | ||
451 | if ( m_isFullscreen ) { | 453 | if ( m_isFullscreen ) { |
452 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); | 454 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); |
453 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 455 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
454 | setCentralWidget( m_consoleWindow ); | 456 | setCentralWidget( m_consoleWindow ); |
455 | ( m_curSession->widgetStack() )->show(); | 457 | ( m_curSession->widgetStack() )->show(); |
456 | m_fullscreen->setText( tr("Full screen") ); | 458 | m_fullscreen->setText( tr("Full screen") ); |
457 | 459 | ||
458 | } else { | 460 | } else { |
459 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 461 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
460 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, | 462 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, |
461 | QPoint(0,0), false); | 463 | QPoint(0,0), false); |
462 | ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 464 | ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
463 | ( m_curSession->widgetStack() )->setFocus(); | 465 | ( m_curSession->widgetStack() )->setFocus(); |
464 | ( m_curSession->widgetStack() )->show(); | 466 | ( m_curSession->widgetStack() )->show(); |
465 | 467 | ||
466 | //QPushButton *cornerButton = new QPushButton( ); | 468 | //QPushButton *cornerButton = new QPushButton( ); |
467 | //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); | 469 | //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); |
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index e5aedb6..7c15560 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp | |||
@@ -1,36 +1,37 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qhbox.h> | ||
5 | #include <qlayout.h> | 6 | #include <qlayout.h> |
6 | #include <qwidgetstack.h> | 7 | #include <qwidgetstack.h> |
7 | 8 | ||
8 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
9 | 10 | ||
10 | #include "emulation_handler.h" | 11 | #include "emulation_handler.h" |
11 | #include "widget_layer.h" | 12 | #include "widget_layer.h" |
12 | #include "emulation_widget.h" | 13 | #include "emulation_widget.h" |
13 | #include "metafactory.h" | 14 | #include "metafactory.h" |
14 | #include "profileconfig.h" | 15 | #include "profileconfig.h" |
15 | #include "profilemanager.h" | 16 | #include "profilemanager.h" |
16 | 17 | ||
17 | ProfileManager::ProfileManager( MetaFactory* fact ) | 18 | ProfileManager::ProfileManager( MetaFactory* fact ) |
18 | : m_fact( fact ) | 19 | : m_fact( fact ) |
19 | { | 20 | { |
20 | 21 | ||
21 | } | 22 | } |
22 | ProfileManager::~ProfileManager() { | 23 | ProfileManager::~ProfileManager() { |
23 | 24 | ||
24 | } | 25 | } |
25 | void ProfileManager::load() { | 26 | void ProfileManager::load() { |
26 | m_list.clear(); | 27 | m_list.clear(); |
27 | ProfileConfig conf("opie-console-profiles"); | 28 | ProfileConfig conf("opie-console-profiles"); |
28 | QStringList groups = conf.groups(); | 29 | QStringList groups = conf.groups(); |
29 | QStringList::Iterator it; | 30 | QStringList::Iterator it; |
30 | 31 | ||
31 | /* | 32 | /* |
32 | * for each profile | 33 | * for each profile |
33 | */ | 34 | */ |
34 | for ( it = groups.begin(); it != groups.end(); ++it ) { | 35 | for ( it = groups.begin(); it != groups.end(); ++it ) { |
35 | conf.setGroup( (*it) ); | 36 | conf.setGroup( (*it) ); |
36 | Profile prof; | 37 | Profile prof; |
@@ -56,77 +57,69 @@ Profile::ValueList ProfileManager::all()const { | |||
56 | return m_list; | 57 | return m_list; |
57 | } | 58 | } |
58 | /* | 59 | /* |
59 | * Our goal is to create a Session | 60 | * Our goal is to create a Session |
60 | * We will load the the IOLayer and EmulationLayer | 61 | * We will load the the IOLayer and EmulationLayer |
61 | * from the factory | 62 | * from the factory |
62 | * we will generate a QWidgetStack | 63 | * we will generate a QWidgetStack |
63 | * add a dummy widget with layout | 64 | * add a dummy widget with layout |
64 | * add "Widget" to the layout | 65 | * add "Widget" to the layout |
65 | * add the dummy to the stack | 66 | * add the dummy to the stack |
66 | * raise the dummy | 67 | * raise the dummy |
67 | * call session->connect(= | 68 | * call session->connect(= |
68 | * this way we only need to reparent | 69 | * this way we only need to reparent |
69 | * in TabWidget | 70 | * in TabWidget |
70 | */ | 71 | */ |
71 | Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { | 72 | Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { |
72 | /* TEST PROFILE!!! | 73 | /* TEST PROFILE!!! |
73 | Profile prof; | 74 | Profile prof; |
74 | QString str = "/dev/ttyS0"; | 75 | QString str = "/dev/ttyS0"; |
75 | prof.writeEntry("Device",str ); | 76 | prof.writeEntry("Device",str ); |
76 | prof.writeEntry("Baud", 115200 ); | 77 | prof.writeEntry("Baud", 115200 ); |
77 | prof.setIOLayer("serial"); | 78 | prof.setIOLayer("serial"); |
78 | prof.setName( "test"); | 79 | prof.setName( "test"); |
79 | */ | 80 | */ |
80 | Session* session = new Session(); | 81 | Session* session = new Session(); |
81 | session->setName( prof.name() ); | 82 | session->setName( prof.name() ); |
82 | /* translate the internal name to the external */ | 83 | /* translate the internal name to the external */ |
83 | session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , | 84 | session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , |
84 | prof) ); | 85 | prof) ); |
85 | 86 | ||
86 | QWidgetStack *stack = new QWidgetStack( parent ); | 87 | QWidgetStack *stack = new QWidgetStack( parent ); |
87 | session->setWidgetStack( stack ); | 88 | session->setWidgetStack( stack ); |
88 | QWidget* dummy = new QWidget( stack ); | 89 | QWidget* dummy = new QHBox( stack ); |
89 | QHBoxLayout* lay = new QHBoxLayout( dummy ); | 90 | stack->raiseWidget( dummy ); |
90 | stack->addWidget( dummy, 0 ); | 91 | |
91 | stack->raiseWidget( 0 ); | ||
92 | EmulationHandler* handler = new EmulationHandler(prof,dummy ); | 92 | EmulationHandler* handler = new EmulationHandler(prof,dummy ); |
93 | session->setEmulationHandler( handler ); | 93 | session->setEmulationHandler( handler ); |
94 | lay->addWidget( handler->widget() ); | ||
95 | // WidgetLayer* wid = new EmulationWidget( prof, dummy ); | ||
96 | // lay->addWidget( wid ); | ||
97 | |||
98 | // session->setEmulationWidget( wid ); | ||
99 | // session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ), | ||
100 | // wid ) ); | ||
101 | session->connect(); | 94 | session->connect(); |
102 | 95 | ||
103 | return session; | 96 | return session; |
104 | } | 97 | } |
105 | void ProfileManager::save( ) { | 98 | void ProfileManager::save( ) { |
106 | QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); | 99 | QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); |
107 | ProfileConfig conf("opie-console-profiles"); | 100 | ProfileConfig conf("opie-console-profiles"); |
108 | Profile::ValueList::Iterator it2; | 101 | Profile::ValueList::Iterator it2; |
109 | for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { | 102 | for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { |
110 | conf.setGroup( (*it2).name() ); | 103 | conf.setGroup( (*it2).name() ); |
111 | 104 | ||
112 | /* now the config stuff */ | 105 | /* now the config stuff */ |
113 | QMap<QString, QString> map = (*it2).conf(); | 106 | QMap<QString, QString> map = (*it2).conf(); |
114 | QMap<QString, QString>::Iterator confIt; | 107 | QMap<QString, QString>::Iterator confIt; |
115 | for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { | 108 | for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { |
116 | conf.writeEntry( confIt.key(), confIt.data() ); | 109 | conf.writeEntry( confIt.key(), confIt.data() ); |
117 | } | 110 | } |
118 | 111 | ||
119 | conf.writeEntry( "name", (*it2).name() ); | 112 | conf.writeEntry( "name", (*it2).name() ); |
120 | QString str = QString::fromUtf8( (*it2).ioLayerName() ); | 113 | QString str = QString::fromUtf8( (*it2).ioLayerName() ); |
121 | 114 | ||
122 | conf.writeEntry( "iolayer", str ); | 115 | conf.writeEntry( "iolayer", str ); |
123 | conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) ); | 116 | conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) ); |
124 | conf.writeEntry( "back", (*it2).background() ); | 117 | conf.writeEntry( "back", (*it2).background() ); |
125 | conf.writeEntry( "fore", (*it2).foreground() ); | 118 | conf.writeEntry( "fore", (*it2).foreground() ); |
126 | conf.writeEntry( "terminal", (*it2).terminal() ); | 119 | conf.writeEntry( "terminal", (*it2).terminal() ); |
127 | } | 120 | } |
128 | } | 121 | } |
129 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { | 122 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { |
130 | m_list = list; | 123 | m_list = list; |
131 | }; | 124 | }; |
132 | Profile ProfileManager::profile( const QString& name )const { | 125 | Profile ProfileManager::profile( const QString& name )const { |
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index e53dbc4..aad100d 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp | |||
@@ -7,64 +7,70 @@ | |||
7 | 7 | ||
8 | 8 | ||
9 | Session::Session() { | 9 | Session::Session() { |
10 | m_widget = 0l; | 10 | m_widget = 0l; |
11 | m_layer = 0l; | 11 | m_layer = 0l; |
12 | m_emu = 0l; | 12 | m_emu = 0l; |
13 | } | 13 | } |
14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) | 14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) |
15 | : m_name( na ), m_widget( widget ), m_layer( lay ) | 15 | : m_name( na ), m_widget( widget ), m_layer( lay ) |
16 | { | 16 | { |
17 | // m_widLay = 0l; | 17 | // m_widLay = 0l; |
18 | // m_emLay = 0l; | 18 | // m_emLay = 0l; |
19 | m_emu = 0l; | 19 | m_emu = 0l; |
20 | } | 20 | } |
21 | Session::~Session() { | 21 | Session::~Session() { |
22 | delete m_layer; | 22 | delete m_layer; |
23 | delete m_emu; | 23 | delete m_emu; |
24 | delete m_widget; | 24 | delete m_widget; |
25 | /* the widget layer should be deleted by the m_widget */ | 25 | /* the widget layer should be deleted by the m_widget */ |
26 | } | 26 | } |
27 | QString Session::name()const { | 27 | QString Session::name()const { |
28 | return m_name; | 28 | return m_name; |
29 | } | 29 | } |
30 | QWidgetStack* Session::widgetStack() { | 30 | QWidgetStack* Session::widgetStack() { |
31 | return m_widget; | 31 | return m_widget; |
32 | } | 32 | } |
33 | IOLayer* Session::layer() { | 33 | IOLayer* Session::layer() { |
34 | return m_layer; | 34 | return m_layer; |
35 | } | 35 | } |
36 | EmulationHandler* Session::emulationHandler() { | 36 | EmulationHandler* Session::emulationHandler() { |
37 | return m_emu; | 37 | return m_emu; |
38 | } | 38 | } |
39 | QWidget* Session::widget() { | ||
40 | if (!m_emu ) | ||
41 | return 0l; | ||
42 | |||
43 | return m_emu->widget(); | ||
44 | } | ||
39 | /* | 45 | /* |
40 | WidgetLayer* Session::emulationWidget() { | 46 | WidgetLayer* Session::emulationWidget() { |
41 | return m_widLay; | 47 | return m_widLay; |
42 | } | 48 | } |
43 | */ | 49 | */ |
44 | void Session::connect() { | 50 | void Session::connect() { |
45 | if ( !m_layer || !m_emu ) | 51 | if ( !m_layer || !m_emu ) |
46 | return; | 52 | return; |
47 | 53 | ||
48 | m_connected = true; | 54 | m_connected = true; |
49 | 55 | ||
50 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), | 56 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), |
51 | m_emu, SLOT(recv(const QByteArray&) ) ); | 57 | m_emu, SLOT(recv(const QByteArray&) ) ); |
52 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), | 58 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), |
53 | m_layer, SLOT(send(const QByteArray&) ) ); | 59 | m_layer, SLOT(send(const QByteArray&) ) ); |
54 | } | 60 | } |
55 | 61 | ||
56 | void Session::disconnect() { | 62 | void Session::disconnect() { |
57 | 63 | ||
58 | if ( !m_layer || !m_emu ) | 64 | if ( !m_layer || !m_emu ) |
59 | return; | 65 | return; |
60 | 66 | ||
61 | m_connected = false; | 67 | m_connected = false; |
62 | 68 | ||
63 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), | 69 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), |
64 | m_emu, SLOT(recv(const QByteArray&) ) ); | 70 | m_emu, SLOT(recv(const QByteArray&) ) ); |
65 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), | 71 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), |
66 | m_layer, SLOT(send(const QByteArray&) ) ); | 72 | m_layer, SLOT(send(const QByteArray&) ) ); |
67 | } | 73 | } |
68 | 74 | ||
69 | void Session::setName( const QString& na){ | 75 | void Session::setName( const QString& na){ |
70 | m_name = na; | 76 | m_name = na; |
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index a1121d3..ff92df3 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h | |||
@@ -5,64 +5,65 @@ | |||
5 | 5 | ||
6 | class IOLayer; | 6 | class IOLayer; |
7 | class EmulationHandler; | 7 | class EmulationHandler; |
8 | /** | 8 | /** |
9 | * This is a Session. A session contains | 9 | * This is a Session. A session contains |
10 | * a QWidget pointer and a IOLayer | 10 | * a QWidget pointer and a IOLayer |
11 | * Imagine a session like a collection of what | 11 | * Imagine a session like a collection of what |
12 | * is needed to show your widget in a tab ;) | 12 | * is needed to show your widget in a tab ;) |
13 | */ | 13 | */ |
14 | class Session { | 14 | class Session { |
15 | public: | 15 | public: |
16 | /** | 16 | /** |
17 | * c'tor with widget and layer | 17 | * c'tor with widget and layer |
18 | * ownership get's transfered | 18 | * ownership get's transfered |
19 | */ | 19 | */ |
20 | Session(); | 20 | Session(); |
21 | Session( const QString&, QWidgetStack* widget, IOLayer* ); | 21 | Session( const QString&, QWidgetStack* widget, IOLayer* ); |
22 | ~Session(); | 22 | ~Session(); |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * return the name of the session | 25 | * return the name of the session |
26 | */ | 26 | */ |
27 | QString name()const; | 27 | QString name()const; |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * return the widgetstack | 30 | * return the widgetstack |
31 | * this is used to be semi modal | 31 | * this is used to be semi modal |
32 | * for FileTransfer | 32 | * for FileTransfer |
33 | * | 33 | * |
34 | * semi modal == SessionModal | 34 | * semi modal == SessionModal |
35 | */ | 35 | */ |
36 | QWidgetStack* widgetStack(); | 36 | QWidgetStack* widgetStack(); |
37 | QWidget* widget(); | ||
37 | 38 | ||
38 | /** | 39 | /** |
39 | * return the layer | 40 | * return the layer |
40 | */ | 41 | */ |
41 | IOLayer* layer(); | 42 | IOLayer* layer(); |
42 | 43 | ||
43 | EmulationHandler* emulationHandler(); | 44 | EmulationHandler* emulationHandler(); |
44 | 45 | ||
45 | /* | 46 | /* |
46 | * connects the data flow from | 47 | * connects the data flow from |
47 | * the IOLayer to the EmulationLayer | 48 | * the IOLayer to the EmulationLayer |
48 | */ | 49 | */ |
49 | void connect(); | 50 | void connect(); |
50 | 51 | ||
51 | /* | 52 | /* |
52 | * disconnect the dataflow | 53 | * disconnect the dataflow |
53 | * this will be done for ft | 54 | * this will be done for ft |
54 | */ | 55 | */ |
55 | void disconnect(); | 56 | void disconnect(); |
56 | 57 | ||
57 | void setWidgetStack( QWidgetStack* widget ); | 58 | void setWidgetStack( QWidgetStack* widget ); |
58 | void setEmulationHandler( EmulationHandler* lay ); | 59 | void setEmulationHandler( EmulationHandler* lay ); |
59 | void setIOLayer( IOLayer* ); | 60 | void setIOLayer( IOLayer* ); |
60 | void setName( const QString& ); | 61 | void setName( const QString& ); |
61 | 62 | ||
62 | bool isConnected(); | 63 | bool isConnected(); |
63 | 64 | ||
64 | private: | 65 | private: |
65 | QString m_name; | 66 | QString m_name; |
66 | QWidgetStack* m_widget; | 67 | QWidgetStack* m_widget; |
67 | IOLayer* m_layer; | 68 | IOLayer* m_layer; |
68 | EmulationHandler* m_emu; | 69 | EmulationHandler* m_emu; |
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp index 8a691f9..419f8ac 100644 --- a/noncore/apps/opie-console/tabwidget.cpp +++ b/noncore/apps/opie-console/tabwidget.cpp | |||
@@ -1,43 +1,44 @@ | |||
1 | 1 | ||
2 | #include "tabwidget.h" | 2 | #include "tabwidget.h" |
3 | 3 | ||
4 | TabWidget::TabWidget( QWidget* parent, const char* name ) | 4 | TabWidget::TabWidget( QWidget* parent, const char* name ) |
5 | : OTabWidget( parent, name ) { | 5 | : OTabWidget( parent, name ) { |
6 | connect(this, SIGNAL( currentChanged(QWidget*) ), | 6 | connect(this, SIGNAL( currentChanged(QWidget*) ), |
7 | this, SLOT( slotCurChanged(QWidget*) ) ); | 7 | this, SLOT( slotCurChanged(QWidget*) ) ); |
8 | } | 8 | } |
9 | 9 | ||
10 | TabWidget::~TabWidget() { | 10 | TabWidget::~TabWidget() { |
11 | } | 11 | } |
12 | 12 | ||
13 | void TabWidget::add( Session* ses ) { | 13 | void TabWidget::add( Session* ses ) { |
14 | qWarning("session ses " + ses->name() ); | ||
14 | if ( !ses->widgetStack() ) return; | 15 | if ( !ses->widgetStack() ) return; |
15 | //reparent( ses->widgetStack(), QPoint() ); | 16 | //reparent( ses->widgetStack(), QPoint() ); |
16 | addTab( ses->widgetStack(), "console/konsole", ses->name() ); | 17 | addTab( ses->widgetStack(), "console/konsole", ses->name() ); |
17 | //addTab( ses->widgetStack(), ses->name() ); | 18 | //addTab( ses->widgetStack(), ses->name() ); |
18 | m_map.insert( ses->widgetStack(), ses ); | 19 | m_map.insert( ses->widgetStack(), ses ); |
19 | } | 20 | } |
20 | 21 | ||
21 | void TabWidget::remove( Session* ses ) { | 22 | void TabWidget::remove( Session* ses ) { |
22 | m_map.remove( ses->widgetStack() ); | 23 | m_map.remove( ses->widgetStack() ); |
23 | removePage( ses->widgetStack() ); | 24 | removePage( ses->widgetStack() ); |
24 | } | 25 | } |
25 | 26 | ||
26 | void TabWidget::slotCurChanged( QWidget* wid ) { | 27 | void TabWidget::slotCurChanged( QWidget* wid ) { |
27 | QMap<QWidget*, Session*>::Iterator it; | 28 | QMap<QWidget*, Session*>::Iterator it; |
28 | it = m_map.find( wid ); | 29 | it = m_map.find( wid ); |
29 | if ( it == m_map.end() ) { | 30 | if ( it == m_map.end() ) { |
30 | return; | 31 | return; |
31 | } | 32 | } |
32 | 33 | ||
33 | emit activated( it.data() ); | 34 | emit activated( it.data() ); |
34 | } | 35 | } |
35 | void TabWidget::setCurrent( Session* ses ) { | 36 | void TabWidget::setCurrent( Session* ses ) { |
36 | if (!ses ) | 37 | if (!ses ) |
37 | return; | 38 | return; |
38 | 39 | ||
39 | //showPage( ses->widgetStack() ); | 40 | //showPage( ses->widgetStack() ); |
40 | setCurrentTab( ses->widgetStack() ); | 41 | setCurrentTab( ses->widgetStack() ); |
41 | } | 42 | } |
42 | 43 | ||
43 | 44 | ||