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,49 +1,62 @@ | |||
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); |
28 | progress = new QLabel(QObject::tr("Progress"), this); | 36 | progress = new QLabel(QObject::tr("Progress"), this); |
29 | status = new QLabel(QObject::tr("Status"), this); | 37 | status = new QLabel(QObject::tr("Status"), this); |
30 | 38 | ||
31 | statusbar = new QLabel(QObject::tr("ready"), this); | 39 | statusbar = new QLabel(QObject::tr("ready"), this); |
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 | ||
41 | progressbar = new QProgressBar(this); | 54 | progressbar = new QProgressBar(this); |
42 | progressbar->setProgress(0); | 55 | progressbar->setProgress(0); |
43 | 56 | ||
44 | selector = new QPushButton("...", this); | 57 | selector = new QPushButton("...", this); |
45 | ok = new QPushButton(QObject::tr("Start transfer"), this); | 58 | ok = new QPushButton(QObject::tr("Start transfer"), this); |
46 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 59 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
47 | 60 | ||
48 | vbox = new QVBoxLayout(this, 2); | 61 | vbox = new QVBoxLayout(this, 2); |
49 | vbox->add(file); | 62 | vbox->add(file); |
@@ -67,66 +80,61 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name) | |||
67 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); | 80 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); |
68 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); | 81 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); |
69 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); | 82 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); |
70 | } | 83 | } |
71 | 84 | ||
72 | TransferDialog::~TransferDialog() | 85 | TransferDialog::~TransferDialog() |
73 | { | 86 | { |
74 | } | 87 | } |
75 | 88 | ||
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 | } |
83 | 96 | ||
84 | void TransferDialog::slotTransfer() | 97 | void TransferDialog::slotTransfer() |
85 | { | 98 | { |
86 | if(filename->text().isEmpty()) | 99 | if(filename->text().isEmpty()) |
87 | { | 100 | { |
88 | QMessageBox::information(this, | 101 | QMessageBox::information(this, |
89 | QObject::tr("Attention"), | 102 | QObject::tr("Attention"), |
90 | QObject::tr("No file has been specified.")); | 103 | QObject::tr("No file has been specified.")); |
91 | return; | 104 | return; |
92 | } | 105 | } |
93 | 106 | ||
94 | ok->setEnabled(false); | 107 | ok->setEnabled(false); |
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.")); |
124 | } | 132 | } |
125 | else | 133 | else |
126 | { | 134 | { |
127 | close(); | 135 | close(); |
128 | } | 136 | } |
129 | } | 137 | } |
130 | 138 | ||
131 | void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) | 139 | void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) |
132 | { | 140 | { |