Diffstat (limited to 'noncore/apps/opie-console/transferdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index d639de6..ba06199 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -1,27 +1,35 @@ | |||
1 | #include "transferdialog.h" | 1 | #include <qlayout.h> |
2 | #include <qcombobox.h> | ||
3 | #include <qlabel.h> | ||
4 | #include <qlineedit.h> | ||
5 | #include <qpushbutton.h> | ||
6 | #include <qmessagebox.h> | ||
7 | #include <qprogressbar.h> | ||
8 | |||
9 | #include <opie/ofiledialog.h> | ||
2 | 10 | ||
3 | #include "filetransfer.h" | 11 | #include "filetransfer.h" |
4 | #include "io_serial.h" | 12 | #include "io_serial.h" |
13 | #include "metafactory.h" | ||
14 | #include "mainwindow.h" | ||
15 | |||
16 | #include "transferdialog.h" | ||
17 | |||
5 | 18 | ||
6 | #include "qlayout.h" | ||
7 | #include "qcombobox.h" | ||
8 | #include "qlabel.h" | ||
9 | #include "qlineedit.h" | ||
10 | #include "qpushbutton.h" | ||
11 | #include "qmessagebox.h" | ||
12 | #include "qprogressbar.h" | ||
13 | 19 | ||
14 | #include "opie/ofiledialog.h" | ||
15 | 20 | ||
16 | TransferDialog::TransferDialog(QWidget *parent, const char *name) | 21 | |
17 | : QDialog(/*parent, name*/NULL, NULL, true) | 22 | |
23 | |||
24 | TransferDialog::TransferDialog(MainWindow *parent, const char *name) | ||
25 | : QDialog(/*parent, name*/0l, 0l, true), m_win(parent) | ||
18 | { | 26 | { |
27 | m_lay = 0l; | ||
19 | QVBoxLayout *vbox; | 28 | QVBoxLayout *vbox; |
20 | QHBoxLayout *hbox, *hbox2; | 29 | QHBoxLayout *hbox, *hbox2; |
21 | QLabel *file, *mode, *progress, *status; | 30 | QLabel *file, *mode, *progress, *status; |
22 | QPushButton *selector; | 31 | QPushButton *selector; |
23 | 32 | ||
24 | transfer = NULL; | ||
25 | 33 | ||
26 | file = new QLabel(QObject::tr("Send file"), this); | 34 | file = new QLabel(QObject::tr("Send file"), this); |
27 | mode = new QLabel(QObject::tr("Transfer mode"), this); | 35 | mode = new QLabel(QObject::tr("Transfer mode"), this); |
@@ -32,9 +40,14 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name) | |||
32 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 40 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
33 | 41 | ||
34 | protocol = new QComboBox(this); | 42 | protocol = new QComboBox(this); |
35 | protocol->insertItem("XModem"); | 43 | /* use the fscking MetaFactory |
36 | protocol->insertItem("YModem"); | 44 | * because we invented it for that fscking reason |
37 | protocol->insertItem("ZModem"); | 45 | * I'm really getting UPSET!!!! |
46 | */ | ||
47 | QStringList list = m_win->factory()->fileTransferLayers(); | ||
48 | for (QStringList::Iterator it =list.begin(); it != list.end(); ++it ) { | ||
49 | protocol->insertItem( (*it) ); | ||
50 | } | ||
38 | 51 | ||
39 | filename = new QLineEdit(this); | 52 | filename = new QLineEdit(this); |
40 | 53 | ||
@@ -76,7 +89,7 @@ TransferDialog::~TransferDialog() | |||
76 | void TransferDialog::slotFilename() | 89 | void TransferDialog::slotFilename() |
77 | { | 90 | { |
78 | QString f; | 91 | QString f; |
79 | 92 | ||
80 | f = OFileDialog::getOpenFileName(0); | 93 | f = OFileDialog::getOpenFileName(0); |
81 | if(!f.isNull()) filename->setText(f); | 94 | if(!f.isNull()) filename->setText(f); |
82 | } | 95 | } |
@@ -95,29 +108,24 @@ void TransferDialog::slotTransfer() | |||
95 | 108 | ||
96 | statusbar->setText(QObject::tr("Sending...")); | 109 | statusbar->setText(QObject::tr("Sending...")); |
97 | 110 | ||
98 | FileTransfer::Type transfermode = FileTransfer::SX; | 111 | m_lay = m_win->factory()->newFileTransfer( protocol->currentText(), |
99 | if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY; | 112 | m_win->currentSession()->layer() ); |
100 | if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ; | 113 | m_lay->sendFile(filename->text()); |
101 | |||
102 | // dummy profile | ||
103 | Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102); | ||
104 | 114 | ||
105 | transfer = new FileTransfer(transfermode, new IOSerial(profile)); | 115 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); |
106 | transfer->sendFile(filename->text()); | 116 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); |
107 | connect(transfer, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); | 117 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); |
108 | connect(transfer, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | ||
109 | connect(transfer, SIGNAL(sent()), SLOT(slotSent())); | ||
110 | } | 118 | } |
111 | 119 | ||
112 | void TransferDialog::slotCancel() | 120 | void TransferDialog::slotCancel() |
113 | { | 121 | { |
114 | ok->setEnabled(true); | 122 | ok->setEnabled(true); |
115 | 123 | ||
116 | if(transfer) | 124 | if(m_lay) |
117 | { | 125 | { |
118 | transfer->cancel(); | 126 | m_lay->cancel(); |
119 | delete transfer; | 127 | delete m_lay; |
120 | transfer = NULL; | 128 | m_lay = 0l; |
121 | QMessageBox::information(this, | 129 | QMessageBox::information(this, |
122 | QObject::tr("Cancelled"), | 130 | QObject::tr("Cancelled"), |
123 | QObject::tr("The file transfer has been cancelled.")); | 131 | QObject::tr("The file transfer has been cancelled.")); |