Diffstat (limited to 'noncore/apps/opie-console/emulation_handler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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 | |||
@@ -2,9 +2,14 @@ | |||
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 | |||
8 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
9 | 14 | ||
10 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 15 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
@@ -16,6 +21,7 @@ EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const c | |||
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 | ||
@@ -38,6 +44,7 @@ EmulationHandler::~EmulationHandler() { | |||
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 | ||
43 | void EmulationHandler::load( const Profile& prof) { | 50 | void EmulationHandler::load( const Profile& prof) { |
@@ -68,7 +75,11 @@ void EmulationHandler::load( const Profile& prof) { | |||
68 | } | 75 | } |
69 | void EmulationHandler::recv( const QByteArray& ar) { | 76 | void 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 | |||
72 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 83 | void EmulationHandler::recvEmulation(const char* src, int len ) { |
73 | QByteArray ar(len); | 84 | QByteArray ar(len); |
74 | 85 | ||
@@ -77,6 +88,8 @@ void EmulationHandler::recvEmulation(const char* src, int len ) { | |||
77 | m_script->append(ar); | 88 | m_script->append(ar); |
78 | emit send(ar); | 89 | emit send(ar); |
79 | } | 90 | } |
91 | |||
92 | |||
80 | QWidget* EmulationHandler::widget() { | 93 | QWidget* EmulationHandler::widget() { |
81 | return m_teWid; | 94 | return m_teWid; |
82 | } | 95 | } |
@@ -184,11 +197,25 @@ bool EmulationHandler::isRecording() { | |||
184 | return (m_script != 0); | 197 | return (m_script != 0); |
185 | } | 198 | } |
186 | 199 | ||
200 | bool EmulationHandler::isLogging() { | ||
201 | return (m_log != 0); | ||
202 | } | ||
203 | |||
187 | void EmulationHandler::startRecording() { | 204 | void EmulationHandler::startRecording() { |
188 | if (!isRecording()) | 205 | if (!isRecording()) |
189 | m_script = new Script(); | 206 | m_script = new Script(); |
190 | } | 207 | } |
191 | 208 | ||
209 | void EmulationHandler::startLogging(const QString fileName) { | ||
210 | m_logFileName = fileName; | ||
211 | if (!isLogging()) | ||
212 | m_log = new Logger(m_logFileName); | ||
213 | } | ||
214 | |||
215 | QString EmulationHandler::logFileName() { | ||
216 | return m_logFileName; | ||
217 | } | ||
218 | |||
192 | void EmulationHandler::clearScript() { | 219 | void EmulationHandler::clearScript() { |
193 | if (isRecording()) { | 220 | if (isRecording()) { |
194 | delete m_script; | 221 | delete m_script; |
@@ -196,6 +223,13 @@ void EmulationHandler::clearScript() { | |||
196 | } | 223 | } |
197 | } | 224 | } |
198 | 225 | ||
226 | void EmulationHandler::clearLog() { | ||
227 | if (isLogging()) { | ||
228 | delete m_log; | ||
229 | m_log = 0; | ||
230 | } | ||
231 | } | ||
232 | |||
199 | void EmulationHandler::runScript(const Script *script) { | 233 | void EmulationHandler::runScript(const Script *script) { |
200 | emit send(script->script()); | 234 | emit send(script->script()); |
201 | } | 235 | } |