summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-13 16:42:36 (UTC)
committer josef <josef>2002-10-13 16:42:36 (UTC)
commit19cf7d4ff5a64aff90e31b29072ce30db6a046ec (patch) (unidiff)
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,84 +1,100 @@
1#include "io_serial.h" 1#include "io_serial.h"
2#include "io_irda.h" 2#include "io_irda.h"
3#include "io_bt.h" 3#include "io_bt.h"
4#include "filetransfer.h" 4#include "filetransfer.h"
5#include "filereceive.h"
5#include "serialconfigwidget.h" 6#include "serialconfigwidget.h"
6#include "irdaconfigwidget.h" 7#include "irdaconfigwidget.h"
7#include "btconfigwidget.h" 8#include "btconfigwidget.h"
8#include "modemconfigwidget.h" 9#include "modemconfigwidget.h"
9#include "terminalwidget.h" 10#include "terminalwidget.h"
10#include "vt102emulation.h" 11#include "vt102emulation.h"
11 12
12#include "default.h" 13#include "default.h"
13 14
14extern "C" { 15extern "C" {
15 // FILE Transfer Stuff 16 // FILE Transfer Stuff
16 FileTransferLayer* newSZTransfer(IOLayer* lay) { 17 FileTransferLayer* newSZTransfer(IOLayer* lay) {
17 return new FileTransfer( FileTransfer::SZ, lay ); 18 return new FileTransfer( FileTransfer::SZ, lay );
18 } 19 }
19 FileTransferLayer* newSYTransfer(IOLayer* lay) { 20 FileTransferLayer* newSYTransfer(IOLayer* lay) {
20 return new FileTransfer( FileTransfer::SY, lay ); 21 return new FileTransfer( FileTransfer::SY, lay );
21 } 22 }
22 FileTransferLayer* newSXTransfer(IOLayer* lay) { 23 FileTransferLayer* newSXTransfer(IOLayer* lay) {
23 return new FileTransfer(FileTransfer ::SX, lay ); 24 return new FileTransfer(FileTransfer ::SX, lay );
24 } 25 }
25 26
27 // FILE Transfer Receive Stuff
28 ReceiveLayer* newSZReceive(IOLayer* lay) {
29 return new FileReceive( FileReceive::SZ, lay );
30 }
31 ReceiveLayer* newSYReceive(IOLayer* lay) {
32 return new FileReceive( FileReceive::SY, lay );
33 }
34 ReceiveLayer* newSXReceive(IOLayer* lay) {
35 return new FileReceive(FileReceive::SX, lay );
36 }
37
26 // Layer stuff 38 // Layer stuff
27 IOLayer* newSerialLayer( const Profile& prof) { 39 IOLayer* newSerialLayer( const Profile& prof) {
28 return new IOSerial( prof ); 40 return new IOSerial( prof );
29 } 41 }
30 IOLayer* newBTLayer( const Profile& prof ) { 42 IOLayer* newBTLayer( const Profile& prof ) {
31 return new IOBt( prof ); 43 return new IOBt( prof );
32 } 44 }
33 IOLayer* newIrDaLayer( const Profile& prof ) { 45 IOLayer* newIrDaLayer( const Profile& prof ) {
34 return new IOIrda( prof ); 46 return new IOIrda( prof );
35 } 47 }
36 48
37 // Connection Widgets 49 // Connection Widgets
38 ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) { 50 ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) {
39 return new SerialConfigWidget( str, wid ); 51 return new SerialConfigWidget( str, wid );
40 } 52 }
41 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) { 53 ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) {
42 return new IrdaConfigWidget( str, wid ); 54 return new IrdaConfigWidget( str, wid );
43 } 55 }
44 ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) { 56 ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) {
45 return new ModemConfigWidget(str, wid ); 57 return new ModemConfigWidget(str, wid );
46 } 58 }
47 ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) { 59 ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) {
48 return new BTConfigWidget(str, wid ); 60 return new BTConfigWidget(str, wid );
49 } 61 }
50 62
51 63
52 // Terminal Widget(s) 64 // Terminal Widget(s)
53 ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { 65 ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) {
54 return new TerminalWidget(na, wid,0 ); 66 return new TerminalWidget(na, wid,0 );
55 } 67 }
56 68
57 // VT Emulations 69 // VT Emulations
58 EmulationLayer* newVT102( WidgetLayer* wid ) { 70 EmulationLayer* newVT102( WidgetLayer* wid ) {
59 return new Vt102Emulation( wid ); 71 return new Vt102Emulation( wid );
60 } 72 }
61 73
62}; 74};
63 75
64Default::Default( MetaFactory* fact ) { 76Default::Default( MetaFactory* fact ) {
65 fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); 77 fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer );
66 fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); 78 fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer );
67 fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); 79 fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer );
68 80
81 fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive );
82 fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive );
83 fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive );
84
69 fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); 85 fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer );
70 fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); 86 fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
71 fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); 87 fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
72 88
73 fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); 89 fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
74 fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); 90 fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
75 fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget ); 91 fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget );
76 fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); 92 fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
77 93
78 fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); 94 fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
79 95
80 fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); 96 fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 );
81} 97}
82Default::~Default() { 98Default::~Default() {
83 99
84} 100}
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,34 +1,38 @@
1#ifndef OPIE_DEFAULT_H 1#ifndef OPIE_DEFAULT_H
2#define OPIE_DEFAULT_H 2#define OPIE_DEFAULT_H
3 3
4#include "metafactory.h" 4#include "metafactory.h"
5 5
6class Widget; 6class Widget;
7 7
8extern "C" { 8extern "C" {
9 FileTransferLayer* newSZTransfer(IOLayer*); 9 FileTransferLayer* newSZTransfer(IOLayer*);
10 FileTransferLayer* newSYTransfer(IOLayer*); 10 FileTransferLayer* newSYTransfer(IOLayer*);
11 FileTransferLayer* newSXTransfer(IOLayer*); 11 FileTransferLayer* newSXTransfer(IOLayer*);
12 12
13 ReceiveLayer* newSZReceive(IOLayer*);
14 ReceiveLayer* newSYReceive(IOLayer*);
15 ReceiveLayer* newSXReceive(IOLayer*);
16
13 IOLayer* newSerialLayer(const Profile&); 17 IOLayer* newSerialLayer(const Profile&);
14 IOLayer* newBTLayer(const Profile& ); 18 IOLayer* newBTLayer(const Profile& );
15 IOLayer* newIrDaLayer(const Profile& ); 19 IOLayer* newIrDaLayer(const Profile& );
16 20
17 ProfileDialogWidget* newSerialWidget(const QString&, QWidget* ); 21 ProfileDialogWidget* newSerialWidget(const QString&, QWidget* );
18 ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* ); 22 ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* );
19 ProfileDialogWidget* newBTWidget (const QString&, QWidget* ); 23 ProfileDialogWidget* newBTWidget (const QString&, QWidget* );
20 24
21 ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ); 25 ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* );
22 26
23 EmulationLayer* newVT102( WidgetLayer* ); 27 EmulationLayer* newVT102( WidgetLayer* );
24}; 28};
25 29
26class MetaFactory; 30class MetaFactory;
27struct Default { 31struct Default {
28public: 32public:
29 Default(MetaFactory* ); 33 Default(MetaFactory* );
30 ~Default(); 34 ~Default();
31}; 35};
32 36
33 37
34#endif 38#endif
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
@@ -1,148 +1,171 @@
1#include <qpe/config.h> 1#include <qpe/config.h>
2#include "metafactory.h" 2#include "metafactory.h"
3 3
4MetaFactory::MetaFactory() { 4MetaFactory::MetaFactory() {
5} 5}
6MetaFactory::~MetaFactory() { 6MetaFactory::~MetaFactory() {
7 7
8} 8}
9void MetaFactory::addConnectionWidgetFactory( const QCString& name, 9void MetaFactory::addConnectionWidgetFactory( const QCString& name,
10 const QString& str, 10 const QString& str,
11 configWidget wid) { 11 configWidget wid) {
12 m_strings.insert( str, name ); 12 m_strings.insert( str, name );
13 m_conFact.insert( str, wid ); 13 m_conFact.insert( str, wid );
14} 14}
15void MetaFactory::addTerminalWidgetFactory( const QCString& name, 15void MetaFactory::addTerminalWidgetFactory( const QCString& name,
16 const QString& str, 16 const QString& str,
17 configWidget wid ) { 17 configWidget wid ) {
18 m_strings.insert( str, name ); 18 m_strings.insert( str, name );
19 m_termFact.insert( str, wid ); 19 m_termFact.insert( str, wid );
20} 20}
21void MetaFactory::addIOLayerFactory( const QCString& name, 21void MetaFactory::addIOLayerFactory( const QCString& name,
22 const QString& str, 22 const QString& str,
23 iolayer lay) { 23 iolayer lay) {
24 m_strings.insert( str, name ); 24 m_strings.insert( str, name );
25 m_layerFact.insert( str, lay ); 25 m_layerFact.insert( str, lay );
26} 26}
27void MetaFactory::addFileTransferLayer( const QCString& name, 27void MetaFactory::addFileTransferLayer( const QCString& name,
28 const QString& str, 28 const QString& str,
29 filelayer lay) { 29 filelayer lay) {
30 m_strings.insert(str, name ); 30 m_strings.insert(str, name );
31 m_fileFact.insert( str, lay ); 31 m_fileFact.insert( str, lay );
32} 32}
33void MetaFactory::addReceiveLayer( const QCString& name,
34 const QString& str,
35 receivelayer lay) {
36 m_strings.insert(str, name );
37 m_receiveFact.insert( str, lay );
38}
33void MetaFactory::addEmulationLayer( const QCString& name, 39void MetaFactory::addEmulationLayer( const QCString& name,
34 const QString& str, 40 const QString& str,
35 emulationLayer em) { 41 emulationLayer em) {
36 m_strings.insert(str, name ); 42 m_strings.insert(str, name );
37 m_emu.insert( str, em ); 43 m_emu.insert( str, em );
38} 44}
39QStringList MetaFactory::ioLayers()const { 45QStringList MetaFactory::ioLayers()const {
40 QStringList list; 46 QStringList list;
41 QMap<QString, iolayer>::ConstIterator it; 47 QMap<QString, iolayer>::ConstIterator it;
42 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { 48 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
43 list << it.key(); 49 list << it.key();
44 } 50 }
45 return list; 51 return list;
46} 52}
47QStringList MetaFactory::connectionWidgets()const { 53QStringList MetaFactory::connectionWidgets()const {
48 QStringList list; 54 QStringList list;
49 QMap<QString, configWidget>::ConstIterator it; 55 QMap<QString, configWidget>::ConstIterator it;
50 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { 56 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
51 list << it.key(); 57 list << it.key();
52 } 58 }
53 return list; 59 return list;
54} 60}
55QStringList MetaFactory::terminalWidgets()const { 61QStringList MetaFactory::terminalWidgets()const {
56 QStringList list; 62 QStringList list;
57 QMap<QString, configWidget>::ConstIterator it; 63 QMap<QString, configWidget>::ConstIterator it;
58 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { 64 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
59 list << it.key(); 65 list << it.key();
60 } 66 }
61 return list; 67 return list;
62} 68}
63QStringList MetaFactory::fileTransferLayers()const { 69QStringList MetaFactory::fileTransferLayers()const {
64 QStringList list; 70 QStringList list;
65 QMap<QString, filelayer>::ConstIterator it; 71 QMap<QString, filelayer>::ConstIterator it;
66 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { 72 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
67 list << it.key(); 73 list << it.key();
68 } 74 }
69 return list; 75 return list;
70} 76}
77QStringList MetaFactory::receiveLayers()const {
78 QStringList list;
79 QMap<QString, receivelayer>::ConstIterator it;
80 for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) {
81 list << it.key();
82 }
83 return list;
84}
71QStringList MetaFactory::emulationLayers()const { 85QStringList MetaFactory::emulationLayers()const {
72 QStringList list; 86 QStringList list;
73 QMap<QString, emulationLayer>::ConstIterator it; 87 QMap<QString, emulationLayer>::ConstIterator it;
74 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { 88 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) {
75 list << it.key(); 89 list << it.key();
76 } 90 }
77 return list; 91 return list;
78} 92}
79 93
80IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { 94IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
81 IOLayer* lay = 0l; 95 IOLayer* lay = 0l;
82 96
83 QMap<QString, iolayer>::Iterator it; 97 QMap<QString, iolayer>::Iterator it;
84 it = m_layerFact.find( str ); 98 it = m_layerFact.find( str );
85 if ( it != m_layerFact.end() ) { 99 if ( it != m_layerFact.end() ) {
86 lay = (*(it.data()))(prof); 100 lay = (*(it.data()))(prof);
87 /* 101 /*
88 iolayer laye = it.data(); 102 iolayer laye = it.data();
89 lay = (*laye )(conf);*/ 103 lay = (*laye )(conf);*/
90 } 104 }
91 105
92 return lay; 106 return lay;
93} 107}
94 108
95ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { 109ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
96 ProfileDialogWidget* wid = 0l; 110 ProfileDialogWidget* wid = 0l;
97 111
98 QMap<QString, configWidget>::Iterator it; 112 QMap<QString, configWidget>::Iterator it;
99 it = m_conFact.find( str ); 113 it = m_conFact.find( str );
100 if ( it != m_conFact.end() ) { 114 if ( it != m_conFact.end() ) {
101 wid = (*(it.data() ) )(str,parent); 115 wid = (*(it.data() ) )(str,parent);
102 } 116 }
103 return wid; 117 return wid;
104} 118}
105ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { 119ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
106 if (str.isEmpty() ) 120 if (str.isEmpty() )
107 return 0l; 121 return 0l;
108 ProfileDialogWidget* wid = 0l; 122 ProfileDialogWidget* wid = 0l;
109 qWarning("new terminalPlugin %s %l", str.latin1(), parent ); 123 qWarning("new terminalPlugin %s %l", str.latin1(), parent );
110 124
111 QMap<QString, configWidget>::Iterator it; 125 QMap<QString, configWidget>::Iterator it;
112 it = m_termFact.find( str ); 126 it = m_termFact.find( str );
113 if ( it != m_termFact.end() ) { 127 if ( it != m_termFact.end() ) {
114 wid = (*(it.data() ) )(str,parent); 128 wid = (*(it.data() ) )(str,parent);
115 } 129 }
116 return wid; 130 return wid;
117} 131}
118EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) { 132EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) {
119 EmulationLayer* lay = 0l; 133 EmulationLayer* lay = 0l;
120 134
121 QMap<QString, emulationLayer>::Iterator it; 135 QMap<QString, emulationLayer>::Iterator it;
122 it = m_emu.find( str ); 136 it = m_emu.find( str );
123 if ( it != m_emu.end() ) { 137 if ( it != m_emu.end() ) {
124 lay = (*(it.data() ) )(wid); 138 lay = (*(it.data() ) )(wid);
125 } 139 }
126 140
127 return lay; 141 return lay;
128} 142}
129FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { 143FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) {
130 FileTransferLayer* file = 0l; 144 FileTransferLayer* file = 0l;
131 QMap<QString, filelayer>::Iterator it; 145 QMap<QString, filelayer>::Iterator it;
132 it = m_fileFact.find( str ); 146 it = m_fileFact.find( str );
133 if ( it != m_fileFact.end() ) { 147 if ( it != m_fileFact.end() ) {
134 file = (*(it.data() ) )(lay); 148 file = (*(it.data() ) )(lay);
135 } 149 }
136 return file; 150 return file;
137} 151}
152ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) {
153 ReceiveLayer* file = 0l;
154 QMap<QString, receivelayer>::Iterator it;
155 it = m_receiveFact.find( str );
156 if ( it != m_receiveFact.end() ) {
157 file = (*(it.data() ) )(lay);
158 }
159 return file;
160}
138QCString MetaFactory::internal( const QString& str )const { 161QCString MetaFactory::internal( const QString& str )const {
139 return m_strings[str]; 162 return m_strings[str];
140} 163}
141QString MetaFactory::external( const QCString& str )const { 164QString MetaFactory::external( const QCString& str )const {
142 QMap<QString, QCString>::ConstIterator it; 165 QMap<QString, QCString>::ConstIterator it;
143 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { 166 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
144 if ( it.data() == str ) 167 if ( it.data() == str )
145 return it.key(); 168 return it.key();
146 } 169 }
147 return QString::null; 170 return QString::null;
148} 171}
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
@@ -1,107 +1,115 @@
1#ifndef OPIE_META_FACTORY_H 1#ifndef OPIE_META_FACTORY_H
2#define OPIE_META_FACTORY_H 2#define OPIE_META_FACTORY_H
3 3
4/** 4/**
5 * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets 5 * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets
6 * and to instantiate these implementations on demand 6 * and to instantiate these implementations on demand
7 */ 7 */
8 8
9#include <qwidget.h> 9#include <qwidget.h>
10#include <qmap.h> 10#include <qmap.h>
11 11
12#include <qpe/config.h> 12#include <qpe/config.h>
13 13
14#include "io_layer.h" 14#include "io_layer.h"
15#include "file_layer.h" 15#include "file_layer.h"
16#include "receive_layer.h"
16#include "profile.h" 17#include "profile.h"
17#include "profiledialogwidget.h" 18#include "profiledialogwidget.h"
18#include "emulation_layer.h" 19#include "emulation_layer.h"
19 20
20class WidgetLayer; 21class WidgetLayer;
21class MetaFactory { 22class MetaFactory {
22public: 23public:
23 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); 24 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
24 typedef IOLayer* (*iolayer)(const Profile& ); 25 typedef IOLayer* (*iolayer)(const Profile& );
25 typedef FileTransferLayer* (*filelayer)(IOLayer*); 26 typedef FileTransferLayer* (*filelayer)(IOLayer*);
27 typedef ReceiveLayer* (*receivelayer)(IOLayer*);
26 typedef EmulationLayer* (*emulationLayer)(WidgetLayer* ); 28 typedef EmulationLayer* (*emulationLayer)(WidgetLayer* );
27 29
28 MetaFactory(); 30 MetaFactory();
29 ~MetaFactory(); 31 ~MetaFactory();
30 32
31 /** 33 /**
32 * add a ProfileDialogWidget to the factory 34 * add a ProfileDialogWidget to the factory
33 * name is the name shown to the user 35 * name is the name shown to the user
34 */ 36 */
35 void addConnectionWidgetFactory( const QCString& internalName, 37 void addConnectionWidgetFactory( const QCString& internalName,
36 const QString& uiString, 38 const QString& uiString,
37 configWidget ); 39 configWidget );
38 void addTerminalWidgetFactory ( const QCString& internalName, 40 void addTerminalWidgetFactory ( const QCString& internalName,
39 const QString& name, 41 const QString& name,
40 configWidget ); 42 configWidget );
41 43
42 /** 44 /**
43 * adds an IOLayer factory 45 * adds an IOLayer factory
44 */ 46 */
45 void addIOLayerFactory( const QCString&, 47 void addIOLayerFactory( const QCString&,
46 const QString&, 48 const QString&,
47 iolayer ); 49 iolayer );
48 50
49 /** 51 /**
50 * adds a FileTransfer Layer 52 * adds a FileTransfer Layer
51 */ 53 */
52 void addFileTransferLayer( const QCString& name, 54 void addFileTransferLayer( const QCString& name,
53 const QString&, 55 const QString&,
54 filelayer ); 56 filelayer );
57 void addReceiveLayer( const QCString& name,
58 const QString&,
59 receivelayer);
55 60
56 /** 61 /**
57 * adds a Factory for Emulation to the Layer.. 62 * adds a Factory for Emulation to the Layer..
58 */ 63 */
59 void addEmulationLayer ( const QCString& name, 64 void addEmulationLayer ( const QCString& name,
60 const QString& uiString, 65 const QString& uiString,
61 emulationLayer ); 66 emulationLayer );
62 67
63 /* translated UI Strings */ 68 /* translated UI Strings */
64 QStringList ioLayers()const; 69 QStringList ioLayers()const;
65 QStringList connectionWidgets()const; 70 QStringList connectionWidgets()const;
66 71
67 /** 72 /**
68 * Terminal Configuration widgets 73 * Terminal Configuration widgets
69 */ 74 */
70 QStringList terminalWidgets()const; 75 QStringList terminalWidgets()const;
71 QStringList fileTransferLayers()const; 76 QStringList fileTransferLayers()const;
77 QStringList receiveLayers()const;
72 QStringList emulationLayers()const; 78 QStringList emulationLayers()const;
73 79
74 /** 80 /**
75 * the generation... 81 * the generation...
76 */ 82 */
77 IOLayer* newIOLayer( const QString&,const Profile& ); 83 IOLayer* newIOLayer( const QString&,const Profile& );
78 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); 84 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
79 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); 85 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
80 EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* ); 86 EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* );
81 FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); 87 FileTransferLayer* newFileTransfer(const QString&, IOLayer* );
88 ReceiveLayer* newReceive(const QString&, IOLayer* );
82 89
83 /* 90 /*
84 * internal takes the maybe translated 91 * internal takes the maybe translated
85 * public QString and maps it to the internal 92 * public QString and maps it to the internal
86 * not translatable QCString 93 * not translatable QCString
87 */ 94 */
88 QCString internal( const QString& )const; 95 QCString internal( const QString& )const;
89 96
90 /* 97 /*
91 * external takes the internal name 98 * external takes the internal name
92 * it returns a translated name 99 * it returns a translated name
93 */ 100 */
94 QString external( const QCString& )const; 101 QString external( const QCString& )const;
95 102
96 103
97private: 104private:
98 QMap<QString, QCString> m_strings; 105 QMap<QString, QCString> m_strings;
99 QMap<QString, configWidget> m_conFact; 106 QMap<QString, configWidget> m_conFact;
100 QMap<QString, configWidget> m_termFact; 107 QMap<QString, configWidget> m_termFact;
101 QMap<QString, iolayer> m_layerFact; 108 QMap<QString, iolayer> m_layerFact;
102 QMap<QString, filelayer> m_fileFact; 109 QMap<QString, filelayer> m_fileFact;
110 QMap<QString, receivelayer> m_receiveFact;
103 QMap<QString, emulationLayer> m_emu; 111 QMap<QString, emulationLayer> m_emu;
104}; 112};
105 113
106 114
107#endif 115#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,218 +1,243 @@
1#include <qlayout.h> 1#include <qlayout.h>
2#include <qcombobox.h> 2#include <qcombobox.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qprogressbar.h> 7#include <qprogressbar.h>
8#include <qradiobutton.h> 8#include <qradiobutton.h>
9#include <qbuttongroup.h> 9#include <qbuttongroup.h>
10 10
11#include <opie/ofiledialog.h> 11#include <opie/ofiledialog.h>
12 12
13#include "filetransfer.h" 13#include "file_layer.h"
14#include "io_serial.h" 14#include "receive_layer.h"
15#include "metafactory.h" 15#include "metafactory.h"
16#include "mainwindow.h" 16#include "mainwindow.h"
17 17
18#include "transferdialog.h" 18#include "transferdialog.h"
19 19
20TransferDialog::TransferDialog(MainWindow *parent, const char *name) 20TransferDialog::TransferDialog(MainWindow *parent, const char *name)
21: QDialog(0l, 0l, true), m_win(parent) 21: QDialog(0l, 0l, true), m_win(parent)
22{ 22{
23 m_lay = 0l; 23 m_lay = 0l;
24 m_recvlay = 0l;
24 QVBoxLayout *vbox, *vbox2; 25 QVBoxLayout *vbox, *vbox2;
25 QHBoxLayout *hbox, *hbox2, *hbox3; 26 QHBoxLayout *hbox, *hbox2, *hbox3;
26 QLabel *file, *mode, *progress, *status; 27 QLabel *file, *mode, *progress, *status;
27 QButtonGroup *group; 28 QButtonGroup *group;
28 QRadioButton *mode_send, *mode_receive; 29 QRadioButton *mode_send, *mode_receive;
29 30
30 group = new QButtonGroup(QObject::tr("Transfer mode"), this); 31 group = new QButtonGroup(QObject::tr("Transfer mode"), this);
31 mode_send = new QRadioButton(QObject::tr("Send"), group); 32 mode_send = new QRadioButton(QObject::tr("Send"), group);
32 mode_receive = new QRadioButton(QObject::tr("Receive"), group); 33 mode_receive = new QRadioButton(QObject::tr("Receive"), group);
33 group->insert(mode_send, id_send); 34 group->insert(mode_send, id_send);
34 group->insert(mode_receive, id_receive); 35 group->insert(mode_receive, id_receive);
35 vbox2 = new QVBoxLayout(group, 2); 36 vbox2 = new QVBoxLayout(group, 2);
36 vbox2->addSpacing(10); 37 vbox2->addSpacing(10);
37 hbox3 = new QHBoxLayout(vbox2, 2); 38 hbox3 = new QHBoxLayout(vbox2, 2);
38 hbox3->add(mode_send); 39 hbox3->add(mode_send);
39 hbox3->add(mode_receive); 40 hbox3->add(mode_receive);
40 mode_send->setChecked(true); 41 mode_send->setChecked(true);
41 m_transfermode = id_send; 42 m_transfermode = id_send;
42 43
43 file = new QLabel(QObject::tr("Send file"), this); 44 file = new QLabel(QObject::tr("Send file"), this);
44 mode = new QLabel(QObject::tr("Transfer protocol"), this); 45 mode = new QLabel(QObject::tr("Transfer protocol"), this);
45 progress = new QLabel(QObject::tr("Progress"), this); 46 progress = new QLabel(QObject::tr("Progress"), this);
46 status = new QLabel(QObject::tr("Status"), this); 47 status = new QLabel(QObject::tr("Status"), this);
47 48
48 statusbar = new QLabel(QObject::tr("Ready"), this); 49 statusbar = new QLabel(QObject::tr("Ready"), this);
49 statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); 50 statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
50 51
51 protocol = new QComboBox(this); 52 protocol = new QComboBox(this);
52 QStringList list = m_win->factory()->fileTransferLayers(); 53 QStringList list = m_win->factory()->fileTransferLayers();
53 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) 54 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
54 protocol->insertItem((*it)); 55 protocol->insertItem((*it));
55 56
56 filename = new QLineEdit(this); 57 filename = new QLineEdit(this);
57 58
58 progressbar = new QProgressBar(this); 59 progressbar = new QProgressBar(this);
59 progressbar->setProgress(0); 60 progressbar->setProgress(0);
60 61
61 selector = new QPushButton("...", this); 62 selector = new QPushButton("...", this);
62 ok = new QPushButton(QObject::tr("Start transfer"), this); 63 ok = new QPushButton(QObject::tr("Start transfer"), this);
63 cancel = new QPushButton(QObject::tr("Cancel"), this); 64 cancel = new QPushButton(QObject::tr("Cancel"), this);
64 65
65 vbox = new QVBoxLayout(this, 2); 66 vbox = new QVBoxLayout(this, 2);
66 vbox->add(group); 67 vbox->add(group);
67 vbox->add(file); 68 vbox->add(file);
68 hbox = new QHBoxLayout(vbox, 0); 69 hbox = new QHBoxLayout(vbox, 0);
69 hbox->add(filename); 70 hbox->add(filename);
70 hbox->add(selector); 71 hbox->add(selector);
71 vbox->add(mode); 72 vbox->add(mode);
72 vbox->add(protocol); 73 vbox->add(protocol);
73 vbox->add(progress); 74 vbox->add(progress);
74 vbox->add(progressbar); 75 vbox->add(progressbar);
75 vbox->add(status); 76 vbox->add(status);
76 vbox->add(statusbar); 77 vbox->add(statusbar);
77 vbox->addStretch(1); 78 vbox->addStretch(1);
78 hbox2 = new QHBoxLayout(vbox, 2); 79 hbox2 = new QHBoxLayout(vbox, 2);
79 hbox2->add(ok); 80 hbox2->add(ok);
80 hbox2->add(cancel); 81 hbox2->add(cancel);
81 82
82 setCaption(QObject::tr("File transfer")); 83 setCaption(QObject::tr("File transfer"));
83 show(); 84 show();
84 85
85 connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); 86 connect(selector, SIGNAL(clicked()), SLOT(slotFilename()));
86 connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); 87 connect(ok, SIGNAL(clicked()), SLOT(slotTransfer()));
87 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); 88 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
88 connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); 89 connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int)));
89} 90}
90 91
91TransferDialog::~TransferDialog() 92TransferDialog::~TransferDialog()
92{ 93{
93} 94}
94 95
95void TransferDialog::slotFilename() 96void TransferDialog::slotFilename()
96{ 97{
97 QString f; 98 QString f;
98 99
99 f = OFileDialog::getOpenFileName(0); 100 f = OFileDialog::getOpenFileName(0);
100 if(!f.isNull()) filename->setText(f); 101 if(!f.isNull()) filename->setText(f);
101} 102}
102 103
103void TransferDialog::slotTransfer() 104void TransferDialog::slotTransfer()
104{ 105{
105 if((m_transfermode == id_send) && (filename->text().isEmpty())) 106 if((m_transfermode == id_send) && (filename->text().isEmpty()))
106 { 107 {
107 QMessageBox::information(this, 108 QMessageBox::information(this,
108 QObject::tr("Attention"), 109 QObject::tr("Attention"),
109 QObject::tr("No file has been specified.")); 110 QObject::tr("No file has been specified."));
110 return; 111 return;
111 } 112 }
112 113
113 ok->setEnabled(false); 114 ok->setEnabled(false);
114 115
115 if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); 116 if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending..."));
116 else statusbar->setText(QObject::tr("Receiving...")); 117 else statusbar->setText(QObject::tr("Receiving..."));
117 118
118 m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
119 if(m_transfermode == id_send) 119 if(m_transfermode == id_send)
120 { 120 {
121 m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
121 m_lay->sendFile(filename->text()); 122 m_lay->sendFile(filename->text());
123
124 connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)),
125 SLOT(slotProgress(const QString&, int, int, int, int, int)));
126 connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
127 connect(m_lay, SIGNAL(sent()), SLOT(slotSent()));
122 } 128 }
123 else 129 else
124 { 130 {
125 } 131 m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer());
132 m_recvlay->receive();
126 133
127 connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); 134 connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)),
128 connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); 135 SLOT(slotProgress(const QString&, int, int, int, int, int)));
129 connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); 136 connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
137 connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&)));
138 }
130} 139}
131 140
132void TransferDialog::slotCancel() 141void TransferDialog::slotCancel()
133{ 142{
134 ok->setEnabled(true); 143 ok->setEnabled(true);
135 statusbar->setText(QObject::tr("Ready")); 144 statusbar->setText(QObject::tr("Ready"));
136 145
137 if(m_lay) 146 if((m_lay) || (m_recvlay))
138 { 147 {
139 m_lay->cancel(); 148 if(m_lay)
140 delete m_lay; 149 {
141 m_lay = 0l; 150 m_lay->cancel();
151 delete m_lay;
152 m_lay = 0l;
153 }
154 if(m_recvlay)
155 {
156 m_recvlay->cancel();
157 delete m_recvlay;
158 m_recvlay = 0l;
159 }
142 QMessageBox::information(this, 160 QMessageBox::information(this,
143 QObject::tr("Cancelled"), 161 QObject::tr("Cancelled"),
144 QObject::tr("The file transfer has been cancelled.")); 162 QObject::tr("The file transfer has been cancelled."));
145 } 163 }
146 else 164 else
147 { 165 {
148 close(); 166 close();
149 } 167 }
150} 168}
151 169
152void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) 170void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds)
153{ 171{
154 progressbar->setProgress(progress); 172 progressbar->setProgress(progress);
155} 173}
156 174
157void TransferDialog::slotError(int error, const QString& message) 175void TransferDialog::slotError(int error, const QString& message)
158{ 176{
159 statusbar->setText(QObject::tr("Ready")); 177 statusbar->setText(QObject::tr("Ready"));
160 178
161 switch(error) 179 switch(error)
162 { 180 {
163 case FileTransferLayer::NotSupported: 181 case FileTransferLayer::NotSupported:
164 QMessageBox::critical(this, 182 QMessageBox::critical(this,
165 QObject::tr("Error"), 183 QObject::tr("Error"),
166 QObject::tr("Operation not supported.")); 184 QObject::tr("Operation not supported."));
167 break; 185 break;
168 case FileTransferLayer::StartError: 186 case FileTransferLayer::StartError:
169 QMessageBox::critical(this, 187 QMessageBox::critical(this,
170 QObject::tr("Error"), 188 QObject::tr("Error"),
171 QObject::tr("Transfer could not be started.")); 189 QObject::tr("Transfer could not be started."));
172 break; 190 break;
173 case FileTransferLayer::NoError: 191 case FileTransferLayer::NoError:
174 QMessageBox::critical(this, 192 QMessageBox::critical(this,
175 QObject::tr("Error"), 193 QObject::tr("Error"),
176 QObject::tr("No error.")); 194 QObject::tr("No error."));
177 break; 195 break;
178 case FileTransferLayer::Undefined: 196 case FileTransferLayer::Undefined:
179 QMessageBox::critical(this, 197 QMessageBox::critical(this,
180 QObject::tr("Error"), 198 QObject::tr("Error"),
181 QObject::tr("Undefined error occured.")); 199 QObject::tr("Undefined error occured."));
182 break; 200 break;
183 case FileTransferLayer::Incomplete: 201 case FileTransferLayer::Incomplete:
184 QMessageBox::critical(this, 202 QMessageBox::critical(this,
185 QObject::tr("Error"), 203 QObject::tr("Error"),
186 QObject::tr("Incomplete transfer.")); 204 QObject::tr("Incomplete transfer."));
187 break; 205 break;
188 case FileTransferLayer::Unknown: 206 case FileTransferLayer::Unknown:
189 default: 207 default:
190 QMessageBox::critical(this, 208 QMessageBox::critical(this,
191 QObject::tr("Error"), 209 QObject::tr("Error"),
192 QObject::tr("Unknown error occured.")); 210 QObject::tr("Unknown error occured."));
193 break; 211 break;
194 } 212 }
195} 213}
196 214
197void TransferDialog::slotSent() 215void TransferDialog::slotSent()
198{ 216{
199 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); 217 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent."));
200 ok->setEnabled(true); 218 ok->setEnabled(true);
201 statusbar->setText(QObject::tr("Ready")); 219 statusbar->setText(QObject::tr("Ready"));
202} 220}
203 221
222void TransferDialog::slotReceived(const QString& file)
223{
224 QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file));
225 ok->setEnabled(true);
226 statusbar->setText(QObject::tr("Ready"));
227}
228
204void TransferDialog::slotMode(int id) 229void TransferDialog::slotMode(int id)
205{ 230{
206 if(id == id_send) 231 if(id == id_send)
207 { 232 {
208 selector->setEnabled(true); 233 selector->setEnabled(true);
209 filename->setEnabled(true); 234 filename->setEnabled(true);
210 } 235 }
211 else 236 else
212 { 237 {
213 selector->setEnabled(false); 238 selector->setEnabled(false);
214 filename->setEnabled(false); 239 filename->setEnabled(false);
215 } 240 }
216 m_transfermode = id; 241 m_transfermode = id;
217} 242}
218 243
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 @@
1#ifndef TRANSFER_DIALOG_H 1#ifndef TRANSFER_DIALOG_H
2#define TRANSFER_DIALOG_H 2#define TRANSFER_DIALOG_H
3 3
4#include "qdialog.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; 10class QPushButton;
11class MainWindow; 11class MainWindow;
12class FileTransferLayer; 12class FileTransferLayer;
13class ReceiveLayer;
13 14
14class TransferDialog : public QDialog 15class TransferDialog : public QDialog
15{ 16{
16 Q_OBJECT 17 Q_OBJECT
17 public: 18 public:
18 TransferDialog(MainWindow *parent = 0l, const char *name = 0l); 19 TransferDialog(MainWindow *parent = 0l, const char *name = 0l);
19 ~TransferDialog(); 20 ~TransferDialog();
20 21
21 public slots: 22 public slots:
22 void slotFilename(); 23 void slotFilename();
23 void slotTransfer(); 24 void slotTransfer();
24 void slotCancel(); 25 void slotCancel();
25 void slotProgress(const QString&, int, int, int, int, int); 26 void slotProgress(const QString&, int, int, int, int, int);
26 void slotError(int error, const QString& message); 27 void slotError(int error, const QString& message);
27 void slotSent(); 28 void slotSent();
29 void slotReceived(const QString& file);
28 void slotMode(int id); 30 void slotMode(int id);
29 31
30 private: 32 private:
31 enum Modes 33 enum Modes
32 { 34 {
33 id_send, 35 id_send,
34 id_receive 36 id_receive
35 }; 37 };
36 38
37 QLineEdit *filename; 39 QLineEdit *filename;
38 QComboBox *protocol; 40 QComboBox *protocol;
39 QProgressBar *progressbar; 41 QProgressBar *progressbar;
40 QLabel *statusbar; 42 QLabel *statusbar;
41 QPushButton *ok, *cancel, *selector; 43 QPushButton *ok, *cancel, *selector;
42 MainWindow* m_win; 44 MainWindow* m_win;
43 FileTransferLayer* m_lay; 45 FileTransferLayer* m_lay;
46 ReceiveLayer *m_recvlay;
44 int m_transfermode; 47 int m_transfermode;
45}; 48};
46 49
47#endif 50#endif
48 51