summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-console/btconfigwidget.cpp4
-rw-r--r--noncore/apps/opie-console/default.cpp2
-rw-r--r--noncore/apps/opie-console/dialer.cpp2
-rw-r--r--noncore/apps/opie-console/dialer.h2
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp4
-rw-r--r--noncore/apps/opie-console/io_modem.cpp2
-rw-r--r--noncore/apps/opie-console/iolayerbase.cpp4
-rw-r--r--noncore/apps/opie-console/irdaconfigwidget.cpp4
-rw-r--r--noncore/apps/opie-console/main.cpp1
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp3
-rw-r--r--noncore/apps/opie-console/procctl.cpp1
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp3
-rw-r--r--noncore/apps/opie-console/serialconfigwidget.cpp2
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp8
14 files changed, 26 insertions, 16 deletions
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp
index 6246f92..64046d8 100644
--- a/noncore/apps/opie-console/btconfigwidget.cpp
+++ b/noncore/apps/opie-console/btconfigwidget.cpp
@@ -1,188 +1,190 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qhbox.h>
#include <qradiobutton.h>
#include "iolayerbase.h"
#include "btconfigwidget.h"
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
uint b = bo->count();
- for (uint i = 0; i < bo->count(); i++ ) {
+ for (int i = 0; i < bo->count(); i++ ) {
if ( bo->text(i) == str ) {
bo->setCurrentItem( i );
return;
}
}
bo->insertItem( str );
bo->setCurrentItem( b );
}
}
BTConfigWidget::BTConfigWidget( const QString& name,
QWidget* parent,
const char* na )
: ProfileDialogConnectionWidget( name, parent, na ) {
m_lay = new QVBoxLayout( this );
m_device = new QLabel( tr( "Device" ), this );
QHBox *deviceBox = new QHBox( this );
m_devRadio = new QRadioButton( deviceBox );
connect( m_devRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotDevRadio( bool ) ) );
m_deviceCmb = new QComboBox( deviceBox );
m_deviceCmb->setEditable( TRUE );
QLabel *macLabel = new QLabel( this );
macLabel->setText( tr( "Or peer mac address" ) );
QHBox *macBox = new QHBox( this );
m_macRadio = new QRadioButton( macBox );
connect( m_macRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotMacRadio( bool ) ) );
m_mac = new QLineEdit( macBox );
m_base = new IOLayerBase(this, "base");
m_lay->addWidget( m_device );
m_lay->addWidget( deviceBox );
m_lay->addWidget( macLabel );
m_lay->addWidget( macBox );
m_lay->addWidget( m_base );
m_deviceCmb->insertItem( "/dev/ttyU0" );
m_deviceCmb->insertItem( "/dev/ttyU1" );
}
BTConfigWidget::~BTConfigWidget() {
}
void BTConfigWidget::load( const Profile& prof ) {
int rad_flow = prof.readNumEntry("Flow");
int rad_parity = prof.readNumEntry("Parity");
int speed = prof.readNumEntry("Speed");
QString mac = prof.readEntry("Mac");
if (!mac.isEmpty() ) {
m_mac->setText( mac );
} else {
m_devRadio->setChecked( true );
}
if (rad_flow == 1) {
m_base->setFlow( IOLayerBase::Hardware );
} else if (rad_flow == 2) {
m_base->setFlow( IOLayerBase::Software );
} else if (rad_flow == 0) {
m_base->setFlow( IOLayerBase::None );
}
if (rad_parity == 1) {
m_base->setParity( IOLayerBase::Even );
} else if ( rad_parity == 2 ) {
m_base->setParity( IOLayerBase::Odd );
} else {
m_base->setParity( IOLayerBase::NonePar );
}
switch( speed ) {
case 115200:
m_base->setSpeed(IOLayerBase::Baud_115200 );
break;
case 57600:
m_base->setSpeed( IOLayerBase::Baud_57600 );
break;
case 38400:
m_base->setSpeed(IOLayerBase::Baud_38400 );
break;
case 19200:
m_base->setSpeed( IOLayerBase::Baud_19200 );
break;
case 9600:
default:
m_base->setSpeed(IOLayerBase::Baud_9600 );
break;
}
if ( prof.readEntry("Device").isEmpty() ) return;
setCurrent( prof.readEntry("Device"), m_deviceCmb );
}
/*
* save speed,
* flow,
* parity
*/
void BTConfigWidget::save( Profile& prof ) {
int flow, parity, speed;
+ flow = parity = speed = 0;
prof.writeEntry("Device", m_deviceCmb->currentText() );
switch( m_base->flow() ) {
case IOLayerBase::None:
flow = 0;
break;
case IOLayerBase::Software:
flow = 2;
break;
case IOLayerBase::Hardware:
flow = 1;
break;
}
switch( m_base->parity() ) {
case IOLayerBase::Odd:
parity = 2;
break;
case IOLayerBase::Even:
parity = 1;
break;
case IOLayerBase::NonePar:
parity = 0;
break;
}
switch( m_base->speed() ) {
case IOLayerBase::Baud_115200:
speed = 115200;
break;
case IOLayerBase::Baud_57600:
speed = 57600;
break;
case IOLayerBase::Baud_38400:
speed = 38400;
break;
case IOLayerBase::Baud_19200:
speed = 19200;
break;
+ default:
case IOLayerBase::Baud_9600:
speed = 9600;
break;
}
prof.writeEntry("Flow", flow);
prof.writeEntry("Parity", parity);
prof.writeEntry("Speed", speed);
prof.writeEntry("Mac", m_mac->text() );
}
void BTConfigWidget::slotMacRadio( bool on ) {
if ( on ) {
m_devRadio->setChecked( false );
m_deviceCmb->setEnabled( false );
m_mac->setEnabled( true );
} else {
m_devRadio->setChecked( true );
}
}
void BTConfigWidget::slotDevRadio( bool on ) {
if ( on ) {
m_macRadio->setChecked( false );
m_deviceCmb->setEnabled( true );
m_mac->setEnabled( false );
} else {
m_macRadio->setChecked( true );
}
}
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
index 0160b56..19640d8 100644
--- a/noncore/apps/opie-console/default.cpp
+++ b/noncore/apps/opie-console/default.cpp
@@ -1,121 +1,121 @@
#include "io_serial.h"
#include "io_irda.h"
#include "io_bt.h"
#include "io_modem.h"
#include "filetransfer.h"
#include "filereceive.h"
#include "serialconfigwidget.h"
#include "irdaconfigwidget.h"
#include "btconfigwidget.h"
#include "modemconfigwidget.h"
#include "terminalwidget.h"
#include "function_keyboard.h"
#include "MyPty.h"
#include "default.h"
extern "C" {
// FILE Transfer Stuff
FileTransferLayer* newSZTransfer(IOLayer* lay) {
return new FileTransfer( FileTransfer::SZ, lay );
}
FileTransferLayer* newSYTransfer(IOLayer* lay) {
return new FileTransfer( FileTransfer::SY, lay );
}
FileTransferLayer* newSXTransfer(IOLayer* lay) {
return new FileTransfer(FileTransfer ::SX, lay );
}
// FILE Transfer Receive Stuff
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 );
}
// 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 ) {
+ ProfileDialogWidget* newConsoleWid( const QString& , QWidget* ) {
return 0l;
}
// Terminal Widget(s)
ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) {
return new TerminalWidget(na, wid,0 );
}
// Function Keyboard Widget
ProfileDialogWidget* newKeyboardWidget(const QString& na, QWidget *wid) {
return new FunctionKeyboardConfig(na, wid);
}
/* // VT Emulations
EmulationLayer* newVT102( WidgetLayer* wid ) {
return new Vt102Emulation( wid );
}
*/
};
Default::Default( MetaFactory* fact ) {
fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer );
fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer );
fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer );
fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive );
fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive );
fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive );
fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer );
fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer );
fact->addIOLayerFactory( "console", QObject::tr("Console"), newConsole );
fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget );
fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
fact->addConnectionWidgetFactory( "console", QObject::tr("Console"), newConsoleWid );
fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
fact->addKeyboardWidgetFactory( "defaultKeys", QObject::tr("Default Keyboard"),
newKeyboardWidget );
// fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 );
}
Default::~Default() {
}
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index d37e406..5056040 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -36,266 +36,266 @@
//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) );
//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
// from modemconfigwidget
//int rad_flow = prof.readNumEntry("Flow");
//int rad_parity = prof.readNumEntry("Parity");
//int speed = prof.readNumEntry("Speed");
//QString number = prof.readEntry("Number");
Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name)
: QDialog(parent, name, true), m_fd(fd), m_profile(profile)
{
QVBoxLayout *vbox;
QLabel *desc;
//m_profile.writeEntry("InitString", "ATZ");
//m_profile.writeEntry("DialPrefix1", "ATDT");
//m_profile.writeEntry("Termination", "\n");
usercancel = 0;
cleanshutdown = 0;
fcntl(m_fd, F_SETFL, O_NONBLOCK);
desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
progress = new QProgressBar(this);
status = new QLabel("", this);
status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
cancel = new QPushButton(QObject::tr("Cancel"), this);
vbox = new QVBoxLayout(this, 2);
vbox->add(desc);
vbox->add(progress);
vbox->add(status);
vbox->add(cancel);
connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
show();
QTimer::singleShot(500, this, SLOT(slotAutostart()));
}
Dialer::~Dialer()
{
}
void Dialer::setHangupOnly()
{
state = state_cancel;
usercancel = 1;
}
void Dialer::slotCancel()
{
if(state != state_online)
{
usercancel = 1;
reset();
}
else accept();
}
void Dialer::reset()
{
switchState(state_cancel);
}
void Dialer::slotAutostart()
{
//state = state_preinit;
dial(m_profile.readEntry("Number"));
}
void Dialer::dial(const QString& number)
{
while(state != state_online)
{
if(!usercancel)
{
state = state_preinit;
trydial(number);
}
else break;
}
if(usercancel)
{
// modem hangup
trydial(QString::null);
reject();
}
}
void Dialer::trydial(const QString& number)
{
if(state != state_cancel) switchState(state_preinit);
if(cleanshutdown)
{
send(m_profile.readEntry("HangupString"));
//send("+++ATH");
send("");
}
if(state != state_cancel)
{
switchState(state_init);
//send("ATZ");
send(m_profile.readEntry("InitString"));
QString response2 = receive();
if(!response2.contains("\nOK\r"))
reset();
}
if(state != state_cancel)
{
switchState(state_options);
send("ATM3L3");
QString response3 = receive();
if(!response3.contains("\nOK\r"))
reset();
}
if(state != state_cancel)
{
switchState(state_dialtone);
send("ATX1");
QString response4 = receive();
if(!response4.contains("\nOK\r"))
reset();
}
if(state != state_cancel)
{
switchState(state_dialing);
//send(QString("ATDT %1").arg(number));
send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number));
QString response5 = receive();
if(!response5.contains("\n" + m_profile.readEntry("DefaultConnect")))
{
if(response5.contains("BUSY"))
switchState(state_dialing);
else
{
QMessageBox::warning(this,
QObject::tr("Failure"),
QObject::tr("Dialing the number failed."));
slotCancel();
}
}
}
if(state != state_cancel)
{
switchState(state_online);
}
}
void Dialer::send(const QString& msg)
{
QString m = msg;
int bytes;
QString termination;
//qWarning("Sending: '%s'", m.latin1());
termination = "\r";
//termination = m_profile.readEntry("Termination");
if(termination == "\n") m = m + "\n";
else if(termination == "\r") m = m + "\r";
else m = m + "\r\n";
bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
if(bytes < 0)
{
reset();
}
}
QString Dialer::receive()
{
QString buf;
char buffer[1024];
int ret;
- int counter;
+ int counter = 0;
while(1)
{
ret = ::read(m_fd, buffer, sizeof(buffer));
if(ret > 0)
{
for(int i = 0; i < ret; i++)
buffer[i] = buffer[i] & 0x7F;
buffer[ret] = 0;
//qWarning("Got: '%s'", buffer);
buf.append(QString(buffer));
if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY")))
{
//qWarning("Receiving: '%s'", buf.latin1());
cleanshutdown = 1;
return buf;
}
}
else if(ret < 0)
{
if(errno != EAGAIN) reset();
else if(!(counter++ % 100)) qApp->processEvents();
}
else if(!(counter++ % 100)) qApp->processEvents();
if(usercancel) return QString::null;
}
cleanshutdown = 1;
return QString::null;
}
void Dialer::switchState(int newstate)
{
int oldstate = state;
state = newstate;
switch(state)
{
case state_cancel:
status->setText(QObject::tr("Cancelling..."));
progress->setProgress(0);
break;
case state_preinit:
status->setText(QObject::tr("Searching modem"));
progress->setProgress(10);
break;
case state_init:
status->setText(QObject::tr("Initializing..."));
progress->setProgress(20);
break;
case state_options:
status->setText(QObject::tr("Reset speakers"));
progress->setProgress(30);
break;
case state_dialtone:
status->setText(QObject::tr("Turning off dialtone"));
progress->setProgress(40);
break;
case state_dialing:
if(oldstate != state_dialing) status->setText(QObject::tr("Dial number"));
else status->setText(QObject::tr("Line busy, redialing number"));
progress->setProgress(50);
break;
case state_online:
status->setText(QObject::tr("Connection established"));
progress->setProgress(100);
cancel->setText(QObject::tr("Dismiss"));
break;
}
}
diff --git a/noncore/apps/opie-console/dialer.h b/noncore/apps/opie-console/dialer.h
index 28303f3..88681a3 100644
--- a/noncore/apps/opie-console/dialer.h
+++ b/noncore/apps/opie-console/dialer.h
@@ -1,54 +1,54 @@
#ifndef DIALER_H
#define DIALER_H
#include <qdialog.h>
#include "profile.h"
class QLabel;
class QProgressBar;
class Dialer : public QDialog
{
Q_OBJECT
public:
Dialer(const Profile& profile, int fd, QWidget *parent = NULL, const char *name = NULL);
~Dialer();
void setHangupOnly();
public slots:
void slotCancel();
void slotAutostart();
private:
void switchState(int newstate);
void reset();
void dial(const QString& number);
void trydial(const QString& number);
void send(const QString& msg);
QString receive();
enum States
{
state_cancel,
state_preinit,
state_init,
state_options,
state_dialtone,
state_dialing,
state_online
};
QLabel *status;
QProgressBar *progress;
QPushButton *cancel;
int state;
int usercancel;
- const Profile& m_profile;
int m_fd;
+ const Profile& m_profile;
int cleanshutdown;
};
#endif
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index fd20e99..100fdfc 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,182 +1,182 @@
#include "function_keyboard.h"
#include <qsizepolicy.h>
#include <qevent.h>
#include <qwindowsystem_qws.h>
#include <qapplication.h>
#include <qlayout.h>
FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
QFrame(parent), numRows(2), numCols(11),
pressedRow(0), pressedCol(0) {
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
Config conf("opie-console-keys");
conf.setGroup("keys");
for (uint r = 0; r < numRows; r++)
for (uint c = 0; c < numCols; c++) {
QString handle = "r" + QString::number(r) + "c" + QString::number(c);
QStringList value_list = conf.readListEntry( handle, '|');
if (value_list.isEmpty()) continue;
keys.insert(
handle,
FKey (value_list[0], value_list[1].toUShort(), value_list[2].toUShort())
);
}
//qWarning("loaded %d keys", keys.count());
if (keys.isEmpty()) loadDefaults();
}
FunctionKeyboard::~FunctionKeyboard() {
}
void FunctionKeyboard::paintEvent(QPaintEvent *e) {
QPainter p(this);
p.setClipRect(e->rect());
p.fillRect(0, 0, width(), height(), QColor(255,255,255));
p.setPen(QColor(0,0,0));
/* those decimals do count! becomes short if use plain int */
for (double i = 0; i <= width(); i += keyWidth) {
p.drawLine((int)i, 0, (int)i, height());
}
// sometimes the last line doesnt get drawn
p.drawLine(width() -1, 0, width() -1, height());
for (int i = 0; i <= height(); i += keyHeight) {
p.drawLine(0, i, width(), i);
}
for (uint r = 0; r < numRows; r++) {
for (uint c = 0; c < numCols; c++) {
QString handle = "r" + QString::number(r) + "c" + QString::number(c);
if (keys.contains(handle)) {
p.drawText(
c * keyWidth + 1, r * keyHeight + 1,
keyWidth, keyHeight,
Qt::AlignHCenter | Qt::AlignVCenter,
keys[handle].getL()
);
}
}
}
}
void FunctionKeyboard::paintKey(int row, int col) {
QPainter p(this);
p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
(pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
p.drawText(
col * keyWidth + 1, row * keyHeight + 1,
keyWidth, keyHeight,
Qt::AlignHCenter | Qt::AlignVCenter,
keys["r" + QString::number(row) + "c" + QString::number(col)].getL()
);
}
void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
pressedRow = e->y() / keyHeight;
pressedCol = (int) (e->x() / keyWidth);
paintKey(pressedRow, pressedCol);
// emit that sucker!
FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
emit keyPressed(k.getU(), k.getQ(), 0, 1, 0);
}
void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
if (pressedRow != -1 && pressedRow != -1) {
int row = pressedRow; pressedRow = -1;
int col = pressedCol; pressedCol = -1;
paintKey(row, col);
FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
emit keyPressed(k.getU(), k.getQ(), 0, 0, 0);
}
}
void FunctionKeyboard::resizeEvent(QResizeEvent*) {
/* set he default font height/width */
QFontMetrics fm=fontMetrics();
keyHeight = fm.lineSpacing() + 2;
keyWidth = (double)width()/numCols;
}
QSize FunctionKeyboard::sizeHint() const {
return QSize(width(), keyHeight * numRows + 1);
}
void FunctionKeyboard::loadDefaults() {
/* what keys should be default? */
keys.insert( "r0c0", FKey ("F1", 4144, 0));
keys.insert( "r0c1", FKey ("F2", 4145, 0));
keys.insert( "r0c2", FKey ("F3", 4145, 0));
keys.insert( "r0c3", FKey ("F4", 4146, 0));
keys.insert( "r0c4", FKey ("F5", 4147, 0));
keys.insert( "r0c5", FKey ("F6", 4148, 0));
keys.insert( "r0c6", FKey ("F7", 4149, 0));
keys.insert( "r0c7", FKey ("F8", 4150, 0));
keys.insert( "r0c8", FKey ("F9", 4151, 0));
keys.insert( "r0c9", FKey ("F10", 4152, 0));
keys.insert( "r0c10", FKey ("F11", 4153, 0));
keys.insert( "r1c7", FKey ("Ho", 4112, 0));
keys.insert( "r1c8", FKey ("End", 4113, 0));
keys.insert( "r1c9", FKey ("PU", 4118, 0));
keys.insert( "r1c10", FKey ("PD", 4119, 0));
}
FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) :
ProfileDialogKeyWidget(name, parent) {
FunctionKeyboard *kb = new FunctionKeyboard(this);
QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this);
QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit"), this);
QVBoxLayout *root = new QVBoxLayout(this, 2);
root->addWidget(kb);
root->addWidget(dimentions);
root->addWidget(editKey);
}
FunctionKeyboardConfig::~FunctionKeyboardConfig() {
}
-void FunctionKeyboardConfig::load (const Profile& prof) {
+void FunctionKeyboardConfig::load (const Profile& ) {
}
-void FunctionKeyboardConfig::save (Profile& prof) {
+void FunctionKeyboardConfig::save (Profile& ) {
}
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index f246d81..d4ea0b2 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -1,89 +1,91 @@
#include "io_modem.h"
#include "dialer.h"
IOModem::IOModem( const Profile &profile )
: IOSerial( profile ) {
m_profile = profile;
}
IOModem::~IOModem() {
}
void IOModem::close() {
// Hangup, discarding result
int fd = rawIO();
Dialer d(m_profile, fd);
d.setHangupOnly();
d.exec();
closeRawIO(fd);
IOSerial::close();
}
bool IOModem::open() {
bool ret = IOSerial::open();
if(!ret) return false;
int fd = rawIO();
Dialer d(m_profile, fd);
int result = d.exec();
closeRawIO(fd);
if(result == QDialog::Accepted)
{
return true;
}
else
{
close();
return false;
}
}
void IOModem::reload( const Profile &config ) {
m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE);
m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY);
m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS);
m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS);
m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW);
m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING );
m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING );
m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 );
m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 );
m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 );
m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 );
m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 );
m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 );
m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING );
m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING );
m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING );
m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME );
m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL );
m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES );
m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME );
m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT );
m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES );
m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG );
}
QString IOModem::identifier() const {
return "modem";
}
QString IOModem::name() const {
return "Modem IO Layer";
}
void IOModem::slotExited(OProcess* proc ){
close();
+ /* delete it afterwards */
+ delete proc;
}
diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp
index b0df02d..47f9e76 100644
--- a/noncore/apps/opie-console/iolayerbase.cpp
+++ b/noncore/apps/opie-console/iolayerbase.cpp
@@ -1,167 +1,169 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qcombobox.h>
#include <qbuttongroup.h>
#include <qhbuttongroup.h>
#include <qradiobutton.h>
#include "iolayerbase.h"
namespace {
enum ParityIds {
id_parity_none,
id_parity_odd,
id_parity_even
};
enum FlowIds {
id_flow_hw,
id_flow_sw,
id_flow_none,
};
enum SpeedIds {
id_baud_115200,
id_baud_57600,
id_baud_38400,
id_baud_19200,
id_baud_9600
};
}
IOLayerBase::IOLayerBase( QWidget* par, const char* name )
: QWidget( par, 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;
+ int index = -1;
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;
+ default:
case Baud_9600:
index = id_baud_9600;
break;
}
m_speedBox->setCurrentItem(index );
}
IOLayerBase::Flow IOLayerBase::flow()const {
if (m_flowHw->isChecked() ) {
return Hardware;
}else if( m_flowSw->isChecked() ) {
return Software;
} else {
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;
+ default:
case id_baud_9600:
return Baud_9600;
break;
}
}
diff --git a/noncore/apps/opie-console/irdaconfigwidget.cpp b/noncore/apps/opie-console/irdaconfigwidget.cpp
index 72e99a1..059530d 100644
--- a/noncore/apps/opie-console/irdaconfigwidget.cpp
+++ b/noncore/apps/opie-console/irdaconfigwidget.cpp
@@ -1,146 +1,148 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qcombobox.h>
#include "iolayerbase.h"
#include "irdaconfigwidget.h"
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
uint b = bo->count();
- for (uint i = 0; i < bo->count(); i++ ) {
+ for (int i = 0; i < bo->count(); i++ ) {
if ( bo->text(i) == str ) {
bo->setCurrentItem( i );
return;
}
}
bo->insertItem( str );
bo->setCurrentItem( b );
}
}
IrdaConfigWidget::IrdaConfigWidget( const QString& name,
QWidget* parent,
const char* na )
: ProfileDialogConnectionWidget( name, parent, na ) {
m_lay = new QVBoxLayout(this );
m_device = new QLabel(tr("Device"), this );
m_deviceCmb = new QComboBox(this );
m_deviceCmb->setEditable( TRUE );
m_base = new IOLayerBase(this, "base");
m_lay->addWidget( m_device );
m_lay->addWidget( m_deviceCmb );
m_lay->addWidget( m_base );
m_deviceCmb->insertItem( "/dev/ircomm0" );
m_deviceCmb->insertItem( "/dev/ircomm1" );
}
IrdaConfigWidget::~IrdaConfigWidget() {
}
void IrdaConfigWidget::load( const Profile& prof ) {
int rad_flow = prof.readNumEntry("Flow");
int rad_parity = prof.readNumEntry("Parity");
int speed = prof.readNumEntry("Speed");
if (rad_flow == 1) {
m_base->setFlow( IOLayerBase::Hardware );
} else if (rad_flow == 2) {
m_base->setFlow( IOLayerBase::Software );
} else {
m_base->setFlow( IOLayerBase::None );
}
if (rad_parity == 1) {
m_base->setParity( IOLayerBase::Even );
} else if ( rad_parity == 2 ) {
m_base->setParity( IOLayerBase::Odd );
} else {
m_base->setParity( IOLayerBase::NonePar );
}
switch( speed ) {
case 115200:
m_base->setSpeed(IOLayerBase::Baud_115200 );
break;
case 57600:
m_base->setSpeed( IOLayerBase::Baud_57600 );
break;
case 38400:
m_base->setSpeed(IOLayerBase::Baud_38400 );
break;
case 19200:
m_base->setSpeed( IOLayerBase::Baud_19200 );
break;
case 9600:
default:
m_base->setSpeed(IOLayerBase::Baud_9600 );
break;
}
if ( prof.readEntry("Device").isEmpty() ) return;
setCurrent( prof.readEntry("Device"), m_deviceCmb );
}
/*
* save speed,
* flow,
* parity
*/
void IrdaConfigWidget::save( Profile& prof ) {
int flow, parity, speed;
+ flow = parity = speed = 0;
prof.writeEntry("Device", m_deviceCmb->currentText() );
switch( m_base->flow() ) {
case IOLayerBase::None:
flow = 0;
break;
case IOLayerBase::Software:
flow = 2;
break;
case IOLayerBase::Hardware:
flow = 1;
break;
}
switch( m_base->parity() ) {
case IOLayerBase::Odd:
parity = 2;
break;
case IOLayerBase::Even:
parity = 1;
break;
case IOLayerBase::NonePar:
parity = 0;
break;
}
switch( m_base->speed() ) {
case IOLayerBase::Baud_115200:
speed = 115200;
break;
case IOLayerBase::Baud_57600:
speed = 57600;
break;
case IOLayerBase::Baud_38400:
speed = 38400;
break;
case IOLayerBase::Baud_19200:
speed = 19200;
break;
+ default:
case IOLayerBase::Baud_9600:
speed = 9600;
break;
}
prof.writeEntry("Flow", flow);
prof.writeEntry("Parity", parity);
prof.writeEntry("Speed", speed);
}
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp
index 78a91a2..7f9f038 100644
--- a/noncore/apps/opie-console/main.cpp
+++ b/noncore/apps/opie-console/main.cpp
@@ -1,113 +1,114 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <qfile.h>
#include <qpe/qpeapplication.h>
#include "mainwindow.h"
//#define FSCKED_DISTRIBUTION 1
#ifdef FSCKED_DISTRIBUTION
/*
* The Zaurus rom
*/
class FixIt {
public:
FixIt();
~FixIt();
void fixIt();
/* no real interested in implementing it */
void breakIt() {
};
char* m_file;
};
FixIt::FixIt() {
/* the new inittab */
m_file = "#\n# /etc/inittab
#
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - JavaVM(Intent) developer mode
# 5 - JavaVM(Intent)
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
# Specify things to do when starting
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/root/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/root/etc/rc.d/rc 6
# Specify things to do before rebooting
um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1
sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1
# Specify program to run on ttyS0
s0:24:respawn:/sbin/getty 9600 ttyS0
#pd:5:respawn:/etc/sync/serialctl
# Specify program to run on tty1
1:2:respawn:/sbin/getty 9600 tty1
ln:345:respawn:survive -l 6 /sbin/launch
#qt:5:respawn:/sbin/qt
# collie sp.
sy::respawn:/sbin/shsync\n";
}
FixIt::~FixIt() {
}
/*
* the retail Zaurus is broken in many ways
* one is that pppd is listening on our port...
* we've to stop it from that and then do kill(SIGHUP,1);
*/
void FixIt::fixIt() {
::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
QFile file( "/etc/inittab" );
if ( file.open(IO_WriteOnly | IO_Raw ) ) {
file.writeBlock(m_file,strlen(m_file) );
}
file.close();
::kill( SIGHUP, 1 );
}
#endif
int main(int argc, char **argv) {
+ argv[0]="embeddedkonsole";
QPEApplication app( argc, argv );
#ifdef FSCKED_DISTRIBUTION
qWarning("fscked");
FixIt it;
it.fixIt();
#endif
MainWindow mw;
mw.setCaption(QObject::tr("Opie console") );
app.showMainWidget( &mw );
int ap = app.exec();
#ifdef FSCKED_DISTRIBUTION
/* should add a signal handler too */
it.breakIt();
#endif
return ap;
}
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index d3a23fa..c37fafd 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -1,200 +1,201 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qhbox.h>
#include <qregexp.h>
#include "modemconfigwidget.h"
#include "dialdialog.h"
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
uint b = bo->count();
- for (uint i = 0; i < bo->count(); i++ ) {
+ for (int i = 0; i < bo->count(); i++ ) {
if ( bo->text(i) == str ) {
bo->setCurrentItem( i );
return;
}
}
bo->insertItem( str );
bo->setCurrentItem( b );
}
}
ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent,
const char* na )
: ProfileDialogConnectionWidget( name, parent, na ) {
m_lay = new QVBoxLayout( this );
m_device = new QLabel(tr( "Modem is attached to:" ), this );
m_deviceCmb = new QComboBox(this );
m_deviceCmb->setEditable( TRUE );
QLabel* telLabel = new QLabel( this );
telLabel->setText( tr( "Enter telefon number here:" ) );
m_telNumber = new QLineEdit( this );
QHBox *buttonBox = new QHBox( this );
QPushButton *atButton = new QPushButton( buttonBox );
atButton->setText( tr( "AT commands" ) );
connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) );
QPushButton *dialButton = new QPushButton( buttonBox );
dialButton->setText( tr( "Enter number" ) );
connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) );
m_base = new IOLayerBase( this, "base" );
m_lay->addWidget( m_device );
m_lay->addWidget( m_deviceCmb );
m_lay->addWidget( telLabel );
m_lay->addWidget( m_telNumber );
m_lay->addWidget( buttonBox );
m_lay->addWidget( m_base );
m_deviceCmb->insertItem( "/dev/ttyS0" );
m_deviceCmb->insertItem( "/dev/ttyS1" );
m_deviceCmb->insertItem( "/dev/ttyS2" );
atConf = new ATConfigDialog( this, "ATConfig", true );
}
ModemConfigWidget::~ModemConfigWidget() {
}
void ModemConfigWidget::load( const Profile& prof ) {
int rad_flow = prof.readNumEntry( "Flow" );
int rad_parity = prof.readNumEntry( "Parity" );
int speed = prof.readNumEntry( "Speed" );
QString number = prof.readEntry( "Number" );
if ( !number.isEmpty() ) {
m_telNumber->setText( number );
}
if ( rad_flow == 1 ) {
m_base->setFlow( IOLayerBase::Hardware );
} else if (rad_flow == 2) {
m_base->setFlow( IOLayerBase::Software );
} else if (rad_flow == 0) {
m_base->setFlow( IOLayerBase::None );
}
if ( rad_parity == 1 ) {
m_base->setParity( IOLayerBase::Even );
} else if ( rad_parity == 2 ){
m_base->setParity( IOLayerBase::Odd );
} else {
m_base->setParity( IOLayerBase::NonePar );
}
switch( speed ) {
case 115200:
m_base->setSpeed( IOLayerBase::Baud_115200 );
break;
case 57600:
m_base->setSpeed( IOLayerBase::Baud_57600 );
break;
case 38400:
m_base->setSpeed( IOLayerBase::Baud_38400 );
break;
case 19200:
m_base->setSpeed( IOLayerBase::Baud_19200 );
break;
case 9600:
default:
m_base->setSpeed( IOLayerBase::Baud_9600 );
break;
}
if ( prof.readEntry( "Device" ).isEmpty() ) {
return;
}
setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
atConf->readConfig( prof );
}
/*
* save speed,
* flow,
* parity
*/
void ModemConfigWidget::save( Profile& prof ) {
int flow, parity, speed;
+ flow = parity = speed = 0;
prof.writeEntry( "Device", m_deviceCmb->currentText() );
switch( m_base->flow() ) {
case IOLayerBase::None:
flow = 0;
break;
case IOLayerBase::Software:
flow = 2;
break;
case IOLayerBase::Hardware:
flow = 1;
break;
}
switch( m_base->parity() ) {
case IOLayerBase::Odd:
parity = 2;
break;
case IOLayerBase::Even:
parity = 1;
break;
case IOLayerBase::NonePar:
parity = 0;
break;
}
switch( m_base->speed() ) {
case IOLayerBase::Baud_115200:
speed = 115200;
break;
case IOLayerBase::Baud_57600:
speed = 57600;
break;
case IOLayerBase::Baud_38400:
speed = 38400;
break;
case IOLayerBase::Baud_19200:
speed = 19200;
break;
case IOLayerBase::Baud_9600:
speed = 9600;
break;
}
prof.writeEntry( "Flow", flow );
prof.writeEntry( "Parity", parity );
prof.writeEntry( "Speed", speed );
prof.writeEntry( "Number", m_telNumber->text() );
atConf->writeConfig(prof);
}
void ModemConfigWidget::slotAT() {
// ATConfigDialog conf( this, "ATConfig", true );
atConf->showMaximized();
if ( atConf->exec() != QDialog::Accepted ) {
// reload old settings
}
}
void ModemConfigWidget::slotDial() {
DialDialog dial( this, "DialConfig", true );
if(!m_telNumber->text().isEmpty()) {
dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), ""));
}
dial.showMaximized();
if ( dial.exec() == QDialog::Accepted ) {
m_telNumber->setText( dial.number() );
}
}
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
index ff6bea8..a44529b 100644
--- a/noncore/apps/opie-console/procctl.cpp
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -1,96 +1,97 @@
#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;
}
+ return m_self;
}
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) {
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/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 413e80b..1765d42 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -1,215 +1,214 @@
#include <qlayout.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qmessagebox.h>
#include <qstringlist.h>
#include <qcombobox.h>
#include <qcheckbox.h>
//#include "profileeditorplugins.h"
#include "metafactory.h"
#include "profileeditordialog.h"
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
for (int i = 0; i < bo->count(); i++ ) {
if ( bo->text(i) == str ) {
bo->setCurrentItem( i );
}
}
};
}
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 = m_key = 0l;
QVBoxLayout *mainLayout = new QVBoxLayout( this );
tabWidget = new OTabWidget( this );
tabWidget->setTabStyle(OTabWidget::TextTab);
mainLayout->add(tabWidget);
/* base tabs */
tabprof = new QWidget(this);
m_tabTerm = new QWidget(this);
m_tabCon = new QWidget(this);
m_tabKey = new QWidget(this);
/* base layout for tabs */
m_layCon = new QHBoxLayout( m_tabCon , 2 );
m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
m_layKey = new QHBoxLayout( m_tabKey, 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 );
m_autoConnect = new QCheckBox(tr("Auto connect after load"), 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->add(m_autoConnect);
vbox3->addStretch(1);
m_showconntab = 0;
tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
- //tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
+ tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys"));
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() ) );
slotKeyActivated( "Default Keyboard" );
setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
m_autoConnect->setChecked(m_prof.autoConnect());
// 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() ) );
m_prof.setAutoConnect( m_autoConnect->isChecked() );
if (m_con )
m_con->save( m_prof );
if (m_term )
m_term->save( m_prof );
if (m_key)
m_key->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 = new NoOptions( str, m_tabCon, "name");
}
m_con->load( m_prof );
m_layCon->addWidget( m_con );
- tabWidget->addTab( m_tabCon, "", QObject::tr("Connection") );
tabWidget->setCurrentTab( tabprof );
}
/*
* we need to switch the widget
*/
void ProfileEditorDialog::slotTermActivated( const QString& str ) {
delete m_term;
m_term = m_fact->newTerminalPlugin( str, m_tabTerm );
if (m_term) {
m_term->load(m_prof );
m_layTerm->addWidget( m_term );
}
}
void ProfileEditorDialog::slotKeyActivated(const QString &str) {
delete m_key;
m_key = m_fact->newKeyboardPlugin( str, m_tabKey );
if (m_key) {
m_key->load(m_prof);
m_layKey->addWidget(m_key);
}
}
diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp
index bd0312a..5c6d975 100644
--- a/noncore/apps/opie-console/serialconfigwidget.cpp
+++ b/noncore/apps/opie-console/serialconfigwidget.cpp
@@ -1,149 +1,149 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qcombobox.h>
#include "iolayerbase.h"
#include "serialconfigwidget.h"
namespace {
void setCurrent( const QString& str, QComboBox* bo ) {
uint b = bo->count();
- for (uint i = 0; i < bo->count(); i++ ) {
+ for (int i = 0; i < bo->count(); i++ ) {
if ( bo->text(i) == str ) {
bo->setCurrentItem( i );
return;
}
}
bo->insertItem( str );
bo->setCurrentItem( b );
}
}
SerialConfigWidget::SerialConfigWidget( const QString& name,
QWidget* parent,
const char* na )
: ProfileDialogConnectionWidget( name, parent, na ) {
m_lay = new QVBoxLayout(this );
m_device = new QLabel(tr("Device"), this );
m_deviceCmb = new QComboBox(this );
m_deviceCmb->setEditable( TRUE );
m_base = new IOLayerBase(this, "base");
m_lay->addWidget( m_device );
m_lay->addWidget( m_deviceCmb );
m_lay->addWidget( m_base );
m_deviceCmb->insertItem( "/dev/ttyS0" );
m_deviceCmb->insertItem( "/dev/ttyS1" );
m_deviceCmb->insertItem( "/dev/ttySA0");
m_deviceCmb->insertItem( "/dev/ttySA1");
}
SerialConfigWidget::~SerialConfigWidget() {
}
void SerialConfigWidget::load( const Profile& prof ) {
int rad_flow = prof.readNumEntry("Flow");
int rad_parity = prof.readNumEntry("Parity");
int speed = prof.readNumEntry("Speed");
if (rad_flow == 1) {
m_base->setFlow( IOLayerBase::Hardware );
} else if (rad_flow == 2) {
m_base->setFlow( IOLayerBase::Software );
} else {
m_base->setFlow( IOLayerBase::None );
}
if (rad_parity == 1) {
m_base->setParity( IOLayerBase::Even );
} else if ( rad_parity == 2 ) {
m_base->setParity( IOLayerBase::Odd );
} else {
m_base->setParity( IOLayerBase::NonePar );
}
switch( speed ) {
case 115200:
m_base->setSpeed(IOLayerBase::Baud_115200 );
break;
case 57600:
m_base->setSpeed( IOLayerBase::Baud_57600 );
break;
case 38400:
m_base->setSpeed(IOLayerBase::Baud_38400 );
break;
case 19200:
m_base->setSpeed( IOLayerBase::Baud_19200 );
break;
case 9600:
default:
m_base->setSpeed(IOLayerBase::Baud_9600 );
break;
}
if ( prof.readEntry("Device").isEmpty() ) return;
setCurrent( prof.readEntry("Device"), m_deviceCmb );
}
/*
* save speed,
* flow,
* parity
*/
void SerialConfigWidget::save( Profile& prof ) {
int flow, parity, speed ;
flow = parity = speed = 0;
prof.writeEntry("Device", m_deviceCmb->currentText() );
switch( m_base->flow() ) {
case IOLayerBase::None:
flow = 0;
break;
case IOLayerBase::Software:
flow = 2;
break;
case IOLayerBase::Hardware:
flow = 1;
break;
}
switch( m_base->parity() ) {
case IOLayerBase::Odd:
parity = 2;
break;
case IOLayerBase::Even:
parity = 1;
break;
case IOLayerBase::NonePar:
parity = 0;
break;
}
switch( m_base->speed() ) {
case IOLayerBase::Baud_115200:
speed = 115200;
break;
case IOLayerBase::Baud_57600:
speed = 57600;
break;
case IOLayerBase::Baud_38400:
speed = 38400;
break;
case IOLayerBase::Baud_19200:
speed = 19200;
break;
default:
case IOLayerBase::Baud_9600:
speed = 9600;
break;
}
prof.writeEntry("Flow", flow);
prof.writeEntry("Parity", parity);
prof.writeEntry("Speed", speed);
}
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp
index f89723c..75c4c72 100644
--- a/noncore/apps/opie-console/transferdialog.cpp
+++ b/noncore/apps/opie-console/transferdialog.cpp
@@ -1,266 +1,266 @@
#include <qlayout.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qprogressbar.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <opie/ofiledialog.h>
#include "file_layer.h"
#include "receive_layer.h"
#include "metafactory.h"
#include "mainwindow.h"
#include "transferdialog.h"
-TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *name)
+TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *)
: QDialog(parent, 0l, true), m_win(mainwindow)
{
m_lay = 0l;
m_recvlay = 0l;
QVBoxLayout *vbox, *vbox2;
QHBoxLayout *hbox, *hbox2, *hbox3;
QLabel *file, *mode, *progress, *status;
QButtonGroup *group;
QRadioButton *mode_send, *mode_receive;
m_autocleanup = 0;
group = new QButtonGroup(QObject::tr("Transfer mode"), this);
mode_send = new QRadioButton(QObject::tr("Send"), group);
mode_receive = new QRadioButton(QObject::tr("Receive"), group);
group->insert(mode_send, id_send);
group->insert(mode_receive, id_receive);
vbox2 = new QVBoxLayout(group, 2);
vbox2->addSpacing(10);
hbox3 = new QHBoxLayout(vbox2, 2);
hbox3->add(mode_send);
hbox3->add(mode_receive);
mode_send->setChecked(true);
m_transfermode = id_send;
file = new QLabel(QObject::tr("Send file"), this);
mode = new QLabel(QObject::tr("Transfer protocol"), this);
progress = new QLabel(QObject::tr("Progress"), this);
status = new QLabel(QObject::tr("Status"), this);
statusbar = new QLabel(QObject::tr("Ready"), this);
statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
protocol = new QComboBox(this);
QStringList list = m_win->factory()->fileTransferLayers();
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
protocol->insertItem((*it));
filename = new QLineEdit(this);
progressbar = new QProgressBar(this);
progressbar->setProgress(0);
selector = new QPushButton("...", this);
ok = new QPushButton(QObject::tr("Start transfer"), this);
cancel = new QPushButton(QObject::tr("Cancel"), this);
vbox = new QVBoxLayout(this, 2);
vbox->add(group);
vbox->add(file);
hbox = new QHBoxLayout(vbox, 0);
hbox->add(filename);
hbox->add(selector);
vbox->add(mode);
vbox->add(protocol);
vbox->add(progress);
vbox->add(progressbar);
vbox->add(status);
vbox->add(statusbar);
vbox->addStretch(1);
hbox2 = new QHBoxLayout(vbox, 2);
hbox2->add(ok);
hbox2->add(cancel);
setCaption(QObject::tr("File transfer"));
show();
connect(selector, SIGNAL(clicked()), SLOT(slotFilename()));
connect(ok, SIGNAL(clicked()), SLOT(slotTransfer()));
connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int)));
}
TransferDialog::~TransferDialog()
{
}
void TransferDialog::slotFilename()
{
QString f;
f = OFileDialog::getOpenFileName(0);
if(!f.isNull()) filename->setText(f);
}
void TransferDialog::slotTransfer()
{
if((m_transfermode == id_send) && (filename->text().isEmpty()))
{
QMessageBox::information(this,
QObject::tr("Attention"),
QObject::tr("No file has been specified."));
return;
}
ok->setEnabled(false);
cleanup();
m_autocleanup = 0;
if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending..."));
else statusbar->setText(QObject::tr("Receiving..."));
if(m_transfermode == id_send)
{
m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer());
m_lay->sendFile(filename->text());
connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)),
SLOT(slotProgress(const QString&, int, int, int, int, int)));
connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
connect(m_lay, SIGNAL(sent()), SLOT(slotSent()));
}
else
{
m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer());
m_recvlay->receive();
connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)),
SLOT(slotProgress(const QString&, int, int, int, int, int)));
connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&)));
connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&)));
}
}
void TransferDialog::cleanup()
{
if(m_lay)
{
m_lay->cancel();
delete m_lay;
m_lay = 0l;
}
if(m_recvlay)
{
m_recvlay->cancel();
delete m_recvlay;
m_recvlay = 0l;
}
}
void TransferDialog::slotCancel()
{
ok->setEnabled(true);
statusbar->setText(QObject::tr("Ready"));
if((m_lay) || (m_recvlay))
{
cleanup();
if(m_autocleanup) close();
else
{
QMessageBox::information(this,
QObject::tr("Cancelled"),
QObject::tr("The file transfer has been cancelled."));
}
}
else
{
close();
}
}
-void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds)
+void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int )
{
progressbar->setProgress(progress);
}
-void TransferDialog::slotError(int error, const QString& message)
+void TransferDialog::slotError(int error, const QString& )
{
statusbar->setText(QObject::tr("Ready"));
switch(error)
{
case FileTransferLayer::NotSupported:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Operation not supported."));
break;
case FileTransferLayer::StartError:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Transfer could not be started."));
break;
case FileTransferLayer::NoError:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("No error."));
break;
case FileTransferLayer::Undefined:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Undefined error occured."));
break;
case FileTransferLayer::Incomplete:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Incomplete transfer."));
break;
case FileTransferLayer::Unknown:
default:
QMessageBox::critical(this,
QObject::tr("Error"),
QObject::tr("Unknown error occured."));
break;
}
m_autocleanup = 1;
}
void TransferDialog::slotSent()
{
progressbar->setProgress(100);
QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent."));
ok->setEnabled(true);
progressbar->setProgress(0);
statusbar->setText(QObject::tr("Ready"));
m_autocleanup = 1;
}
-void TransferDialog::slotReceived(const QString& file)
+void TransferDialog::slotReceived(const QString& )
{
progressbar->setProgress(100);
QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received."));
//QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file));
ok->setEnabled(true);
progressbar->setProgress(0);
statusbar->setText(QObject::tr("Ready"));
m_autocleanup = 1;
}
void TransferDialog::slotMode(int id)
{
if(id == id_send)
{
selector->setEnabled(true);
filename->setEnabled(true);
}
else
{
selector->setEnabled(false);
filename->setEnabled(false);
}
m_transfermode = id;
}