summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore 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
@@ -114,16 +114,19 @@ void MyPty::donePty()
::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()
{
@@ -182,16 +185,17 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int)
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()
@@ -218,25 +222,26 @@ int MyPty::openPty()
}
}
}
#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.
@@ -251,17 +256,21 @@ 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)
@@ -283,13 +292,12 @@ 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;
@@ -303,7 +311,14 @@ void MyPty::readPty()
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
@@ -38,12 +38,13 @@ public:
~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.
@@ -89,9 +90,10 @@ 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,10 +1,13 @@
#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
@@ -20,12 +23,17 @@ public:
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();
/**
@@ -62,12 +70,17 @@ public:
/**
* 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& );
@@ -76,12 +89,13 @@ signals:
* 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;
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
@@ -184,6 +184,13 @@ void IOSerial::closeRawIO(int fd) {
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
@@ -34,15 +34,17 @@ public:
~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:
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
@@ -357,17 +357,18 @@ void MainWindow::slotConfigure() {
* 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 );
@@ -392,13 +393,13 @@ 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 );
@@ -430,12 +431,13 @@ 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 );
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,10 +1,11 @@
#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"
@@ -82,25 +83,17 @@ Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) {
/* 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" ) );
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
@@ -33,12 +33,18 @@ QWidgetStack* Session::widgetStack() {
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() {
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
@@ -31,12 +31,13 @@ public:
* this is used to be semi modal
* for FileTransfer
*
* semi modal == SessionModal
*/
QWidgetStack* widgetStack();
+ QWidget* widget();
/**
* return the layer
*/
IOLayer* layer();
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
@@ -8,12 +8,13 @@ TabWidget::TabWidget( QWidget* parent, const char* name )
}
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 );
}