summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp44
-rw-r--r--noncore/apps/opie-console/transferdialog.h3
2 files changed, 34 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp
index 0083cc1..f9a0b87 100644
--- a/noncore/apps/opie-console/transferdialog.cpp
+++ b/noncore/apps/opie-console/transferdialog.cpp
@@ -25,12 +25,14 @@ TransferDialog::TransferDialog(MainWindow *parent, const char *name)
25 QVBoxLayout *vbox, *vbox2; 25 QVBoxLayout *vbox, *vbox2;
26 QHBoxLayout *hbox, *hbox2, *hbox3; 26 QHBoxLayout *hbox, *hbox2, *hbox3;
27 QLabel *file, *mode, *progress, *status; 27 QLabel *file, *mode, *progress, *status;
28 QButtonGroup *group; 28 QButtonGroup *group;
29 QRadioButton *mode_send, *mode_receive; 29 QRadioButton *mode_send, *mode_receive;
30 30
31 m_autocleanup = 0;
32
31 group = new QButtonGroup(QObject::tr("Transfer mode"), this); 33 group = new QButtonGroup(QObject::tr("Transfer mode"), this);
32 mode_send = new QRadioButton(QObject::tr("Send"), group); 34 mode_send = new QRadioButton(QObject::tr("Send"), group);
33 mode_receive = new QRadioButton(QObject::tr("Receive"), group); 35 mode_receive = new QRadioButton(QObject::tr("Receive"), group);
34 group->insert(mode_send, id_send); 36 group->insert(mode_send, id_send);
35 group->insert(mode_receive, id_receive); 37 group->insert(mode_receive, id_receive);
36 vbox2 = new QVBoxLayout(group, 2); 38 vbox2 = new QVBoxLayout(group, 2);
@@ -110,12 +112,15 @@ void TransferDialog::slotTransfer()
110 QObject::tr("No file has been specified.")); 112 QObject::tr("No file has been specified."));
111 return; 113 return;
112 } 114 }
113 115
114 ok->setEnabled(false); 116 ok->setEnabled(false);
115 117
118 cleanup();
119 m_autocleanup = 0;
120
116 if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); 121 if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending..."));
117 else statusbar->setText(QObject::tr("Receiving...")); 122 else statusbar->setText(QObject::tr("Receiving..."));
118 123
119 if(m_transfermode == id_send) 124 if(m_transfermode == id_send)
120 { 125 {
121 m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); 126 m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
@@ -135,34 +140,43 @@ void TransferDialog::slotTransfer()
135 SLOT(slotProgress(const QString&, int, int, int, int, int))); 140 SLOT(slotProgress(const QString&, int, int, int, int, int)));
136 connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); 141 connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
137 connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); 142 connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&)));
138 } 143 }
139} 144}
140 145
146void TransferDialog::cleanup()
147{
148 if(m_lay)
149 {
150 m_lay->cancel();
151 delete m_lay;
152 m_lay = 0l;
153 }
154 if(m_recvlay)
155 {
156 m_recvlay->cancel();
157 delete m_recvlay;
158 m_recvlay = 0l;
159 }
160}
161
141void TransferDialog::slotCancel() 162void TransferDialog::slotCancel()
142{ 163{
143 ok->setEnabled(true); 164 ok->setEnabled(true);
144 statusbar->setText(QObject::tr("Ready")); 165 statusbar->setText(QObject::tr("Ready"));
145 166
146 if((m_lay) || (m_recvlay)) 167 if((m_lay) || (m_recvlay))
147 { 168 {
148 if(m_lay) 169 cleanup();
149 { 170 if(m_autocleanup) close();
150 m_lay->cancel(); 171 else
151 delete m_lay;
152 m_lay = 0l;
153 }
154 if(m_recvlay)
155 { 172 {
156 m_recvlay->cancel(); 173 QMessageBox::information(this,
157 delete m_recvlay; 174 QObject::tr("Cancelled"),
158 m_recvlay = 0l; 175 QObject::tr("The file transfer has been cancelled."));
159 } 176 }
160 QMessageBox::information(this,
161 QObject::tr("Cancelled"),
162 QObject::tr("The file transfer has been cancelled."));
163 } 177 }
164 else 178 else
165 { 179 {
166 close(); 180 close();
167 } 181 }
168} 182}
@@ -207,26 +221,30 @@ void TransferDialog::slotError(int error, const QString& message)
207 default: 221 default:
208 QMessageBox::critical(this, 222 QMessageBox::critical(this,
209 QObject::tr("Error"), 223 QObject::tr("Error"),
210 QObject::tr("Unknown error occured.")); 224 QObject::tr("Unknown error occured."));
211 break; 225 break;
212 } 226 }
227
228 m_autocleanup = 1;
213} 229}
214 230
215void TransferDialog::slotSent() 231void TransferDialog::slotSent()
216{ 232{
217 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); 233 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent."));
218 ok->setEnabled(true); 234 ok->setEnabled(true);
219 statusbar->setText(QObject::tr("Ready")); 235 statusbar->setText(QObject::tr("Ready"));
236 m_autocleanup = 1;
220} 237}
221 238
222void TransferDialog::slotReceived(const QString& file) 239void TransferDialog::slotReceived(const QString& file)
223{ 240{
224 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); 241 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file));
225 ok->setEnabled(true); 242 ok->setEnabled(true);
226 statusbar->setText(QObject::tr("Ready")); 243 statusbar->setText(QObject::tr("Ready"));
244 m_autocleanup = 1;
227} 245}
228 246
229void TransferDialog::slotMode(int id) 247void TransferDialog::slotMode(int id)
230{ 248{
231 if(id == id_send) 249 if(id == id_send)
232 { 250 {
diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h
index de3a5cf..1b27f16 100644
--- a/noncore/apps/opie-console/transferdialog.h
+++ b/noncore/apps/opie-console/transferdialog.h
@@ -33,19 +33,22 @@ class TransferDialog : public QDialog
33 enum Modes 33 enum Modes
34 { 34 {
35 id_send, 35 id_send,
36 id_receive 36 id_receive
37 }; 37 };
38 38
39 void cleanup();
40
39 QLineEdit *filename; 41 QLineEdit *filename;
40 QComboBox *protocol; 42 QComboBox *protocol;
41 QProgressBar *progressbar; 43 QProgressBar *progressbar;
42 QLabel *statusbar; 44 QLabel *statusbar;
43 QPushButton *ok, *cancel, *selector; 45 QPushButton *ok, *cancel, *selector;
44 MainWindow* m_win; 46 MainWindow* m_win;
45 FileTransferLayer* m_lay; 47 FileTransferLayer* m_lay;
46 ReceiveLayer *m_recvlay; 48 ReceiveLayer *m_recvlay;
47 int m_transfermode; 49 int m_transfermode;
50 int m_autocleanup;
48}; 51};
49 52
50#endif 53#endif
51 54