summaryrefslogtreecommitdiff
path: root/noncore/apps
Unidiff
Diffstat (limited to 'noncore/apps') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/metafactory.cpp2
-rw-r--r--noncore/apps/opie-console/metafactory.h6
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp5
-rw-r--r--noncore/apps/opie-console/session.cpp6
-rw-r--r--noncore/apps/opie-console/session.h8
-rw-r--r--noncore/apps/opie-console/widget.cpp12
-rw-r--r--noncore/apps/opie-console/widget_layer.h3
7 files changed, 23 insertions, 19 deletions
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 02a9f9b..2b672cf 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -70,70 +70,70 @@ QStringList MetaFactory::fileTransferLayers()const {
70} 70}
71QStringList MetaFactory::emulationLayers()const { 71QStringList MetaFactory::emulationLayers()const {
72 QStringList list; 72 QStringList list;
73 QMap<QString, emulationLayer>::ConstIterator it; 73 QMap<QString, emulationLayer>::ConstIterator it;
74 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { 74 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) {
75 list << it.key(); 75 list << it.key();
76 } 76 }
77 return list; 77 return list;
78} 78}
79 79
80IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { 80IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
81 IOLayer* lay = 0l; 81 IOLayer* lay = 0l;
82 82
83 QMap<QString, iolayer>::Iterator it; 83 QMap<QString, iolayer>::Iterator it;
84 it = m_layerFact.find( str ); 84 it = m_layerFact.find( str );
85 if ( it != m_layerFact.end() ) { 85 if ( it != m_layerFact.end() ) {
86 lay = (*(it.data()))(prof); 86 lay = (*(it.data()))(prof);
87 /* 87 /*
88 iolayer laye = it.data(); 88 iolayer laye = it.data();
89 lay = (*laye )(conf);*/ 89 lay = (*laye )(conf);*/
90 } 90 }
91 91
92 return lay; 92 return lay;
93} 93}
94 94
95ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { 95ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
96 ProfileDialogWidget* wid = 0l; 96 ProfileDialogWidget* wid = 0l;
97 97
98 QMap<QString, configWidget>::Iterator it; 98 QMap<QString, configWidget>::Iterator it;
99 it = m_conFact.find( str ); 99 it = m_conFact.find( str );
100 if ( it != m_conFact.end() ) { 100 if ( it != m_conFact.end() ) {
101 wid = (*(it.data() ) )(str,parent); 101 wid = (*(it.data() ) )(str,parent);
102 } 102 }
103 return wid; 103 return wid;
104} 104}
105ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { 105ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
106 if (str.isEmpty() ) 106 if (str.isEmpty() )
107 return 0l; 107 return 0l;
108 ProfileDialogWidget* wid = 0l; 108 ProfileDialogWidget* wid = 0l;
109 qWarning("new terminalPlugin %s %l", str.latin1(), parent ); 109 qWarning("new terminalPlugin %s %l", str.latin1(), parent );
110 110
111 QMap<QString, configWidget>::Iterator it; 111 QMap<QString, configWidget>::Iterator it;
112 it = m_termFact.find( str ); 112 it = m_termFact.find( str );
113 if ( it != m_termFact.end() ) { 113 if ( it != m_termFact.end() ) {
114 wid = (*(it.data() ) )(str,parent); 114 wid = (*(it.data() ) )(str,parent);
115 } 115 }
116 return wid; 116 return wid;
117} 117}
118EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, Widget* wid) { 118EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) {
119 EmulationLayer* lay = 0l; 119 EmulationLayer* lay = 0l;
120 120
121 QMap<QString, emulationLayer>::Iterator it; 121 QMap<QString, emulationLayer>::Iterator it;
122 it = m_emu.find( str ); 122 it = m_emu.find( str );
123 if ( it != m_emu.end() ) { 123 if ( it != m_emu.end() ) {
124 lay = (*(it.data() ) )(wid); 124 lay = (*(it.data() ) )(wid);
125 } 125 }
126 126
127 return lay; 127 return lay;
128} 128}
129QCString MetaFactory::internal( const QString& str )const { 129QCString MetaFactory::internal( const QString& str )const {
130 return m_strings[str]; 130 return m_strings[str];
131} 131}
132QString MetaFactory::external( const QCString& str )const { 132QString MetaFactory::external( const QCString& str )const {
133 QMap<QString, QCString>::ConstIterator it; 133 QMap<QString, QCString>::ConstIterator it;
134 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { 134 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
135 if ( it.data() == str ) 135 if ( it.data() == str )
136 return it.key(); 136 return it.key();
137 } 137 }
138 return QString::null; 138 return QString::null;
139} 139}
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index 71c35a2..d05ece4 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -1,106 +1,106 @@
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 "profile.h" 16#include "profile.h"
17#include "profiledialogwidget.h" 17#include "profiledialogwidget.h"
18#include "emulation_layer.h" 18#include "emulation_layer.h"
19 19
20class Widget; 20class WidgetLayer;
21class MetaFactory { 21class MetaFactory {
22public: 22public:
23 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); 23 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
24 typedef IOLayer* (*iolayer)(const Profile& ); 24 typedef IOLayer* (*iolayer)(const Profile& );
25 typedef FileTransferLayer* (*filelayer)(IOLayer*); 25 typedef FileTransferLayer* (*filelayer)(IOLayer*);
26 typedef EmulationLayer* (*emulationLayer)(Widget* ); 26 typedef EmulationLayer* (*emulationLayer)(WidgetLayer* );
27 27
28 MetaFactory(); 28 MetaFactory();
29 ~MetaFactory(); 29 ~MetaFactory();
30 30
31 /** 31 /**
32 * add a ProfileDialogWidget to the factory 32 * add a ProfileDialogWidget to the factory
33 * name is the name shown to the user 33 * name is the name shown to the user
34 */ 34 */
35 void addConnectionWidgetFactory( const QCString& internalName, 35 void addConnectionWidgetFactory( const QCString& internalName,
36 const QString& uiString, 36 const QString& uiString,
37 configWidget ); 37 configWidget );
38 void addTerminalWidgetFactory ( const QCString& internalName, 38 void addTerminalWidgetFactory ( const QCString& internalName,
39 const QString& name, 39 const QString& name,
40 configWidget ); 40 configWidget );
41 41
42 /** 42 /**
43 * adds an IOLayer factory 43 * adds an IOLayer factory
44 */ 44 */
45 void addIOLayerFactory( const QCString&, 45 void addIOLayerFactory( const QCString&,
46 const QString&, 46 const QString&,
47 iolayer ); 47 iolayer );
48 48
49 /** 49 /**
50 * adds a FileTransfer Layer 50 * adds a FileTransfer Layer
51 */ 51 */
52 void addFileTransferLayer( const QCString& name, 52 void addFileTransferLayer( const QCString& name,
53 const QString&, 53 const QString&,
54 filelayer ); 54 filelayer );
55 55
56 /** 56 /**
57 * adds a Factory for Emulation to the Layer.. 57 * adds a Factory for Emulation to the Layer..
58 */ 58 */
59 void addEmulationLayer ( const QCString& name, 59 void addEmulationLayer ( const QCString& name,
60 const QString& uiString, 60 const QString& uiString,
61 emulationLayer ); 61 emulationLayer );
62 62
63 /* translated UI Strings */ 63 /* translated UI Strings */
64 QStringList ioLayers()const; 64 QStringList ioLayers()const;
65 QStringList connectionWidgets()const; 65 QStringList connectionWidgets()const;
66 66
67 /** 67 /**
68 * Terminal Configuration widgets 68 * Terminal Configuration widgets
69 */ 69 */
70 QStringList terminalWidgets()const; 70 QStringList terminalWidgets()const;
71 QStringList fileTransferLayers()const; 71 QStringList fileTransferLayers()const;
72 QStringList emulationLayers()const; 72 QStringList emulationLayers()const;
73 73
74 /** 74 /**
75 * the generation... 75 * the generation...
76 */ 76 */
77 IOLayer* newIOLayer( const QString&,const Profile& ); 77 IOLayer* newIOLayer( const QString&,const Profile& );
78 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); 78 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
79 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); 79 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
80 EmulationLayer* newEmulationLayer(const QString&, Widget* ); 80 EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* );
81 81
82 /* 82 /*
83 * internal takes the maybe translated 83 * internal takes the maybe translated
84 * public QString and maps it to the internal 84 * public QString and maps it to the internal
85 * not translatable QCString 85 * not translatable QCString
86 */ 86 */
87 QCString internal( const QString& )const; 87 QCString internal( const QString& )const;
88 88
89 /* 89 /*
90 * external takes the internal name 90 * external takes the internal name
91 * it returns a translated name 91 * it returns a translated name
92 */ 92 */
93 QString external( const QCString& )const; 93 QString external( const QCString& )const;
94 94
95 95
96private: 96private:
97 QMap<QString, QCString> m_strings; 97 QMap<QString, QCString> m_strings;
98 QMap<QString, configWidget> m_conFact; 98 QMap<QString, configWidget> m_conFact;
99 QMap<QString, configWidget> m_termFact; 99 QMap<QString, configWidget> m_termFact;
100 QMap<QString, iolayer> m_layerFact; 100 QMap<QString, iolayer> m_layerFact;
101 QMap<QString, filelayer> m_fileFact; 101 QMap<QString, filelayer> m_fileFact;
102 QMap<QString, emulationLayer> m_emu; 102 QMap<QString, emulationLayer> m_emu;
103}; 103};
104 104
105 105
106#endif 106#endif
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index dcf3cbd..78751e7 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -1,126 +1,127 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include <qfile.h> 4#include <qfile.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qwidgetstack.h> 6#include <qwidgetstack.h>
7 7
8#include <qpe/config.h> 8#include <qpe/config.h>
9 9
10#include "widget.h" 10#include "widget_layer.h"
11#include "emulation_widget.h"
11#include "metafactory.h" 12#include "metafactory.h"
12#include "profileconfig.h" 13#include "profileconfig.h"
13#include "profilemanager.h" 14#include "profilemanager.h"
14 15
15ProfileManager::ProfileManager( MetaFactory* fact ) 16ProfileManager::ProfileManager( MetaFactory* fact )
16 : m_fact( fact ) 17 : m_fact( fact )
17{ 18{
18 19
19} 20}
20ProfileManager::~ProfileManager() { 21ProfileManager::~ProfileManager() {
21 22
22} 23}
23void ProfileManager::load() { 24void ProfileManager::load() {
24 m_list.clear(); 25 m_list.clear();
25 qWarning("load"); 26 qWarning("load");
26 ProfileConfig conf("opie-console-profiles"); 27 ProfileConfig conf("opie-console-profiles");
27 QStringList groups = conf.groups(); 28 QStringList groups = conf.groups();
28 QStringList::Iterator it; 29 QStringList::Iterator it;
29 30
30 /* 31 /*
31 * for each profile 32 * for each profile
32 */ 33 */
33 for ( it = groups.begin(); it != groups.end(); ++it ) { 34 for ( it = groups.begin(); it != groups.end(); ++it ) {
34 qWarning("group " + (*it) ); 35 qWarning("group " + (*it) );
35 conf.setGroup( (*it) ); 36 conf.setGroup( (*it) );
36 Profile prof; 37 Profile prof;
37 prof.setName( conf.readEntry("name") ); 38 prof.setName( conf.readEntry("name") );
38 prof.setIOLayer( conf.readEntry("iolayer").utf8() ); 39 prof.setIOLayer( conf.readEntry("iolayer").utf8() );
39 prof.setTerminalName( conf.readEntry("term").utf8() ); 40 prof.setTerminalName( conf.readEntry("term").utf8() );
40 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); 41 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() );
41 prof.setBackground( conf.readNumEntry("back") ); 42 prof.setBackground( conf.readNumEntry("back") );
42 prof.setForeground( conf.readNumEntry("fore") ); 43 prof.setForeground( conf.readNumEntry("fore") );
43 prof.setTerminal( conf.readNumEntry("terminal") ); 44 prof.setTerminal( conf.readNumEntry("terminal") );
44 prof.setConf( conf.items( (*it) ) ); 45 prof.setConf( conf.items( (*it) ) );
45 46
46 /* now add it */ 47 /* now add it */
47 m_list.append( prof ); 48 m_list.append( prof );
48 } 49 }
49 50
50} 51}
51void ProfileManager::clear() { 52void ProfileManager::clear() {
52 m_list.clear(); 53 m_list.clear();
53} 54}
54Profile::ValueList ProfileManager::all()const { 55Profile::ValueList ProfileManager::all()const {
55 return m_list; 56 return m_list;
56} 57}
57/* 58/*
58 * Our goal is to create a Session 59 * Our goal is to create a Session
59 * We will load the the IOLayer and EmulationLayer 60 * We will load the the IOLayer and EmulationLayer
60 * from the factory 61 * from the factory
61 * we will generate a QWidgetStack 62 * we will generate a QWidgetStack
62 * add a dummy widget with layout 63 * add a dummy widget with layout
63 * add "Widget" to the layout 64 * add "Widget" to the layout
64 * add the dummy to the stack 65 * add the dummy to the stack
65 * raise the dummy 66 * raise the dummy
66 * call session->connect(= 67 * call session->connect(=
67 * this way we only need to reparent 68 * this way we only need to reparent
68 * in TabWidget 69 * in TabWidget
69 */ 70 */
70Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { 71Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) {
71 Session* session = new Session(); 72 Session* session = new Session();
72 session->setName( prof.name() ); 73 session->setName( prof.name() );
73 /* translate the internal name to the external */ 74 /* translate the internal name to the external */
74 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , 75 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) ,
75 prof) ); 76 prof) );
76 77
77 QWidgetStack *stack = new QWidgetStack(parent); 78 QWidgetStack *stack = new QWidgetStack(parent);
78 session->setWidgetStack( stack ); 79 session->setWidgetStack( stack );
79 QWidget* dummy = new QWidget(stack ); 80 QWidget* dummy = new QWidget(stack );
80 QHBoxLayout* lay = new QHBoxLayout(dummy ); 81 QHBoxLayout* lay = new QHBoxLayout(dummy );
81 stack->addWidget( dummy, 0 ); 82 stack->addWidget( dummy, 0 );
82 stack->raiseWidget( 0 ); 83 stack->raiseWidget( 0 );
83 Widget* wid = new Widget(dummy ); 84 WidgetLayer* wid = new EmulationWidget( prof, dummy );
84 lay->addWidget( wid ); 85 lay->addWidget( wid );
85 86
86 session->setEmulationWidget( wid ); 87 session->setEmulationWidget( wid );
87 session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ), 88 session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ),
88 wid ) ); 89 wid ) );
89 session->connect(); 90 session->connect();
90 91
91 return session; 92 return session;
92} 93}
93void ProfileManager::save( ) { 94void ProfileManager::save( ) {
94 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); 95 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) );
95 ProfileConfig conf("opie-console-profiles"); 96 ProfileConfig conf("opie-console-profiles");
96 Profile::ValueList::Iterator it; 97 Profile::ValueList::Iterator it;
97 for (it = m_list.begin(); it != m_list.end(); ++it ) { 98 for (it = m_list.begin(); it != m_list.end(); ++it ) {
98 conf.setGroup( (*it).name() ); 99 conf.setGroup( (*it).name() );
99 conf.writeEntry( "name", (*it).name() ); 100 conf.writeEntry( "name", (*it).name() );
100 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); 101 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) );
101 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); 102 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) );
102 conf.writeEntry( "back", (*it).background() ); 103 conf.writeEntry( "back", (*it).background() );
103 conf.writeEntry( "fore", (*it).foreground() ); 104 conf.writeEntry( "fore", (*it).foreground() );
104 conf.writeEntry( "terminal", (*it).terminal() ); 105 conf.writeEntry( "terminal", (*it).terminal() );
105 /* now the config stuff */ 106 /* now the config stuff */
106 QMap<QString, QString> map = (*it).conf(); 107 QMap<QString, QString> map = (*it).conf();
107 QMap<QString, QString>::Iterator it; 108 QMap<QString, QString>::Iterator it;
108 for ( it = map.begin(); it != map.end(); ++it ) { 109 for ( it = map.begin(); it != map.end(); ++it ) {
109 conf.writeEntry( it.key(), it.data() ); 110 conf.writeEntry( it.key(), it.data() );
110 } 111 }
111 } 112 }
112} 113}
113void ProfileManager::setProfiles( const Profile::ValueList& list ) { 114void ProfileManager::setProfiles( const Profile::ValueList& list ) {
114 m_list = list; 115 m_list = list;
115}; 116};
116Profile ProfileManager::profile( const QString& name )const { 117Profile ProfileManager::profile( const QString& name )const {
117 Profile prof; 118 Profile prof;
118 Profile::ValueList::ConstIterator it; 119 Profile::ValueList::ConstIterator it;
119 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 120 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
120 if ( name == (*it).name() ) { 121 if ( name == (*it).name() ) {
121 prof = (*it); 122 prof = (*it);
122 break; 123 break;
123 } 124 }
124 } 125 }
125 return prof; 126 return prof;
126} 127}
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index 42b0583..ff2c3e2 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -1,81 +1,81 @@
1 1
2 2
3#include "io_layer.h" 3#include "io_layer.h"
4#include "file_layer.h" 4#include "file_layer.h"
5#include "widget.h" 5#include "widget_layer.h"
6#include "emulation_layer.h" 6#include "emulation_layer.h"
7#include "session.h" 7#include "session.h"
8 8
9 9
10Session::Session() { 10Session::Session() {
11 m_widget = 0l; 11 m_widget = 0l;
12 m_layer = 0l; 12 m_layer = 0l;
13 m_widLay = 0l; 13 m_widLay = 0l;
14 m_emLay = 0l; 14 m_emLay = 0l;
15} 15}
16Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) 16Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay)
17 : m_name( na ), m_widget( widget ), m_layer( lay ) 17 : m_name( na ), m_widget( widget ), m_layer( lay )
18{ 18{
19 m_widLay = 0l; 19 m_widLay = 0l;
20 m_emLay = 0l; 20 m_emLay = 0l;
21} 21}
22Session::~Session() { 22Session::~Session() {
23 delete m_layer; 23 delete m_layer;
24 delete m_emLay; 24 delete m_emLay;
25 delete m_widget; 25 delete m_widget;
26 /* the widget layer should be deleted by the m_widget */ 26 /* the widget layer should be deleted by the m_widget */
27} 27}
28QString Session::name()const { 28QString Session::name()const {
29 return m_name; 29 return m_name;
30} 30}
31QWidgetStack* Session::widgetStack() { 31QWidgetStack* Session::widgetStack() {
32 return m_widget; 32 return m_widget;
33} 33}
34IOLayer* Session::layer() { 34IOLayer* Session::layer() {
35 return m_layer; 35 return m_layer;
36} 36}
37EmulationLayer* Session::emulationLayer() { 37EmulationLayer* Session::emulationLayer() {
38 return m_emLay; 38 return m_emLay;
39} 39}
40Widget* Session::emulationWidget() { 40WidgetLayer* Session::emulationWidget() {
41 return m_widLay; 41 return m_widLay;
42} 42}
43void Session::connect() { 43void Session::connect() {
44 if ( !m_layer || !m_emLay ) 44 if ( !m_layer || !m_emLay )
45 return; 45 return;
46 46
47 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), 47 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ),
48 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); 48 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) );
49 QObject::connect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ), 49 QObject::connect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ),
50 m_layer, SLOT(send(const QByteArray&) ) ); 50 m_layer, SLOT(send(const QByteArray&) ) );
51} 51}
52void Session::disconnect() { 52void Session::disconnect() {
53 if ( !m_layer || !m_emLay ) 53 if ( !m_layer || !m_emLay )
54 return; 54 return;
55 55
56 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), 56 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ),
57 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); 57 m_emLay, SLOT(onRcvBlock(const QByteArray&) ) );
58 QObject::disconnect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ), 58 QObject::disconnect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ),
59 m_layer, SLOT(send(const QByteArray&) ) ); 59 m_layer, SLOT(send(const QByteArray&) ) );
60} 60}
61void Session::setName( const QString& na){ 61void Session::setName( const QString& na){
62 m_name = na; 62 m_name = na;
63} 63}
64void Session::setWidgetStack( QWidgetStack* wid ) { 64void Session::setWidgetStack( QWidgetStack* wid ) {
65 delete m_widget; 65 delete m_widget;
66 /* the EmulationLayer was destroyed... */ 66 /* the EmulationLayer was destroyed... */
67 delete m_emLay; 67 delete m_emLay;
68 m_widget = wid; 68 m_widget = wid;
69} 69}
70void Session::setIOLayer( IOLayer* lay ) { 70void Session::setIOLayer( IOLayer* lay ) {
71 delete m_layer; 71 delete m_layer;
72 m_layer = lay; 72 m_layer = lay;
73} 73}
74void Session::setEmulationLayer( EmulationLayer* lay ) { 74void Session::setEmulationLayer( EmulationLayer* lay ) {
75 delete m_emLay; 75 delete m_emLay;
76 m_emLay = lay; 76 m_emLay = lay;
77} 77}
78void Session::setEmulationWidget( Widget* lay ) { 78void Session::setEmulationWidget( WidgetLayer* lay ) {
79 delete m_widLay; 79 delete m_widLay;
80 m_widLay = lay; 80 m_widLay = lay;
81} 81}
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h
index c3673fc..64c2cdb 100644
--- a/noncore/apps/opie-console/session.h
+++ b/noncore/apps/opie-console/session.h
@@ -1,74 +1,74 @@
1#ifndef OPIE_SESSION_H 1#ifndef OPIE_SESSION_H
2#define OPIE_SESSION_H 2#define OPIE_SESSION_H
3 3
4#include <qwidgetstack.h> 4#include <qwidgetstack.h>
5 5
6class IOLayer; 6class IOLayer;
7class EmulationLayer; 7class EmulationLayer;
8class Widget; 8class WidgetLayer;
9/** 9/**
10 * This is a Session. A session contains 10 * This is a Session. A session contains
11 * a QWidget pointer and a IOLayer 11 * a QWidget pointer and a IOLayer
12 * Imagine a session like a collection of what 12 * Imagine a session like a collection of what
13 * is needed to show your widget in a tab ;) 13 * is needed to show your widget in a tab ;)
14 */ 14 */
15class Session { 15class Session {
16public: 16public:
17 /** 17 /**
18 * c'tor with widget and layer 18 * c'tor with widget and layer
19 * ownership get's transfered 19 * ownership get's transfered
20 */ 20 */
21 Session(); 21 Session();
22 Session( const QString&, QWidgetStack* widget, IOLayer* ); 22 Session( const QString&, QWidgetStack* widget, IOLayer* );
23 ~Session(); 23 ~Session();
24 24
25 /** 25 /**
26 * return the name of the session 26 * return the name of the session
27 */ 27 */
28 QString name()const; 28 QString name()const;
29 29
30 /** 30 /**
31 * return the widgetstack 31 * return the widgetstack
32 * this is used to be semi modal 32 * this is used to be semi modal
33 * for FileTransfer 33 * for FileTransfer
34 * 34 *
35 * semi modal == SessionModal 35 * semi modal == SessionModal
36 */ 36 */
37 QWidgetStack* widgetStack(); 37 QWidgetStack* widgetStack();
38 38
39 /** 39 /**
40 * return the layer 40 * return the layer
41 */ 41 */
42 IOLayer* layer(); 42 IOLayer* layer();
43 43
44 EmulationLayer* emulationLayer(); 44 EmulationLayer* emulationLayer();
45 Widget* emulationWidget(); 45 WidgetLayer* emulationWidget();
46 46
47 /* 47 /*
48 * connects the data flow from 48 * connects the data flow from
49 * the IOLayer to the EmulationLayer 49 * the IOLayer to the EmulationLayer
50 */ 50 */
51 void connect(); 51 void connect();
52 52
53 /* 53 /*
54 * disconnect the dataflow 54 * disconnect the dataflow
55 * this will be done for ft 55 * this will be done for ft
56 */ 56 */
57 void disconnect(); 57 void disconnect();
58 58
59 void setWidgetStack( QWidgetStack* widget ); 59 void setWidgetStack( QWidgetStack* widget );
60 void setEmulationLayer( EmulationLayer* lay ); 60 void setEmulationLayer( EmulationLayer* lay );
61 void setEmulationWidget( Widget* lay ); 61 void setEmulationWidget( WidgetLayer* lay );
62 void setIOLayer( IOLayer* ); 62 void setIOLayer( IOLayer* );
63 void setName( const QString& ); 63 void setName( const QString& );
64 64
65private: 65private:
66 QString m_name; 66 QString m_name;
67 QWidgetStack* m_widget; 67 QWidgetStack* m_widget;
68 IOLayer* m_layer; 68 IOLayer* m_layer;
69 EmulationLayer* m_emLay; 69 EmulationLayer* m_emLay;
70 Widget* m_widLay; 70 WidgetLayer* m_widLay;
71 71
72}; 72};
73 73
74#endif 74#endif
diff --git a/noncore/apps/opie-console/widget.cpp b/noncore/apps/opie-console/widget.cpp
index b8f2906..d948179 100644
--- a/noncore/apps/opie-console/widget.cpp
+++ b/noncore/apps/opie-console/widget.cpp
@@ -1,71 +1,72 @@
1/* ------------------------------------------------------------------------ */ 1/* ------------------------------------------------------------------------ */
2/* */ 2/* */
3/* [TEWidget.C] Terminal Emulation Widget */ 3/* [TEWidget.C] Terminal Emulation Widget */
4/* */ 4/* */
5/* ------------------------------------------------------------------------ */ 5/* ------------------------------------------------------------------------ */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ------------------------------------------------------------------------ */ 11/* ------------------------------------------------------------------------ */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19/* ibot: 19/* ibot:
20 i changed 20 i changed
21 "currentSession->getEmulation()->sendString()" to 21 "currentSession->getEmulation()->sendString()" to
22 "currentSession->layer()->send()" 22 "currentSession->layer()->send()"
23 # this is not right! EmulationLayer should send it... 23 # this is not right! EmulationLayer should send it...
24 i changed all those to use emulationLayer()->send() instead
24 i had to create a QByteArray before... 25 i had to create a QByteArray before...
25 26
26TODO: 27TODO:
27alter Widget to use only QByteArray, where applicable. 28alter Widget to use only QByteArray, where applicable.
28*/ 29*/
29 30
30 31
31 32
32/*! \class Widget 33/*! \class Widget
33 34
34 \brief Visible screen contents 35 \brief Visible screen contents
35 36
36 This class is responsible to map the `image' of a terminal emulation to the 37 This class is responsible to map the `image' of a terminal emulation to the
37 display. All the dependency of the emulation to a specific GUI or toolkit is 38 display. All the dependency of the emulation to a specific GUI or toolkit is
38 localized here. Further, this widget has no knowledge about being part of an 39 localized here. Further, this widget has no knowledge about being part of an
39 emulation, it simply work within the terminal emulation framework by exposing 40 emulation, it simply work within the terminal emulation framework by exposing
40 size and key events and by being ordered to show a new image. 41 size and key events and by being ordered to show a new image.
41 42
42 <ul> 43 <ul>
43 <li> The internal image has the size of the widget (evtl. rounded up) 44 <li> The internal image has the size of the widget (evtl. rounded up)
44 <li> The external image used in setImage can have any size. 45 <li> The external image used in setImage can have any size.
45 <li> (internally) the external image is simply copied to the internal 46 <li> (internally) the external image is simply copied to the internal
46 when a setImage happens. During a resizeEvent no painting is done 47 when a setImage happens. During a resizeEvent no painting is done
47 a paintEvent is expected to follow anyway. 48 a paintEvent is expected to follow anyway.
48 </ul> 49 </ul>
49 50
50 \sa TEScreen \sa Emulation 51 \sa TEScreen \sa Emulation
51*/ 52*/
52 53
53/* FIXME: 54/* FIXME:
54 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent 55 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent
55 - 'font_a' not used in mouse events 56 - 'font_a' not used in mouse events
56 - add destructor 57 - add destructor
57*/ 58*/
58 59
59/* TODO 60/* TODO
60 - evtl. be sensitive to `paletteChange' while using default colors. 61 - evtl. be sensitive to `paletteChange' while using default colors.
61 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 62 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
62*/ 63*/
63 64
64// #include "config.h" 65// #include "config.h"
65#include "widget.h" 66#include "widget.h"
66#include "session.h" 67#include "session.h"
67#include <qpe/config.h> 68#include <qpe/config.h>
68#include <qapplication.h> 69#include <qapplication.h>
69 70
70#include <qcursor.h> 71#include <qcursor.h>
71#include <qregexp.h> 72#include <qregexp.h>
@@ -1185,107 +1186,108 @@ void Widget::styleChange(QStyle &)
1185 1186
1186void Widget::dragEnterEvent(QDragEnterEvent* e) 1187void Widget::dragEnterEvent(QDragEnterEvent* e)
1187{ 1188{
1188 e->accept(QTextDrag::canDecode(e) || 1189 e->accept(QTextDrag::canDecode(e) ||
1189 QUriDrag::canDecode(e)); 1190 QUriDrag::canDecode(e));
1190} 1191}
1191 1192
1192void Widget::dropEvent(QDropEvent* event) 1193void Widget::dropEvent(QDropEvent* event)
1193{ 1194{
1194 // The current behaviour when url(s) are dropped is 1195 // The current behaviour when url(s) are dropped is
1195 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1196 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1196 // * in all other cases, just paste 1197 // * in all other cases, just paste
1197 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1198 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1198 QStrList strlist; 1199 QStrList strlist;
1199 int file_count = 0; 1200 int file_count = 0;
1200 dropText = ""; 1201 dropText = "";
1201 bool bPopup = true; 1202 bool bPopup = true;
1202 1203
1203 if(QUriDrag::decode(event, strlist)) { 1204 if(QUriDrag::decode(event, strlist)) {
1204 if (strlist.count()) { 1205 if (strlist.count()) {
1205 for(const char* p = strlist.first(); p; p = strlist.next()) { 1206 for(const char* p = strlist.first(); p; p = strlist.next()) {
1206 if(file_count++ > 0) { 1207 if(file_count++ > 0) {
1207 dropText += " "; 1208 dropText += " ";
1208 bPopup = false; // more than one file, don't popup 1209 bPopup = false; // more than one file, don't popup
1209 } 1210 }
1210 1211
1211/* 1212/*
1212 KURL url(p); 1213 KURL url(p);
1213 if (url.isLocalFile()) { 1214 if (url.isLocalFile()) {
1214 dropText += url.path(); // local URL : remove protocol 1215 dropText += url.path(); // local URL : remove protocol
1215 } 1216 }
1216 else { 1217 else {
1217 dropText += url.prettyURL(); 1218 dropText += url.prettyURL();
1218 bPopup = false; // a non-local file, don't popup 1219 bPopup = false; // a non-local file, don't popup
1219 } 1220 }
1220*/ 1221*/
1221 1222
1222 } 1223 }
1223 1224
1224 if (bPopup) 1225 if (bPopup)
1225 // m_drop->popup(pos() + event->pos()); 1226 // m_drop->popup(pos() + event->pos());
1226 m_drop->popup(mapToGlobal(event->pos())); 1227 m_drop->popup(mapToGlobal(event->pos()));
1227 else 1228 else
1228 { 1229 {
1229 if (currentSession) { 1230 if (currentSession) {
1230 //currentSession->getEmulation()->sendString(dropText.local8Bit()); 1231 //currentSession->getEmulation()->sendString(dropText.local8Bit());
1231 QByteArray tmp; 1232 QByteArray tmp;
1232 // ibot: this should be pretty wrong... 1233 // ibot: this should be pretty wrong...
1233 currentSession->layer()->send( tmp.setRawData( dropText.local8Bit())); 1234 // now it sends to the right layer
1235 currentSession-> emulationLayer()->send( tmp.setRawData( dropText.local8Bit()));
1234 } 1236 }
1235 // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1237 // kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1236 } 1238 }
1237 } 1239 }
1238 } 1240 }
1239 else if(QTextDrag::decode(event, dropText)) { 1241 else if(QTextDrag::decode(event, dropText)) {
1240// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1242// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1241 if (currentSession) { 1243 if (currentSession) {
1242 //currentSession->getEmulation()->sendString(dropText.local8Bit()); 1244 //currentSession->getEmulation()->sendString(dropText.local8Bit());
1243 QByteArray tmp; 1245 QByteArray tmp;
1244 currentSession->layer()->send( tmp.setRawData( dropText.local8Bit())); 1246 currentSession->emulationLayer()->send( tmp.setRawData( dropText.local8Bit()));
1245 } 1247 }
1246 // Paste it 1248 // Paste it
1247 } 1249 }
1248} 1250}
1249#endif 1251#endif
1250 1252
1251 1253
1252void Widget::drop_menu_activated(int item) 1254void Widget::drop_menu_activated(int item)
1253{ 1255{
1254#ifndef QT_NO_DRAGANDDROP 1256#ifndef QT_NO_DRAGANDDROP
1255 QByteArray tmp; 1257 QByteArray tmp;
1256 switch (item) 1258 switch (item)
1257 { 1259 {
1258 case 0: // paste 1260 case 0: // paste
1259 //currentSession->getEmulation()->sendString(dropText.local8Bit()); 1261 //currentSession->getEmulation()->sendString(dropText.local8Bit());
1260 currentSession->layer()->send( tmp.setRawData( dropText.local8Bit())); 1262 currentSession->emulationLayer()->send( tmp.setRawData( dropText.local8Bit()));
1261 1263
1262// KWM::activate((Window)this->winId()); 1264// KWM::activate((Window)this->winId());
1263 break; 1265 break;
1264 case 1: // cd ... 1266 case 1: // cd ...
1265 //currentSession->getEmulation()->sendString("cd "); 1267 //currentSession->getEmulation()->sendString("cd ");
1266 tmp.setRawData( "cd " ); 1268 tmp.setRawData( "cd " );
1267 currentSession->layer()->send( tmp ); 1269 currentSession->emulationLayer()->send( tmp );
1268 struct stat statbuf; 1270 struct stat statbuf;
1269 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1271 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1270 { 1272 {
1271 if ( !S_ISDIR(statbuf.st_mode) ) 1273 if ( !S_ISDIR(statbuf.st_mode) )
1272 { 1274 {
1273/* 1275/*
1274 KURL url; 1276 KURL url;
1275 url.setPath( dropText ); 1277 url.setPath( dropText );
1276 dropText = url.directory( true, false ); // remove filename 1278 dropText = url.directory( true, false ); // remove filename
1277*/ 1279*/
1278 } 1280 }
1279 } 1281 }
1280 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1282 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1281 QByteArray tmp2; 1283 QByteArray tmp2;
1282 tmp.setRawDate( dropText.local8Bit() + "\n" ); 1284 tmp.setRawDate( dropText.local8Bit() + "\n" );
1283 //currentSession->getEmulation()->sendString(dropText.local8Bit()); 1285 //currentSession->getEmulation()->sendString(dropText.local8Bit());
1284 //currentSession->getEmulation()->sendString("\n"); 1286 //currentSession->getEmulation()->sendString("\n");
1285 currentSession->layer()->send( tmp ); 1287 currentSession->emulationLayer()->send( tmp );
1286// KWM::activate((Window)this->winId()); 1288// KWM::activate((Window)this->winId());
1287 break; 1289 break;
1288 } 1290 }
1289#endif 1291#endif
1290} 1292}
1291 1293
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h
index 5bd2ef9..01a4614 100644
--- a/noncore/apps/opie-console/widget_layer.h
+++ b/noncore/apps/opie-console/widget_layer.h
@@ -57,98 +57,99 @@ public:
57 /** 57 /**
58 * sets the image 58 * sets the image
59 * @param QArray<Character> const newimg, the new image 59 * @param QArray<Character> const newimg, the new image
60 * @param int lines, lines count of newimg 60 * @param int lines, lines count of newimg
61 * @param int columns, columns count of newimg 61 * @param int columns, columns count of newimg
62 */ 62 */
63 virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; 63 virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0;
64 64
65 /** 65 /**
66 * annoy the user 66 * annoy the user
67 */ 67 */
68 void bell(); 68 void bell();
69 69
70 /** 70 /**
71 * @return int m_lines, the lines count 71 * @return int m_lines, the lines count
72 */ 72 */
73 int lines(){ return m_lines; } 73 int lines(){ return m_lines; }
74 74
75 /** 75 /**
76 * @return int m_columns, the columns count 76 * @return int m_columns, the columns count
77 */ 77 */
78 int columns(){ return m_columns; } 78 int columns(){ return m_columns; }
79 79
80 /** 80 /**
81 * insert current selection (currently this is only the clipboard) 81 * insert current selection (currently this is only the clipboard)
82 */ 82 */
83 void insertSelection(); 83 void insertSelection();
84 84
85 /** 85 /**
86 * insert text 86 * insert text
87 * @param QString text, the text to be inserted 87 * @param QString text, the text to be inserted
88 */ 88 */
89 void insertText( QString text ); 89 void insertText( QString text );
90 90
91 /** 91 /**
92 * set selection (clipboard) to text 92 * set selection (clipboard) to text
93 * @param const QString &text, the text to be selected 93 * @param const QString &text, the text to be selected
94 */ 94 */
95 void setSelection( const QString &text ); 95 void setSelection( const QString &text );
96 96
97 /** 97 /**
98 * paste content of clipboard 98 * paste content of clipboard
99 */ 99 */
100 void pasteClipboard(); 100 void pasteClipboard();
101 101
102 102
103 /** 103 /**
104 * reload configuration 104 * reload configuration
105 * @param const Profile& config, the config to be used (may be the same as in constructor)
105 */ 106 */
106 virtual void reloadConfig() = 0; 107 virtual void reloadConfig( const Profile& config ) = 0;
107 108
108 109
109 /** 110 /**
110 * sets the scrollbar (if implemented by successor of this class) 111 * sets the scrollbar (if implemented by successor of this class)
111 */ 112 */
112 virtual void setScroll( int cursor, int slines ); 113 virtual void setScroll( int cursor, int slines );
113 114
114 /** 115 /**
115 * scrolls (if implemented, by successor of this class) 116 * scrolls (if implemented, by successor of this class)
116 * @param int value, how much the widget should scroll up (positive value) or down (negative value) 117 * @param int value, how much the widget should scroll up (positive value) or down (negative value)
117 */ 118 */
118 virtual void scroll( int value ); 119 virtual void scroll( int value );
119 120
120signals: 121signals:
121 122
122 /** 123 /**
123 * key was pressed 124 * key was pressed
124 */ 125 */
125 void keyPressed( QKeyEvent *e ); 126 void keyPressed( QKeyEvent *e );
126 127
127 /** 128 /**
128 * whenever Mouse selects something 129 * whenever Mouse selects something
129 * @param int button, the button that us pressed : 130 * @param int button, the button that us pressed :
130 * 0left Button 131 * 0left Button
131 * 3Button released 132 * 3Button released
132 * @param int x, x position 133 * @param int x, x position
133 * @param int y, y position 134 * @param int y, y position
134 * 135 *
135 * // numbering due to layout in old TEWidget 136 * // numbering due to layout in old TEWidget
136 */ 137 */
137 void mousePressed( int button, int x, int y ); 138 void mousePressed( int button, int x, int y );
138 139
139 /** 140 /**
140 * size of image changed 141 * size of image changed
141 * @param int lines, line count of new size 142 * @param int lines, line count of new size
142 * @param int columns, column count of new size 143 * @param int columns, column count of new size
143 */ 144 */
144 void imageSizeChanged( int lines, int columns ); 145 void imageSizeChanged( int lines, int columns );
145 146
146 /** 147 /**
147 * cursor in history changed 148 * cursor in history changed
148 * @param int value, value of history cursor 149 * @param int value, value of history cursor
149 */ 150 */
150 void historyCursorChanged( int value ); 151 void historyCursorChanged( int value );
151 152
152 /** 153 /**
153 * selection should be cleared 154 * selection should be cleared
154 */ 155 */