summaryrefslogtreecommitdiff
path: root/noncore
authorwazlaf <wazlaf>2002-10-20 14:53:08 (UTC)
committer wazlaf <wazlaf>2002-10-20 14:53:08 (UTC)
commit18ba3be9ca69c42476e310649e3068d2d5f8a03b (patch) (unidiff)
treed6a68e8f1a319ef8320d714356beebcf440a630f /noncore
parent9f442f5af601d1e15bb4d0509ed012e61609260d (diff)
downloadopie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.zip
opie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.tar.gz
opie-18ba3be9ca69c42476e310649e3068d2d5f8a03b.tar.bz2
scripting fixed (moved from emulation_layer to emulation_handler). Scripts now use QByteArray instead of QString
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp34
-rw-r--r--noncore/apps/opie-console/emulation_handler.h19
-rw-r--r--noncore/apps/opie-console/emulation_layer.cpp36
-rw-r--r--noncore/apps/opie-console/emulation_layer.h18
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp16
-rw-r--r--noncore/apps/opie-console/script.cpp15
-rw-r--r--noncore/apps/opie-console/script.h6
7 files changed, 68 insertions, 76 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 8846959..df8e573 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,59 +1,65 @@
1#include <qwidget.h> 1#include <qwidget.h>
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3 3
4#include "TEWidget.h" 4#include "TEWidget.h"
5#include "TEmuVt102.h" 5#include "TEmuVt102.h"
6 6
7#include "profile.h" 7#include "profile.h"
8#include "emulation_handler.h" 8#include "emulation_handler.h"
9 9#include "script.h"
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 m_teWid->setMinimumSize(150, 70 ); 15 m_teWid->setMinimumSize(150, 70 );
16 m_script = 0;
16 parent->resize( m_teWid->calcSize(80, 24 ) ); 17 parent->resize( m_teWid->calcSize(80, 24 ) );
17 m_teEmu = new TEmuVt102(m_teWid ); 18 m_teEmu = new TEmuVt102(m_teWid );
18 19
19 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 20 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
20 this, SIGNAL(changeSize(int, int) ) ); 21 this, SIGNAL(changeSize(int, int) ) );
21 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 22 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
22 this, SLOT(recvEmulation(const char*, int) ) ); 23 this, SLOT(recvEmulation(const char*, int) ) );
23 m_teEmu->setConnect( true ); 24 m_teEmu->setConnect( true );
24 m_teEmu->setHistory( TRUE ); 25 m_teEmu->setHistory( TRUE );
25 load( prof ); 26 load( prof );
26 27
27 28
28 29
29} 30}
30EmulationHandler::~EmulationHandler() { 31EmulationHandler::~EmulationHandler() {
32 if (isRecording())
33 clearScript();
31 delete m_teEmu; 34 delete m_teEmu;
32 delete m_teWid; 35 delete m_teWid;
33} 36}
37
34void EmulationHandler::load( const Profile& prof) { 38void EmulationHandler::load( const Profile& prof) {
35 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 39 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
36 int num = prof.readNumEntry("Color"); 40 int num = prof.readNumEntry("Color");
37 setColor( foreColor(num), backColor(num) ); 41 setColor( foreColor(num), backColor(num) );
38 m_teWid->setBackgroundColor(backColor(num) ); 42 m_teWid->setBackgroundColor(backColor(num) );
39} 43}
40void EmulationHandler::recv( const QByteArray& ar) { 44void EmulationHandler::recv( const QByteArray& ar) {
41 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 45 m_teEmu->onRcvBlock(ar.data(), ar.count() );
42} 46}
43void EmulationHandler::recvEmulation(const char* src, int len ) { 47void EmulationHandler::recvEmulation(const char* src, int len ) {
44 QByteArray ar(len); 48 QByteArray ar(len);
45 49
46 memcpy(ar.data(), src, sizeof(char) * len ); 50 memcpy(ar.data(), src, sizeof(char) * len );
47 51
52 if (isRecording())
53 m_script->append(ar);
48 emit send(ar); 54 emit send(ar);
49} 55}
50QWidget* EmulationHandler::widget() { 56QWidget* EmulationHandler::widget() {
51 return m_teWid; 57 return m_teWid;
52} 58}
53/* 59/*
54 * allocate a new table of colors 60 * allocate a new table of colors
55 */ 61 */
56void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 62void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
57 ColorEntry table[TABLE_COLORS]; 63 ColorEntry table[TABLE_COLORS];
58 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 64 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
59 65
@@ -136,12 +142,38 @@ QColor EmulationHandler::backColor(int col ) {
136 case Profile::Orange: 142 case Profile::Orange:
137 qWarning("Background black"); 143 qWarning("Background black");
138 co = Qt::black; 144 co = Qt::black;
139 break; 145 break;
140 } 146 }
141 147
142 return co; 148 return co;
143} 149}
144 150
145QPushButton* EmulationHandler::cornerButton() { 151QPushButton* EmulationHandler::cornerButton() {
146 return m_teWid->cornerButton(); 152 return m_teWid->cornerButton();
147} 153}
154
155
156Script *EmulationHandler::script() {
157 return m_script;
158}
159
160bool EmulationHandler::isRecording() {
161 return (m_script != 0);
162}
163
164void EmulationHandler::startRecording() {
165 if (!isRecording())
166 m_script = new Script();
167}
168
169void EmulationHandler::clearScript() {
170 if (isRecording()) {
171 delete m_script;
172 m_script = 0;
173 }
174}
175
176void EmulationHandler::runScript(const Script *script) {
177 emit send(script->script());
178}
179
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h
index 9ceafc6..7ca2cf3 100644
--- a/noncore/apps/opie-console/emulation_handler.h
+++ b/noncore/apps/opie-console/emulation_handler.h
@@ -20,54 +20,71 @@
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 TEmulation; 30class TEmulation;
31class QFont; 31class QFont;
32class Script;
32class EmulationHandler : public QObject { 33class EmulationHandler : public QObject {
33 Q_OBJECT 34 Q_OBJECT
34public: 35public:
35 /** 36 /**
36 * simple c'tor the parent of the TEWdiget 37 * simple c'tor the parent of the TEWdiget
37 * and a name 38 * and a name
38 * and a Profile 39 * and a Profile
39 */ 40 */
40 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); 41 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l );
41 42
42 /** 43 /**
43 * delete all components 44 * delete all components
44 */ 45 */
45 ~EmulationHandler(); 46 ~EmulationHandler();
46 47
47 void load( const Profile& ); 48 void load( const Profile& );
48 QWidget* widget(); 49 QWidget* widget();
49 void setColor( const QColor& fore, const QColor& back ); 50 void setColor( const QColor& fore, const QColor& back );
50 QPushButton* cornerButton(); 51 QPushButton* cornerButton();
52
53 /* Scripts */
54 /* Create a new script and record all typed characters */
55 void startRecording();
56
57 /* Return whether we are currently recording a script */
58 bool isRecording();
59
60 /* Return the current script (or NULL) */
61 Script *script();
62
63 /* Stop recording and remove the current script from memory */
64 void clearScript();
65
66 /* Run a script by forwarding its keys to the EmulationLayer */
67 void runScript(const Script *);
51 68
52signals: 69signals:
53 void send( const QByteArray& ); 70 void send( const QByteArray& );
54 void changeSize(int rows, int cols ); 71 void changeSize(int rows, int cols );
55 72
56 73
57public slots: 74public slots:
58 void recv( const QByteArray& ); 75 void recv( const QByteArray& );
59 76
60private slots: 77private slots:
61 void recvEmulation( const char*, int len ); 78 void recvEmulation( const char*, int len );
62private: 79private:
63 QFont font( int ); 80 QFont font( int );
64 QColor foreColor(int ); 81 QColor foreColor(int );
65 QColor backColor(int ); 82 QColor backColor(int );
66 83
67private: 84private:
68 TEWidget* m_teWid; 85 TEWidget* m_teWid;
69 TEmulation* m_teEmu; 86 TEmulation* m_teEmu;
70 87 Script * m_script;
71}; 88};
72 89
73#endif 90#endif
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp
index 265c11f..6a2679e 100644
--- a/noncore/apps/opie-console/emulation_layer.cpp
+++ b/noncore/apps/opie-console/emulation_layer.cpp
@@ -98,25 +98,24 @@
98EmulationLayer::EmulationLayer( WidgetLayer* gui ) 98EmulationLayer::EmulationLayer( WidgetLayer* gui )
99: decoder((QTextDecoder*)NULL) 99: decoder((QTextDecoder*)NULL)
100{ 100{
101 this->gui = gui; 101 this->gui = gui;
102 102
103 screen[0] = new Screen(gui->lines(),gui->columns()); 103 screen[0] = new Screen(gui->lines(),gui->columns());
104 screen[1] = new Screen(gui->lines(),gui->columns()); 104 screen[1] = new Screen(gui->lines(),gui->columns());
105 scr = screen[0]; 105 scr = screen[0];
106 106
107 bulk_nlcnt = 0; // reset bulk newline counter 107 bulk_nlcnt = 0; // reset bulk newline counter
108 bulk_incnt = 0; // reset bulk counter 108 bulk_incnt = 0; // reset bulk counter
109 connected = FALSE; 109 connected = FALSE;
110 m_script = 0;
111 110
112 QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) ); 111 QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) );
113 QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ), 112 QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ),
114 this,SLOT( onImageSizeChange( int, int ) ) ); 113 this,SLOT( onImageSizeChange( int, int ) ) );
115 QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ), 114 QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ),
116 this,SLOT( historyCursorChange( int ) ) ); 115 this,SLOT( historyCursorChange( int ) ) );
117 QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ), 116 QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ),
118 this,SLOT( onKeyPress( QKeyEvent* ) ) ); 117 this,SLOT( onKeyPress( QKeyEvent* ) ) );
119 QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ), 118 QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ),
120 this,SLOT( onSelectionBegin( const int, const int ) ) ); 119 this,SLOT( onSelectionBegin( const int, const int ) ) );
121 QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ), 120 QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ),
122 this,SLOT( onSelectionExtend( const int,const int ) ) ); 121 this,SLOT( onSelectionExtend( const int,const int ) ) );
@@ -124,26 +123,24 @@ EmulationLayer::EmulationLayer( WidgetLayer* gui )
124 this,SLOT( setSelection( const bool ) ) ); 123 this,SLOT( setSelection( const bool ) ) );
125 QObject::connect(gui,SIGNAL( selectionCleared() ), 124 QObject::connect(gui,SIGNAL( selectionCleared() ),
126 this,SLOT( clearSelection() ) ); 125 this,SLOT( clearSelection() ) );
127} 126}
128 127
129/*! 128/*!
130*/ 129*/
131 130
132EmulationLayer::~EmulationLayer() 131EmulationLayer::~EmulationLayer()
133{ 132{
134 delete screen[0]; 133 delete screen[0];
135 delete screen[1]; 134 delete screen[1];
136 if (isRecording())
137 clearScript();
138 bulk_timer.stop(); 135 bulk_timer.stop();
139} 136}
140 137
141/*! change between primary and alternate screen 138/*! change between primary and alternate screen
142*/ 139*/
143 140
144void EmulationLayer::setScreen(int n) 141void EmulationLayer::setScreen(int n)
145{ 142{
146 scr = screen[n&1]; 143 scr = screen[n&1];
147} 144}
148 145
149void EmulationLayer::setHistory(bool on) 146void EmulationLayer::setHistory(bool on)
@@ -223,27 +220,24 @@ void EmulationLayer::onKeyPress( QKeyEvent* ev )
223 { // A block of text 220 { // A block of text
224 // Note that the text is proper unicode. 221 // Note that the text is proper unicode.
225 // We should do a conversion here, but since this 222 // We should do a conversion here, but since this
226 // routine will never be used, we simply emit plain ascii. 223 // routine will never be used, we simply emit plain ascii.
227 sendString( ev->text().ascii() ); //,ev->text().length()); 224 sendString( ev->text().ascii() ); //,ev->text().length());
228 } 225 }
229 else if (ev->ascii()>0) 226 else if (ev->ascii()>0)
230 { 227 {
231 QByteArray c = QByteArray( 1 ); 228 QByteArray c = QByteArray( 1 );
232 c.at( 0 ) = ev->ascii(); 229 c.at( 0 ) = ev->ascii();
233 // ibot: qbytearray is emited not char* 230 // ibot: qbytearray is emited not char*
234 231
235 /* Are we currently recording a script? If so, store the typed character */
236 if (isRecording())
237 m_script->appendString(ev->text());
238 emit sndBlock( (QByteArray) c ); 232 emit sndBlock( (QByteArray) c );
239 } 233 }
240} 234}
241 235
242// Unblocking, Byte to Unicode translation --------------------------------- -- 236// Unblocking, Byte to Unicode translation --------------------------------- --
243 237
244/* 238/*
245 We are doing code conversion from locale to unicode first. 239 We are doing code conversion from locale to unicode first.
246*/ 240*/
247 241
248void EmulationLayer::onRcvBlock(const QByteArray &s ) 242void EmulationLayer::onRcvBlock(const QByteArray &s )
249{ 243{
@@ -252,53 +246,24 @@ void EmulationLayer::onRcvBlock(const QByteArray &s )
252 for (int i = 0; i < s.size(); i++) 246 for (int i = 0; i < s.size(); i++)
253 { 247 {
254 //TODO: ibot: maybe decoding qbytearray to unicode in io_layer? 248 //TODO: ibot: maybe decoding qbytearray to unicode in io_layer?
255 QString result = decoder->toUnicode(&s[i],1); 249 QString result = decoder->toUnicode(&s[i],1);
256 int reslen = result.length(); 250 int reslen = result.length();
257 for (int j = 0; j < reslen; j++) 251 for (int j = 0; j < reslen; j++)
258 onRcvChar(result[j].unicode()); 252 onRcvChar(result[j].unicode());
259 if (s[i] == '\n') bulkNewline(); 253 if (s[i] == '\n') bulkNewline();
260 } 254 }
261 bulkEnd(); 255 bulkEnd();
262} 256}
263 257
264// Scripts ----------------------------------------------------------------- --
265
266
267Script *EmulationLayer::script() {
268 return m_script;
269}
270
271bool EmulationLayer::isRecording() {
272 return (m_script != 0);
273}
274
275void EmulationLayer::startRecording() {
276 if (!isRecording())
277 m_script = new Script();
278}
279
280void EmulationLayer::clearScript() {
281 if (isRecording()) {
282
283 }
284}
285
286void EmulationLayer::runScript(const Script *script) {
287 QByteArray a = QByteArray();
288 QString str = script->script();
289 a.setRawData(str.ascii(), str.length());
290 emit sndBlock(a);
291}
292
293// Selection --------------------------------------------------------------- -- 258// Selection --------------------------------------------------------------- --
294 259
295void EmulationLayer::onSelectionBegin(const int x, const int y) { 260void EmulationLayer::onSelectionBegin(const int x, const int y) {
296 if (!connected) return; 261 if (!connected) return;
297 scr->setSelBeginXY(x,y); 262 scr->setSelBeginXY(x,y);
298 showBulk(); 263 showBulk();
299} 264}
300 265
301void EmulationLayer::onSelectionExtend(const int x, const int y) { 266void EmulationLayer::onSelectionExtend(const int x, const int y) {
302 if (!connected) return; 267 if (!connected) return;
303 scr->setSelExtentXY(x,y); 268 scr->setSelExtentXY(x,y);
304 showBulk(); 269 showBulk();
@@ -397,12 +362,13 @@ void EmulationLayer::onHistoryCursorChange(int cursor)
397{ 362{
398 if (!connected) return; 363 if (!connected) return;
399 scr->setHistCursor(cursor); 364 scr->setHistCursor(cursor);
400 showBulk(); 365 showBulk();
401} 366}
402 367
403void EmulationLayer::setColumns(int columns) 368void EmulationLayer::setColumns(int columns)
404{ 369{
405 //FIXME: this goes strange ways. 370 //FIXME: this goes strange ways.
406 // Can we put this straight or explain it at least? 371 // Can we put this straight or explain it at least?
407 emit changeColumns(columns); 372 emit changeColumns(columns);
408} 373}
374
diff --git a/noncore/apps/opie-console/emulation_layer.h b/noncore/apps/opie-console/emulation_layer.h
index 928ad04..73e5bf6 100644
--- a/noncore/apps/opie-console/emulation_layer.h
+++ b/noncore/apps/opie-console/emulation_layer.h
@@ -23,25 +23,24 @@
23 /* */ 23 /* */
24/* -------------------------------------------------------------------------- */ 24/* -------------------------------------------------------------------------- */
25 25
26#ifndef EMULATION_LAYER_H 26#ifndef EMULATION_LAYER_H
27#define EMULATION_LAYER_H 27#define EMULATION_LAYER_H
28 28
29#include "widget_layer.h" 29#include "widget_layer.h"
30#include "screen.h" 30#include "screen.h"
31#include <qtimer.h> 31#include <qtimer.h>
32#include <stdio.h> 32#include <stdio.h>
33#include <qtextcodec.h> 33#include <qtextcodec.h>
34#include "keytrans.h" 34#include "keytrans.h"
35#include "script.h"
36 35
37class EmulationLayer : public QObject 36class EmulationLayer : public QObject
38{ Q_OBJECT 37{ Q_OBJECT
39 38
40public: 39public:
41 40
42 EmulationLayer( WidgetLayer* gui ); 41 EmulationLayer( WidgetLayer* gui );
43 ~EmulationLayer(); 42 ~EmulationLayer();
44 43
45public: 44public:
46 virtual void setHistory(bool on); 45 virtual void setHistory(bool on);
47 virtual bool history(); 46 virtual bool history();
@@ -96,40 +95,24 @@ public:
96 /** 95 /**
97 * sends a string to IOLayer 96 * sends a string to IOLayer
98 * encodes to suit emulation before 97 * encodes to suit emulation before
99 */ 98 */
100 virtual void sendString(const QByteArray&) = 0; 99 virtual void sendString(const QByteArray&) = 0;
101 100
102 virtual void setConnect(bool r); 101 virtual void setConnect(bool r);
103 void setColumns(int columns); 102 void setColumns(int columns);
104 103
105 void setKeytrans(int no); 104 void setKeytrans(int no);
106 void setKeytrans(const char * no); 105 void setKeytrans(const char * no);
107 106
108 /* Scripts */
109
110 /* Create a new script and record all typed characters */
111 void startRecording();
112
113 /* Return whether we are currently recording a script */
114 bool isRecording();
115
116 /* Return the current script (or NULL) */
117 Script *script();
118
119 /* Stop recording and remove the current script from memory */
120 void clearScript();
121
122 /* Run a script by forwarding its keys to the EmulationLayer */
123 void runScript(const Script *);
124protected: 107protected:
125 108
126 WidgetLayer* gui; 109 WidgetLayer* gui;
127 Screen* scr; // referes to one `screen' 110 Screen* scr; // referes to one `screen'
128 Screen* screen[2]; // 0 = primary, 1 = alternate 111 Screen* screen[2]; // 0 = primary, 1 = alternate
129 void setScreen(int n); // set `scr' to `screen[n]' 112 void setScreen(int n); // set `scr' to `screen[n]'
130 113
131 bool connected; // communicate with widget 114 bool connected; // communicate with widget
132 115
133 void setCodec(int c); // codec number, 0 = locale, 1=utf8 116 void setCodec(int c); // codec number, 0 = locale, 1=utf8
134 117
135 QTextCodec* codec; 118 QTextCodec* codec;
@@ -147,17 +130,16 @@ private slots: // triggered by timer
147private: 130private:
148 131
149 void bulkNewline(); 132 void bulkNewline();
150 void bulkStart(); 133 void bulkStart();
151 void bulkEnd(); 134 void bulkEnd();
152 135
153private: 136private:
154 137
155 QTimer bulk_timer; 138 QTimer bulk_timer;
156 int bulk_nlcnt; // bulk newline counter 139 int bulk_nlcnt; // bulk newline counter
157 char* SelectedText; 140 char* SelectedText;
158 int bulk_incnt; // bulk counter 141 int bulk_incnt; // bulk counter
159 Script *m_script;
160 142
161}; 143};
162 144
163#endif // ifndef EMULATION_H 145#endif // ifndef EMULATION_H
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index a7541f0..49f9653 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -277,59 +277,55 @@ QList<Session> MainWindow::sessions() {
277 277
278void MainWindow::slotNew() { 278void MainWindow::slotNew() {
279 ProfileEditorDialog dlg(factory() ); 279 ProfileEditorDialog dlg(factory() );
280 dlg.showMaximized(); 280 dlg.showMaximized();
281 int ret = dlg.exec(); 281 int ret = dlg.exec();
282 282
283 if ( ret == QDialog::Accepted ) { 283 if ( ret == QDialog::Accepted ) {
284 create( dlg.profile() ); 284 create( dlg.profile() );
285 } 285 }
286} 286}
287 287
288void MainWindow::slotRecordScript() { 288void MainWindow::slotRecordScript() {
289/* if (currentSession()) { 289 if (currentSession()) {
290 currentSession()->emulationLayer()->startRecording(); 290 currentSession()->emulationHandler()->startRecording();
291 } 291 }
292 */
293} 292}
294 293
295void MainWindow::slotSaveScript() { 294void MainWindow::slotSaveScript() {
296/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 295 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
297 MimeTypes types; 296 MimeTypes types;
298 QStringList script; 297 QStringList script;
299 script << "text/plain"; 298 script << "text/plain";
300 types.insert("Script", script); 299 types.insert("Script", script);
301 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 300 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
302 if (!filename.isEmpty()) { 301 if (!filename.isEmpty()) {
303 currentSession()->emulationLayer()->script()->saveTo(filename); 302 currentSession()->emulationHandler()->script()->saveTo(filename);
304 currentSession()->emulationLayer()->clearScript(); 303 currentSession()->emulationHandler()->clearScript();
305 } 304 }
306 } 305 }
307 */
308} 306}
309 307
310void MainWindow::slotRunScript() { 308void MainWindow::slotRunScript() {
311/*
312 if (currentSession()) { 309 if (currentSession()) {
313 MimeTypes types; 310 MimeTypes types;
314 QStringList script; 311 QStringList script;
315 script << "text/plain"; 312 script << "text/plain";
316 types.insert("Script", script); 313 types.insert("Script", script);
317 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 314 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
318 if (!filename.isEmpty()) { 315 if (!filename.isEmpty()) {
319 Script script(DocLnk(filename).file()); 316 Script script(DocLnk(filename).file());
320 currentSession()->emulationLayer()->runScript(&script); 317 currentSession()->emulationHandler()->runScript(&script);
321 } 318 }
322 } 319 }
323 */
324} 320}
325 321
326void MainWindow::slotConnect() { 322void MainWindow::slotConnect() {
327 if ( currentSession() ) { 323 if ( currentSession() ) {
328 bool ret = currentSession()->layer()->open(); 324 bool ret = currentSession()->layer()->open();
329 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 325 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
330 QObject::tr("Failed"), 326 QObject::tr("Failed"),
331 QObject::tr("Connecting failed for this session.")); 327 QObject::tr("Connecting failed for this session."));
332 else { 328 else {
333 m_connect->setEnabled( false ); 329 m_connect->setEnabled( false );
334 m_disconnect->setEnabled( true ); 330 m_disconnect->setEnabled( true );
335 } 331 }
diff --git a/noncore/apps/opie-console/script.cpp b/noncore/apps/opie-console/script.cpp
index a09fab6..9cb1cd3 100644
--- a/noncore/apps/opie-console/script.cpp
+++ b/noncore/apps/opie-console/script.cpp
@@ -1,30 +1,29 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include "script.h" 3#include "script.h"
4 4
5Script::Script() { 5Script::Script() {
6} 6}
7 7
8Script::Script(const QString fileName) { 8Script::Script(const QString fileName) {
9 QFile file(fileName); 9 QFile file(fileName);
10 QTextStream stream(&file); 10 m_script = file.readAll();
11 while (!stream.atEnd()) {
12 appendString(stream.readLine());
13 }
14} 11}
15 12
16void Script::saveTo(const QString fileName) const { 13void Script::saveTo(const QString fileName) const {
17 QFile file(fileName); 14 QFile file(fileName);
18 file.open(IO_WriteOnly); 15 file.open(IO_WriteOnly);
19 file.writeBlock(m_script.ascii(), m_script.length()); 16 file.writeBlock(m_script);
20 file.close(); 17 file.close();
21} 18}
22 19
23 20
24void Script::appendString(const QString string) { 21void Script::append(const QByteArray &data) {
25 m_script += string; 22 int size = m_script.size();
23 m_script.resize(size + data.size());
24 memcpy(m_script.data() + size, data.data(), data.size());
26} 25}
27 26
28QString Script::script() const { 27QByteArray Script::script() const {
29 return m_script; 28 return m_script;
30} 29}
diff --git a/noncore/apps/opie-console/script.h b/noncore/apps/opie-console/script.h
index dc2351b..b3eac7f 100644
--- a/noncore/apps/opie-console/script.h
+++ b/noncore/apps/opie-console/script.h
@@ -6,25 +6,25 @@
6/* Very simple scripting - this class stores keys received 6/* Very simple scripting - this class stores keys received
7 * by emulation_layer */ 7 * by emulation_layer */
8 8
9class Script { 9class Script {
10public: 10public:
11 /* Construct an empty script */ 11 /* Construct an empty script */
12 Script(); 12 Script();
13 13
14 /* Load a script from a text file */ 14 /* Load a script from a text file */
15 Script(const QString fileName); 15 Script(const QString fileName);
16 16
17 /* Append a line to the script */ 17 /* Append a line to the script */
18 void appendString(const QString string); 18 void append(const QByteArray &data);
19 19
20 /* Save this script to a file */ 20 /* Save this script to a file */
21 void saveTo(const QString fileName) const; 21 void saveTo(const QString fileName) const;
22 22
23 /* Return the script's content */ 23 /* Return the script's content */
24 QString script() const; 24 QByteArray script() const;
25protected: 25protected:
26 QString m_script; 26 QByteArray m_script;
27}; 27};
28 28
29 29
30#endif /* CONSOLE_SCRIPT_H */ 30#endif /* CONSOLE_SCRIPT_H */