author | zecke <zecke> | 2002-10-12 21:18:46 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-12 21:18:46 (UTC) |
commit | 9b33ff5f74c30a5a4905093715a6f345edee26ab (patch) (side-by-side diff) | |
tree | eb0155744adb8c0901e27e001c7e09fc8c789369 | |
parent | 3eb9678dfab4d152858b7f72c7f0c057fe393541 (diff) | |
download | opie-9b33ff5f74c30a5a4905093715a6f345edee26ab.zip opie-9b33ff5f74c30a5a4905093715a6f345edee26ab.tar.gz opie-9b33ff5f74c30a5a4905093715a6f345edee26ab.tar.bz2 |
Calmed down... 2nd try after merge
Use MetaFactory cuase it's so nice and avoids thousands of if() else if
stuff
Fix a bug in filetransfer where cancel after exit leaded to a crash cause
of bogus adresses in the QSocketNotifiers..
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/senderui.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 70 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 8 |
7 files changed, 60 insertions, 35 deletions
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index b39dc95..8e86ebb 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp @@ -190,8 +190,10 @@ void FileTransfer::slotRead() { /* * find the progress */ void FileTransfer::slotProgress( const QStringList& list ) { + if ( m_type != SZ ) + return; bool complete = true; int min, sec; int bps; unsigned long sent, total; @@ -241,8 +243,9 @@ void FileTransfer::slotExec() { char buf[2]; ::read(m_term[0], buf, 1 ); delete m_proc; delete m_not; + m_proc = m_not = 0l; close( m_term[0] ); close( m_term[1] ); close( m_comm[0] ); close( m_comm[1] ); diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index fbeaa74..88727e4 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -225,9 +225,11 @@ void MainWindow::create( const Profile& prof ) { } void MainWindow::slotTransfer() { + if ( currentSession() ) { TransferDialog dlg(this); dlg.showMaximized(); dlg.exec(); + } } diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 2b672cf..901f29f 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp @@ -125,8 +125,17 @@ EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* } return lay; } +FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { + FileTransferLayer* file = 0l; + QMap<QString, filelayer>::Iterator it; + it = m_fileFact.find( str ); + if ( it != m_fileFact.end() ) { + file = (*(it.data() ) )(lay); + } + return file; +} QCString MetaFactory::internal( const QString& str )const { return m_strings[str]; } QString MetaFactory::external( const QCString& str )const { diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index d05ece4..7f0699b 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h @@ -77,8 +77,9 @@ public: IOLayer* newIOLayer( const QString&,const Profile& ); ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* ); + FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); /* * internal takes the maybe translated * public QString and maps it to the internal diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp index 3e0bd65..8bc1676 100644 --- a/noncore/apps/opie-console/test/senderui.cpp +++ b/noncore/apps/opie-console/test/senderui.cpp @@ -39,9 +39,9 @@ SenderUI::~SenderUI() { } void SenderUI::slotSendFile() { - sz = new FileTransfer(FileTransfer::SZ, ser); + sz = new FileTransfer(FileTransfer::SY, ser); sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); connect (sz, SIGNAL(sent()), this, SLOT(fileTransComplete())); 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,28 +1,36 @@ -#include "transferdialog.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> #include "filetransfer.h" #include "io_serial.h" +#include "metafactory.h" +#include "mainwindow.h" + +#include "transferdialog.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) -: QDialog(/*parent, name*/NULL, NULL, true) + + + +TransferDialog::TransferDialog(MainWindow *parent, const char *name) +: QDialog(/*parent, name*/0l, 0l, true), m_win(parent) { + m_lay = 0l; QVBoxLayout *vbox; QHBoxLayout *hbox, *hbox2; QLabel *file, *mode, *progress, *status; 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); @@ -31,11 +39,16 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name) statusbar = new QLabel(QObject::tr("ready"), this); statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); protocol = new QComboBox(this); - protocol->insertItem("XModem"); - protocol->insertItem("YModem"); - protocol->insertItem("ZModem"); + /* use the fscking MetaFactory + * because we invented it for that fscking reason + * I'm really getting UPSET!!!! + */ + QStringList list = m_win->factory()->fileTransferLayers(); + for (QStringList::Iterator it =list.begin(); it != list.end(); ++it ) { + protocol->insertItem( (*it) ); + } filename = new QLineEdit(this); progressbar = new QProgressBar(this); @@ -75,9 +88,9 @@ TransferDialog::~TransferDialog() void TransferDialog::slotFilename() { QString f; - + f = OFileDialog::getOpenFileName(0); if(!f.isNull()) filename->setText(f); } @@ -94,31 +107,26 @@ void TransferDialog::slotTransfer() ok->setEnabled(false); statusbar->setText(QObject::tr("Sending...")); - 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); + m_lay = m_win->factory()->newFileTransfer( protocol->currentText(), + m_win->currentSession()->layer() ); + m_lay->sendFile(filename->text()); - transfer = new FileTransfer(transfermode, new IOSerial(profile)); - transfer->sendFile(filename->text()); - connect(transfer, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); - connect(transfer, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); - connect(transfer, SIGNAL(sent()), SLOT(slotSent())); + connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); + connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); + connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); } void TransferDialog::slotCancel() { ok->setEnabled(true); - if(transfer) + if(m_lay) { - transfer->cancel(); - delete transfer; - transfer = NULL; + m_lay->cancel(); + delete m_lay; + m_lay = 0l; QMessageBox::information(this, QObject::tr("Cancelled"), QObject::tr("The file transfer has been cancelled.")); } diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h index 61f425c..b0c1a76 100644 --- a/noncore/apps/opie-console/transferdialog.h +++ b/noncore/apps/opie-console/transferdialog.h @@ -7,15 +7,16 @@ class QLineEdit; class QComboBox; class QProgressBar; class QLabel; class QPushButton; -class FileTransfer; +class MainWindow; +class FileTransferLayer; class TransferDialog : public QDialog { Q_OBJECT public: - TransferDialog(QWidget *parent = NULL, const char *name = NULL); + TransferDialog(MainWindow *parent = 0l, const char *name = 0l); ~TransferDialog(); public slots: void slotFilename(); @@ -30,9 +31,10 @@ class TransferDialog : public QDialog QComboBox *protocol; QProgressBar *progressbar; QLabel *statusbar; QPushButton *ok, *cancel; - FileTransfer *transfer; + MainWindow* m_win; + FileTransferLayer* m_lay; }; #endif |