summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-10-08 20:03:40 (UTC)
committer harlekin <harlekin>2004-10-08 20:03:40 (UTC)
commit4e884ee63f16d1367ff7b854dbe5b50a6871c008 (patch) (unidiff)
treefb9d9d13e9329e6ee9048bfc0e857d3918f4ecca
parent51e49f0bd035545b983c799f7089de6b0ff2547e (diff)
downloadopie-4e884ee63f16d1367ff7b854dbe5b50a6871c008.zip
opie-4e884ee63f16d1367ff7b854dbe5b50a6871c008.tar.gz
opie-4e884ee63f16d1367ff7b854dbe5b50a6871c008.tar.bz2
added a 10east define for some changed builds for them, also added a logging mode, also some changes to the "fix broken distros" part, snapshot
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp1
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp34
-rw-r--r--noncore/apps/opie-console/emulation_handler.h16
-rw-r--r--noncore/apps/opie-console/fixit.cpp101
-rw-r--r--noncore/apps/opie-console/fixit.h77
-rw-r--r--noncore/apps/opie-console/logger.cpp20
-rw-r--r--noncore/apps/opie-console/logger.h19
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp60
-rw-r--r--noncore/apps/opie-console/mainwindow.h4
-rw-r--r--noncore/apps/opie-console/opie-console-embedix.control10
-rw-r--r--noncore/apps/opie-console/opie-console.pro14
11 files changed, 275 insertions, 81 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index 6d57703..315ea4a 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -24,128 +24,129 @@
24*/ 24*/
25 25
26/*! \class TEPty 26/*! \class TEPty
27 27
28 \brief Ptys provide a pseudo terminal connection to a program. 28 \brief Ptys provide a pseudo terminal connection to a program.
29 29
30 Although closely related to pipes, these pseudo terminal connections have 30 Although closely related to pipes, these pseudo terminal connections have
31 some ability, that makes it nessesary to uses them. Most importent, they 31 some ability, that makes it nessesary to uses them. Most importent, they
32 know about changing screen sizes and UNIX job control. 32 know about changing screen sizes and UNIX job control.
33 33
34 Within the terminal emulation framework, this class represents the 34 Within the terminal emulation framework, this class represents the
35 host side of the terminal together with the connecting serial line. 35 host side of the terminal together with the connecting serial line.
36 36
37 One can create many instances of this class within a program. 37 One can create many instances of this class within a program.
38 As a side effect of using this class, a signal(2) handler is 38 As a side effect of using this class, a signal(2) handler is
39 installed on SIGCHLD. 39 installed on SIGCHLD.
40 40
41 \par FIXME 41 \par FIXME
42 42
43 [NOTE: much of the technical stuff below will be replaced by forkpty.] 43 [NOTE: much of the technical stuff below will be replaced by forkpty.]
44 44
45 publish the SIGCHLD signal if not related to an instance. 45 publish the SIGCHLD signal if not related to an instance.
46 46
47 clearify TEPty::done vs. TEPty::~TEPty semantics. 47 clearify TEPty::done vs. TEPty::~TEPty semantics.
48 check if pty is restartable via run after done. 48 check if pty is restartable via run after done.
49 49
50 \par Pseudo terminals 50 \par Pseudo terminals
51 51
52 Pseudo terminals are a unique feature of UNIX, and always come in form of 52 Pseudo terminals are a unique feature of UNIX, and always come in form of
53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each 53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
54 other by the operating system. One may think of them as two serial devices 54 other by the operating system. One may think of them as two serial devices
55 linked by a null-modem cable. Being based on devices the number of 55 linked by a null-modem cable. Being based on devices the number of
56 simultanous instances of this class is (globally) limited by the number of 56 simultanous instances of this class is (globally) limited by the number of
57 those device pairs, which is 256. 57 those device pairs, which is 256.
58 58
59 Another technic are UNIX 98 PTY's. These are supported also, and prefered 59 Another technic are UNIX 98 PTY's. These are supported also, and prefered
60 over the (obsolete) predecessor. 60 over the (obsolete) predecessor.
61 61
62 There's a sinister ioctl(2), signal(2) and job control stuff 62 There's a sinister ioctl(2), signal(2) and job control stuff
63 nessesary to make everything work as it should. 63 nessesary to make everything work as it should.
64*/ 64*/
65 65
66#include "procctl.h" 66#include "procctl.h"
67#include "MyPty.h" 67#include "MyPty.h"
68 68
69/* OPIE */ 69/* OPIE */
70#include <opie2/odebug.h> 70#include <opie2/odebug.h>
71using namespace Opie::Core; 71using namespace Opie::Core;
72 72
73/* QT */ 73/* QT */
74#include <qsocketnotifier.h> 74#include <qsocketnotifier.h>
75#include <qfile.h> 75#include <qfile.h>
76 76
77/* STD */ 77/* STD */
78#include <stdlib.h> 78#include <stdlib.h>
79#include <stdio.h> 79#include <stdio.h>
80#include <signal.h> 80#include <signal.h>
81#include <fcntl.h> 81#include <fcntl.h>
82#include <unistd.h> 82#include <unistd.h>
83#include <termios.h> 83#include <termios.h>
84#include <sys/types.h> 84#include <sys/types.h>
85#include <sys/ioctl.h> 85#include <sys/ioctl.h>
86#include <sys/wait.h> 86#include <sys/wait.h>
87 87
88
88#ifdef HAVE_OPENPTY 89#ifdef HAVE_OPENPTY
89#include <pty.h> 90#include <pty.h>
90#endif 91#endif
91 92
92#undef VERBOSE_DEBUG 93#undef VERBOSE_DEBUG
93 94
94 95
95/* -------------------------------------------------------------------------- */ 96/* -------------------------------------------------------------------------- */
96 97
97/*! 98/*!
98 Informs the client program about the 99 Informs the client program about the
99 actual size of the window. 100 actual size of the window.
100*/ 101*/
101 102
102void MyPty::setSize(int lines, int columns) 103void MyPty::setSize(int lines, int columns)
103{ 104{
104 owarn << "setting size" << oendl; 105 owarn << "setting size" << oendl;
105 struct winsize wsize; 106 struct winsize wsize;
106 wsize.ws_row = (unsigned short)lines; 107 wsize.ws_row = (unsigned short)lines;
107 wsize.ws_col = (unsigned short)columns; 108 wsize.ws_col = (unsigned short)columns;
108 if(m_fd < 0) return; 109 if(m_fd < 0) return;
109 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); 110 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
110} 111}
111 112
112 113
113void MyPty::donePty() 114void MyPty::donePty()
114{ 115{
115 // This is code from the Qt DumbTerminal example 116 // This is code from the Qt DumbTerminal example
116 117
117 ::close(m_fd); 118 ::close(m_fd);
118 119
119 if (m_cpid) { 120 if (m_cpid) {
120 kill(m_cpid, SIGHUP); 121 kill(m_cpid, SIGHUP);
121 //waitpid(m_cpid, &status, 0); 122 //waitpid(m_cpid, &status, 0);
122 delete m_sn_e; 123 delete m_sn_e;
123 delete m_sn_r; 124 delete m_sn_r;
124 m_sn_e = 0l; 125 m_sn_e = 0l;
125 m_sn_r = 0l; 126 m_sn_r = 0l;
126 } 127 }
127 128
128 m_cpid = 0; 129 m_cpid = 0;
129 m_fd = -1; 130 m_fd = -1;
130// emit done(status); 131// emit done(status);
131} 132}
132 133
133 134
134const char* MyPty::deviceName() 135const char* MyPty::deviceName()
135{ 136{
136 return m_ttynam; 137 return m_ttynam;
137} 138}
138 139
139 140
140void MyPty::error() 141void MyPty::error()
141{ 142{
142 // This is code from the Qt DumbTerminal example 143 // This is code from the Qt DumbTerminal example
143 donePty(); 144 donePty();
144} 145}
145 146
146void MyPty::start() { 147void MyPty::start() {
147 QStrList lis; 148 QStrList lis;
148 int r =run(m_cmd.latin1(), lis, 0, 0); 149 int r =run(m_cmd.latin1(), lis, 0, 0);
149 r = r; 150 r = r;
150} 151}
151/*! 152/*!
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 956ac76..e045aef 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,213 +1,247 @@
1#include "TEmuVt102.h" 1#include "TEmuVt102.h"
2#include "profile.h" 2#include "profile.h"
3#include "emulation_handler.h" 3#include "emulation_handler.h"
4#include "script.h" 4#include "script.h"
5#include "logger.h"
5 6
6/* OPIE */ 7/* OPIE */
7#include <opie2/odebug.h> 8#include <opie2/odebug.h>
9
10#include <qfile.h>
11#include <qtextstream.h>
12
8using namespace Opie::Core; 13using namespace Opie::Core;
9 14
10EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 15EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
11 : QObject(0, name ) 16 : QObject(0, name )
12{ 17{
13 m_teWid = new TEWidget( parent, "TerminalMain"); 18 m_teWid = new TEWidget( parent, "TerminalMain");
14 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) 19 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
15 // use setWrapAt(80) for normal console with scrollbar 20 // use setWrapAt(80) for normal console with scrollbar
16 setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80); 21 setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80);
17 m_teWid->setMinimumSize(150, 70 ); 22 m_teWid->setMinimumSize(150, 70 );
18 m_script = 0; 23 m_script = 0;
24 m_log = 0;
19 parent->resize( m_teWid->calcSize(80, 24 ) ); 25 parent->resize( m_teWid->calcSize(80, 24 ) );
20 m_teEmu = new TEmuVt102(m_teWid ); 26 m_teEmu = new TEmuVt102(m_teWid );
21 27
22 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), 28 connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ),
23 this, SIGNAL(changeSize(int,int) ) ); 29 this, SIGNAL(changeSize(int,int) ) );
24 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), 30 connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ),
25 this, SLOT(recvEmulation(const char*,int) ) ); 31 this, SLOT(recvEmulation(const char*,int) ) );
26 m_teEmu->setConnect( true ); 32 m_teEmu->setConnect( true );
27 m_teEmu->setHistory( TRUE ); 33 m_teEmu->setHistory( TRUE );
28 load( prof ); 34 load( prof );
29 35
30 36
31 37
32} 38}
33TEmulation* EmulationHandler::emulation() { 39TEmulation* EmulationHandler::emulation() {
34 return m_teEmu; 40 return m_teEmu;
35} 41}
36EmulationHandler::~EmulationHandler() { 42EmulationHandler::~EmulationHandler() {
37 if (isRecording()) 43 if (isRecording())
38 clearScript(); 44 clearScript();
39 delete m_teEmu; 45 delete m_teEmu;
40 delete m_teWid; 46 delete m_teWid;
47 delete m_log;
41} 48}
42 49
43void EmulationHandler::load( const Profile& prof) { 50void EmulationHandler::load( const Profile& prof) {
44 51
45// m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 52// m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
46 QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal ); 53 QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal );
47 font.setFixedPitch( TRUE ); 54 font.setFixedPitch( TRUE );
48 m_teWid->setVTFont( font ); 55 m_teWid->setVTFont( font );
49 56
50 int num = prof.readNumEntry("Color"); 57 int num = prof.readNumEntry("Color");
51 setColor( foreColor(num), backColor(num) ); 58 setColor( foreColor(num), backColor(num) );
52 m_teWid->setBackgroundColor(backColor(num) ); 59 m_teWid->setBackgroundColor(backColor(num) );
53 60
54 int term = prof.readNumEntry("Terminal", 0) ; 61 int term = prof.readNumEntry("Terminal", 0) ;
55 switch(term) { 62 switch(term) {
56 default: 63 default:
57 case Profile::VT102: 64 case Profile::VT102:
58 case Profile::VT100: 65 case Profile::VT100:
59 m_teEmu->setKeytrans("vt100.keytab"); 66 m_teEmu->setKeytrans("vt100.keytab");
60 break; 67 break;
61 case Profile::Linux: 68 case Profile::Linux:
62 m_teEmu->setKeytrans("linux.keytab"); 69 m_teEmu->setKeytrans("linux.keytab");
63 break; 70 break;
64 case Profile::XTerm: 71 case Profile::XTerm:
65 m_teEmu->setKeytrans("default.Keytab"); 72 m_teEmu->setKeytrans("default.Keytab");
66 break; 73 break;
67 } 74 }
68} 75}
69void EmulationHandler::recv( const QByteArray& ar) { 76void EmulationHandler::recv( const QByteArray& ar) {
70 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 77 m_teEmu->onRcvBlock(ar.data(), ar.count() );
78 if ( isLogging() ) {
79 m_log->append( ar );
80 }
71} 81}
82
72void EmulationHandler::recvEmulation(const char* src, int len ) { 83void EmulationHandler::recvEmulation(const char* src, int len ) {
73 QByteArray ar(len); 84 QByteArray ar(len);
74 85
75 memcpy(ar.data(), src, sizeof(char) * len ); 86 memcpy(ar.data(), src, sizeof(char) * len );
76 if (isRecording()) 87 if (isRecording())
77 m_script->append(ar); 88 m_script->append(ar);
78 emit send(ar); 89 emit send(ar);
79} 90}
91
92
80QWidget* EmulationHandler::widget() { 93QWidget* EmulationHandler::widget() {
81 return m_teWid; 94 return m_teWid;
82} 95}
83/* 96/*
84 * allocate a new table of colors 97 * allocate a new table of colors
85 */ 98 */
86void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 99void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
87 ColorEntry table[TABLE_COLORS]; 100 ColorEntry table[TABLE_COLORS];
88 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 101 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
89 102
90 for (int i = 0; i < TABLE_COLORS; i++ ) { 103 for (int i = 0; i < TABLE_COLORS; i++ ) {
91 if ( i == 0 || i == 10 ) { 104 if ( i == 0 || i == 10 ) {
92 table[i].color = fore; 105 table[i].color = fore;
93 }else if ( i == 1 || i == 11 ) { 106 }else if ( i == 1 || i == 11 ) {
94 table[i].color = back; 107 table[i].color = back;
95 table[i].transparent = 0; 108 table[i].transparent = 0;
96 }else { 109 }else {
97 table[i].color = defaultCt[i].color; 110 table[i].color = defaultCt[i].color;
98 } 111 }
99 } 112 }
100 m_teWid->setColorTable(table ); 113 m_teWid->setColorTable(table );
101 m_teWid->update(); 114 m_teWid->update();
102} 115}
103QFont EmulationHandler::font( int id ) { 116QFont EmulationHandler::font( int id ) {
104 QString name; 117 QString name;
105 int size = 0; 118 int size = 0;
106 switch(id ) { 119 switch(id ) {
107 default: // fall through 120 default: // fall through
108 case 0: 121 case 0:
109 name = QString::fromLatin1("Micro"); 122 name = QString::fromLatin1("Micro");
110 size = 4; 123 size = 4;
111 break; 124 break;
112 case 1: 125 case 1:
113 name = QString::fromLatin1("Fixed"); 126 name = QString::fromLatin1("Fixed");
114 size = 7; 127 size = 7;
115 break; 128 break;
116 case 2: 129 case 2:
117 name = QString::fromLatin1("Fixed"); 130 name = QString::fromLatin1("Fixed");
118 size = 12; 131 size = 12;
119 break; 132 break;
120 } 133 }
121 QFont font(name, size, QFont::Normal ); 134 QFont font(name, size, QFont::Normal );
122 font.setFixedPitch(TRUE ); 135 font.setFixedPitch(TRUE );
123 return font; 136 return font;
124} 137}
125QColor EmulationHandler::foreColor(int col) { 138QColor EmulationHandler::foreColor(int col) {
126 QColor co; 139 QColor co;
127 /* we need to switch it */ 140 /* we need to switch it */
128 switch( col ) { 141 switch( col ) {
129 default: 142 default:
130 case Profile::White: 143 case Profile::White:
131 /* color is black */ 144 /* color is black */
132 co = Qt::white; 145 co = Qt::white;
133 break; 146 break;
134 case Profile::Black: 147 case Profile::Black:
135 co = Qt::black; 148 co = Qt::black;
136 break; 149 break;
137 case Profile::Green: 150 case Profile::Green:
138 owarn << "Foreground green" << oendl; 151 owarn << "Foreground green" << oendl;
139 co = Qt::green; 152 co = Qt::green;
140 break; 153 break;
141 case Profile::Orange: 154 case Profile::Orange:
142 owarn << "Foreground orange" << oendl; 155 owarn << "Foreground orange" << oendl;
143 co.setRgb( 231, 184, 98 ); 156 co.setRgb( 231, 184, 98 );
144 break; 157 break;
145 } 158 }
146 159
147 return co; 160 return co;
148} 161}
149QColor EmulationHandler::backColor(int col ) { 162QColor EmulationHandler::backColor(int col ) {
150 QColor co; 163 QColor co;
151 /* we need to switch it */ 164 /* we need to switch it */
152 switch( col ) { 165 switch( col ) {
153 default: 166 default:
154 case Profile::White: 167 case Profile::White:
155 /* color is white */ 168 /* color is white */
156 co = Qt::black; 169 co = Qt::black;
157 break; 170 break;
158 case Profile::Black: 171 case Profile::Black:
159 co = Qt::white; 172 co = Qt::white;
160 break; 173 break;
161 case Profile::Green: 174 case Profile::Green:
162 owarn << "Background black" << oendl; 175 owarn << "Background black" << oendl;
163 co = Qt::black; 176 co = Qt::black;
164 break; 177 break;
165 case Profile::Orange: 178 case Profile::Orange:
166 owarn << "Background black" << oendl; 179 owarn << "Background black" << oendl;
167 co = Qt::black; 180 co = Qt::black;
168 break; 181 break;
169 } 182 }
170 183
171 return co; 184 return co;
172} 185}
173 186
174QPushButton* EmulationHandler::cornerButton() { 187QPushButton* EmulationHandler::cornerButton() {
175 return m_teWid->cornerButton(); 188 return m_teWid->cornerButton();
176} 189}
177 190
178 191
179Script *EmulationHandler::script() { 192Script *EmulationHandler::script() {
180 return m_script; 193 return m_script;
181} 194}
182 195
183bool EmulationHandler::isRecording() { 196bool EmulationHandler::isRecording() {
184 return (m_script != 0); 197 return (m_script != 0);
185} 198}
186 199
200bool EmulationHandler::isLogging() {
201 return (m_log != 0);
202}
203
187void EmulationHandler::startRecording() { 204void EmulationHandler::startRecording() {
188 if (!isRecording()) 205 if (!isRecording())
189 m_script = new Script(); 206 m_script = new Script();
190} 207}
191 208
209void EmulationHandler::startLogging(const QString fileName) {
210 m_logFileName = fileName;
211 if (!isLogging())
212 m_log = new Logger(m_logFileName);
213}
214
215QString EmulationHandler::logFileName() {
216 return m_logFileName;
217}
218
192void EmulationHandler::clearScript() { 219void EmulationHandler::clearScript() {
193 if (isRecording()) { 220 if (isRecording()) {
194 delete m_script; 221 delete m_script;
195 m_script = 0; 222 m_script = 0;
196 } 223 }
197} 224}
198 225
226void EmulationHandler::clearLog() {
227 if (isLogging()) {
228 delete m_log;
229 m_log = 0;
230 }
231}
232
199void EmulationHandler::runScript(const Script *script) { 233void EmulationHandler::runScript(const Script *script) {
200 emit send(script->script()); 234 emit send(script->script());
201} 235}
202 236
203void EmulationHandler::copy() { 237void EmulationHandler::copy() {
204 m_teWid->emitSelection(); 238 m_teWid->emitSelection();
205} 239}
206void EmulationHandler::paste() { 240void EmulationHandler::paste() {
207 m_teWid->pasteClipboard(); 241 m_teWid->pasteClipboard();
208} 242}
209 243
210void EmulationHandler::setWrap(int columns) { 244void EmulationHandler::setWrap(int columns) {
211 m_teWid->setWrapAt(columns); 245 m_teWid->setWrapAt(columns);
212} 246}
213 247
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h
index 1338525..1092c82 100644
--- a/noncore/apps/opie-console/emulation_handler.h
+++ b/noncore/apps/opie-console/emulation_handler.h
@@ -1,95 +1,111 @@
1#ifndef OPIE_EMULATION_HANDLER_H 1#ifndef OPIE_EMULATION_HANDLER_H
2#define OPIE_EMULATION_HANDLER_H 2#define OPIE_EMULATION_HANDLER_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qcolor.h> 5#include <qcolor.h>
6#include <qcstring.h> 6#include <qcstring.h>
7 7
8/* 8/*
9 * Badly ibotty lacks the time to finish 9 * Badly ibotty lacks the time to finish
10 * his widget in time.. 10 * his widget in time..
11 * Never the less we've to have an EmulationWidget 11 * Never the less we've to have an EmulationWidget
12 * This is why I'm taking the inferior not cleaned 12 * This is why I'm taking the inferior not cleaned
13 * up TE* KDE STUFF 13 * up TE* KDE STUFF
14 */ 14 */
15 15
16/** 16/**
17 * This is the layer above the IOLayer* 17 * This is the layer above the IOLayer*
18 * This nice QObject here will get stuff from 18 * This nice QObject here will get stuff from
19 * got a slot and a signal 19 * got a slot and a signal
20 * the signal for data 20 * the signal for data
21 * the slot for receiving 21 * the slot for receiving
22 * it'll set up the widget internally 22 * it'll set up the widget internally
23 * and manage the communication between 23 * and manage the communication between
24 * the pre QByteArray world! 24 * the pre QByteArray world!
25 */ 25 */
26class Profile; 26class Profile;
27class QWidget; 27class QWidget;
28class QPushButton; 28class QPushButton;
29class TEWidget; 29class TEWidget;
30class QFile;
30class TEmulation; 31class TEmulation;
31class QFont; 32class QFont;
33class QTextStream;
32class Script; 34class Script;
35class Logger;
36
33class EmulationHandler : public QObject { 37class EmulationHandler : public QObject {
34 Q_OBJECT 38 Q_OBJECT
35public: 39public:
36 /** 40 /**
37 * simple c'tor the parent of the TEWdiget 41 * simple c'tor the parent of the TEWdiget
38 * and a name 42 * and a name
39 * and a Profile 43 * and a Profile
40 */ 44 */
41 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); 45 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l );
42 46
43 /** 47 /**
44 * delete all components 48 * delete all components
45 */ 49 */
46 ~EmulationHandler(); 50 ~EmulationHandler();
47 51
48 void load( const Profile& ); 52 void load( const Profile& );
49 QWidget* widget(); 53 QWidget* widget();
50 TEmulation *emulation(); 54 TEmulation *emulation();
51 void setColor( const QColor& fore, const QColor& back ); 55 void setColor( const QColor& fore, const QColor& back );
52 QPushButton* cornerButton(); 56 QPushButton* cornerButton();
53 57
54 /* Scripts */ 58 /* Scripts */
55 /* Create a new script and record all typed characters */ 59 /* Create a new script and record all typed characters */
56 void startRecording(); 60 void startRecording();
57 61
62 void startLogging(const QString);
63
58 /* Return whether we are currently recording a script */ 64 /* Return whether we are currently recording a script */
59 bool isRecording(); 65 bool isRecording();
60 66
67 /* Return whether we are currently recording a log */
68 bool isLogging();
69
70 QString logFileName();
71
61 /* Return the current script (or NULL) */ 72 /* Return the current script (or NULL) */
62 Script *script(); 73 Script *script();
63 74
64 /* Stop recording and remove the current script from memory */ 75 /* Stop recording and remove the current script from memory */
65 void clearScript(); 76 void clearScript();
77
78 /* Stop logging and remove the current log from memory */
79 void clearLog();
66 80
67 /* Run a script by forwarding its keys to the EmulationLayer */ 81 /* Run a script by forwarding its keys to the EmulationLayer */
68 void runScript(const Script *); 82 void runScript(const Script *);
69 83
70 /* Propagate change to widget */ 84 /* Propagate change to widget */
71 void setWrap(int columns); 85 void setWrap(int columns);
72signals: 86signals:
73 void send( const QByteArray& ); 87 void send( const QByteArray& );
74 void changeSize(int rows, int cols ); 88 void changeSize(int rows, int cols );
75 89
76 90
77public slots: 91public slots:
78 void recv( const QByteArray& ); 92 void recv( const QByteArray& );
79 void paste(); 93 void paste();
80 void copy(); 94 void copy();
81 95
82private slots: 96private slots:
83 void recvEmulation( const char*, int len ); 97 void recvEmulation( const char*, int len );
84private: 98private:
85 QFont font( int ); 99 QFont font( int );
86 QColor foreColor(int ); 100 QColor foreColor(int );
87 QColor backColor(int ); 101 QColor backColor(int );
88 102
89private: 103private:
90 TEWidget* m_teWid; 104 TEWidget* m_teWid;
91 TEmulation* m_teEmu; 105 TEmulation* m_teEmu;
92 Script * m_script; 106 Script * m_script;
107 Logger *m_log;
108 QString m_logFileName;
93}; 109};
94 110
95#endif 111#endif
diff --git a/noncore/apps/opie-console/fixit.cpp b/noncore/apps/opie-console/fixit.cpp
new file mode 100644
index 0000000..c14e35e
--- a/dev/null
+++ b/noncore/apps/opie-console/fixit.cpp
@@ -0,0 +1,101 @@
1
2#include "fixit.h"
3
4using namespace Opie::Core;
5
6#ifdef FSCKED_DISTRI
7FixIt::FixIt() : QObject() {
8 /* the new inittab */
9 m_file = "#\n# /etc/inittab"
10"#"
11""
12"# 0 - halt (Do NOT set initdefault to this)"
13"# 1 - Single user mode"
14"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
15"# 3 - Full multiuser mode"
16"# 4 - JavaVM(Intent) developer mode"
17"# 5 - JavaVM(Intent)"
18"# 6 - reboot (Do NOT set initdefault to this)"
19"#"
20"id:5:initdefault:"
21""
22"# Specify things to do when starting"
23"si::sysinit:/etc/rc.d/rc.sysinit"
24""
25"l0:0:wait:/root/etc/rc.d/rc 0"
26"l1:1:wait:/etc/rc.d/rc 1"
27"l2:2:wait:/etc/rc.d/rc 2"
28"l3:3:wait:/etc/rc.d/rc 3"
29"l4:4:wait:/etc/rc.d/rc 4"
30"l5:5:wait:/etc/rc.d/rc 5"
31"l6:6:wait:/root/etc/rc.d/rc 6"
32""
33"# Specify things to do before rebooting"
34"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
35"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
36""
37"# Specify program to run on ttyS0"
38"s0:24:respawn:/sbin/getty 9600 ttyS0"
39"#pd:5:respawn:/etc/sync/serialctl"
40""
41"# Specify program to run on tty1"
42"1:2:respawn:/sbin/getty 9600 tty1"
43"ln:345:respawn:survive -l 6 /sbin/launch"
44"#qt:5:respawn:/sbin/qt"
45""
46"# collie sp."
47"sy::respawn:/sbin/shsync\n";
48}
49
50FixIt::~FixIt() {
51}
52
53/*
54 * the retail Zaurus is broken in many ways
55 * one is that pppd is listening on our port...
56 * we've to stop it from that and then do kill(SIGHUP,1);
57 */
58void FixIt::fixIt() {
59 #ifndef EAST
60 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
61 QFile file( "/etc/inittab" );
62 if ( file.open(IO_WriteOnly | IO_Raw ) ) {
63 file.writeBlock(m_file,strlen(m_file) );
64 }
65 file.close();
66 ::kill( SIGHUP, 1 );
67
68 #else
69
70 OProcess m_kill;
71 m_kill << "sh";
72 m_kill << "-c";
73 m_kill << QString(QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_kill_0_1.sh");
74
75
76 if ( !m_kill.start(OProcess::DontCare,OProcess::NoCommunication) ) {
77 owarn << "could not execute kill script" << oendl;
78 } else {
79 Global::statusMessage( tr("Fixing up Embedix"));
80 }
81
82 #endif
83}
84
85void FixIt::breakIt() {
86 #ifdef EAST
87 OProcess m_restart;
88 m_restart << "sh";
89 m_restart << "-c";
90 m_restart << QString(QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_restart_0_1.sh");
91
92
93 if ( !m_restart.start() ) {
94 owarn << "could not execute restart script" << oendl;
95 }
96
97 #endif
98}
99
100
101#endif
diff --git a/noncore/apps/opie-console/fixit.h b/noncore/apps/opie-console/fixit.h
index 6a8a101..c9188cf 100644
--- a/noncore/apps/opie-console/fixit.h
+++ b/noncore/apps/opie-console/fixit.h
@@ -1,90 +1,35 @@
1#ifndef FIX_IT_H 1#ifndef FIX_IT_H
2#define FIX_IT_H 2#define FIX_IT_H
3 3
4#include <opie2/oprocess.h>
5#include <opie2/odebug.h>
6
7#include <qpe/global.h>
8#include <qpe/qpeapplication.h>
4 9
5#include <sys/types.h> 10#include <sys/types.h>
6 11
7#include <stdio.h> 12#include <stdio.h>
8#include <stdlib.h> 13#include <stdlib.h>
9#include <signal.h> 14#include <signal.h>
10#include <qfile.h> 15
11 16
12/* 17/*
13 * The Zaurus rom 18 * The Zaurus rom
14 */ 19 */
15class FixIt { 20class FixIt : public QObject {
21
22 Q_OBJECT
23
16public: 24public:
17 FixIt(); 25 FixIt();
18 ~FixIt(); 26 ~FixIt();
19 void fixIt(); 27 void fixIt();
20 /* no real interested in implementing it */ 28 /* no real interested in implementing it */
21 void breakIt() { 29 void breakIt();
22
23 };
24 char* m_file; 30 char* m_file;
25}; 31};
26 32
27#ifdef FSCKED_DISTRI
28FixIt::FixIt() {
29 /* the new inittab */
30 m_file = "#\n# /etc/inittab"
31"#"
32""
33"# 0 - halt (Do NOT set initdefault to this)"
34"# 1 - Single user mode"
35"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
36"# 3 - Full multiuser mode"
37"# 4 - JavaVM(Intent) developer mode"
38"# 5 - JavaVM(Intent)"
39"# 6 - reboot (Do NOT set initdefault to this)"
40"#"
41"id:5:initdefault:"
42""
43"# Specify things to do when starting"
44"si::sysinit:/etc/rc.d/rc.sysinit"
45""
46"l0:0:wait:/root/etc/rc.d/rc 0"
47"l1:1:wait:/etc/rc.d/rc 1"
48"l2:2:wait:/etc/rc.d/rc 2"
49"l3:3:wait:/etc/rc.d/rc 3"
50"l4:4:wait:/etc/rc.d/rc 4"
51"l5:5:wait:/etc/rc.d/rc 5"
52"l6:6:wait:/root/etc/rc.d/rc 6"
53""
54"# Specify things to do before rebooting"
55"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
56"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
57""
58"# Specify program to run on ttyS0"
59"s0:24:respawn:/sbin/getty 9600 ttyS0"
60"#pd:5:respawn:/etc/sync/serialctl"
61""
62"# Specify program to run on tty1"
63"1:2:respawn:/sbin/getty 9600 tty1"
64"ln:345:respawn:survive -l 6 /sbin/launch"
65"#qt:5:respawn:/sbin/qt"
66""
67"# collie sp."
68"sy::respawn:/sbin/shsync\n";
69
70}
71FixIt::~FixIt() {
72}
73/*
74 * the retail Zaurus is broken in many ways
75 * one is that pppd is listening on our port...
76 * we've to stop it from that and then do kill(SIGHUP,1);
77 */
78void FixIt::fixIt() {
79 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
80 QFile file( "/etc/inittab" );
81 if ( file.open(IO_WriteOnly | IO_Raw ) ) {
82 file.writeBlock(m_file,strlen(m_file) );
83 }
84 file.close();
85 ::kill( SIGHUP, 1 );
86}
87 33
88#endif 34#endif
89 35
90#endif
diff --git a/noncore/apps/opie-console/logger.cpp b/noncore/apps/opie-console/logger.cpp
new file mode 100644
index 0000000..56557f3
--- a/dev/null
+++ b/noncore/apps/opie-console/logger.cpp
@@ -0,0 +1,20 @@
1#include <qfile.h>
2#include <qtextstream.h>
3
4#include "logger.h"
5
6
7Logger::Logger() {}
8
9Logger::Logger(const QString fileName) {
10 m_file.setName(fileName);
11 m_file.open(IO_ReadWrite);
12}
13
14Logger::~Logger() {
15 m_file.close();
16}
17
18void Logger::append(QByteArray ar) {
19 m_file.writeBlock(ar);
20} \ No newline at end of file
diff --git a/noncore/apps/opie-console/logger.h b/noncore/apps/opie-console/logger.h
new file mode 100644
index 0000000..cdc9f68
--- a/dev/null
+++ b/noncore/apps/opie-console/logger.h
@@ -0,0 +1,19 @@
1#ifndef CONSOLE_LOGGER_H
2#define CONSOLE_LOGGER_H
3
4#include <qstring.h>
5#include <qfile.h>
6
7class Logger {
8
9public:
10 Logger();
11 Logger(const QString fileName);
12 void append(QByteArray ar);
13 ~Logger();
14
15private:
16 QFile m_file;
17};
18
19#endif \ No newline at end of file
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 1a5a59f..a0622d4 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,226 +1,235 @@
1#include "TEmulation.h" 1#include "TEmulation.h"
2#include "profileeditordialog.h" 2#include "profileeditordialog.h"
3#include "configdialog.h" 3#include "configdialog.h"
4#include "default.h" 4#include "default.h"
5#include "profilemanager.h" 5#include "profilemanager.h"
6#include "mainwindow.h" 6#include "mainwindow.h"
7#include "tabwidget.h" 7#include "tabwidget.h"
8#include "transferdialog.h" 8#include "transferdialog.h"
9#include "function_keyboard.h" 9#include "function_keyboard.h"
10#include "emulation_handler.h" 10#include "emulation_handler.h"
11#include "script.h" 11#include "script.h"
12#include "fixit.h" 12#include "fixit.h"
13 13
14/* OPIE */ 14/* OPIE */
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16#include <opie2/ofiledialog.h> 16#include <opie2/ofiledialog.h>
17#include <qpe/filemanager.h> 17#include <qpe/filemanager.h>
18using namespace Opie::Core; 18using namespace Opie::Core;
19using namespace Opie::Ui; 19using namespace Opie::Ui;
20 20
21/* QT */ 21/* QT */
22#include <qaction.h> 22#include <qaction.h>
23#include <qmenubar.h> 23#include <qmenubar.h>
24#include <qtoolbar.h> 24#include <qtoolbar.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27#include <qfileinfo.h> 27#include <qfileinfo.h>
28 28
29/* STD */ 29/* STD */
30#include <assert.h> 30#include <assert.h>
31 31
32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
33
33#ifdef FSCKED_DISTRI 34#ifdef FSCKED_DISTRI
34 FixIt fix; 35 FixIt fix;
35 fix.fixIt(); 36 fix.fixIt();
36#endif 37#endif
37 38
38 setCaption(QObject::tr("Opie Console") ); 39 setCaption(QObject::tr("Opie Console") );
39 KeyTrans::loadAll(); 40 KeyTrans::loadAll();
40 for (int i = 0; i < KeyTrans::count(); i++ ) { 41 for (int i = 0; i < KeyTrans::count(); i++ ) {
41 KeyTrans* s = KeyTrans::find(i ); 42 KeyTrans* s = KeyTrans::find(i );
42 assert( s ); 43 assert( s );
43 } 44 }
44 m_factory = new MetaFactory(); 45 m_factory = new MetaFactory();
45 Default def(m_factory); 46 Default def(m_factory);
46 m_sessions.setAutoDelete( TRUE ); 47 m_sessions.setAutoDelete( TRUE );
47 m_curSession = 0; 48 m_curSession = 0;
48 m_manager = new ProfileManager( m_factory ); 49 m_manager = new ProfileManager( m_factory );
49 m_manager->load(); 50 m_manager->load();
50 m_scriptsData.setAutoDelete(TRUE); 51 m_scriptsData.setAutoDelete(TRUE);
51 52
52 initUI(); 53 initUI();
53 populateProfiles(); 54 populateProfiles();
54 populateScripts(); 55 populateScripts();
55} 56}
56 57
57void MainWindow::initUI() { 58void MainWindow::initUI() {
58 59
59 setToolBarsMovable( FALSE ); 60 setToolBarsMovable( FALSE );
60 61
61 /* tool bar for the menu */ 62 /* tool bar for the menu */
62 m_tool = new QToolBar( this ); 63 m_tool = new QToolBar( this );
63 m_tool->setHorizontalStretchable( TRUE ); 64 m_tool->setHorizontalStretchable( TRUE );
64 65
65 m_bar = new QMenuBar( m_tool ); 66 m_bar = new QMenuBar( m_tool );
66 m_console = new QPopupMenu( this ); 67 m_console = new QPopupMenu( this );
67 m_scripts = new QPopupMenu( this ); 68 m_scripts = new QPopupMenu( this );
68 m_sessionsPop= new QPopupMenu( this ); 69 m_sessionsPop= new QPopupMenu( this );
69 m_scriptsPop = new QPopupMenu( this ); 70 m_scriptsPop = new QPopupMenu( this );
70 71
71 /* add a toolbar for icons */ 72 /* add a toolbar for icons */
72 m_icons = new QToolBar(this); 73 m_icons = new QToolBar(this);
73 74
74 /* 75 /*
75 * the settings action 76 * the settings action
76 */ 77 */
77 m_setProfiles = new QAction(tr("Configure Profiles"), 78 m_setProfiles = new QAction(tr("Configure Profiles"),
78 Resource::loadPixmap( "SettingsIcon" ), 79 Resource::loadPixmap( "SettingsIcon" ),
79 QString::null, 0, this, 0); 80 QString::null, 0, this, 0);
80 m_setProfiles->addTo( m_console ); 81 m_setProfiles->addTo( m_console );
81 connect( m_setProfiles, SIGNAL(activated() ), 82 connect( m_setProfiles, SIGNAL(activated() ),
82 this, SLOT(slotConfigure() ) ); 83 this, SLOT(slotConfigure() ) );
83 84
84 m_console->insertSeparator(); 85 m_console->insertSeparator();
85 /* 86 /*
86 * new Action for new sessions 87 * new Action for new sessions
87 */ 88 */
88 QAction* newCon = new QAction(tr("New Profile"), 89 QAction* newCon = new QAction(tr("New Profile"),
89 Resource::loadPixmap( "new" ), 90 Resource::loadPixmap( "new" ),
90 QString::null, 0, this, 0); 91 QString::null, 0, this, 0);
91 newCon->addTo( m_console ); 92 newCon->addTo( m_console );
92 connect( newCon, SIGNAL(activated() ), 93 connect( newCon, SIGNAL(activated() ),
93 this, SLOT(slotNew() ) ); 94 this, SLOT(slotNew() ) );
94 95
95 m_console->insertSeparator(); 96 m_console->insertSeparator();
96 97
97 QAction *saveCon = new QAction( tr("Save Profile" ), 98 QAction *saveCon = new QAction( tr("Save Profile" ),
98 Resource::loadPixmap( "save" ), QString::null, 99 Resource::loadPixmap( "save" ), QString::null,
99 0, this, 0 ); 100 0, this, 0 );
100 saveCon->addTo( m_console ); 101 saveCon->addTo( m_console );
101 connect( saveCon, SIGNAL(activated() ), 102 connect( saveCon, SIGNAL(activated() ),
102 this, SLOT(slotSaveSession() ) ); 103 this, SLOT(slotSaveSession() ) );
103 m_console->insertSeparator(); 104 m_console->insertSeparator();
104 105
105 /* 106 /*
106 * connect action 107 * connect action
107 */ 108 */
108 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 109 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
109 QString::null, 0, this, 0 ); 110 QString::null, 0, this, 0 );
110 m_connect->addTo( m_console ); 111 m_connect->addTo( m_console );
111 connect(m_connect, SIGNAL(activated() ), 112 connect(m_connect, SIGNAL(activated() ),
112 this, SLOT(slotConnect() ) ); 113 this, SLOT(slotConnect() ) );
113 114
114 /* 115 /*
115 * disconnect action 116 * disconnect action
116 */ 117 */
117 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 118 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
118 QString::null, 0, this, 0 ); 119 QString::null, 0, this, 0 );
119 m_disconnect->addTo( m_console ); 120 m_disconnect->addTo( m_console );
120 connect(m_disconnect, SIGNAL(activated() ), 121 connect(m_disconnect, SIGNAL(activated() ),
121 this, SLOT(slotDisconnect() ) ); 122 this, SLOT(slotDisconnect() ) );
122 123
123 m_console->insertSeparator(); 124 m_console->insertSeparator();
124 125
125 126#ifndef EAST
126 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); 127 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
127 m_quickLaunch->addTo( m_icons ); 128 m_quickLaunch->addTo( m_icons );
128 connect( m_quickLaunch, SIGNAL( activated() ), 129 connect( m_quickLaunch, SIGNAL( activated() ),
129 this, SLOT( slotQuickLaunch() ) ); 130 this, SLOT( slotQuickLaunch() ) );
131#endif
130 132
131 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); 133 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
132 134
133 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 135 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
134 0, this, 0 ); 136 0, this, 0 );
135 m_transfer->addTo( m_console ); 137 m_transfer->addTo( m_console );
136 connect(m_transfer, SIGNAL(activated() ), 138 connect(m_transfer, SIGNAL(activated() ),
137 this, SLOT(slotTransfer() ) ); 139 this, SLOT(slotTransfer() ) );
138 140
139 141
140 142
141 /* 143 /*
142 * immediate change of line wrap policy 144 * immediate change of line wrap policy
143 */ 145 */
144 m_isWrapped = true; 146 m_isWrapped = true;
145 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); 147 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true );
146 m_wrap->addTo( m_console ); 148 m_wrap->addTo( m_console );
147 m_wrap->setOn( true ); 149 m_wrap->setOn( true );
148 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); 150 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
149 151
150 /* 152 /*
151 * fullscreen 153 * fullscreen
152 */ 154 */
153 m_isFullscreen = false; 155 m_isFullscreen = false;
154 156
155 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 157 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
156 , QString::null, 0, this, 0 ); 158 , QString::null, 0, this, 0 );
157 m_fullscreen->addTo( m_console ); 159 m_fullscreen->addTo( m_console );
158 connect( m_fullscreen, SIGNAL( activated() ), 160 connect( m_fullscreen, SIGNAL( activated() ),
159 this, SLOT( slotFullscreen() ) ); 161 this, SLOT( slotFullscreen() ) );
160 162
161 m_console->insertSeparator(); 163 m_console->insertSeparator();
162 164
165 m_recordLog = new QAction();
166 m_recordLog->setText( tr("Start log") );
167 m_recordLog->addTo( m_console );
168 connect(m_recordLog, SIGNAL(activated() ),
169 this, SLOT( slotSaveLog() ) );
170 m_recordingLog = false;
171
163 QAction *a = new QAction(); 172 QAction *a = new QAction();
164 a->setText( tr("Save history") ); 173 a->setText( tr("Save history") );
165 a->addTo( m_console ); 174 a->addTo( m_console );
166 connect(a, SIGNAL(activated() ), 175 connect(a, SIGNAL(activated() ),
167 this, SLOT(slotSaveHistory() ) ); 176 this, SLOT(slotSaveHistory() ) );
168 /* 177 /*
169 * terminate action 178 * terminate action
170 */ 179 */
171 m_terminate = new QAction(); 180 m_terminate = new QAction();
172 m_terminate->setText( tr("Terminate") ); 181 m_terminate->setText( tr("Terminate") );
173 m_terminate->addTo( m_console ); 182 m_terminate->addTo( m_console );
174 connect(m_terminate, SIGNAL(activated() ), 183 connect(m_terminate, SIGNAL(activated() ),
175 this, SLOT(slotTerminate() ) ); 184 this, SLOT(slotTerminate() ) );
176 185
177 m_closewindow = new QAction(); 186 m_closewindow = new QAction();
178 m_closewindow->setText( tr("Close Window") ); 187 m_closewindow->setText( tr("Close Window") );
179 m_closewindow->addTo( m_console ); 188 m_closewindow->addTo( m_console );
180 connect( m_closewindow, SIGNAL(activated() ), 189 connect( m_closewindow, SIGNAL(activated() ),
181 this, SLOT(slotClose() ) ); 190 this, SLOT(slotClose() ) );
182 191
183 192
184 /* 193 /*
185 * script actions 194 * script actions
186 */ 195 */
187 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 196 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
188 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 197 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
189 198
190 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 199 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
191 m_recordScript->addTo(m_scripts); 200 m_recordScript->addTo(m_scripts);
192 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 201 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
193 202
194 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 203 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
195 m_saveScript->addTo(m_scripts); 204 m_saveScript->addTo(m_scripts);
196 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 205 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
197 206
198 207
199 /* 208 /*
200 * action that open/closes the keyboard 209 * action that open/closes the keyboard
201 */ 210 */
202 m_openKeys = new QAction (tr("Open Keyboard..."), 211 m_openKeys = new QAction (tr("Open Keyboard..."),
203 Resource::loadPixmap( "console/keys/keyboard_icon" ), 212 Resource::loadPixmap( "console/keys/keyboard_icon" ),
204 QString::null, 0, this, 0); 213 QString::null, 0, this, 0);
205 m_openKeys->setToggleAction(true); 214 m_openKeys->setToggleAction(true);
206 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 215 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
207 216
208 /* insert the submenu */ 217 /* insert the submenu */
209 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 218 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
210 -1, 0); 219 -1, 0);
211 220
212 /* insert the connection menu */ 221 /* insert the connection menu */
213 m_bar->insertItem( tr("Connection"), m_console ); 222 m_bar->insertItem( tr("Connection"), m_console );
214 223
215 /* the scripts menu */ 224 /* the scripts menu */
216 m_bar->insertItem( tr("Scripts"), m_scripts ); 225 m_bar->insertItem( tr("Scripts"), m_scripts );
217 226
218 /* and the keyboard */ 227 /* and the keyboard */
219 m_keyBar = new QToolBar(this); 228 m_keyBar = new QToolBar(this);
220 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 229 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
221 m_keyBar->setHorizontalStretchable( TRUE ); 230 m_keyBar->setHorizontalStretchable( TRUE );
222 m_keyBar->hide(); 231 m_keyBar->hide();
223 232
224 m_kb = new FunctionKeyboard(m_keyBar); 233 m_kb = new FunctionKeyboard(m_keyBar);
225 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), 234 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
226 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); 235 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool)));
@@ -361,142 +370,141 @@ void MainWindow::slotSaveScript() {
361 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 370 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
362 currentSession()->emulationHandler()->clearScript(); 371 currentSession()->emulationHandler()->clearScript();
363 m_saveScript->setEnabled(false); 372 m_saveScript->setEnabled(false);
364 m_recordScript->setEnabled(true); 373 m_recordScript->setEnabled(true);
365 populateScripts(); 374 populateScripts();
366 } 375 }
367 } 376 }
368} 377}
369 378
370void MainWindow::slotRunScript(int id) { 379void MainWindow::slotRunScript(int id) {
371 if (currentSession()) { 380 if (currentSession()) {
372 int index = m_scriptsPop->indexOf(id); 381 int index = m_scriptsPop->indexOf(id);
373 DocLnk *lnk = m_scriptsData.at(index); 382 DocLnk *lnk = m_scriptsData.at(index);
374 QString filePath = lnk->file(); 383 QString filePath = lnk->file();
375 Script script(filePath); 384 Script script(filePath);
376 currentSession()->emulationHandler()->runScript(&script); 385 currentSession()->emulationHandler()->runScript(&script);
377 } 386 }
378} 387}
379 388
380void MainWindow::slotConnect() { 389void MainWindow::slotConnect() {
381 if ( currentSession() ) { 390 if ( currentSession() ) {
382 bool ret = currentSession()->layer()->open(); 391 bool ret = currentSession()->layer()->open();
383 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 392 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
384 QObject::tr("Failed"), 393 QObject::tr("Failed"),
385 QObject::tr("Connecting failed for this session.")); 394 QObject::tr("Connecting failed for this session."));
386 else { 395 else {
387 m_connect->setEnabled( false ); 396 m_connect->setEnabled( false );
388 m_disconnect->setEnabled( true ); 397 m_disconnect->setEnabled( true );
389 398
390 // if it does not support file transfer, disable the menu entry 399 // if it does not support file transfer, disable the menu entry
391 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 400 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
392 m_transfer->setEnabled( false ); 401 m_transfer->setEnabled( false );
393 } else { 402 } else {
394 m_transfer->setEnabled( true ); 403 m_transfer->setEnabled( true );
395 } 404 }
396 405
397 m_recordScript->setEnabled( true ); 406 m_recordScript->setEnabled( true );
398 m_scripts->setItemEnabled(m_runScript_id, true); 407 m_scripts->setItemEnabled(m_runScript_id, true);
399 } 408 }
400 } 409 }
401} 410}
402 411
403void MainWindow::slotDisconnect() { 412void MainWindow::slotDisconnect() {
404 if ( currentSession() ) { 413 if ( currentSession() ) {
405 currentSession()->layer()->close(); 414 currentSession()->layer()->close();
406 m_connect->setEnabled( true ); 415 m_connect->setEnabled( true );
407 m_disconnect->setEnabled( false ); 416 m_disconnect->setEnabled( false );
408 m_transfer->setEnabled( false ); 417 m_transfer->setEnabled( false );
409 m_recordScript->setEnabled( false); 418 m_recordScript->setEnabled( false);
410 m_saveScript->setEnabled( false ); 419 m_saveScript->setEnabled( false );
411 m_scripts->setItemEnabled(m_runScript_id, false); 420 m_scripts->setItemEnabled(m_runScript_id, false);
412 } 421 }
413} 422}
414 423
415void MainWindow::slotTerminate() { 424void MainWindow::slotTerminate() {
416 if ( currentSession() ) 425 if ( currentSession() )
417 currentSession()->layer()->close(); 426 currentSession()->layer()->close();
418 427
419 slotClose(); 428 slotClose();
420 /* FIXME move to the next session */ 429 /* FIXME move to the next session */
421} 430}
422 431
423 432
424 433
425
426
427
428void MainWindow::slotQuickLaunch() { 434void MainWindow::slotQuickLaunch() {
429 Profile prof = manager()->profile( "default" ); 435
436 Profile prof = manager()->profile( "default" );
430 if ( prof.name() == "default" ) { 437 if ( prof.name() == "default" ) {
431 create( prof ); 438 create( prof );
432 } else { 439 } else {
440 #ifndef EAST
433 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 441 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
434 newProf.setAutoConnect( true ); 442 newProf.setAutoConnect( true );
435 create( newProf ); 443 create( newProf );
436 slotSaveSession(); 444 slotSaveSession();
445 #endif
437 } 446 }
438
439} 447}
440 448
441void MainWindow::slotConfigure() { 449void MainWindow::slotConfigure() {
442 ConfigDialog conf( manager()->all(), factory() ); 450 ConfigDialog conf( manager()->all(), factory() );
443 451
444 int ret = QPEApplication::execDialog( &conf ); 452 int ret = QPEApplication::execDialog( &conf );
445 453
446 if ( QDialog::Accepted == ret ) { 454 if ( QDialog::Accepted == ret ) {
447 manager()->setProfiles( conf.list() ); 455 manager()->setProfiles( conf.list() );
448 manager()->save(); 456 manager()->save();
449 populateProfiles(); 457 populateProfiles();
450 } 458 }
451} 459}
452/* 460/*
453 * we will remove 461 * we will remove
454 * this window from the tabwidget 462 * this window from the tabwidget
455 * remove it from the list 463 * remove it from the list
456 * delete it 464 * delete it
457 * and set the currentSession() 465 * and set the currentSession()
458 */ 466 */
459void MainWindow::slotClose() { 467void MainWindow::slotClose() {
460 if (!currentSession() ) 468 if (!currentSession() )
461 return; 469 return;
462 470
463 Session* ses = currentSession(); 471 Session* ses = currentSession();
464 owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl; 472 owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl;
465 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 473 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
466 m_curSession = NULL; 474 m_curSession = NULL;
467 tabWidget()->remove( /*currentSession()*/ses ); 475 tabWidget()->remove( /*currentSession()*/ses );
468 /*it's autodelete */ 476 /*it's autodelete */
469 m_sessions.remove( ses ); 477 m_sessions.remove( ses );
470 owarn << "after remove!!" << oendl; 478 owarn << "after remove!!" << oendl;
471 479
472 if (!currentSession() ) { 480 if (!currentSession() ) {
473 m_connect->setEnabled( false ); 481 m_connect->setEnabled( false );
474 m_disconnect->setEnabled( false ); 482 m_disconnect->setEnabled( false );
475 m_terminate->setEnabled( false ); 483 m_terminate->setEnabled( false );
476 m_transfer->setEnabled( false ); 484 m_transfer->setEnabled( false );
477 m_recordScript->setEnabled( false ); 485 m_recordScript->setEnabled( false );
478 m_saveScript->setEnabled( false ); 486 m_saveScript->setEnabled( false );
479 m_scripts->setItemEnabled(m_runScript_id, false); 487 m_scripts->setItemEnabled(m_runScript_id, false);
480 m_fullscreen->setEnabled( false ); 488 m_fullscreen->setEnabled( false );
481 m_wrap->setEnabled( false ); 489 m_wrap->setEnabled( false );
482 m_closewindow->setEnabled( false ); 490 m_closewindow->setEnabled( false );
483 } 491 }
484 492
485 m_kb->loadDefaults(); 493 m_kb->loadDefaults();
486} 494}
487 495
488/* 496/*
489 * We will get the name 497 * We will get the name
490 * Then the profile 498 * Then the profile
491 * and then we will make a profile 499 * and then we will make a profile
492 */ 500 */
493void MainWindow::slotProfile( int id) { 501void MainWindow::slotProfile( int id) {
494 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 502 Profile prof = manager()->profile( m_sessionsPop->text( id) );
495 create( prof ); 503 create( prof );
496} 504}
497 505
498 506
499 507
500void MainWindow::create( const Profile& prof ) { 508void MainWindow::create( const Profile& prof ) {
501 if(m_curSession) 509 if(m_curSession)
502 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 510 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
@@ -547,188 +555,224 @@ void MainWindow::create( const Profile& prof ) {
547 m_kb->load(currentSession()->profile()); 555 m_kb->load(currentSession()->profile());
548} 556}
549 557
550void MainWindow::slotTransfer() 558void MainWindow::slotTransfer()
551{ 559{
552 if ( currentSession() ) { 560 if ( currentSession() ) {
553 Session *mysession = currentSession(); 561 Session *mysession = currentSession();
554 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 562 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
555 mysession->setTransferDialog(&dlg); 563 mysession->setTransferDialog(&dlg);
556 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 564 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
557 //dlg.showMaximized(); 565 //dlg.showMaximized();
558 currentSession()->widgetStack()->addWidget(&dlg, -1); 566 currentSession()->widgetStack()->addWidget(&dlg, -1);
559 dlg.show(); 567 dlg.show();
560 //dlg.exec(); 568 //dlg.exec();
561 while(dlg.isRunning()) qApp->processEvents(); 569 while(dlg.isRunning()) qApp->processEvents();
562 mysession->setTransferDialog(0l); 570 mysession->setTransferDialog(0l);
563 } 571 }
564} 572}
565 573
566 574
567void MainWindow::slotOpenKeb(bool state) { 575void MainWindow::slotOpenKeb(bool state) {
568 576
569 if (state) m_keyBar->show(); 577 if (state) m_keyBar->show();
570 else m_keyBar->hide(); 578 else m_keyBar->hide();
571 579
572} 580}
573 581
574 582
575void MainWindow::slotOpenButtons( bool state ) { 583void MainWindow::slotOpenButtons( bool state ) {
576 584
577 if ( state ) { 585 if ( state ) {
578 m_buttonBar->show(); 586 m_buttonBar->show();
579 } else { 587 } else {
580 m_buttonBar->hide(); 588 m_buttonBar->hide();
581 } 589 }
582} 590}
583 591
584 592
585 593
586void MainWindow::slotSessionChanged( Session* ses ) { 594void MainWindow::slotSessionChanged( Session* ses ) {
587 owarn << "changed!" << oendl; 595 owarn << "changed!" << oendl;
588 596
589 if(m_curSession) 597 if(m_curSession)
590 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 598 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
591 if(ses) 599 if(ses)
592 if(ses->transferDialog()) ses->transferDialog()->show(); 600 if(ses->transferDialog()) ses->transferDialog()->show();
593 601
594 if ( ses ) { 602 if ( ses ) {
595 m_curSession = ses; 603 m_curSession = ses;
596 odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl; 604 odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl;
597 if ( m_curSession->layer()->isConnected() ) { 605 if ( m_curSession->layer()->isConnected() ) {
598 m_connect->setEnabled( false ); 606 m_connect->setEnabled( false );
599 m_disconnect->setEnabled( true ); 607 m_disconnect->setEnabled( true );
600 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 608 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
601 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 609 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
602 m_scripts->setItemEnabled(m_runScript_id, true); 610 m_scripts->setItemEnabled(m_runScript_id, true);
603 } else { 611 } else {
604 m_connect->setEnabled( true ); 612 m_connect->setEnabled( true );
605 m_disconnect->setEnabled( false ); 613 m_disconnect->setEnabled( false );
606 m_recordScript->setEnabled( false ); 614 m_recordScript->setEnabled( false );
607 m_saveScript->setEnabled( false ); 615 m_saveScript->setEnabled( false );
608 m_scripts->setItemEnabled(m_runScript_id, false); 616 m_scripts->setItemEnabled(m_runScript_id, false);
609 } 617 }
610 618
619 if ( ( currentSession()->emulationHandler()->isLogging() ) ) {
620 m_recordLog->setText( tr("Stop log") );
621 } else {
622 m_recordLog->setText( tr("Start log") );
623 }
624
611 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 625 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
612 m_transfer->setEnabled( false ); 626 m_transfer->setEnabled( false );
613 } else { 627 } else {
614 m_transfer->setEnabled( true ); 628 m_transfer->setEnabled( true );
615 } 629 }
616 630
617 QWidget *w = m_curSession->widget(); 631 QWidget *w = m_curSession->widget();
618 if(w) w->setFocus(); 632 if(w) w->setFocus();
619 633
620 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 634 if(currentSession()->profile().readNumEntry("Wrap", 80)){
621 m_isWrapped = true; 635 m_isWrapped = true;
622 } else { 636 } else {
623 m_isWrapped = false; 637 m_isWrapped = false;
624 } 638 }
625 639
626 m_kb->load(currentSession()->profile()); 640 m_kb->load(currentSession()->profile());
627 } 641 }
628} 642}
629 643
630void MainWindow::slotWrap() 644void MainWindow::slotWrap()
631{ 645{
632 if(m_curSession) 646 if(m_curSession)
633 { 647 {
634 EmulationHandler *e = m_curSession->emulationHandler(); 648 EmulationHandler *e = m_curSession->emulationHandler();
635 if(e) 649 if(e)
636 { 650 {
637 e->setWrap( m_isWrapped ? 80:0 ); 651 e->setWrap( m_isWrapped ? 80:0 );
638 m_isWrapped = !m_isWrapped; 652 m_isWrapped = !m_isWrapped;
639 } 653 }
640 } 654 }
641} 655}
642 656
643void MainWindow::slotFullscreen() { 657void MainWindow::slotFullscreen() {
644 658
645 659
646 660
647 if ( m_isFullscreen ) { 661 if ( m_isFullscreen ) {
648 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 662 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
649 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 663 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
650 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 664 ( m_curSession->emulationHandler() )->cornerButton()->hide();
651 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 665 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
652 666
653 } else { 667 } else {
654 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 668 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
655 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 669 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
656 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 670 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
657 , QPoint(0,0), false ); 671 , QPoint(0,0), false );
658 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 672 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
659 ( m_curSession->widgetStack() )->setFocus(); 673 ( m_curSession->widgetStack() )->setFocus();
660 ( m_curSession->widgetStack() )->show(); 674 ( m_curSession->widgetStack() )->show();
661 675
662 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 676 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
663 677
664 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 678 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
665 } 679 }
666 680
667 m_isFullscreen = !m_isFullscreen; 681 m_isFullscreen = !m_isFullscreen;
668} 682}
669 683
670 684
671void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 685void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
672 686
673 if ( m_curSession ) { 687 if ( m_curSession ) {
674 688
675 QEvent::Type state; 689 QEvent::Type state;
676 690
677 if (pressed) state = QEvent::KeyPress; 691 if (pressed) state = QEvent::KeyPress;
678 else state = QEvent::KeyRelease; 692 else state = QEvent::KeyRelease;
679 693
680 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 694 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
681 695
682 // is this the best way to do this? cant figure out any other way to work 696 // is this the best way to do this? cant figure out any other way to work
683 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 697 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
684 ke.ignore(); 698 ke.ignore();
685 } 699 }
686} 700}
687void MainWindow::slotCopy() { 701void MainWindow::slotCopy() {
688 if (!currentSession() ) return; 702 if (!currentSession() ) return;
689 currentSession()->emulationHandler()->copy(); 703 currentSession()->emulationHandler()->copy();
690} 704}
691void MainWindow::slotPaste() { 705void MainWindow::slotPaste() {
692 if (!currentSession() ) return; 706 if (!currentSession() ) return;
693 currentSession()->emulationHandler()->paste(); 707 currentSession()->emulationHandler()->paste();
694} 708}
695 709
696/* 710/*
697 * Save the session 711 * Save the session
698 */ 712 */
699 713
700void MainWindow::slotSaveSession() { 714void MainWindow::slotSaveSession() {
701 if (!currentSession() ) { 715 if (!currentSession() ) {
702 QMessageBox::information(this, tr("Save Connection"), 716 QMessageBox::information(this, tr("Save Connection"),
703 tr("<qt>There is no Connection.</qt>"), 1 ); 717 tr("<qt>There is no Connection.</qt>"), 1 );
704 return; 718 return;
705 } 719 }
706 manager()->add( currentSession()->profile() ); 720 manager()->add( currentSession()->profile() );
707 manager()->save(); 721 manager()->save();
708 populateProfiles(); 722 populateProfiles();
709} 723}
724
725
726
727void MainWindow::slotSaveLog() {
728
729 if( currentSession()->emulationHandler()->isLogging() ) {
730 DocLnk nf;
731 QString m_logName = currentSession()->emulationHandler()->logFileName();
732 QFileInfo info(m_logName);
733 nf.setType("text/plain");
734 nf.setFile(m_logName);
735 nf.setName(info.fileName());
736 nf.writeLink();
737 m_recordLog->setText( tr("Start log") );
738 m_recordingLog = false;
739 currentSession()->emulationHandler()->clearLog();
740 } else {
741 QMap<QString, QStringList> map;
742 QStringList text;
743 text << "text/plain";
744 map.insert(tr("Log"), text );
745 QString m_logName = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
746 if (m_logName.isEmpty() ) return;
747
748 m_recordLog->setText( tr("Stop log") );
749 m_recordingLog = true;
750 currentSession()->emulationHandler()->startLogging(m_logName);
751 }
752}
753
710void MainWindow::slotSaveHistory() { 754void MainWindow::slotSaveHistory() {
711 QMap<QString, QStringList> map; 755 QMap<QString, QStringList> map;
712 QStringList text; 756 QStringList text;
713 text << "text/plain"; 757 text << "text/plain";
714 map.insert(tr("History"), text ); 758 map.insert(tr("History"), text );
715 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 759 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
716 if (filename.isEmpty() ) return; 760 if (filename.isEmpty() ) return;
717 761
718 QFileInfo info(filename); 762 QFileInfo info(filename);
719 763
720 DocLnk nf; 764 DocLnk nf;
721 nf.setType("text/plain"); 765 nf.setType("text/plain");
722 nf.setFile(filename); 766 nf.setFile(filename);
723 nf.setName(info.fileName()); 767 nf.setName(info.fileName());
724 768
725 769
726 QFile file(filename); 770 QFile file(filename);
727 file.open(IO_WriteOnly ); 771 file.open(IO_WriteOnly );
728 QTextStream str(&file ); 772 QTextStream str(&file );
729 if ( currentSession() ) 773 if ( currentSession() )
730 currentSession()->emulationHandler()->emulation()->streamHistory(&str); 774 currentSession()->emulationHandler()->emulation()->streamHistory(&str);
731 775
732 file.close(); 776 file.close();
733 nf.writeLink(); 777 nf.writeLink();
734} 778}
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index db07f5a..f3c8b81 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -1,139 +1,143 @@
1#ifndef OPIE_MAIN_WINDOW_H 1#ifndef OPIE_MAIN_WINDOW_H
2#define OPIE_MAIN_WINDOW_H 2#define OPIE_MAIN_WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <qfile.h>
6 7
7#include "session.h" 8#include "session.h"
8 9
9/** 10/**
10 * this is the MainWindow of the new opie console 11 * this is the MainWindow of the new opie console
11 * it's also the dispatcher between the different 12 * it's also the dispatcher between the different
12 * actions supported by the gui 13 * actions supported by the gui
13 */ 14 */
14class QToolBar; 15class QToolBar;
15class QToolButton; 16class QToolButton;
16class QMenuBar; 17class QMenuBar;
17class QAction; 18class QAction;
18class MetaFactory; 19class MetaFactory;
19class TabWidget; 20class TabWidget;
20class ProfileManager; 21class ProfileManager;
21class Profile; 22class Profile;
22class FunctionKeyboard; 23class FunctionKeyboard;
23class FKey; 24class FKey;
24class DocLnk; 25class DocLnk;
25 26
26class MainWindow : public QMainWindow { 27class MainWindow : public QMainWindow {
27 Q_OBJECT 28 Q_OBJECT
28public: 29public:
29 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); 30 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
30 ~MainWindow(); 31 ~MainWindow();
31 static QString appName() {return QString::fromLatin1("opie-console"); } 32 static QString appName() {return QString::fromLatin1("opie-console"); }
32 33
33 /** 34 /**
34 * our factory to generate IOLayer and so on 35 * our factory to generate IOLayer and so on
35 * 36 *
36 */ 37 */
37 MetaFactory* factory(); 38 MetaFactory* factory();
38 39
39 /** 40 /**
40 * A session contains a QWidget*, 41 * A session contains a QWidget*,
41 * an IOLayer* and some infos for us 42 * an IOLayer* and some infos for us
42 */ 43 */
43 Session* currentSession(); 44 Session* currentSession();
44 45
45 /** 46 /**
46 * the session list 47 * the session list
47 */ 48 */
48 QList<Session> sessions(); 49 QList<Session> sessions();
49 50
50 /** 51 /**
51 * 52 *
52 */ 53 */
53 ProfileManager* manager(); 54 ProfileManager* manager();
54 TabWidget* tabWidget(); 55 TabWidget* tabWidget();
55 56
56private slots: 57private slots:
57 void slotNew(); 58 void slotNew();
58 void slotConnect(); 59 void slotConnect();
59 void slotDisconnect(); 60 void slotDisconnect();
60 void slotTerminate(); 61 void slotTerminate();
61 void slotConfigure(); 62 void slotConfigure();
62 void slotClose(); 63 void slotClose();
63 void slotProfile(int); 64 void slotProfile(int);
64 void slotTransfer(); 65 void slotTransfer();
65 void slotOpenKeb(bool); 66 void slotOpenKeb(bool);
66 void slotOpenButtons(bool); 67 void slotOpenButtons(bool);
67 void slotRecordScript(); 68 void slotRecordScript();
68 void slotSaveScript(); 69 void slotSaveScript();
69 void slotRunScript(int); 70 void slotRunScript(int);
70 void slotFullscreen(); 71 void slotFullscreen();
71 void slotQuickLaunch(); 72 void slotQuickLaunch();
72 void slotWrap(); 73 void slotWrap();
73 void slotSessionChanged( Session* ); 74 void slotSessionChanged( Session* );
74 void slotKeyReceived(FKey, ushort, ushort, bool); 75 void slotKeyReceived(FKey, ushort, ushort, bool);
75 void slotSaveHistory(); 76 void slotSaveHistory();
77 void slotSaveLog();
76 78
77 /* what could these both slot do? */ 79 /* what could these both slot do? */
78 void slotCopy(); 80 void slotCopy();
79 void slotPaste(); 81 void slotPaste();
80 82
81 /* save the currentSession() to Profiles */ 83 /* save the currentSession() to Profiles */
82 void slotSaveSession(); 84 void slotSaveSession();
83 85
84private: 86private:
85 void initUI(); 87 void initUI();
86 void populateProfiles(); 88 void populateProfiles();
87 void populateScripts(); 89 void populateScripts();
88 void create( const Profile& ); 90 void create( const Profile& );
89 /** 91 /**
90 * the current session 92 * the current session
91 */ 93 */
92 Session* m_curSession; 94 Session* m_curSession;
93 95
94 /** 96 /**
95 * the session list 97 * the session list
96 */ 98 */
97 QList<Session> m_sessions; 99 QList<Session> m_sessions;
98 QList<DocLnk> m_scriptsData; 100 QList<DocLnk> m_scriptsData;
99 101
100 /** 102 /**
101 * the metafactory 103 * the metafactory
102 */ 104 */
103 MetaFactory* m_factory; 105 MetaFactory* m_factory;
104 ProfileManager* m_manager; 106 ProfileManager* m_manager;
105 107
106 TabWidget* m_consoleWindow; 108 TabWidget* m_consoleWindow;
107 QToolBar* m_tool; 109 QToolBar* m_tool;
108 QToolBar* m_icons; 110 QToolBar* m_icons;
109 QToolBar* m_keyBar; 111 QToolBar* m_keyBar;
110 QToolBar* m_buttonBar; 112 QToolBar* m_buttonBar;
111 QMenuBar* m_bar; 113 QMenuBar* m_bar;
112 QPopupMenu* m_console; 114 QPopupMenu* m_console;
113 QPopupMenu* m_sessionsPop; 115 QPopupMenu* m_sessionsPop;
114 QPopupMenu* m_scriptsPop; 116 QPopupMenu* m_scriptsPop;
115 QPopupMenu* m_scripts; 117 QPopupMenu* m_scripts;
116 QAction* m_connect; 118 QAction* m_connect;
117 QAction* m_disconnect; 119 QAction* m_disconnect;
118 QAction* m_quickLaunch; 120 QAction* m_quickLaunch;
119 QAction* m_terminate; 121 QAction* m_terminate;
120 QAction* m_transfer; 122 QAction* m_transfer;
121 QAction* m_setProfiles; 123 QAction* m_setProfiles;
122 QAction* m_openKeys; 124 QAction* m_openKeys;
123 QAction* m_openButtons; 125 QAction* m_openButtons;
124 QAction* m_recordScript; 126 QAction* m_recordScript;
125 QAction* m_saveScript; 127 QAction* m_saveScript;
126 QAction* m_fullscreen; 128 QAction* m_fullscreen;
127 QAction* m_wrap; 129 QAction* m_wrap;
128 QAction* m_closewindow; 130 QAction* m_closewindow;
131 QAction* m_recordLog;
129 132
130 FunctionKeyboard *m_kb; 133 FunctionKeyboard *m_kb;
131 int m_runScript_id; 134 int m_runScript_id;
132 bool m_isFullscreen; 135 bool m_isFullscreen;
133 bool m_isWrapped; 136 bool m_isWrapped;
137 bool m_recordingLog;
134 138
135 QWidget* savedParentFullscreen; 139 QWidget* savedParentFullscreen;
136}; 140};
137 141
138 142
139#endif 143#endif
diff --git a/noncore/apps/opie-console/opie-console-embedix.control b/noncore/apps/opie-console/opie-console-embedix.control
new file mode 100644
index 0000000..cf27554
--- a/dev/null
+++ b/noncore/apps/opie-console/opie-console-embedix.control
@@ -0,0 +1,10 @@
1Package: opie-console
2Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* share/opie-console/*
3Priority: optional
4Section: opie/applications
5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm
7Version: 0.6-$SUB_VERSION
8Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs
9License: GPL
10Description: Opie terminal app
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 6bc42bd..223cb91 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,74 +1,74 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ 3HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
4 file_layer.h filetransfer.h \ 4 file_layer.h filetransfer.h \
5 metafactory.h \ 5 metafactory.h \
6 session.h \ 6 session.h \
7 mainwindow.h \ 7 mainwindow.h \
8 profile.h \ 8 profile.h \
9 profileconfig.h \ 9 profileconfig.h \
10 profilemanager.h \ 10 profilemanager.h \
11 tabwidget.h \ 11 tabwidget.h \
12 configdialog.h \ 12 configdialog.h \
13 keytrans.h \ 13 keytrans.h \
14 transferdialog.h \ 14 transferdialog.h \
15 profiledialogwidget.h \ 15 profiledialogwidget.h \
16 profileeditordialog.h \ 16 profileeditordialog.h \
17 default.h \ 17 default.h \
18 iolayerbase.h \ 18 iolayerbase.h \
19 serialconfigwidget.h irdaconfigwidget.h \ 19 serialconfigwidget.h irdaconfigwidget.h \
20 btconfigwidget.h modemconfigwidget.h \ 20 btconfigwidget.h modemconfigwidget.h \
21 atconfigdialog.h dialdialog.h \ 21 atconfigdialog.h dialdialog.h \
22 procctl.h \ 22 procctl.h \
23 function_keyboard.h \ 23 function_keyboard.h \
24 receive_layer.h filereceive.h \ 24 receive_layer.h filereceive.h \
25 script.h \ 25 script.h \
26 dialer.h \ 26 dialer.h logger.h \
27 terminalwidget.h \ 27 terminalwidget.h \
28 emulation_handler.h TECommon.h \ 28 emulation_handler.h TECommon.h \
29 TEHistory.h TEScreen.h TEWidget.h \ 29 TEHistory.h TEScreen.h TEWidget.h \
30 TEmuVt102.h TEmulation.h MyPty.h \ 30 TEmuVt102.h TEmulation.h MyPty.h \
31 consoleconfigwidget.h 31 consoleconfigwidget.h fixit.h
32 32
33SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ 33SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
34 file_layer.cpp filetransfer.cpp \ 34 file_layer.cpp filetransfer.cpp \
35 main.cpp \ 35 main.cpp \
36 metafactory.cpp \ 36 metafactory.cpp \
37 session.cpp \ 37 session.cpp \
38 mainwindow.cpp \ 38 mainwindow.cpp \
39 profile.cpp \ 39 profile.cpp \
40 profileconfig.cpp \ 40 profileconfig.cpp \
41 profilemanager.cpp \ 41 profilemanager.cpp \
42 tabwidget.cpp \ 42 tabwidget.cpp \
43 configdialog.cpp \ 43 configdialog.cpp \
44 keytrans.cpp \ 44 keytrans.cpp \
45 transferdialog.cpp \ 45 transferdialog.cpp \
46 profiledialogwidget.cpp \ 46 profiledialogwidget.cpp \
47 profileeditordialog.cpp \ 47 profileeditordialog.cpp \
48 iolayerbase.cpp \ 48 iolayerbase.cpp \
49 serialconfigwidget.cpp irdaconfigwidget.cpp \ 49 serialconfigwidget.cpp irdaconfigwidget.cpp \
50 btconfigwidget.cpp modemconfigwidget.cpp \ 50 btconfigwidget.cpp modemconfigwidget.cpp \
51 atconfigdialog.cpp dialdialog.cpp \ 51 atconfigdialog.cpp dialdialog.cpp \
52 default.cpp procctl.cpp \ 52 default.cpp procctl.cpp \
53 function_keyboard.cpp \ 53 function_keyboard.cpp \
54 receive_layer.cpp filereceive.cpp \ 54 receive_layer.cpp filereceive.cpp \
55 script.cpp \ 55 script.cpp \
56 dialer.cpp \ 56 dialer.cpp logger.cpp \
57 terminalwidget.cpp \ 57 terminalwidget.cpp \
58 emulation_handler.cpp TEHistory.cpp \ 58 emulation_handler.cpp TEHistory.cpp \
59 TEScreen.cpp TEWidget.cpp \ 59 TEScreen.cpp TEWidget.cpp \
60 TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ 60 TEmuVt102.cpp TEmulation.cpp MyPty.cpp \
61 consoleconfigwidget.cpp 61 consoleconfigwidget.cpp fixit.cpp
62 62
63 63
64DESTDIR = $(OPIEDIR)/bin/ 64DESTDIR = $(OPIEDIR)/bin/
65INTERFACES = configurebase.ui editbase.ui 65INTERFACES = configurebase.ui editbase.ui
66INCLUDEPATH += $(OPIEDIR)/include 66INCLUDEPATH += $(OPIEDIR)/include
67DEPENDPATH += $(OPIEDIR)/include 67DEPENDPATH += $(OPIEDIR)/include
68LIBS += -lqpe -lopiecore2 -lopieui2 -lutil 68LIBS += -lqpe -lopiecore2 -lopieui2
69TARGET = opie-console 69TARGET = opie-console
70 70
71DEFINES += HAVE_OPENPTY 71#DEFINES += HAVE_OPENPTY
72 72#DEFINES += EAST FSCKED_DISTRI
73 73
74include ( $(OPIEDIR)/include.pro ) 74include ( $(OPIEDIR)/include.pro )