author | josef <josef> | 2002-10-13 12:11:15 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-13 12:11:15 (UTC) |
commit | 0e6d241e26211a8ffff07ba8e23f4a3cec9065be (patch) (unidiff) | |
tree | 1cecafc71b4261943250cf7f83013e749c5c3a1e | |
parent | 5f9fb52583eb399c79a108b8e79c1a558a730422 (diff) | |
download | opie-0e6d241e26211a8ffff07ba8e23f4a3cec9065be.zip opie-0e6d241e26211a8ffff07ba8e23f4a3cec9065be.tar.gz opie-0e6d241e26211a8ffff07ba8e23f4a3cec9065be.tar.bz2 |
- extend file transfer dialog so it can receive too (without filename argument)
- fix error messages so they match the error code
- don't show dialog maximized. It's still modal but we're coming near...
- reset status to "ready" after interrupting or finishing operation
- bugfix in filetransfer.cpp: don't kill process if pid is not set
=> before the fix, cancel() killed random processes!
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 99 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 14 |
4 files changed, 79 insertions, 40 deletions
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index 8e86ebb..14787f6 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp | |||
@@ -1,253 +1,253 @@ | |||
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 ) { | 17 | : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { |
18 | signal(SIGPIPE, SIG_IGN ); | 18 | signal(SIGPIPE, SIG_IGN ); |
19 | 19 | ||
20 | m_not = 0l; | 20 | m_not = 0l; |
21 | m_proc = 0l; | 21 | m_proc = 0l; |
22 | } | 22 | } |
23 | FileTransfer::~FileTransfer() { | 23 | FileTransfer::~FileTransfer() { |
24 | } | 24 | } |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * now we will send the file. | 27 | * now we will send the file. |
28 | * | 28 | * |
29 | * we request an fd. The IOLayer should be closed | 29 | * we request an fd. The IOLayer should be closed |
30 | * then we will setup a pipe for progress communication | 30 | * then we will setup a pipe for progress communication |
31 | * then we will dup2 the m_fd in the forked process | 31 | * then we will dup2 the m_fd in the forked process |
32 | * to do direct IO from and to the fd | 32 | * to do direct IO from and to the fd |
33 | */ | 33 | */ |
34 | void FileTransfer::sendFile( const QString& file ) { | 34 | void FileTransfer::sendFile( const QString& file ) { |
35 | m_prog =-1; | 35 | m_prog =-1; |
36 | m_fd = layer()->rawIO(); | 36 | m_fd = layer()->rawIO(); |
37 | // | 37 | // |
38 | // m_fd = ::open("/dev/ttyS0", O_RDWR); | 38 | // m_fd = ::open("/dev/ttyS0", O_RDWR); |
39 | 39 | ||
40 | m_file = file; | 40 | m_file = file; |
41 | if ( pipe( m_comm ) < 0 ) | 41 | if ( pipe( m_comm ) < 0 ) |
42 | m_comm[0] = m_comm[1] = 0; | 42 | m_comm[0] = m_comm[1] = 0; |
43 | if ( pipe( m_info ) < 0 ) | 43 | if ( pipe( m_info ) < 0 ) |
44 | m_info[0] = m_info[1] = 0; | 44 | m_info[0] = m_info[1] = 0; |
45 | 45 | ||
46 | 46 | ||
47 | m_pid = fork(); | 47 | m_pid = fork(); |
48 | switch( m_pid ) { | 48 | switch( m_pid ) { |
49 | case -1: | 49 | case -1: |
50 | emit error( StartError, tr("Was not able to fork") ); | 50 | emit error( StartError, tr("Was not able to fork") ); |
51 | break; | 51 | break; |
52 | case 0:{ | 52 | case 0:{ |
53 | setupChild(); | 53 | setupChild(); |
54 | qWarning("output:"+file ); | 54 | qWarning("output:"+file ); |
55 | /* exec */ | 55 | /* exec */ |
56 | char* verbose = "-vv"; | 56 | char* verbose = "-vv"; |
57 | char* binray = "-b"; | 57 | char* binray = "-b"; |
58 | 58 | ||
59 | 59 | ||
60 | char* typus; | 60 | char* typus; |
61 | switch(m_type ) { | 61 | switch(m_type ) { |
62 | case SZ: | 62 | case SZ: |
63 | typus = ""; | 63 | typus = ""; |
64 | break; | 64 | break; |
65 | case SX: | 65 | case SX: |
66 | typus = "-X"; | 66 | typus = "-X"; |
67 | break; | 67 | break; |
68 | case SY: | 68 | case SY: |
69 | typus = "--ymodem"; | 69 | typus = "--ymodem"; |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | 72 | ||
73 | /* we should never return from here */ | 73 | /* we should never return from here */ |
74 | execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); | 74 | execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); |
75 | 75 | ||
76 | /* communication for error!*/ | 76 | /* communication for error!*/ |
77 | char resultByte =1; | 77 | char resultByte =1; |
78 | if (m_info[1] ) | 78 | if (m_info[1] ) |
79 | write(m_info[1], &resultByte, 1 ); | 79 | write(m_info[1], &resultByte, 1 ); |
80 | _exit( -1 ); | 80 | _exit( -1 ); |
81 | break; | 81 | break; |
82 | } | 82 | } |
83 | default:{ | 83 | default:{ |
84 | if ( m_info[1] ) | 84 | if ( m_info[1] ) |
85 | close( m_info[1] ); | 85 | close( m_info[1] ); |
86 | if ( m_info[0] ) for (;;) { | 86 | if ( m_info[0] ) for (;;) { |
87 | char resultByte; int len; | 87 | char resultByte; int len; |
88 | len = read(m_info[0], &resultByte, 1 ); | 88 | len = read(m_info[0], &resultByte, 1 ); |
89 | /* len == 1 start up failed */ | 89 | /* len == 1 start up failed */ |
90 | if ( len == 1 ) { | 90 | if ( len == 1 ) { |
91 | emit error( StartError, tr("Could not start") ); | 91 | emit error( StartError, tr("Could not start") ); |
92 | return; | 92 | return; |
93 | } | 93 | } |
94 | if ( len == -1 ) | 94 | if ( len == -1 ) |
95 | if ( (errno == ECHILD ) || (errno == EINTR ) ) | 95 | if ( (errno == ECHILD ) || (errno == EINTR ) ) |
96 | continue; | 96 | continue; |
97 | 97 | ||
98 | // len == 0 or something like this | 98 | // len == 0 or something like this |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | if ( m_info[0] ) | 101 | if ( m_info[0] ) |
102 | close( m_info[0] ); | 102 | close( m_info[0] ); |
103 | 103 | ||
104 | 104 | ||
105 | 105 | ||
106 | /* replace by QSocketNotifier!!! */ | 106 | /* replace by QSocketNotifier!!! */ |
107 | m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); | 107 | m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); |
108 | connect(m_not, SIGNAL(activated(int) ), | 108 | connect(m_not, SIGNAL(activated(int) ), |
109 | this, SLOT(slotRead() ) ); | 109 | this, SLOT(slotRead() ) ); |
110 | if ( pipe(m_term) < 0 ) | 110 | if ( pipe(m_term) < 0 ) |
111 | m_term[0] = m_term[1] = 0; | 111 | m_term[0] = m_term[1] = 0; |
112 | 112 | ||
113 | ProcCtl::self()->add(m_pid, m_term[1] ); | 113 | ProcCtl::self()->add(m_pid, m_term[1] ); |
114 | m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); | 114 | m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); |
115 | connect(m_proc, SIGNAL(activated(int) ), | 115 | connect(m_proc, SIGNAL(activated(int) ), |
116 | this, SLOT(slotExec() ) ); | 116 | this, SLOT(slotExec() ) ); |
117 | 117 | ||
118 | } | 118 | } |
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | /* | 122 | /* |
123 | * let's call the one with the filename | 123 | * let's call the one with the filename |
124 | */ | 124 | */ |
125 | void FileTransfer::sendFile( const QFile& file ) { | 125 | void FileTransfer::sendFile( const QFile& file ) { |
126 | sendFile( file.name() ); | 126 | sendFile( file.name() ); |
127 | } | 127 | } |
128 | 128 | ||
129 | /* | 129 | /* |
130 | * setting up communication | 130 | * setting up communication |
131 | * between parent child and ioLayer | 131 | * between parent child and ioLayer |
132 | */ | 132 | */ |
133 | void FileTransfer::setupChild() { | 133 | void FileTransfer::setupChild() { |
134 | /* | 134 | /* |
135 | * we do not want to read from our | 135 | * we do not want to read from our |
136 | * information channel | 136 | * information channel |
137 | */ | 137 | */ |
138 | if (m_info[0] ) | 138 | if (m_info[0] ) |
139 | close(m_info[0] ); | 139 | close(m_info[0] ); |
140 | /* | 140 | /* |
141 | * FD_CLOEXEC will close the | 141 | * FD_CLOEXEC will close the |
142 | * fd on successfull exec | 142 | * fd on successfull exec |
143 | */ | 143 | */ |
144 | if (m_info[1] ) | 144 | if (m_info[1] ) |
145 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); | 145 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); |
146 | 146 | ||
147 | if (m_comm[0] ) | 147 | if (m_comm[0] ) |
148 | close( m_comm[0] ); | 148 | close( m_comm[0] ); |
149 | /* | 149 | /* |
150 | * now set the communication | 150 | * now set the communication |
151 | * m_fd STDIN_FILENO | 151 | * m_fd STDIN_FILENO |
152 | * STDOUT_FILENO | 152 | * STDOUT_FILENO |
153 | * STDERR_FILENO | 153 | * STDERR_FILENO |
154 | */ | 154 | */ |
155 | dup2( m_fd, STDIN_FILENO ); | 155 | dup2( m_fd, STDIN_FILENO ); |
156 | dup2( m_fd, STDOUT_FILENO ); | 156 | dup2( m_fd, STDOUT_FILENO ); |
157 | dup2( m_comm[1], STDERR_FILENO ); | 157 | dup2( m_comm[1], STDERR_FILENO ); |
158 | } | 158 | } |
159 | 159 | ||
160 | /* | 160 | /* |
161 | * read from the stderr of the child | 161 | * read from the stderr of the child |
162 | * process | 162 | * process |
163 | */ | 163 | */ |
164 | void FileTransfer::slotRead() { | 164 | void FileTransfer::slotRead() { |
165 | QByteArray ar(4096); | 165 | QByteArray ar(4096); |
166 | int len = read(m_comm[0], ar.data(), 4096 ); | 166 | int len = read(m_comm[0], ar.data(), 4096 ); |
167 | qWarning("slot read %d", len); | 167 | qWarning("slot read %d", len); |
168 | for (int i = 0; i < len; i++ ) { | 168 | for (int i = 0; i < len; i++ ) { |
169 | // printf("%c", ar[i] ); | 169 | // printf("%c", ar[i] ); |
170 | } | 170 | } |
171 | ar.resize( len ); | 171 | ar.resize( len ); |
172 | QString str( ar ); | 172 | QString str( ar ); |
173 | qWarning(str.simplifyWhiteSpace() ); | 173 | qWarning(str.simplifyWhiteSpace() ); |
174 | QStringList lis = QStringList::split(' ', str ); | 174 | QStringList lis = QStringList::split(' ', str ); |
175 | /* | 175 | /* |
176 | * Transfer finished.. either complete or incomplete | 176 | * Transfer finished.. either complete or incomplete |
177 | */ | 177 | */ |
178 | if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { | 178 | if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { |
179 | qWarning("sent!!!!"); | 179 | qWarning("sent!!!!"); |
180 | emit sent(); | 180 | emit sent(); |
181 | return; | 181 | return; |
182 | } | 182 | } |
183 | /* | 183 | /* |
184 | * do progress reading | 184 | * do progress reading |
185 | */ | 185 | */ |
186 | slotProgress( lis ); | 186 | slotProgress( lis ); |
187 | 187 | ||
188 | 188 | ||
189 | } | 189 | } |
190 | /* | 190 | /* |
191 | * find the progress | 191 | * find the progress |
192 | */ | 192 | */ |
193 | void FileTransfer::slotProgress( const QStringList& list ) { | 193 | void FileTransfer::slotProgress( const QStringList& list ) { |
194 | if ( m_type != SZ ) | 194 | if ( m_type != SZ ) |
195 | return; | 195 | return; |
196 | bool complete = true; | 196 | bool complete = true; |
197 | int min, sec; | 197 | int min, sec; |
198 | int bps; | 198 | int bps; |
199 | unsigned long sent, total; | 199 | unsigned long sent, total; |
200 | 200 | ||
201 | min = sec = bps = -1; | 201 | min = sec = bps = -1; |
202 | sent = total = 0; | 202 | sent = total = 0; |
203 | 203 | ||
204 | // Data looks like this | 204 | // Data looks like this |
205 | // 0 1 2 3 4 5 | 205 | // 0 1 2 3 4 5 |
206 | // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 | 206 | // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 |
207 | QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); | 207 | QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); |
208 | sent = progi[0].toULong(&complete ); | 208 | sent = progi[0].toULong(&complete ); |
209 | if (!complete ) return; | 209 | if (!complete ) return; |
210 | 210 | ||
211 | total = progi[1].toULong(&complete ); | 211 | total = progi[1].toULong(&complete ); |
212 | if (!complete || total == 0) { | 212 | if (!complete || total == 0) { |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | 215 | ||
216 | qWarning("%s, %d, %d", progi.join("/").latin1(), sent, total ); | 216 | qWarning("%s, %d, %d", progi.join("/").latin1(), sent, total ); |
217 | 217 | ||
218 | double pro = (double)sent/total; | 218 | double pro = (double)sent/total; |
219 | int prog = pro * 100; | 219 | int prog = pro * 100; |
220 | 220 | ||
221 | // speed | 221 | // speed |
222 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); | 222 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); |
223 | bps = progi[1].toInt(); | 223 | bps = progi[1].toInt(); |
224 | 224 | ||
225 | // time | 225 | // time |
226 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); | 226 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); |
227 | min = progi[0].toInt(); | 227 | min = progi[0].toInt(); |
228 | sec = progi[1].toInt(); | 228 | sec = progi[1].toInt(); |
229 | 229 | ||
230 | 230 | ||
231 | if ( prog > m_prog ) { | 231 | if ( prog > m_prog ) { |
232 | m_prog = prog; | 232 | m_prog = prog; |
233 | emit progress(m_file, m_prog, bps, -1, min , sec ); | 233 | emit progress(m_file, m_prog, bps, -1, min , sec ); |
234 | } | 234 | } |
235 | 235 | ||
236 | } | 236 | } |
237 | void FileTransfer::cancel() { | 237 | void FileTransfer::cancel() { |
238 | ::kill(m_pid,9 ); | 238 | if(m_pid > 0) ::kill(m_pid,9 ); |
239 | delete m_not; | 239 | delete m_not; |
240 | } | 240 | } |
241 | void FileTransfer::slotExec() { | 241 | void FileTransfer::slotExec() { |
242 | qWarning("exited!"); | 242 | qWarning("exited!"); |
243 | char buf[2]; | 243 | char buf[2]; |
244 | ::read(m_term[0], buf, 1 ); | 244 | ::read(m_term[0], buf, 1 ); |
245 | delete m_proc; | 245 | delete m_proc; |
246 | delete m_not; | 246 | delete m_not; |
247 | m_proc = m_not = 0l; | 247 | m_proc = m_not = 0l; |
248 | close( m_term[0] ); | 248 | close( m_term[0] ); |
249 | close( m_term[1] ); | 249 | close( m_term[1] ); |
250 | close( m_comm[0] ); | 250 | close( m_comm[0] ); |
251 | close( m_comm[1] ); | 251 | close( m_comm[1] ); |
252 | emit sent(); | 252 | emit sent(); |
253 | } | 253 | } |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 3af0cba..8f5d56b 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,275 +1,275 @@ | |||
1 | 1 | ||
2 | #include <qaction.h> | 2 | #include <qaction.h> |
3 | #include <qmenubar.h> | 3 | #include <qmenubar.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qtoolbar.h> | 6 | #include <qtoolbar.h> |
7 | #include <qpe/resource.h> | 7 | #include <qpe/resource.h> |
8 | 8 | ||
9 | 9 | ||
10 | #include "profileeditordialog.h" | 10 | #include "profileeditordialog.h" |
11 | #include "configdialog.h" | 11 | #include "configdialog.h" |
12 | #include "default.h" | 12 | #include "default.h" |
13 | #include "metafactory.h" | 13 | #include "metafactory.h" |
14 | #include "profile.h" | 14 | #include "profile.h" |
15 | #include "profilemanager.h" | 15 | #include "profilemanager.h" |
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | #include "tabwidget.h" | 17 | #include "tabwidget.h" |
18 | #include "transferdialog.h" | 18 | #include "transferdialog.h" |
19 | #include "function_keyboard.h" | 19 | #include "function_keyboard.h" |
20 | 20 | ||
21 | MainWindow::MainWindow() { | 21 | MainWindow::MainWindow() { |
22 | m_factory = new MetaFactory(); | 22 | m_factory = new MetaFactory(); |
23 | Default def(m_factory); | 23 | Default def(m_factory); |
24 | m_sessions.setAutoDelete( TRUE ); | 24 | m_sessions.setAutoDelete( TRUE ); |
25 | m_curSession = 0; | 25 | m_curSession = 0; |
26 | m_manager = new ProfileManager( m_factory ); | 26 | m_manager = new ProfileManager( m_factory ); |
27 | m_manager->load(); | 27 | m_manager->load(); |
28 | 28 | ||
29 | initUI(); | 29 | initUI(); |
30 | populateProfiles(); | 30 | populateProfiles(); |
31 | } | 31 | } |
32 | void MainWindow::initUI() { | 32 | void MainWindow::initUI() { |
33 | setToolBarsMovable( FALSE ); | 33 | setToolBarsMovable( FALSE ); |
34 | 34 | ||
35 | /* tool bar for the menu */ | 35 | /* tool bar for the menu */ |
36 | m_tool = new QToolBar( this ); | 36 | m_tool = new QToolBar( this ); |
37 | m_tool->setHorizontalStretchable( TRUE ); | 37 | m_tool->setHorizontalStretchable( TRUE ); |
38 | 38 | ||
39 | m_bar = new QMenuBar( m_tool ); | 39 | m_bar = new QMenuBar( m_tool ); |
40 | m_console = new QPopupMenu( this ); | 40 | m_console = new QPopupMenu( this ); |
41 | m_sessionsPop= new QPopupMenu( this ); | 41 | m_sessionsPop= new QPopupMenu( this ); |
42 | m_settings = new QPopupMenu( this ); | 42 | m_settings = new QPopupMenu( this ); |
43 | 43 | ||
44 | /* add a toolbar for icons */ | 44 | /* add a toolbar for icons */ |
45 | m_icons = new QToolBar(this); | 45 | m_icons = new QToolBar(this); |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * new Action for new sessions | 48 | * new Action for new sessions |
49 | */ | 49 | */ |
50 | QAction* a = new QAction(tr("New Connection"), | 50 | QAction* a = new QAction(tr("New Connection"), |
51 | Resource::loadPixmap( "new" ), | 51 | Resource::loadPixmap( "new" ), |
52 | QString::null, 0, this, 0); | 52 | QString::null, 0, this, 0); |
53 | a->addTo( m_console ); | 53 | a->addTo( m_console ); |
54 | a->addTo( m_icons ); | 54 | a->addTo( m_icons ); |
55 | connect(a, SIGNAL(activated() ), | 55 | connect(a, SIGNAL(activated() ), |
56 | this, SLOT(slotNew() ) ); | 56 | this, SLOT(slotNew() ) ); |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * connect action | 59 | * connect action |
60 | */ | 60 | */ |
61 | m_connect = new QAction(); | 61 | m_connect = new QAction(); |
62 | m_connect->setText( tr("Connect") ); | 62 | m_connect->setText( tr("Connect") ); |
63 | m_connect->addTo( m_console ); | 63 | m_connect->addTo( m_console ); |
64 | connect(m_connect, SIGNAL(activated() ), | 64 | connect(m_connect, SIGNAL(activated() ), |
65 | this, SLOT(slotConnect() ) ); | 65 | this, SLOT(slotConnect() ) ); |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * disconnect action | 68 | * disconnect action |
69 | */ | 69 | */ |
70 | m_disconnect = new QAction(); | 70 | m_disconnect = new QAction(); |
71 | m_disconnect->setText( tr("Disconnect") ); | 71 | m_disconnect->setText( tr("Disconnect") ); |
72 | m_disconnect->addTo( m_console ); | 72 | m_disconnect->addTo( m_console ); |
73 | connect(m_disconnect, SIGNAL(activated() ), | 73 | connect(m_disconnect, SIGNAL(activated() ), |
74 | this, SLOT(slotDisconnect() ) ); | 74 | this, SLOT(slotDisconnect() ) ); |
75 | 75 | ||
76 | m_transfer = new QAction(); | 76 | m_transfer = new QAction(); |
77 | m_transfer->setText( tr("Transfer file...") ); | 77 | m_transfer->setText( tr("Transfer file...") ); |
78 | m_transfer->addTo( m_console ); | 78 | m_transfer->addTo( m_console ); |
79 | connect(m_transfer, SIGNAL(activated() ), | 79 | connect(m_transfer, SIGNAL(activated() ), |
80 | this, SLOT(slotTransfer() ) ); | 80 | this, SLOT(slotTransfer() ) ); |
81 | 81 | ||
82 | /* | 82 | /* |
83 | * terminate action | 83 | * terminate action |
84 | */ | 84 | */ |
85 | m_terminate = new QAction(); | 85 | m_terminate = new QAction(); |
86 | m_terminate->setText( tr("Terminate") ); | 86 | m_terminate->setText( tr("Terminate") ); |
87 | m_terminate->addTo( m_console ); | 87 | m_terminate->addTo( m_console ); |
88 | connect(m_terminate, SIGNAL(activated() ), | 88 | connect(m_terminate, SIGNAL(activated() ), |
89 | this, SLOT(slotTerminate() ) ); | 89 | this, SLOT(slotTerminate() ) ); |
90 | 90 | ||
91 | a = new QAction(); | 91 | a = new QAction(); |
92 | a->setText( tr("Close Window") ); | 92 | a->setText( tr("Close Window") ); |
93 | a->addTo( m_console ); | 93 | a->addTo( m_console ); |
94 | connect(a, SIGNAL(activated() ), | 94 | connect(a, SIGNAL(activated() ), |
95 | this, SLOT(slotClose() ) ); | 95 | this, SLOT(slotClose() ) ); |
96 | 96 | ||
97 | /* | 97 | /* |
98 | * the settings action | 98 | * the settings action |
99 | */ | 99 | */ |
100 | m_setProfiles = new QAction(tr("Configure Profiles"), | 100 | m_setProfiles = new QAction(tr("Configure Profiles"), |
101 | Resource::loadPixmap( "SettingsIcon" ), | 101 | Resource::loadPixmap( "SettingsIcon" ), |
102 | QString::null, 0, this, 0); | 102 | QString::null, 0, this, 0); |
103 | m_setProfiles->addTo( m_settings ); | 103 | m_setProfiles->addTo( m_settings ); |
104 | m_setProfiles->addTo( m_icons ); | 104 | m_setProfiles->addTo( m_icons ); |
105 | connect( m_setProfiles, SIGNAL(activated() ), | 105 | connect( m_setProfiles, SIGNAL(activated() ), |
106 | this, SLOT(slotConfigure() ) ); | 106 | this, SLOT(slotConfigure() ) ); |
107 | 107 | ||
108 | /* | 108 | /* |
109 | * action that open/closes the keyboard | 109 | * action that open/closes the keyboard |
110 | */ | 110 | */ |
111 | m_openKeys = new QAction (tr("Open Keyboard..."), | 111 | m_openKeys = new QAction (tr("Open Keyboard..."), |
112 | Resource::loadPixmap( "down" ), | 112 | Resource::loadPixmap( "down" ), |
113 | QString::null, 0, this, 0); | 113 | QString::null, 0, this, 0); |
114 | 114 | ||
115 | m_openKeys->setToggleAction(true); | 115 | m_openKeys->setToggleAction(true); |
116 | 116 | ||
117 | connect (m_openKeys, SIGNAL(toggled(bool)), | 117 | connect (m_openKeys, SIGNAL(toggled(bool)), |
118 | this, SLOT(slotOpenKeb(bool))); | 118 | this, SLOT(slotOpenKeb(bool))); |
119 | m_openKeys->addTo(m_icons); | 119 | m_openKeys->addTo(m_icons); |
120 | 120 | ||
121 | 121 | ||
122 | /* insert the submenu */ | 122 | /* insert the submenu */ |
123 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 123 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
124 | -1, 0); | 124 | -1, 0); |
125 | 125 | ||
126 | /* insert the connection menu */ | 126 | /* insert the connection menu */ |
127 | m_bar->insertItem( tr("Connection"), m_console ); | 127 | m_bar->insertItem( tr("Connection"), m_console ); |
128 | 128 | ||
129 | /* the settings menu */ | 129 | /* the settings menu */ |
130 | m_bar->insertItem( tr("Settings"), m_settings ); | 130 | m_bar->insertItem( tr("Settings"), m_settings ); |
131 | 131 | ||
132 | /* and the keyboard */ | 132 | /* and the keyboard */ |
133 | m_keyBar = new QToolBar(this); | 133 | m_keyBar = new QToolBar(this); |
134 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 134 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
135 | m_keyBar->setHorizontalStretchable( TRUE ); | 135 | m_keyBar->setHorizontalStretchable( TRUE ); |
136 | m_keyBar->hide(); | 136 | m_keyBar->hide(); |
137 | 137 | ||
138 | m_kb = new FunctionKeyboard(m_keyBar); | 138 | m_kb = new FunctionKeyboard(m_keyBar); |
139 | 139 | ||
140 | /* | 140 | /* |
141 | * connect to the menu activation | 141 | * connect to the menu activation |
142 | */ | 142 | */ |
143 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 143 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
144 | this, SLOT(slotProfile( int ) ) ); | 144 | this, SLOT(slotProfile( int ) ) ); |
145 | 145 | ||
146 | m_consoleWindow = new TabWidget( this, "blah"); | 146 | m_consoleWindow = new TabWidget( this, "blah"); |
147 | setCentralWidget( m_consoleWindow ); | 147 | setCentralWidget( m_consoleWindow ); |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | ProfileManager* MainWindow::manager() { | 151 | ProfileManager* MainWindow::manager() { |
152 | return m_manager; | 152 | return m_manager; |
153 | } | 153 | } |
154 | TabWidget* MainWindow::tabWidget() { | 154 | TabWidget* MainWindow::tabWidget() { |
155 | return m_consoleWindow; | 155 | return m_consoleWindow; |
156 | } | 156 | } |
157 | void MainWindow::populateProfiles() { | 157 | void MainWindow::populateProfiles() { |
158 | m_sessionsPop->clear(); | 158 | m_sessionsPop->clear(); |
159 | Profile::ValueList list = manager()->all(); | 159 | Profile::ValueList list = manager()->all(); |
160 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 160 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
161 | m_sessionsPop->insertItem( (*it).name() ); | 161 | m_sessionsPop->insertItem( (*it).name() ); |
162 | } | 162 | } |
163 | 163 | ||
164 | } | 164 | } |
165 | MainWindow::~MainWindow() { | 165 | MainWindow::~MainWindow() { |
166 | delete m_factory; | 166 | delete m_factory; |
167 | manager()->save(); | 167 | manager()->save(); |
168 | } | 168 | } |
169 | 169 | ||
170 | MetaFactory* MainWindow::factory() { | 170 | MetaFactory* MainWindow::factory() { |
171 | return m_factory; | 171 | return m_factory; |
172 | } | 172 | } |
173 | 173 | ||
174 | Session* MainWindow::currentSession() { | 174 | Session* MainWindow::currentSession() { |
175 | return m_curSession; | 175 | return m_curSession; |
176 | } | 176 | } |
177 | 177 | ||
178 | QList<Session> MainWindow::sessions() { | 178 | QList<Session> MainWindow::sessions() { |
179 | return m_sessions; | 179 | return m_sessions; |
180 | } | 180 | } |
181 | 181 | ||
182 | void MainWindow::slotNew() { | 182 | void MainWindow::slotNew() { |
183 | qWarning("New Connection"); | 183 | qWarning("New Connection"); |
184 | ProfileEditorDialog dlg(factory() ); | 184 | ProfileEditorDialog dlg(factory() ); |
185 | int ret = dlg.exec(); | 185 | int ret = dlg.exec(); |
186 | 186 | ||
187 | if ( ret == QDialog::Accepted ) { | 187 | if ( ret == QDialog::Accepted ) { |
188 | create( dlg.profile() ); | 188 | create( dlg.profile() ); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | void MainWindow::slotConnect() { | 192 | void MainWindow::slotConnect() { |
193 | if ( currentSession() ) | 193 | if ( currentSession() ) |
194 | currentSession()->layer()->open(); | 194 | currentSession()->layer()->open(); |
195 | } | 195 | } |
196 | 196 | ||
197 | void MainWindow::slotDisconnect() { | 197 | void MainWindow::slotDisconnect() { |
198 | if ( currentSession() ) | 198 | if ( currentSession() ) |
199 | currentSession()->layer()->close(); | 199 | currentSession()->layer()->close(); |
200 | } | 200 | } |
201 | 201 | ||
202 | void MainWindow::slotTerminate() { | 202 | void MainWindow::slotTerminate() { |
203 | if ( currentSession() ) | 203 | if ( currentSession() ) |
204 | currentSession()->layer()->close(); | 204 | currentSession()->layer()->close(); |
205 | 205 | ||
206 | slotClose(); | 206 | slotClose(); |
207 | /* FIXME move to the next session */ | 207 | /* FIXME move to the next session */ |
208 | } | 208 | } |
209 | 209 | ||
210 | void MainWindow::slotConfigure() { | 210 | void MainWindow::slotConfigure() { |
211 | qWarning("configure"); | 211 | qWarning("configure"); |
212 | ConfigDialog conf( manager()->all(), factory() ); | 212 | ConfigDialog conf( manager()->all(), factory() ); |
213 | conf.showMaximized(); | 213 | conf.showMaximized(); |
214 | 214 | ||
215 | int ret = conf.exec(); | 215 | int ret = conf.exec(); |
216 | 216 | ||
217 | if ( QDialog::Accepted == ret ) { | 217 | if ( QDialog::Accepted == ret ) { |
218 | qWarning("conf %d", conf.list().count() ); | 218 | qWarning("conf %d", conf.list().count() ); |
219 | manager()->setProfiles( conf.list() ); | 219 | manager()->setProfiles( conf.list() ); |
220 | populateProfiles(); | 220 | populateProfiles(); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | /* | 223 | /* |
224 | * we will remove | 224 | * we will remove |
225 | * this window from the tabwidget | 225 | * this window from the tabwidget |
226 | * remove it from the list | 226 | * remove it from the list |
227 | * delete it | 227 | * delete it |
228 | * and set the currentSession() | 228 | * and set the currentSession() |
229 | */ | 229 | */ |
230 | void MainWindow::slotClose() { | 230 | void MainWindow::slotClose() { |
231 | qWarning("close"); | 231 | qWarning("close"); |
232 | if (!currentSession() ) | 232 | if (!currentSession() ) |
233 | return; | 233 | return; |
234 | 234 | ||
235 | tabWidget()->remove( currentSession() ); | 235 | tabWidget()->remove( currentSession() ); |
236 | /*it's autodelete */ | 236 | /*it's autodelete */ |
237 | m_sessions.remove( m_curSession ); | 237 | m_sessions.remove( m_curSession ); |
238 | m_curSession = m_sessions.first(); | 238 | m_curSession = m_sessions.first(); |
239 | tabWidget()->setCurrent( m_curSession ); | 239 | tabWidget()->setCurrent( m_curSession ); |
240 | } | 240 | } |
241 | 241 | ||
242 | /* | 242 | /* |
243 | * We will get the name | 243 | * We will get the name |
244 | * Then the profile | 244 | * Then the profile |
245 | * and then we will make a profile | 245 | * and then we will make a profile |
246 | */ | 246 | */ |
247 | void MainWindow::slotProfile( int id) { | 247 | void MainWindow::slotProfile( int id) { |
248 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 248 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
249 | create( prof ); | 249 | create( prof ); |
250 | } | 250 | } |
251 | void MainWindow::create( const Profile& prof ) { | 251 | void MainWindow::create( const Profile& prof ) { |
252 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 252 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
253 | 253 | ||
254 | m_sessions.append( ses ); | 254 | m_sessions.append( ses ); |
255 | tabWidget()->add( ses ); | 255 | tabWidget()->add( ses ); |
256 | m_curSession = ses; | 256 | m_curSession = ses; |
257 | 257 | ||
258 | } | 258 | } |
259 | 259 | ||
260 | void MainWindow::slotTransfer() | 260 | void MainWindow::slotTransfer() |
261 | { | 261 | { |
262 | if ( currentSession() ) { | 262 | if ( currentSession() ) { |
263 | TransferDialog dlg(this); | 263 | TransferDialog dlg(this); |
264 | dlg.showMaximized(); | 264 | //dlg.showMaximized(); |
265 | dlg.exec(); | 265 | dlg.exec(); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | void MainWindow::slotOpenKeb(bool state) { | 270 | void MainWindow::slotOpenKeb(bool state) { |
271 | 271 | ||
272 | if (state) m_keyBar->show(); | 272 | if (state) m_keyBar->show(); |
273 | else m_keyBar->hide(); | 273 | else m_keyBar->hide(); |
274 | 274 | ||
275 | } | 275 | } |
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index ba06199..d3b9c0a 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -1,187 +1,218 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | #include <qcombobox.h> | 2 | #include <qcombobox.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qprogressbar.h> | 7 | #include <qprogressbar.h> |
8 | #include <qradiobutton.h> | ||
9 | #include <qbuttongroup.h> | ||
8 | 10 | ||
9 | #include <opie/ofiledialog.h> | 11 | #include <opie/ofiledialog.h> |
10 | 12 | ||
11 | #include "filetransfer.h" | 13 | #include "filetransfer.h" |
12 | #include "io_serial.h" | 14 | #include "io_serial.h" |
13 | #include "metafactory.h" | 15 | #include "metafactory.h" |
14 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
15 | 17 | ||
16 | #include "transferdialog.h" | 18 | #include "transferdialog.h" |
17 | 19 | ||
18 | |||
19 | |||
20 | |||
21 | |||
22 | |||
23 | |||
24 | TransferDialog::TransferDialog(MainWindow *parent, const char *name) | 20 | TransferDialog::TransferDialog(MainWindow *parent, const char *name) |
25 | : QDialog(/*parent, name*/0l, 0l, true), m_win(parent) | 21 | : QDialog(0l, 0l, true), m_win(parent) |
26 | { | 22 | { |
27 | m_lay = 0l; | 23 | m_lay = 0l; |
28 | QVBoxLayout *vbox; | 24 | QVBoxLayout *vbox, *vbox2; |
29 | QHBoxLayout *hbox, *hbox2; | 25 | QHBoxLayout *hbox, *hbox2, *hbox3; |
30 | QLabel *file, *mode, *progress, *status; | 26 | QLabel *file, *mode, *progress, *status; |
31 | QPushButton *selector; | 27 | QButtonGroup *group; |
32 | 28 | QRadioButton *mode_send, *mode_receive; | |
29 | |||
30 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); | ||
31 | mode_send = new QRadioButton(QObject::tr("Send"), group); | ||
32 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); | ||
33 | group->insert(mode_send, id_send); | ||
34 | group->insert(mode_receive, id_receive); | ||
35 | vbox2 = new QVBoxLayout(group, 2); | ||
36 | vbox2->addSpacing(10); | ||
37 | hbox3 = new QHBoxLayout(vbox2, 2); | ||
38 | hbox3->add(mode_send); | ||
39 | hbox3->add(mode_receive); | ||
40 | mode_send->setChecked(true); | ||
41 | m_transfermode = id_send; | ||
33 | 42 | ||
34 | file = new QLabel(QObject::tr("Send file"), this); | 43 | file = new QLabel(QObject::tr("Send file"), this); |
35 | mode = new QLabel(QObject::tr("Transfer mode"), this); | 44 | mode = new QLabel(QObject::tr("Transfer protocol"), this); |
36 | progress = new QLabel(QObject::tr("Progress"), this); | 45 | progress = new QLabel(QObject::tr("Progress"), this); |
37 | status = new QLabel(QObject::tr("Status"), this); | 46 | status = new QLabel(QObject::tr("Status"), this); |
38 | 47 | ||
39 | statusbar = new QLabel(QObject::tr("ready"), this); | 48 | statusbar = new QLabel(QObject::tr("Ready"), this); |
40 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 49 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
41 | 50 | ||
42 | protocol = new QComboBox(this); | 51 | protocol = new QComboBox(this); |
43 | /* use the fscking MetaFactory | 52 | QStringList list = m_win->factory()->fileTransferLayers(); |
44 | * because we invented it for that fscking reason | 53 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) |
45 | * I'm really getting UPSET!!!! | 54 | protocol->insertItem((*it)); |
46 | */ | ||
47 | QStringList list = m_win->factory()->fileTransferLayers(); | ||
48 | for (QStringList::Iterator it =list.begin(); it != list.end(); ++it ) { | ||
49 | protocol->insertItem( (*it) ); | ||
50 | } | ||
51 | 55 | ||
52 | filename = new QLineEdit(this); | 56 | filename = new QLineEdit(this); |
53 | 57 | ||
54 | progressbar = new QProgressBar(this); | 58 | progressbar = new QProgressBar(this); |
55 | progressbar->setProgress(0); | 59 | progressbar->setProgress(0); |
56 | 60 | ||
57 | selector = new QPushButton("...", this); | 61 | selector = new QPushButton("...", this); |
58 | ok = new QPushButton(QObject::tr("Start transfer"), this); | 62 | ok = new QPushButton(QObject::tr("Start transfer"), this); |
59 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 63 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
60 | 64 | ||
61 | vbox = new QVBoxLayout(this, 2); | 65 | vbox = new QVBoxLayout(this, 2); |
66 | vbox->add(group); | ||
62 | vbox->add(file); | 67 | vbox->add(file); |
63 | hbox = new QHBoxLayout(vbox, 0); | 68 | hbox = new QHBoxLayout(vbox, 0); |
64 | hbox->add(filename); | 69 | hbox->add(filename); |
65 | hbox->add(selector); | 70 | hbox->add(selector); |
66 | vbox->add(mode); | 71 | vbox->add(mode); |
67 | vbox->add(protocol); | 72 | vbox->add(protocol); |
68 | vbox->add(progress); | 73 | vbox->add(progress); |
69 | vbox->add(progressbar); | 74 | vbox->add(progressbar); |
70 | vbox->add(status); | 75 | vbox->add(status); |
71 | vbox->add(statusbar); | 76 | vbox->add(statusbar); |
72 | vbox->addStretch(1); | 77 | vbox->addStretch(1); |
73 | hbox2 = new QHBoxLayout(vbox, 2); | 78 | hbox2 = new QHBoxLayout(vbox, 2); |
74 | hbox2->add(ok); | 79 | hbox2->add(ok); |
75 | hbox2->add(cancel); | 80 | hbox2->add(cancel); |
76 | 81 | ||
77 | setCaption(QObject::tr("File transfer")); | 82 | setCaption(QObject::tr("File transfer")); |
78 | show(); | 83 | show(); |
79 | 84 | ||
80 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); | 85 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); |
81 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); | 86 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); |
82 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); | 87 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); |
88 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); | ||
83 | } | 89 | } |
84 | 90 | ||
85 | TransferDialog::~TransferDialog() | 91 | TransferDialog::~TransferDialog() |
86 | { | 92 | { |
87 | } | 93 | } |
88 | 94 | ||
89 | void TransferDialog::slotFilename() | 95 | void TransferDialog::slotFilename() |
90 | { | 96 | { |
91 | QString f; | 97 | QString f; |
92 | 98 | ||
93 | f = OFileDialog::getOpenFileName(0); | 99 | f = OFileDialog::getOpenFileName(0); |
94 | if(!f.isNull()) filename->setText(f); | 100 | if(!f.isNull()) filename->setText(f); |
95 | } | 101 | } |
96 | 102 | ||
97 | void TransferDialog::slotTransfer() | 103 | void TransferDialog::slotTransfer() |
98 | { | 104 | { |
99 | if(filename->text().isEmpty()) | 105 | if((m_transfermode == id_send) && (filename->text().isEmpty())) |
100 | { | 106 | { |
101 | QMessageBox::information(this, | 107 | QMessageBox::information(this, |
102 | QObject::tr("Attention"), | 108 | QObject::tr("Attention"), |
103 | QObject::tr("No file has been specified.")); | 109 | QObject::tr("No file has been specified.")); |
104 | return; | 110 | return; |
105 | } | 111 | } |
106 | 112 | ||
107 | ok->setEnabled(false); | 113 | ok->setEnabled(false); |
108 | 114 | ||
109 | statusbar->setText(QObject::tr("Sending...")); | 115 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); |
116 | else statusbar->setText(QObject::tr("Receiving...")); | ||
110 | 117 | ||
111 | m_lay = m_win->factory()->newFileTransfer( protocol->currentText(), | 118 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); |
112 | m_win->currentSession()->layer() ); | 119 | if(m_transfermode == id_send) |
113 | m_lay->sendFile(filename->text()); | 120 | { |
121 | m_lay->sendFile(filename->text()); | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | } | ||
114 | 126 | ||
115 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); | 127 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); |
116 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 128 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); |
117 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); | 129 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); |
118 | } | 130 | } |
119 | 131 | ||
120 | void TransferDialog::slotCancel() | 132 | void TransferDialog::slotCancel() |
121 | { | 133 | { |
122 | ok->setEnabled(true); | 134 | ok->setEnabled(true); |
135 | statusbar->setText(QObject::tr("Ready")); | ||
123 | 136 | ||
124 | if(m_lay) | 137 | if(m_lay) |
125 | { | 138 | { |
126 | m_lay->cancel(); | 139 | m_lay->cancel(); |
127 | delete m_lay; | 140 | delete m_lay; |
128 | m_lay = 0l; | 141 | m_lay = 0l; |
129 | QMessageBox::information(this, | 142 | QMessageBox::information(this, |
130 | QObject::tr("Cancelled"), | 143 | QObject::tr("Cancelled"), |
131 | QObject::tr("The file transfer has been cancelled.")); | 144 | QObject::tr("The file transfer has been cancelled.")); |
132 | } | 145 | } |
133 | else | 146 | else |
134 | { | 147 | { |
135 | close(); | 148 | close(); |
136 | } | 149 | } |
137 | } | 150 | } |
138 | 151 | ||
139 | void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) | 152 | void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) |
140 | { | 153 | { |
141 | progressbar->setProgress(progress); | 154 | progressbar->setProgress(progress); |
142 | } | 155 | } |
143 | 156 | ||
144 | void TransferDialog::slotError(int error, const QString& message) | 157 | void TransferDialog::slotError(int error, const QString& message) |
145 | { | 158 | { |
159 | statusbar->setText(QObject::tr("Ready")); | ||
160 | |||
146 | switch(error) | 161 | switch(error) |
147 | { | 162 | { |
148 | case FileTransferLayer::NotSupported: | 163 | case FileTransferLayer::NotSupported: |
149 | QMessageBox::critical(this, | 164 | QMessageBox::critical(this, |
150 | QObject::tr("Error"), | 165 | QObject::tr("Error"), |
151 | QObject::tr("Operation not supported.")); | 166 | QObject::tr("Operation not supported.")); |
152 | break; | 167 | break; |
153 | case FileTransferLayer::StartError: | 168 | case FileTransferLayer::StartError: |
154 | QMessageBox::critical(this, | 169 | QMessageBox::critical(this, |
155 | QObject::tr("Error"), | 170 | QObject::tr("Error"), |
156 | QObject::tr("Operation not supported.")); | 171 | QObject::tr("Transfer could not be started.")); |
157 | break; | 172 | break; |
158 | case FileTransferLayer::NoError: | 173 | case FileTransferLayer::NoError: |
159 | QMessageBox::critical(this, | 174 | QMessageBox::critical(this, |
160 | QObject::tr("Error"), | 175 | QObject::tr("Error"), |
161 | QObject::tr("Operation not supported.")); | 176 | QObject::tr("No error.")); |
162 | break; | 177 | break; |
163 | case FileTransferLayer::Undefined: | 178 | case FileTransferLayer::Undefined: |
164 | QMessageBox::critical(this, | 179 | QMessageBox::critical(this, |
165 | QObject::tr("Error"), | 180 | QObject::tr("Error"), |
166 | QObject::tr("Operation not supported.")); | 181 | QObject::tr("Undefined error occured.")); |
167 | break; | 182 | break; |
168 | case FileTransferLayer::Incomplete: | 183 | case FileTransferLayer::Incomplete: |
169 | QMessageBox::critical(this, | 184 | QMessageBox::critical(this, |
170 | QObject::tr("Error"), | 185 | QObject::tr("Error"), |
171 | QObject::tr("Operation not supported.")); | 186 | QObject::tr("Incomplete transfer.")); |
172 | break; | 187 | break; |
173 | case FileTransferLayer::Unknown: | 188 | case FileTransferLayer::Unknown: |
174 | default: | 189 | default: |
175 | QMessageBox::critical(this, | 190 | QMessageBox::critical(this, |
176 | QObject::tr("Error"), | 191 | QObject::tr("Error"), |
177 | QObject::tr("Operation not supported.")); | 192 | QObject::tr("Unknown error occured.")); |
178 | break; | 193 | break; |
179 | } | 194 | } |
180 | } | 195 | } |
181 | 196 | ||
182 | void TransferDialog::slotSent() | 197 | void TransferDialog::slotSent() |
183 | { | 198 | { |
184 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); | 199 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); |
185 | ok->setEnabled(true); | 200 | ok->setEnabled(true); |
201 | statusbar->setText(QObject::tr("Ready")); | ||
202 | } | ||
203 | |||
204 | void TransferDialog::slotMode(int id) | ||
205 | { | ||
206 | if(id == id_send) | ||
207 | { | ||
208 | selector->setEnabled(true); | ||
209 | filename->setEnabled(true); | ||
210 | } | ||
211 | else | ||
212 | { | ||
213 | selector->setEnabled(false); | ||
214 | filename->setEnabled(false); | ||
215 | } | ||
216 | m_transfermode = id; | ||
186 | } | 217 | } |
187 | 218 | ||
diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h index b0c1a76..a567161 100644 --- a/noncore/apps/opie-console/transferdialog.h +++ b/noncore/apps/opie-console/transferdialog.h | |||
@@ -1,40 +1,48 @@ | |||
1 | #ifndef TRANSFER_DIALOG_H | 1 | #ifndef TRANSFER_DIALOG_H |
2 | #define TRANSFER_DIALOG_H | 2 | #define TRANSFER_DIALOG_H |
3 | 3 | ||
4 | #include "qdialog.h" | 4 | #include "qdialog.h" |
5 | 5 | ||
6 | class QLineEdit; | 6 | class QLineEdit; |
7 | class QComboBox; | 7 | class QComboBox; |
8 | class QProgressBar; | 8 | class QProgressBar; |
9 | class QLabel; | 9 | class QLabel; |
10 | class QPushButton; | 10 | class QPushButton; |
11 | class MainWindow; | 11 | class MainWindow; |
12 | class FileTransferLayer; | 12 | class FileTransferLayer; |
13 | 13 | ||
14 | class TransferDialog : public QDialog | 14 | class TransferDialog : public QDialog |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | public: | 17 | public: |
18 | TransferDialog(MainWindow *parent = 0l, const char *name = 0l); | 18 | TransferDialog(MainWindow *parent = 0l, const char *name = 0l); |
19 | ~TransferDialog(); | 19 | ~TransferDialog(); |
20 | 20 | ||
21 | public slots: | 21 | public slots: |
22 | void slotFilename(); | 22 | void slotFilename(); |
23 | void slotTransfer(); | 23 | void slotTransfer(); |
24 | void slotCancel(); | 24 | void slotCancel(); |
25 | void slotProgress(const QString&, int, int, int, int, int); | 25 | void slotProgress(const QString&, int, int, int, int, int); |
26 | void slotError(int error, const QString& message); | 26 | void slotError(int error, const QString& message); |
27 | void slotSent(); | 27 | void slotSent(); |
28 | void slotMode(int id); | ||
28 | 29 | ||
29 | private: | 30 | private: |
31 | enum Modes | ||
32 | { | ||
33 | id_send, | ||
34 | id_receive | ||
35 | }; | ||
36 | |||
30 | QLineEdit *filename; | 37 | QLineEdit *filename; |
31 | QComboBox *protocol; | 38 | QComboBox *protocol; |
32 | QProgressBar *progressbar; | 39 | QProgressBar *progressbar; |
33 | QLabel *statusbar; | 40 | QLabel *statusbar; |
34 | QPushButton *ok, *cancel; | 41 | QPushButton *ok, *cancel, *selector; |
35 | MainWindow* m_win; | 42 | MainWindow* m_win; |
36 | FileTransferLayer* m_lay; | 43 | FileTransferLayer* m_lay; |
44 | int m_transfermode; | ||
37 | }; | 45 | }; |
38 | 46 | ||
39 | #endif | 47 | #endif |
40 | 48 | ||