summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/sz_transfer.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/sz_transfer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp121
1 files changed, 15 insertions, 106 deletions
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp
index 41917c0..0a315cf 100644
--- a/noncore/apps/opie-console/sz_transfer.cpp
+++ b/noncore/apps/opie-console/sz_transfer.cpp
@@ -6,100 +6,4 @@
6#include <sys/termios.h> 6#include <sys/termios.h>
7 7
8/* following function ripped out of minicom's sysdep2.c */
9
10
11/*
12 * Set cbreak mode.
13 * Mode 0 = normal.
14 * Mode 1 = cbreak, no echo
15 * Mode 2 = raw, no echo.
16 * Mode 3 = only return erasechar (for wkeys.c)
17 *
18 * Returns: the current erase character.
19 */
20
21static struct termios savetty;
22int setcbreak(int mode)
23{
24#if 1
25 struct termios tty;
26 static int init = 0;
27 static int erasechar;
28
29
30 if (init == 0) {
31 tcgetattr(0, &savetty);
32 erasechar = savetty.c_cc[VERASE];
33 init++;
34 }
35
36 if (mode == 3) return(erasechar);
37
38
39
40 /* Always return to default settings first */
41 tcsetattr(0, TCSADRAIN, &savetty);
42
43 if (mode == 0) {
44 return(erasechar);
45 }
46
47 tcgetattr(0, &tty);
48 if (mode == 1) {
49 tty.c_oflag &= ~OPOST;
50 tty.c_lflag &= ~(XCASE|ECHONL|NOFLSH);
51 tty.c_lflag &= ~(ICANON | ISIG | ECHO);
52 tty.c_iflag &= ~(ICRNL|INLCR);
53 tty.c_cflag |= CREAD;
54 tty.c_cc[VTIME] = 5;
55 tty.c_cc[VMIN] = 1;
56 }
57 if (mode == 2) { /* raw */
58 tty.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | IUCLC |
59 IXANY | IXON | IXOFF | INPCK | ISTRIP);
60 tty.c_iflag |= (BRKINT | IGNPAR);
61 tty.c_oflag &= ~OPOST;
62 tty.c_lflag &= ~(XCASE|ECHONL|NOFLSH);
63 tty.c_lflag &= ~(ICANON | ISIG | ECHO);
64 tty.c_cflag |= CREAD;
65 tty.c_cc[VTIME] = 5;
66 tty.c_cc[VMIN] = 1;
67 }
68 tcsetattr(0, TCSADRAIN, &tty);
69 return(erasechar);
70#else
71 struct sgttyb args;
72 static int init = 0;
73 static int erasechar;
74
75 if (init == 0) {
76 (void) ioctl(0, TIOCGETP, &savetty);
77 (void) ioctl(0, TIOCGETC, &savetty2);
78 erasechar = savetty.sg_erase;
79 init++;
80 }
81
82 if (mode == 3) return(erasechar);
83
84 if (mode == 0) {
85 (void) ioctl(0, TIOCSETP, &savetty);
86 (void) ioctl(0, TIOCSETC, &savetty2);
87 return(erasechar);
88 }
89
90 (void) ioctl(0, TIOCGETP, &args);
91 if (mode == 1) {
92 args.sg_flags |= CBREAK;
93 args.sg_flags &= ~(ECHO|RAW);
94 }
95 if (mode == 2) {
96 args.sg_flags |= RAW;
97 args.sg_flags &= ~(ECHO|CBREAK);
98 }
99 (void) ioctl(0, TIOCSETP, &args);
100 return(erasechar);
101#endif
102
103}
104 8
105 9
@@ -122,8 +26,8 @@ void SzTransfer::sendFile(const QString& file) {
122 proc = new OProcess; 26 proc = new OProcess;
123 *proc << "sz"; 27 *proc << "sz";
124 *proc << "-v" << "-v" << "-v" << "-b" << file; 28 *proc << "-v" << "-v" << "-b" << file;
125 connect(proc, SIGNAL(processExited(OProcess *)), 29 connect(proc, SIGNAL(processExited(OProcess *)),
126 this, SLOT(sent())); 30 this, SLOT(sent()));
127 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), 31 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
128 this, SLOT(SzReceivedStdout(OProcess *, char *, int))); 32 this, SLOT(SzReceivedStdout(OProcess *, char *, int)));
129 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), 33 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
@@ -137,11 +41,15 @@ void SzTransfer::sendFile(const QString& file) {
137void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { 41void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) {
138 42
139 //qWarning("recieved from sz %d bytes", buflen); 43 qWarning("recieved from sz on stdout %d bytes", buflen);
140 44
141 QByteArray data(buflen); 45 QByteArray data(buflen);
142 data.fill(*buffer, buflen); 46 data.fill(*buffer, buflen);
47 for (uint i = 0; i < data.count(); i++ ) {
48 printf("%c", buffer[i] );
49 }
50 printf("\n");
143 51
144 // send out through the io layer 52 // send out through the io layer
145 (layer())->send(data); 53 layer()->send(data);
146} 54}
147 55
@@ -149,13 +57,14 @@ void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) {
149 57
150 // parse and show data in a progress dialog/widget 58 // parse and show data in a progress dialog/widget
151 printf("\n"); 59 printf("stderr:\n");
152 for (int i = 0; i < length; i++) 60 //for (int i = 0; i < length; i++)
153 printf("%c", buffer[i]); 61 // printf("%c", buffer[i]);
62 //printf("\n");
154} 63}
155 64
156void SzTransfer::receivedStdin(const QByteArray &data) { 65void SzTransfer::receivedStdin(const QByteArray &data) {
157 66
158 //qWarning("recieved from io_serial %d bytes", data.size()); 67 qWarning("recieved from io_serial %d bytes", data.size());
159 68
160 // recieved data from the io layer goes to sz 69 // recieved data from the io layer goes to sz
161 proc->writeStdin(data.data(), data.size()); 70 proc->writeStdin(data.data(), data.size());