author | zecke <zecke> | 2002-10-11 22:31:15 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-11 22:31:15 (UTC) |
commit | c8c961b4106f49f544195733cef17af5f15f6bb8 (patch) (unidiff) | |
tree | 3db3cad73021d14c417de2166249ec9e7a5f1aa4 | |
parent | 597cda9456f8ef883d486b6ed7d7c09339919da9 (diff) | |
download | opie-c8c961b4106f49f544195733cef17af5f15f6bb8.zip opie-c8c961b4106f49f544195733cef17af5f15f6bb8.tar.gz opie-c8c961b4106f49f544195733cef17af5f15f6bb8.tar.bz2 |
suspending connections in rawMode... closeRawIO afterwards please
Progress for FileTransfer
FileTransferLayer updates. ErrorCodes + Better methods cancel and better progress
default switch to FileTransfer
TabWidget is a OTabWidget again
-rw-r--r-- | noncore/apps/opie-console/default.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/file_layer.h | 21 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 143 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.h | 15 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_layer.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_layer.h | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.h | 4 |
11 files changed, 197 insertions, 37 deletions
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index a6c3bc4..b092273 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp | |||
@@ -1,32 +1,32 @@ | |||
1 | #include "io_serial.h" | 1 | #include "io_serial.h" |
2 | #include "sz_transfer.h" | 2 | #include "filetransfer.h" |
3 | #include "serialconfigwidget.h" | 3 | #include "serialconfigwidget.h" |
4 | #include "irdaconfigwidget.h" | 4 | #include "irdaconfigwidget.h" |
5 | #include "btconfigwidget.h" | 5 | #include "btconfigwidget.h" |
6 | #include "terminalwidget.h" | 6 | #include "terminalwidget.h" |
7 | #include "vt102emulation.h" | 7 | #include "vt102emulation.h" |
8 | 8 | ||
9 | #include "default.h" | 9 | #include "default.h" |
10 | 10 | ||
11 | extern "C" { | 11 | extern "C" { |
12 | // FILE Transfer Stuff | 12 | // FILE Transfer Stuff |
13 | FileTransferLayer* newSZTransfer(IOLayer* lay) { | 13 | FileTransferLayer* newSZTransfer(IOLayer* lay) { |
14 | return new SzTransfer( SzTransfer::SZ, lay ); | 14 | return new FileTransfer( FileTransfer::SZ, lay ); |
15 | } | 15 | } |
16 | FileTransferLayer* newSYTransfer(IOLayer* lay) { | 16 | FileTransferLayer* newSYTransfer(IOLayer* lay) { |
17 | return new SzTransfer( SzTransfer::SY, lay ); | 17 | return new FileTransfer( FileTransfer::SY, lay ); |
18 | } | 18 | } |
19 | FileTransferLayer* newSXTransfer(IOLayer* lay) { | 19 | FileTransferLayer* newSXTransfer(IOLayer* lay) { |
20 | return new SzTransfer( SzTransfer::SX, lay ); | 20 | return new FileTransfer(FileTransfer ::SX, lay ); |
21 | } | 21 | } |
22 | 22 | ||
23 | // Layer stuff | 23 | // Layer stuff |
24 | IOLayer* newSerialLayer( const Profile& prof) { | 24 | IOLayer* newSerialLayer( const Profile& prof) { |
25 | return new IOSerial( prof ); | 25 | return new IOSerial( prof ); |
26 | } | 26 | } |
27 | IOLayer* newBTLayer( const Profile& ) { | 27 | IOLayer* newBTLayer( const Profile& ) { |
28 | return 0l; | 28 | return 0l; |
29 | } | 29 | } |
30 | IOLayer* newIrDaLayer( const Profile& ) { | 30 | IOLayer* newIrDaLayer( const Profile& ) { |
31 | return 0l; | 31 | return 0l; |
32 | } | 32 | } |
diff --git a/noncore/apps/opie-console/file_layer.h b/noncore/apps/opie-console/file_layer.h index 0bd0fd1..bf31540 100644 --- a/noncore/apps/opie-console/file_layer.h +++ b/noncore/apps/opie-console/file_layer.h | |||
@@ -1,54 +1,69 @@ | |||
1 | #ifndef OPIE_FILE_LAYER_H | 1 | #ifndef OPIE_FILE_LAYER_H |
2 | #define OPIE_FILE_LAYER_H | 2 | #define OPIE_FILE_LAYER_H |
3 | 3 | ||
4 | #include <qmap.h> | ||
5 | |||
4 | #include "io_layer.h" | 6 | #include "io_layer.h" |
5 | 7 | ||
6 | class QFile; | 8 | class QFile; |
7 | /** | 9 | /** |
8 | * this is the layer for sending files | 10 | * this is the layer for sending files |
9 | */ | 11 | */ |
10 | class FileTransferLayer : public QObject { | 12 | class FileTransferLayer : public QObject { |
11 | |||
12 | Q_OBJECT | 13 | Q_OBJECT |
13 | 14 | ||
14 | public: | 15 | public: |
16 | enum Errors{ | ||
17 | NotSupported, | ||
18 | StartError, | ||
19 | NoError, | ||
20 | Unknown, | ||
21 | Undefined, | ||
22 | Incomplete | ||
23 | }; | ||
15 | /** | 24 | /** |
16 | *the io layer to be used | 25 | *the io layer to be used |
17 | */ | 26 | */ |
18 | FileTransferLayer( IOLayer* ); | 27 | FileTransferLayer( IOLayer* ); |
19 | virtual ~FileTransferLayer(); | 28 | virtual ~FileTransferLayer(); |
20 | 29 | ||
21 | public slots: | 30 | public slots: |
22 | /** | 31 | /** |
23 | * send a file over the layer | 32 | * send a file over the layer |
24 | */ | 33 | */ |
25 | virtual void sendFile( const QString& file ) = 0; | 34 | virtual void sendFile( const QString& file ) = 0; |
26 | virtual void sendFile( const QFile& ) = 0; | 35 | virtual void sendFile( const QFile& ) = 0; |
36 | virtual void cancel() = 0; | ||
27 | 37 | ||
28 | signals: | 38 | signals: |
29 | /** | 39 | /** |
30 | * sent the file | 40 | * sent the file |
31 | */ | 41 | */ |
32 | void sent(); | 42 | void sent(); |
33 | 43 | ||
34 | /** | 44 | /** |
35 | * an error occured | 45 | * an error occured |
36 | */ | 46 | */ |
37 | 47 | ||
38 | void error( int, const QString& ); | 48 | void error( int, const QString& ); |
39 | 49 | ||
40 | /* | 50 | /* |
41 | * 100 == done | 51 | * @param file The file to send |
52 | * @param progress the progress made from 0-100 | ||
53 | * @param speed Speed in bps | ||
54 | * @param hours The hours it take to finish | ||
55 | * @param minutes The minutes it takes to finish | ||
56 | * @param send The seconds... | ||
42 | * | 57 | * |
43 | */ | 58 | */ |
44 | void progress( const QString& file, int progress ); | 59 | void progress( const QString& file, int progress, int speed, int hours, int minutes, int seconds ); |
45 | 60 | ||
46 | protected: | 61 | protected: |
47 | IOLayer* layer(); | 62 | IOLayer* layer(); |
48 | 63 | ||
49 | private: | 64 | private: |
50 | IOLayer* m_layer; | 65 | IOLayer* m_layer; |
51 | 66 | ||
52 | }; | 67 | }; |
53 | 68 | ||
54 | #endif | 69 | #endif |
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index 78982bd..7b75d35 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp | |||
@@ -2,127 +2,148 @@ | |||
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 "filetransfer.h" | 12 | #include "filetransfer.h" |
13 | 13 | ||
14 | /** | ||
15 | * | ||
16 | * | ||
17 | class FileTransferControl { | ||
18 | public: | ||
19 | FileTransferControl(); | ||
20 | ~FileTransferControl(); | ||
21 | |||
22 | |||
23 | }; | ||
24 | */ | ||
25 | |||
14 | bool FileTransfer::terminate = false; | 26 | bool FileTransfer::terminate = false; |
15 | pid_t FileTransfer::m_pid; | 27 | pid_t FileTransfer::m_pid; |
16 | 28 | ||
17 | FileTransfer::FileTransfer( Type t, IOLayer* lay ) | 29 | FileTransfer::FileTransfer( Type t, IOLayer* lay ) |
18 | : FileTransferLayer( lay ), m_type( t ) { | 30 | : FileTransferLayer( lay ), m_type( t ) { |
31 | signal(SIGPIPE, SIG_IGN ); | ||
19 | signal( SIGCHLD, signal_handler ); | 32 | signal( SIGCHLD, signal_handler ); |
33 | m_not = 0l; | ||
20 | } | 34 | } |
21 | FileTransfer::~FileTransfer() { | 35 | FileTransfer::~FileTransfer() { |
22 | } | 36 | } |
23 | 37 | ||
24 | /** | 38 | /** |
25 | * now we will send the file. | 39 | * now we will send the file. |
26 | * | 40 | * |
27 | * we request an fd. The IOLayer should be closed | 41 | * we request an fd. The IOLayer should be closed |
28 | * then we will setup a pipe for progress communication | 42 | * then we will setup a pipe for progress communication |
29 | * then we will dup2 the m_fd in the forked process | 43 | * then we will dup2 the m_fd in the forked process |
30 | * to do direct IO from and to the fd | 44 | * to do direct IO from and to the fd |
31 | */ | 45 | */ |
32 | void FileTransfer::sendFile( const QString& file ) { | 46 | void FileTransfer::sendFile( const QString& file ) { |
47 | m_prog =-1; | ||
33 | m_fd = layer()->rawIO(); | 48 | m_fd = layer()->rawIO(); |
34 | // | 49 | // |
35 | // m_fd = ::open("/dev/ttyS0", O_RDWR); | 50 | // m_fd = ::open("/dev/ttyS0", O_RDWR); |
36 | 51 | ||
37 | 52 | m_file = file; | |
38 | if ( pipe( m_comm ) < 0 ) | 53 | if ( pipe( m_comm ) < 0 ) |
39 | m_comm[0] = m_comm[1] = 0; | 54 | m_comm[0] = m_comm[1] = 0; |
40 | if ( pipe( m_info ) < 0 ) | 55 | if ( pipe( m_info ) < 0 ) |
41 | m_info[0] = m_info[1] = 0; | 56 | m_info[0] = m_info[1] = 0; |
42 | 57 | ||
43 | qWarning("output:"+file ); | 58 | |
44 | m_pid = fork(); | 59 | m_pid = fork(); |
45 | switch( m_pid ) { | 60 | switch( m_pid ) { |
61 | case -1: | ||
62 | emit error( StartError, tr("Was not able to fork") ); | ||
63 | break; | ||
46 | case 0:{ | 64 | case 0:{ |
47 | setupChild(); | 65 | setupChild(); |
66 | qWarning("output:"+file ); | ||
48 | /* exec */ | 67 | /* exec */ |
49 | char* verbose = "-vv"; | 68 | char* verbose = "-vv"; |
50 | char* binray = "-b"; | 69 | char* binray = "-b"; |
51 | 70 | ||
52 | 71 | ||
53 | /* we should never return from here */ | 72 | /* we should never return from here */ |
54 | execlp("sz", "sz", verbose, binray, file.latin1(), NULL ); | 73 | execlp("sz", "sz", verbose, binray, file.latin1(), NULL ); |
55 | 74 | ||
56 | /* communication for error!*/ | 75 | /* communication for error!*/ |
57 | char resultByte =1; | 76 | char resultByte =1; |
58 | if (m_info[1] ) | 77 | if (m_info[1] ) |
59 | write(m_info[1], &resultByte, 1 ); | 78 | write(m_info[1], &resultByte, 1 ); |
60 | _exit( -1 ); | 79 | _exit( -1 ); |
61 | break; | 80 | break; |
62 | } | 81 | } |
63 | default:{ | 82 | default:{ |
64 | if ( m_info[1] ) | 83 | if ( m_info[1] ) |
65 | close( m_info[1] ); | 84 | close( m_info[1] ); |
66 | if ( m_info[0] ) for (;;) { | 85 | if ( m_info[0] ) for (;;) { |
67 | char resultByte; int len; | 86 | char resultByte; int len; |
68 | len = read(m_info[0], &resultByte, 1 ); | 87 | len = read(m_info[0], &resultByte, 1 ); |
69 | /* len == 1 start up failed */ | 88 | /* len == 1 start up failed */ |
70 | if ( len == 1 ) | 89 | if ( len == 1 ) { |
90 | emit error( StartError, tr("Could not start") ); | ||
71 | return; | 91 | return; |
92 | } | ||
72 | if ( len == -1 ) | 93 | if ( len == -1 ) |
73 | if ( (errno == ECHILD ) || (errno == EINTR ) ) | 94 | if ( (errno == ECHILD ) || (errno == EINTR ) ) |
74 | continue; | 95 | continue; |
75 | 96 | ||
76 | // len == 0 or something like this | 97 | // len == 0 or something like this |
77 | break; | 98 | break; |
78 | } | 99 | } |
79 | if ( m_info[0] ) | 100 | if ( m_info[0] ) |
80 | close( m_info[0] ); | 101 | close( m_info[0] ); |
81 | 102 | ||
82 | terminate = false; | 103 | terminate = false; |
83 | fd_set fds; | 104 | fd_set fds; |
84 | struct timeval timeout; | 105 | struct timeval timeout; |
85 | int sel; | 106 | int sel; |
86 | 107 | ||
87 | /* replace by QSocketNotifier!!! */ | 108 | /* replace by QSocketNotifier!!! */ |
88 | while (!terminate) { | 109 | m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); |
89 | FD_ZERO( &fds ); | 110 | connect(m_not, SIGNAL(activated(int) ), |
90 | FD_SET( m_comm[0], &fds ); | 111 | this, SLOT(slotRead() ) ); |
91 | sel = select( m_comm[0]+1, &fds, NULL, NULL, &timeout ); | ||
92 | if (sel ) { | ||
93 | if ( FD_ISSET(m_comm[0], &fds ) ) { | ||
94 | printf("out:"); | ||
95 | QByteArray ar(4096); | ||
96 | int len = read(m_comm[0], ar.data(), 4096 ); | ||
97 | for (int i = 0; i < len; i++ ) { | ||
98 | // printf("%c", ar[i] ); | ||
99 | } | ||
100 | printf("\n"); | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | break; | ||
105 | } | 112 | } |
113 | break; | ||
106 | } | 114 | } |
107 | } | 115 | } |
116 | /* | ||
117 | * let's call the one with the filename | ||
118 | */ | ||
108 | void FileTransfer::sendFile( const QFile& file ) { | 119 | void FileTransfer::sendFile( const QFile& file ) { |
109 | sendFile( file.name() ); | 120 | sendFile( file.name() ); |
110 | } | 121 | } |
122 | /* | ||
123 | * our signal handler to be replaced by | ||
124 | * a procctl thingie | ||
125 | */ | ||
111 | void FileTransfer::signal_handler(int ) { | 126 | void FileTransfer::signal_handler(int ) { |
127 | qWarning("Terminated"); | ||
112 | int status; | 128 | int status; |
113 | signal( SIGCHLD, signal_handler ); | 129 | signal( SIGCHLD, signal_handler ); |
114 | waitpid( m_pid, &status, WNOHANG ); | 130 | waitpid( m_pid, &status, WNOHANG ); |
115 | terminate = true; | 131 | terminate = true; |
116 | } | 132 | } |
133 | |||
134 | /* | ||
135 | * setting up communication | ||
136 | * between parent child and ioLayer | ||
137 | */ | ||
117 | void FileTransfer::setupChild() { | 138 | void FileTransfer::setupChild() { |
118 | /* | 139 | /* |
119 | * we do not want to read from our | 140 | * we do not want to read from our |
120 | * information channel | 141 | * information channel |
121 | */ | 142 | */ |
122 | if (m_info[0] ) | 143 | if (m_info[0] ) |
123 | close(m_info[0] ); | 144 | close(m_info[0] ); |
124 | /* | 145 | /* |
125 | * FD_CLOEXEC will close the | 146 | * FD_CLOEXEC will close the |
126 | * fd on successfull exec | 147 | * fd on successfull exec |
127 | */ | 148 | */ |
128 | if (m_info[1] ) | 149 | if (m_info[1] ) |
@@ -131,12 +152,94 @@ void FileTransfer::setupChild() { | |||
131 | if (m_comm[0] ) | 152 | if (m_comm[0] ) |
132 | close( m_comm[0] ); | 153 | close( m_comm[0] ); |
133 | /* | 154 | /* |
134 | * now set the communication | 155 | * now set the communication |
135 | * m_fd STDIN_FILENO | 156 | * m_fd STDIN_FILENO |
136 | * STDOUT_FILENO | 157 | * STDOUT_FILENO |
137 | * STDERR_FILENO | 158 | * STDERR_FILENO |
138 | */ | 159 | */ |
139 | dup2( m_fd, STDIN_FILENO ); | 160 | dup2( m_fd, STDIN_FILENO ); |
140 | dup2( m_fd, STDOUT_FILENO ); | 161 | dup2( m_fd, STDOUT_FILENO ); |
141 | dup2( m_comm[1], STDERR_FILENO ); | 162 | dup2( m_comm[1], STDERR_FILENO ); |
142 | } | 163 | } |
164 | |||
165 | /* | ||
166 | * read from the stderr of the child | ||
167 | * process | ||
168 | */ | ||
169 | void FileTransfer::slotRead() { | ||
170 | QByteArray ar(4096); | ||
171 | int len = read(m_comm[0], ar.data(), 4096 ); | ||
172 | qWarning("slot read %d", len); | ||
173 | for (int i = 0; i < len; i++ ) { | ||
174 | // printf("%c", ar[i] ); | ||
175 | } | ||
176 | ar.resize( len ); | ||
177 | QString str( ar ); | ||
178 | QStringList lis = QStringList::split(' ', str ); | ||
179 | /* | ||
180 | * Transfer finished.. either complete or incomplete | ||
181 | */ | ||
182 | if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { | ||
183 | qWarning("sent!!!!"); | ||
184 | emit sent(); | ||
185 | return; | ||
186 | } | ||
187 | /* | ||
188 | * do progress reading | ||
189 | */ | ||
190 | slotProgress( lis ); | ||
191 | |||
192 | |||
193 | } | ||
194 | /* | ||
195 | * find the progress | ||
196 | */ | ||
197 | void FileTransfer::slotProgress( const QStringList& list ) { | ||
198 | bool complete = true; | ||
199 | int min, sec; | ||
200 | int bps; | ||
201 | unsigned long sent, total; | ||
202 | |||
203 | min = sec = bps = -1; | ||
204 | sent = total = 0; | ||
205 | |||
206 | // Data looks like this | ||
207 | // 0 1 2 3 4 5 | ||
208 | // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 | ||
209 | QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); | ||
210 | sent = progi[0].toULong(&complete ); | ||
211 | if (!complete ) return; | ||
212 | |||
213 | total = progi[1].toULong(&complete ); | ||
214 | if (!complete || total == 0) { | ||
215 | qWarning("returning!!"); | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | qWarning("%s, %d, %d", progi.join("/").latin1(), sent, total ); | ||
220 | |||
221 | double pro = (double)sent/total; | ||
222 | int prog = pro * 100; | ||
223 | |||
224 | // speed | ||
225 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); | ||
226 | bps = progi[1].toInt(); | ||
227 | |||
228 | // time | ||
229 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); | ||
230 | min = progi[0].toInt(); | ||
231 | sec = progi[1].toInt(); | ||
232 | |||
233 | |||
234 | qWarning("Prog!:%d", prog ); | ||
235 | if ( prog > m_prog ) { | ||
236 | m_prog = prog; | ||
237 | emit progress(m_file, m_prog, bps, -1, min , sec ); | ||
238 | qWarning("Progress: %s, %d\%, %d, %d:%d", m_file.latin1(), m_prog, bps, min, sec ); | ||
239 | } | ||
240 | |||
241 | } | ||
242 | void FileTransfer::cancel() { | ||
243 | ::kill(m_pid,9 ); | ||
244 | delete m_not; | ||
245 | } | ||
diff --git a/noncore/apps/opie-console/filetransfer.h b/noncore/apps/opie-console/filetransfer.h index 06c6d12..0829f16 100644 --- a/noncore/apps/opie-console/filetransfer.h +++ b/noncore/apps/opie-console/filetransfer.h | |||
@@ -1,38 +1,53 @@ | |||
1 | #ifndef OPIE_FILE_TRANSFER_H | 1 | #ifndef OPIE_FILE_TRANSFER_H |
2 | #define OPIE_FILE_TRANSFER_H | 2 | #define OPIE_FILE_TRANSFER_H |
3 | 3 | ||
4 | #include <sys/types.h> | 4 | #include <sys/types.h> |
5 | 5 | ||
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qstringlist.h> | ||
7 | 8 | ||
8 | #include "file_layer.h" | 9 | #include "file_layer.h" |
9 | 10 | ||
10 | class QSocketNotifier; | 11 | class QSocketNotifier; |
11 | class OProcess; | 12 | class OProcess; |
13 | class FileTransferControl; | ||
12 | class FileTransfer : public FileTransferLayer{ | 14 | class FileTransfer : public FileTransferLayer{ |
13 | Q_OBJECT | 15 | Q_OBJECT |
16 | friend class FileTransferControl; | ||
14 | public: | 17 | public: |
15 | enum Type { | 18 | enum Type { |
16 | SZ = 0, | 19 | SZ = 0, |
17 | SX, | 20 | SX, |
18 | SY | 21 | SY |
19 | }; | 22 | }; |
20 | FileTransfer( Type t, IOLayer* ); | 23 | FileTransfer( Type t, IOLayer* ); |
21 | ~FileTransfer(); | 24 | ~FileTransfer(); |
22 | 25 | ||
23 | void sendFile( const QString& file ); | 26 | void sendFile( const QString& file ); |
24 | void sendFile( const QFile& ); | 27 | void sendFile( const QFile& ); |
28 | void cancel(); | ||
25 | 29 | ||
26 | private slots: | 30 | private slots: |
27 | void setupChild(); | 31 | void setupChild(); |
32 | void slotRead(); | ||
33 | void slotProgress( const QStringList& ); | ||
28 | private: | 34 | private: |
35 | /* | ||
36 | * FIXME? What does happen if we've | ||
37 | * two FileTransfers at a time? | ||
38 | * Have a procctl which does listen | ||
39 | * for termination and then send a signal | ||
40 | */ | ||
29 | static pid_t m_pid; | 41 | static pid_t m_pid; |
30 | int m_fd; | 42 | int m_fd; |
43 | int m_prog; | ||
31 | int m_info[2]; | 44 | int m_info[2]; |
32 | int m_comm[2]; | 45 | int m_comm[2]; |
46 | QString m_file; | ||
33 | Type m_type; | 47 | Type m_type; |
48 | QSocketNotifier *m_not; | ||
34 | static void signal_handler(int); | 49 | static void signal_handler(int); |
35 | static bool terminate; | 50 | static bool terminate; |
36 | }; | 51 | }; |
37 | 52 | ||
38 | #endif | 53 | #endif |
diff --git a/noncore/apps/opie-console/io_layer.cpp b/noncore/apps/opie-console/io_layer.cpp index 79d47f5..9ba2f70 100644 --- a/noncore/apps/opie-console/io_layer.cpp +++ b/noncore/apps/opie-console/io_layer.cpp | |||
@@ -6,12 +6,15 @@ IOLayer::IOLayer() | |||
6 | } | 6 | } |
7 | 7 | ||
8 | IOLayer::IOLayer(const Profile &) | 8 | IOLayer::IOLayer(const Profile &) |
9 | : QObject() | 9 | : QObject() |
10 | { | 10 | { |
11 | } | 11 | } |
12 | 12 | ||
13 | IOLayer::~IOLayer() { | 13 | IOLayer::~IOLayer() { |
14 | } | 14 | } |
15 | int IOLayer::rawIO()const{ | 15 | int IOLayer::rawIO()const{ |
16 | return -1; | 16 | return -1; |
17 | } | 17 | } |
18 | void IOLayer::closeRawIO(int) { | ||
19 | |||
20 | } | ||
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h index 7745021..bf5a893 100644 --- a/noncore/apps/opie-console/io_layer.h +++ b/noncore/apps/opie-console/io_layer.h | |||
@@ -45,26 +45,34 @@ public: | |||
45 | */ | 45 | */ |
46 | virtual QString identifier() const = 0; | 46 | virtual QString identifier() const = 0; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * a short name | 49 | * a short name |
50 | */ | 50 | */ |
51 | virtual QString name() const = 0; | 51 | virtual QString name() const = 0; |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * a file descriptor which opens | 54 | * a file descriptor which opens |
55 | * the device for io but does not | 55 | * the device for io but does not |
56 | * do any ioctling on it... | 56 | * do any ioctling on it... |
57 | * and it'll stop listening to the before opened | ||
58 | * device | ||
57 | */ | 59 | */ |
58 | virtual int rawIO()const; | 60 | virtual int rawIO()const; |
61 | |||
62 | /** | ||
63 | * will close the rawIO stuff | ||
64 | * and will listen to it's data again... | ||
65 | */ | ||
66 | virtual void closeRawIO(int); | ||
59 | signals: | 67 | signals: |
60 | /** | 68 | /** |
61 | * received input as QCString | 69 | * received input as QCString |
62 | */ | 70 | */ |
63 | virtual void received( const QByteArray& ) = 0; | 71 | virtual void received( const QByteArray& ) = 0; |
64 | 72 | ||
65 | /** | 73 | /** |
66 | * an error occured | 74 | * an error occured |
67 | * int for the error number | 75 | * int for the error number |
68 | * and QString for a text | 76 | * and QString for a text |
69 | */ | 77 | */ |
70 | virtual void error( int, const QString& ) = 0; | 78 | virtual void error( int, const QString& ) = 0; |
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index 845f4be..4129d64 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -18,24 +18,25 @@ IOSerial::~IOSerial() { | |||
18 | } | 18 | } |
19 | } | 19 | } |
20 | 20 | ||
21 | void IOSerial::send(const QByteArray &data) { | 21 | void IOSerial::send(const QByteArray &data) { |
22 | if (m_fd) { | 22 | if (m_fd) { |
23 | write(m_fd, data.data(), data.size()); | 23 | write(m_fd, data.data(), data.size()); |
24 | } else { | 24 | } else { |
25 | emit error(Refuse, tr("Not connected")); | 25 | emit error(Refuse, tr("Not connected")); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | void IOSerial::close() { | 29 | void IOSerial::close() { |
30 | qWarning("closing!"); | ||
30 | if (m_fd) { | 31 | if (m_fd) { |
31 | delete m_read; | 32 | delete m_read; |
32 | delete m_error; | 33 | delete m_error; |
33 | ::close(m_fd); | 34 | ::close(m_fd); |
34 | m_fd = 0; | 35 | m_fd = 0; |
35 | } else { | 36 | } else { |
36 | emit error(Refuse, tr("Not connected")); | 37 | emit error(Refuse, tr("Not connected")); |
37 | } | 38 | } |
38 | } | 39 | } |
39 | 40 | ||
40 | bool IOSerial::open() { | 41 | bool IOSerial::open() { |
41 | qWarning("open"); | 42 | qWarning("open"); |
@@ -108,25 +109,25 @@ bool IOSerial::open() { | |||
108 | tty.c_cflag |= (PARENB | PARODD); | 109 | tty.c_cflag |= (PARENB | PARODD); |
109 | 110 | ||
110 | /* Set the changes */ | 111 | /* Set the changes */ |
111 | tcsetattr(m_fd, TCSANOW, &tty); | 112 | tcsetattr(m_fd, TCSANOW, &tty); |
112 | 113 | ||
113 | /* Notifications on read & errors */ | 114 | /* Notifications on read & errors */ |
114 | m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); | 115 | m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); |
115 | m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); | 116 | m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); |
116 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | 117 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); |
117 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | 118 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); |
118 | return TRUE; | 119 | return TRUE; |
119 | } else { | 120 | } else { |
120 | qWarning("opened"); | 121 | qWarning(" already opened"); |
121 | emit error(Refuse, tr("Device is already connected")); | 122 | emit error(Refuse, tr("Device is already connected")); |
122 | m_fd = 0; | 123 | m_fd = 0; |
123 | return FALSE; | 124 | return FALSE; |
124 | } | 125 | } |
125 | } | 126 | } |
126 | 127 | ||
127 | void IOSerial::reload(const Profile &config) { | 128 | void IOSerial::reload(const Profile &config) { |
128 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); | 129 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); |
129 | qWarning( "Dev" +m_device ); | 130 | qWarning( "Dev" +m_device ); |
130 | qWarning( "Conf:" +config.readEntry("Device") ); | 131 | qWarning( "Conf:" +config.readEntry("Device") ); |
131 | m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); | 132 | m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); |
132 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); | 133 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); |
@@ -167,16 +168,29 @@ void IOSerial::dataArrived() { | |||
167 | array.resize( len ); | 168 | array.resize( len ); |
168 | emit received(array); | 169 | emit received(array); |
169 | } | 170 | } |
170 | 171 | ||
171 | QString IOSerial::identifier() const { | 172 | QString IOSerial::identifier() const { |
172 | return "serial"; | 173 | return "serial"; |
173 | } | 174 | } |
174 | 175 | ||
175 | QString IOSerial::name() const { | 176 | QString IOSerial::name() const { |
176 | return "RS232 Serial IO Layer"; | 177 | return "RS232 Serial IO Layer"; |
177 | } | 178 | } |
178 | int IOSerial::rawIO()const { | 179 | int IOSerial::rawIO()const { |
180 | if (m_read ) | ||
181 | disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | ||
182 | if (m_error ) | ||
183 | disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | ||
184 | |||
179 | int fd = ::open(m_device, O_RDWR ); | 185 | int fd = ::open(m_device, O_RDWR ); |
180 | 186 | ||
181 | return fd; | 187 | return fd; |
182 | }; | 188 | }; |
189 | void IOSerial::closeRawIO(int fd) { | ||
190 | if (m_read ) | ||
191 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | ||
192 | if (m_error ) | ||
193 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | ||
194 | |||
195 | ::close( fd ); | ||
196 | } | ||
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h index 00a6d2c..facbbc1 100644 --- a/noncore/apps/opie-console/io_serial.h +++ b/noncore/apps/opie-console/io_serial.h | |||
@@ -27,24 +27,25 @@ public: | |||
27 | 27 | ||
28 | enum Flow { | 28 | enum Flow { |
29 | FlowHW = 0x01, | 29 | FlowHW = 0x01, |
30 | FlowSW = 0x02 | 30 | FlowSW = 0x02 |
31 | }; | 31 | }; |
32 | 32 | ||
33 | IOSerial(const Profile &); | 33 | IOSerial(const Profile &); |
34 | ~IOSerial(); | 34 | ~IOSerial(); |
35 | 35 | ||
36 | QString identifier() const; | 36 | QString identifier() const; |
37 | QString name() const; | 37 | QString name() const; |
38 | int rawIO()const; | 38 | int rawIO()const; |
39 | void closeRawIO(int fd ); | ||
39 | signals: | 40 | signals: |
40 | void received(const QByteArray &); | 41 | void received(const QByteArray &); |
41 | void error(int, const QString &); | 42 | void error(int, const QString &); |
42 | public slots: | 43 | public slots: |
43 | void send(const QByteArray &); | 44 | void send(const QByteArray &); |
44 | bool open(); | 45 | bool open(); |
45 | void close(); | 46 | void close(); |
46 | void reload(const Profile &); | 47 | void reload(const Profile &); |
47 | protected: | 48 | protected: |
48 | int baud(int baud) const; | 49 | int baud(int baud) const; |
49 | protected slots: | 50 | protected slots: |
50 | void dataArrived(); | 51 | void dataArrived(); |
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 996eb84..37cef92 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -1,18 +1,18 @@ | |||
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 \ | 5 | HEADERS = io_layer.h io_serial.h io_irda.h \ |
6 | file_layer.h sz_transfer.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 \ |
@@ -22,25 +22,25 @@ HEADERS = io_layer.h io_serial.h io_irda.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 btconfigwidget.h \ | 29 | serialconfigwidget.h irdaconfigwidget.h btconfigwidget.h \ |
30 | emulation_widget.h | 30 | emulation_widget.h |
31 | 31 | ||
32 | 32 | ||
33 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp \ | 33 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp \ |
34 | file_layer.cpp sz_transfer.cpp \ | 34 | file_layer.cpp filetransfer.cpp \ |
35 | main.cpp \ | 35 | main.cpp \ |
36 | metafactory.cpp \ | 36 | metafactory.cpp \ |
37 | session.cpp \ | 37 | session.cpp \ |
38 | mainwindow.cpp \ | 38 | mainwindow.cpp \ |
39 | profile.cpp \ | 39 | profile.cpp \ |
40 | profileconfig.cpp \ | 40 | profileconfig.cpp \ |
41 | profilemanager.cpp \ | 41 | profilemanager.cpp \ |
42 | tabwidget.cpp \ | 42 | tabwidget.cpp \ |
43 | configdialog.cpp \ | 43 | configdialog.cpp \ |
44 | emulation_layer.cpp \ | 44 | emulation_layer.cpp \ |
45 | vt102emulation.cpp \ | 45 | vt102emulation.cpp \ |
46 | history.cpp \ | 46 | history.cpp \ |
@@ -50,15 +50,15 @@ SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp \ | |||
50 | transferdialog.cpp \ | 50 | transferdialog.cpp \ |
51 | profiledialogwidget.cpp \ | 51 | profiledialogwidget.cpp \ |
52 | profileeditordialog.cpp \ | 52 | profileeditordialog.cpp \ |
53 | default.cpp \ | 53 | default.cpp \ |
54 | terminalwidget.cpp \ | 54 | terminalwidget.cpp \ |
55 | iolayerbase.cpp \ | 55 | iolayerbase.cpp \ |
56 | serialconfigwidget.cpp irdaconfigwidget.cpp btconfigwidget.cpp \ | 56 | serialconfigwidget.cpp irdaconfigwidget.cpp btconfigwidget.cpp \ |
57 | emulation_widget.cpp | 57 | emulation_widget.cpp |
58 | 58 | ||
59 | INTERFACES = configurebase.ui editbase.ui | 59 | INTERFACES = configurebase.ui editbase.ui |
60 | INCLUDEPATH += $(OPIEDIR)/include | 60 | INCLUDEPATH += $(OPIEDIR)/include |
61 | DEPENDPATH += $(OPIEDIR)/include | 61 | DEPENDPATH += $(OPIEDIR)/include |
62 | LIBS += -lqpe -lopie | 62 | LIBS += -lqpe -lopie |
63 | TARGET = opie-console | 63 | TARGET = opie-console |
64 | 64 | ||
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp index cfaef91..466b536 100644 --- a/noncore/apps/opie-console/tabwidget.cpp +++ b/noncore/apps/opie-console/tabwidget.cpp | |||
@@ -1,43 +1,44 @@ | |||
1 | 1 | ||
2 | #include "tabwidget.h" | 2 | #include "tabwidget.h" |
3 | 3 | ||
4 | TabWidget::TabWidget( QWidget* parent, const char* name ) | 4 | TabWidget::TabWidget( QWidget* parent, const char* name ) |
5 | : QTabWidget( parent, name ) { | 5 | : OTabWidget( parent, name ) { |
6 | connect(this, SIGNAL( currentChanged(QWidget*) ), | 6 | connect(this, SIGNAL( currentChanged(QWidget*) ), |
7 | this, SLOT( slotCurChanged(QWidget*) ) ); | 7 | this, SLOT( slotCurChanged(QWidget*) ) ); |
8 | } | 8 | } |
9 | 9 | ||
10 | TabWidget::~TabWidget() { | 10 | TabWidget::~TabWidget() { |
11 | } | 11 | } |
12 | 12 | ||
13 | void TabWidget::add( Session* ses ) { | 13 | void TabWidget::add( Session* ses ) { |
14 | if ( !ses->widgetStack() ) return; | 14 | if ( !ses->widgetStack() ) return; |
15 | qWarning("going to add it"); | 15 | qWarning("going to add it"); |
16 | //reparent( ses->widgetStack(), QPoint() ); | 16 | //reparent( ses->widgetStack(), QPoint() ); |
17 | //addTab( ses->widgetStack(), "console/konsole", ses->name() ); | 17 | addTab( ses->widgetStack(), "console/konsole", ses->name() ); |
18 | addTab( ses->widgetStack(), ses->name() ); | 18 | //addTab( ses->widgetStack(), ses->name() ); |
19 | m_map.insert( ses->widgetStack(), ses ); | 19 | m_map.insert( ses->widgetStack(), ses ); |
20 | } | 20 | } |
21 | 21 | ||
22 | void TabWidget::remove( Session* ses ) { | 22 | void TabWidget::remove( Session* ses ) { |
23 | m_map.remove( ses->widgetStack() ); | 23 | m_map.remove( ses->widgetStack() ); |
24 | removePage( ses->widgetStack() ); | 24 | removePage( ses->widgetStack() ); |
25 | } | 25 | } |
26 | 26 | ||
27 | void TabWidget::slotCurChanged( QWidget* wid ) { | 27 | void TabWidget::slotCurChanged( QWidget* wid ) { |
28 | QMap<QWidget*, Session*>::Iterator it; | 28 | QMap<QWidget*, Session*>::Iterator it; |
29 | it = m_map.find( wid ); | 29 | it = m_map.find( wid ); |
30 | if ( it == m_map.end() ) { | 30 | if ( it == m_map.end() ) { |
31 | return; | 31 | return; |
32 | } | 32 | } |
33 | 33 | ||
34 | emit activated( it.data() ); | 34 | emit activated( it.data() ); |
35 | } | 35 | } |
36 | void TabWidget::setCurrent( Session* ses ) { | 36 | void TabWidget::setCurrent( Session* ses ) { |
37 | if (!ses ) | 37 | if (!ses ) |
38 | return; | 38 | return; |
39 | 39 | ||
40 | showPage( ses->widgetStack() ); | 40 | //showPage( ses->widgetStack() ); |
41 | setCurrentTab( ses->widgetStack() ); | ||
41 | } | 42 | } |
42 | 43 | ||
43 | 44 | ||
diff --git a/noncore/apps/opie-console/tabwidget.h b/noncore/apps/opie-console/tabwidget.h index 42a00ec..cbaa0f1 100644 --- a/noncore/apps/opie-console/tabwidget.h +++ b/noncore/apps/opie-console/tabwidget.h | |||
@@ -1,24 +1,24 @@ | |||
1 | #ifndef OPIE_TAB_WIDGET_H | 1 | #ifndef OPIE_TAB_WIDGET_H |
2 | #define OPIE_TAB_WIDGET_H | 2 | #define OPIE_TAB_WIDGET_H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | #include <qtabwidget.h> | 5 | #include <opie/otabwidget.h> |
6 | 6 | ||
7 | #include "session.h" | 7 | #include "session.h" |
8 | /** | 8 | /** |
9 | * This is our central tab widget | 9 | * This is our central tab widget |
10 | * we can add sessions here | 10 | * we can add sessions here |
11 | */ | 11 | */ |
12 | class TabWidget : public QTabWidget{ | 12 | class TabWidget : public OTabWidget{ |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | public: | 14 | public: |
15 | TabWidget(QWidget *parent, const char* name ); | 15 | TabWidget(QWidget *parent, const char* name ); |
16 | ~TabWidget(); | 16 | ~TabWidget(); |
17 | void add( Session* ); | 17 | void add( Session* ); |
18 | void remove( Session* ); | 18 | void remove( Session* ); |
19 | void setCurrent( Session* ); | 19 | void setCurrent( Session* ); |
20 | 20 | ||
21 | signals: | 21 | signals: |
22 | void activated(Session* ses ); | 22 | void activated(Session* ses ); |
23 | private slots: | 23 | private slots: |
24 | void slotCurChanged( QWidget* wid ); | 24 | void slotCurChanged( QWidget* wid ); |