author | josef <josef> | 2002-10-12 19:27:15 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-12 19:27:15 (UTC) |
commit | 63fb25f130c9ec82646165c6d35d502d5929bbe8 (patch) (unidiff) | |
tree | 1f5c1da7d9e183f76f15272704c605b19ad0d6fa | |
parent | 82b04543125d6d856df180c437c8d9f95f41e888 (diff) | |
download | opie-63fb25f130c9ec82646165c6d35d502d5929bbe8.zip opie-63fb25f130c9ec82646165c6d35d502d5929bbe8.tar.gz opie-63fb25f130c9ec82646165c6d35d502d5929bbe8.tar.bz2 |
- my bad: FileTransfer inherits from the layer -> there are the signals :)
- setup sig handlers for sent(), progress(), error()
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 53 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 3 |
2 files changed, 55 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index 45522a8..d639de6 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -89,27 +89,29 @@ void TransferDialog::slotTransfer() | |||
89 | QObject::tr("Attention"), | 89 | QObject::tr("Attention"), |
90 | QObject::tr("No file has been specified.")); | 90 | QObject::tr("No file has been specified.")); |
91 | return; | 91 | return; |
92 | } | 92 | } |
93 | 93 | ||
94 | ok->setEnabled(false); | 94 | ok->setEnabled(false); |
95 | 95 | ||
96 | statusbar->setText(QObject::tr("Sending...")); | 96 | statusbar->setText(QObject::tr("Sending...")); |
97 | progressbar->setProgress(1); | ||
98 | 97 | ||
99 | FileTransfer::Type transfermode = FileTransfer::SX; | 98 | FileTransfer::Type transfermode = FileTransfer::SX; |
100 | if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY; | 99 | if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY; |
101 | if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ; | 100 | if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ; |
102 | 101 | ||
103 | // dummy profile | 102 | // dummy profile |
104 | Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102); | 103 | Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102); |
105 | 104 | ||
106 | transfer = new FileTransfer(transfermode, new IOSerial(profile)); | 105 | transfer = new FileTransfer(transfermode, new IOSerial(profile)); |
107 | transfer->sendFile(filename->text()); | 106 | transfer->sendFile(filename->text()); |
107 | connect(transfer, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); | ||
108 | connect(transfer, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | ||
109 | connect(transfer, SIGNAL(sent()), SLOT(slotSent())); | ||
108 | } | 110 | } |
109 | 111 | ||
110 | void TransferDialog::slotCancel() | 112 | void TransferDialog::slotCancel() |
111 | { | 113 | { |
112 | ok->setEnabled(true); | 114 | ok->setEnabled(true); |
113 | 115 | ||
114 | if(transfer) | 116 | if(transfer) |
115 | { | 117 | { |
@@ -121,8 +123,57 @@ void TransferDialog::slotCancel() | |||
121 | QObject::tr("The file transfer has been cancelled.")); | 123 | QObject::tr("The file transfer has been cancelled.")); |
122 | } | 124 | } |
123 | else | 125 | else |
124 | { | 126 | { |
125 | close(); | 127 | close(); |
126 | } | 128 | } |
127 | } | 129 | } |
128 | 130 | ||
131 | void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) | ||
132 | { | ||
133 | progressbar->setProgress(progress); | ||
134 | } | ||
135 | |||
136 | void TransferDialog::slotError(int error, const QString& message) | ||
137 | { | ||
138 | switch(error) | ||
139 | { | ||
140 | case FileTransferLayer::NotSupported: | ||
141 | QMessageBox::critical(this, | ||
142 | QObject::tr("Error"), | ||
143 | QObject::tr("Operation not supported.")); | ||
144 | break; | ||
145 | case FileTransferLayer::StartError: | ||
146 | QMessageBox::critical(this, | ||
147 | QObject::tr("Error"), | ||
148 | QObject::tr("Operation not supported.")); | ||
149 | break; | ||
150 | case FileTransferLayer::NoError: | ||
151 | QMessageBox::critical(this, | ||
152 | QObject::tr("Error"), | ||
153 | QObject::tr("Operation not supported.")); | ||
154 | break; | ||
155 | case FileTransferLayer::Undefined: | ||
156 | QMessageBox::critical(this, | ||
157 | QObject::tr("Error"), | ||
158 | QObject::tr("Operation not supported.")); | ||
159 | break; | ||
160 | case FileTransferLayer::Incomplete: | ||
161 | QMessageBox::critical(this, | ||
162 | QObject::tr("Error"), | ||
163 | QObject::tr("Operation not supported.")); | ||
164 | break; | ||
165 | case FileTransferLayer::Unknown: | ||
166 | default: | ||
167 | QMessageBox::critical(this, | ||
168 | QObject::tr("Error"), | ||
169 | QObject::tr("Operation not supported.")); | ||
170 | break; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | void TransferDialog::slotSent() | ||
175 | { | ||
176 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); | ||
177 | ok->setEnabled(true); | ||
178 | } | ||
179 | |||
diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h index 62ae14d..61f425c 100644 --- a/noncore/apps/opie-console/transferdialog.h +++ b/noncore/apps/opie-console/transferdialog.h | |||
@@ -16,16 +16,19 @@ class TransferDialog : public QDialog | |||
16 | public: | 16 | public: |
17 | TransferDialog(QWidget *parent = NULL, const char *name = NULL); | 17 | TransferDialog(QWidget *parent = NULL, const char *name = NULL); |
18 | ~TransferDialog(); | 18 | ~TransferDialog(); |
19 | 19 | ||
20 | public slots: | 20 | public slots: |
21 | void slotFilename(); | 21 | void slotFilename(); |
22 | void slotTransfer(); | 22 | void slotTransfer(); |
23 | void slotCancel(); | 23 | void slotCancel(); |
24 | void slotProgress(const QString&, int, int, int, int, int); | ||
25 | void slotError(int error, const QString& message); | ||
26 | void slotSent(); | ||
24 | 27 | ||
25 | private: | 28 | private: |
26 | QLineEdit *filename; | 29 | QLineEdit *filename; |
27 | QComboBox *protocol; | 30 | QComboBox *protocol; |
28 | QProgressBar *progressbar; | 31 | QProgressBar *progressbar; |
29 | QLabel *statusbar; | 32 | QLabel *statusbar; |
30 | QPushButton *ok, *cancel; | 33 | QPushButton *ok, *cancel; |
31 | FileTransfer *transfer; | 34 | FileTransfer *transfer; |