summaryrefslogtreecommitdiff
path: root/noncore
authorjosef <josef>2002-10-13 12:11:15 (UTC)
committer josef <josef>2002-10-13 12:11:15 (UTC)
commit0e6d241e26211a8ffff07ba8e23f4a3cec9065be (patch) (unidiff)
tree1cecafc71b4261943250cf7f83013e749c5c3a1e /noncore
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 (limited to 'noncore') (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
@@ -14,7 +14,7 @@
14 14
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
20 m_not = 0l; 20 m_not = 0l;
@@ -235,7 +235,7 @@ void FileTransfer::slotProgress( const QStringList& list ) {
235 235
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}
241void FileTransfer::slotExec() { 241void FileTransfer::slotExec() {
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
@@ -261,7 +261,7 @@ 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}
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
@@ -5,6 +5,8 @@
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
@@ -15,39 +17,41 @@
15 17
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);
53 57
@@ -59,6 +63,7 @@ TransferDialog::TransferDialog(MainWindow *parent, const char *name)
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);
@@ -80,6 +85,7 @@ TransferDialog::TransferDialog(MainWindow *parent, const char *name)
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
85TransferDialog::~TransferDialog() 91TransferDialog::~TransferDialog()
@@ -96,7 +102,7 @@ void TransferDialog::slotFilename()
96 102
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,
102 QObject::tr("Attention"), 108 QObject::tr("Attention"),
@@ -106,13 +112,19 @@ void TransferDialog::slotTransfer()
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}
@@ -120,11 +132,12 @@ void TransferDialog::slotTransfer()
120void TransferDialog::slotCancel() 132void 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"),
@@ -143,6 +156,8 @@ void TransferDialog::slotProgress(const QString& file, int progress, int speed,
143 156
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 {
148 case FileTransferLayer::NotSupported: 163 case FileTransferLayer::NotSupported:
@@ -153,28 +168,28 @@ void TransferDialog::slotError(int error, const QString& message)
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}
@@ -183,5 +198,21 @@ 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
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
@@ -25,15 +25,23 @@ class TransferDialog : public QDialog
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