summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp6
-rw-r--r--noncore/apps/opie-console/configdialog.cpp1
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp6
-rw-r--r--noncore/apps/opie-console/filereceive.cpp2
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp6
-rw-r--r--noncore/apps/opie-console/io_bt.cpp1
-rw-r--r--noncore/apps/opie-console/io_irda.cpp2
-rw-r--r--noncore/apps/opie-console/io_serial.cpp8
-rw-r--r--noncore/apps/opie-console/iolayerbase.cpp3
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp5
-rw-r--r--noncore/apps/opie-console/metafactory.cpp1
-rw-r--r--noncore/apps/opie-console/procctl.cpp1
-rw-r--r--noncore/apps/opie-console/profile.cpp2
-rw-r--r--noncore/apps/opie-console/profileconfig.cpp1
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp7
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp4
-rw-r--r--noncore/apps/opie-console/session.cpp1
-rw-r--r--noncore/apps/opie-console/tabwidget.cpp1
18 files changed, 3 insertions, 55 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index ae01392..b6ae1d9 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -21,295 +21,289 @@
*/
/*! \file
*/
/*! \class TEPty
\brief Ptys provide a pseudo terminal connection to a program.
Although closely related to pipes, these pseudo terminal connections have
some ability, that makes it nessesary to uses them. Most importent, they
know about changing screen sizes and UNIX job control.
Within the terminal emulation framework, this class represents the
host side of the terminal together with the connecting serial line.
One can create many instances of this class within a program.
As a side effect of using this class, a signal(2) handler is
installed on SIGCHLD.
\par FIXME
[NOTE: much of the technical stuff below will be replaced by forkpty.]
publish the SIGCHLD signal if not related to an instance.
clearify TEPty::done vs. TEPty::~TEPty semantics.
check if pty is restartable via run after done.
\par Pseudo terminals
Pseudo terminals are a unique feature of UNIX, and always come in form of
pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
other by the operating system. One may think of them as two serial devices
linked by a null-modem cable. Being based on devices the number of
simultanous instances of this class is (globally) limited by the number of
those device pairs, which is 256.
Another technic are UNIX 98 PTY's. These are supported also, and prefered
over the (obsolete) predecessor.
There's a sinister ioctl(2), signal(2) and job control stuff
nessesary to make everything work as it should.
*/
#include <qapplication.h>
#include <qsocketnotifier.h>
#include <qstring.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#ifdef HAVE_OPENPTY
#include <pty.h>
#endif
#include "procctl.h"
#include "MyPty.h"
#undef VERBOSE_DEBUG
/* -------------------------------------------------------------------------- */
/*!
Informs the client program about the
actual size of the window.
*/
void MyPty::setSize(int lines, int columns)
{
struct winsize wsize;
wsize.ws_row = (unsigned short)lines;
wsize.ws_col = (unsigned short)columns;
if(m_fd < 0) return;
ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
}
void MyPty::donePty()
{
// This is code from the Qt DumbTerminal example
int status = 0;
::close(m_fd);
if (m_cpid) {
- qWarning("killing!!!");
kill(m_cpid, SIGHUP);
//waitpid(m_cpid, &status, 0);
delete m_sn_e;
m_sn_e = 0l;
}
m_cpid = 0;
// emit done(status);
}
const char* MyPty::deviceName()
{
return m_ttynam;
}
void MyPty::error()
{
- qWarning("error");
// This is code from the Qt DumbTerminal example
donePty();
}
void MyPty::start() {
char* cmd = "/bin/sh";
QStrList lis;
int r =run(cmd, lis, 0, 0);
r = r;
}
/*!
start the client program.
*/
int MyPty::run(const char* cmd, QStrList &, const char*, int)
{
// This is code from the Qt DumbTerminal example
m_cpid = fork();
if ( !m_cpid ) {
// child - exec shell on tty
for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
int ttyfd = ::open(m_ttynam, O_RDWR);
dup2(ttyfd, STDIN_FILENO);
dup2(ttyfd, STDOUT_FILENO);
dup2(ttyfd, STDERR_FILENO);
// should be done with tty, so close it
::close(ttyfd);
static struct termios ttmode;
if ( setsid() < 0 )
perror( "failed to set process group" );
#if defined (TIOCSCTTY)
// grabbed from APUE by Stevens
ioctl(STDIN_FILENO, TIOCSCTTY, 0);
#endif
tcgetattr( STDIN_FILENO, &ttmode );
ttmode.c_cc[VINTR] = 3;
ttmode.c_cc[VERASE] = 8;
tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
setenv("TERM","vt100",1);
setenv("COLORTERM","0",1);
if (getuid() == 0) {
char msg[] = "WARNING: You are running this shell as root!\n";
write(ttyfd, msg, sizeof(msg));
}
execl(cmd, cmd, 0);
donePty();
exit(-1);
}
// parent - continue as a widget
QSocketNotifier* 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_e,SIGNAL(activated(int)),this,SLOT(error()));
return 0;
}
int MyPty::openPty()
{
// This is code from the Qt DumbTerminal example
int ptyfd = -1;
#ifdef HAVE_OPENPTY
int ttyfd;
if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) )
ptyfd = -1;
else
close(ttyfd); // we open the ttynam ourselves.
#else
for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) {
for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) {
sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1);
sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1);
if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) {
if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) {
::close(ptyfd);
ptyfd = -1;
}
}
}
}
#endif
if ( ptyfd < 0 ) {
qApp->exit(1);
return -1;
}
return ptyfd;
}
/*!
Create an instance.
*/
MyPty::MyPty(const Profile&) : m_cpid(0)
{
m_sn_e = 0l;
m_fd = openPty();
ProcCtl* ctl = ProcCtl::self();
}
/*!
Destructor.
Note that the related client program is not killed
(yet) when a instance is deleted.
*/
MyPty::~MyPty()
{
donePty();
}
QString MyPty::identifier()const {
return QString::fromLatin1("term");
}
QString MyPty::name()const{
return identifier();
}
bool MyPty::open() {
start();
return true;
}
void MyPty::close() {
donePty();
}
void MyPty::reload( const Profile& ) {
}
/*! sends len bytes through the line */
void MyPty::send(const QByteArray& ar)
{
- qWarning("sending!");
#ifdef VERBOSE_DEBUG
// verbose debug
printf("sending bytes:\n");
for (uint i = 0; i < ar.count(); i++)
printf("%c", ar[i]);
printf("\n");
#endif
::write(m_fd, ar.data(), ar.count());
}
/*! indicates that a block of data is received */
void MyPty::readPty()
{
- qWarning("read");
QByteArray buf(4096);
int len = ::read( m_fd, buf.data(), 4096 );
if (len == -1 || len == 0) {
- qWarning("donePty!!! now!");
donePty();
- qWarning("return %s", sender()->className() );
delete sender();
return;
}
if (len < 0)
return;
buf.resize(len);
emit received(buf);
#ifdef VERBOSE_DEBUG
// verbose debug
printf("read bytes:\n");
for (uint i = 0; i < buf.count(); i++)
printf("%c", buf[i]);
printf("\n");
#endif
}
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp
index 8745305..0bc6588 100644
--- a/noncore/apps/opie-console/configdialog.cpp
+++ b/noncore/apps/opie-console/configdialog.cpp
@@ -1,115 +1,114 @@
#include <qdialog.h>
#include <qlistview.h>
#include "profile.h"
#include "configdialog.h"
#include "metafactory.h"
#include "profileeditordialog.h"
class ConfigListItem : public QListViewItem {
public:
ConfigListItem( QListView* item, const Profile& );
~ConfigListItem();
Profile profile()const;
private:
Profile m_prof;
};
ConfigListItem::ConfigListItem( QListView* item, const Profile& prof )
: QListViewItem( item ), m_prof( prof )
{
setText(0, prof.name() );
}
ConfigListItem::~ConfigListItem() {
}
Profile ConfigListItem::profile()const {
return m_prof;
}
/* Dialog */
ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa,
QWidget* parent )
: ConfigureBase( parent, 0, TRUE ), m_fact( fa )
{
//init();
{
Profile::ValueList::ConstIterator it;
for (it = lis.begin(); it != lis.end(); ++it ) {
new ConfigListItem( lstView, (*it) );
}
}
}
ConfigDialog::~ConfigDialog() {
}
Profile::ValueList ConfigDialog::list()const {
/* iterate over the list */
Profile::ValueList lst;
QListViewItemIterator it(lstView);
for ( ; it.current(); ++it ) {
ConfigListItem* item = (ConfigListItem*)it.current();
lst.append( item->profile() );
}
return lst;
}
/* our slots */
void ConfigDialog::slotRemove() {
ConfigListItem* item = (ConfigListItem*)lstView->currentItem();
if (!item )
return;
lstView->takeItem( item );
delete item;
}
void ConfigDialog::slotEdit() {
Profile p;
if(!lstView->currentItem()) return;
// Load profile
p = ((ConfigListItem*)lstView->currentItem())->profile();
ProfileEditorDialog dlg(m_fact, p);
dlg.setCaption("Edit Connection Profile");
dlg.showMaximized();
int ret = dlg.exec();
if(ret == QDialog::Accepted)
{
if(lstView->currentItem()) delete lstView->currentItem();
// use dlg.terminal()!
Profile p = dlg.profile();
new ConfigListItem(lstView, p);
}
}
void ConfigDialog::slotAdd() {
- qWarning("slotAdd");
ProfileEditorDialog dlg(m_fact);
dlg.setCaption("New Connection");
dlg.showMaximized();
int ret = dlg.exec();
if(ret == QDialog::Accepted)
{
// TODO: Move into general profile save part
// assignments
//QString type = dlg.term_type();
//if(type == "VT102") profile = Profile::VT102;
// get profile from editor
Profile p = dlg.profile();
new ConfigListItem(lstView, p);
}
}
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 836a05b..b2cd348 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,148 +1,142 @@
#include <qwidget.h>
#include "TEWidget.h"
#include "TEmuVt102.h"
#include "profile.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& prof) {
m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
int num = prof.readNumEntry("Color");
setColor( foreColor(num), backColor(num) );
m_teWid->setBackgroundColor(backColor(num) );
}
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;
}
/*
* allocate a new table of colors
*/
void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
ColorEntry table[TABLE_COLORS];
const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
for (int i = 0; i < TABLE_COLORS; i++ ) {
if ( i == 0 || i == 10 ) {
table[i].color = fore;
}else if ( i == 1 || i == 11 ) {
table[i].color = back;
table[i].transparent = 0;
}else {
table[i].color = defaultCt[i].color;
}
}
m_teWid->setColorTable(table );
m_teWid->update();
}
QFont EmulationHandler::font( int id ) {
QString name;
int size = 0;
switch(id ) {
default: // fall through
case 0:
name = QString::fromLatin1("Micro");
size = 4;
break;
case 1:
name = QString::fromLatin1("Fixed");
size = 7;
break;
case 2:
name = QString::fromLatin1("Fixed");
size = 12;
break;
}
QFont font(name, size, QFont::Normal );
font.setFixedPitch(TRUE );
return font;
}
QColor EmulationHandler::foreColor(int col) {
QColor co;
/* we need to switch it */
switch( col ) {
default:
case Profile::White:
- qWarning("Foreground black");
/* color is black */
co = Qt::white;
break;
case Profile::Black:
- qWarning("Foreground white");
co = Qt::black;
break;
case Profile::Green:
qWarning("Foreground green");
co = Qt::green;
break;
case Profile::Orange:
qWarning("Foreground orange");
// FIXME needs better color here
co = Qt::darkYellow;
break;
}
return co;
}
QColor EmulationHandler::backColor(int col ) {
QColor co;
/* we need to switch it */
switch( col ) {
default:
case Profile::White:
- qWarning("Background white");
/* color is white */
co = Qt::black;
break;
case Profile::Black:
- qWarning("Background black");
co = Qt::white;
break;
case Profile::Green:
qWarning("Background black");
co = Qt::black;
break;
case Profile::Orange:
qWarning("Background black");
co = Qt::black;
break;
}
return co;
}
diff --git a/noncore/apps/opie-console/filereceive.cpp b/noncore/apps/opie-console/filereceive.cpp
index 26b3dec..e517862 100644
--- a/noncore/apps/opie-console/filereceive.cpp
+++ b/noncore/apps/opie-console/filereceive.cpp
@@ -42,118 +42,116 @@ void FileReceive::receive( const QString& dir ) {
setupChild();
char* typus = NULL;
switch(m_type ) {
case SZ:
break;
case SX:
typus = "-X";
break;
case SY:
typus = "--ymodem";
break;
}
/* we should never return from here */
execlp("rz", "rz", typus, NULL );
char resultByte = 1;
if (m_info[1] )
::write(m_info[1], &resultByte, 1 );
_exit( -1 );
break;
}
default: {
if ( m_info[1] )
close( m_info[1] );
if ( m_info[0] ) for (;;) {
char resultByte; int len;
len = read(m_info[0], &resultByte, 1 );
/* len == 1 start up failed */
if ( len == 1 ) {
emit error( StartError, tr("Could not start") );
return;
}
if ( len == -1 )
if ( (errno == ECHILD ) || (errno == EINTR ) )
continue;
// len == 0 or something like this
break;
}
if ( m_info[0] )
close( m_info[0] );
m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read );
connect(m_not, SIGNAL(activated(int) ),
this, SLOT(slotRead() ) );
if ( pipe(m_term) < 0 )
m_term[0] = m_term[1] = 0;
ProcCtl::self()->add(m_pid, m_term[1] );
m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read );
connect(m_proc, SIGNAL(activated(int) ),
this, SLOT(slotExec() ) );
}
break;
}
}
void FileReceive::cancel() {
::kill(m_pid, 9 );
}
void FileReceive::setupChild() {
changeDir( currentDir() );
/*
* we do not want to read from our
* information channel
*/
if (m_info[0] )
close(m_info[0] );
/*
* FD_CLOEXEC will close the
* fd on successfull exec
*/
if (m_info[1] )
fcntl(m_info[1], F_SETFD, FD_CLOEXEC );
if (m_comm[0] )
close( m_comm[0] );
/*
* now set the communication
* m_fd STDIN_FILENO
* STDOUT_FILENO
* STDERR_FILENO
*/
dup2( m_fd, STDIN_FILENO );
dup2( m_fd, STDOUT_FILENO );
dup2( m_comm[1], STDERR_FILENO );
}
void FileReceive::slotRead() {
QByteArray ar(4096);
int len = read(m_comm[0], ar.data(), 4096 );
- qWarning("slot read %d", len);
for (int i = 0; i < len; i++ ) {
// printf("%c", ar[i] );
}
ar.resize( len );
QString str( ar );
- qWarning(str.simplifyWhiteSpace() );
}
void FileReceive::slotExec() {
char buf[2];
::read(m_term[0], buf, 1 );
delete m_proc;
delete m_not;
m_not = m_proc = 0l;
close( m_term[0] );
close( m_term[1] );
close( m_comm[0] );
close( m_comm[1] );
layer()->closeRawIO(m_fd);
emit received(QString::null);
}
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp
index 8ca0df2..b81c2a2 100644
--- a/noncore/apps/opie-console/filetransfer.cpp
+++ b/noncore/apps/opie-console/filetransfer.cpp
@@ -1,256 +1,250 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <qcstring.h>
#include <qsocketnotifier.h>
#include <opie/oprocess.h>
#include "procctl.h"
#include "filetransfer.h"
FileTransfer::FileTransfer( Type t, IOLayer* lay )
: FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) {
signal(SIGPIPE, SIG_IGN );
m_pid = 0;
m_not = 0l;
m_proc = 0l;
}
FileTransfer::~FileTransfer() {
}
/**
* now we will send the file.
*
* we request an fd. The IOLayer should be closed
* then we will setup a pipe for progress communication
* then we will dup2 the m_fd in the forked process
* to do direct IO from and to the fd
*/
void FileTransfer::sendFile( const QString& file ) {
m_prog =-1;
m_fd = layer()->rawIO();
//
// m_fd = ::open("/dev/ttyS0", O_RDWR);
m_file = file;
if ( pipe( m_comm ) < 0 )
m_comm[0] = m_comm[1] = 0;
if ( pipe( m_info ) < 0 )
m_info[0] = m_info[1] = 0;
m_pid = fork();
switch( m_pid ) {
case -1:
emit error( StartError, tr("Was not able to fork") );
slotExec();
break;
case 0:{
setupChild();
- qWarning("output:"+file );
/* exec */
char* verbose = "-vv";
char* binray = "-b";
char* typus;
switch(m_type ) {
case SZ:
typus = "";
break;
case SX:
typus = "-X";
break;
case SY:
typus = "--ymodem";
break;
}
/* we should never return from here */
execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL );
/* communication for error!*/
char resultByte =1;
if (m_info[1] )
write(m_info[1], &resultByte, 1 );
_exit( -1 );
break;
}
default:{
if ( m_info[1] )
close( m_info[1] );
if ( m_info[0] ) for (;;) {
char resultByte; int len;
len = read(m_info[0], &resultByte, 1 );
/* len == 1 start up failed */
if ( len == 1 ) {
emit error( StartError, tr("Could not start") );
return;
}
if ( len == -1 )
if ( (errno == ECHILD ) || (errno == EINTR ) )
continue;
// len == 0 or something like this
break;
}
if ( m_info[0] )
close( m_info[0] );
/* replace by QSocketNotifier!!! */
m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read );
connect(m_not, SIGNAL(activated(int) ),
this, SLOT(slotRead() ) );
if ( pipe(m_term) < 0 )
m_term[0] = m_term[1] = 0;
ProcCtl::self()->add(m_pid, m_term[1] );
m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read );
connect(m_proc, SIGNAL(activated(int) ),
this, SLOT(slotExec() ) );
}
break;
}
}
/*
* let's call the one with the filename
*/
void FileTransfer::sendFile( const QFile& file ) {
sendFile( file.name() );
}
/*
* setting up communication
* between parent child and ioLayer
*/
void FileTransfer::setupChild() {
/*
* we do not want to read from our
* information channel
*/
if (m_info[0] )
close(m_info[0] );
/*
* FD_CLOEXEC will close the
* fd on successfull exec
*/
if (m_info[1] )
fcntl(m_info[1], F_SETFD, FD_CLOEXEC );
if (m_comm[0] )
close( m_comm[0] );
/*
* now set the communication
* m_fd STDIN_FILENO
* STDOUT_FILENO
* STDERR_FILENO
*/
dup2( m_fd, STDIN_FILENO );
dup2( m_fd, STDOUT_FILENO );
dup2( m_comm[1], STDERR_FILENO );
}
/*
* read from the stderr of the child
* process
*/
void FileTransfer::slotRead() {
QByteArray ar(4096);
int len = read(m_comm[0], ar.data(), 4096 );
- qWarning("slot read %d", len);
for (int i = 0; i < len; i++ ) {
// printf("%c", ar[i] );
}
ar.resize( len );
QString str( ar );
- qWarning(str.simplifyWhiteSpace() );
QStringList lis = QStringList::split(' ', str );
/*
* Transfer finished.. either complete or incomplete
*/
if ( lis[0].simplifyWhiteSpace() == "Transfer" ) {
- qWarning("sent!!!!");
return;
}
/*
* do progress reading
*/
slotProgress( lis );
}
/*
* find the progress
*/
void FileTransfer::slotProgress( const QStringList& list ) {
if ( m_type != SZ )
return;
bool complete = true;
int min, sec;
int bps;
unsigned long sent, total;
min = sec = bps = -1;
sent = total = 0;
// Data looks like this
// 0 1 2 3 4 5
// Bytes Sent 65536/11534336 BPS:7784 ETA 24:33
QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() );
sent = progi[0].toULong(&complete );
if (!complete ) return;
total = progi[1].toULong(&complete );
if (!complete || total == 0) {
return;
}
- qWarning("%s, %d, %d", progi.join("/").latin1(), sent, total );
double pro = (double)sent/total;
int prog = pro * 100;
// speed
progi = QStringList::split(':', list[3].simplifyWhiteSpace() );
bps = progi[1].toInt();
// time
progi = QStringList::split(':', list[5].simplifyWhiteSpace() );
min = progi[0].toInt();
sec = progi[1].toInt();
if ( prog > m_prog ) {
m_prog = prog;
emit progress(m_file, m_prog, bps, -1, min , sec );
}
}
void FileTransfer::cancel() {
if(m_pid > 0) ::kill(m_pid,9 );
}
void FileTransfer::slotExec() {
- qWarning("exited!");
char buf[2];
::read(m_term[0], buf, 1 );
delete m_proc;
delete m_not;
m_proc = m_not = 0l;
close( m_term[0] );
close( m_term[1] );
close( m_comm[0] );
close( m_comm[1] );
layer()->closeRawIO( m_fd );
emit sent();
m_pid = 0;
}
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp
index 8bff4df..0831faf 100644
--- a/noncore/apps/opie-console/io_bt.cpp
+++ b/noncore/apps/opie-console/io_bt.cpp
@@ -1,63 +1,64 @@
#include "io_bt.h"
IOBt::IOBt( const Profile &config ) : IOSerial( config ) {
m_attach = 0;
}
IOBt::~IOBt() {
if ( m_attach ) {
delete m_attach;
}
}
void IOBt::close() {
IOSerial::close();
// still need error handling
delete m_attach;
}
bool IOBt::open() {
// hciattach here
m_attach = new OProcess();
*m_attach << "hciattach /dev/ttyS2 any 57600";
// then start hcid, then rcfomm handling (m_mac)
connect( m_attach, SIGNAL( processExited( OProcess* ) ),
this, SLOT( slotExited( OProcess* ) ) );
if ( m_attach->start() ) {
IOSerial::open();
} else {
qWarning("could not attach to device");
delete m_attach;
+ m_attach = 0;
}
}
void IOBt::reload( const Profile &config ) {
m_device = config.readEntry("Device", BT_DEFAULT_DEVICE);
m_mac = config.readEntry("Mac", BT_DEFAULT_MAC);
m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY);
m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS);
m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS);
m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW);
}
QString IOBt::identifier() const {
return "bluetooth";
}
QString IOBt::name() const {
return "BLuetooth IO Layer";
}
void IOBt::slotExited( OProcess* proc ){
close();
}
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp
index 8e31e82..56a373c 100644
--- a/noncore/apps/opie-console/io_irda.cpp
+++ b/noncore/apps/opie-console/io_irda.cpp
@@ -1,60 +1,62 @@
#include "io_irda.h"
IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) {
m_attach = 0;
}
IOIrda::~IOIrda() {
if ( m_attach ) {
delete m_attach;
}
}
void IOIrda::close() {
IOSerial::close();
// still need error handling
delete m_attach;
}
bool IOIrda::open() {
// irdaattach here
m_attach = new OProcess();
*m_attach << "irattach /dev/ttyS2 -s";
connect( m_attach, SIGNAL( processExited( OProcess* ) ),
this, SLOT( slotExited( OProcess* ) ) );
if ( m_attach->start() ) {
IOSerial::open();
} else {
+ // emit error!!!
qWarning("could not attach to device");
delete m_attach;
+ m_attach = 0l;
}
}
void IOIrda::reload( const Profile &config ) {
m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE);
m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY);
m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS);
m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS);
m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW);
}
QString IOIrda::identifier() const {
return "irda";
}
QString IOIrda::name() const {
return "Irda IO Layer";
}
void IOIrda::slotExited(OProcess* proc ){
close();
}
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index 03f1b1a..a4a6f0b 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -1,197 +1,189 @@
#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;
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() {
- qWarning("closing!");
if (m_fd) {
delete m_read;
delete m_error;
::close(m_fd);
m_fd = 0;
} else {
emit error(Refuse, tr("Not connected"));
}
}
bool IOSerial::open() {
- qWarning("open");
if (!m_fd) {
- qWarning("going to open %s", m_device.latin1());
struct termios tty;
m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (m_fd < 0) {
- qWarning(" fd < 0 ");
emit error(CouldNotOpen, strerror(errno));
return FALSE;
}
tcgetattr(m_fd, &tty);
/* Baud rate */
int speed = baud(m_baud);
if (speed == -1) {
- qWarning("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)) {
m_dbits = 8;
}
/* Data bits */
switch (m_dbits) {
case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break;
case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break;
case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break;
case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break;
default: break;
}
/* Raw, no echo mode */
tty.c_iflag = IGNBRK;
tty.c_lflag = 0;
tty.c_oflag = 0;
tty.c_cflag |= CLOCAL | CREAD;
/* Stop bits */
if (m_sbits == 2) {
tty.c_cflag |= CSTOPB;
} else {
tty.c_cflag &= ~CSTOPB;
}
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 5;
/* Flow control */
if (m_flow & FlowSW)
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()));
return TRUE;
} else {
- qWarning(" already opened");
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);
- qWarning( "Dev" +m_device );
- qWarning( "Conf:" +config.readEntry("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;
case 4800: return B4800; break;
case 9600: return B9600; break;
case 19200: return B19200; break;
case 38400: return B38400; break;
case 57600: return B57600; break;
case 115200: return B115200; break;
}
return -1;
}
void IOSerial::errorOccured() {
emit error(ClosedUnexpected, strerror(errno));
close();
}
void IOSerial::dataArrived() {
QByteArray array(4097);
int len = read(m_fd, array.data(), 4096);
if (len == 0)
close();
if (len < 0)
return;
array.resize( len );
emit received(array);
}
QString IOSerial::identifier() const {
return "serial";
}
QString IOSerial::name() const {
return "RS232 Serial IO Layer";
}
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 );
}
diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp
index 49ed284..b0df02d 100644
--- a/noncore/apps/opie-console/iolayerbase.cpp
+++ b/noncore/apps/opie-console/iolayerbase.cpp
@@ -36,135 +36,132 @@ IOLayerBase::IOLayerBase( QWidget* par, const char* name )
{
m_speedLabel = new QLabel(tr("Speed"), this );
m_speedBox = new QComboBox(this );
m_groupFlow = new QButtonGroup(tr("Flow control"),this );
m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow );
m_flowSw = new QRadioButton(tr("Software"), m_groupFlow );
m_flowNone = new QRadioButton( tr("None"), m_groupFlow );
m_groupParity = new QButtonGroup(tr("Parity"), this );
m_parityNone = new QRadioButton(tr("None"), m_groupParity );
m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity );
m_parityEven = new QRadioButton(tr("Even"), m_groupParity );
m_lroot = new QVBoxLayout( this );
m_lroot->add(m_speedLabel );
m_lroot->add(m_speedBox );
m_lroot->setStretchFactor(m_speedLabel, 1);
m_lroot->setStretchFactor(m_speedBox, 1 );
m_hbox = new QHBoxLayout(m_groupFlow, 2 );
m_hbox->add(m_flowHw );
m_hbox->add(m_flowSw );
m_hbox->add(m_flowNone );
m_lroot->add(m_groupFlow );
m_lroot->setStretchFactor(m_groupFlow, 2 );
m_hboxPar = new QHBoxLayout( m_groupParity, 2 );
m_hboxPar->add(m_parityOdd );
m_hboxPar->add(m_parityEven );
m_hboxPar->add(m_parityNone );
m_lroot->add(m_groupParity );
m_lroot->setStretchFactor(m_groupParity, 2 );
m_lroot->addStretch(2);
// profiles
m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 );
m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 );
m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 );
m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 );
m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 );
};
IOLayerBase::~IOLayerBase() {
}
void IOLayerBase::setFlow( Flow flo ) {
switch ( flo ) {
case Software:
m_flowSw->setChecked( true );
break;
case Hardware:
m_flowHw->setChecked( true );
break;
case None:
m_flowNone->setChecked( true );
break;
}
}
void IOLayerBase::setParity( Parity par ) {
switch( par ) {
case NonePar:
m_parityNone->setChecked( true );
break;
case Odd:
m_parityOdd->setChecked( true );
break;
case Even:
m_parityEven->setChecked( true );
break;
}
}
void IOLayerBase::setSpeed( Speed sp ) {
int index;
switch( sp ) {
case Baud_115200:
index = id_baud_115200;
break;
case Baud_57600:
index = id_baud_57600;
break;
case Baud_38400:
index = id_baud_38400;
break;
case Baud_19200:
index = id_baud_19200;
break;
case Baud_9600:
index = id_baud_9600;
break;
}
m_speedBox->setCurrentItem(index );
}
IOLayerBase::Flow IOLayerBase::flow()const {
if (m_flowHw->isChecked() ) {
- qWarning("Hardware flow");
return Hardware;
}else if( m_flowSw->isChecked() ) {
- qWarning("Software");
return Software;
} else {
- qWarning("None");
return None;
}
}
IOLayerBase::Parity IOLayerBase::parity()const {
if ( m_parityOdd->isChecked() ) {
return Odd;
} else if ( m_parityEven->isChecked() ) {
return Even;
} else {
return NonePar;
}
}
IOLayerBase::Speed IOLayerBase::speed()const{
switch( m_speedBox->currentItem() ) {
case id_baud_115200:
return Baud_115200;
break;
case id_baud_57600:
return Baud_57600;
break;
case id_baud_38400:
return Baud_38400;
break;
case id_baud_19200:
return Baud_19200;
break;
case id_baud_9600:
return Baud_9600;
break;
}
}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index b770551..94c99bc 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -170,312 +170,307 @@ void MainWindow::initUI() {
m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
m_runScript->addTo(m_scripts);
connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
/*
* action that open/closes the keyboard
*/
m_openKeys = new QAction (tr("Open Keyboard..."),
Resource::loadPixmap( "down" ),
QString::null, 0, this, 0);
m_openKeys->setToggleAction(true);
connect (m_openKeys, SIGNAL(toggled(bool)),
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);
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 );
}
ProfileManager* MainWindow::manager() {
return m_manager;
}
TabWidget* MainWindow::tabWidget() {
return m_consoleWindow;
}
void MainWindow::populateProfiles() {
m_sessionsPop->clear();
Profile::ValueList list = manager()->all();
for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
m_sessionsPop->insertItem( (*it).name() );
}
}
MainWindow::~MainWindow() {
delete m_factory;
manager()->save();
}
MetaFactory* MainWindow::factory() {
return m_factory;
}
Session* MainWindow::currentSession() {
return m_curSession;
}
QList<Session> MainWindow::sessions() {
return m_sessions;
}
void MainWindow::slotNew() {
- qWarning("New Connection");
ProfileEditorDialog dlg(factory() );
dlg.showMaximized();
int ret = dlg.exec();
if ( ret == QDialog::Accepted ) {
create( dlg.profile() );
}
}
void MainWindow::slotRecordScript() {
/* if (currentSession()) {
currentSession()->emulationLayer()->startRecording();
}
*/
}
void MainWindow::slotSaveScript() {
/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) {
MimeTypes types;
QStringList script;
script << "text/plain";
types.insert("Script", script);
QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
if (!filename.isEmpty()) {
currentSession()->emulationLayer()->script()->saveTo(filename);
currentSession()->emulationLayer()->clearScript();
}
}
*/
}
void MainWindow::slotRunScript() {
/*
if (currentSession()) {
MimeTypes types;
QStringList script;
script << "text/plain";
types.insert("Script", script);
QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
if (!filename.isEmpty()) {
Script script(DocLnk(filename).file());
currentSession()->emulationLayer()->runScript(&script);
}
}
*/
}
void MainWindow::slotConnect() {
if ( currentSession() ) {
bool ret = currentSession()->layer()->open();
if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
QObject::tr("Failed"),
QObject::tr("Connecting failed for this session."));
m_connect->setEnabled( false );
m_disconnect->setEnabled( true );
}
}
void MainWindow::slotDisconnect() {
if ( currentSession() ) {
currentSession()->layer()->close();
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
}
}
void MainWindow::slotTerminate() {
if ( currentSession() )
currentSession()->layer()->close();
slotClose();
/* FIXME move to the next session */
}
void MainWindow::slotConfigure() {
- qWarning("configure");
ConfigDialog conf( manager()->all(), factory() );
conf.showMaximized();
int ret = conf.exec();
if ( QDialog::Accepted == ret ) {
- qWarning("conf %d", conf.list().count() );
manager()->setProfiles( conf.list() );
manager()->save();
populateProfiles();
}
}
/*
* we will remove
* this window from the tabwidget
* remove it from the list
* delete it
* and set the currentSession()
*/
void MainWindow::slotClose() {
- qWarning("close");
if (!currentSession() )
return;
tabWidget()->remove( currentSession() );
/*it's autodelete */
m_sessions.remove( m_curSession );
m_curSession = m_sessions.first();
tabWidget()->setCurrent( m_curSession );
if (!currentSession() ) {
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 );
}
}
/*
* We will get the name
* Then the profile
* and then we will make a profile
*/
void MainWindow::slotProfile( int id) {
Profile prof = manager()->profile( m_sessionsPop->text( id) );
create( prof );
}
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."));
//if(ses) delete ses;
return;
}
m_sessions.append( ses );
tabWidget()->add( ses );
m_curSession = ses;
// dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
m_terminate->setEnabled( true );
m_transfer->setEnabled( true );
m_recordScript->setEnabled( true );
m_saveScript->setEnabled( true );
m_runScript->setEnabled( true );
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 ) {
if ( ses ) {
- qWarning("changing %s", ses->name().latin1() );
m_curSession = ses;
if ( m_curSession->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;
}
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 09ba586..04a5dfa 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -27,145 +27,144 @@ void MetaFactory::addIOLayerFactory( const QCString& name,
void MetaFactory::addFileTransferLayer( const QCString& name,
const QString& str,
filelayer lay) {
m_strings.insert(str, name );
m_fileFact.insert( str, lay );
}
void MetaFactory::addReceiveLayer( const QCString& name,
const QString& str,
receivelayer lay) {
m_strings.insert(str, name );
m_receiveFact.insert( str, lay );
}
void MetaFactory::addEmulationLayer( const QCString& name,
const QString& str,
emulationLayer em) {
m_strings.insert(str, name );
m_emu.insert( str, em );
}
QStringList MetaFactory::ioLayers()const {
QStringList list;
QMap<QString, iolayer>::ConstIterator it;
for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
list << it.key();
}
return list;
}
QStringList MetaFactory::connectionWidgets()const {
QStringList list;
QMap<QString, configWidget>::ConstIterator it;
for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
list << it.key();
}
return list;
}
QStringList MetaFactory::terminalWidgets()const {
QStringList list;
QMap<QString, configWidget>::ConstIterator it;
for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
list << it.key();
}
return list;
}
QStringList MetaFactory::fileTransferLayers()const {
QStringList list;
QMap<QString, filelayer>::ConstIterator it;
for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
list << it.key();
}
return list;
}
QStringList MetaFactory::receiveLayers()const {
QStringList list;
QMap<QString, receivelayer>::ConstIterator it;
for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) {
list << it.key();
}
return list;
}
QStringList MetaFactory::emulationLayers()const {
QStringList list;
QMap<QString, emulationLayer>::ConstIterator it;
for ( it = m_emu.begin(); it != m_emu.end(); ++it ) {
list << it.key();
}
return list;
}
IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
IOLayer* lay = 0l;
QMap<QString, iolayer>::Iterator it;
it = m_layerFact.find( str );
if ( it != m_layerFact.end() ) {
lay = (*(it.data()))(prof);
/*
iolayer laye = it.data();
lay = (*laye )(conf);*/
}
return lay;
}
ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
ProfileDialogWidget* wid = 0l;
QMap<QString, configWidget>::Iterator it;
it = m_conFact.find( str );
if ( it != m_conFact.end() ) {
wid = (*(it.data() ) )(str,parent);
}
return wid;
}
ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
if (str.isEmpty() )
return 0l;
ProfileDialogWidget* wid = 0l;
- qWarning("new terminalPlugin %s %l", str.latin1(), parent );
QMap<QString, configWidget>::Iterator it;
it = m_termFact.find( str );
if ( it != m_termFact.end() ) {
wid = (*(it.data() ) )(str,parent);
}
return wid;
}
EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) {
EmulationLayer* lay = 0l;
QMap<QString, emulationLayer>::Iterator it;
it = m_emu.find( str );
if ( it != m_emu.end() ) {
lay = (*(it.data() ) )(wid);
}
return lay;
}
FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) {
FileTransferLayer* file = 0l;
QMap<QString, filelayer>::Iterator it;
it = m_fileFact.find( str );
if ( it != m_fileFact.end() ) {
file = (*(it.data() ) )(lay);
}
return file;
}
ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) {
ReceiveLayer* file = 0l;
QMap<QString, receivelayer>::Iterator it;
it = m_receiveFact.find( str );
if ( it != m_receiveFact.end() ) {
file = (*(it.data() ) )(lay);
}
return file;
}
QCString MetaFactory::internal( const QString& str )const {
return m_strings[str];
}
QString MetaFactory::external( const QCString& str )const {
QMap<QString, QCString>::ConstIterator it;
for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
if ( it.data() == str )
return it.key();
}
return QString::null;
}
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
index d1cfaf6..ff6bea8 100644
--- a/noncore/apps/opie-console/procctl.cpp
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -1,97 +1,96 @@
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include "procctl.h"
ProcContainer *ProcCtl::m_last = 0;
ProcCtl* ProcCtl::m_self = 0;
ProcCtl::ProcCtl() {
signal( SIGCHLD, signal_handler );
}
ProcCtl::~ProcCtl() {
}
ProcCtl* ProcCtl::self() {
if (!m_self ) {
m_self = new ProcCtl;
}
}
void ProcCtl::add(pid_t pi, int fd ) {
ProcContainer * con = new ProcContainer;
//memset(con, 0, sizeof(con) );
con->pid = pi;
con->fd = fd;
con->status = 0;
con->prev = m_last;
m_last = con;
}
void ProcCtl::remove( pid_t pi ) {
/*
* We first check if the last item
* is equal to pi the we
*
*/
ProcContainer* con;
if (m_last->pid == pi ) {
con = m_last;
m_last = con->prev;
delete con;
return;
}
con = m_last;
ProcContainer* forw = 0l;
while (con ) {
/* remove it */
if ( pi == con->pid ) {
forw->prev = con->prev;
delete con;
return;
}
forw = con;
con = con->prev;
}
}
void ProcCtl::remove( ProcContainer con ) {
remove( con.pid );
}
int ProcCtl::status(pid_t pid )const{
ProcContainer *con = m_last;
while (con) {
if (con->pid == pid )
return con->status;
con = con->prev;
}
return -1;
}
void ProcCtl::signal_handler(int) {
- qWarning("signal handler in ProcCtl");
int status;
signal( SIGCHLD, signal_handler );
pid_t pi = waitpid( -1, &status, WNOHANG );
/*
* find the container for pid
*
*/
if ( pi < 0 ) {
return;
}
ProcContainer* con = m_last;
while (con) {
if ( con->pid == pi ) {
con->status = status;
char result = 1;
/* give a 'signal' */
::write(con->fd, &result, 1 );
}
con = con->prev;
}
}
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp
index ffd672e..1a94619 100644
--- a/noncore/apps/opie-console/profile.cpp
+++ b/noncore/apps/opie-console/profile.cpp
@@ -1,121 +1,119 @@
#include "profile.h"
Profile::Profile() {
}
Profile::Profile( const QString& name,
const QCString& iolayerName,
const QCString& termName,
int background,
int foreground,
int terminal )
: m_name( name ), m_ioLayer( iolayerName ), m_term( termName),
m_back( background ), m_fore( foreground ), m_terminal( terminal )
{}
Profile::Profile( const Profile& prof )
{
(*this) = prof;
}
bool Profile::operator==( const Profile& prof ) {
if ( m_name == prof.m_name ) return true;
return false;
}
Profile &Profile::operator=( const Profile& prof ) {
m_name = prof.m_name;
m_ioLayer = prof.m_ioLayer;
m_back = prof.m_back;
m_fore = prof.m_fore;
m_terminal = prof.m_terminal;
m_conf = prof.m_conf;
m_term = prof.m_term;
return *this;
}
Profile::~Profile() {
}
QMap<QString, QString> Profile::conf()const {
return m_conf;
}
QString Profile::name()const {
return m_name;
}
QCString Profile::ioLayerName()const {
return m_ioLayer;
}
QCString Profile::terminalName( )const {
return m_term;
}
int Profile::foreground()const {
return m_fore;
}
int Profile::background()const {
return m_back;
}
int Profile::terminal()const {
return m_terminal;
}
void Profile::setName( const QString& str ) {
m_name = str;
}
void Profile::setIOLayer( const QCString& name ) {
m_ioLayer = name;
}
void Profile::setTerminalName( const QCString& str ) {
m_term = str;
}
void Profile::setBackground( int back ) {
m_back = back;
}
void Profile::setForeground( int fore ) {
m_fore = fore;
}
void Profile::setTerminal( int term ) {
m_terminal = term;
}
/* config stuff */
void Profile::clearConf() {
m_conf.clear();
}
void Profile::writeEntry( const QString& key, const QString& value ) {
- qWarning("key %s value %s", key.latin1(), value.latin1() );
m_conf.replace( key, value );
}
void Profile::writeEntry( const QString& key, int num ) {
- qWarning("num");
writeEntry( key, QString::number( num ) );
}
void Profile::writeEntry( const QString& key, bool b ) {
writeEntry( key, QString::number(b) );
}
void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) {
writeEntry( key, lis.join(sep) );
}
QString Profile::readEntry( const QString& key, const QString& deflt )const {
QMap<QString, QString>::ConstIterator it;
it = m_conf.find( key );
if ( it != m_conf.end() )
return it.data();
return deflt;
}
int Profile::readNumEntry( const QString& key, int def )const {
QMap<QString, QString>::ConstIterator it;
it = m_conf.find( key );
if ( it != m_conf.end() ) {
bool ok;
int val = it.data().toInt(&ok);
if (ok)
return val;
}
return def;
}
bool Profile::readBoolEntry( const QString& key, bool def )const {
return readNumEntry( key, def );
}
void Profile::setConf( const QMap<QString, QString>& conf ) {
m_conf = conf;
};
diff --git a/noncore/apps/opie-console/profileconfig.cpp b/noncore/apps/opie-console/profileconfig.cpp
index 732fae7..bd089c8 100644
--- a/noncore/apps/opie-console/profileconfig.cpp
+++ b/noncore/apps/opie-console/profileconfig.cpp
@@ -1,46 +1,45 @@
#include "profileconfig.h"
ProfileConfig::ProfileConfig( const QString& prof )
: Config( prof )
{
}
ProfileConfig::~ProfileConfig() {
}
QStringList ProfileConfig::groups()const {
QStringList list;
QMap<QString, ConfigGroup>::ConstIterator it;
it= Config::groups.begin();
- qWarning("config %d", Config::groups.count() );
for (; it != Config::groups.end(); ++it )
list << it.key();
return list;
}
void ProfileConfig::clearAll() {
QMap<QString, ConfigGroup>::ConstIterator it;
it = Config::groups.begin();
for ( ; it != Config::groups.end(); ++it )
clearGroup( it.key() );
}
void ProfileConfig::clearGroup( const QString& str ) {
QString cur =git.key();
setGroup( str );
Config::clearGroup();
setGroup( cur );
}
QMap<QString, QString> ProfileConfig::items( const QString& group )const {
QMap<QString, QString> map;
QMap<QString, ConfigGroup>::ConstIterator it;
it = Config::groups.find( group );
if (it != Config::groups.end() )
map = it.data();
return map;
}
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 094c871..b709cf3 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -22,179 +22,172 @@ namespace {
}
}
ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
const Profile& prof )
: QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
{
initUI();
// Apply current profile
// plugin_plugin->load(profile);
// ... (reset profile name line edit etc.)
}
ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
: QDialog(0, 0, TRUE), m_fact( fact )
{
// Default profile
m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102);
initUI();
// Apply current profile
// plugin_plugin->load(profile);
}
Profile ProfileEditorDialog::profile() const
{
return m_prof;
}
void ProfileEditorDialog::initUI()
{
m_con = m_term = 0l;
QVBoxLayout *mainLayout = new QVBoxLayout( this );
OTabWidget *tabWidget = new OTabWidget( this );
tabWidget->setTabStyle(OTabWidget::TextTab);
mainLayout->add(tabWidget);
QWidget *tabprof;
/* base tabs */
tabprof = new QWidget(this);
m_tabTerm = new QWidget(this);
m_tabCon = new QWidget(this);
/* base layout for tabs */
m_layCon = new QHBoxLayout( m_tabCon , 2 );
m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
// profile tab
QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
m_name = new QLineEdit(tabprof);
QLabel *con = new QLabel(tr("Connection"), tabprof );
QLabel *term = new QLabel(tr("Terminal"), tabprof );
m_conCmb = new QComboBox( tabprof );
m_termCmb = new QComboBox( tabprof );
// layouting
QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
vbox3->add(name);
vbox3->add(m_name);
vbox3->add(con );
vbox3->add(m_conCmb );
vbox3->add(term );
vbox3->add(m_termCmb );
vbox3->addStretch(1);
tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
tabWidget->setCurrentTab( tabprof );
// fill the comboboxes
QStringList list = m_fact->connectionWidgets();
QStringList::Iterator it;
for (it =list.begin(); it != list.end(); ++it ) {
m_conCmb->insertItem( (*it) );
}
list = m_fact->terminalWidgets();
for (it =list.begin(); it != list.end(); ++it ) {
m_termCmb->insertItem( (*it) );
}
// load profile values
m_name->setText(m_prof.name());
slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
slotTermActivated( m_fact->external(m_prof.terminalName() ) );
setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
- qWarning("Layer: %s %s", m_prof.ioLayerName().data(),
- m_fact->external(m_prof.ioLayerName() ).latin1() );
- qWarning("Term: %s %s", m_prof.terminalName().data(),
- m_fact->external(m_prof.terminalName() ).latin1() );
// signal and slots
connect(m_conCmb, SIGNAL(activated(const QString& ) ),
this, SLOT(slotConActivated(const QString&) ) );
connect(m_termCmb, SIGNAL(activated(const QString& ) ),
this, SLOT(slotTermActivated(const QString& ) ) );
}
ProfileEditorDialog::~ProfileEditorDialog() {
}
void ProfileEditorDialog::accept()
{
if(profName().isEmpty())
{
QMessageBox::information(this,
QObject::tr("Invalid profile"),
QObject::tr("Please enter a profile name."));
return;
}
// Save profile and plugin profile
//if(plugin_plugin) plugin_plugin->save();
// Save general values
m_prof.setName(profName());
m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
- qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(),
- m_termCmb->currentText().latin1() );
if (m_con )
m_con->save( m_prof );
if (m_term )
m_term->save( m_prof );
QDialog::accept();
}
QString ProfileEditorDialog::profName()const
{
return m_name->text();
}
QCString ProfileEditorDialog::profType()const
{
/*QStringList w = m_fact->configWidgets();
for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
if(device_box->currentText() == m_fact->name((*it))) return (*it);
*/
return QCString();
}
/*
* we need to switch the widget
*/
void ProfileEditorDialog::slotConActivated( const QString& str ) {
delete m_con;
m_con = m_fact->newConnectionPlugin( str, m_tabCon );
if (m_con ) {
m_con->load( m_prof );
m_layCon->addWidget( m_con );
}
}
/*
* we need to switch the widget
*/
void ProfileEditorDialog::slotTermActivated( const QString& str ) {
delete m_term;
m_term = m_fact->newTerminalPlugin( str, m_tabTerm );
- qWarning("past");
if (m_term) {
m_term->load(m_prof );
m_layTerm->addWidget( m_term );
}
}
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index 95a46f9..e5aedb6 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -1,146 +1,142 @@
#include <stdio.h>
#include <stdlib.h>
#include <qfile.h>
#include <qlayout.h>
#include <qwidgetstack.h>
#include <qpe/config.h>
#include "emulation_handler.h"
#include "widget_layer.h"
#include "emulation_widget.h"
#include "metafactory.h"
#include "profileconfig.h"
#include "profilemanager.h"
ProfileManager::ProfileManager( MetaFactory* fact )
: m_fact( fact )
{
}
ProfileManager::~ProfileManager() {
}
void ProfileManager::load() {
m_list.clear();
- qWarning("load");
ProfileConfig conf("opie-console-profiles");
QStringList groups = conf.groups();
QStringList::Iterator it;
/*
* for each profile
*/
for ( it = groups.begin(); it != groups.end(); ++it ) {
- qWarning("group " + (*it) );
conf.setGroup( (*it) );
Profile prof;
prof.setName( conf.readEntry("name") );
prof.setIOLayer( conf.readEntry("iolayer").utf8() );
prof.setTerminalName( conf.readEntry("term").utf8() );
- qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() );
prof.setBackground( conf.readNumEntry("back") );
prof.setForeground( conf.readNumEntry("fore") );
prof.setTerminal( conf.readNumEntry("terminal") );
// THIS is evil because all data get's reset
prof.setConf( conf.items( (*it) ) );
/* now add it */
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() );
}
conf.writeEntry( "name", (*it2).name() );
QString str = QString::fromUtf8( (*it2).ioLayerName() );
- qWarning("IOLayerName " + str );
conf.writeEntry( "iolayer", str );
conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) );
conf.writeEntry( "back", (*it2).background() );
conf.writeEntry( "fore", (*it2).foreground() );
conf.writeEntry( "terminal", (*it2).terminal() );
}
}
void ProfileManager::setProfiles( const Profile::ValueList& list ) {
m_list = list;
};
Profile ProfileManager::profile( const QString& name )const {
Profile prof;
Profile::ValueList::ConstIterator it;
for ( it = m_list.begin(); it != m_list.end(); ++it ) {
if ( name == (*it).name() ) {
prof = (*it);
break;
}
}
return prof;
}
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index d0ace6c..e53dbc4 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -1,100 +1,99 @@
#include "io_layer.h"
#include "file_layer.h"
#include "emulation_handler.h"
#include "session.h"
Session::Session() {
m_widget = 0l;
m_layer = 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_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;
}
EmulationHandler* Session::emulationHandler() {
return m_emu;
}
/*
WidgetLayer* Session::emulationWidget() {
return m_widLay;
}
*/
void Session::connect() {
if ( !m_layer || !m_emu )
return;
m_connected = true;
- qWarning("connection in session");
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/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp
index 466b536..8a691f9 100644
--- a/noncore/apps/opie-console/tabwidget.cpp
+++ b/noncore/apps/opie-console/tabwidget.cpp
@@ -1,44 +1,43 @@
#include "tabwidget.h"
TabWidget::TabWidget( QWidget* parent, const char* name )
: OTabWidget( parent, name ) {
connect(this, SIGNAL( currentChanged(QWidget*) ),
this, SLOT( slotCurChanged(QWidget*) ) );
}
TabWidget::~TabWidget() {
}
void TabWidget::add( Session* ses ) {
if ( !ses->widgetStack() ) return;
- qWarning("going to add it");
//reparent( ses->widgetStack(), QPoint() );
addTab( ses->widgetStack(), "console/konsole", ses->name() );
//addTab( ses->widgetStack(), ses->name() );
m_map.insert( ses->widgetStack(), ses );
}
void TabWidget::remove( Session* ses ) {
m_map.remove( ses->widgetStack() );
removePage( ses->widgetStack() );
}
void TabWidget::slotCurChanged( QWidget* wid ) {
QMap<QWidget*, Session*>::Iterator it;
it = m_map.find( wid );
if ( it == m_map.end() ) {
return;
}
emit activated( it.data() );
}
void TabWidget::setCurrent( Session* ses ) {
if (!ses )
return;
//showPage( ses->widgetStack() );
setCurrentTab( ses->widgetStack() );
}