-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 47 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 12 |
4 files changed, 43 insertions, 31 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index c67c7c7..9e7f56c 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -1,48 +1,52 @@ #include <qwidget.h> #include "TEWidget.h" #include "TEmuVt102.h" #include "emulation_handler.h" EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) : QObject(0, name ) { m_teWid = new TEWidget( parent, "TerminalMain"); m_teWid->setMinimumSize(150, 70 ); 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 ); } EmulationHandler::~EmulationHandler() { delete m_teEmu; delete m_teWid; } void EmulationHandler::load( const Profile& ) { QFont font = QFont("Fixed", 12, QFont::Normal ); font.setFixedPitch(TRUE); m_teWid->setVTFont( font ); - m_teWid->setBackgroundColor(Qt::black ); + m_teWid->setBackgroundColor(Qt::gray ); } void EmulationHandler::recv( const QByteArray& ar) { + qWarning("received in EmulationHandler!"); m_teEmu->onRcvBlock(ar.data(), ar.count() ); } void EmulationHandler::recvEmulation(const char* src, int len ) { + qWarning("received from te "); QByteArray ar(len); + memcpy(ar.data(), src, sizeof(char) * len ); emit send(ar); } QWidget* EmulationHandler::widget() { return m_teWid; } diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index e8bdb2e..95a46f9 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp @@ -51,61 +51,70 @@ void ProfileManager::load() { m_list.append( prof ); } } void ProfileManager::clear() { m_list.clear(); } Profile::ValueList ProfileManager::all()const { return m_list; } /* * Our goal is to create a Session * We will load the the IOLayer and EmulationLayer * from the factory * we will generate a QWidgetStack * add a dummy widget with layout * add "Widget" to the layout * add the dummy to the stack * raise the dummy * call session->connect(= * this way we only need to reparent * in TabWidget */ Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { +/* TEST PROFILE!!! + Profile prof; + QString str = "/dev/ttyS0"; + prof.writeEntry("Device",str ); + prof.writeEntry("Baud", 115200 ); + prof.setIOLayer("serial"); + prof.setName( "test"); +*/ 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 ); 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; for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { conf.setGroup( (*it2).name() ); /* now the config stuff */ QMap<QString, QString> map = (*it2).conf(); QMap<QString, QString>::Iterator confIt; for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { conf.writeEntry( confIt.key(), confIt.data() ); } diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index 7cae0df..f4fbcf2 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp @@ -1,87 +1,90 @@ #include "io_layer.h" #include "file_layer.h" -#include "widget_layer.h" -#include "emulation_layer.h" +#include "emulation_handler.h" #include "session.h" Session::Session() { m_widget = 0l; m_layer = 0l; -// m_widLay = 0l; -// m_emLay = 0l; + m_emu = 0l; } Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) : m_name( na ), m_widget( widget ), m_layer( lay ) { // m_widLay = 0l; // m_emLay = 0l; + m_emu = 0l; } Session::~Session() { delete m_layer; -// delete m_emLay; + delete m_emu; delete m_widget; /* the widget layer should be deleted by the m_widget */ } QString Session::name()const { return m_name; } QWidgetStack* Session::widgetStack() { return m_widget; } IOLayer* Session::layer() { return m_layer; } -/*EmulationLayer* Session::emulationLayer() { - return m_emLay; +EmulationHandler* Session::emulationHandler() { + return m_emu; } +/* WidgetLayer* Session::emulationWidget() { return m_widLay; } */ void Session::connect() { -/* if ( !m_layer || !m_emLay ) + if ( !m_layer || !m_emu ) return; + qWarning("connection in session"); QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), - m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); - QObject::connect(m_emLay, SIGNAL(sndBlock(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_emLay ) + + if ( !m_layer || !m_emu ) return; QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), - m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); - QObject::disconnect(m_emLay, SIGNAL(sndBlock(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... */ - //delete m_emLay; + m_widget = wid; } void Session::setIOLayer( IOLayer* lay ) { delete m_layer; m_layer = lay; } -/* -void Session::setEmulationLayer( EmulationLayer* lay ) { - delete m_emLay; - m_emLay = lay; + +void Session::setEmulationHandler( EmulationHandler* lay ) { + delete m_emu; + m_emu = lay; } +/* void Session::setEmulationWidget( WidgetLayer* lay ) { delete m_widLay; m_widLay = lay; } -*/
\ No newline at end of file +*/ diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index 04bf257..c3f3661 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h @@ -1,74 +1,70 @@ #ifndef OPIE_SESSION_H #define OPIE_SESSION_H #include <qwidgetstack.h> class IOLayer; -class EmulationLayer; -class WidgetLayer; +class EmulationHandler; /** * This is a Session. A session contains * a QWidget pointer and a IOLayer * Imagine a session like a collection of what * is needed to show your widget in a tab ;) */ class Session { public: /** * c'tor with widget and layer * ownership get's transfered */ Session(); Session( const QString&, QWidgetStack* widget, IOLayer* ); ~Session(); /** * return the name of the session */ QString name()const; /** * return the widgetstack * this is used to be semi modal * for FileTransfer * * semi modal == SessionModal */ QWidgetStack* widgetStack(); /** * return the layer */ IOLayer* layer(); -// EmulationLayer* emulationLayer(); - WidgetLayer* emulationWidget(); + 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 setEmulationLayer( EmulationLayer* lay ); -// void setEmulationWidget( WidgetLayer* lay ); + void setEmulationHandler( EmulationHandler* lay ); void setIOLayer( IOLayer* ); void setName( const QString& ); private: QString m_name; QWidgetStack* m_widget; IOLayer* m_layer; -// EmulationLayer* m_emLay; -// WidgetLayer* m_widLay; + EmulationHandler* m_emu; }; #endif |