summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-13 12:11:15 (UTC)
committer josef <josef>2002-10-13 12:11:15 (UTC)
commit0e6d241e26211a8ffff07ba8e23f4a3cec9065be (patch) (unidiff)
tree1cecafc71b4261943250cf7f83013e749c5c3a1e
parent5f9fb52583eb399c79a108b8e79c1a558a730422 (diff)
downloadopie-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!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp4
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp2
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp99
-rw-r--r--noncore/apps/opie-console/transferdialog.h14
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
@@ -15,5 +15,5 @@
15 15
16FileTransfer::FileTransfer( Type t, IOLayer* lay ) 16FileTransfer::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
@@ -236,5 +236,5 @@ void FileTransfer::slotProgress( const QStringList& list ) {
236} 236}
237void FileTransfer::cancel() { 237void 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}
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
@@ -262,5 +262,5 @@ void MainWindow::slotTransfer()
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 }
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
@@ -6,4 +6,6 @@
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>
@@ -16,37 +18,39 @@
16#include "transferdialog.h" 18#include "transferdialog.h"
17 19
18
19
20
21
22
23
24TransferDialog::TransferDialog(MainWindow *parent, const char *name) 20TransferDialog::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);
@@ -60,4 +64,5 @@ TransferDialog::TransferDialog(MainWindow *parent, const char *name)
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);
@@ -81,4 +86,5 @@ TransferDialog::TransferDialog(MainWindow *parent, const char *name)
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
@@ -97,5 +103,5 @@ void TransferDialog::slotFilename()
97void TransferDialog::slotTransfer() 103void 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,
@@ -107,11 +113,17 @@ void TransferDialog::slotTransfer()
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()));
@@ -121,9 +133,10 @@ 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,
@@ -144,4 +157,6 @@ void TransferDialog::slotProgress(const QString& file, int progress, int speed,
144void TransferDialog::slotError(int error, const QString& message) 157void TransferDialog::slotError(int error, const QString& message)
145{ 158{
159 statusbar->setText(QObject::tr("Ready"));
160
146 switch(error) 161 switch(error)
147 { 162 {
@@ -154,20 +169,20 @@ void TransferDialog::slotError(int error, const QString& message)
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:
@@ -175,5 +190,5 @@ void TransferDialog::slotError(int error, const QString& message)
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 }
@@ -184,4 +199,20 @@ void TransferDialog::slotSent()
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
204void 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
@@ -26,13 +26,21 @@ class TransferDialog : public QDialog
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