summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -10,12 +10,13 @@
#include "default.h"
#include "metafactory.h"
#include "profile.h"
#include "profilemanager.h"
#include "mainwindow.h"
#include "tabwidget.h"
+#include "transferdialog.h"
MainWindow::MainWindow() {
m_factory = new MetaFactory();
Default def(m_factory);
m_sessions.setAutoDelete( TRUE );
m_curSession = 0;
@@ -60,12 +61,18 @@ void MainWindow::initUI() {
m_disconnect = new QAction();
m_disconnect->setText( tr("Disconnect") );
m_disconnect->addTo( m_console );
connect(m_disconnect, SIGNAL(activated() ),
this, SLOT(slotDisconnect() ) );
+ m_transfer = new QAction();
+ m_transfer->setText( tr("Transfer file...") );
+ m_transfer->addTo( m_console );
+ connect(m_transfer, SIGNAL(activated() ),
+ this, SLOT(slotTransfer() ) );
+
/*
* terminate action
*/
m_terminate = new QAction();
m_terminate->setText( tr("Terminate") );
m_terminate->addTo( m_console );
@@ -211,7 +218,16 @@ void MainWindow::slotProfile( int id) {
void MainWindow::create( const Profile& prof ) {
Session *ses = manager()->fromProfile( prof, tabWidget() );
m_sessions.append( ses );
tabWidget()->add( ses );
m_curSession = ses;
+
}
+
+void MainWindow::slotTransfer()
+{
+ TransferDialog dlg(this);
+ dlg.showMaximized();
+ dlg.exec();
+}
+
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
@@ -52,12 +52,13 @@ private slots:
void slotConnect();
void slotDisconnect();
void slotTerminate();
void slotConfigure();
void slotClose();
void slotProfile(int);
+ void slotTransfer();
private:
void initUI();
void populateProfiles();
void create( const Profile& );
/**
@@ -82,12 +83,13 @@ private:
QPopupMenu* m_console;
QPopupMenu* m_settings;
QPopupMenu* m_sessionsPop;
QAction* m_connect;
QAction* m_disconnect;
QAction* m_terminate;
+ QAction* m_transfer;
QAction* m_setProfiles;
};
#endif
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,25 +1,30 @@
#include "transferdialog.h"
+#include "filetransfer.h"
+#include "io_serial.h"
+
#include "qlayout.h"
#include "qcombobox.h"
#include "qlabel.h"
#include "qlineedit.h"
#include "qpushbutton.h"
#include "qmessagebox.h"
#include "qprogressbar.h"
#include "opie/ofiledialog.h"
TransferDialog::TransferDialog(QWidget *parent, const char *name)
-: QWidget(parent, name)
+: QDialog(/*parent, name*/NULL, NULL, true)
{
QVBoxLayout *vbox;
QHBoxLayout *hbox, *hbox2;
QLabel *file, *mode, *progress, *status;
- QPushButton *selector, *ok, *cancel;
+ QPushButton *selector;
+
+ transfer = NULL;
file = new QLabel(QObject::tr("Send file"), this);
mode = new QLabel(QObject::tr("Transfer mode"), this);
progress = new QLabel(QObject::tr("Progress"), this);
status = new QLabel(QObject::tr("Status"), this);
@@ -34,13 +39,13 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name)
filename = new QLineEdit(this);
progressbar = new QProgressBar(this);
progressbar->setProgress(0);
selector = new QPushButton("...", this);
- ok = new QPushButton(QObject::tr("OK"), this);
+ ok = new QPushButton(QObject::tr("Start transfer"), this);
cancel = new QPushButton(QObject::tr("Cancel"), this);
vbox = new QVBoxLayout(this, 2);
vbox->add(file);
hbox = new QHBoxLayout(vbox, 0);
hbox->add(filename);
@@ -58,13 +63,13 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name)
setCaption(QObject::tr("File transfer"));
show();
connect(selector, SIGNAL(clicked()), SLOT(slotFilename()));
connect(ok, SIGNAL(clicked()), SLOT(slotTransfer()));
- connect(cancel, SIGNAL(clicked()), SLOT(close()));
+ connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
}
TransferDialog::~TransferDialog()
{
}
@@ -83,10 +88,41 @@ void TransferDialog::slotTransfer()
QMessageBox::information(this,
QObject::tr("Attention"),
QObject::tr("No file has been specified."));
return;
}
+ ok->setEnabled(false);
+
statusbar->setText(QObject::tr("Sending..."));
progressbar->setProgress(1);
+
+ FileTransfer::Type transfermode = FileTransfer::SX;
+ if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY;
+ if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ;
+
+ // dummy profile
+ Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102);
+
+ transfer = new FileTransfer(transfermode, new IOSerial(profile));
+ transfer->sendFile(filename->text());
+}
+
+void TransferDialog::slotCancel()
+{
+ ok->setEnabled(true);
+
+ if(transfer)
+ {
+ transfer->cancel();
+ delete transfer;
+ transfer = NULL;
+ QMessageBox::information(this,
+ QObject::tr("Cancelled"),
+ QObject::tr("The file transfer has been cancelled."));
+ }
+ else
+ {
+ close();
+ }
}
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,30 +1,35 @@
#ifndef TRANSFER_DIALOG_H
#define TRANSFER_DIALOG_H
-#include "qwidget.h"
+#include "qdialog.h"
class QLineEdit;
class QComboBox;
class QProgressBar;
class QLabel;
+class QPushButton;
+class FileTransfer;
-class TransferDialog : public QWidget
+class TransferDialog : public QDialog
{
Q_OBJECT
public:
TransferDialog(QWidget *parent = NULL, const char *name = NULL);
~TransferDialog();
public slots:
void slotFilename();
void slotTransfer();
+ void slotCancel();
private:
QLineEdit *filename;
QComboBox *protocol;
QProgressBar *progressbar;
QLabel *statusbar;
+ QPushButton *ok, *cancel;
+ FileTransfer *transfer;
};
#endif