summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (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
@@ -40,96 +40,97 @@
\par FIXME
[NOTE: much of the technical stuff below will be replaced by forkpty.]
publish the SIGCHLD signal if not related to an instance.
clearify TEPty::done vs. TEPty::~TEPty semantics.
check if pty is restartable via run after done.
\par Pseudo terminals
Pseudo terminals are a unique feature of UNIX, and always come in form of
pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
other by the operating system. One may think of them as two serial devices
linked by a null-modem cable. Being based on devices the number of
simultanous instances of this class is (globally) limited by the number of
those device pairs, which is 256.
Another technic are UNIX 98 PTY's. These are supported also, and prefered
over the (obsolete) predecessor.
There's a sinister ioctl(2), signal(2) and job control stuff
nessesary to make everything work as it should.
*/
#include "procctl.h"
#include "MyPty.h"
/* OPIE */
#include <opie2/odebug.h>
using namespace Opie::Core;
/* QT */
#include <qsocketnotifier.h>
#include <qfile.h>
/* STD */
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
+
#ifdef HAVE_OPENPTY
#include <pty.h>
#endif
#undef VERBOSE_DEBUG
/* -------------------------------------------------------------------------- */
/*!
Informs the client program about the
actual size of the window.
*/
void MyPty::setSize(int lines, int columns)
{
owarn << "setting size" << oendl;
struct winsize wsize;
wsize.ws_row = (unsigned short)lines;
wsize.ws_col = (unsigned short)columns;
if(m_fd < 0) return;
ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
}
void MyPty::donePty()
{
// This is code from the Qt DumbTerminal example
::close(m_fd);
if (m_cpid) {
kill(m_cpid, SIGHUP);
//waitpid(m_cpid, &status, 0);
delete m_sn_e;
delete m_sn_r;
m_sn_e = 0l;
m_sn_r = 0l;
}
m_cpid = 0;
m_fd = -1;
// emit done(status);
}
const char* MyPty::deviceName()
{
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,127 +1,140 @@
#include "TEmuVt102.h"
#include "profile.h"
#include "emulation_handler.h"
#include "script.h"
+#include "logger.h"
/* OPIE */
#include <opie2/odebug.h>
+
+#include <qfile.h>
+#include <qtextstream.h>
+
using namespace Opie::Core;
EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
: QObject(0, name )
{
m_teWid = new TEWidget( parent, "TerminalMain");
// use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
// use setWrapAt(80) for normal console with scrollbar
setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80);
m_teWid->setMinimumSize(150, 70 );
m_script = 0;
+ m_log = 0;
parent->resize( m_teWid->calcSize(80, 24 ) );
m_teEmu = new TEmuVt102(m_teWid );
connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ),
this, SIGNAL(changeSize(int,int) ) );
connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ),
this, SLOT(recvEmulation(const char*,int) ) );
m_teEmu->setConnect( true );
m_teEmu->setHistory( TRUE );
load( prof );
}
TEmulation* EmulationHandler::emulation() {
return m_teEmu;
}
EmulationHandler::~EmulationHandler() {
if (isRecording())
clearScript();
delete m_teEmu;
delete m_teWid;
+ delete m_log;
}
void EmulationHandler::load( const Profile& prof) {
// m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal );
font.setFixedPitch( TRUE );
m_teWid->setVTFont( font );
int num = prof.readNumEntry("Color");
setColor( foreColor(num), backColor(num) );
m_teWid->setBackgroundColor(backColor(num) );
int term = prof.readNumEntry("Terminal", 0) ;
switch(term) {
default:
case Profile::VT102:
case Profile::VT100:
m_teEmu->setKeytrans("vt100.keytab");
break;
case Profile::Linux:
m_teEmu->setKeytrans("linux.keytab");
break;
case Profile::XTerm:
m_teEmu->setKeytrans("default.Keytab");
break;
}
}
void EmulationHandler::recv( const QByteArray& ar) {
m_teEmu->onRcvBlock(ar.data(), ar.count() );
+ if ( isLogging() ) {
+ m_log->append( ar );
+ }
}
+
void EmulationHandler::recvEmulation(const char* src, int len ) {
QByteArray ar(len);
memcpy(ar.data(), src, sizeof(char) * len );
if (isRecording())
m_script->append(ar);
emit send(ar);
}
+
+
QWidget* EmulationHandler::widget() {
return m_teWid;
}
/*
* allocate a new table of colors
*/
void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
ColorEntry table[TABLE_COLORS];
const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
for (int i = 0; i < TABLE_COLORS; i++ ) {
if ( i == 0 || i == 10 ) {
table[i].color = fore;
}else if ( i == 1 || i == 11 ) {
table[i].color = back;
table[i].transparent = 0;
}else {
table[i].color = defaultCt[i].color;
}
}
m_teWid->setColorTable(table );
m_teWid->update();
}
QFont EmulationHandler::font( int id ) {
QString name;
int size = 0;
switch(id ) {
default: // fall through
case 0:
name = QString::fromLatin1("Micro");
size = 4;
break;
case 1:
name = QString::fromLatin1("Fixed");
size = 7;
break;
case 2:
name = QString::fromLatin1("Fixed");
size = 12;
break;
}
QFont font(name, size, QFont::Normal );
font.setFixedPitch(TRUE );
return font;
}
QColor EmulationHandler::foreColor(int col) {
QColor co;
/* we need to switch it */
@@ -139,75 +152,96 @@ QColor EmulationHandler::foreColor(int col) {
co = Qt::green;
break;
case Profile::Orange:
owarn << "Foreground orange" << oendl;
co.setRgb( 231, 184, 98 );
break;
}
return co;
}
QColor EmulationHandler::backColor(int col ) {
QColor co;
/* we need to switch it */
switch( col ) {
default:
case Profile::White:
/* color is white */
co = Qt::black;
break;
case Profile::Black:
co = Qt::white;
break;
case Profile::Green:
owarn << "Background black" << oendl;
co = Qt::black;
break;
case Profile::Orange:
owarn << "Background black" << oendl;
co = Qt::black;
break;
}
return co;
}
QPushButton* EmulationHandler::cornerButton() {
return m_teWid->cornerButton();
}
Script *EmulationHandler::script() {
return m_script;
}
bool EmulationHandler::isRecording() {
return (m_script != 0);
}
+bool EmulationHandler::isLogging() {
+ return (m_log != 0);
+}
+
void EmulationHandler::startRecording() {
if (!isRecording())
m_script = new Script();
}
+void EmulationHandler::startLogging(const QString fileName) {
+ m_logFileName = fileName;
+ if (!isLogging())
+ m_log = new Logger(m_logFileName);
+}
+
+QString EmulationHandler::logFileName() {
+ return m_logFileName;
+}
+
void EmulationHandler::clearScript() {
if (isRecording()) {
delete m_script;
m_script = 0;
}
}
+void EmulationHandler::clearLog() {
+ if (isLogging()) {
+ delete m_log;
+ m_log = 0;
+ }
+}
+
void EmulationHandler::runScript(const Script *script) {
emit send(script->script());
}
void EmulationHandler::copy() {
m_teWid->emitSelection();
}
void EmulationHandler::paste() {
m_teWid->pasteClipboard();
}
void EmulationHandler::setWrap(int columns) {
m_teWid->setWrapAt(columns);
}
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 @@
#ifndef OPIE_EMULATION_HANDLER_H
#define OPIE_EMULATION_HANDLER_H
#include <qobject.h>
#include <qcolor.h>
#include <qcstring.h>
/*
* Badly ibotty lacks the time to finish
* his widget in time..
* Never the less we've to have an EmulationWidget
* This is why I'm taking the inferior not cleaned
* up TE* KDE STUFF
*/
/**
* This is the layer above the IOLayer*
* This nice QObject here will get stuff from
* got a slot and a signal
* the signal for data
* the slot for receiving
* it'll set up the widget internally
* and manage the communication between
* the pre QByteArray world!
*/
class Profile;
class QWidget;
class QPushButton;
class TEWidget;
+class QFile;
class TEmulation;
class QFont;
+class QTextStream;
class Script;
+class Logger;
+
class EmulationHandler : public QObject {
Q_OBJECT
public:
/**
* simple c'tor the parent of the TEWdiget
* and a name
* and a Profile
*/
EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l );
/**
* delete all components
*/
~EmulationHandler();
void load( const Profile& );
QWidget* widget();
TEmulation *emulation();
void setColor( const QColor& fore, const QColor& back );
QPushButton* cornerButton();
/* Scripts */
/* Create a new script and record all typed characters */
void startRecording();
+ void startLogging(const QString);
+
/* Return whether we are currently recording a script */
bool isRecording();
+ /* Return whether we are currently recording a log */
+ bool isLogging();
+
+ QString logFileName();
+
/* Return the current script (or NULL) */
Script *script();
/* Stop recording and remove the current script from memory */
void clearScript();
+
+ /* Stop logging and remove the current log from memory */
+ void clearLog();
/* Run a script by forwarding its keys to the EmulationLayer */
void runScript(const Script *);
/* Propagate change to widget */
void setWrap(int columns);
signals:
void send( const QByteArray& );
void changeSize(int rows, int cols );
public slots:
void recv( const QByteArray& );
void paste();
void copy();
private slots:
void recvEmulation( const char*, int len );
private:
QFont font( int );
QColor foreColor(int );
QColor backColor(int );
private:
TEWidget* m_teWid;
TEmulation* m_teEmu;
Script * m_script;
+ Logger *m_log;
+ QString m_logFileName;
};
#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 @@
+
+#include "fixit.h"
+
+using namespace Opie::Core;
+
+#ifdef FSCKED_DISTRI
+FixIt::FixIt() : QObject() {
+ /* the new inittab */
+ m_file = "#\n# /etc/inittab"
+"#"
+""
+"# 0 - halt (Do NOT set initdefault to this)"
+"# 1 - Single user mode"
+"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
+"# 3 - Full multiuser mode"
+"# 4 - JavaVM(Intent) developer mode"
+"# 5 - JavaVM(Intent)"
+"# 6 - reboot (Do NOT set initdefault to this)"
+"#"
+"id:5:initdefault:"
+""
+"# Specify things to do when starting"
+"si::sysinit:/etc/rc.d/rc.sysinit"
+""
+"l0:0:wait:/root/etc/rc.d/rc 0"
+"l1:1:wait:/etc/rc.d/rc 1"
+"l2:2:wait:/etc/rc.d/rc 2"
+"l3:3:wait:/etc/rc.d/rc 3"
+"l4:4:wait:/etc/rc.d/rc 4"
+"l5:5:wait:/etc/rc.d/rc 5"
+"l6:6:wait:/root/etc/rc.d/rc 6"
+""
+"# Specify things to do before rebooting"
+"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
+"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
+""
+"# Specify program to run on ttyS0"
+"s0:24:respawn:/sbin/getty 9600 ttyS0"
+"#pd:5:respawn:/etc/sync/serialctl"
+""
+"# Specify program to run on tty1"
+"1:2:respawn:/sbin/getty 9600 tty1"
+"ln:345:respawn:survive -l 6 /sbin/launch"
+"#qt:5:respawn:/sbin/qt"
+""
+"# collie sp."
+"sy::respawn:/sbin/shsync\n";
+}
+
+FixIt::~FixIt() {
+}
+
+/*
+ * the retail Zaurus is broken in many ways
+ * one is that pppd is listening on our port...
+ * we've to stop it from that and then do kill(SIGHUP,1);
+ */
+void FixIt::fixIt() {
+ #ifndef EAST
+ ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
+ QFile file( "/etc/inittab" );
+ if ( file.open(IO_WriteOnly | IO_Raw ) ) {
+ file.writeBlock(m_file,strlen(m_file) );
+ }
+ file.close();
+ ::kill( SIGHUP, 1 );
+
+ #else
+
+ OProcess m_kill;
+ m_kill << "sh";
+ m_kill << "-c";
+ m_kill << QString(QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_kill_0_1.sh");
+
+
+ if ( !m_kill.start(OProcess::DontCare,OProcess::NoCommunication) ) {
+ owarn << "could not execute kill script" << oendl;
+ } else {
+ Global::statusMessage( tr("Fixing up Embedix"));
+ }
+
+ #endif
+}
+
+void FixIt::breakIt() {
+ #ifdef EAST
+ OProcess m_restart;
+ m_restart << "sh";
+ m_restart << "-c";
+ m_restart << QString(QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_restart_0_1.sh");
+
+
+ if ( !m_restart.start() ) {
+ owarn << "could not execute restart script" << oendl;
+ }
+
+ #endif
+}
+
+
+#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 @@
#ifndef FIX_IT_H
#define FIX_IT_H
+#include <opie2/oprocess.h>
+#include <opie2/odebug.h>
+
+#include <qpe/global.h>
+#include <qpe/qpeapplication.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
-#include <qfile.h>
+
/*
* The Zaurus rom
*/
-class FixIt {
+class FixIt : public QObject {
+
+ Q_OBJECT
+
public:
FixIt();
~FixIt();
void fixIt();
/* no real interested in implementing it */
- void breakIt() {
-
- };
+ void breakIt();
char* m_file;
};
-#ifdef FSCKED_DISTRI
-FixIt::FixIt() {
- /* the new inittab */
- m_file = "#\n# /etc/inittab"
-"#"
-""
-"# 0 - halt (Do NOT set initdefault to this)"
-"# 1 - Single user mode"
-"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
-"# 3 - Full multiuser mode"
-"# 4 - JavaVM(Intent) developer mode"
-"# 5 - JavaVM(Intent)"
-"# 6 - reboot (Do NOT set initdefault to this)"
-"#"
-"id:5:initdefault:"
-""
-"# Specify things to do when starting"
-"si::sysinit:/etc/rc.d/rc.sysinit"
-""
-"l0:0:wait:/root/etc/rc.d/rc 0"
-"l1:1:wait:/etc/rc.d/rc 1"
-"l2:2:wait:/etc/rc.d/rc 2"
-"l3:3:wait:/etc/rc.d/rc 3"
-"l4:4:wait:/etc/rc.d/rc 4"
-"l5:5:wait:/etc/rc.d/rc 5"
-"l6:6:wait:/root/etc/rc.d/rc 6"
-""
-"# Specify things to do before rebooting"
-"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
-"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
-""
-"# Specify program to run on ttyS0"
-"s0:24:respawn:/sbin/getty 9600 ttyS0"
-"#pd:5:respawn:/etc/sync/serialctl"
-""
-"# Specify program to run on tty1"
-"1:2:respawn:/sbin/getty 9600 tty1"
-"ln:345:respawn:survive -l 6 /sbin/launch"
-"#qt:5:respawn:/sbin/qt"
-""
-"# collie sp."
-"sy::respawn:/sbin/shsync\n";
-
-}
-FixIt::~FixIt() {
-}
-/*
- * the retail Zaurus is broken in many ways
- * one is that pppd is listening on our port...
- * we've to stop it from that and then do kill(SIGHUP,1);
- */
-void FixIt::fixIt() {
- ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
- QFile file( "/etc/inittab" );
- if ( file.open(IO_WriteOnly | IO_Raw ) ) {
- file.writeBlock(m_file,strlen(m_file) );
- }
- file.close();
- ::kill( SIGHUP, 1 );
-}
#endif
-#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 @@
+#include <qfile.h>
+#include <qtextstream.h>
+
+#include "logger.h"
+
+
+Logger::Logger() {}
+
+Logger::Logger(const QString fileName) {
+ m_file.setName(fileName);
+ m_file.open(IO_ReadWrite);
+}
+
+Logger::~Logger() {
+ m_file.close();
+}
+
+void Logger::append(QByteArray ar) {
+ m_file.writeBlock(ar);
+} \ 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 @@
+#ifndef CONSOLE_LOGGER_H
+#define CONSOLE_LOGGER_H
+
+#include <qstring.h>
+#include <qfile.h>
+
+class Logger {
+
+public:
+ Logger();
+ Logger(const QString fileName);
+ void append(QByteArray ar);
+ ~Logger();
+
+private:
+ QFile m_file;
+};
+
+#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,210 +1,219 @@
#include "TEmulation.h"
#include "profileeditordialog.h"
#include "configdialog.h"
#include "default.h"
#include "profilemanager.h"
#include "mainwindow.h"
#include "tabwidget.h"
#include "transferdialog.h"
#include "function_keyboard.h"
#include "emulation_handler.h"
#include "script.h"
#include "fixit.h"
/* OPIE */
#include <opie2/odebug.h>
#include <opie2/ofiledialog.h>
#include <qpe/filemanager.h>
using namespace Opie::Core;
using namespace Opie::Ui;
/* QT */
#include <qaction.h>
#include <qmenubar.h>
#include <qtoolbar.h>
#include <qmessagebox.h>
#include <qwhatsthis.h>
#include <qfileinfo.h>
/* STD */
#include <assert.h>
MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
+
#ifdef FSCKED_DISTRI
- FixIt fix;
- fix.fixIt();
+ FixIt fix;
+ fix.fixIt();
#endif
setCaption(QObject::tr("Opie Console") );
KeyTrans::loadAll();
for (int i = 0; i < KeyTrans::count(); i++ ) {
KeyTrans* s = KeyTrans::find(i );
assert( s );
}
m_factory = new MetaFactory();
Default def(m_factory);
m_sessions.setAutoDelete( TRUE );
m_curSession = 0;
m_manager = new ProfileManager( m_factory );
m_manager->load();
m_scriptsData.setAutoDelete(TRUE);
initUI();
populateProfiles();
populateScripts();
}
void MainWindow::initUI() {
setToolBarsMovable( FALSE );
/* tool bar for the menu */
m_tool = new QToolBar( this );
m_tool->setHorizontalStretchable( TRUE );
m_bar = new QMenuBar( m_tool );
m_console = new QPopupMenu( this );
m_scripts = new QPopupMenu( this );
m_sessionsPop= new QPopupMenu( this );
m_scriptsPop = new QPopupMenu( this );
/* add a toolbar for icons */
m_icons = new QToolBar(this);
/*
* the settings action
*/
m_setProfiles = new QAction(tr("Configure Profiles"),
Resource::loadPixmap( "SettingsIcon" ),
QString::null, 0, this, 0);
m_setProfiles->addTo( m_console );
connect( m_setProfiles, SIGNAL(activated() ),
this, SLOT(slotConfigure() ) );
m_console->insertSeparator();
/*
* new Action for new sessions
*/
QAction* newCon = new QAction(tr("New Profile"),
Resource::loadPixmap( "new" ),
QString::null, 0, this, 0);
newCon->addTo( m_console );
connect( newCon, SIGNAL(activated() ),
this, SLOT(slotNew() ) );
m_console->insertSeparator();
QAction *saveCon = new QAction( tr("Save Profile" ),
Resource::loadPixmap( "save" ), QString::null,
0, this, 0 );
saveCon->addTo( m_console );
connect( saveCon, SIGNAL(activated() ),
this, SLOT(slotSaveSession() ) );
m_console->insertSeparator();
/*
* connect action
*/
m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
QString::null, 0, this, 0 );
m_connect->addTo( m_console );
connect(m_connect, SIGNAL(activated() ),
this, SLOT(slotConnect() ) );
/*
* disconnect action
*/
m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
QString::null, 0, this, 0 );
m_disconnect->addTo( m_console );
connect(m_disconnect, SIGNAL(activated() ),
this, SLOT(slotDisconnect() ) );
m_console->insertSeparator();
-
+#ifndef EAST
m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
m_quickLaunch->addTo( m_icons );
connect( m_quickLaunch, SIGNAL( activated() ),
this, SLOT( slotQuickLaunch() ) );
+#endif
QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
0, this, 0 );
m_transfer->addTo( m_console );
connect(m_transfer, SIGNAL(activated() ),
this, SLOT(slotTransfer() ) );
/*
* immediate change of line wrap policy
*/
m_isWrapped = true;
m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true );
m_wrap->addTo( m_console );
m_wrap->setOn( true );
connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
/*
* fullscreen
*/
m_isFullscreen = false;
m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
, QString::null, 0, this, 0 );
m_fullscreen->addTo( m_console );
connect( m_fullscreen, SIGNAL( activated() ),
this, SLOT( slotFullscreen() ) );
m_console->insertSeparator();
+ m_recordLog = new QAction();
+ m_recordLog->setText( tr("Start log") );
+ m_recordLog->addTo( m_console );
+ connect(m_recordLog, SIGNAL(activated() ),
+ this, SLOT( slotSaveLog() ) );
+ m_recordingLog = false;
+
QAction *a = new QAction();
a->setText( tr("Save history") );
a->addTo( m_console );
connect(a, SIGNAL(activated() ),
this, SLOT(slotSaveHistory() ) );
/*
* terminate action
*/
m_terminate = new QAction();
m_terminate->setText( tr("Terminate") );
m_terminate->addTo( m_console );
connect(m_terminate, SIGNAL(activated() ),
this, SLOT(slotTerminate() ) );
m_closewindow = new QAction();
m_closewindow->setText( tr("Close Window") );
m_closewindow->addTo( m_console );
connect( m_closewindow, SIGNAL(activated() ),
this, SLOT(slotClose() ) );
/*
* script actions
*/
m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
m_recordScript->addTo(m_scripts);
connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
m_saveScript->addTo(m_scripts);
connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
/*
* action that open/closes the keyboard
*/
m_openKeys = new QAction (tr("Open Keyboard..."),
Resource::loadPixmap( "console/keys/keyboard_icon" ),
QString::null, 0, this, 0);
m_openKeys->setToggleAction(true);
connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
/* insert the submenu */
m_console->insertItem(tr("New from Profile"), m_sessionsPop,
-1, 0);
@@ -377,110 +386,109 @@ void MainWindow::slotRunScript(int id) {
}
}
void MainWindow::slotConnect() {
if ( currentSession() ) {
bool ret = currentSession()->layer()->open();
if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
QObject::tr("Failed"),
QObject::tr("Connecting failed for this session."));
else {
m_connect->setEnabled( false );
m_disconnect->setEnabled( true );
// if it does not support file transfer, disable the menu entry
if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
m_transfer->setEnabled( false );
} else {
m_transfer->setEnabled( true );
}
m_recordScript->setEnabled( true );
m_scripts->setItemEnabled(m_runScript_id, true);
}
}
}
void MainWindow::slotDisconnect() {
if ( currentSession() ) {
currentSession()->layer()->close();
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
m_transfer->setEnabled( false );
m_recordScript->setEnabled( false);
m_saveScript->setEnabled( false );
m_scripts->setItemEnabled(m_runScript_id, false);
}
}
void MainWindow::slotTerminate() {
if ( currentSession() )
currentSession()->layer()->close();
slotClose();
/* FIXME move to the next session */
}
-
-
-
void MainWindow::slotQuickLaunch() {
- Profile prof = manager()->profile( "default" );
+
+ Profile prof = manager()->profile( "default" );
if ( prof.name() == "default" ) {
create( prof );
} else {
+ #ifndef EAST
Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
newProf.setAutoConnect( true );
create( newProf );
slotSaveSession();
+ #endif
}
-
}
void MainWindow::slotConfigure() {
ConfigDialog conf( manager()->all(), factory() );
int ret = QPEApplication::execDialog( &conf );
if ( QDialog::Accepted == ret ) {
manager()->setProfiles( conf.list() );
manager()->save();
populateProfiles();
}
}
/*
* we will remove
* this window from the tabwidget
* remove it from the list
* delete it
* and set the currentSession()
*/
void MainWindow::slotClose() {
if (!currentSession() )
return;
Session* ses = currentSession();
owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl;
/* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
m_curSession = NULL;
tabWidget()->remove( /*currentSession()*/ses );
/*it's autodelete */
m_sessions.remove( ses );
owarn << "after remove!!" << oendl;
if (!currentSession() ) {
m_connect->setEnabled( false );
m_disconnect->setEnabled( false );
m_terminate->setEnabled( false );
m_transfer->setEnabled( false );
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_scripts->setItemEnabled(m_runScript_id, false);
m_fullscreen->setEnabled( false );
m_wrap->setEnabled( false );
m_closewindow->setEnabled( false );
}
m_kb->loadDefaults();
}
@@ -563,96 +571,102 @@ void MainWindow::slotTransfer()
}
}
void MainWindow::slotOpenKeb(bool state) {
if (state) m_keyBar->show();
else m_keyBar->hide();
}
void MainWindow::slotOpenButtons( bool state ) {
if ( state ) {
m_buttonBar->show();
} else {
m_buttonBar->hide();
}
}
void MainWindow::slotSessionChanged( Session* ses ) {
owarn << "changed!" << oendl;
if(m_curSession)
if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
if(ses)
if(ses->transferDialog()) ses->transferDialog()->show();
if ( ses ) {
m_curSession = ses;
odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl;
if ( m_curSession->layer()->isConnected() ) {
m_connect->setEnabled( false );
m_disconnect->setEnabled( true );
m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
m_scripts->setItemEnabled(m_runScript_id, true);
} else {
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_scripts->setItemEnabled(m_runScript_id, false);
}
+ if ( ( currentSession()->emulationHandler()->isLogging() ) ) {
+ m_recordLog->setText( tr("Stop log") );
+ } else {
+ m_recordLog->setText( tr("Start log") );
+ }
+
if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
m_transfer->setEnabled( false );
} else {
m_transfer->setEnabled( true );
}
QWidget *w = m_curSession->widget();
if(w) w->setFocus();
if(currentSession()->profile().readNumEntry("Wrap", 80)){
m_isWrapped = true;
} else {
m_isWrapped = false;
}
m_kb->load(currentSession()->profile());
}
}
void MainWindow::slotWrap()
{
if(m_curSession)
{
EmulationHandler *e = m_curSession->emulationHandler();
if(e)
{
e->setWrap( m_isWrapped ? 80:0 );
m_isWrapped = !m_isWrapped;
}
}
}
void MainWindow::slotFullscreen() {
if ( m_isFullscreen ) {
( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
( m_curSession->emulationHandler() )->cornerButton()->hide();
disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
} else {
savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
, QPoint(0,0), false );
( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
@@ -662,73 +676,103 @@ void MainWindow::slotFullscreen() {
( ( m_curSession->emulationHandler() )->cornerButton() )->show();
connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
}
m_isFullscreen = !m_isFullscreen;
}
void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
if ( m_curSession ) {
QEvent::Type state;
if (pressed) state = QEvent::KeyPress;
else state = QEvent::KeyRelease;
QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
// is this the best way to do this? cant figure out any other way to work
QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
ke.ignore();
}
}
void MainWindow::slotCopy() {
if (!currentSession() ) return;
currentSession()->emulationHandler()->copy();
}
void MainWindow::slotPaste() {
if (!currentSession() ) return;
currentSession()->emulationHandler()->paste();
}
/*
* Save the session
*/
void MainWindow::slotSaveSession() {
if (!currentSession() ) {
QMessageBox::information(this, tr("Save Connection"),
tr("<qt>There is no Connection.</qt>"), 1 );
return;
}
manager()->add( currentSession()->profile() );
manager()->save();
populateProfiles();
}
+
+
+
+void MainWindow::slotSaveLog() {
+
+ if( currentSession()->emulationHandler()->isLogging() ) {
+ DocLnk nf;
+ QString m_logName = currentSession()->emulationHandler()->logFileName();
+ QFileInfo info(m_logName);
+ nf.setType("text/plain");
+ nf.setFile(m_logName);
+ nf.setName(info.fileName());
+ nf.writeLink();
+ m_recordLog->setText( tr("Start log") );
+ m_recordingLog = false;
+ currentSession()->emulationHandler()->clearLog();
+ } else {
+ QMap<QString, QStringList> map;
+ QStringList text;
+ text << "text/plain";
+ map.insert(tr("Log"), text );
+ QString m_logName = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
+ if (m_logName.isEmpty() ) return;
+
+ m_recordLog->setText( tr("Stop log") );
+ m_recordingLog = true;
+ currentSession()->emulationHandler()->startLogging(m_logName);
+ }
+}
+
void MainWindow::slotSaveHistory() {
QMap<QString, QStringList> map;
QStringList text;
text << "text/plain";
map.insert(tr("History"), text );
QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
if (filename.isEmpty() ) return;
QFileInfo info(filename);
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filename);
nf.setName(info.fileName());
QFile file(filename);
file.open(IO_WriteOnly );
QTextStream str(&file );
if ( currentSession() )
currentSession()->emulationHandler()->emulation()->streamHistory(&str);
file.close();
nf.writeLink();
}
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 @@
#ifndef OPIE_MAIN_WINDOW_H
#define OPIE_MAIN_WINDOW_H
#include <qmainwindow.h>
#include <qlist.h>
+#include <qfile.h>
#include "session.h"
/**
* this is the MainWindow of the new opie console
* it's also the dispatcher between the different
* actions supported by the gui
*/
class QToolBar;
class QToolButton;
class QMenuBar;
class QAction;
class MetaFactory;
class TabWidget;
class ProfileManager;
class Profile;
class FunctionKeyboard;
class FKey;
class DocLnk;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
~MainWindow();
static QString appName() {return QString::fromLatin1("opie-console"); }
/**
* our factory to generate IOLayer and so on
*
*/
MetaFactory* factory();
/**
* A session contains a QWidget*,
* an IOLayer* and some infos for us
*/
Session* currentSession();
/**
* the session list
*/
QList<Session> sessions();
/**
*
*/
ProfileManager* manager();
TabWidget* tabWidget();
private slots:
void slotNew();
void slotConnect();
void slotDisconnect();
void slotTerminate();
void slotConfigure();
void slotClose();
void slotProfile(int);
void slotTransfer();
void slotOpenKeb(bool);
void slotOpenButtons(bool);
void slotRecordScript();
void slotSaveScript();
void slotRunScript(int);
void slotFullscreen();
void slotQuickLaunch();
void slotWrap();
void slotSessionChanged( Session* );
void slotKeyReceived(FKey, ushort, ushort, bool);
void slotSaveHistory();
+ void slotSaveLog();
/* what could these both slot do? */
void slotCopy();
void slotPaste();
/* save the currentSession() to Profiles */
void slotSaveSession();
private:
void initUI();
void populateProfiles();
void populateScripts();
void create( const Profile& );
/**
* the current session
*/
Session* m_curSession;
/**
* the session list
*/
QList<Session> m_sessions;
QList<DocLnk> m_scriptsData;
/**
* the metafactory
*/
MetaFactory* m_factory;
ProfileManager* m_manager;
TabWidget* m_consoleWindow;
QToolBar* m_tool;
QToolBar* m_icons;
QToolBar* m_keyBar;
QToolBar* m_buttonBar;
QMenuBar* m_bar;
QPopupMenu* m_console;
QPopupMenu* m_sessionsPop;
QPopupMenu* m_scriptsPop;
QPopupMenu* m_scripts;
QAction* m_connect;
QAction* m_disconnect;
QAction* m_quickLaunch;
QAction* m_terminate;
QAction* m_transfer;
QAction* m_setProfiles;
QAction* m_openKeys;
QAction* m_openButtons;
QAction* m_recordScript;
QAction* m_saveScript;
QAction* m_fullscreen;
QAction* m_wrap;
QAction* m_closewindow;
+ QAction* m_recordLog;
FunctionKeyboard *m_kb;
int m_runScript_id;
bool m_isFullscreen;
bool m_isWrapped;
+ bool m_recordingLog;
QWidget* savedParentFullscreen;
};
#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 @@
+Package: opie-console
+Files: bin/opie-console apps/Applications/opie-console.desktop pics/console/* share/opie-console/*
+Priority: optional
+Section: opie/applications
+Maintainer: Opie Team <opie@handhelds.org>
+Architecture: arm
+Version: 0.6-$SUB_VERSION
+Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs
+License: GPL
+Description: 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 @@
TEMPLATE = app
CONFIG += qt warn_on
HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
file_layer.h filetransfer.h \
metafactory.h \
session.h \
mainwindow.h \
profile.h \
profileconfig.h \
profilemanager.h \
tabwidget.h \
configdialog.h \
keytrans.h \
transferdialog.h \
profiledialogwidget.h \
profileeditordialog.h \
default.h \
iolayerbase.h \
serialconfigwidget.h irdaconfigwidget.h \
btconfigwidget.h modemconfigwidget.h \
atconfigdialog.h dialdialog.h \
procctl.h \
function_keyboard.h \
receive_layer.h filereceive.h \
script.h \
- dialer.h \
+ dialer.h logger.h \
terminalwidget.h \
emulation_handler.h TECommon.h \
TEHistory.h TEScreen.h TEWidget.h \
TEmuVt102.h TEmulation.h MyPty.h \
- consoleconfigwidget.h
+ consoleconfigwidget.h fixit.h
SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
file_layer.cpp filetransfer.cpp \
main.cpp \
metafactory.cpp \
session.cpp \
mainwindow.cpp \
profile.cpp \
profileconfig.cpp \
profilemanager.cpp \
tabwidget.cpp \
configdialog.cpp \
keytrans.cpp \
transferdialog.cpp \
profiledialogwidget.cpp \
profileeditordialog.cpp \
iolayerbase.cpp \
serialconfigwidget.cpp irdaconfigwidget.cpp \
btconfigwidget.cpp modemconfigwidget.cpp \
atconfigdialog.cpp dialdialog.cpp \
default.cpp procctl.cpp \
function_keyboard.cpp \
receive_layer.cpp filereceive.cpp \
script.cpp \
- dialer.cpp \
+ dialer.cpp logger.cpp \
terminalwidget.cpp \
emulation_handler.cpp TEHistory.cpp \
TEScreen.cpp TEWidget.cpp \
TEmuVt102.cpp TEmulation.cpp MyPty.cpp \
- consoleconfigwidget.cpp
+ consoleconfigwidget.cpp fixit.cpp
DESTDIR = $(OPIEDIR)/bin/
INTERFACES = configurebase.ui editbase.ui
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopiecore2 -lopieui2 -lutil
+LIBS += -lqpe -lopiecore2 -lopieui2
TARGET = opie-console
-DEFINES += HAVE_OPENPTY
-
+#DEFINES += HAVE_OPENPTY
+#DEFINES += EAST FSCKED_DISTRI
include ( $(OPIEDIR)/include.pro )