Diffstat (limited to 'noncore/apps/opie-console/transferdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index d3b9c0a..0083cc1 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp @@ -1,35 +1,36 @@ #include <qlayout.h> #include <qcombobox.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <opie/ofiledialog.h> -#include "filetransfer.h" -#include "io_serial.h" +#include "file_layer.h" +#include "receive_layer.h" #include "metafactory.h" #include "mainwindow.h" #include "transferdialog.h" TransferDialog::TransferDialog(MainWindow *parent, const char *name) : QDialog(0l, 0l, true), m_win(parent) { m_lay = 0l; + m_recvlay = 0l; QVBoxLayout *vbox, *vbox2; QHBoxLayout *hbox, *hbox2, *hbox3; QLabel *file, *mode, *progress, *status; QButtonGroup *group; QRadioButton *mode_send, *mode_receive; group = new QButtonGroup(QObject::tr("Transfer mode"), this); mode_send = new QRadioButton(QObject::tr("Send"), group); mode_receive = new QRadioButton(QObject::tr("Receive"), group); group->insert(mode_send, id_send); group->insert(mode_receive, id_receive); vbox2 = new QVBoxLayout(group, 2); @@ -106,48 +107,65 @@ void TransferDialog::slotTransfer() { QMessageBox::information(this, QObject::tr("Attention"), QObject::tr("No file has been specified.")); return; } ok->setEnabled(false); if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); else statusbar->setText(QObject::tr("Receiving...")); - m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); if(m_transfermode == id_send) { + m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); m_lay->sendFile(filename->text()); + + connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), + SLOT(slotProgress(const QString&, int, int, int, int, int))); + connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); + connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); } else { - } + m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); + m_recvlay->receive(); - connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); - connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); - connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); + connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), + SLOT(slotProgress(const QString&, int, int, int, int, int))); + connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); + connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); + } } void TransferDialog::slotCancel() { ok->setEnabled(true); statusbar->setText(QObject::tr("Ready")); - if(m_lay) + if((m_lay) || (m_recvlay)) { - m_lay->cancel(); - delete m_lay; - m_lay = 0l; + if(m_lay) + { + m_lay->cancel(); + delete m_lay; + m_lay = 0l; + } + if(m_recvlay) + { + m_recvlay->cancel(); + delete m_recvlay; + m_recvlay = 0l; + } QMessageBox::information(this, QObject::tr("Cancelled"), QObject::tr("The file transfer has been cancelled.")); } else { close(); } } void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) { @@ -192,24 +210,31 @@ void TransferDialog::slotError(int error, const QString& message) QObject::tr("Unknown error occured.")); break; } } void TransferDialog::slotSent() { QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); ok->setEnabled(true); statusbar->setText(QObject::tr("Ready")); } +void TransferDialog::slotReceived(const QString& file) +{ + QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); + ok->setEnabled(true); + statusbar->setText(QObject::tr("Ready")); +} + void TransferDialog::slotMode(int id) { if(id == id_send) { selector->setEnabled(true); filename->setEnabled(true); } else { selector->setEnabled(false); filename->setEnabled(false); } |