summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console
Unidiff
Diffstat (limited to 'noncore/apps/opie-console') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/TEScreen.cpp17
-rw-r--r--noncore/apps/opie-console/TEScreen.h2
-rw-r--r--noncore/apps/opie-console/TEmulation.cpp4
-rw-r--r--noncore/apps/opie-console/TEmulation.h7
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp3
-rw-r--r--noncore/apps/opie-console/emulation_handler.h1
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp35
-rw-r--r--noncore/apps/opie-console/mainwindow.h1
-rw-r--r--noncore/apps/opie-console/metafactory.cpp25
-rw-r--r--noncore/apps/opie-console/metafactory.h11
10 files changed, 64 insertions, 42 deletions
diff --git a/noncore/apps/opie-console/TEScreen.cpp b/noncore/apps/opie-console/TEScreen.cpp
index a3d115d..2675d31 100644
--- a/noncore/apps/opie-console/TEScreen.cpp
+++ b/noncore/apps/opie-console/TEScreen.cpp
@@ -964,79 +964,79 @@ void TEScreen::setSelBeginXY(const int x, const int y)
964} 964}
965 965
966void TEScreen::setSelExtentXY(const int x, const int y) 966void TEScreen::setSelExtentXY(const int x, const int y)
967{ 967{
968 if (sel_begin == -1) return; 968 if (sel_begin == -1) return;
969 int l = loc(x,y + histCursor); 969 int l = loc(x,y + histCursor);
970 970
971 if (l < sel_begin) 971 if (l < sel_begin)
972 { 972 {
973 sel_TL = l; 973 sel_TL = l;
974 sel_BR = sel_begin; 974 sel_BR = sel_begin;
975 } 975 }
976 else 976 else
977 { 977 {
978 /* FIXME, HACK to correct for x too far to the right... */ 978 /* FIXME, HACK to correct for x too far to the right... */
979 if (( x == columns )|| (x == 0)) l--; 979 if (( x == columns )|| (x == 0)) l--;
980 980
981 sel_TL = sel_begin; 981 sel_TL = sel_begin;
982 sel_BR = l; 982 sel_BR = l;
983 } 983 }
984} 984}
985 985
986QString TEScreen::getSelText(const BOOL preserve_line_breaks) 986QString TEScreen::getSelText(const BOOL preserve_line_breaks)
987{ 987{
988 if (sel_begin == -1) 988 if (sel_begin == -1)
989 return QString::null; // Selection got clear while selecting. 989 return QString::null; // Selection got clear while selecting.
990 990
991 int *m; // buffer to fill. 991 int *m; // buffer to fill.
992 int s, d; // source index, dest. index. 992 int s, d; // source index, dest. index.
993 int hist_BR = loc(0, hist.getLines()); 993 int hist_BR = loc(0, hist.getLines());
994 int hY = sel_TL / columns; 994 int hY = sel_TL / columns;
995 int hX = sel_TL % columns; 995 int hX = sel_TL % columns;
996 int eol; // end of line 996 int eol; // end of line
997 997
998 s = sel_TL; // tracks copy in source. 998 s = sel_TL; // tracks copy in source.
999 999
1000 // allocate buffer for maximum 1000 // allocate buffer for maximum
1001 // possible size... 1001 // possible size...
1002 d = (sel_BR - sel_TL) / columns + 1; 1002 d = (sel_BR - sel_TL) / columns + 1;
1003 m = new int[d * (columns + 1) + 2]; 1003 m = new int[d * (columns + 1) + 2];
1004 d = 0; 1004 d = 0;
1005 1005
1006 while (s <= sel_BR) 1006 while (s <= sel_BR)
1007 { 1007 {
1008 if (s < hist_BR) 1008 if (s < hist_BR)
1009 { // get lines from hist.history 1009 { // get lines from hist.history
1010 // buffer. 1010 // buffer.
1011 eol = hist.getLineLen(hY); 1011 eol = hist.getLineLen(hY);
1012 1012
1013 if ((hY == (sel_BR / columns)) && 1013 if ((hY == (sel_BR / columns)) &&
1014 (eol >= (sel_BR % columns))) 1014 (eol >= (sel_BR % columns)))
1015 { 1015 {
1016 eol = sel_BR % columns + 1; 1016 eol = sel_BR % columns + 1;
1017 } 1017 }
1018 1018
1019 while (hX < eol) 1019 while (hX < eol)
1020 { 1020 {
1021 m[d++] = hist.getCell(hY, hX++).c; 1021 m[d++] = hist.getCell(hY, hX++).c;
1022 s++; 1022 s++;
1023 } 1023 }
1024 1024
1025 if (s <= sel_BR) 1025 if (s <= sel_BR)
1026 { 1026 {
1027 // The line break handling 1027 // The line break handling
1028 // It's different from the screen 1028 // It's different from the screen
1029 // image case! 1029 // image case!
1030 if (eol % columns == 0) 1030 if (eol % columns == 0)
1031 { 1031 {
1032 // That's either a completely filled 1032 // That's either a completely filled
1033 // line or an empty line 1033 // line or an empty line
1034 if (eol == 0) 1034 if (eol == 0)
1035 { 1035 {
1036 m[d++] = '\n'; 1036 m[d++] = '\n';
1037 } 1037 }
1038 else 1038 else
1039 { 1039 {
1040 // We have a full line. 1040 // We have a full line.
1041 // FIXME: How can we handle newlines 1041 // FIXME: How can we handle newlines
1042 // at this position?! 1042 // at this position?!
@@ -1091,56 +1091,67 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks)
1091 { 1091 {
1092 if (image[eol - hist_BR].c == ' ') 1092 if (image[eol - hist_BR].c == ' ')
1093 { 1093 {
1094 m[d++] = ' '; 1094 m[d++] = ' ';
1095 } 1095 }
1096 } 1096 }
1097 else 1097 else
1098 { 1098 {
1099 m[d++] = ((preserve_line_breaks || 1099 m[d++] = ((preserve_line_breaks ||
1100 ((eol % columns) == 0)) ? 1100 ((eol % columns) == 0)) ?
1101 '\n' : ' '); 1101 '\n' : ' ');
1102 } 1102 }
1103 } 1103 }
1104 1104
1105 s = (eol / columns + 1) * columns; 1105 s = (eol / columns + 1) * columns;
1106 } 1106 }
1107 } 1107 }
1108 1108
1109 QChar* qc = new QChar[d]; 1109 QChar* qc = new QChar[d];
1110 1110
1111 for (int i = 0; i < d; i++) 1111 for (int i = 0; i < d; i++)
1112 { 1112 {
1113 qc[i] = m[i]; 1113 qc[i] = m[i];
1114 } 1114 }
1115 1115
1116 QString res(qc, d); 1116 QString res(qc, d);
1117 1117
1118 delete m; 1118 delete m;
1119 delete qc; 1119 delete qc;
1120 1120
1121 return res; 1121 return res;
1122} 1122}
1123QString TEScreen::getHistory() {
1124 sel_begin = 0;
1125 sel_BR = sel_begin;
1126 sel_TL = sel_begin;
1127 setSelExtentXY(columns-1,lines-1);
1128 QString tmp=getSelText(true);
1129 while (tmp.at(tmp.length()-2).unicode()==10 && tmp.at(tmp.length()-1).unicode()==10)
1130 tmp.truncate(tmp.length()-1);
1131
1132 return tmp;
1133}
1123/* above ... end of line processing for selection -- psilva 1134/* above ... end of line processing for selection -- psilva
1124cases: 1135cases:
1125 1136
11261) (eol+1)%columns == 0 --> the whole line is filled. 11371) (eol+1)%columns == 0 --> the whole line is filled.
1127 If the last char is a space, insert (preserve) space. otherwise 1138 If the last char is a space, insert (preserve) space. otherwise
1128 leave the text alone, so that words that are broken by linewrap 1139 leave the text alone, so that words that are broken by linewrap
1129 are preserved. 1140 are preserved.
1130 1141
1131FIXME: 1142FIXME:
1132 * this suppresses \n for command output that is 1143 * this suppresses \n for command output that is
1133 sized to the exact column width of the screen. 1144 sized to the exact column width of the screen.
1134 1145
11352) eol%columns == 0 --> blank line. 11462) eol%columns == 0 --> blank line.
1136 insert a \n unconditionally. 1147 insert a \n unconditionally.
1137 Do it either you would because you are in preserve_line_break mode, 1148 Do it either you would because you are in preserve_line_break mode,
1138 or because it's an ASCII paragraph delimiter, so even when 1149 or because it's an ASCII paragraph delimiter, so even when
1139 not preserving line_breaks, you want to preserve paragraph breaks. 1150 not preserving line_breaks, you want to preserve paragraph breaks.
1140 1151
1141 3) else --> partially filled line 1152 3) else --> partially filled line
1142 insert a \n in preserve line break mode, else a space 1153 insert a \n in preserve line break mode, else a space
1143 The space prevents concatenation of the last word of one 1154 The space prevents concatenation of the last word of one
1144 line with the first of the next. 1155 line with the first of the next.
1145 1156
1146*/ 1157*/
diff --git a/noncore/apps/opie-console/TEScreen.h b/noncore/apps/opie-console/TEScreen.h
index 473ce79..a840b44 100644
--- a/noncore/apps/opie-console/TEScreen.h
+++ b/noncore/apps/opie-console/TEScreen.h
@@ -141,48 +141,50 @@ public: // these are all `Screen' operations
141 /*! return the number of lines. */ 141 /*! return the number of lines. */
142 int getLines() { return lines; } 142 int getLines() { return lines; }
143 /*! return the number of columns. */ 143 /*! return the number of columns. */
144 int getColumns() { return columns; } 144 int getColumns() { return columns; }
145 145
146 /*! set the position of the history cursor. */ 146 /*! set the position of the history cursor. */
147 void setHistCursor(int cursor); 147 void setHistCursor(int cursor);
148 /*! return the position of the history cursor. */ 148 /*! return the position of the history cursor. */
149 int getHistCursor(); 149 int getHistCursor();
150 150
151 int getHistLines (); 151 int getHistLines ();
152 void setScroll(bool on); 152 void setScroll(bool on);
153 bool hasScroll(); 153 bool hasScroll();
154 154
155 // 155 //
156 // Selection 156 // Selection
157 // 157 //
158 void setSelBeginXY(const int x, const int y); 158 void setSelBeginXY(const int x, const int y);
159 void setSelExtentXY(const int x, const int y); 159 void setSelExtentXY(const int x, const int y);
160 void clearSelection(); 160 void clearSelection();
161 QString getSelText(const BOOL preserve_line_breaks); 161 QString getSelText(const BOOL preserve_line_breaks);
162 162
163 void checkSelection(int from, int to); 163 void checkSelection(int from, int to);
164 164
165 QString getHistory();
166
165private: // helper 167private: // helper
166 168
167 void clearImage(int loca, int loce, char c); 169 void clearImage(int loca, int loce, char c);
168 void moveImage(int dst, int loca, int loce); 170 void moveImage(int dst, int loca, int loce);
169 171
170 void scrollUp(int from, int i); 172 void scrollUp(int from, int i);
171 void scrollDown(int from, int i); 173 void scrollDown(int from, int i);
172 174
173 void addHistLine(); 175 void addHistLine();
174 176
175 void initTabStops(); 177 void initTabStops();
176 178
177 void effectiveRendition(); 179 void effectiveRendition();
178 void reverseRendition(ca* p); 180 void reverseRendition(ca* p);
179 181
180private: 182private:
181 183
182 /* 184 /*
183 The state of the screen is more complex as one would 185 The state of the screen is more complex as one would
184 expect first. The screem does really do part of the 186 expect first. The screem does really do part of the
185 emulation providing state informations in form of modes, 187 emulation providing state informations in form of modes,
186 margins, tabulators, cursor etc. 188 margins, tabulators, cursor etc.
187 189
188 Even more unexpected are variables to save and restore 190 Even more unexpected are variables to save and restore
diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp
index 7a0c624..3b1b9e1 100644
--- a/noncore/apps/opie-console/TEmulation.cpp
+++ b/noncore/apps/opie-console/TEmulation.cpp
@@ -250,49 +250,51 @@ void TEmulation::onRcvBlock(const char *s, int len)
250 250
251void TEmulation::onSelectionBegin(const int x, const int y) { 251void TEmulation::onSelectionBegin(const int x, const int y) {
252 if (!connected) return; 252 if (!connected) return;
253 scr->setSelBeginXY(x,y); 253 scr->setSelBeginXY(x,y);
254 showBulk(); 254 showBulk();
255} 255}
256 256
257void TEmulation::onSelectionExtend(const int x, const int y) { 257void TEmulation::onSelectionExtend(const int x, const int y) {
258 if (!connected) return; 258 if (!connected) return;
259 scr->setSelExtentXY(x,y); 259 scr->setSelExtentXY(x,y);
260 showBulk(); 260 showBulk();
261} 261}
262 262
263void TEmulation::setSelection(const BOOL preserve_line_breaks) { 263void TEmulation::setSelection(const BOOL preserve_line_breaks) {
264 if (!connected) return; 264 if (!connected) return;
265 QString t = scr->getSelText(preserve_line_breaks); 265 QString t = scr->getSelText(preserve_line_breaks);
266 if (!t.isNull()) gui->setSelection(t); 266 if (!t.isNull()) gui->setSelection(t);
267} 267}
268 268
269void TEmulation::clearSelection() { 269void TEmulation::clearSelection() {
270 if (!connected) return; 270 if (!connected) return;
271 scr->clearSelection(); 271 scr->clearSelection();
272 showBulk(); 272 showBulk();
273} 273}
274 274void TEmulation::streamHistory(QTextStream* stream) {
275 *stream << scr->getHistory();
276}
275// Refreshing -------------------------------------------------------------- -- 277// Refreshing -------------------------------------------------------------- --
276 278
277#define BULK_TIMEOUT 20 279#define BULK_TIMEOUT 20
278 280
279/*! 281/*!
280 called when \n comes in. Evtl. triggers showBulk at endBulk 282 called when \n comes in. Evtl. triggers showBulk at endBulk
281*/ 283*/
282 284
283void TEmulation::bulkNewline() 285void TEmulation::bulkNewline()
284{ 286{
285 bulk_nlcnt += 1; 287 bulk_nlcnt += 1;
286 bulk_incnt = 0; // reset bulk counter since `nl' rule applies 288 bulk_incnt = 0; // reset bulk counter since `nl' rule applies
287} 289}
288 290
289/*! 291/*!
290*/ 292*/
291 293
292void TEmulation::showBulk() 294void TEmulation::showBulk()
293{ 295{
294 bulk_nlcnt = 0; // reset bulk newline counter 296 bulk_nlcnt = 0; // reset bulk newline counter
295 bulk_incnt = 0; // reset bulk counter 297 bulk_incnt = 0; // reset bulk counter
296 if (connected) 298 if (connected)
297 { 299 {
298 ca* image = scr->getCookedImage(); // get the image 300 ca* image = scr->getCookedImage(); // get the image
diff --git a/noncore/apps/opie-console/TEmulation.h b/noncore/apps/opie-console/TEmulation.h
index ec15e7a..d7b3d6d 100644
--- a/noncore/apps/opie-console/TEmulation.h
+++ b/noncore/apps/opie-console/TEmulation.h
@@ -3,99 +3,104 @@
3/* [emulation.h] Fundamental Terminal Emulation */ 3/* [emulation.h] Fundamental Terminal Emulation */
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#ifndef EMULATION_H 19#ifndef EMULATION_H
20#define EMULATION_H 20#define EMULATION_H
21 21
22#include "TEWidget.h" 22#include "TEWidget.h"
23#include "TEScreen.h" 23#include "TEScreen.h"
24#include <qtimer.h> 24#include <qtimer.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <qtextcodec.h> 26#include <qtextcodec.h>
27#include <qtextstream.h>
28
27#include "keytrans.h" 29#include "keytrans.h"
28 30
29class TEmulation : public QObject 31class TEmulation : public QObject
30{ Q_OBJECT 32{ Q_OBJECT
31 33
32public: 34public:
33 35
34 TEmulation(TEWidget* gui); 36 TEmulation(TEWidget* gui);
35 ~TEmulation(); 37 ~TEmulation();
36 38
37public: 39public:
38 virtual void setHistory(bool on); 40 virtual void setHistory(bool on);
39 virtual bool history(); 41 virtual bool history();
42 virtual void streamHistory( QTextStream* );
40 43
41public slots: // signals incoming from TEWidget 44public slots: // signals incoming from TEWidget
42 45
43 virtual void onImageSizeChange(int lines, int columns); 46 virtual void onImageSizeChange(int lines, int columns);
44 virtual void onHistoryCursorChange(int cursor); 47 virtual void onHistoryCursorChange(int cursor);
45 virtual void onKeyPress(QKeyEvent*); 48 virtual void onKeyPress(QKeyEvent*);
46 49
47 virtual void clearSelection(); 50 virtual void clearSelection();
48 virtual void onSelectionBegin(const int x, const int y); 51 virtual void onSelectionBegin(const int x, const int y);
49 virtual void onSelectionExtend(const int x, const int y); 52 virtual void onSelectionExtend(const int x, const int y);
50 virtual void setSelection(const BOOL preserve_line_breaks); 53 virtual void setSelection(const BOOL preserve_line_breaks);
51 54
52public slots: // signals incoming from data source 55public slots: // signals incoming from data source
53 56
54 void onRcvBlock(const char* txt,int len); 57 void onRcvBlock(const char* txt,int len);
55 58
56signals: 59signals:
57 60
58 void sndBlock(const char* txt,int len); 61 void sndBlock(const char* txt,int len);
59 void ImageSizeChanged(int lines, int columns); 62 void ImageSizeChanged(int lines, int columns);
60 void changeColumns(int columns); 63 void changeColumns(int columns);
61 void changeTitle(int arg, const char* str); 64 void changeTitle(int arg, const char* str);
62 65
63public: 66public:
64 67
65 virtual void onRcvChar(int); 68 virtual void onRcvChar(int);
66 69
67 virtual void setMode (int) = 0; 70 virtual void setMode (int) = 0;
68 virtual void resetMode(int) = 0; 71 virtual void resetMode(int) = 0;
69 72
70 virtual void sendString(const char*) = 0; 73 virtual void sendString(const char*) = 0;
71 74
72 virtual void setConnect(bool r); 75 virtual void setConnect(bool r);
73 void setColumns(int columns); 76 void setColumns(int columns);
74 77
75 void setKeytrans(int no); 78 void setKeytrans(int no);
76 void setKeytrans(const char * no); 79 void setKeytrans(const char * no);
77 80
81
82
78protected: 83protected:
79 84
80 TEWidget* gui; 85 TEWidget* gui;
81 TEScreen* scr; // referes to one `screen' 86 TEScreen* scr; // referes to one `screen'
82 TEScreen* screen[2]; // 0 = primary, 1 = alternate 87 TEScreen* screen[2]; // 0 = primary, 1 = alternate
83 void setScreen(int n); // set `scr' to `screen[n]' 88 void setScreen(int n); // set `scr' to `screen[n]'
84 89
85 bool connected; // communicate with widget 90 bool connected; // communicate with widget
86 91
87 void setCodec(int c); // codec number, 0 = locale, 1=utf8 92 void setCodec(int c); // codec number, 0 = locale, 1=utf8
88 93
89 QTextCodec* codec; 94 QTextCodec* codec;
90 QTextCodec* localeCodec; 95 QTextCodec* localeCodec;
91 QTextDecoder* decoder; 96 QTextDecoder* decoder;
92 97
93 KeyTrans* keytrans; 98 KeyTrans* keytrans;
94 99
95// refreshing related material. 100// refreshing related material.
96// this is localized in the class. 101// this is localized in the class.
97private slots: // triggered by timer 102private slots: // triggered by timer
98 103
99 void showBulk(); 104 void showBulk();
100 105
101private: 106private:
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 7924568..235facb 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -10,48 +10,51 @@
10 10
11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
12 : QObject(0, name ) 12 : QObject(0, name )
13{ 13{
14 m_teWid = new TEWidget( parent, "TerminalMain"); 14 m_teWid = new TEWidget( parent, "TerminalMain");
15 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) 15 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
16 // use setWrapAt(80) for normal console with scrollbar 16 // use setWrapAt(80) for normal console with scrollbar
17 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); 17 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
18 m_teWid->setMinimumSize(150, 70 ); 18 m_teWid->setMinimumSize(150, 70 );
19 m_script = 0; 19 m_script = 0;
20 parent->resize( m_teWid->calcSize(80, 24 ) ); 20 parent->resize( m_teWid->calcSize(80, 24 ) );
21 m_teEmu = new TEmuVt102(m_teWid ); 21 m_teEmu = new TEmuVt102(m_teWid );
22 22
23 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 23 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
24 this, SIGNAL(changeSize(int, int) ) ); 24 this, SIGNAL(changeSize(int, int) ) );
25 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 25 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
26 this, SLOT(recvEmulation(const char*, int) ) ); 26 this, SLOT(recvEmulation(const char*, int) ) );
27 m_teEmu->setConnect( true ); 27 m_teEmu->setConnect( true );
28 m_teEmu->setHistory( TRUE ); 28 m_teEmu->setHistory( TRUE );
29 load( prof ); 29 load( prof );
30 30
31 31
32 32
33} 33}
34TEmulation* EmulationHandler::emulation() {
35 return m_teEmu;
36}
34EmulationHandler::~EmulationHandler() { 37EmulationHandler::~EmulationHandler() {
35 if (isRecording()) 38 if (isRecording())
36 clearScript(); 39 clearScript();
37 delete m_teEmu; 40 delete m_teEmu;
38 delete m_teWid; 41 delete m_teWid;
39} 42}
40 43
41void EmulationHandler::load( const Profile& prof) { 44void EmulationHandler::load( const Profile& prof) {
42 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 45 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
43 int num = prof.readNumEntry("Color"); 46 int num = prof.readNumEntry("Color");
44 setColor( foreColor(num), backColor(num) ); 47 setColor( foreColor(num), backColor(num) );
45 m_teWid->setBackgroundColor(backColor(num) ); 48 m_teWid->setBackgroundColor(backColor(num) );
46 49
47 int term = prof.readNumEntry("Terminal", 0) ; 50 int term = prof.readNumEntry("Terminal", 0) ;
48 switch(term) { 51 switch(term) {
49 default: 52 default:
50 case Profile::VT102: 53 case Profile::VT102:
51 case Profile::VT100: 54 case Profile::VT100:
52 m_teEmu->setKeytrans("vt100.keytab"); 55 m_teEmu->setKeytrans("vt100.keytab");
53 break; 56 break;
54 case Profile::Linux: 57 case Profile::Linux:
55 m_teEmu->setKeytrans("linux.keytab"); 58 m_teEmu->setKeytrans("linux.keytab");
56 break; 59 break;
57 case Profile::XTerm: 60 case Profile::XTerm:
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h
index 7bc6f16..1338525 100644
--- a/noncore/apps/opie-console/emulation_handler.h
+++ b/noncore/apps/opie-console/emulation_handler.h
@@ -26,48 +26,49 @@
26class Profile; 26class Profile;
27class QWidget; 27class QWidget;
28class QPushButton; 28class QPushButton;
29class TEWidget; 29class TEWidget;
30class TEmulation; 30class TEmulation;
31class QFont; 31class QFont;
32class Script; 32class Script;
33class EmulationHandler : public QObject { 33class EmulationHandler : public QObject {
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 /** 36 /**
37 * simple c'tor the parent of the TEWdiget 37 * simple c'tor the parent of the TEWdiget
38 * and a name 38 * and a name
39 * and a Profile 39 * and a Profile
40 */ 40 */
41 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); 41 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l );
42 42
43 /** 43 /**
44 * delete all components 44 * delete all components
45 */ 45 */
46 ~EmulationHandler(); 46 ~EmulationHandler();
47 47
48 void load( const Profile& ); 48 void load( const Profile& );
49 QWidget* widget(); 49 QWidget* widget();
50 TEmulation *emulation();
50 void setColor( const QColor& fore, const QColor& back ); 51 void setColor( const QColor& fore, const QColor& back );
51 QPushButton* cornerButton(); 52 QPushButton* cornerButton();
52 53
53 /* Scripts */ 54 /* Scripts */
54 /* Create a new script and record all typed characters */ 55 /* Create a new script and record all typed characters */
55 void startRecording(); 56 void startRecording();
56 57
57 /* Return whether we are currently recording a script */ 58 /* Return whether we are currently recording a script */
58 bool isRecording(); 59 bool isRecording();
59 60
60 /* Return the current script (or NULL) */ 61 /* Return the current script (or NULL) */
61 Script *script(); 62 Script *script();
62 63
63 /* Stop recording and remove the current script from memory */ 64 /* Stop recording and remove the current script from memory */
64 void clearScript(); 65 void clearScript();
65 66
66 /* Run a script by forwarding its keys to the EmulationLayer */ 67 /* Run a script by forwarding its keys to the EmulationLayer */
67 void runScript(const Script *); 68 void runScript(const Script *);
68 69
69 /* Propagate change to widget */ 70 /* Propagate change to widget */
70 void setWrap(int columns); 71 void setWrap(int columns);
71signals: 72signals:
72 void send( const QByteArray& ); 73 void send( const QByteArray& );
73 void changeSize(int rows, int cols ); 74 void changeSize(int rows, int cols );
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index d221715..01468ca 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,43 +1,45 @@
1#include <assert.h> 1#include <assert.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qmenubar.h> 4#include <qmenubar.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qpopupmenu.h> 6#include <qpopupmenu.h>
7#include <qtoolbar.h> 7#include <qtoolbar.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qwhatsthis.h> 10#include <qwhatsthis.h>
11#include <qfileinfo.h> 11#include <qfileinfo.h>
12#include <qtextstream.h>
12 13
13#include <qpe/resource.h> 14#include <qpe/resource.h>
14#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
15#include <qpe/filemanager.h> 16#include <qpe/filemanager.h>
16#include <qpe/mimetype.h> 17#include <qpe/mimetype.h>
17 18
18#include <opie/ofiledialog.h> 19#include <opie/ofiledialog.h>
19 20
21#include "TEmulation.h"
20#include "keytrans.h" 22#include "keytrans.h"
21#include "profileeditordialog.h" 23#include "profileeditordialog.h"
22#include "configdialog.h" 24#include "configdialog.h"
23#include "default.h" 25#include "default.h"
24#include "metafactory.h" 26#include "metafactory.h"
25#include "profile.h" 27#include "profile.h"
26#include "profilemanager.h" 28#include "profilemanager.h"
27#include "mainwindow.h" 29#include "mainwindow.h"
28#include "tabwidget.h" 30#include "tabwidget.h"
29#include "transferdialog.h" 31#include "transferdialog.h"
30#include "function_keyboard.h" 32#include "function_keyboard.h"
31#include "emulation_handler.h" 33#include "emulation_handler.h"
32#include "script.h" 34#include "script.h"
33 35
34static char * filesave_xpm[] = { 36static char * filesave_xpm[] = {
35"16 16 78 1", 37"16 16 78 1",
36" c None", 38" c None",
37". c #343434", 39". c #343434",
38"+ c #A0A0A0", 40"+ c #A0A0A0",
39"@ c #565656", 41"@ c #565656",
40"# c #9E9E9E", 42"# c #9E9E9E",
41"$ c #525252", 43"$ c #525252",
42"% c #929292", 44"% c #929292",
43"& c #676767", 45"& c #676767",
@@ -220,48 +222,54 @@ void MainWindow::initUI() {
220 m_transfer->addTo( m_console ); 222 m_transfer->addTo( m_console );
221 connect(m_transfer, SIGNAL(activated() ), 223 connect(m_transfer, SIGNAL(activated() ),
222 this, SLOT(slotTransfer() ) ); 224 this, SLOT(slotTransfer() ) );
223 225
224 /* 226 /*
225 * immediate change of line wrap policy 227 * immediate change of line wrap policy
226 */ 228 */
227 m_isWrapped = false; 229 m_isWrapped = false;
228 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); 230 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 );
229 m_wrap->addTo( m_console ); 231 m_wrap->addTo( m_console );
230 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); 232 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
231 233
232 /* 234 /*
233 * fullscreen 235 * fullscreen
234 */ 236 */
235 m_isFullscreen = false; 237 m_isFullscreen = false;
236 238
237 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 239 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
238 , QString::null, 0, this, 0); 240 , QString::null, 0, this, 0);
239 m_fullscreen->addTo( m_console ); 241 m_fullscreen->addTo( m_console );
240 connect( m_fullscreen, SIGNAL( activated() ), 242 connect( m_fullscreen, SIGNAL( activated() ),
241 this, SLOT( slotFullscreen() ) ); 243 this, SLOT( slotFullscreen() ) );
242 244
243 m_console->insertSeparator(); 245 m_console->insertSeparator();
246
247 QAction *a = new QAction();
248 a->setText( tr("Save history") );
249 a->addTo( m_console );
250 connect(a, SIGNAL(activated() ),
251 this, SLOT(slotSaveHistory() ) );
244 /* 252 /*
245 * terminate action 253 * terminate action
246 */ 254 */
247 m_terminate = new QAction(); 255 m_terminate = new QAction();
248 m_terminate->setText( tr("Terminate") ); 256 m_terminate->setText( tr("Terminate") );
249 m_terminate->addTo( m_console ); 257 m_terminate->addTo( m_console );
250 connect(m_terminate, SIGNAL(activated() ), 258 connect(m_terminate, SIGNAL(activated() ),
251 this, SLOT(slotTerminate() ) ); 259 this, SLOT(slotTerminate() ) );
252 260
253 m_closewindow = new QAction(); 261 m_closewindow = new QAction();
254 m_closewindow->setText( tr("Close Window") ); 262 m_closewindow->setText( tr("Close Window") );
255 m_closewindow->addTo( m_console ); 263 m_closewindow->addTo( m_console );
256 connect( m_closewindow, SIGNAL(activated() ), 264 connect( m_closewindow, SIGNAL(activated() ),
257 this, SLOT(slotClose() ) ); 265 this, SLOT(slotClose() ) );
258 266
259 267
260 /* 268 /*
261 * script actions 269 * script actions
262 */ 270 */
263 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 271 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
264 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 272 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
265 273
266 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 274 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
267 m_recordScript->addTo(m_scripts); 275 m_recordScript->addTo(m_scripts);
@@ -281,49 +289,49 @@ void MainWindow::initUI() {
281 m_openKeys->setToggleAction(true); 289 m_openKeys->setToggleAction(true);
282 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 290 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
283 291
284 /* insert the submenu */ 292 /* insert the submenu */
285 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 293 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
286 -1, 0); 294 -1, 0);
287 295
288 /* insert the connection menu */ 296 /* insert the connection menu */
289 m_bar->insertItem( tr("Connection"), m_console ); 297 m_bar->insertItem( tr("Connection"), m_console );
290 298
291 /* the scripts menu */ 299 /* the scripts menu */
292 m_bar->insertItem( tr("Scripts"), m_scripts ); 300 m_bar->insertItem( tr("Scripts"), m_scripts );
293 301
294 /* and the keyboard */ 302 /* and the keyboard */
295 m_keyBar = new QToolBar(this); 303 m_keyBar = new QToolBar(this);
296 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 304 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
297 m_keyBar->setHorizontalStretchable( TRUE ); 305 m_keyBar->setHorizontalStretchable( TRUE );
298 m_keyBar->hide(); 306 m_keyBar->hide();
299 307
300 m_kb = new FunctionKeyboard(m_keyBar); 308 m_kb = new FunctionKeyboard(m_keyBar);
301 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 309 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
302 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 310 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
303 311
304 312
305 QAction *a = new QAction(tr("Copy"), 313 a = new QAction(tr("Copy"),
306 Resource::loadPixmap("copy"), QString::null, 314 Resource::loadPixmap("copy"), QString::null,
307 0, this, 0 ); 315 0, this, 0 );
308 //a->addTo( m_icons ); 316 //a->addTo( m_icons );
309 connect( a, SIGNAL(activated() ), 317 connect( a, SIGNAL(activated() ),
310 this, SLOT(slotCopy() ) ); 318 this, SLOT(slotCopy() ) );
311 319
312 QAction *paste = new QAction(tr("Paste"), 320 QAction *paste = new QAction(tr("Paste"),
313 Resource::loadPixmap("paste"), QString::null, 321 Resource::loadPixmap("paste"), QString::null,
314 0, this, 0 ); 322 0, this, 0 );
315 connect( paste, SIGNAL(activated() ), 323 connect( paste, SIGNAL(activated() ),
316 this, SLOT(slotPaste() ) ); 324 this, SLOT(slotPaste() ) );
317 325
318 326
319 newCon->addTo( m_icons ); 327 newCon->addTo( m_icons );
320 m_setProfiles->addTo( m_icons ); 328 m_setProfiles->addTo( m_icons );
321 paste->addTo( m_icons ); 329 paste->addTo( m_icons );
322 m_openKeys->addTo(m_icons); 330 m_openKeys->addTo(m_icons);
323 m_fullscreen->addTo( m_icons ); 331 m_fullscreen->addTo( m_icons );
324 332
325 m_connect->setEnabled( false ); 333 m_connect->setEnabled( false );
326 m_disconnect->setEnabled( false ); 334 m_disconnect->setEnabled( false );
327 m_terminate->setEnabled( false ); 335 m_terminate->setEnabled( false );
328 m_transfer->setEnabled( false ); 336 m_transfer->setEnabled( false );
329 m_scripts->setItemEnabled(m_runScript_id, false); 337 m_scripts->setItemEnabled(m_runScript_id, false);
@@ -747,24 +755,49 @@ void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
747} 755}
748void MainWindow::slotCopy() { 756void MainWindow::slotCopy() {
749 if (!currentSession() ) return; 757 if (!currentSession() ) return;
750 currentSession()->emulationHandler()->copy(); 758 currentSession()->emulationHandler()->copy();
751} 759}
752void MainWindow::slotPaste() { 760void MainWindow::slotPaste() {
753 if (!currentSession() ) return; 761 if (!currentSession() ) return;
754 currentSession()->emulationHandler()->paste(); 762 currentSession()->emulationHandler()->paste();
755} 763}
756 764
757/* 765/*
758 * Save the session 766 * Save the session
759 */ 767 */
760 768
761void MainWindow::slotSaveSession() { 769void MainWindow::slotSaveSession() {
762 if (!currentSession() ) { 770 if (!currentSession() ) {
763 QMessageBox::information(this, tr("Save Connection"), 771 QMessageBox::information(this, tr("Save Connection"),
764 tr("<qt>There is no Connection.</qt>"), 1 ); 772 tr("<qt>There is no Connection.</qt>"), 1 );
765 return; 773 return;
766 } 774 }
767 manager()->add( currentSession()->profile() ); 775 manager()->add( currentSession()->profile() );
768 manager()->save(); 776 manager()->save();
769 populateProfiles(); 777 populateProfiles();
770} 778}
779void MainWindow::slotSaveHistory() {
780 QMap<QString, QStringList> map;
781 QStringList text;
782 text << "text/plain";
783 map.insert(tr("History"), text );
784 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
785 if (filename.isEmpty() ) return;
786
787 QFileInfo info(filename);
788
789 DocLnk nf;
790 nf.setType("text/plain");
791 nf.setFile(filename);
792 nf.setName(info.fileName());
793
794
795 QFile file(filename);
796 file.open(IO_WriteOnly );
797 QTextStream str(&file );
798 if ( currentSession() )
799 currentSession()->emulationHandler()->emulation()->streamHistory(&str);
800
801 file.close();
802 nf.writeLink();
803}
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 37219c5..0fac38b 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -49,48 +49,49 @@ public:
49 /** 49 /**
50 * 50 *
51 */ 51 */
52 ProfileManager* manager(); 52 ProfileManager* manager();
53 TabWidget* tabWidget(); 53 TabWidget* tabWidget();
54 54
55private slots: 55private slots:
56 void slotNew(); 56 void slotNew();
57 void slotConnect(); 57 void slotConnect();
58 void slotDisconnect(); 58 void slotDisconnect();
59 void slotTerminate(); 59 void slotTerminate();
60 void slotConfigure(); 60 void slotConfigure();
61 void slotClose(); 61 void slotClose();
62 void slotProfile(int); 62 void slotProfile(int);
63 void slotTransfer(); 63 void slotTransfer();
64 void slotOpenKeb(bool); 64 void slotOpenKeb(bool);
65 void slotOpenButtons(bool); 65 void slotOpenButtons(bool);
66 void slotRecordScript(); 66 void slotRecordScript();
67 void slotSaveScript(); 67 void slotSaveScript();
68 void slotRunScript(int); 68 void slotRunScript(int);
69 void slotFullscreen(); 69 void slotFullscreen();
70 void slotWrap(); 70 void slotWrap();
71 void slotSessionChanged( Session* ); 71 void slotSessionChanged( Session* );
72 void slotKeyReceived(FKey, ushort, ushort, bool); 72 void slotKeyReceived(FKey, ushort, ushort, bool);
73 void slotSaveHistory();
73 74
74 /* what could these both slot do? */ 75 /* what could these both slot do? */
75 void slotCopy(); 76 void slotCopy();
76 void slotPaste(); 77 void slotPaste();
77 78
78 /* save the currentSession() to Profiles */ 79 /* save the currentSession() to Profiles */
79 void slotSaveSession(); 80 void slotSaveSession();
80 81
81private: 82private:
82 void initUI(); 83 void initUI();
83 void populateProfiles(); 84 void populateProfiles();
84 void populateScripts(); 85 void populateScripts();
85 void create( const Profile& ); 86 void create( const Profile& );
86 /** 87 /**
87 * the current session 88 * the current session
88 */ 89 */
89 Session* m_curSession; 90 Session* m_curSession;
90 91
91 /** 92 /**
92 * the session list 93 * the session list
93 */ 94 */
94 QList<Session> m_sessions; 95 QList<Session> m_sessions;
95 QList<DocLnk> m_scriptsData; 96 QList<DocLnk> m_scriptsData;
96 97
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 0b43e17..24928e7 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -22,102 +22,88 @@ void MetaFactory::addKeyboardWidgetFactory( const QCString& name,
22 const QString & str, 22 const QString & str,
23 configWidget wid) { 23 configWidget wid) {
24 m_strings.insert( str, name ); 24 m_strings.insert( str, name );
25 m_keyFact.insert( str, wid ); 25 m_keyFact.insert( str, wid );
26 26
27} 27}
28void MetaFactory::addIOLayerFactory( const QCString& name, 28void MetaFactory::addIOLayerFactory( const QCString& name,
29 const QString& str, 29 const QString& str,
30 iolayer lay) { 30 iolayer lay) {
31 m_strings.insert( str, name ); 31 m_strings.insert( str, name );
32 m_layerFact.insert( str, lay ); 32 m_layerFact.insert( str, lay );
33} 33}
34void MetaFactory::addFileTransferLayer( const QCString& name, 34void MetaFactory::addFileTransferLayer( const QCString& name,
35 const QString& str, 35 const QString& str,
36 filelayer lay) { 36 filelayer lay) {
37 m_strings.insert(str, name ); 37 m_strings.insert(str, name );
38 m_fileFact.insert( str, lay ); 38 m_fileFact.insert( str, lay );
39} 39}
40void MetaFactory::addReceiveLayer( const QCString& name, 40void MetaFactory::addReceiveLayer( const QCString& name,
41 const QString& str, 41 const QString& str,
42 receivelayer lay) { 42 receivelayer lay) {
43 m_strings.insert(str, name ); 43 m_strings.insert(str, name );
44 m_receiveFact.insert( str, lay ); 44 m_receiveFact.insert( str, lay );
45} 45}
46void MetaFactory::addEmulationLayer( const QCString& name,
47 const QString& str,
48 emulationLayer em) {
49 m_strings.insert(str, name );
50 m_emu.insert( str, em );
51}
52QStringList MetaFactory::ioLayers()const { 46QStringList MetaFactory::ioLayers()const {
53 QStringList list; 47 QStringList list;
54 QMap<QString, iolayer>::ConstIterator it; 48 QMap<QString, iolayer>::ConstIterator it;
55 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { 49 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
56 list << it.key(); 50 list << it.key();
57 } 51 }
58 return list; 52 return list;
59} 53}
60QStringList MetaFactory::connectionWidgets()const { 54QStringList MetaFactory::connectionWidgets()const {
61 QStringList list; 55 QStringList list;
62 QMap<QString, configWidget>::ConstIterator it; 56 QMap<QString, configWidget>::ConstIterator it;
63 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { 57 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
64 list << it.key(); 58 list << it.key();
65 } 59 }
66 return list; 60 return list;
67} 61}
68QStringList MetaFactory::terminalWidgets()const { 62QStringList MetaFactory::terminalWidgets()const {
69 QStringList list; 63 QStringList list;
70 QMap<QString, configWidget>::ConstIterator it; 64 QMap<QString, configWidget>::ConstIterator it;
71 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { 65 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
72 list << it.key(); 66 list << it.key();
73 } 67 }
74 return list; 68 return list;
75} 69}
76QStringList MetaFactory::fileTransferLayers()const { 70QStringList MetaFactory::fileTransferLayers()const {
77 QStringList list; 71 QStringList list;
78 QMap<QString, filelayer>::ConstIterator it; 72 QMap<QString, filelayer>::ConstIterator it;
79 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { 73 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
80 list << it.key(); 74 list << it.key();
81 } 75 }
82 return list; 76 return list;
83} 77}
84QStringList MetaFactory::receiveLayers()const { 78QStringList MetaFactory::receiveLayers()const {
85 QStringList list; 79 QStringList list;
86 QMap<QString, receivelayer>::ConstIterator it; 80 QMap<QString, receivelayer>::ConstIterator it;
87 for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) { 81 for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) {
88 list << it.key(); 82 list << it.key();
89 } 83 }
90 return list; 84 return list;
91} 85}
92QStringList MetaFactory::emulationLayers()const {
93 QStringList list;
94 QMap<QString, emulationLayer>::ConstIterator it;
95 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) {
96 list << it.key();
97 }
98 return list;
99}
100 86
101IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { 87IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
102 IOLayer* lay = 0l; 88 IOLayer* lay = 0l;
103 89
104 QMap<QString, iolayer>::Iterator it; 90 QMap<QString, iolayer>::Iterator it;
105 it = m_layerFact.find( str ); 91 it = m_layerFact.find( str );
106 if ( it != m_layerFact.end() ) { 92 if ( it != m_layerFact.end() ) {
107 lay = (*(it.data()))(prof); 93 lay = (*(it.data()))(prof);
108 /* 94 /*
109 iolayer laye = it.data(); 95 iolayer laye = it.data();
110 lay = (*laye )(conf);*/ 96 lay = (*laye )(conf);*/
111 } 97 }
112 98
113 return lay; 99 return lay;
114} 100}
115 101
116ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { 102ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
117 ProfileDialogWidget* wid = 0l; 103 ProfileDialogWidget* wid = 0l;
118 104
119 QMap<QString, configWidget>::Iterator it; 105 QMap<QString, configWidget>::Iterator it;
120 it = m_conFact.find( str ); 106 it = m_conFact.find( str );
121 if ( it != m_conFact.end() ) { 107 if ( it != m_conFact.end() ) {
122 wid = (*(it.data() ) )(str,parent); 108 wid = (*(it.data() ) )(str,parent);
123 } 109 }
@@ -127,59 +113,48 @@ ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget
127 if (str.isEmpty() ) 113 if (str.isEmpty() )
128 return 0l; 114 return 0l;
129 ProfileDialogWidget* wid = 0l; 115 ProfileDialogWidget* wid = 0l;
130 116
131 QMap<QString, configWidget>::Iterator it; 117 QMap<QString, configWidget>::Iterator it;
132 it = m_termFact.find( str ); 118 it = m_termFact.find( str );
133 if ( it != m_termFact.end() ) { 119 if ( it != m_termFact.end() ) {
134 wid = (*(it.data() ) )(str,parent); 120 wid = (*(it.data() ) )(str,parent);
135 } 121 }
136 return wid; 122 return wid;
137} 123}
138ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget *parent) { 124ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget *parent) {
139 125
140 if (str.isEmpty() ) 126 if (str.isEmpty() )
141 return 0l; 127 return 0l;
142 ProfileDialogWidget* wid = 0l; 128 ProfileDialogWidget* wid = 0l;
143 129
144 QMap<QString, configWidget>::Iterator it; 130 QMap<QString, configWidget>::Iterator it;
145 it = m_keyFact.find( str ); 131 it = m_keyFact.find( str );
146 if ( it != m_keyFact.end() ) { 132 if ( it != m_keyFact.end() ) {
147 wid = (*(it.data() ) )(str,parent); 133 wid = (*(it.data() ) )(str,parent);
148 } 134 }
149 return wid; 135 return wid;
150} 136}
151EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) {
152 EmulationLayer* lay = 0l;
153
154 QMap<QString, emulationLayer>::Iterator it;
155 it = m_emu.find( str );
156 if ( it != m_emu.end() ) {
157 lay = (*(it.data() ) )(wid);
158 }
159
160 return lay;
161}
162FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { 137FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) {
163 FileTransferLayer* file = 0l; 138 FileTransferLayer* file = 0l;
164 QMap<QString, filelayer>::Iterator it; 139 QMap<QString, filelayer>::Iterator it;
165 it = m_fileFact.find( str ); 140 it = m_fileFact.find( str );
166 if ( it != m_fileFact.end() ) { 141 if ( it != m_fileFact.end() ) {
167 file = (*(it.data() ) )(lay); 142 file = (*(it.data() ) )(lay);
168 } 143 }
169 return file; 144 return file;
170} 145}
171ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) { 146ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) {
172 ReceiveLayer* file = 0l; 147 ReceiveLayer* file = 0l;
173 QMap<QString, receivelayer>::Iterator it; 148 QMap<QString, receivelayer>::Iterator it;
174 it = m_receiveFact.find( str ); 149 it = m_receiveFact.find( str );
175 if ( it != m_receiveFact.end() ) { 150 if ( it != m_receiveFact.end() ) {
176 file = (*(it.data() ) )(lay); 151 file = (*(it.data() ) )(lay);
177 } 152 }
178 return file; 153 return file;
179} 154}
180QCString MetaFactory::internal( const QString& str )const { 155QCString MetaFactory::internal( const QString& str )const {
181 return m_strings[str]; 156 return m_strings[str];
182} 157}
183QString MetaFactory::external( const QCString& str )const { 158QString MetaFactory::external( const QCString& str )const {
184 QMap<QString, QCString>::ConstIterator it; 159 QMap<QString, QCString>::ConstIterator it;
185 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { 160 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index f89136c..bcc40db 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -1,120 +1,109 @@
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 "receive_layer.h"
17#include "profile.h" 17#include "profile.h"
18#include "profiledialogwidget.h" 18#include "profiledialogwidget.h"
19#include "emulation_layer.h"
20 19
21class WidgetLayer; 20class WidgetLayer;
22class MetaFactory { 21class MetaFactory {
23public: 22public:
24 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); 23 typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
25 typedef IOLayer* (*iolayer)(const Profile& ); 24 typedef IOLayer* (*iolayer)(const Profile& );
26 typedef FileTransferLayer* (*filelayer)(IOLayer*); 25 typedef FileTransferLayer* (*filelayer)(IOLayer*);
27 typedef ReceiveLayer* (*receivelayer)(IOLayer*); 26 typedef ReceiveLayer* (*receivelayer)(IOLayer*);
28 typedef EmulationLayer* (*emulationLayer)(WidgetLayer* );
29 27
30 MetaFactory(); 28 MetaFactory();
31 ~MetaFactory(); 29 ~MetaFactory();
32 30
33 /** 31 /**
34 * add a ProfileDialogWidget to the factory 32 * add a ProfileDialogWidget to the factory
35 * name is the name shown to the user 33 * name is the name shown to the user
36 */ 34 */
37 void addConnectionWidgetFactory( const QCString& internalName, 35 void addConnectionWidgetFactory( const QCString& internalName,
38 const QString& uiString, 36 const QString& uiString,
39 configWidget ); 37 configWidget );
40 void addTerminalWidgetFactory ( const QCString& internalName, 38 void addTerminalWidgetFactory ( const QCString& internalName,
41 const QString& name, 39 const QString& name,
42 configWidget ); 40 configWidget );
43 void addKeyboardWidgetFactory ( const QCString& internalName, 41 void addKeyboardWidgetFactory ( const QCString& internalName,
44 const QString& name, 42 const QString& name,
45 configWidget ); 43 configWidget );
46 44
47 /** 45 /**
48 * adds an IOLayer factory 46 * adds an IOLayer factory
49 */ 47 */
50 void addIOLayerFactory( const QCString&, 48 void addIOLayerFactory( const QCString&,
51 const QString&, 49 const QString&,
52 iolayer ); 50 iolayer );
53 51
54 /** 52 /**
55 * adds a FileTransfer Layer 53 * adds a FileTransfer Layer
56 */ 54 */
57 void addFileTransferLayer( const QCString& name, 55 void addFileTransferLayer( const QCString& name,
58 const QString&, 56 const QString&,
59 filelayer ); 57 filelayer );
60 void addReceiveLayer( const QCString& name, 58 void addReceiveLayer( const QCString& name,
61 const QString&, 59 const QString&,
62 receivelayer); 60 receivelayer);
63 61
64 /**
65 * adds a Factory for Emulation to the Layer..
66 */
67 void addEmulationLayer ( const QCString& name,
68 const QString& uiString,
69 emulationLayer );
70 62
71 /* translated UI Strings */ 63 /* translated UI Strings */
72 QStringList ioLayers()const; 64 QStringList ioLayers()const;
73 QStringList connectionWidgets()const; 65 QStringList connectionWidgets()const;
74 66
75 /** 67 /**
76 * Terminal Configuration widgets 68 * Terminal Configuration widgets
77 */ 69 */
78 QStringList terminalWidgets()const; 70 QStringList terminalWidgets()const;
79 QStringList fileTransferLayers()const; 71 QStringList fileTransferLayers()const;
80 QStringList receiveLayers()const; 72 QStringList receiveLayers()const;
81 QStringList emulationLayers()const;
82 73
83 /** 74 /**
84 * the generation... 75 * the generation...
85 */ 76 */
86 IOLayer* newIOLayer( const QString&,const Profile& ); 77 IOLayer* newIOLayer( const QString&,const Profile& );
87 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); 78 ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
88 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); 79 ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
89 ProfileDialogWidget* newKeyboardPlugin( const QString&, QWidget* ); 80 ProfileDialogWidget* newKeyboardPlugin( const QString&, QWidget* );
90 EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* );
91 FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); 81 FileTransferLayer* newFileTransfer(const QString&, IOLayer* );
92 ReceiveLayer* newReceive(const QString&, IOLayer* ); 82 ReceiveLayer* newReceive(const QString&, IOLayer* );
93 83
94 /* 84 /*
95 * internal takes the maybe translated 85 * internal takes the maybe translated
96 * public QString and maps it to the internal 86 * public QString and maps it to the internal
97 * not translatable QCString 87 * not translatable QCString
98 */ 88 */
99 QCString internal( const QString& )const; 89 QCString internal( const QString& )const;
100 90
101 /* 91 /*
102 * external takes the internal name 92 * external takes the internal name
103 * it returns a translated name 93 * it returns a translated name
104 */ 94 */
105 QString external( const QCString& )const; 95 QString external( const QCString& )const;
106 96
107 97
108private: 98private:
109 QMap<QString, QCString> m_strings; 99 QMap<QString, QCString> m_strings;
110 QMap<QString, configWidget> m_conFact; 100 QMap<QString, configWidget> m_conFact;
111 QMap<QString, configWidget> m_termFact; 101 QMap<QString, configWidget> m_termFact;
112 QMap<QString, configWidget> m_keyFact; 102 QMap<QString, configWidget> m_keyFact;
113 QMap<QString, iolayer> m_layerFact; 103 QMap<QString, iolayer> m_layerFact;
114 QMap<QString, filelayer> m_fileFact; 104 QMap<QString, filelayer> m_fileFact;
115 QMap<QString, receivelayer> m_receiveFact; 105 QMap<QString, receivelayer> m_receiveFact;
116 QMap<QString, emulationLayer> m_emu;
117}; 106};
118 107
119 108
120#endif 109#endif