author | zecke <zecke> | 2002-10-13 15:31:12 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-13 15:31:12 (UTC) |
commit | 6a9726437a59cf3b18bf57d6e20fb2dfaaa2fc34 (patch) (unidiff) | |
tree | 14fa6710ef6d80fa213250a97f13253eb88a80cd | |
parent | 5db679753dac04095a2fa4b03297785ed4ba4030 (diff) | |
download | opie-6a9726437a59cf3b18bf57d6e20fb2dfaaa2fc34.zip opie-6a9726437a59cf3b18bf57d6e20fb2dfaaa2fc34.tar.gz opie-6a9726437a59cf3b18bf57d6e20fb2dfaaa2fc34.tar.bz2 |
Move some stuff in filetransfer around
make pid == 0 after a finished process.
Introduce the FileReceive class
it does not parse progress though
-rw-r--r-- | noncore/apps/opie-console/filereceive.cpp | 159 | ||||
-rw-r--r-- | noncore/apps/opie-console/filereceive.h | 42 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/receive_layer.cpp | 33 | ||||
-rw-r--r-- | noncore/apps/opie-console/receive_layer.h | 22 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/console.pro | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/sender.ui | 22 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/senderui.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/senderui.h | 1 |
10 files changed, 292 insertions, 15 deletions
diff --git a/noncore/apps/opie-console/filereceive.cpp b/noncore/apps/opie-console/filereceive.cpp new file mode 100644 index 0000000..26b3dec --- a/dev/null +++ b/noncore/apps/opie-console/filereceive.cpp | |||
@@ -0,0 +1,159 @@ | |||
1 | #include <unistd.h> | ||
2 | #include <fcntl.h> | ||
3 | #include <signal.h> | ||
4 | #include <errno.h> | ||
5 | |||
6 | #include <qsocketnotifier.h> | ||
7 | |||
8 | #include "io_layer.h" | ||
9 | #include "procctl.h" | ||
10 | #include "filereceive.h" | ||
11 | |||
12 | FileReceive::FileReceive( Type t, IOLayer* lay, const QString& dir ) | ||
13 | : ReceiveLayer(lay, dir ), m_type( t ) | ||
14 | { | ||
15 | m_fd = -1; | ||
16 | m_not = 0l; | ||
17 | m_proc = 0l; | ||
18 | } | ||
19 | FileReceive::~FileReceive() { | ||
20 | } | ||
21 | void FileReceive::receive() { | ||
22 | receive( currentDir() ); | ||
23 | } | ||
24 | void FileReceive::receive( const QString& dir ) { | ||
25 | m_prog = -1; | ||
26 | m_fd = layer()->rawIO(); | ||
27 | m_curDir = dir; | ||
28 | |||
29 | if (pipe( m_comm ) < 0 ) | ||
30 | m_comm[0] = m_comm[1] = 0; | ||
31 | if (pipe( m_info ) < 0 ) | ||
32 | m_info[0] = m_info[1] = 0; | ||
33 | |||
34 | m_pid = fork(); | ||
35 | switch( m_pid ) { | ||
36 | case -1: | ||
37 | //emit error | ||
38 | slotExec(); | ||
39 | break; | ||
40 | /* child */ | ||
41 | case 0: { | ||
42 | setupChild(); | ||
43 | char* typus = NULL; | ||
44 | switch(m_type ) { | ||
45 | case SZ: | ||
46 | break; | ||
47 | case SX: | ||
48 | typus = "-X"; | ||
49 | break; | ||
50 | case SY: | ||
51 | typus = "--ymodem"; | ||
52 | break; | ||
53 | } | ||
54 | |||
55 | /* we should never return from here */ | ||
56 | execlp("rz", "rz", typus, NULL ); | ||
57 | |||
58 | char resultByte = 1; | ||
59 | if (m_info[1] ) | ||
60 | ::write(m_info[1], &resultByte, 1 ); | ||
61 | |||
62 | _exit( -1 ); | ||
63 | break; | ||
64 | } | ||
65 | default: { | ||
66 | if ( m_info[1] ) | ||
67 | close( m_info[1] ); | ||
68 | |||
69 | if ( m_info[0] ) for (;;) { | ||
70 | char resultByte; int len; | ||
71 | len = read(m_info[0], &resultByte, 1 ); | ||
72 | /* len == 1 start up failed */ | ||
73 | if ( len == 1 ) { | ||
74 | emit error( StartError, tr("Could not start") ); | ||
75 | return; | ||
76 | } | ||
77 | if ( len == -1 ) | ||
78 | if ( (errno == ECHILD ) || (errno == EINTR ) ) | ||
79 | continue; | ||
80 | |||
81 | // len == 0 or something like this | ||
82 | break; | ||
83 | } | ||
84 | |||
85 | if ( m_info[0] ) | ||
86 | close( m_info[0] ); | ||
87 | |||
88 | m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); | ||
89 | connect(m_not, SIGNAL(activated(int) ), | ||
90 | this, SLOT(slotRead() ) ); | ||
91 | if ( pipe(m_term) < 0 ) | ||
92 | m_term[0] = m_term[1] = 0; | ||
93 | |||
94 | ProcCtl::self()->add(m_pid, m_term[1] ); | ||
95 | m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); | ||
96 | connect(m_proc, SIGNAL(activated(int) ), | ||
97 | this, SLOT(slotExec() ) ); | ||
98 | |||
99 | } | ||
100 | break; | ||
101 | |||
102 | } | ||
103 | |||
104 | } | ||
105 | void FileReceive::cancel() { | ||
106 | ::kill(m_pid, 9 ); | ||
107 | } | ||
108 | void FileReceive::setupChild() { | ||
109 | changeDir( currentDir() ); | ||
110 | /* | ||
111 | * we do not want to read from our | ||
112 | * information channel | ||
113 | */ | ||
114 | if (m_info[0] ) | ||
115 | close(m_info[0] ); | ||
116 | /* | ||
117 | * FD_CLOEXEC will close the | ||
118 | * fd on successfull exec | ||
119 | */ | ||
120 | if (m_info[1] ) | ||
121 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); | ||
122 | |||
123 | if (m_comm[0] ) | ||
124 | close( m_comm[0] ); | ||
125 | /* | ||
126 | * now set the communication | ||
127 | * m_fd STDIN_FILENO | ||
128 | * STDOUT_FILENO | ||
129 | * STDERR_FILENO | ||
130 | */ | ||
131 | dup2( m_fd, STDIN_FILENO ); | ||
132 | dup2( m_fd, STDOUT_FILENO ); | ||
133 | dup2( m_comm[1], STDERR_FILENO ); | ||
134 | } | ||
135 | void FileReceive::slotRead() { | ||
136 | QByteArray ar(4096); | ||
137 | int len = read(m_comm[0], ar.data(), 4096 ); | ||
138 | qWarning("slot read %d", len); | ||
139 | for (int i = 0; i < len; i++ ) { | ||
140 | // printf("%c", ar[i] ); | ||
141 | } | ||
142 | ar.resize( len ); | ||
143 | QString str( ar ); | ||
144 | qWarning(str.simplifyWhiteSpace() ); | ||
145 | } | ||
146 | void FileReceive::slotExec() { | ||
147 | char buf[2]; | ||
148 | ::read(m_term[0], buf, 1 ); | ||
149 | delete m_proc; | ||
150 | delete m_not; | ||
151 | m_not = m_proc = 0l; | ||
152 | close( m_term[0] ); | ||
153 | close( m_term[1] ); | ||
154 | close( m_comm[0] ); | ||
155 | close( m_comm[1] ); | ||
156 | layer()->closeRawIO(m_fd); | ||
157 | emit received(QString::null); | ||
158 | |||
159 | } | ||
diff --git a/noncore/apps/opie-console/filereceive.h b/noncore/apps/opie-console/filereceive.h new file mode 100644 index 0000000..a525439 --- a/dev/null +++ b/noncore/apps/opie-console/filereceive.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef OPIE_FILE_RECEIVE_H | ||
2 | #define OPIE_FILE_RECEIVE_H | ||
3 | |||
4 | /** | ||
5 | * This is the receive Implementation | ||
6 | * for X-Modem/Y-Modem/Z-Modem | ||
7 | */ | ||
8 | #include <sys/types.h> | ||
9 | |||
10 | #include "receive_layer.h" | ||
11 | |||
12 | class QSocketNotifier; | ||
13 | class FileReceive : public ReceiveLayer { | ||
14 | Q_OBJECT | ||
15 | public: | ||
16 | enum Type { | ||
17 | SZ = 0, | ||
18 | SX, | ||
19 | SY | ||
20 | }; | ||
21 | FileReceive( Type t, IOLayer* lay, const QString& startDir = QString::null ); | ||
22 | ~FileReceive(); | ||
23 | void receive(); | ||
24 | void receive( const QString& dir ); | ||
25 | void cancel(); | ||
26 | private slots: | ||
27 | void setupChild(); | ||
28 | void slotRead(); | ||
29 | void slotExec(); | ||
30 | private: | ||
31 | pid_t m_pid; | ||
32 | int m_fd; | ||
33 | int m_prog; | ||
34 | int m_info[2]; | ||
35 | int m_comm[2]; | ||
36 | int m_term[2]; | ||
37 | Type m_type; | ||
38 | QSocketNotifier* m_not; | ||
39 | QSocketNotifier* m_proc; | ||
40 | }; | ||
41 | |||
42 | #endif | ||
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index 14787f6..8ca0df2 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp | |||
@@ -1,253 +1,256 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <fcntl.h> | 4 | #include <fcntl.h> |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | 6 | ||
7 | #include <qcstring.h> | 7 | #include <qcstring.h> |
8 | #include <qsocketnotifier.h> | 8 | #include <qsocketnotifier.h> |
9 | 9 | ||
10 | #include <opie/oprocess.h> | 10 | #include <opie/oprocess.h> |
11 | 11 | ||
12 | #include "procctl.h" | 12 | #include "procctl.h" |
13 | #include "filetransfer.h" | 13 | #include "filetransfer.h" |
14 | 14 | ||
15 | 15 | ||
16 | FileTransfer::FileTransfer( Type t, IOLayer* lay ) | 16 | FileTransfer::FileTransfer( Type t, IOLayer* lay ) |
17 | : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { | 17 | : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { |
18 | signal(SIGPIPE, SIG_IGN ); | 18 | signal(SIGPIPE, SIG_IGN ); |
19 | 19 | ||
20 | m_pid = 0; | ||
20 | m_not = 0l; | 21 | m_not = 0l; |
21 | m_proc = 0l; | 22 | m_proc = 0l; |
22 | } | 23 | } |
23 | FileTransfer::~FileTransfer() { | 24 | FileTransfer::~FileTransfer() { |
24 | } | 25 | } |
25 | 26 | ||
26 | /** | 27 | /** |
27 | * now we will send the file. | 28 | * now we will send the file. |
28 | * | 29 | * |
29 | * we request an fd. The IOLayer should be closed | 30 | * we request an fd. The IOLayer should be closed |
30 | * then we will setup a pipe for progress communication | 31 | * then we will setup a pipe for progress communication |
31 | * then we will dup2 the m_fd in the forked process | 32 | * then we will dup2 the m_fd in the forked process |
32 | * to do direct IO from and to the fd | 33 | * to do direct IO from and to the fd |
33 | */ | 34 | */ |
34 | void FileTransfer::sendFile( const QString& file ) { | 35 | void FileTransfer::sendFile( const QString& file ) { |
35 | m_prog =-1; | 36 | m_prog =-1; |
36 | m_fd = layer()->rawIO(); | 37 | m_fd = layer()->rawIO(); |
37 | // | 38 | // |
38 | // m_fd = ::open("/dev/ttyS0", O_RDWR); | 39 | // m_fd = ::open("/dev/ttyS0", O_RDWR); |
39 | 40 | ||
40 | m_file = file; | 41 | m_file = file; |
41 | if ( pipe( m_comm ) < 0 ) | 42 | if ( pipe( m_comm ) < 0 ) |
42 | m_comm[0] = m_comm[1] = 0; | 43 | m_comm[0] = m_comm[1] = 0; |
43 | if ( pipe( m_info ) < 0 ) | 44 | if ( pipe( m_info ) < 0 ) |
44 | m_info[0] = m_info[1] = 0; | 45 | m_info[0] = m_info[1] = 0; |
45 | 46 | ||
46 | 47 | ||
47 | m_pid = fork(); | 48 | m_pid = fork(); |
48 | switch( m_pid ) { | 49 | switch( m_pid ) { |
49 | case -1: | 50 | case -1: |
50 | emit error( StartError, tr("Was not able to fork") ); | 51 | emit error( StartError, tr("Was not able to fork") ); |
52 | slotExec(); | ||
51 | break; | 53 | break; |
52 | case 0:{ | 54 | case 0:{ |
53 | setupChild(); | 55 | setupChild(); |
54 | qWarning("output:"+file ); | 56 | qWarning("output:"+file ); |
55 | /* exec */ | 57 | /* exec */ |
56 | char* verbose = "-vv"; | 58 | char* verbose = "-vv"; |
57 | char* binray = "-b"; | 59 | char* binray = "-b"; |
58 | 60 | ||
59 | 61 | ||
60 | char* typus; | 62 | char* typus; |
61 | switch(m_type ) { | 63 | switch(m_type ) { |
62 | case SZ: | 64 | case SZ: |
63 | typus = ""; | 65 | typus = ""; |
64 | break; | 66 | break; |
65 | case SX: | 67 | case SX: |
66 | typus = "-X"; | 68 | typus = "-X"; |
67 | break; | 69 | break; |
68 | case SY: | 70 | case SY: |
69 | typus = "--ymodem"; | 71 | typus = "--ymodem"; |
70 | break; | 72 | break; |
71 | } | 73 | } |
72 | 74 | ||
73 | /* we should never return from here */ | 75 | /* we should never return from here */ |
74 | execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); | 76 | execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); |
75 | 77 | ||
76 | /* communication for error!*/ | 78 | /* communication for error!*/ |
77 | char resultByte =1; | 79 | char resultByte =1; |
78 | if (m_info[1] ) | 80 | if (m_info[1] ) |
79 | write(m_info[1], &resultByte, 1 ); | 81 | write(m_info[1], &resultByte, 1 ); |
80 | _exit( -1 ); | 82 | _exit( -1 ); |
81 | break; | 83 | break; |
82 | } | 84 | } |
83 | default:{ | 85 | default:{ |
84 | if ( m_info[1] ) | 86 | if ( m_info[1] ) |
85 | close( m_info[1] ); | 87 | close( m_info[1] ); |
86 | if ( m_info[0] ) for (;;) { | 88 | if ( m_info[0] ) for (;;) { |
87 | char resultByte; int len; | 89 | char resultByte; int len; |
88 | len = read(m_info[0], &resultByte, 1 ); | 90 | len = read(m_info[0], &resultByte, 1 ); |
89 | /* len == 1 start up failed */ | 91 | /* len == 1 start up failed */ |
90 | if ( len == 1 ) { | 92 | if ( len == 1 ) { |
91 | emit error( StartError, tr("Could not start") ); | 93 | emit error( StartError, tr("Could not start") ); |
92 | return; | 94 | return; |
93 | } | 95 | } |
94 | if ( len == -1 ) | 96 | if ( len == -1 ) |
95 | if ( (errno == ECHILD ) || (errno == EINTR ) ) | 97 | if ( (errno == ECHILD ) || (errno == EINTR ) ) |
96 | continue; | 98 | continue; |
97 | 99 | ||
98 | // len == 0 or something like this | 100 | // len == 0 or something like this |
99 | break; | 101 | break; |
100 | } | 102 | } |
101 | if ( m_info[0] ) | 103 | if ( m_info[0] ) |
102 | close( m_info[0] ); | 104 | close( m_info[0] ); |
103 | 105 | ||
104 | 106 | ||
105 | 107 | ||
106 | /* replace by QSocketNotifier!!! */ | 108 | /* replace by QSocketNotifier!!! */ |
107 | m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); | 109 | m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); |
108 | connect(m_not, SIGNAL(activated(int) ), | 110 | connect(m_not, SIGNAL(activated(int) ), |
109 | this, SLOT(slotRead() ) ); | 111 | this, SLOT(slotRead() ) ); |
110 | if ( pipe(m_term) < 0 ) | 112 | if ( pipe(m_term) < 0 ) |
111 | m_term[0] = m_term[1] = 0; | 113 | m_term[0] = m_term[1] = 0; |
112 | 114 | ||
113 | ProcCtl::self()->add(m_pid, m_term[1] ); | 115 | ProcCtl::self()->add(m_pid, m_term[1] ); |
114 | m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); | 116 | m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); |
115 | connect(m_proc, SIGNAL(activated(int) ), | 117 | connect(m_proc, SIGNAL(activated(int) ), |
116 | this, SLOT(slotExec() ) ); | 118 | this, SLOT(slotExec() ) ); |
117 | 119 | ||
118 | } | 120 | } |
119 | break; | 121 | break; |
120 | } | 122 | } |
121 | } | 123 | } |
122 | /* | 124 | /* |
123 | * let's call the one with the filename | 125 | * let's call the one with the filename |
124 | */ | 126 | */ |
125 | void FileTransfer::sendFile( const QFile& file ) { | 127 | void FileTransfer::sendFile( const QFile& file ) { |
126 | sendFile( file.name() ); | 128 | sendFile( file.name() ); |
127 | } | 129 | } |
128 | 130 | ||
129 | /* | 131 | /* |
130 | * setting up communication | 132 | * setting up communication |
131 | * between parent child and ioLayer | 133 | * between parent child and ioLayer |
132 | */ | 134 | */ |
133 | void FileTransfer::setupChild() { | 135 | void FileTransfer::setupChild() { |
134 | /* | 136 | /* |
135 | * we do not want to read from our | 137 | * we do not want to read from our |
136 | * information channel | 138 | * information channel |
137 | */ | 139 | */ |
138 | if (m_info[0] ) | 140 | if (m_info[0] ) |
139 | close(m_info[0] ); | 141 | close(m_info[0] ); |
140 | /* | 142 | /* |
141 | * FD_CLOEXEC will close the | 143 | * FD_CLOEXEC will close the |
142 | * fd on successfull exec | 144 | * fd on successfull exec |
143 | */ | 145 | */ |
144 | if (m_info[1] ) | 146 | if (m_info[1] ) |
145 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); | 147 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); |
146 | 148 | ||
147 | if (m_comm[0] ) | 149 | if (m_comm[0] ) |
148 | close( m_comm[0] ); | 150 | close( m_comm[0] ); |
149 | /* | 151 | /* |
150 | * now set the communication | 152 | * now set the communication |
151 | * m_fd STDIN_FILENO | 153 | * m_fd STDIN_FILENO |
152 | * STDOUT_FILENO | 154 | * STDOUT_FILENO |
153 | * STDERR_FILENO | 155 | * STDERR_FILENO |
154 | */ | 156 | */ |
155 | dup2( m_fd, STDIN_FILENO ); | 157 | dup2( m_fd, STDIN_FILENO ); |
156 | dup2( m_fd, STDOUT_FILENO ); | 158 | dup2( m_fd, STDOUT_FILENO ); |
157 | dup2( m_comm[1], STDERR_FILENO ); | 159 | dup2( m_comm[1], STDERR_FILENO ); |
158 | } | 160 | } |
159 | 161 | ||
160 | /* | 162 | /* |
161 | * read from the stderr of the child | 163 | * read from the stderr of the child |
162 | * process | 164 | * process |
163 | */ | 165 | */ |
164 | void FileTransfer::slotRead() { | 166 | void FileTransfer::slotRead() { |
165 | QByteArray ar(4096); | 167 | QByteArray ar(4096); |
166 | int len = read(m_comm[0], ar.data(), 4096 ); | 168 | int len = read(m_comm[0], ar.data(), 4096 ); |
167 | qWarning("slot read %d", len); | 169 | qWarning("slot read %d", len); |
168 | for (int i = 0; i < len; i++ ) { | 170 | for (int i = 0; i < len; i++ ) { |
169 | // printf("%c", ar[i] ); | 171 | // printf("%c", ar[i] ); |
170 | } | 172 | } |
171 | ar.resize( len ); | 173 | ar.resize( len ); |
172 | QString str( ar ); | 174 | QString str( ar ); |
173 | qWarning(str.simplifyWhiteSpace() ); | 175 | qWarning(str.simplifyWhiteSpace() ); |
174 | QStringList lis = QStringList::split(' ', str ); | 176 | QStringList lis = QStringList::split(' ', str ); |
175 | /* | 177 | /* |
176 | * Transfer finished.. either complete or incomplete | 178 | * Transfer finished.. either complete or incomplete |
177 | */ | 179 | */ |
178 | if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { | 180 | if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { |
179 | qWarning("sent!!!!"); | 181 | qWarning("sent!!!!"); |
180 | emit sent(); | ||
181 | return; | 182 | return; |
182 | } | 183 | } |
183 | /* | 184 | /* |
184 | * do progress reading | 185 | * do progress reading |
185 | */ | 186 | */ |
186 | slotProgress( lis ); | 187 | slotProgress( lis ); |
187 | 188 | ||
188 | 189 | ||
189 | } | 190 | } |
190 | /* | 191 | /* |
191 | * find the progress | 192 | * find the progress |
192 | */ | 193 | */ |
193 | void FileTransfer::slotProgress( const QStringList& list ) { | 194 | void FileTransfer::slotProgress( const QStringList& list ) { |
194 | if ( m_type != SZ ) | 195 | if ( m_type != SZ ) |
195 | return; | 196 | return; |
196 | bool complete = true; | 197 | bool complete = true; |
197 | int min, sec; | 198 | int min, sec; |
198 | int bps; | 199 | int bps; |
199 | unsigned long sent, total; | 200 | unsigned long sent, total; |
200 | 201 | ||
201 | min = sec = bps = -1; | 202 | min = sec = bps = -1; |
202 | sent = total = 0; | 203 | sent = total = 0; |
203 | 204 | ||
204 | // Data looks like this | 205 | // Data looks like this |
205 | // 0 1 2 3 4 5 | 206 | // 0 1 2 3 4 5 |
206 | // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 | 207 | // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 |
207 | QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); | 208 | QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); |
208 | sent = progi[0].toULong(&complete ); | 209 | sent = progi[0].toULong(&complete ); |
209 | if (!complete ) return; | 210 | if (!complete ) return; |
210 | 211 | ||
211 | total = progi[1].toULong(&complete ); | 212 | total = progi[1].toULong(&complete ); |
212 | if (!complete || total == 0) { | 213 | if (!complete || total == 0) { |
213 | return; | 214 | return; |
214 | } | 215 | } |
215 | 216 | ||
216 | qWarning("%s, %d, %d", progi.join("/").latin1(), sent, total ); | 217 | qWarning("%s, %d, %d", progi.join("/").latin1(), sent, total ); |
217 | 218 | ||
218 | double pro = (double)sent/total; | 219 | double pro = (double)sent/total; |
219 | int prog = pro * 100; | 220 | int prog = pro * 100; |
220 | 221 | ||
221 | // speed | 222 | // speed |
222 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); | 223 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); |
223 | bps = progi[1].toInt(); | 224 | bps = progi[1].toInt(); |
224 | 225 | ||
225 | // time | 226 | // time |
226 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); | 227 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); |
227 | min = progi[0].toInt(); | 228 | min = progi[0].toInt(); |
228 | sec = progi[1].toInt(); | 229 | sec = progi[1].toInt(); |
229 | 230 | ||
230 | 231 | ||
231 | if ( prog > m_prog ) { | 232 | if ( prog > m_prog ) { |
232 | m_prog = prog; | 233 | m_prog = prog; |
233 | emit progress(m_file, m_prog, bps, -1, min , sec ); | 234 | emit progress(m_file, m_prog, bps, -1, min , sec ); |
234 | } | 235 | } |
235 | 236 | ||
236 | } | 237 | } |
237 | void FileTransfer::cancel() { | 238 | void FileTransfer::cancel() { |
238 | if(m_pid > 0) ::kill(m_pid,9 ); | 239 | if(m_pid > 0) ::kill(m_pid,9 ); |
239 | delete m_not; | 240 | |
240 | } | 241 | } |
241 | void FileTransfer::slotExec() { | 242 | void FileTransfer::slotExec() { |
242 | qWarning("exited!"); | 243 | qWarning("exited!"); |
243 | char buf[2]; | 244 | char buf[2]; |
244 | ::read(m_term[0], buf, 1 ); | 245 | ::read(m_term[0], buf, 1 ); |
245 | delete m_proc; | 246 | delete m_proc; |
246 | delete m_not; | 247 | delete m_not; |
247 | m_proc = m_not = 0l; | 248 | m_proc = m_not = 0l; |
248 | close( m_term[0] ); | 249 | close( m_term[0] ); |
249 | close( m_term[1] ); | 250 | close( m_term[1] ); |
250 | close( m_comm[0] ); | 251 | close( m_comm[0] ); |
251 | close( m_comm[1] ); | 252 | close( m_comm[1] ); |
253 | layer()->closeRawIO( m_fd ); | ||
252 | emit sent(); | 254 | emit sent(); |
255 | m_pid = 0; | ||
253 | } | 256 | } |
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 8e39a48..0b4676b 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -1,68 +1,72 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | #CONFIG = qt warn_on release | 2 | #CONFIG = qt warn_on release |
3 | CONFIG = qt debug | 3 | CONFIG = qt debug |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h\ | 5 | HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h\ |
6 | file_layer.h filetransfer.h \ | 6 | file_layer.h filetransfer.h \ |
7 | metafactory.h \ | 7 | metafactory.h \ |
8 | session.h \ | 8 | session.h \ |
9 | mainwindow.h \ | 9 | mainwindow.h \ |
10 | profile.h \ | 10 | profile.h \ |
11 | profileconfig.h \ | 11 | profileconfig.h \ |
12 | profilemanager.h \ | 12 | profilemanager.h \ |
13 | configwidget.h \ | 13 | configwidget.h \ |
14 | tabwidget.h \ | 14 | tabwidget.h \ |
15 | configdialog.h \ | 15 | configdialog.h \ |
16 | emulation_layer.h \ | 16 | emulation_layer.h \ |
17 | vt102emulation.h \ | 17 | vt102emulation.h \ |
18 | common.h \ | 18 | common.h \ |
19 | history.h \ | 19 | history.h \ |
20 | screen.h \ | 20 | screen.h \ |
21 | keytrans.h \ | 21 | keytrans.h \ |
22 | widget_layer.h \ | 22 | widget_layer.h \ |
23 | transferdialog.h \ | 23 | transferdialog.h \ |
24 | profiledialogwidget.h \ | 24 | profiledialogwidget.h \ |
25 | profileeditordialog.h \ | 25 | profileeditordialog.h \ |
26 | default.h \ | 26 | default.h \ |
27 | terminalwidget.h \ | 27 | terminalwidget.h \ |
28 | iolayerbase.h \ | 28 | iolayerbase.h \ |
29 | serialconfigwidget.h irdaconfigwidget.h \ | 29 | serialconfigwidget.h irdaconfigwidget.h \ |
30 | btconfigwidget.h modemconfigwidget.h \ | 30 | btconfigwidget.h modemconfigwidget.h \ |
31 | atconfigdialog.h dialdialog.h \ | 31 | atconfigdialog.h dialdialog.h \ |
32 | emulation_widget.h procctl.h \ | 32 | emulation_widget.h procctl.h \ |
33 | function_keyboard.h script.h | 33 | function_keyboard.h \ |
34 | receive_layer.h filereceive.h \ | ||
35 | script.h | ||
34 | 36 | ||
35 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp \ | 37 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp \ |
36 | file_layer.cpp filetransfer.cpp \ | 38 | file_layer.cpp filetransfer.cpp \ |
37 | main.cpp \ | 39 | main.cpp \ |
38 | metafactory.cpp \ | 40 | metafactory.cpp \ |
39 | session.cpp \ | 41 | session.cpp \ |
40 | mainwindow.cpp \ | 42 | mainwindow.cpp \ |
41 | profile.cpp \ | 43 | profile.cpp \ |
42 | profileconfig.cpp \ | 44 | profileconfig.cpp \ |
43 | profilemanager.cpp \ | 45 | profilemanager.cpp \ |
44 | tabwidget.cpp \ | 46 | tabwidget.cpp \ |
45 | configdialog.cpp \ | 47 | configdialog.cpp \ |
46 | emulation_layer.cpp \ | 48 | emulation_layer.cpp \ |
47 | vt102emulation.cpp \ | 49 | vt102emulation.cpp \ |
48 | history.cpp \ | 50 | history.cpp \ |
49 | screen.cpp \ | 51 | screen.cpp \ |
50 | keytrans.cpp \ | 52 | keytrans.cpp \ |
51 | widget_layer.cpp \ | 53 | widget_layer.cpp \ |
52 | transferdialog.cpp \ | 54 | transferdialog.cpp \ |
53 | profiledialogwidget.cpp \ | 55 | profiledialogwidget.cpp \ |
54 | profileeditordialog.cpp \ | 56 | profileeditordialog.cpp \ |
55 | terminalwidget.cpp \ | 57 | terminalwidget.cpp \ |
56 | iolayerbase.cpp \ | 58 | iolayerbase.cpp \ |
57 | serialconfigwidget.cpp irdaconfigwidget.cpp \ | 59 | serialconfigwidget.cpp irdaconfigwidget.cpp \ |
58 | btconfigwidget.cpp modemconfigwidget.cpp \ | 60 | btconfigwidget.cpp modemconfigwidget.cpp \ |
59 | atconfigdialog.cpp dialdialog.cpp \ | 61 | atconfigdialog.cpp dialdialog.cpp \ |
60 | emulation_widget.cpp default.cpp procctl.cpp \ | 62 | emulation_widget.cpp default.cpp procctl.cpp \ |
61 | function_keyboard.cpp script.cpp | 63 | function_keyboard.cpp \ |
64 | receive_layer.cpp filereceive.cpp \ | ||
65 | script.cpp | ||
62 | 66 | ||
63 | INTERFACES = configurebase.ui editbase.ui | 67 | INTERFACES = configurebase.ui editbase.ui |
64 | INCLUDEPATH += $(OPIEDIR)/include | 68 | INCLUDEPATH += $(OPIEDIR)/include |
65 | DEPENDPATH += $(OPIEDIR)/include | 69 | DEPENDPATH += $(OPIEDIR)/include |
66 | LIBS += -lqpe -lopie | 70 | LIBS += -lqpe -lopie |
67 | TARGET = opie-console | 71 | TARGET = opie-console |
68 | 72 | ||
diff --git a/noncore/apps/opie-console/receive_layer.cpp b/noncore/apps/opie-console/receive_layer.cpp new file mode 100644 index 0000000..05e2c67 --- a/dev/null +++ b/noncore/apps/opie-console/receive_layer.cpp | |||
@@ -0,0 +1,33 @@ | |||
1 | #include <unistd.h> | ||
2 | |||
3 | #include <qstring.h> | ||
4 | #include <qfile.h> | ||
5 | |||
6 | #include "io_layer.h" | ||
7 | #include "receive_layer.h" | ||
8 | |||
9 | ReceiveLayer::ReceiveLayer( IOLayer* lay, const QString& startDir ) | ||
10 | : QObject(), m_curDir( startDir ), m_layer(lay ) | ||
11 | { | ||
12 | |||
13 | } | ||
14 | ReceiveLayer::~ReceiveLayer() { | ||
15 | |||
16 | } | ||
17 | IOLayer* ReceiveLayer::layer() { | ||
18 | return m_layer; | ||
19 | } | ||
20 | QString ReceiveLayer::currentDir()const{ | ||
21 | if (m_curDir.isEmpty() ) | ||
22 | return QString::fromLocal8Bit( ::getwd(NULL) ); | ||
23 | return m_curDir; | ||
24 | } | ||
25 | void ReceiveLayer::changeDir( const QString& str) { | ||
26 | ::chdir( str.latin1() ); | ||
27 | } | ||
28 | void ReceiveLayer::receive( const QString& dir, Mode, Features ) { | ||
29 | receive( dir ); | ||
30 | } | ||
31 | void ReceiveLayer::cancel() { | ||
32 | |||
33 | } | ||
diff --git a/noncore/apps/opie-console/receive_layer.h b/noncore/apps/opie-console/receive_layer.h index 0cfe16d..157c7e5 100644 --- a/noncore/apps/opie-console/receive_layer.h +++ b/noncore/apps/opie-console/receive_layer.h | |||
@@ -1,113 +1,121 @@ | |||
1 | #ifndef OPIE_RECEIVE_LAYER_H | 1 | #ifndef OPIE_RECEIVE_LAYER_H |
2 | #define OPIE_RECEIVE_LAYER_H | 2 | #define OPIE_RECEIVE_LAYER_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | 5 | ||
6 | /** | 6 | /** |
7 | * An abstract Layer for receiving files | 7 | * An abstract Layer for receiving files |
8 | * from an IOLayer connection | 8 | * from an IOLayer connection |
9 | * It gives us the possibility to listen | 9 | * It gives us the possibility to listen |
10 | * to get progress to stop listen | 10 | * to get progress to stop listen |
11 | * to get errors | 11 | * to get errors |
12 | */ | 12 | */ |
13 | class IOLayer; | 13 | class IOLayer; |
14 | class ReceiveLayer : public QObject { | 14 | class ReceiveLayer : public QObject { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | /** | 17 | /** |
18 | * How to receive files | 18 | * How to receive files |
19 | * How handhel \r\n? | 19 | * How handhel \r\n? |
20 | * ASCII or binary | 20 | * ASCII or binary |
21 | */ | 21 | */ |
22 | enum Mode { | 22 | enum Mode { |
23 | Ascii = 0l, | 23 | Ascii = 0l, |
24 | Binary | 24 | Binary |
25 | }; | 25 | }; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * What features to use | 28 | * What features to use |
29 | * DISCUSS IT!!!! | 29 | * DISCUSS IT!!!! |
30 | * see rz --help for more info | 30 | * see rz --help for more info |
31 | */ | 31 | */ |
32 | enum Features { | 32 | enum Features { |
33 | Append = 0, | 33 | Append = 0, |
34 | AllowRemoteCommands = 1, | 34 | AllowRemoteCommands = 1, |
35 | WriteToNull = 2, | 35 | WriteToNull = 2, |
36 | Escape = 4, | 36 | Escape = 4, |
37 | Rename = 8, | 37 | Rename = 8, |
38 | OpenSync = 16, | 38 | OpenSync = 16, |
39 | ProtectExisting = 32, | 39 | ProtectExisting = 32, |
40 | Resume = 64, | 40 | Resume = 64, |
41 | KeepUppercase = 128, | 41 | KeepUppercase = 128, |
42 | DisableRestrict = 256, | 42 | DisableRestrict = 256, |
43 | Restricted = 512, | 43 | Restricted = 512, |
44 | Overwrite = 1024 | 44 | Overwrite = 1024 |
45 | }; | 45 | }; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * which protocol to use? | 48 | * Error codes |
49 | */ | 49 | */ |
50 | enum Type{ | 50 | enum Error { |
51 | SZ = 0, | 51 | Unknown = 0, |
52 | SX, | 52 | StartError |
53 | SY | ||
54 | }; | 53 | }; |
55 | 54 | ||
56 | /** | 55 | /** |
57 | * C'tor constructs an new Object | 56 | * C'tor constructs an new Object |
58 | * @param lay The Layer to be used | 57 | * @param lay The Layer to be used |
59 | * @param t The Type | 58 | * @param t The Type |
60 | * @param startDir In which dir should files be received? | 59 | * @param startDir In which dir should files be received? |
61 | */ | 60 | */ |
62 | ReceiveLayer( IOLayer* lay, Type t, const QString& startDir = QString::null ); | 61 | ReceiveLayer( IOLayer* lay, const QString& startDir = QString::null ); |
63 | virtual ~ReceiveLayer(); | 62 | virtual ~ReceiveLayer(); |
64 | 63 | ||
65 | public slots: | 64 | public slots: |
66 | /** | 65 | /** |
67 | * start receiving in current dir | 66 | * start receiving in current dir |
68 | * with protocol from the c'tor | 67 | * with protocol from the c'tor |
69 | */ | 68 | */ |
70 | virtual void receive() = 0; | 69 | virtual void receive() = 0; |
71 | 70 | ||
72 | /** | 71 | /** |
73 | * start to receive in dir with type | 72 | * start to receive in dir with type |
74 | * from the c'tor | 73 | * from the c'tor |
75 | */ | 74 | */ |
76 | virtual void receive( const QString& dir ) = 0; | 75 | virtual void receive( const QString& dir ) = 0; |
77 | 76 | ||
78 | /** | 77 | /** |
79 | * advanced method with features and Mode | 78 | * advanced method with features and Mode |
80 | */ | 79 | */ |
81 | virtual void receive( const QString& dir, Mode, Features ) {} | 80 | virtual void receive( const QString& dir, Mode, Features ); |
82 | 81 | ||
83 | /** | 82 | /** |
84 | * cancel receive | 83 | * cancel receive |
85 | */ | 84 | */ |
86 | virtual void cancel(); | 85 | virtual void cancel(); |
87 | 86 | ||
88 | signals: | 87 | signals: |
89 | /** | 88 | /** |
90 | * error happend | 89 | * error happend |
91 | * error code as int | 90 | * error code as int |
92 | * and a QString for UI translated string | 91 | * and a QString for UI translated string |
93 | */ | 92 | */ |
94 | void error(int, const QString& ); | 93 | void error(int, const QString& ); |
95 | 94 | ||
96 | /** | 95 | /** |
97 | * progress | 96 | * progress |
98 | * @param file The completed path to the file which is received | 97 | * @param file The completed path to the file which is received |
99 | * @param speed the speed in bps | 98 | * @param speed the speed in bps |
100 | * @param hour The hours remaining | 99 | * @param hour The hours remaining |
101 | * @param minutes The miniutes remaining | 100 | * @param minutes The miniutes remaining |
102 | * @param seconds The seconds remaining | 101 | * @param seconds The seconds remaining |
103 | */ | 102 | */ |
104 | void progress( const QString& file, int progress, int speed, int hour, int min, int seconds ); | 103 | void progress( const QString& file, int progress, int speed, int hour, int min, int seconds ); |
105 | 104 | ||
106 | /** | 105 | /** |
107 | * completely received a file | 106 | * completely received a file |
108 | */ | 107 | */ |
109 | void received( const QString& file ); | 108 | void received( const QString& file ); |
110 | 109 | ||
110 | protected: | ||
111 | QString m_curDir; | ||
112 | IOLayer* layer(); | ||
113 | /* from a variable set from the outside */ | ||
114 | QString currentDir()const; | ||
115 | void changeDir( const QString& ); | ||
116 | private: | ||
117 | IOLayer* m_layer; | ||
118 | |||
111 | }; | 119 | }; |
112 | 120 | ||
113 | #endif | 121 | #endif |
diff --git a/noncore/apps/opie-console/test/console.pro b/noncore/apps/opie-console/test/console.pro index af0e9f7..6de2cd0 100644 --- a/noncore/apps/opie-console/test/console.pro +++ b/noncore/apps/opie-console/test/console.pro | |||
@@ -1,15 +1,17 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | #CONFIG = qt warn_on release | 2 | #CONFIG = qt warn_on release |
3 | CONFIG = qt debug | 3 | CONFIG = qt debug |
4 | #DESTDIR = $(OPIEDIR)/bin | 4 | #DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = ../io_layer.h ../io_serial.h ../sz_transfer.h ../file_layer.h\ | 5 | HEADERS = ../io_layer.h ../io_serial.h ../sz_transfer.h ../file_layer.h\ |
6 | senderui.h ../profile.h ../filetransfer.h ../procctl.h | 6 | senderui.h ../profile.h ../filetransfer.h ../procctl.h \ |
7 | ../filereceive.h ../receive_layer.h | ||
7 | SOURCES = ../io_layer.cpp ../io_serial.cpp \ | 8 | SOURCES = ../io_layer.cpp ../io_serial.cpp \ |
8 | ../profile.cpp ../sz_transfer.cpp ../file_layer.cpp\ | 9 | ../profile.cpp ../sz_transfer.cpp ../file_layer.cpp\ |
9 | main.cpp senderui.cpp ../filetransfer.cpp ../procctl.cpp | 10 | main.cpp senderui.cpp ../filetransfer.cpp ../procctl.cpp \ |
11 | ../filereceive.cpp ../receive_layer.cpp | ||
10 | INTERFACES = sender.ui | 12 | INTERFACES = sender.ui |
11 | INCLUDEPATH += $(OPIEDIR)/include | 13 | INCLUDEPATH += $(OPIEDIR)/include |
12 | DEPENDPATH += $(OPIEDIR)/include | 14 | DEPENDPATH += $(OPIEDIR)/include |
13 | LIBS += -lqpe -lopie | 15 | LIBS += -lqpe -lopie |
14 | TARGET = test | 16 | TARGET = test |
15 | 17 | ||
diff --git a/noncore/apps/opie-console/test/sender.ui b/noncore/apps/opie-console/test/sender.ui index b946b81..74b9790 100644 --- a/noncore/apps/opie-console/test/sender.ui +++ b/noncore/apps/opie-console/test/sender.ui | |||
@@ -1,78 +1,96 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>Sender</class> | 2 | <class>Sender</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>Form1</cstring> | 7 | <cstring>Form1</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>596</width> | 14 | <width>592</width> |
15 | <height>480</height> | 15 | <height>480</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Form1</string> | 20 | <string>Form1</string> |
21 | </property> | 21 | </property> |
22 | <vbox> | 22 | <vbox> |
23 | <property stdset="1"> | 23 | <property stdset="1"> |
24 | <name>margin</name> | 24 | <name>margin</name> |
25 | <number>11</number> | 25 | <number>11</number> |
26 | </property> | 26 | </property> |
27 | <property stdset="1"> | 27 | <property stdset="1"> |
28 | <name>spacing</name> | 28 | <name>spacing</name> |
29 | <number>6</number> | 29 | <number>6</number> |
30 | </property> | 30 | </property> |
31 | <widget> | 31 | <widget> |
32 | <class>QMultiLineEdit</class> | 32 | <class>QMultiLineEdit</class> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>name</name> | 34 | <name>name</name> |
35 | <cstring>MultiLineEdit1</cstring> | 35 | <cstring>MultiLineEdit1</cstring> |
36 | </property> | 36 | </property> |
37 | </widget> | 37 | </widget> |
38 | <widget> | 38 | <widget> |
39 | <class>QPushButton</class> | 39 | <class>QPushButton</class> |
40 | <property stdset="1"> | 40 | <property stdset="1"> |
41 | <name>name</name> | 41 | <name>name</name> |
42 | <cstring>PushButton3</cstring> | ||
43 | </property> | ||
44 | <property stdset="1"> | ||
45 | <name>text</name> | ||
46 | <string>Receive File</string> | ||
47 | </property> | ||
48 | </widget> | ||
49 | <widget> | ||
50 | <class>QPushButton</class> | ||
51 | <property stdset="1"> | ||
52 | <name>name</name> | ||
42 | <cstring>PushButton1</cstring> | 53 | <cstring>PushButton1</cstring> |
43 | </property> | 54 | </property> |
44 | <property stdset="1"> | 55 | <property stdset="1"> |
45 | <name>text</name> | 56 | <name>text</name> |
46 | <string>&Send</string> | 57 | <string>&Send</string> |
47 | </property> | 58 | </property> |
48 | </widget> | 59 | </widget> |
49 | <widget> | 60 | <widget> |
50 | <class>QPushButton</class> | 61 | <class>QPushButton</class> |
51 | <property stdset="1"> | 62 | <property stdset="1"> |
52 | <name>name</name> | 63 | <name>name</name> |
53 | <cstring>PushButton2</cstring> | 64 | <cstring>PushButton2</cstring> |
54 | </property> | 65 | </property> |
55 | <property stdset="1"> | 66 | <property stdset="1"> |
56 | <name>text</name> | 67 | <name>text</name> |
57 | <string>Send &File</string> | 68 | <string>Send &File</string> |
58 | </property> | 69 | </property> |
59 | </widget> | 70 | </widget> |
60 | </vbox> | 71 | </vbox> |
61 | </widget> | 72 | </widget> |
62 | <connections> | 73 | <connections> |
63 | <connection> | 74 | <connection> |
64 | <sender>PushButton1</sender> | 75 | <sender>PushButton1</sender> |
65 | <signal>clicked()</signal> | 76 | <signal>clicked()</signal> |
66 | <receiver>Form1</receiver> | 77 | <receiver>Form1</receiver> |
67 | <slot>slotSend()</slot> | 78 | <slot>slotSend()</slot> |
68 | </connection> | 79 | </connection> |
69 | <slot access="public">slotSend()</slot> | ||
70 | <connection> | 80 | <connection> |
71 | <sender>PushButton2</sender> | 81 | <sender>PushButton2</sender> |
72 | <signal>clicked()</signal> | 82 | <signal>clicked()</signal> |
73 | <receiver>Form1</receiver> | 83 | <receiver>Form1</receiver> |
74 | <slot>slotSendFile()</slot> | 84 | <slot>slotSendFile()</slot> |
75 | </connection> | 85 | </connection> |
86 | <connection> | ||
87 | <sender>PushButton3</sender> | ||
88 | <signal>clicked()</signal> | ||
89 | <receiver>Form1</receiver> | ||
90 | <slot>slotRev()</slot> | ||
91 | </connection> | ||
92 | <slot access="public">slotRev()</slot> | ||
93 | <slot access="public">slotSend()</slot> | ||
76 | <slot access="public">slotSendFile()</slot> | 94 | <slot access="public">slotSendFile()</slot> |
77 | </connections> | 95 | </connections> |
78 | </UI> | 96 | </UI> |
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp index 8bc1676..2ce3f6d 100644 --- a/noncore/apps/opie-console/test/senderui.cpp +++ b/noncore/apps/opie-console/test/senderui.cpp | |||
@@ -1,68 +1,75 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <fcntl.h> | 3 | #include <fcntl.h> |
4 | #include <sys/termios.h> | 4 | #include <sys/termios.h> |
5 | 5 | ||
6 | #include <qmultilineedit.h> | 6 | #include <qmultilineedit.h> |
7 | #include <qsocketnotifier.h> | 7 | #include <qsocketnotifier.h> |
8 | 8 | ||
9 | #include "../profile.h" | 9 | #include "../profile.h" |
10 | #include "../io_serial.h" | 10 | #include "../io_serial.h" |
11 | #include "../filetransfer.h" | 11 | #include "../filetransfer.h" |
12 | #include "../filereceive.h" | ||
12 | 13 | ||
13 | #include <opie/oprocess.h> | 14 | #include <opie/oprocess.h> |
14 | 15 | ||
15 | #include "senderui.h" | 16 | #include "senderui.h" |
16 | 17 | ||
17 | SenderUI::SenderUI() | 18 | SenderUI::SenderUI() |
18 | : Sender() { | 19 | : Sender() { |
19 | 20 | ||
20 | /* we do that manually */ | 21 | /* we do that manually */ |
21 | Profile prof; | 22 | Profile prof; |
22 | QString str = "/dev/ttyS0"; | 23 | QString str = "/dev/ttyS0"; |
23 | prof.writeEntry("Device",str ); | 24 | prof.writeEntry("Device",str ); |
24 | prof.writeEntry("Baud", 115200 ); | 25 | prof.writeEntry("Baud", 115200 ); |
25 | 26 | ||
26 | qWarning("prof " + prof.readEntry("Device") + " " + str); | 27 | qWarning("prof " + prof.readEntry("Device") + " " + str); |
27 | ser = new IOSerial(prof); | 28 | ser = new IOSerial(prof); |
28 | connect(ser, SIGNAL(received(const QByteArray& ) ), | 29 | connect(ser, SIGNAL(received(const QByteArray& ) ), |
29 | this, SLOT(got(const QByteArray&) ) ); | 30 | this, SLOT(got(const QByteArray&) ) ); |
30 | 31 | ||
31 | if ( ser->open() ) | 32 | if ( ser->open() ) |
32 | qWarning("opened!!!"); | 33 | qWarning("opened!!!"); |
33 | else | 34 | else |
34 | qWarning("could not open"); | 35 | qWarning("could not open"); |
35 | 36 | ||
36 | 37 | ||
37 | } | 38 | } |
38 | SenderUI::~SenderUI() { | 39 | SenderUI::~SenderUI() { |
39 | 40 | ||
40 | } | 41 | } |
41 | void SenderUI::slotSendFile() { | 42 | void SenderUI::slotSendFile() { |
42 | 43 | ||
43 | sz = new FileTransfer(FileTransfer::SY, ser); | 44 | sz = new FileTransfer(FileTransfer::SY, ser); |
44 | sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); | 45 | sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); |
45 | 46 | ||
46 | connect (sz, SIGNAL(sent()), | 47 | connect (sz, SIGNAL(sent()), |
47 | this, SLOT(fileTransComplete())); | 48 | this, SLOT(fileTransComplete())); |
48 | } | 49 | } |
49 | 50 | ||
50 | void SenderUI::slotSend() { | 51 | void SenderUI::slotSend() { |
51 | QCString str = MultiLineEdit1->text().utf8(); | 52 | QCString str = MultiLineEdit1->text().utf8(); |
52 | qWarning("sending: %s", str.data() ); | 53 | qWarning("sending: %s", str.data() ); |
53 | ser->send( str ); | 54 | ser->send( str ); |
54 | } | 55 | } |
55 | void SenderUI::got(const QByteArray& ar) { | 56 | void SenderUI::got(const QByteArray& ar) { |
56 | for ( uint i = 0; i < ar.count(); i++ ) { | 57 | for ( uint i = 0; i < ar.count(); i++ ) { |
57 | printf("%c", ar[i] ); | 58 | printf("%c", ar[i] ); |
58 | } | 59 | } |
59 | //printf("\n"); | 60 | //printf("\n"); |
60 | } | 61 | } |
61 | 62 | ||
62 | void SenderUI::fileTransComplete() { | 63 | void SenderUI::fileTransComplete() { |
63 | 64 | ||
64 | qWarning("file transfer complete"); | 65 | qWarning("file transfer complete"); |
65 | } | 66 | } |
66 | void SenderUI::send() { | 67 | void SenderUI::send() { |
67 | 68 | ||
68 | } | 69 | } |
70 | void SenderUI::slotRev(){ | ||
71 | qWarning("Going to receive!"); | ||
72 | FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); | ||
73 | rev->receive(); | ||
74 | |||
75 | } \ No newline at end of file | ||
diff --git a/noncore/apps/opie-console/test/senderui.h b/noncore/apps/opie-console/test/senderui.h index 5e613cd..c130dcf 100644 --- a/noncore/apps/opie-console/test/senderui.h +++ b/noncore/apps/opie-console/test/senderui.h | |||
@@ -1,33 +1,34 @@ | |||
1 | #ifndef SENDER_UI_H | 1 | #ifndef SENDER_UI_H |
2 | #define SENDER_UI_H | 2 | #define SENDER_UI_H |
3 | 3 | ||
4 | #include <qcstring.h> | 4 | #include <qcstring.h> |
5 | 5 | ||
6 | #include "sender.h" | 6 | #include "sender.h" |
7 | 7 | ||
8 | class IOSerial; | 8 | class IOSerial; |
9 | class FileTransfer; | 9 | class FileTransfer; |
10 | class QSocketNotifier; | 10 | class QSocketNotifier; |
11 | class OProcess; | 11 | class OProcess; |
12 | class SenderUI : public Sender { | 12 | class SenderUI : public Sender { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | public: | 14 | public: |
15 | SenderUI(); | 15 | SenderUI(); |
16 | ~SenderUI(); | 16 | ~SenderUI(); |
17 | 17 | ||
18 | public slots: | 18 | public slots: |
19 | void send(); | 19 | void send(); |
20 | void slotSendFile(); | 20 | void slotSendFile(); |
21 | void slotSend(); | 21 | void slotSend(); |
22 | void slotRev(); | ||
22 | void got(const QByteArray& ); | 23 | void got(const QByteArray& ); |
23 | void fileTransComplete(); | 24 | void fileTransComplete(); |
24 | private: | 25 | private: |
25 | IOSerial* ser; | 26 | IOSerial* ser; |
26 | FileTransfer* sz; | 27 | FileTransfer* sz; |
27 | int m_fd; | 28 | int m_fd; |
28 | QSocketNotifier* m_sock; | 29 | QSocketNotifier* m_sock; |
29 | OProcess* m_proc; | 30 | OProcess* m_proc; |
30 | }; | 31 | }; |
31 | 32 | ||
32 | 33 | ||
33 | #endif | 34 | #endif |