author | harlekin <harlekin> | 2002-10-15 22:03:01 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-15 22:03:01 (UTC) |
commit | ce953c24f809385088905ffd02f6d6187d0a4f12 (patch) (side-by-side diff) | |
tree | 19f10579ebd5870cf38940d624c97111ea8137b3 | |
parent | 676be5604cbdb3213c00775e0ff66f4e766f8dcb (diff) | |
download | opie-ce953c24f809385088905ffd02f6d6187d0a4f12.zip opie-ce953c24f809385088905ffd02f6d6187d0a4f12.tar.gz opie-ce953c24f809385088905ffd02f6d6187d0a4f12.tar.bz2 |
next isConnected try
-rw-r--r-- | noncore/apps/opie-console/MyPty.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_layer.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.h | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 2 |
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 @@ -51,17 +51,17 @@ public: */ 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); 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 @@ -45,17 +45,17 @@ extern "C" { } 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 ); 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 @@ -74,16 +74,18 @@ public: 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 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 @@ -3,16 +3,17 @@ #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(); } @@ -27,17 +28,19 @@ void IOSerial::send(const QByteArray &data) { } 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); @@ -106,16 +109,17 @@ bool IOSerial::open() { /* 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; } } @@ -189,8 +193,12 @@ void IOSerial::closeRawIO(int 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 @@ -33,16 +33,17 @@ public: 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(); @@ -57,11 +58,13 @@ protected: 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 @@ -200,17 +200,17 @@ void MainWindow::initUI() { /* 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 ); @@ -434,18 +434,18 @@ 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 ); } } } @@ -484,11 +484,11 @@ 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 @@ -46,31 +46,27 @@ QWidget* Session::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; @@ -95,11 +91,8 @@ void Session::setEmulationHandler( EmulationHandler* 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 @@ -55,18 +55,16 @@ public: */ 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; }; |