summaryrefslogtreecommitdiff
path: root/noncore
authorzecke <zecke>2002-10-12 21:18:46 (UTC)
committer zecke <zecke>2002-10-12 21:18:46 (UTC)
commit9b33ff5f74c30a5a4905093715a6f345edee26ab (patch) (side-by-side diff)
treeeb0155744adb8c0901e27e001c7e09fc8c789369 /noncore
parent3eb9678dfab4d152858b7f72c7f0c057fe393541 (diff)
downloadopie-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..
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp3
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp2
-rw-r--r--noncore/apps/opie-console/metafactory.cpp9
-rw-r--r--noncore/apps/opie-console/metafactory.h1
-rw-r--r--noncore/apps/opie-console/test/senderui.cpp2
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp70
-rw-r--r--noncore/apps/opie-console/transferdialog.h8
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
@@ -191,6 +191,8 @@ 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;
@@ -242,6 +244,7 @@ void FileTransfer::slotExec() {
::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] );
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
@@ -226,8 +226,10 @@ 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
@@ -126,6 +126,15 @@ 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];
}
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
@@ -78,6 +78,7 @@ public:
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
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
@@ -40,7 +40,7 @@ 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()),
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,27 +1,35 @@
-#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);
@@ -32,9 +40,14 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name)
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);
@@ -76,7 +89,7 @@ TransferDialog::~TransferDialog()
void TransferDialog::slotFilename()
{
QString f;
-
+
f = OFileDialog::getOpenFileName(0);
if(!f.isNull()) filename->setText(f);
}
@@ -95,29 +108,24 @@ void TransferDialog::slotTransfer()
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
@@ -8,13 +8,14 @@ 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:
@@ -31,7 +32,8 @@ class TransferDialog : public QDialog
QProgressBar *progressbar;
QLabel *statusbar;
QPushButton *ok, *cancel;
- FileTransfer *transfer;
+ MainWindow* m_win;
+ FileTransferLayer* m_lay;
};
#endif