summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp1
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp87
-rw-r--r--noncore/apps/opie-console/mainwindow.h9
3 files changed, 60 insertions, 37 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index b2b107e..e80168d 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -62,9 +62,8 @@ void EmulationHandler::recv( const QByteArray& ar) {
62void EmulationHandler::recvEmulation(const char* src, int len ) { 62void EmulationHandler::recvEmulation(const char* src, int len ) {
63 QByteArray ar(len); 63 QByteArray ar(len);
64 64
65 memcpy(ar.data(), src, sizeof(char) * len ); 65 memcpy(ar.data(), src, sizeof(char) * len );
66
67 if (isRecording()) 66 if (isRecording())
68 m_script->append(ar); 67 m_script->append(ar);
69 emit send(ar); 68 emit send(ar);
70} 69}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 44ef458..2e00a07 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -9,8 +9,11 @@
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qwhatsthis.h> 10#include <qwhatsthis.h>
11 11
12#include <qpe/resource.h> 12#include <qpe/resource.h>
13#include <qpe/qpeapplication.h>
14#include <qpe/filemanager.h>
15#include <qpe/mimetype.h>
13 16
14#include <opie/ofiledialog.h> 17#include <opie/ofiledialog.h>
15 18
16#include "keytrans.h" 19#include "keytrans.h"
@@ -43,8 +46,9 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(
43 m_manager->load(); 46 m_manager->load();
44 47
45 initUI(); 48 initUI();
46 populateProfiles(); 49 populateProfiles();
50 populateScripts();
47} 51}
48void MainWindow::initUI() { 52void MainWindow::initUI() {
49 setToolBarsMovable( FALSE ); 53 setToolBarsMovable( FALSE );
50 54
@@ -55,8 +59,9 @@ void MainWindow::initUI() {
55 m_bar = new QMenuBar( m_tool ); 59 m_bar = new QMenuBar( m_tool );
56 m_console = new QPopupMenu( this ); 60 m_console = new QPopupMenu( this );
57 m_scripts = new QPopupMenu( this ); 61 m_scripts = new QPopupMenu( this );
58 m_sessionsPop= new QPopupMenu( this ); 62 m_sessionsPop= new QPopupMenu( this );
63 m_scriptsPop = new QPopupMenu( this );
59 64
60 /* add a toolbar for icons */ 65 /* add a toolbar for icons */
61 m_icons = new QToolBar(this); 66 m_icons = new QToolBar(this);
62 67
@@ -149,19 +154,19 @@ void MainWindow::initUI() {
149 154
150 /* 155 /*
151 * script actions 156 * script actions
152 */ 157 */
158 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
159 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
160
153 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 161 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
154 m_recordScript->addTo(m_scripts); 162 m_recordScript->addTo(m_scripts);
155 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 163 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
156 164
157 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 165 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
158 m_saveScript->addTo(m_scripts); 166 m_saveScript->addTo(m_scripts);
159 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 167 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
160 168
161 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
162 m_runScript->addTo(m_scripts);
163 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
164 169
165 /* 170 /*
166 * action that open/closes the keyboard 171 * action that open/closes the keyboard
167 */ 172 */
@@ -215,11 +220,11 @@ void MainWindow::initUI() {
215 m_connect->setEnabled( false ); 220 m_connect->setEnabled( false );
216 m_disconnect->setEnabled( false ); 221 m_disconnect->setEnabled( false );
217 m_terminate->setEnabled( false ); 222 m_terminate->setEnabled( false );
218 m_transfer->setEnabled( false ); 223 m_transfer->setEnabled( false );
224 m_scripts->setItemEnabled(m_runScript_id, false);
219 m_recordScript->setEnabled( false ); 225 m_recordScript->setEnabled( false );
220 m_saveScript->setEnabled( false ); 226 m_saveScript->setEnabled( false );
221 m_runScript->setEnabled( false );
222 m_fullscreen->setEnabled( false ); 227 m_fullscreen->setEnabled( false );
223 m_closewindow->setEnabled( false ); 228 m_closewindow->setEnabled( false );
224 229
225 /* 230 /*
@@ -248,8 +253,23 @@ void MainWindow::populateProfiles() {
248 m_sessionsPop->insertItem( (*it).name() ); 253 m_sessionsPop->insertItem( (*it).name() );
249 } 254 }
250 255
251} 256}
257
258void MainWindow::populateScripts() {
259 m_scriptsPop->clear();
260 m_scriptsData.clear();
261 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
262 QListIterator<DocLnk> dit(files.children());
263 for (; dit.current(); ++dit) {
264 if (*dit && (*dit)->name().length()>0) {
265 m_scriptsData.append((*dit));
266 m_scriptsPop->insertItem((*dit)->name());
267 }
268 }
269
270}
271
252MainWindow::~MainWindow() { 272MainWindow::~MainWindow() {
253 delete m_factory; 273 delete m_factory;
254 manager()->save(); 274 manager()->save();
255} 275}
@@ -278,40 +298,42 @@ void MainWindow::slotNew() {
278 298
279void MainWindow::slotRecordScript() { 299void MainWindow::slotRecordScript() {
280 if (currentSession()) { 300 if (currentSession()) {
281 currentSession()->emulationHandler()->startRecording(); 301 currentSession()->emulationHandler()->startRecording();
302 m_saveScript->setEnabled(true);
303 m_recordScript->setEnabled(false);
282 } 304 }
283} 305}
284 306
285void MainWindow::slotSaveScript() { 307void MainWindow::slotSaveScript() {
286 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 308 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
287 MimeTypes types; 309 QMap<QString, QStringList> map;
288 QStringList script; 310 QStringList text;
289 script << "text/plain"; 311 text << "text/plain";
290 script << "text/all"; 312 map.insert(tr("Script"), text );
291 script << "application/octet-stream"; 313 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
292 types.insert("Script", script);
293 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
294 if (!filename.isEmpty()) { 314 if (!filename.isEmpty()) {
295 currentSession()->emulationHandler()->script()->saveTo(filename); 315 DocLnk nf;
316 nf.setType("text/plain");
317 nf.setFile(filename);
318 nf.setName(filename);
319 FileManager fm;
320 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
296 currentSession()->emulationHandler()->clearScript(); 321 currentSession()->emulationHandler()->clearScript();
322 m_saveScript->setEnabled(false);
323 m_recordScript->setEnabled(true);
324 populateScripts();
297 } 325 }
298 } 326 }
299} 327}
300 328
301void MainWindow::slotRunScript() { 329void MainWindow::slotRunScript(int id) {
302 if (currentSession()) { 330 if (currentSession()) {
303 MimeTypes types; 331 DocLnk *lnk = m_scriptsData.at(m_scriptsPop->indexOf(id));
304 QStringList script; 332 QString filePath = lnk->file();
305 script << "text/plain"; 333 printf("path is : %s\n", filePath.latin1());
306 script << "text/all"; 334 Script script(filePath);
307 script << "application/octet-stream"; 335 currentSession()->emulationHandler()->runScript(&script);
308 types.insert("Script", script);
309 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
310 if (!filename.isEmpty()) {
311 Script script(DocLnk(filename).file());
312 currentSession()->emulationHandler()->runScript(&script);
313 }
314 } 336 }
315} 337}
316 338
317void MainWindow::slotConnect() { 339void MainWindow::slotConnect() {
@@ -324,10 +346,9 @@ void MainWindow::slotConnect() {
324 m_connect->setEnabled( false ); 346 m_connect->setEnabled( false );
325 m_disconnect->setEnabled( true ); 347 m_disconnect->setEnabled( true );
326 m_transfer->setEnabled( true ); 348 m_transfer->setEnabled( true );
327 m_recordScript->setEnabled( true ); 349 m_recordScript->setEnabled( true );
328 m_saveScript->setEnabled( true ); 350 m_scripts->setItemEnabled(m_runScript_id, true);
329 m_runScript->setEnabled( true );
330 } 351 }
331 } 352 }
332} 353}
333 354
@@ -338,9 +359,9 @@ void MainWindow::slotDisconnect() {
338 m_disconnect->setEnabled( false ); 359 m_disconnect->setEnabled( false );
339 m_transfer->setEnabled( false ); 360 m_transfer->setEnabled( false );
340 m_recordScript->setEnabled( false); 361 m_recordScript->setEnabled( false);
341 m_saveScript->setEnabled( false ); 362 m_saveScript->setEnabled( false );
342 m_runScript->setEnabled( false ); 363 m_scripts->setItemEnabled(m_runScript_id, false);
343 } 364 }
344} 365}
345 366
346void MainWindow::slotTerminate() { 367void MainWindow::slotTerminate() {
@@ -389,9 +410,9 @@ void MainWindow::slotClose() {
389 m_terminate->setEnabled( false ); 410 m_terminate->setEnabled( false );
390 m_transfer->setEnabled( false ); 411 m_transfer->setEnabled( false );
391 m_recordScript->setEnabled( false ); 412 m_recordScript->setEnabled( false );
392 m_saveScript->setEnabled( false ); 413 m_saveScript->setEnabled( false );
393 m_runScript->setEnabled( false ); 414 m_scripts->setItemEnabled(m_runScript_id, false);
394 m_fullscreen->setEnabled( false ); 415 m_fullscreen->setEnabled( false );
395 m_closewindow->setEnabled( false ); 416 m_closewindow->setEnabled( false );
396 } 417 }
397 418
@@ -432,9 +453,9 @@ void MainWindow::create( const Profile& prof ) {
432 m_closewindow->setEnabled( true ); 453 m_closewindow->setEnabled( true );
433 m_transfer->setEnabled( false ); 454 m_transfer->setEnabled( false );
434 m_recordScript->setEnabled( false ); 455 m_recordScript->setEnabled( false );
435 m_saveScript->setEnabled( false ); 456 m_saveScript->setEnabled( false );
436 m_runScript->setEnabled( false ); 457 m_scripts->setItemEnabled(m_runScript_id, false);
437 458
438 // is io_layer wants direct connection, then autoconnect 459 // is io_layer wants direct connection, then autoconnect
439 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 460 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
440 if (prof.autoConnect()) { 461 if (prof.autoConnect()) {
@@ -486,17 +507,17 @@ void MainWindow::slotSessionChanged( Session* ses ) {
486 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 507 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
487 if ( m_curSession->layer()->isConnected() ) { 508 if ( m_curSession->layer()->isConnected() ) {
488 m_connect->setEnabled( false ); 509 m_connect->setEnabled( false );
489 m_disconnect->setEnabled( true ); 510 m_disconnect->setEnabled( true );
490 m_recordScript->setEnabled( true ); 511 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
491 m_saveScript->setEnabled( true ); 512 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
492 m_runScript->setEnabled( true ); 513 m_scripts->setItemEnabled(m_runScript_id, true);
493 } else { 514 } else {
494 m_connect->setEnabled( true ); 515 m_connect->setEnabled( true );
495 m_disconnect->setEnabled( false ); 516 m_disconnect->setEnabled( false );
496 m_recordScript->setEnabled( false ); 517 m_recordScript->setEnabled( false );
497 m_saveScript->setEnabled( false ); 518 m_saveScript->setEnabled( false );
498 m_runScript->setEnabled( false ); 519 m_scripts->setItemEnabled(m_runScript_id, false);
499 } 520 }
500 521
501 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 522 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
502 m_transfer->setEnabled( false ); 523 m_transfer->setEnabled( false );
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 19d3a3d..3b16f0a 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -20,9 +20,9 @@ class TabWidget;
20class ProfileManager; 20class ProfileManager;
21class Profile; 21class Profile;
22class FunctionKeyboard; 22class FunctionKeyboard;
23class FKey; 23class FKey;
24 24class DocLnk;
25 25
26class MainWindow : public QMainWindow { 26class MainWindow : public QMainWindow {
27 Q_OBJECT 27 Q_OBJECT
28public: 28public:
@@ -64,9 +64,9 @@ private slots:
64 void slotOpenKeb(bool); 64 void slotOpenKeb(bool);
65 void slotOpenButtons(bool); 65 void slotOpenButtons(bool);
66 void slotRecordScript(); 66 void slotRecordScript();
67 void slotSaveScript(); 67 void slotSaveScript();
68 void slotRunScript(); 68 void slotRunScript(int);
69 void slotFullscreen(); 69 void slotFullscreen();
70 void slotSessionChanged( Session* ); 70 void slotSessionChanged( Session* );
71 void slotKeyReceived(FKey, ushort, ushort, bool); 71 void slotKeyReceived(FKey, ushort, ushort, bool);
72 72
@@ -79,8 +79,9 @@ private slots:
79 79
80private: 80private:
81 void initUI(); 81 void initUI();
82 void populateProfiles(); 82 void populateProfiles();
83 void populateScripts();
83 void create( const Profile& ); 84 void create( const Profile& );
84 /** 85 /**
85 * the current session 86 * the current session
86 */ 87 */
@@ -89,8 +90,9 @@ private:
89 /** 90 /**
90 * the session list 91 * the session list
91 */ 92 */
92 QList<Session> m_sessions; 93 QList<Session> m_sessions;
94 QList<DocLnk> m_scriptsData;
93 95
94 /** 96 /**
95 * the metafactory 97 * the metafactory
96 */ 98 */
@@ -104,8 +106,9 @@ private:
104 QToolBar* m_buttonBar; 106 QToolBar* m_buttonBar;
105 QMenuBar* m_bar; 107 QMenuBar* m_bar;
106 QPopupMenu* m_console; 108 QPopupMenu* m_console;
107 QPopupMenu* m_sessionsPop; 109 QPopupMenu* m_sessionsPop;
110 QPopupMenu* m_scriptsPop;
108 QPopupMenu* m_scripts; 111 QPopupMenu* m_scripts;
109 QAction* m_connect; 112 QAction* m_connect;
110 QAction* m_disconnect; 113 QAction* m_disconnect;
111 QAction* m_terminate; 114 QAction* m_terminate;
@@ -114,13 +117,13 @@ private:
114 QAction* m_openKeys; 117 QAction* m_openKeys;
115 QAction* m_openButtons; 118 QAction* m_openButtons;
116 QAction* m_recordScript; 119 QAction* m_recordScript;
117 QAction* m_saveScript; 120 QAction* m_saveScript;
118 QAction* m_runScript;
119 QAction* m_fullscreen; 121 QAction* m_fullscreen;
120 QAction* m_closewindow; 122 QAction* m_closewindow;
121 123
122 FunctionKeyboard *m_kb; 124 FunctionKeyboard *m_kb;
125 int m_runScript_id;
123 bool m_isFullscreen; 126 bool m_isFullscreen;
124 127
125 QWidget* savedParentFullscreen; 128 QWidget* savedParentFullscreen;
126}; 129};