summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp16
-rw-r--r--noncore/apps/opie-console/mainwindow.h2
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp44
-rw-r--r--noncore/apps/opie-console/transferdialog.h9
4 files changed, 65 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 0bd6a13..fbeaa74 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -13,6 +13,7 @@
13#include "profilemanager.h" 13#include "profilemanager.h"
14#include "mainwindow.h" 14#include "mainwindow.h"
15#include "tabwidget.h" 15#include "tabwidget.h"
16#include "transferdialog.h"
16 17
17MainWindow::MainWindow() { 18MainWindow::MainWindow() {
18 m_factory = new MetaFactory(); 19 m_factory = new MetaFactory();
@@ -63,6 +64,12 @@ void MainWindow::initUI() {
63 connect(m_disconnect, SIGNAL(activated() ), 64 connect(m_disconnect, SIGNAL(activated() ),
64 this, SLOT(slotDisconnect() ) ); 65 this, SLOT(slotDisconnect() ) );
65 66
67 m_transfer = new QAction();
68 m_transfer->setText( tr("Transfer file...") );
69 m_transfer->addTo( m_console );
70 connect(m_transfer, SIGNAL(activated() ),
71 this, SLOT(slotTransfer() ) );
72
66 /* 73 /*
67 * terminate action 74 * terminate action
68 */ 75 */
@@ -214,4 +221,13 @@ void MainWindow::create( const Profile& prof ) {
214 m_sessions.append( ses ); 221 m_sessions.append( ses );
215 tabWidget()->add( ses ); 222 tabWidget()->add( ses );
216 m_curSession = ses; 223 m_curSession = ses;
224
217} 225}
226
227void MainWindow::slotTransfer()
228{
229 TransferDialog dlg(this);
230 dlg.showMaximized();
231 dlg.exec();
232}
233
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 7ef9c26..c8b0b65 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -55,6 +55,7 @@ private slots:
55 void slotConfigure(); 55 void slotConfigure();
56 void slotClose(); 56 void slotClose();
57 void slotProfile(int); 57 void slotProfile(int);
58 void slotTransfer();
58 59
59private: 60private:
60 void initUI(); 61 void initUI();
@@ -85,6 +86,7 @@ private:
85 QAction* m_connect; 86 QAction* m_connect;
86 QAction* m_disconnect; 87 QAction* m_disconnect;
87 QAction* m_terminate; 88 QAction* m_terminate;
89 QAction* m_transfer;
88 QAction* m_setProfiles; 90 QAction* m_setProfiles;
89 91
90}; 92};
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,5 +1,8 @@
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"
@@ -11,12 +14,14 @@
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);
@@ -37,7 +42,7 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name)
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);
@@ -61,7 +66,7 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name)
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()
@@ -86,7 +91,38 @@ void TransferDialog::slotTransfer()
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
diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h
index 4fe17dd..62ae14d 100644
--- a/noncore/apps/opie-console/transferdialog.h
+++ b/noncore/apps/opie-console/transferdialog.h
@@ -1,14 +1,16 @@
1#ifndef TRANSFER_DIALOG_H 1#ifndef TRANSFER_DIALOG_H
2#define TRANSFER_DIALOG_H 2#define TRANSFER_DIALOG_H
3 3
4#include "qwidget.h" 4#include "qdialog.h"
5 5
6class QLineEdit; 6class QLineEdit;
7class QComboBox; 7class QComboBox;
8class QProgressBar; 8class QProgressBar;
9class QLabel; 9class QLabel;
10class QPushButton;
11class FileTransfer;
10 12
11class TransferDialog : public QWidget 13class TransferDialog : public QDialog
12{ 14{
13 Q_OBJECT 15 Q_OBJECT
14 public: 16 public:
@@ -18,12 +20,15 @@ class TransferDialog : public QWidget
18 public slots: 20 public slots:
19 void slotFilename(); 21 void slotFilename();
20 void slotTransfer(); 22 void slotTransfer();
23 void slotCancel();
21 24
22 private: 25 private:
23 QLineEdit *filename; 26 QLineEdit *filename;
24 QComboBox *protocol; 27 QComboBox *protocol;
25 QProgressBar *progressbar; 28 QProgressBar *progressbar;
26 QLabel *statusbar; 29 QLabel *statusbar;
30 QPushButton *ok, *cancel;
31 FileTransfer *transfer;
27}; 32};
28 33
29#endif 34#endif