summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/transferdialog.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/transferdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp
index 08fb32b..45522a8 100644
--- a/noncore/apps/opie-console/transferdialog.cpp
+++ b/noncore/apps/opie-console/transferdialog.cpp
@@ -1,92 +1,128 @@
1#include "transferdialog.h" 1#include "transferdialog.h"
2 2
3#include "filetransfer.h"
4#include "io_serial.h"
5
3#include "qlayout.h" 6#include "qlayout.h"
4#include "qcombobox.h" 7#include "qcombobox.h"
5#include "qlabel.h" 8#include "qlabel.h"
6#include "qlineedit.h" 9#include "qlineedit.h"
7#include "qpushbutton.h" 10#include "qpushbutton.h"
8#include "qmessagebox.h" 11#include "qmessagebox.h"
9#include "qprogressbar.h" 12#include "qprogressbar.h"
10 13
11#include "opie/ofiledialog.h" 14#include "opie/ofiledialog.h"
12 15
13TransferDialog::TransferDialog(QWidget *parent, const char *name) 16TransferDialog::TransferDialog(QWidget *parent, const char *name)
14: QWidget(parent, name) 17: QDialog(/*parent, name*/NULL, NULL, true)
15{ 18{
16 QVBoxLayout *vbox; 19 QVBoxLayout *vbox;
17 QHBoxLayout *hbox, *hbox2; 20 QHBoxLayout *hbox, *hbox2;
18 QLabel *file, *mode, *progress, *status; 21 QLabel *file, *mode, *progress, *status;
19 QPushButton *selector, *ok, *cancel; 22 QPushButton *selector;
23
24 transfer = NULL;
20 25
21 file = new QLabel(QObject::tr("Send file"), this); 26 file = new QLabel(QObject::tr("Send file"), this);
22 mode = new QLabel(QObject::tr("Transfer mode"), this); 27 mode = new QLabel(QObject::tr("Transfer mode"), this);
23 progress = new QLabel(QObject::tr("Progress"), this); 28 progress = new QLabel(QObject::tr("Progress"), this);
24 status = new QLabel(QObject::tr("Status"), this); 29 status = new QLabel(QObject::tr("Status"), this);
25 30
26 statusbar = new QLabel(QObject::tr("ready"), this); 31 statusbar = new QLabel(QObject::tr("ready"), this);
27 statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); 32 statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
28 33
29 protocol = new QComboBox(this); 34 protocol = new QComboBox(this);
30 protocol->insertItem("XModem"); 35 protocol->insertItem("XModem");
31 protocol->insertItem("YModem"); 36 protocol->insertItem("YModem");
32 protocol->insertItem("ZModem"); 37 protocol->insertItem("ZModem");
33 38
34 filename = new QLineEdit(this); 39 filename = new QLineEdit(this);
35 40
36 progressbar = new QProgressBar(this); 41 progressbar = new QProgressBar(this);
37 progressbar->setProgress(0); 42 progressbar->setProgress(0);
38 43
39 selector = new QPushButton("...", this); 44 selector = new QPushButton("...", this);
40 ok = new QPushButton(QObject::tr("OK"), this); 45 ok = new QPushButton(QObject::tr("Start transfer"), this);
41 cancel = new QPushButton(QObject::tr("Cancel"), this); 46 cancel = new QPushButton(QObject::tr("Cancel"), this);
42 47
43 vbox = new QVBoxLayout(this, 2); 48 vbox = new QVBoxLayout(this, 2);
44 vbox->add(file); 49 vbox->add(file);
45 hbox = new QHBoxLayout(vbox, 0); 50 hbox = new QHBoxLayout(vbox, 0);
46 hbox->add(filename); 51 hbox->add(filename);
47 hbox->add(selector); 52 hbox->add(selector);
48 vbox->add(mode); 53 vbox->add(mode);
49 vbox->add(protocol); 54 vbox->add(protocol);
50 vbox->add(progress); 55 vbox->add(progress);
51 vbox->add(progressbar); 56 vbox->add(progressbar);
52 vbox->add(status); 57 vbox->add(status);
53 vbox->add(statusbar); 58 vbox->add(statusbar);
54 vbox->addStretch(1); 59 vbox->addStretch(1);
55 hbox2 = new QHBoxLayout(vbox, 2); 60 hbox2 = new QHBoxLayout(vbox, 2);
56 hbox2->add(ok); 61 hbox2->add(ok);
57 hbox2->add(cancel); 62 hbox2->add(cancel);
58 63
59 setCaption(QObject::tr("File transfer")); 64 setCaption(QObject::tr("File transfer"));
60 show(); 65 show();
61 66
62 connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); 67 connect(selector, SIGNAL(clicked()), SLOT(slotFilename()));
63 connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); 68 connect(ok, SIGNAL(clicked()), SLOT(slotTransfer()));
64 connect(cancel, SIGNAL(clicked()), SLOT(close())); 69 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
65} 70}
66 71
67TransferDialog::~TransferDialog() 72TransferDialog::~TransferDialog()
68{ 73{
69} 74}
70 75
71void TransferDialog::slotFilename() 76void TransferDialog::slotFilename()
72{ 77{
73 QString f; 78 QString f;
74 79
75 f = OFileDialog::getOpenFileName(0); 80 f = OFileDialog::getOpenFileName(0);
76 if(!f.isNull()) filename->setText(f); 81 if(!f.isNull()) filename->setText(f);
77} 82}
78 83
79void TransferDialog::slotTransfer() 84void TransferDialog::slotTransfer()
80{ 85{
81 if(filename->text().isEmpty()) 86 if(filename->text().isEmpty())
82 { 87 {
83 QMessageBox::information(this, 88 QMessageBox::information(this,
84 QObject::tr("Attention"), 89 QObject::tr("Attention"),
85 QObject::tr("No file has been specified.")); 90 QObject::tr("No file has been specified."));
86 return; 91 return;
87 } 92 }
88 93
94 ok->setEnabled(false);
95
89 statusbar->setText(QObject::tr("Sending...")); 96 statusbar->setText(QObject::tr("Sending..."));
90 progressbar->setProgress(1); 97 progressbar->setProgress(1);
98
99 FileTransfer::Type transfermode = FileTransfer::SX;
100 if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY;
101 if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ;
102
103 // dummy profile
104 Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102);
105
106 transfer = new FileTransfer(transfermode, new IOSerial(profile));
107 transfer->sendFile(filename->text());
108}
109
110void TransferDialog::slotCancel()
111{
112 ok->setEnabled(true);
113
114 if(transfer)
115 {
116 transfer->cancel();
117 delete transfer;
118 transfer = NULL;
119 QMessageBox::information(this,
120 QObject::tr("Cancelled"),
121 QObject::tr("The file transfer has been cancelled."));
122 }
123 else
124 {
125 close();
126 }
91} 127}
92 128