summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-console/BUGS9
-rw-r--r--noncore/apps/opie-console/MyPty.cpp23
-rw-r--r--noncore/apps/opie-console/MyPty.h2
-rw-r--r--noncore/apps/opie-console/io_layer.h14
-rw-r--r--noncore/apps/opie-console/io_serial.cpp7
-rw-r--r--noncore/apps/opie-console/io_serial.h4
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp10
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp15
-rw-r--r--noncore/apps/opie-console/session.cpp6
-rw-r--r--noncore/apps/opie-console/session.h1
-rw-r--r--noncore/apps/opie-console/tabwidget.cpp1
11 files changed, 72 insertions, 20 deletions
diff --git a/noncore/apps/opie-console/BUGS b/noncore/apps/opie-console/BUGS
new file mode 100644
index 0000000..ffaceef
--- a/dev/null
+++ b/noncore/apps/opie-console/BUGS
@@ -0,0 +1,9 @@
+Ok we all know we write perfect code
+but sometimes the compiler produces bad code
+and we need to work around some compiler bugs!! -zecke
+
+MyPty is broken in some ways
+ if you do connect/disconnect/connect sh will be executed in the
+ process of opie-console.... funny aye?
+
+OTabWidget seems to give us problems too
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index b6ae1d9..565d03f 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -112,20 +112,23 @@ void MyPty::donePty()
int status = 0;
::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()
{
return m_ttynam;
}
@@ -180,20 +183,21 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int)
}
execl(cmd, cmd, 0);
donePty();
exit(-1);
}
// parent - continue as a widget
- QSocketNotifier* sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this);
+ delete m_sn_r;
+ m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this);
delete m_sn_e;
m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this);
- connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
+ connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error()));
return 0;
}
int MyPty::openPty()
{
// This is code from the Qt DumbTerminal example
@@ -216,29 +220,30 @@ int MyPty::openPty()
ptyfd = -1;
}
}
}
}
#endif
if ( ptyfd < 0 ) {
- qApp->exit(1);
+// qApp->exit(1);
return -1;
}
return ptyfd;
}
/*!
Create an instance.
*/
MyPty::MyPty(const Profile&) : m_cpid(0)
{
m_sn_e = 0l;
+ m_sn_r = 0l;
m_fd = openPty();
ProcCtl* ctl = ProcCtl::self();
}
/*!
Destructor.
Note that the related client program is not killed
(yet) when a instance is deleted.
@@ -249,21 +254,25 @@ MyPty::~MyPty()
}
QString MyPty::identifier()const {
return QString::fromLatin1("term");
}
QString MyPty::name()const{
return identifier();
}
bool MyPty::open() {
+ if (m_fd < 0)
+ m_fd = openPty();
+
start();
return true;
}
void MyPty::close() {
donePty();
+ m_fd = openPty();
}
void MyPty::reload( const Profile& ) {
}
/*! sends len bytes through the line */
void MyPty::send(const QByteArray& ar)
{
#ifdef VERBOSE_DEBUG
@@ -281,17 +290,16 @@ void MyPty::send(const QByteArray& ar)
void MyPty::readPty()
{
QByteArray buf(4096);
int len = ::read( m_fd, buf.data(), 4096 );
if (len == -1 || len == 0) {
donePty();
- delete sender();
return;
}
if (len < 0)
return;
buf.resize(len);
@@ -301,9 +309,16 @@ void MyPty::readPty()
// verbose debug
printf("read bytes:\n");
for (uint i = 0; i < buf.count(); i++)
printf("%c", buf[i]);
printf("\n");
#endif
}
+QBitArray MyPty::supports()const {
+ QBitArray ar(3);
+ ar[0] = 1;
+ ar[1] = 0;
+ ar[2] = 0;
+ return ar;
+}
diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h
index 3166fa0..ad271df 100644
--- a/noncore/apps/opie-console/MyPty.h
+++ b/noncore/apps/opie-console/MyPty.h
@@ -36,16 +36,17 @@ public:
MyPty(const Profile&);
~MyPty();
QString identifier()const;
QString name()const;
+ QBitArray supports()const;
public slots:
/*!
having a `run' separate from the constructor allows to make
the necessary connections to the signals and slots of the
instance before starting the execution of the client.
*/
void start();
@@ -87,11 +88,12 @@ private:
private:
char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx"
char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..."
int m_fd;
int m_cpid;
QSocketNotifier* m_sn_e;
+ QSocketNotifier* m_sn_r;
};
#endif
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h
index 5f2fa3c..4977e94 100644
--- a/noncore/apps/opie-console/io_layer.h
+++ b/noncore/apps/opie-console/io_layer.h
@@ -1,12 +1,15 @@
#ifndef OPIE_IO_LAYER_H
#define OPIE_IO_LAYER_H
+#include <qbitarray.h>
#include <qobject.h>
+
+
#include <qpe/config.h>
#include "profile.h"
/**
* This is the base class for IO Layers
* It will used to sent and recv data( QByteArray )
* it
@@ -18,16 +21,21 @@ public:
NoError = -1,
Refuse = 0,
CouldNotOpen =1,
ClosedUnexpected =2,
ClosedError =3,
Terminate = 4
/* add more errors here */
};
+ enum Feature {
+ AutoConnect = 0,
+ TransferFile =1,
+ Close =2
+ };
/**
* a small c'tor
*/
IOLayer();
/**
* create an IOLayer instance from a config file
* the currently set group stores the profile/session
@@ -60,30 +68,36 @@ public:
virtual int rawIO()const;
/**
* will close the rawIO stuff
* and will listen to it's data again...
*/
virtual void closeRawIO(int);
+ /**
+ * What does the IOLayer support?
+ * Bits are related to features
+ */
+ virtual QBitArray supports()const = 0;
signals:
/**
* received input as QCString
*/
virtual void received( const QByteArray& );
/**
* an error occured
* int for the error number
* and QString for a text
*/
virtual void error( int, const QString& );
+ virtual void closed();
public slots:
/**
* send a QCString to the device
*/
virtual void send( const QByteArray& ) = 0;
/**
* bool open
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index a4a6f0b..c10d5a8 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -182,8 +182,15 @@ int IOSerial::rawIO()const {
void IOSerial::closeRawIO(int fd) {
if (m_read )
connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
if (m_error )
connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
::close( fd );
}
+QBitArray IOSerial::supports()const {
+ QBitArray ar(3);
+ ar[0] = ar[2] = 0;
+ ar[1] = 1;
+
+ return ar;
+}
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h
index facbbc1..b1d1be1 100644
--- a/noncore/apps/opie-console/io_serial.h
+++ b/noncore/apps/opie-console/io_serial.h
@@ -32,19 +32,21 @@ public:
IOSerial(const Profile &);
~IOSerial();
QString identifier() const;
QString name() const;
int rawIO()const;
void closeRawIO(int fd );
-signals:
+ QBitArray supports()const;
+/*signals:
void received(const QByteArray &);
void error(int, const QString &);
+*/
public slots:
void send(const QByteArray &);
bool open();
void close();
void reload(const Profile &);
protected:
int baud(int baud) const;
protected slots:
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 94c99bc..29dbcf3 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -355,21 +355,22 @@ void MainWindow::slotConfigure() {
* remove it from the list
* delete it
* and set the currentSession()
*/
void MainWindow::slotClose() {
if (!currentSession() )
return;
+ Session* ses = currentSession();
+ qWarning("removing! currentSession %s", currentSession()->name().latin1() );
tabWidget()->remove( currentSession() );
/*it's autodelete */
- m_sessions.remove( m_curSession );
- m_curSession = m_sessions.first();
- tabWidget()->setCurrent( m_curSession );
+ m_sessions.remove( ses );
+ qWarning("after remove!!");
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 );
@@ -390,17 +391,17 @@ void MainWindow::slotProfile( int id) {
}
void MainWindow::create( const Profile& prof ) {
Session *ses = manager()->fromProfile( prof, tabWidget() );
if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
{
QMessageBox::warning(this,
QObject::tr("Session failed"),
- QObject::tr("Cannot open session: Not all components were found."));
+ QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
//if(ses) delete ses;
return;
}
m_sessions.append( ses );
tabWidget()->add( ses );
m_curSession = ses;
@@ -428,16 +429,17 @@ void MainWindow::slotTransfer()
void MainWindow::slotOpenKeb(bool state) {
if (state) m_keyBar->show();
else m_keyBar->hide();
}
void MainWindow::slotSessionChanged( Session* ses ) {
+ qWarning("changed!");
if ( ses ) {
m_curSession = ses;
if ( m_curSession->isConnected() ) {
m_connect->setEnabled( false );
m_disconnect->setEnabled( true );
} else {
m_connect->setEnabled( true );
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index e5aedb6..7c15560 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -1,12 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <qfile.h>
+#include <qhbox.h>
#include <qlayout.h>
#include <qwidgetstack.h>
#include <qpe/config.h>
#include "emulation_handler.h"
#include "widget_layer.h"
#include "emulation_widget.h"
@@ -80,29 +81,21 @@ Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) {
Session* session = new Session();
session->setName( prof.name() );
/* translate the internal name to the external */
session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) ,
prof) );
QWidgetStack *stack = new QWidgetStack( parent );
session->setWidgetStack( stack );
- QWidget* dummy = new QWidget( stack );
- QHBoxLayout* lay = new QHBoxLayout( dummy );
- stack->addWidget( dummy, 0 );
- stack->raiseWidget( 0 );
+ QWidget* dummy = new QHBox( stack );
+ stack->raiseWidget( dummy );
+
EmulationHandler* handler = new EmulationHandler(prof,dummy );
session->setEmulationHandler( handler );
- lay->addWidget( handler->widget() );
-// WidgetLayer* wid = new EmulationWidget( prof, dummy );
-// lay->addWidget( wid );
-
-// session->setEmulationWidget( wid );
-// session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ),
-// wid ) );
session->connect();
return session;
}
void ProfileManager::save( ) {
QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) );
ProfileConfig conf("opie-console-profiles");
Profile::ValueList::Iterator it2;
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index e53dbc4..aad100d 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -31,16 +31,22 @@ QWidgetStack* Session::widgetStack() {
return m_widget;
}
IOLayer* Session::layer() {
return m_layer;
}
EmulationHandler* Session::emulationHandler() {
return m_emu;
}
+QWidget* Session::widget() {
+ if (!m_emu )
+ return 0l;
+
+ return m_emu->widget();
+}
/*
WidgetLayer* Session::emulationWidget() {
return m_widLay;
}
*/
void Session::connect() {
if ( !m_layer || !m_emu )
return;
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h
index a1121d3..ff92df3 100644
--- a/noncore/apps/opie-console/session.h
+++ b/noncore/apps/opie-console/session.h
@@ -29,16 +29,17 @@ public:
/**
* return the widgetstack
* this is used to be semi modal
* for FileTransfer
*
* semi modal == SessionModal
*/
QWidgetStack* widgetStack();
+ QWidget* widget();
/**
* return the layer
*/
IOLayer* layer();
EmulationHandler* emulationHandler();
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp
index 8a691f9..419f8ac 100644
--- a/noncore/apps/opie-console/tabwidget.cpp
+++ b/noncore/apps/opie-console/tabwidget.cpp
@@ -6,16 +6,17 @@ TabWidget::TabWidget( QWidget* parent, const char* name )
connect(this, SIGNAL( currentChanged(QWidget*) ),
this, SLOT( slotCurChanged(QWidget*) ) );
}
TabWidget::~TabWidget() {
}
void TabWidget::add( Session* ses ) {
+ qWarning("session ses " + ses->name() );
if ( !ses->widgetStack() ) return;
//reparent( ses->widgetStack(), QPoint() );
addTab( ses->widgetStack(), "console/konsole", ses->name() );
//addTab( ses->widgetStack(), ses->name() );
m_map.insert( ses->widgetStack(), ses );
}
void TabWidget::remove( Session* ses ) {