summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-13 16:42:36 (UTC)
committer josef <josef>2002-10-13 16:42:36 (UTC)
commit19cf7d4ff5a64aff90e31b29072ce30db6a046ec (patch) (side-by-side diff)
tree9935de353676391f237ebd4e0c0b16d967dee513
parent40e7d87b58e6146944da4613c04bfafc90dbb379 (diff)
downloadopie-19cf7d4ff5a64aff90e31b29072ce30db6a046ec.zip
opie-19cf7d4ff5a64aff90e31b29072ce30db6a046ec.tar.gz
opie-19cf7d4ff5a64aff90e31b29072ce30db6a046ec.tar.bz2
- let metafactory manage new ReceiveLayer objects
- include Receive::SX, ::SY, ::SZ into default.cpp - use metafactory in transferdialog for receive operations too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/default.cpp16
-rw-r--r--noncore/apps/opie-console/default.h4
-rw-r--r--noncore/apps/opie-console/metafactory.cpp23
-rw-r--r--noncore/apps/opie-console/metafactory.h8
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp47
-rw-r--r--noncore/apps/opie-console/transferdialog.h3
6 files changed, 90 insertions, 11 deletions
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
index 4853785..dd9681d 100644
--- a/noncore/apps/opie-console/default.cpp
+++ b/noncore/apps/opie-console/default.cpp
@@ -1,37 +1,49 @@
#include "io_serial.h"
#include "io_irda.h"
#include "io_bt.h"
#include "filetransfer.h"
+#include "filereceive.h"
#include "serialconfigwidget.h"
#include "irdaconfigwidget.h"
#include "btconfigwidget.h"
#include "modemconfigwidget.h"
#include "terminalwidget.h"
#include "vt102emulation.h"
#include "default.h"
extern "C" {
// FILE Transfer Stuff
FileTransferLayer* newSZTransfer(IOLayer* lay) {
return new FileTransfer( FileTransfer::SZ, lay );
}
FileTransferLayer* newSYTransfer(IOLayer* lay) {
return new FileTransfer( FileTransfer::SY, lay );
}
FileTransferLayer* newSXTransfer(IOLayer* lay) {
return new FileTransfer(FileTransfer ::SX, lay );
}
+ // FILE Transfer Receive Stuff
+ ReceiveLayer* newSZReceive(IOLayer* lay) {
+ return new FileReceive( FileReceive::SZ, lay );
+ }
+ ReceiveLayer* newSYReceive(IOLayer* lay) {
+ return new FileReceive( FileReceive::SY, lay );
+ }
+ ReceiveLayer* newSXReceive(IOLayer* lay) {
+ return new FileReceive(FileReceive::SX, lay );
+ }
+
// Layer stuff
IOLayer* newSerialLayer( const Profile& prof) {
return new IOSerial( prof );
}
IOLayer* newBTLayer( const Profile& prof ) {
return new IOBt( prof );
}
IOLayer* newIrDaLayer( const Profile& prof ) {
return new IOIrda( prof );
}
// Connection Widgets
@@ -57,24 +69,28 @@ extern "C" {
// VT Emulations
EmulationLayer* newVT102( WidgetLayer* wid ) {
return new Vt102Emulation( wid );
}
};
Default::Default( MetaFactory* fact ) {
fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer );
fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer );
fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer );
+ fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive );
+ fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive );
+ fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive );
+
fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer );
fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget );
fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 );
diff --git a/noncore/apps/opie-console/default.h b/noncore/apps/opie-console/default.h
index 4d51db8..03616f3 100644
--- a/noncore/apps/opie-console/default.h
+++ b/noncore/apps/opie-console/default.h
@@ -1,24 +1,28 @@
#ifndef OPIE_DEFAULT_H
#define OPIE_DEFAULT_H
#include "metafactory.h"
class Widget;
extern "C" {
FileTransferLayer* newSZTransfer(IOLayer*);
FileTransferLayer* newSYTransfer(IOLayer*);
FileTransferLayer* newSXTransfer(IOLayer*);
+ ReceiveLayer* newSZReceive(IOLayer*);
+ ReceiveLayer* newSYReceive(IOLayer*);
+ ReceiveLayer* newSXReceive(IOLayer*);
+
IOLayer* newSerialLayer(const Profile&);
IOLayer* newBTLayer(const Profile& );
IOLayer* newIrDaLayer(const Profile& );
ProfileDialogWidget* newSerialWidget(const QString&, QWidget* );
ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* );
ProfileDialogWidget* newBTWidget (const QString&, QWidget* );
ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* );
EmulationLayer* newVT102( WidgetLayer* );
};
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 901f29f..09ba586 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -21,24 +21,30 @@ void MetaFactory::addTerminalWidgetFactory( const QCString& name,
void MetaFactory::addIOLayerFactory( const QCString& name,
const QString& str,
iolayer lay) {
m_strings.insert( str, name );
m_layerFact.insert( str, lay );
}
void MetaFactory::addFileTransferLayer( const QCString& name,
const QString& str,
filelayer lay) {
m_strings.insert(str, name );
m_fileFact.insert( str, lay );
}
+void MetaFactory::addReceiveLayer( const QCString& name,
+ const QString& str,
+ receivelayer lay) {
+ m_strings.insert(str, name );
+ m_receiveFact.insert( str, lay );
+}
void MetaFactory::addEmulationLayer( const QCString& name,
const QString& str,
emulationLayer em) {
m_strings.insert(str, name );
m_emu.insert( str, em );
}
QStringList MetaFactory::ioLayers()const {
QStringList list;
QMap<QString, iolayer>::ConstIterator it;
for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
list << it.key();
}
@@ -59,24 +65,32 @@ QStringList MetaFactory::terminalWidgets()const {
list << it.key();
}
return list;
}
QStringList MetaFactory::fileTransferLayers()const {
QStringList list;
QMap<QString, filelayer>::ConstIterator it;
for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
list << it.key();
}
return list;
}
+QStringList MetaFactory::receiveLayers()const {
+ QStringList list;
+ QMap<QString, receivelayer>::ConstIterator it;
+ for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) {
+ list << it.key();
+ }
+ return list;
+}
QStringList MetaFactory::emulationLayers()const {
QStringList list;
QMap<QString, emulationLayer>::ConstIterator it;
for ( it = m_emu.begin(); it != m_emu.end(); ++it ) {
list << it.key();
}
return list;
}
IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
IOLayer* lay = 0l;
@@ -126,23 +140,32 @@ 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;
}
+ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) {
+ ReceiveLayer* file = 0l;
+ QMap<QString, receivelayer>::Iterator it;
+ it = m_receiveFact.find( str );
+ if ( it != m_receiveFact.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 {
QMap<QString, QCString>::ConstIterator it;
for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
if ( it.data() == str )
return it.key();
}
return QString::null;
}
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index 7f0699b..d6aa5e2 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -4,34 +4,36 @@
/**
* The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets
* and to instantiate these implementations on demand
*/
#include <qwidget.h>
#include <qmap.h>
#include <qpe/config.h>
#include "io_layer.h"
#include "file_layer.h"
+#include "receive_layer.h"
#include "profile.h"
#include "profiledialogwidget.h"
#include "emulation_layer.h"
class WidgetLayer;
class MetaFactory {
public:
typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
typedef IOLayer* (*iolayer)(const Profile& );
typedef FileTransferLayer* (*filelayer)(IOLayer*);
+ typedef ReceiveLayer* (*receivelayer)(IOLayer*);
typedef EmulationLayer* (*emulationLayer)(WidgetLayer* );
MetaFactory();
~MetaFactory();
/**
* add a ProfileDialogWidget to the factory
* name is the name shown to the user
*/
void addConnectionWidgetFactory( const QCString& internalName,
const QString& uiString,
configWidget );
@@ -43,65 +45,71 @@ public:
* adds an IOLayer factory
*/
void addIOLayerFactory( const QCString&,
const QString&,
iolayer );
/**
* adds a FileTransfer Layer
*/
void addFileTransferLayer( const QCString& name,
const QString&,
filelayer );
+ void addReceiveLayer( const QCString& name,
+ const QString&,
+ receivelayer);
/**
* adds a Factory for Emulation to the Layer..
*/
void addEmulationLayer ( const QCString& name,
const QString& uiString,
emulationLayer );
/* translated UI Strings */
QStringList ioLayers()const;
QStringList connectionWidgets()const;
/**
* Terminal Configuration widgets
*/
QStringList terminalWidgets()const;
QStringList fileTransferLayers()const;
+ QStringList receiveLayers()const;
QStringList emulationLayers()const;
/**
* the generation...
*/
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* );
+ ReceiveLayer* newReceive(const QString&, IOLayer* );
/*
* internal takes the maybe translated
* public QString and maps it to the internal
* not translatable QCString
*/
QCString internal( const QString& )const;
/*
* external takes the internal name
* it returns a translated name
*/
QString external( const QCString& )const;
private:
QMap<QString, QCString> m_strings;
QMap<QString, configWidget> m_conFact;
QMap<QString, configWidget> m_termFact;
QMap<QString, iolayer> m_layerFact;
QMap<QString, filelayer> m_fileFact;
+ QMap<QString, receivelayer> m_receiveFact;
QMap<QString, emulationLayer> m_emu;
};
#endif
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp
index d3b9c0a..0083cc1 100644
--- a/noncore/apps/opie-console/transferdialog.cpp
+++ b/noncore/apps/opie-console/transferdialog.cpp
@@ -1,35 +1,36 @@
#include <qlayout.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qprogressbar.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <opie/ofiledialog.h>
-#include "filetransfer.h"
-#include "io_serial.h"
+#include "file_layer.h"
+#include "receive_layer.h"
#include "metafactory.h"
#include "mainwindow.h"
#include "transferdialog.h"
TransferDialog::TransferDialog(MainWindow *parent, const char *name)
: QDialog(0l, 0l, true), m_win(parent)
{
m_lay = 0l;
+ m_recvlay = 0l;
QVBoxLayout *vbox, *vbox2;
QHBoxLayout *hbox, *hbox2, *hbox3;
QLabel *file, *mode, *progress, *status;
QButtonGroup *group;
QRadioButton *mode_send, *mode_receive;
group = new QButtonGroup(QObject::tr("Transfer mode"), this);
mode_send = new QRadioButton(QObject::tr("Send"), group);
mode_receive = new QRadioButton(QObject::tr("Receive"), group);
group->insert(mode_send, id_send);
group->insert(mode_receive, id_receive);
vbox2 = new QVBoxLayout(group, 2);
@@ -106,48 +107,65 @@ void TransferDialog::slotTransfer()
{
QMessageBox::information(this,
QObject::tr("Attention"),
QObject::tr("No file has been specified."));
return;
}
ok->setEnabled(false);
if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending..."));
else statusbar->setText(QObject::tr("Receiving..."));
- m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
if(m_transfermode == id_send)
{
+ m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
m_lay->sendFile(filename->text());
+
+ 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()));
}
else
{
- }
+ m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer());
+ m_recvlay->receive();
- 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()));
+ connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)),
+ SLOT(slotProgress(const QString&, int, int, int, int, int)));
+ connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
+ connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&)));
+ }
}
void TransferDialog::slotCancel()
{
ok->setEnabled(true);
statusbar->setText(QObject::tr("Ready"));
- if(m_lay)
+ if((m_lay) || (m_recvlay))
{
- m_lay->cancel();
- delete m_lay;
- m_lay = 0l;
+ if(m_lay)
+ {
+ m_lay->cancel();
+ delete m_lay;
+ m_lay = 0l;
+ }
+ if(m_recvlay)
+ {
+ m_recvlay->cancel();
+ delete m_recvlay;
+ m_recvlay = 0l;
+ }
QMessageBox::information(this,
QObject::tr("Cancelled"),
QObject::tr("The file transfer has been cancelled."));
}
else
{
close();
}
}
void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds)
{
@@ -192,24 +210,31 @@ void TransferDialog::slotError(int error, const QString& message)
QObject::tr("Unknown error occured."));
break;
}
}
void TransferDialog::slotSent()
{
QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent."));
ok->setEnabled(true);
statusbar->setText(QObject::tr("Ready"));
}
+void TransferDialog::slotReceived(const QString& file)
+{
+ QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file));
+ ok->setEnabled(true);
+ statusbar->setText(QObject::tr("Ready"));
+}
+
void TransferDialog::slotMode(int id)
{
if(id == id_send)
{
selector->setEnabled(true);
filename->setEnabled(true);
}
else
{
selector->setEnabled(false);
filename->setEnabled(false);
}
diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h
index a567161..de3a5cf 100644
--- a/noncore/apps/opie-console/transferdialog.h
+++ b/noncore/apps/opie-console/transferdialog.h
@@ -1,48 +1,51 @@
#ifndef TRANSFER_DIALOG_H
#define TRANSFER_DIALOG_H
#include "qdialog.h"
class QLineEdit;
class QComboBox;
class QProgressBar;
class QLabel;
class QPushButton;
class MainWindow;
class FileTransferLayer;
+class ReceiveLayer;
class TransferDialog : public QDialog
{
Q_OBJECT
public:
TransferDialog(MainWindow *parent = 0l, const char *name = 0l);
~TransferDialog();
public slots:
void slotFilename();
void slotTransfer();
void slotCancel();
void slotProgress(const QString&, int, int, int, int, int);
void slotError(int error, const QString& message);
void slotSent();
+ void slotReceived(const QString& file);
void slotMode(int id);
private:
enum Modes
{
id_send,
id_receive
};
QLineEdit *filename;
QComboBox *protocol;
QProgressBar *progressbar;
QLabel *statusbar;
QPushButton *ok, *cancel, *selector;
MainWindow* m_win;
FileTransferLayer* m_lay;
+ ReceiveLayer *m_recvlay;
int m_transfermode;
};
#endif