Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

session.cpp

Go to the documentation of this file.
00001 /* -------------------------------------------------------------------------- */
00002 /*                                                                            */
00003 /* Ported Konsole to Qt/Embedded                                              */
00004 /*                                                                            */
00005 /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com>                  */
00006 /*                                                                            */
00007 /* -------------------------------------------------------------------------- */
00008 #include "session.h"
00009 // #include <kdebug.h>
00010 
00011 #include <stdlib.h>
00012 
00013 #define HERE fprintf(stderr,"%s(%d): here\n",__FILE__,__LINE__)
00014 
00025 TESession::TESession(QMainWindow* main, TEWidget* _te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args)
00026 {
00027   te = _te;
00028   term = _term;
00029 
00030   // sh = new TEPty();
00031   sh = new MyPty();
00032   em = new TEmuVt102(te);
00033 
00034   sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary
00035   QObject::connect( sh,SIGNAL(block_in(const char*,int)),
00036                     em,SLOT(onRcvBlock(const char*,int)) );
00037   QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)),
00038                     sh,SLOT(setSize(int,int)));
00039 
00040   // 'main' should do those connects itself, somehow.
00041   // These aren't KTMW's slots, but konsole's.(David)
00042 
00043 /*
00044   QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)),
00045                     main,SLOT(notifySize(int,int)));
00046 */
00047   QObject::connect( em,SIGNAL(sndBlock(const char*,int)),
00048                     sh,SLOT(send_bytes(const char*,int)) );
00049   QObject::connect( em,SIGNAL(changeColumns(int)),
00050                     main,SLOT(changeColumns(int)) );
00051 
00052   
00053 
00054   QObject::connect( em,SIGNAL(changeTitle(int,const QString&)),
00055                     this,SLOT(changeTitle(int,const QString&)) );
00056 
00057   QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) );
00058 }
00059 
00060 
00061 
00062 void TESession::run()
00063 {
00064   //kdDebug() << "Running the session!" << pgm << "\n";
00065   sh->run(pgm,args,term.data(),FALSE);
00066 }
00067 
00068 void TESession::kill(int ) // signal)
00069 {
00070 //  sh->kill(signal);
00071 }
00072 
00073 TESession::~TESession()
00074 {
00075  QObject::disconnect( sh, SIGNAL( done(int) ),
00076                       this, SLOT( done(int) ) );
00077   delete em;
00078   delete sh;
00079 }
00080 
00081 void TESession::setConnect(bool c)
00082 {
00083   em->setConnect(c);
00084 }
00085 
00086 void TESession::done(int status)
00087 {
00088   emit done(te,status);
00089 }
00090 
00091 void TESession::terminate()
00092 {
00093   delete this;
00094 }
00095 
00096 TEmulation* TESession::getEmulation()
00097 {
00098   return em;
00099 }
00100 
00101 // following interfaces might be misplaced ///
00102 
00103 int TESession::schemaNo()
00104 {
00105   return schema_no;
00106 }
00107 
00108 int TESession::keymap()
00109 {
00110   return keymap_no;
00111 }
00112 
00113 int TESession::fontNo()
00114 {
00115   return font_no;
00116 }
00117 
00118 const char* TESession::emuName()
00119 {
00120   return term.data();
00121 }
00122 
00123 void TESession::setSchemaNo(int sn)
00124 {
00125   schema_no = sn;
00126 }
00127 
00128 void TESession::setKeymapNo(int kn)
00129 {
00130   keymap_no = kn;
00131   em->setKeytrans(kn);
00132 }
00133 
00134 void TESession::setFontNo(int fn)
00135 {
00136   font_no = fn;
00137 }
00138 
00139 void TESession::changeTitle(int, const QString& title)
00140 {
00141   this->title = title;
00142   emit changeTitle(te, title);
00143 }
00144 
00145 const QString& TESession::Title()
00146 {
00147   return title;
00148 }
00149 
00150 void TESession::setHistory(bool on)
00151 {
00152   em->setHistory( on );
00153 }
00154 
00155 bool TESession::history()
00156 {
00157   return em->history();
00158 }
00159 
00160 // #include "session.moc"

Generated on Sat Nov 5 16:15:27 2005 for OPIE by  doxygen 1.4.2