summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.h2
-rw-r--r--noncore/apps/opie-console/default.cpp2
-rw-r--r--noncore/apps/opie-console/io_layer.h2
-rw-r--r--noncore/apps/opie-console/io_serial.cpp8
-rw-r--r--noncore/apps/opie-console/io_serial.h3
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp8
-rw-r--r--noncore/apps/opie-console/session.cpp7
-rw-r--r--noncore/apps/opie-console/session.h2
8 files changed, 19 insertions, 15 deletions
diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h
index ad271df..81abad5 100644
--- a/noncore/apps/opie-console/MyPty.h
+++ b/noncore/apps/opie-console/MyPty.h
@@ -35,49 +35,49 @@ class MyPty : public IOLayer
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();
int run(const char* pgm, QStrList & args , const char* term, int addutmp);
bool open();
void close();
void reload( const Profile& );
void setSize(int lines, int columns);
void error();
-
+ bool isConnected() { return true; };
signals:
/*!
emitted when the client program terminates.
\param status the wait(2) status code of the terminated client program.
*/
void done(int status);
/*!
emitted when a new block of data comes in.
\param s - the data
\param len - the length of the block
*/
void received(const QByteArray&);
public slots:
void send(const QByteArray& );
private:
const char* deviceName();
protected slots:
void readPty();
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
index 64c9542..8b905e1 100644
--- a/noncore/apps/opie-console/default.cpp
+++ b/noncore/apps/opie-console/default.cpp
@@ -29,49 +29,49 @@ extern "C" {
ReceiveLayer* newSZReceive(IOLayer* lay) {
return new FileReceive( FileReceive::SZ, lay );
}
ReceiveLayer* newSYReceive(IOLayer* lay) {
return new FileReceive( FileReceive::SY, lay );
}
ReceiveLayer* newSXReceive(IOLayer* lay) {
return new FileReceive(FileReceive::SX, lay );
}
// Layer stuff
IOLayer* newSerialLayer( const Profile& prof) {
return new IOSerial( prof );
}
IOLayer* newBTLayer( const Profile& prof ) {
return new IOBt( prof );
}
IOLayer* newIrDaLayer( const Profile& prof ) {
return new IOIrda( prof );
}
IOLayer* newModemLayer( const Profile& prof ) {
return new IOModem( prof );
}
IOLayer* newConsole( const Profile& prof ) {
- return new MyPty(prof );
+ return new MyPty( prof );
}
// Connection Widgets
ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) {
return new SerialConfigWidget( str, wid );
}
ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) {
return new IrdaConfigWidget( str, wid );
}
ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) {
return new ModemConfigWidget(str, wid );
}
ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) {
return new BTConfigWidget(str, wid );
}
ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) {
return 0l;
}
// Terminal Widget(s)
ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) {
return new TerminalWidget(na, wid,0 );
}
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h
index 4977e94..d5f7eab 100644
--- a/noncore/apps/opie-console/io_layer.h
+++ b/noncore/apps/opie-console/io_layer.h
@@ -58,48 +58,50 @@ public:
*/
virtual QString name() const = 0;
/**
* a file descriptor which opens
* the device for io but does not
* do any ioctling on it...
* and it'll stop listening to the before opened
* device
*/
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;
+ virtual bool isConnected() = 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
*/
virtual bool open() = 0;
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index c10d5a8..b89a53b 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -1,59 +1,62 @@
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <unistd.h>
#include "io_serial.h"
IOSerial::IOSerial(const Profile &config) : IOLayer(config) {
m_read = 0l;
m_error = 0l;
m_fd = 0;
+ m_connected = false;
reload(config);
}
IOSerial::~IOSerial() {
if (m_fd) {
close();
}
}
void IOSerial::send(const QByteArray &data) {
if (m_fd) {
write(m_fd, data.data(), data.size());
} else {
emit error(Refuse, tr("Not connected"));
}
}
void IOSerial::close() {
if (m_fd) {
delete m_read;
delete m_error;
::close(m_fd);
m_fd = 0;
+ m_connected = false;
} else {
+ m_connected = false;
emit error(Refuse, tr("Not connected"));
}
}
bool IOSerial::open() {
if (!m_fd) {
struct termios tty;
m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (m_fd < 0) {
emit error(CouldNotOpen, strerror(errno));
return FALSE;
}
tcgetattr(m_fd, &tty);
/* Baud rate */
int speed = baud(m_baud);
if (speed == -1) {
emit error(Refuse, tr("Invalid baud rate"));
}
cfsetospeed(&tty, speed);
cfsetispeed(&tty, speed);
/* Take care of Space / Mark parity */
if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) {
@@ -90,48 +93,49 @@ bool IOSerial::open() {
tty.c_iflag |= IXON | IXOFF;
else
tty.c_iflag &= ~(IXON|IXOFF|IXANY);
if (m_flow & FlowHW)
tty.c_cflag |= CRTSCTS;
else
tty.c_cflag &= ~CRTSCTS;
/* Parity */
tty.c_cflag &= ~(PARENB | PARODD);
if (m_parity & ParityEven)
tty.c_cflag |= PARENB;
else if (m_parity & ParityOdd)
tty.c_cflag |= (PARENB | PARODD);
/* Set the changes */
tcsetattr(m_fd, TCSANOW, &tty);
/* Notifications on read & errors */
m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this);
connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
+ m_connected = false;
return TRUE;
} else {
emit error(Refuse, tr("Device is already connected"));
m_fd = 0;
return FALSE;
}
}
void IOSerial::reload(const Profile &config) {
m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE);
m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY);
m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS);
m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS);
m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW);
}
int IOSerial::baud(int baud) const {
switch (baud) {
case 300: return B300; break;
case 600: return B600; break;
case 1200: return B1200; break;
case 2400: return B2400; break;
@@ -173,24 +177,28 @@ int IOSerial::rawIO()const {
if (m_read )
disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
if (m_error )
disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
int fd = ::open(m_device, O_RDWR );
return fd;
};
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;
}
+
+bool IOSerial::isConnected() {
+ return m_connected;
+}
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h
index b1d1be1..7a1ea1d 100644
--- a/noncore/apps/opie-console/io_serial.h
+++ b/noncore/apps/opie-console/io_serial.h
@@ -17,51 +17,54 @@
class IOSerial : public IOLayer {
Q_OBJECT
public:
enum Parity {
ParityNone = 0,
ParityEven,
ParityOdd,
ParitySpace,
ParityMark
};
enum Flow {
FlowHW = 0x01,
FlowSW = 0x02
};
IOSerial(const Profile &);
~IOSerial();
QString identifier() const;
QString name() const;
int rawIO()const;
void closeRawIO(int fd );
QBitArray supports()const;
+ bool isConnected();
/*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:
void dataArrived();
void errorOccured();
protected:
QSocketNotifier *m_read;
QSocketNotifier *m_error;
QString m_device;
int m_baud;
int m_parity;
int m_dbits;
int m_sbits;
int m_flow;
int m_fd;
+ bool m_connected;
+
};
#endif /* OPIE_IO_SERIAL */
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index d3b6c8a..4326609 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -184,49 +184,49 @@ void MainWindow::initUI() {
this, SLOT(slotOpenKeb(bool)));
m_openKeys->addTo(m_icons);
/* insert the submenu */
m_console->insertItem(tr("New from Profile"), m_sessionsPop,
-1, 0);
/* insert the connection menu */
m_bar->insertItem( tr("Connection"), m_console );
/* the scripts menu */
m_bar->insertItem( tr("Scripts"), m_scripts );
/* the settings menu */
m_bar->insertItem( tr("Settings"), m_settings );
/* and the keyboard */
m_keyBar = new QToolBar(this);
addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
m_keyBar->setHorizontalStretchable( TRUE );
m_keyBar->hide();
m_kb = new FunctionKeyboard(m_keyBar);
- connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)),
+ connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)),
this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool)));
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_runScript->setEnabled( false );
m_fullscreen->setEnabled( false );
m_closewindow->setEnabled( false );
/*
* connect to the menu activation
*/
connect( m_sessionsPop, SIGNAL(activated( int ) ),
this, SLOT(slotProfile( int ) ) );
m_consoleWindow = new TabWidget( this, "blah");
connect(m_consoleWindow, SIGNAL(activated(Session*) ),
this, SLOT(slotSessionChanged(Session*) ) );
setCentralWidget( m_consoleWindow );
@@ -418,77 +418,77 @@ void MainWindow::create( const Profile& prof ) {
m_fullscreen->setEnabled( true );
m_closewindow->setEnabled( true );
}
void MainWindow::slotTransfer()
{
if ( currentSession() ) {
TransferDialog dlg(this);
dlg.showMaximized();
dlg.exec();
}
}
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() ) {
+ qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
+ if ( m_curSession->layer()->isConnected() ) {
m_connect->setEnabled( false );
m_disconnect->setEnabled( true );
} else {
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
}
}
}
void MainWindow::slotFullscreen() {
if ( m_isFullscreen ) {
( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false );
( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken );
setCentralWidget( m_consoleWindow );
( m_curSession->widgetStack() )->show();
m_fullscreen->setText( tr("Full screen") );
} else {
( 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());
( m_curSession->widgetStack() )->setFocus();
( m_curSession->widgetStack() )->show();
//QPushButton *cornerButton = new QPushButton( );
//cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
//connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
// need teh scrollbar
// ( m_curSession->widgetStack() )->setCornerWidget( cornerButton );
m_fullscreen->setText( tr("Stop full screen") );
}
m_isFullscreen = !m_isFullscreen;
}
void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) {
qWarning("received key event! relay to TE widget");
if ( m_curSession ) {
QKeyEvent ke(QEvent::KeyPress, q, u, 0);
ke.ignore();
// where should i send this event? doesnt work sending it here
- QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke);
+ QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke);
}
}
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index aad100d..2ce6872 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -30,76 +30,69 @@ QString Session::name()const {
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;
- m_connected = true;
-
QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ),
m_emu, SLOT(recv(const QByteArray&) ) );
QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ),
m_layer, SLOT(send(const QByteArray&) ) );
}
void Session::disconnect() {
if ( !m_layer || !m_emu )
return;
- m_connected = false;
-
QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ),
m_emu, SLOT(recv(const QByteArray&) ) );
QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ),
m_layer, SLOT(send(const QByteArray&) ) );
}
void Session::setName( const QString& na){
m_name = na;
}
void Session::setWidgetStack( QWidgetStack* wid ) {
delete m_emu;
m_emu = 0l;
delete m_widget;
/* the EmulationLayer was destroyed... */
m_widget = wid;
}
void Session::setIOLayer( IOLayer* lay ) {
delete m_layer;
m_layer = lay;
}
void Session::setEmulationHandler( EmulationHandler* lay ) {
delete m_emu;
m_emu = lay;
}
/*
void Session::setEmulationWidget( WidgetLayer* lay ) {
delete m_widLay;
m_widLay = lay;
}
*/
-bool Session::isConnected() {
- return m_connected;
-}
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h
index ff92df3..83b2046 100644
--- a/noncore/apps/opie-console/session.h
+++ b/noncore/apps/opie-console/session.h
@@ -39,36 +39,34 @@ public:
/**
* return the layer
*/
IOLayer* layer();
EmulationHandler* emulationHandler();
/*
* connects the data flow from
* the IOLayer to the EmulationLayer
*/
void connect();
/*
* disconnect the dataflow
* this will be done for ft
*/
void disconnect();
void setWidgetStack( QWidgetStack* widget );
void setEmulationHandler( EmulationHandler* lay );
void setIOLayer( IOLayer* );
void setName( const QString& );
- bool isConnected();
-
private:
QString m_name;
QWidgetStack* m_widget;
IOLayer* m_layer;
EmulationHandler* m_emu;
bool m_connected;
};
#endif