summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-01-21 00:37:32 (UTC)
committer mickeyl <mickeyl>2003-01-21 00:37:32 (UTC)
commit2f708339e301f28aadc622f4d58a2d22e0b598fb (patch) (unidiff)
tree58cc0564a3e888acdcf5868ca48d21ef8f82ccec
parentc5c75d4622f9c7d6aa1a8fd2ce3aed415032d932 (diff)
downloadopie-2f708339e301f28aadc622f4d58a2d22e0b598fb.zip
opie-2f708339e301f28aadc622f4d58a2d22e0b598fb.tar.gz
opie-2f708339e301f28aadc622f4d58a2d22e0b598fb.tar.bz2
fixed a lot of errors and sloppyness to make it compile again...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp4
-rw-r--r--noncore/apps/opie-console/io_bt.cpp12
-rw-r--r--noncore/apps/opie-console/io_bt.h13
-rw-r--r--noncore/apps/opie-console/io_irda.cpp12
-rw-r--r--noncore/apps/opie-console/io_irda.h13
-rw-r--r--noncore/apps/opie-console/io_layer.cpp1
-rw-r--r--noncore/apps/opie-console/io_layer.h4
-rw-r--r--noncore/apps/opie-console/io_modem.cpp11
-rw-r--r--noncore/apps/opie-console/io_modem.h13
-rw-r--r--noncore/apps/opie-console/io_serial.h21
-rw-r--r--noncore/apps/opie-console/opie-console.pro12
11 files changed, 81 insertions, 35 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index 23d4966..b2f6a74 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -1,368 +1,368 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [MyPty.C] Pseudo Terminal Device */ 3/* [MyPty.C] Pseudo Terminal Device */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* -------------------------------------------------------------------------- */ 10/* -------------------------------------------------------------------------- */
11 /* */ 11 /* */
12/* Ported Konsole to Qt/Embedded */ 12/* Ported Konsole to Qt/Embedded */
13 /* */ 13 /* */
14/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 14/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
15 /* */ 15 /* */
16/* -------------------------------------------------------------------------- */ 16/* -------------------------------------------------------------------------- */
17 17
18/* If you're compiling konsole on non-Linux platforms and find 18/* If you're compiling konsole on non-Linux platforms and find
19 problems that you can track down to this file, please have 19 problems that you can track down to this file, please have
20 a look into ../README.ports, too. 20 a look into ../README.ports, too.
21*/ 21*/
22 22
23/*! \file 23/*! \file
24*/ 24*/
25 25
26/*! \class TEPty 26/*! \class TEPty
27 27
28 \brief Ptys provide a pseudo terminal connection to a program. 28 \brief Ptys provide a pseudo terminal connection to a program.
29 29
30 Although closely related to pipes, these pseudo terminal connections have 30 Although closely related to pipes, these pseudo terminal connections have
31 some ability, that makes it nessesary to uses them. Most importent, they 31 some ability, that makes it nessesary to uses them. Most importent, they
32 know about changing screen sizes and UNIX job control. 32 know about changing screen sizes and UNIX job control.
33 33
34 Within the terminal emulation framework, this class represents the 34 Within the terminal emulation framework, this class represents the
35 host side of the terminal together with the connecting serial line. 35 host side of the terminal together with the connecting serial line.
36 36
37 One can create many instances of this class within a program. 37 One can create many instances of this class within a program.
38 As a side effect of using this class, a signal(2) handler is 38 As a side effect of using this class, a signal(2) handler is
39 installed on SIGCHLD. 39 installed on SIGCHLD.
40 40
41 \par FIXME 41 \par FIXME
42 42
43 [NOTE: much of the technical stuff below will be replaced by forkpty.] 43 [NOTE: much of the technical stuff below will be replaced by forkpty.]
44 44
45 publish the SIGCHLD signal if not related to an instance. 45 publish the SIGCHLD signal if not related to an instance.
46 46
47 clearify TEPty::done vs. TEPty::~TEPty semantics. 47 clearify TEPty::done vs. TEPty::~TEPty semantics.
48 check if pty is restartable via run after done. 48 check if pty is restartable via run after done.
49 49
50 \par Pseudo terminals 50 \par Pseudo terminals
51 51
52 Pseudo terminals are a unique feature of UNIX, and always come in form of 52 Pseudo terminals are a unique feature of UNIX, and always come in form of
53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each 53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
54 other by the operating system. One may think of them as two serial devices 54 other by the operating system. One may think of them as two serial devices
55 linked by a null-modem cable. Being based on devices the number of 55 linked by a null-modem cable. Being based on devices the number of
56 simultanous instances of this class is (globally) limited by the number of 56 simultanous instances of this class is (globally) limited by the number of
57 those device pairs, which is 256. 57 those device pairs, which is 256.
58 58
59 Another technic are UNIX 98 PTY's. These are supported also, and prefered 59 Another technic are UNIX 98 PTY's. These are supported also, and prefered
60 over the (obsolete) predecessor. 60 over the (obsolete) predecessor.
61 61
62 There's a sinister ioctl(2), signal(2) and job control stuff 62 There's a sinister ioctl(2), signal(2) and job control stuff
63 nessesary to make everything work as it should. 63 nessesary to make everything work as it should.
64*/ 64*/
65 65
66 66
67#include <qapplication.h> 67#include <qapplication.h>
68#include <qsocketnotifier.h> 68#include <qsocketnotifier.h>
69#include <qstring.h> 69#include <qstring.h>
70#include <qfile.h> 70#include <qfile.h>
71 71
72#include <stdlib.h> 72#include <stdlib.h>
73#include <stdio.h> 73#include <stdio.h>
74#include <signal.h> 74#include <signal.h>
75#include <fcntl.h> 75#include <fcntl.h>
76#include <unistd.h> 76#include <unistd.h>
77#include <termios.h> 77#include <termios.h>
78#include <sys/types.h> 78#include <sys/types.h>
79#include <sys/ioctl.h> 79#include <sys/ioctl.h>
80#include <sys/wait.h> 80#include <sys/wait.h>
81 81
82#ifdef HAVE_OPENPTY 82#ifdef HAVE_OPENPTY
83#include <pty.h> 83#include <pty.h>
84#endif 84#endif
85 85
86#include "procctl.h" 86#include "procctl.h"
87#include "MyPty.h" 87#include "MyPty.h"
88 88
89 89
90#undef VERBOSE_DEBUG 90#undef VERBOSE_DEBUG
91 91
92 92
93/* -------------------------------------------------------------------------- */ 93/* -------------------------------------------------------------------------- */
94 94
95/*! 95/*!
96 Informs the client program about the 96 Informs the client program about the
97 actual size of the window. 97 actual size of the window.
98*/ 98*/
99 99
100void MyPty::setSize(int lines, int columns) 100void MyPty::setSize(int lines, int columns)
101{ 101{
102 qWarning("setting size"); 102 qWarning("setting size");
103 struct winsize wsize; 103 struct winsize wsize;
104 wsize.ws_row = (unsigned short)lines; 104 wsize.ws_row = (unsigned short)lines;
105 wsize.ws_col = (unsigned short)columns; 105 wsize.ws_col = (unsigned short)columns;
106 if(m_fd < 0) return; 106 if(m_fd < 0) return;
107 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); 107 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
108} 108}
109 109
110 110
111void MyPty::donePty() 111void MyPty::donePty()
112{ 112{
113 // This is code from the Qt DumbTerminal example 113 // This is code from the Qt DumbTerminal example
114 114
115 ::close(m_fd); 115 ::close(m_fd);
116 116
117 if (m_cpid) { 117 if (m_cpid) {
118 kill(m_cpid, SIGHUP); 118 kill(m_cpid, SIGHUP);
119 //waitpid(m_cpid, &status, 0); 119 //waitpid(m_cpid, &status, 0);
120 delete m_sn_e; 120 delete m_sn_e;
121 delete m_sn_r; 121 delete m_sn_r;
122 m_sn_e = 0l; 122 m_sn_e = 0l;
123 m_sn_r = 0l; 123 m_sn_r = 0l;
124 } 124 }
125 125
126 m_cpid = 0; 126 m_cpid = 0;
127 m_fd = -1; 127 m_fd = -1;
128// emit done(status); 128// emit done(status);
129} 129}
130 130
131 131
132const char* MyPty::deviceName() 132const char* MyPty::deviceName()
133{ 133{
134 return m_ttynam; 134 return m_ttynam;
135} 135}
136 136
137 137
138void MyPty::error() 138void MyPty::error()
139{ 139{
140 // This is code from the Qt DumbTerminal example 140 // This is code from the Qt DumbTerminal example
141 donePty(); 141 donePty();
142} 142}
143 143
144void MyPty::start() { 144void MyPty::start() {
145 QStrList lis; 145 QStrList lis;
146 int r =run(m_cmd.latin1(), lis, 0, 0); 146 int r =run(m_cmd.latin1(), lis, 0, 0);
147 r = r; 147 r = r;
148} 148}
149/*! 149/*!
150 start the client program. 150 start the client program.
151*/ 151*/
152int MyPty::run(const char* cmd, QStrList &, const char*, int) 152int MyPty::run(const char* cmd, QStrList &, const char*, int)
153{ 153{
154 // This is code from the Qt DumbTerminal example 154 // This is code from the Qt DumbTerminal example
155 m_cpid = fork(); 155 m_cpid = fork();
156 156
157 if ( !m_cpid ) { 157 if ( !m_cpid ) {
158 // child - exec shell on tty 158 // child - exec shell on tty
159 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); 159 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
160 int ttyfd = ::open(m_ttynam, O_RDWR); 160 int ttyfd = ::open(m_ttynam, O_RDWR);
161 dup2(ttyfd, STDIN_FILENO); 161 dup2(ttyfd, STDIN_FILENO);
162 dup2(ttyfd, STDOUT_FILENO); 162 dup2(ttyfd, STDOUT_FILENO);
163 dup2(ttyfd, STDERR_FILENO); 163 dup2(ttyfd, STDERR_FILENO);
164 // should be done with tty, so close it 164 // should be done with tty, so close it
165 ::close(ttyfd); 165 ::close(ttyfd);
166 static struct termios ttmode; 166 static struct termios ttmode;
167 if ( setsid() < 0 ) 167 if ( setsid() < 0 )
168 perror( "failed to set process group" ); 168 perror( "failed to set process group" );
169#if defined (TIOCSCTTY) 169#if defined (TIOCSCTTY)
170 // grabbed from APUE by Stevens 170 // grabbed from APUE by Stevens
171 ioctl(STDIN_FILENO, TIOCSCTTY, 0); 171 ioctl(STDIN_FILENO, TIOCSCTTY, 0);
172#endif 172#endif
173 tcgetattr( STDIN_FILENO, &ttmode ); 173 tcgetattr( STDIN_FILENO, &ttmode );
174 ttmode.c_cc[VINTR] = 3; 174 ttmode.c_cc[VINTR] = 3;
175 ttmode.c_cc[VERASE] = 8; 175 ttmode.c_cc[VERASE] = 8;
176 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); 176 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
177 setenv("TERM",m_term,1); 177 setenv("TERM",m_term,1);
178 setenv("COLORTERM","0",1); 178 setenv("COLORTERM","0",1);
179 EnvironmentMap::Iterator it; 179 EnvironmentMap::Iterator it;
180 for (it = m_env.begin(); it != m_env.end(); it++) { 180 for (it = m_env.begin(); it != m_env.end(); it++) {
181 setenv(it.key().latin1(), it.data().latin1(), 1); 181 setenv(it.key().latin1(), it.data().latin1(), 1);
182 } 182 }
183 if (getuid() == 0) { 183 if (getuid() == 0) {
184 char msg[] = "WARNING: You are running this shell as root!\n"; 184 char msg[] = "WARNING: You are running this shell as root!\n";
185 write(ttyfd, msg, sizeof(msg)); 185 write(ttyfd, msg, sizeof(msg));
186 } 186 }
187 execl(cmd, cmd, 0); 187 execl(cmd, cmd, 0);
188 188
189 donePty(); 189 donePty();
190 exit(-1); 190 exit(-1);
191 } 191 }
192 192
193 // parent - continue as a widget 193 // parent - continue as a widget
194 delete m_sn_r; 194 delete m_sn_r;
195 m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); 195 m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this);
196 delete m_sn_e; 196 delete m_sn_e;
197 m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); 197 m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this);
198 connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); 198 connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
199 connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); 199 connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error()));
200 200
201 return 0; 201 return 0;
202} 202}
203 203
204int MyPty::openPty() 204int MyPty::openPty()
205{ 205{
206 // This is code from the Qt DumbTerminal example 206 // This is code from the Qt DumbTerminal example
207 int ptyfd = -1; 207 int ptyfd = -1;
208 208
209#ifdef HAVE_OPENPTY 209#ifdef HAVE_OPENPTY
210 int ttyfd; 210 int ttyfd;
211 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) 211 if ( openpty(&ptyfd,&ttyfd,m_ttynam,0,0) )
212 ptyfd = -1; 212 ptyfd = -1;
213 else 213 else
214 close(ttyfd); // we open the ttynam ourselves. 214 ::close(ttyfd); // we open the ttynam ourselves.
215#else 215#else
216 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { 216 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) {
217 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { 217 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) {
218 sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); 218 sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1);
219 sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); 219 sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1);
220 if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { 220 if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) {
221 if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { 221 if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) {
222 ::close(ptyfd); 222 ::close(ptyfd);
223 ptyfd = -1; 223 ptyfd = -1;
224 } 224 }
225 } 225 }
226 } 226 }
227 } 227 }
228#endif 228#endif
229 229
230 if ( ptyfd < 0 ) { 230 if ( ptyfd < 0 ) {
231 //qApp->exit(1); 231 //qApp->exit(1);
232 return -1; 232 return -1;
233 } 233 }
234 234
235 return ptyfd; 235 return ptyfd;
236} 236}
237 237
238/*! 238/*!
239 Create an instance. 239 Create an instance.
240*/ 240*/
241MyPty::MyPty(const Profile& prof) : m_cpid(0) 241MyPty::MyPty(const Profile& prof) : m_cpid(0)
242{ 242{
243 243
244 int term = prof.readNumEntry("Terminal", Profile::VT100 ); 244 int term = prof.readNumEntry("Terminal", Profile::VT100 );
245 switch( term ) { 245 switch( term ) {
246 default: 246 default:
247 case Profile::VT100: 247 case Profile::VT100:
248 case Profile::VT102: 248 case Profile::VT102:
249 m_term = "vt100"; 249 m_term = "vt100";
250 break; 250 break;
251 case Profile::Linux: 251 case Profile::Linux:
252 m_term = "linux"; 252 m_term = "linux";
253 break; 253 break;
254 case Profile::XTerm: 254 case Profile::XTerm:
255 m_term = "xterm"; 255 m_term = "xterm";
256 break; 256 break;
257 } 257 }
258 m_sn_e = 0l; 258 m_sn_e = 0l;
259 m_sn_r = 0l; 259 m_sn_r = 0l;
260 m_fd = openPty(); 260 m_fd = openPty();
261 ProcCtl* ctl = ProcCtl::self(); 261 ProcCtl* ctl = ProcCtl::self();
262 Q_UNUSED(ctl); 262 Q_UNUSED(ctl);
263 reload(prof); 263 reload(prof);
264} 264}
265 265
266/*! 266/*!
267 Destructor. 267 Destructor.
268 Note that the related client program is not killed 268 Note that the related client program is not killed
269 (yet) when a instance is deleted. 269 (yet) when a instance is deleted.
270*/ 270*/
271MyPty::~MyPty() 271MyPty::~MyPty()
272{ 272{
273 donePty(); 273 donePty();
274} 274}
275QString MyPty::identifier()const { 275QString MyPty::identifier()const {
276 return QString::fromLatin1("term"); 276 return QString::fromLatin1("term");
277} 277}
278QString MyPty::name()const{ 278QString MyPty::name()const{
279 return identifier(); 279 return identifier();
280} 280}
281bool MyPty::open() { 281bool MyPty::open() {
282 if (m_fd < 0) 282 if (m_fd < 0)
283 m_fd = openPty(); 283 m_fd = openPty();
284 284
285 start(); 285 start();
286 return true; 286 return true;
287} 287}
288void MyPty::close() { 288void MyPty::close() {
289 donePty(); 289 donePty();
290 m_fd = openPty(); 290 m_fd = openPty();
291} 291}
292void MyPty::reload( const Profile& prof) { 292void MyPty::reload( const Profile& prof) {
293 m_env.clear(); 293 m_env.clear();
294 m_cmd = prof.readEntry("Command", "/bin/sh"); 294 m_cmd = prof.readEntry("Command", "/bin/sh");
295 295
296 /* 296 /*
297 * Lets check if m_cmd actually 297 * Lets check if m_cmd actually
298 * exists.... 298 * exists....
299 * we try to use bin/bash and if 299 * we try to use bin/bash and if
300 * this fails we 300 * this fails we
301 * will fallback to /bin/sh 301 * will fallback to /bin/sh
302 * which should be there 100% 302 * which should be there 100%
303 */ 303 */
304 if ( m_cmd.stripWhiteSpace() == "/bin/bash" && !QFile::exists(QFile::encodeName(m_cmd) ) ) 304 if ( m_cmd.stripWhiteSpace() == "/bin/bash" && !QFile::exists(QFile::encodeName(m_cmd) ) )
305 m_cmd = "/bin/sh"; 305 m_cmd = "/bin/sh";
306 306
307 307
308 int envcount = prof.readNumEntry("EnvVars", 0); 308 int envcount = prof.readNumEntry("EnvVars", 0);
309 for (int i=0; i<envcount; i++) { 309 for (int i=0; i<envcount; i++) {
310 QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); 310 QString name = prof.readEntry("Env_Name_" + QString::number(i), "");
311 QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); 311 QString value = prof.readEntry("Env_Value_" + QString::number(i), "");
312 if (!(name.isEmpty() || value.isEmpty())) { 312 if (!(name.isEmpty() || value.isEmpty())) {
313 m_env.insert(name, value); 313 m_env.insert(name, value);
314 } 314 }
315 } 315 }
316} 316}
317/*! sends len bytes through the line */ 317/*! sends len bytes through the line */
318void MyPty::send(const QByteArray& ar) 318void MyPty::send(const QByteArray& ar)
319{ 319{
320#ifdef VERBOSE_DEBUG 320#ifdef VERBOSE_DEBUG
321 // verbose debug 321 // verbose debug
322 printf("sending bytes:\n"); 322 printf("sending bytes:\n");
323 for (uint i = 0; i < ar.count(); i++) 323 for (uint i = 0; i < ar.count(); i++)
324 printf("%c", ar[i]); 324 printf("%c", ar[i]);
325 printf("\n"); 325 printf("\n");
326#endif 326#endif
327 327
328 ::write(m_fd, ar.data(), ar.count()); 328 ::write(m_fd, ar.data(), ar.count());
329} 329}
330 330
331/*! indicates that a block of data is received */ 331/*! indicates that a block of data is received */
332void MyPty::readPty() 332void MyPty::readPty()
333{ 333{
334 QByteArray buf(4096); 334 QByteArray buf(4096);
335 335
336 int len = ::read( m_fd, buf.data(), 4096 ); 336 int len = ::read( m_fd, buf.data(), 4096 );
337 337
338 if (len == -1 || len == 0) { 338 if (len == -1 || len == 0) {
339 donePty(); 339 donePty();
340 return; 340 return;
341 } 341 }
342 342
343 if (len < 0) 343 if (len < 0)
344 return; 344 return;
345 345
346 346
347 buf.resize(len); 347 buf.resize(len);
348 emit received(buf); 348 emit received(buf);
349 349
350#ifdef VERBOSE_DEBUG 350#ifdef VERBOSE_DEBUG
351 // verbose debug 351 // verbose debug
352 printf("read bytes:\n"); 352 printf("read bytes:\n");
353 for (uint i = 0; i < buf.count(); i++) 353 for (uint i = 0; i < buf.count(); i++)
354 printf("%c", buf[i]); 354 printf("%c", buf[i]);
355 printf("\n"); 355 printf("\n");
356#endif 356#endif
357 357
358} 358}
359QBitArray MyPty::supports()const { 359QBitArray MyPty::supports()const {
360 QBitArray ar(3); 360 QBitArray ar(3);
361 //autoconnect 361 //autoconnect
362 ar[0] = 1; 362 ar[0] = 1;
363 // 363 //
364 ar[1] = 0; 364 ar[1] = 0;
365 ar[2] = 0; 365 ar[2] = 0;
366 366
367 return ar; 367 return ar;
368} 368}
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp
index 8dd8151..37bf797 100644
--- a/noncore/apps/opie-console/io_bt.cpp
+++ b/noncore/apps/opie-console/io_bt.cpp
@@ -1,80 +1,92 @@
1 1
2#include "io_bt.h" 2#include "io_bt.h"
3 3
4IOBt::IOBt( const Profile &config ) : IOSerial( config ) { 4IOBt::IOBt( const Profile &config ) : IOSerial( config ) {
5 m_attach = 0; 5 m_attach = 0;
6} 6}
7 7
8 8
9IOBt::~IOBt() { 9IOBt::~IOBt() {
10 if ( m_attach ) { 10 if ( m_attach ) {
11 delete m_attach; 11 delete m_attach;
12 } 12 }
13} 13}
14 14
15 15
16void IOBt::close() { 16void IOBt::close() {
17 17
18 IOSerial::close(); 18 IOSerial::close();
19 // still need error handling 19 // still need error handling
20 if ( m_attach ) { 20 if ( m_attach ) {
21 delete m_attach; 21 delete m_attach;
22 m_attach = 0; 22 m_attach = 0;
23 } 23 }
24} 24}
25 25
26bool IOBt::open() { 26bool IOBt::open() {
27 bool ret = false; 27 bool ret = false;
28 28
29 // only set up bt stuff if mac address was set, otherwise use the device set 29 // only set up bt stuff if mac address was set, otherwise use the device set
30 if ( !m_mac.isEmpty() ) { 30 if ( !m_mac.isEmpty() ) {
31 31
32 // now it should also be checked, if there is a connection to the device with that mac allready 32 // now it should also be checked, if there is a connection to the device with that mac allready
33 // hciattach here 33 // hciattach here
34 m_attach = new OProcess(); 34 m_attach = new OProcess();
35 *m_attach << "hciattach /dev/ttyS2 any 57600"; 35 *m_attach << "hciattach /dev/ttyS2 any 57600";
36 36
37 // then start hcid, then rcfomm handling (m_mac) 37 // then start hcid, then rcfomm handling (m_mac)
38 38
39 connect( m_attach, SIGNAL( processExited( OProcess* ) ), 39 connect( m_attach, SIGNAL( processExited( OProcess* ) ),
40 this, SLOT( slotExited( OProcess* ) ) ); 40 this, SLOT( slotExited( OProcess* ) ) );
41 41
42 if ( m_attach->start() ) { 42 if ( m_attach->start() ) {
43 ret = IOSerial::open(); 43 ret = IOSerial::open();
44 } else { 44 } else {
45 qWarning("could not attach to device"); 45 qWarning("could not attach to device");
46 delete m_attach; 46 delete m_attach;
47 m_attach = 0; 47 m_attach = 0;
48 } 48 }
49 } else { 49 } else {
50 // directly to the normal serial 50 // directly to the normal serial
51 // TODO: look first if the connection really exists. ( is set up ) 51 // TODO: look first if the connection really exists. ( is set up )
52 52
53 ret =IOSerial::open(); 53 ret =IOSerial::open();
54 } 54 }
55 return ret; 55 return ret;
56} 56}
57 57
58void IOBt::reload( const Profile &config ) { 58void IOBt::reload( const Profile &config ) {
59 m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); 59 m_device = config.readEntry("Device", BT_DEFAULT_DEVICE);
60 m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); 60 m_mac = config.readEntry("Mac", BT_DEFAULT_MAC);
61 m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); 61 m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD);
62 m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); 62 m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY);
63 m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); 63 m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS);
64 m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); 64 m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS);
65 m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); 65 m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW);
66} 66}
67 67
68 68
69QString IOBt::identifier() const { 69QString IOBt::identifier() const {
70 return "bluetooth"; 70 return "bluetooth";
71} 71}
72 72
73QString IOBt::name() const { 73QString IOBt::name() const {
74 return "BLuetooth IO Layer"; 74 return "BLuetooth IO Layer";
75} 75}
76 76
77void IOBt::slotExited( OProcess* proc ){ 77void IOBt::slotExited( OProcess* proc ){
78 close(); 78 close();
79 delete proc; 79 delete proc;
80} 80}
81
82QBitArray IOBt::supports() const {
83 return QBitArray( 3 );
84}
85
86bool IOBt::isConnected() {
87 return false;
88}
89
90void IOBt::send(const QByteArray &data) {
91 qDebug( "Please overload me..." );
92}
diff --git a/noncore/apps/opie-console/io_bt.h b/noncore/apps/opie-console/io_bt.h
index 5e9988c..239eefb 100644
--- a/noncore/apps/opie-console/io_bt.h
+++ b/noncore/apps/opie-console/io_bt.h
@@ -1,48 +1,51 @@
1#ifndef OPIE_IO_BT 1#ifndef OPIE_IO_BT
2#define OPIE_IO_BT 2#define OPIE_IO_BT
3 3
4#include <opie/oprocess.h> 4#include <opie/oprocess.h>
5#include "io_serial.h" 5#include "io_serial.h"
6 6
7/* Default values to be used if the profile information is incomplete */ 7/* Default values to be used if the profile information is incomplete */
8#define BT_DEFAULT_DEVICE "/dev/ttyU0" 8#define BT_DEFAULT_DEVICE "/dev/ttyU0"
9#define BT_DEFAULT_BAUD 9600 9#define BT_DEFAULT_BAUD 9600
10#define BT_DEFAULT_PARITY 0 10#define BT_DEFAULT_PARITY 0
11#define BT_DEFAULT_DBITS 8 11#define BT_DEFAULT_DBITS 8
12#define BT_DEFAULT_SBITS 1 12#define BT_DEFAULT_SBITS 1
13#define BT_DEFAULT_FLOW 0 13#define BT_DEFAULT_FLOW 0
14#define BT_DEFAULT_MAC 0 14#define BT_DEFAULT_MAC 0
15 15
16 16
17/* IOSerial implements a RS232 IO Layer */ 17/* IOSerial implements a RS232 IO Layer */
18 18
19class IOBt : public IOSerial { 19class IOBt : public IOSerial {
20 20
21 Q_OBJECT 21 Q_OBJECT
22 22
23public: 23public:
24 24
25 IOBt(const Profile &); 25 IOBt(const Profile &);
26 ~IOBt(); 26 ~IOBt();
27 27
28 QString identifier() const; 28 virtual QString identifier() const;
29 QString name() const; 29 virtual QString name() const;
30 virtual QBitArray supports() const;
31 virtual bool isConnected();
30 32
31signals: 33signals:
32 void received(const QByteArray &); 34 void received(const QByteArray &);
33 void error(int, const QString &); 35 void error(int, const QString &);
34 36
35public slots: 37public slots:
36 bool open(); 38 virtual void send( const QByteArray& );
37 void close(); 39 virtual bool open();
38 void reload(const Profile &); 40 virtual void close();
41 virtual void reload(const Profile &);
39 42
40private: 43private:
41 OProcess *m_attach; 44 OProcess *m_attach;
42 QString m_mac; 45 QString m_mac;
43private slots: 46private slots:
44 void slotExited(OProcess* proc); 47 void slotExited(OProcess* proc);
45 48
46}; 49};
47 50
48#endif /* OPIE_IO_IRDA */ 51#endif /* OPIE_IO_IRDA */
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp
index b3b693f..e360fb4 100644
--- a/noncore/apps/opie-console/io_irda.cpp
+++ b/noncore/apps/opie-console/io_irda.cpp
@@ -1,65 +1,77 @@
1 1
2#include "io_irda.h" 2#include "io_irda.h"
3 3
4IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { 4IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) {
5 m_attach = 0; 5 m_attach = 0;
6} 6}
7 7
8 8
9IOIrda::~IOIrda() { 9IOIrda::~IOIrda() {
10 if ( m_attach ) { 10 if ( m_attach ) {
11 delete m_attach; 11 delete m_attach;
12 } 12 }
13} 13}
14 14
15 15
16void IOIrda::close() { 16void IOIrda::close() {
17 17
18 IOSerial::close(); 18 IOSerial::close();
19 // still need error handling 19 // still need error handling
20 delete m_attach; 20 delete m_attach;
21} 21}
22 22
23bool IOIrda::open() { 23bool IOIrda::open() {
24 bool ret; 24 bool ret;
25 25
26 // irdaattach here 26 // irdaattach here
27 m_attach = new OProcess(); 27 m_attach = new OProcess();
28 *m_attach << "irattach /dev/ttyS2 -s"; 28 *m_attach << "irattach /dev/ttyS2 -s";
29 29
30 connect( m_attach, SIGNAL( processExited( OProcess* ) ), 30 connect( m_attach, SIGNAL( processExited( OProcess* ) ),
31 this, SLOT( slotExited( OProcess* ) ) ); 31 this, SLOT( slotExited( OProcess* ) ) );
32 32
33 if ( m_attach->start() ) { 33 if ( m_attach->start() ) {
34 ret= IOSerial::open(); 34 ret= IOSerial::open();
35 } else { 35 } else {
36 // emit error!!! 36 // emit error!!!
37 qWarning("could not attach to device"); 37 qWarning("could not attach to device");
38 delete m_attach; 38 delete m_attach;
39 m_attach = 0l; 39 m_attach = 0l;
40 } 40 }
41 return ret; 41 return ret;
42} 42}
43 43
44void IOIrda::reload( const Profile &config ) { 44void IOIrda::reload( const Profile &config ) {
45 m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); 45 m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE);
46 m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); 46 m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD);
47 m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); 47 m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY);
48 m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); 48 m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS);
49 m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); 49 m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS);
50 m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); 50 m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW);
51} 51}
52 52
53 53
54QString IOIrda::identifier() const { 54QString IOIrda::identifier() const {
55 return "irda"; 55 return "irda";
56} 56}
57 57
58QString IOIrda::name() const { 58QString IOIrda::name() const {
59 return "Irda IO Layer"; 59 return "Irda IO Layer";
60} 60}
61 61
62void IOIrda::slotExited(OProcess* proc ){ 62void IOIrda::slotExited(OProcess* proc ){
63 close(); 63 close();
64 delete proc; 64 delete proc;
65} 65}
66
67QBitArray IOIrda::supports()const {
68 return QBitArray( 3 );
69}
70
71bool IOIrda::isConnected() {
72 return false;
73}
74
75void IOIrda::send(const QByteArray &data) {
76 qDebug( "Please overload me..." );
77}
diff --git a/noncore/apps/opie-console/io_irda.h b/noncore/apps/opie-console/io_irda.h
index 3aee951..14b1ae3 100644
--- a/noncore/apps/opie-console/io_irda.h
+++ b/noncore/apps/opie-console/io_irda.h
@@ -1,46 +1,49 @@
1#ifndef OPIE_IO_IRDA 1#ifndef OPIE_IO_IRDA
2#define OPIE_IO_IRDA 2#define OPIE_IO_IRDA
3 3
4#include <opie/oprocess.h> 4#include <opie/oprocess.h>
5#include "io_serial.h" 5#include "io_serial.h"
6 6
7/* Default values to be used if the profile information is incomplete */ 7/* Default values to be used if the profile information is incomplete */
8#define IRDA_DEFAULT_DEVICE "/dev/ircomm0" 8#define IRDA_DEFAULT_DEVICE "/dev/ircomm0"
9#define IRDA_DEFAULT_BAUD 9600 9#define IRDA_DEFAULT_BAUD 9600
10#define IRDA_DEFAULT_PARITY 0 10#define IRDA_DEFAULT_PARITY 0
11#define IRDA_DEFAULT_DBITS 8 11#define IRDA_DEFAULT_DBITS 8
12#define IRDA_DEFAULT_SBITS 1 12#define IRDA_DEFAULT_SBITS 1
13#define IRDA_DEFAULT_FLOW 0 13#define IRDA_DEFAULT_FLOW 0
14 14
15/* IOSerial implements a RS232 IO Layer */ 15/* IOSerial implements a RS232 IO Layer */
16 16
17class IOIrda : public IOSerial { 17class IOIrda : public IOSerial {
18 18
19 Q_OBJECT 19 Q_OBJECT
20 20
21public: 21public:
22 22
23 IOIrda(const Profile &); 23 IOIrda(const Profile &);
24 ~IOIrda(); 24 ~IOIrda();
25 25
26 QString identifier() const; 26 virtual QString identifier() const;
27 QString name() const; 27 virtual QString name() const;
28 virtual QBitArray supports() const;
29 virtual bool isConnected();
28 30
29signals: 31signals:
30 void received(const QByteArray &); 32 void received(const QByteArray &);
31 void error(int, const QString &); 33 void error(int, const QString &);
32 34
33public slots: 35public slots:
34 bool open(); 36 virtual void send( const QByteArray& );
35 void close(); 37 virtual bool open();
36 void reload(const Profile &); 38 virtual void close();
39 virtual void reload(const Profile &);
37 40
38private: 41private:
39 OProcess *m_attach; 42 OProcess *m_attach;
40 43
41private slots: 44private slots:
42 void slotExited(OProcess* proc); 45 void slotExited(OProcess* proc);
43 46
44}; 47};
45 48
46#endif /* OPIE_IO_IRDA */ 49#endif /* OPIE_IO_IRDA */
diff --git a/noncore/apps/opie-console/io_layer.cpp b/noncore/apps/opie-console/io_layer.cpp
index 975ee60..52ec828 100644
--- a/noncore/apps/opie-console/io_layer.cpp
+++ b/noncore/apps/opie-console/io_layer.cpp
@@ -1,22 +1,23 @@
1#include "io_layer.h" 1#include "io_layer.h"
2 2
3IOLayer::IOLayer() 3IOLayer::IOLayer()
4 : QObject() 4 : QObject()
5{ 5{
6} 6}
7 7
8IOLayer::IOLayer(const Profile &) 8IOLayer::IOLayer(const Profile &)
9 : QObject() 9 : QObject()
10{ 10{
11} 11}
12 12
13IOLayer::~IOLayer() { 13IOLayer::~IOLayer() {
14} 14}
15int IOLayer::rawIO()const{ 15int IOLayer::rawIO()const{
16 return -1; 16 return -1;
17} 17}
18void IOLayer::closeRawIO(int) { 18void IOLayer::closeRawIO(int) {
19 19
20} 20}
21void IOLayer::setSize(int, int ) { 21void IOLayer::setSize(int, int ) {
22} 22}
23
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h
index ed4478b..4f9bbe4 100644
--- a/noncore/apps/opie-console/io_layer.h
+++ b/noncore/apps/opie-console/io_layer.h
@@ -1,132 +1,132 @@
1#ifndef OPIE_IO_LAYER_H 1#ifndef OPIE_IO_LAYER_H
2#define OPIE_IO_LAYER_H 2#define OPIE_IO_LAYER_H
3 3
4#include <qbitarray.h> 4#include <qbitarray.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7 7
8#include <qpe/config.h> 8#include <qpe/config.h>
9 9
10#include "profile.h" 10#include "profile.h"
11 11
12/** 12/**
13 * This is the base class for IO Layers 13 * This is the base class for IO Layers
14 * It will used to sent and recv data( QByteArray ) 14 * It will used to sent and recv data( QByteArray )
15 * it 15 * it
16 */ 16 */
17class IOLayer : public QObject { 17class IOLayer : public QObject {
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
20 enum Error { 20 enum Error {
21 NoError = -1, 21 NoError = -1,
22 Refuse = 0, 22 Refuse = 0,
23 CouldNotOpen =1, 23 CouldNotOpen =1,
24 ClosedUnexpected =2, 24 ClosedUnexpected =2,
25 ClosedError =3, 25 ClosedError =3,
26 Terminate = 4 26 Terminate = 4
27 /* add more errors here */ 27 /* add more errors here */
28 }; 28 };
29 enum Feature { 29 enum Feature {
30 AutoConnect = 0, 30 AutoConnect = 0,
31 TransferFile = 1, 31 TransferFile = 1,
32 Close = 2 32 Close = 2
33 }; 33 };
34 /** 34 /**
35 * a small c'tor 35 * a small c'tor
36 */ 36 */
37 IOLayer(); 37 IOLayer();
38 38
39 /** 39 /**
40 * create an IOLayer instance from a config file 40 * create an IOLayer instance from a config file
41 * the currently set group stores the profile/session 41 * the currently set group stores the profile/session
42 * information 42 * information
43 */ 43 */
44 IOLayer( const Profile& ); 44 IOLayer( const Profile& );
45 45
46 /** 46 /**
47 * destructor 47 * destructor
48 */ 48 */
49 virtual ~IOLayer(); 49 virtual ~IOLayer();
50 50
51 /** 51 /**
52 * a small internal identifier 52 * a small internal identifier
53 */ 53 */
54 virtual QString identifier() const = 0; 54 virtual QString identifier() const = 0;
55 55
56 /** 56 /**
57 * a short name 57 * a short name
58 */ 58 */
59 virtual QString name() const = 0; 59 virtual QString name() const = 0;
60 60
61 /** 61 /**
62 * a file descriptor which opens 62 * a file descriptor which opens
63 * the device for io but does not 63 * the device for io but does not
64 * do any ioctling on it... 64 * do any ioctling on it...
65 * and it'll stop listening to the before opened 65 * and it'll stop listening to the before opened
66 * device 66 * device
67 */ 67 */
68 virtual int rawIO()const; 68 virtual int rawIO() const;
69 69
70 /** 70 /**
71 * will close the rawIO stuff 71 * will close the rawIO stuff
72 * and will listen to it's data again... 72 * and will listen to it's data again...
73 */ 73 */
74 virtual void closeRawIO(int); 74 virtual void closeRawIO(int);
75 75
76 /** 76 /**
77 * What does the IOLayer support? 77 * What does the IOLayer support?
78 * Bits are related to features 78 * Bits are related to features
79 */ 79 */
80 virtual QBitArray supports()const = 0; 80 virtual QBitArray supports() const = 0;
81 81
82 virtual bool isConnected() = 0; 82 virtual bool isConnected() = 0;
83 83
84signals: 84signals:
85 /** 85 /**
86 * received input as QCString 86 * received input as QCString
87 */ 87 */
88 virtual void received( const QByteArray& ); 88 virtual void received( const QByteArray& );
89 89
90 /** 90 /**
91 * an error occured 91 * an error occured
92 * int for the error number 92 * int for the error number
93 * and QString for a text 93 * and QString for a text
94 */ 94 */
95 virtual void error( int, const QString& ); 95 virtual void error( int, const QString& );
96 96
97 97
98 virtual void closed(); 98 virtual void closed();
99 99
100 /* signal emitted for closure of the IOLayer 100 /* signal emitted for closure of the IOLayer
101 * for some reasons 101 * for some reasons
102 */ 102 */
103 virtual void closed(IOLayer*); 103 virtual void closed(IOLayer*);
104public slots: 104public slots:
105 /** 105 /**
106 * send a QCString to the device 106 * send a QCString to the device
107 */ 107 */
108 virtual void send( const QByteArray& ) = 0; 108 virtual void send( const QByteArray& ) = 0;
109 109
110 /** 110 /**
111 * bool open 111 * bool open
112 */ 112 */
113 virtual bool open() = 0; 113 virtual bool open() = 0;
114 114
115 /** 115 /**
116 * close the io 116 * close the io
117 */ 117 */
118 virtual void close() = 0; 118 virtual void close() = 0;
119 119
120 /** 120 /**
121 * closes and reloads the settings 121 * closes and reloads the settings
122 */ 122 */
123 virtual void reload( const Profile& ) = 0; 123 virtual void reload( const Profile& ) = 0;
124 124
125 /** 125 /**
126 * set the size 126 * set the size
127 * needed for pty 127 * needed for pty
128 */ 128 */
129 virtual void setSize(int lines, int cols ); 129 virtual void setSize(int lines, int cols );
130}; 130};
131 131
132#endif 132#endif
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index 896c24f..1ce680a 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -1,95 +1,106 @@
1 1
2#include "io_modem.h" 2#include "io_modem.h"
3 3
4#include "dialer.h" 4#include "dialer.h"
5 5
6IOModem::IOModem( const Profile &profile ) 6IOModem::IOModem( const Profile &profile )
7 : IOSerial( profile ) { 7 : IOSerial( profile ) {
8 m_profile = profile; 8 m_profile = profile;
9} 9}
10 10
11 11
12IOModem::~IOModem() { 12IOModem::~IOModem() {
13 13
14} 14}
15 15
16 16
17void IOModem::close() { 17void IOModem::close() {
18 // Hangup, discarding result 18 // Hangup, discarding result
19 //int fd = rawIO(); 19 //int fd = rawIO();
20 internDetach(); 20 internDetach();
21 Dialer d(m_profile, m_fd); 21 Dialer d(m_profile, m_fd);
22 d.setHangupOnly(); 22 d.setHangupOnly();
23 //d.exec(); 23 //d.exec();
24 internAttach(); 24 internAttach();
25 //closeRawIO(fd); 25 //closeRawIO(fd);
26 26
27 IOSerial::close(); 27 IOSerial::close();
28} 28}
29 29
30bool IOModem::open() { 30bool IOModem::open() {
31 bool ret = IOSerial::open(); 31 bool ret = IOSerial::open();
32 if(!ret) return false; 32 if(!ret) return false;
33 33
34 //int fd = rawIO(); 34 //int fd = rawIO();
35 internDetach(); 35 internDetach();
36 Dialer d(m_profile, m_fd); 36 Dialer d(m_profile, m_fd);
37 37
38 int result = d.exec(); 38 int result = d.exec();
39 internAttach(); 39 internAttach();
40 //closeRawIO(fd); 40 //closeRawIO(fd);
41 if(result == QDialog::Accepted) 41 if(result == QDialog::Accepted)
42 { 42 {
43 return true; 43 return true;
44 } 44 }
45 else 45 else
46 { 46 {
47 close(); 47 close();
48 return false; 48 return false;
49 } 49 }
50} 50}
51 51
52void IOModem::reload( const Profile &config ) { 52void IOModem::reload( const Profile &config ) {
53 53
54 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); 54 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE);
55 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); 55 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD);
56 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); 56 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY);
57 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); 57 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS);
58 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); 58 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS);
59 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); 59 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW);
60 60
61 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); 61 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING );
62 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); 62 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING );
63 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); 63 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 );
64 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); 64 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 );
65 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); 65 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 );
66 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); 66 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 );
67 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); 67 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 );
68 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); 68 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 );
69 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); 69 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING );
70 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); 70 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING );
71 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); 71 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING );
72 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); 72 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME );
73 m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); 73 m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL );
74 m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); 74 m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES );
75 m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); 75 m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME );
76 m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); 76 m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT );
77 m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); 77 m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES );
78 m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); 78 m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG );
79} 79}
80 80
81 81
82QString IOModem::identifier() const { 82QString IOModem::identifier() const {
83 return "modem"; 83 return "modem";
84} 84}
85 85
86QString IOModem::name() const { 86QString IOModem::name() const {
87 return "Modem IO Layer"; 87 return "Modem IO Layer";
88} 88}
89 89
90void IOModem::slotExited(OProcess* proc ){ 90void IOModem::slotExited(OProcess* proc ){
91 close(); 91 close();
92 /* delete it afterwards */ 92 /* delete it afterwards */
93 delete proc; 93 delete proc;
94} 94}
95 95
96QBitArray IOModem::supports()const {
97 return QBitArray( 3 );
98}
99
100bool IOModem::isConnected() {
101 return false;
102}
103
104void IOModem::send(const QByteArray &data) {
105 qDebug( "Please overload me..." );
106}
diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h
index 17228bd..2a926df 100644
--- a/noncore/apps/opie-console/io_modem.h
+++ b/noncore/apps/opie-console/io_modem.h
@@ -1,71 +1,74 @@
1#ifndef OPIE_IO_MODEM 1#ifndef OPIE_IO_MODEM
2#define OPIE_IO_MODEM 2#define OPIE_IO_MODEM
3 3
4#include <opie/oprocess.h> 4#include <opie/oprocess.h>
5#include "io_serial.h" 5#include "io_serial.h"
6#include "profile.h" 6#include "profile.h"
7 7
8/* Default values to be used if the profile information is incomplete */ 8/* Default values to be used if the profile information is incomplete */
9#define MODEM_DEFAULT_DEVICE "/dev/ttyS0" 9#define MODEM_DEFAULT_DEVICE "/dev/ttyS0"
10#define MODEM_DEFAULT_BAUD 9600 10#define MODEM_DEFAULT_BAUD 9600
11#define MODEM_DEFAULT_PARITY 0 11#define MODEM_DEFAULT_PARITY 0
12#define MODEM_DEFAULT_DBITS 8 12#define MODEM_DEFAULT_DBITS 8
13#define MODEM_DEFAULT_SBITS 1 13#define MODEM_DEFAULT_SBITS 1
14#define MODEM_DEFAULT_FLOW 0 14#define MODEM_DEFAULT_FLOW 0
15 15
16#define MODEM_DEFAULT_INIT_STRING "AT" 16#define MODEM_DEFAULT_INIT_STRING "AT"
17#define MODEM_DEFAULT_RESET_STRING "ATZ~" 17#define MODEM_DEFAULT_RESET_STRING "ATZ~"
18#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" 18#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT"
19#define MODEM_DEFAULT_DIAL_SUFFIX1 "" 19#define MODEM_DEFAULT_DIAL_SUFFIX1 ""
20#define MODEM_DEFAULT_DIAL_PREFIX2 "" 20#define MODEM_DEFAULT_DIAL_PREFIX2 ""
21#define MODEM_DEFAULT_DIAL_SUFFIX2 "" 21#define MODEM_DEFAULT_DIAL_SUFFIX2 ""
22#define MODEM_DEFAULT_DIAL_PREFIX3 "" 22#define MODEM_DEFAULT_DIAL_PREFIX3 ""
23#define MODEM_DEFAULT_DIAL_SUFFIX3 "" 23#define MODEM_DEFAULT_DIAL_SUFFIX3 ""
24#define MODEM_DEFAULT_CONNECT_STRING "CONNECT" 24#define MODEM_DEFAULT_CONNECT_STRING "CONNECT"
25#define MODEM_DEFAULT_HANGUP_STRING "+++ATH" 25#define MODEM_DEFAULT_HANGUP_STRING "+++ATH"
26#define MODEM_DEFAULT_CANCEL_STRING "" 26#define MODEM_DEFAULT_CANCEL_STRING ""
27#define MODEM_DEFAULT_DIAL_TIME 45 27#define MODEM_DEFAULT_DIAL_TIME 45
28#define MODEM_DEFAULT_DELAY_REDIAL 2 28#define MODEM_DEFAULT_DELAY_REDIAL 2
29#define MODEM_DEFAULT_NUMBER_TRIES 10 29#define MODEM_DEFAULT_NUMBER_TRIES 10
30#define MODEM_DEFAULT_DTR_DROP_TIME 1 30#define MODEM_DEFAULT_DTR_DROP_TIME 1
31#define MODEM_DEFAULT_BPS_DETECT 0 // bool 31#define MODEM_DEFAULT_BPS_DETECT 0 // bool
32#define MODEM_DEFAULT_DCD_LINES 1 //bool 32#define MODEM_DEFAULT_DCD_LINES 1 //bool
33#define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool 33#define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool
34 34
35/* IOSerial implements a RS232 IO Layer */ 35/* IOSerial implements a RS232 IO Layer */
36 36
37class IOModem : public IOSerial { 37class IOModem : public IOSerial {
38 38
39 Q_OBJECT 39 Q_OBJECT
40 40
41public: 41public:
42 42
43 IOModem(const Profile &); 43 IOModem(const Profile &);
44 ~IOModem(); 44 ~IOModem();
45 45
46 QString identifier() const; 46 virtual QString identifier() const;
47 QString name() const; 47 virtual QString name() const;
48 virtual QBitArray supports() const;
49 virtual bool isConnected();
48 50
49signals: 51signals:
50 void received(const QByteArray &); 52 void received(const QByteArray &);
51 void error(int, const QString &); 53 void error(int, const QString &);
52 54
53public slots: 55public slots:
54 bool open(); 56 virtual void send( const QByteArray& );
55 void close(); 57 virtual bool open();
56 void reload(const Profile &); 58 virtual void close();
59 virtual void reload(const Profile &);
57 60
58private: 61private:
59 62
60 QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, 63 QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2,
61 m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; 64 m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel;
62 int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, 65 int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime,
63 m_bpsDetect, m_dcdLines, m_multiLineUntag; 66 m_bpsDetect, m_dcdLines, m_multiLineUntag;
64 Profile m_profile; 67 Profile m_profile;
65 68
66private slots: 69private slots:
67 void slotExited(OProcess* proc); 70 void slotExited(OProcess* proc);
68 71
69}; 72};
70 73
71#endif 74#endif
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h
index edceac6..20c1ae1 100644
--- a/noncore/apps/opie-console/io_serial.h
+++ b/noncore/apps/opie-console/io_serial.h
@@ -1,72 +1,73 @@
1#ifndef OPIE_IO_SERIAL 1#ifndef OPIE_IO_SERIAL
2#define OPIE_IO_SERIAL 2#define OPIE_IO_SERIAL
3 3
4#include <qsocketnotifier.h> 4#include <qsocketnotifier.h>
5#include "io_layer.h" 5#include "io_layer.h"
6 6
7/* Default values to be used if the profile information is incomplete */ 7/* Default values to be used if the profile information is incomplete */
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
17class IOSerial : public IOLayer { 17class IOSerial : public IOLayer {
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
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 virtual QString identifier() const;
37 QString name() const; 37 virtual QString name() const;
38 int rawIO()const; 38 int rawIO() const;
39 void closeRawIO(int fd ); 39 void closeRawIO (int fd );
40 QBitArray supports()const; 40 virtual QBitArray supports() const;
41 bool isConnected(); 41 virtual bool isConnected();
42
42/*signals: 43/*signals:
43 void received(const QByteArray &); 44 void received(const QByteArray &);
44 void error(int, const QString &); 45 void error(int, const QString &);
45*/ 46*/
46public slots: 47public slots:
47 void send(const QByteArray &); 48 virtual void send(const QByteArray &);
48 bool open(); 49 virtual bool open();
49 void close(); 50 virtual void close();
50 void reload(const Profile &); 51 virtual void reload(const Profile &);
51protected: 52protected:
52 int baud(int baud) const; 53 int baud(int baud) const;
53 void internDetach(); 54 void internDetach();
54 void internAttach(); 55 void internAttach();
55protected slots: 56protected slots:
56 void dataArrived(); 57 void dataArrived();
57 void errorOccured(); 58 void errorOccured();
58protected: 59protected:
59 QSocketNotifier *m_read; 60 QSocketNotifier *m_read;
60 QSocketNotifier *m_error; 61 QSocketNotifier *m_error;
61 QString m_device; 62 QString m_device;
62 int m_baud; 63 int m_baud;
63 int m_parity; 64 int m_parity;
64 int m_dbits; 65 int m_dbits;
65 int m_sbits; 66 int m_sbits;
66 int m_flow; 67 int m_flow;
67 int m_fd; 68 int m_fd;
68 bool m_connected; 69 bool m_connected;
69 70
70}; 71};
71 72
72#endif /* OPIE_IO_SERIAL */ 73#endif /* OPIE_IO_SERIAL */
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 1bb9f35..5ffa46f 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,77 +1,77 @@
1TEMPLATE = app 1TEMPLATE = app
2 TMAKE_CXXFLAGS=-DHAVE_OPENPTY 2 TMAKE_CXXFLAGS+= -DHAVE_OPENPTY
3CONFIG = qt warn_on release 3CONFIG += qt warn_on release
4 #CONFIG = qt debug 4 #CONFIG = qt debug
5DESTDIR = $(OPIEDIR)/bin 5DESTDIR = $(OPIEDIR)/bin
6HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ 6HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
7 file_layer.h filetransfer.h \ 7 file_layer.h filetransfer.h \
8 metafactory.h \ 8 metafactory.h \
9 session.h \ 9 session.h \
10 mainwindow.h \ 10 mainwindow.h \
11 profile.h \ 11 profile.h \
12 profileconfig.h \ 12 profileconfig.h \
13 profilemanager.h \ 13 profilemanager.h \
14 configwidget.h \ 14 configwidget.h \
15 tabwidget.h \ 15 tabwidget.h \
16 configdialog.h \ 16 configdialog.h \
17 keytrans.h \ 17 keytrans.h \
18 transferdialog.h \ 18 transferdialog.h \
19 profiledialogwidget.h \ 19 profiledialogwidget.h \
20 profileeditordialog.h \ 20 profileeditordialog.h \
21 default.h \ 21 default.h \
22 iolayerbase.h \ 22 iolayerbase.h \
23 serialconfigwidget.h irdaconfigwidget.h \ 23 serialconfigwidget.h irdaconfigwidget.h \
24 btconfigwidget.h modemconfigwidget.h \ 24 btconfigwidget.h modemconfigwidget.h \
25 atconfigdialog.h dialdialog.h \ 25 atconfigdialog.h dialdialog.h \
26 procctl.h \ 26 procctl.h \
27 function_keyboard.h \ 27 function_keyboard.h \
28 receive_layer.h filereceive.h \ 28 receive_layer.h filereceive.h \
29 script.h \ 29 script.h \
30 dialer.h \ 30 dialer.h \
31 terminalwidget.h \ 31 terminalwidget.h \
32 emulation_handler.h TECommon.h \ 32 emulation_handler.h TECommon.h \
33 TEHistroy.h TEScreen.h TEWidget.h \ 33 TEHistory.h TEScreen.h TEWidget.h \
34 TEmuVt102.h TEmulation.h MyPty.h \ 34 TEmuVt102.h TEmulation.h MyPty.h \
35 consoleconfigwidget.h 35 consoleconfigwidget.h
36 36
37SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ 37SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
38 file_layer.cpp filetransfer.cpp \ 38 file_layer.cpp filetransfer.cpp \
39 main.cpp \ 39 main.cpp \
40 metafactory.cpp \ 40 metafactory.cpp \
41 session.cpp \ 41 session.cpp \
42 mainwindow.cpp \ 42 mainwindow.cpp \
43 profile.cpp \ 43 profile.cpp \
44 profileconfig.cpp \ 44 profileconfig.cpp \
45 profilemanager.cpp \ 45 profilemanager.cpp \
46 tabwidget.cpp \ 46 tabwidget.cpp \
47 configdialog.cpp \ 47 configdialog.cpp \
48 keytrans.cpp \ 48 keytrans.cpp \
49 transferdialog.cpp \ 49 transferdialog.cpp \
50 profiledialogwidget.cpp \ 50 profiledialogwidget.cpp \
51 profileeditordialog.cpp \ 51 profileeditordialog.cpp \
52 iolayerbase.cpp \ 52 iolayerbase.cpp \
53 serialconfigwidget.cpp irdaconfigwidget.cpp \ 53 serialconfigwidget.cpp irdaconfigwidget.cpp \
54 btconfigwidget.cpp modemconfigwidget.cpp \ 54 btconfigwidget.cpp modemconfigwidget.cpp \
55 atconfigdialog.cpp dialdialog.cpp \ 55 atconfigdialog.cpp dialdialog.cpp \
56 default.cpp procctl.cpp \ 56 default.cpp procctl.cpp \
57 function_keyboard.cpp \ 57 function_keyboard.cpp \
58 receive_layer.cpp filereceive.cpp \ 58 receive_layer.cpp filereceive.cpp \
59 script.cpp \ 59 script.cpp \
60 dialer.cpp \ 60 dialer.cpp \
61 terminalwidget.cpp \ 61 terminalwidget.cpp \
62 emulation_handler.cpp TEHistory.cpp \ 62 emulation_handler.cpp TEHistory.cpp \
63 TEScreen.cpp TEWidget.cpp \ 63 TEScreen.cpp TEWidget.cpp \
64 TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ 64 TEmuVt102.cpp TEmulation.cpp MyPty.cpp \
65 consoleconfigwidget.cpp 65 consoleconfigwidget.cpp
66 66
67 67
68INTERFACES = configurebase.ui editbase.ui 68INTERFACES = configurebase.ui editbase.ui
69INCLUDEPATH += $(OPIEDIR)/include 69INCLUDEPATH += $(OPIEDIR)/include
70DEPENDPATH += $(OPIEDIR)/include 70DEPENDPATH += $(OPIEDIR)/include
71LIBS += -lqpe -lopie 71LIBS += -lqpe -lopie -lutil
72TARGET = opie-console 72TARGET = opie-console
73 73
74 74
75 75
76 76
77include ( ../../../include.pro ) 77include ( ../../../include.pro )