summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialdialog.cpp8
-rw-r--r--noncore/apps/opie-console/dialdialog.h2
-rw-r--r--noncore/apps/opie-console/dialer.cpp5
-rw-r--r--noncore/apps/opie-console/io_modem.cpp8
-rw-r--r--noncore/apps/opie-console/io_modem.h2
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp5
6 files changed, 21 insertions, 9 deletions
diff --git a/noncore/apps/opie-console/dialdialog.cpp b/noncore/apps/opie-console/dialdialog.cpp
index 8bf32f9..0ace8f7 100644
--- a/noncore/apps/opie-console/dialdialog.cpp
+++ b/noncore/apps/opie-console/dialdialog.cpp
@@ -31,65 +31,73 @@ DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags f
LCD->setNumDigits( 25 );
LCD->setSegmentStyle( QLCDNumber::Flat );
LCD->setMaximumHeight( 30 );
QGridLayout *layout = new QGridLayout( this , 4, 3 );
QButtonGroup *dialButtons = new QButtonGroup( );
QPushButton *number0 = new QPushButton( this );
number0->setText( QString( "0" ) );
QFont number0_font( number0->font() );
number0_font.setBold( TRUE );
number0->setFont( number0_font );
layout->addWidget( number0, 4, 1 );
dialButtons->insert( number0 );
int x = 0, y = 0;
for ( int i = 0 ; i < 9; i++ ) {
QPushButton *number = new QPushButton( this );
number->setText( QString( "%1" ).arg( i + 1 ) );
QFont number_font( number->font() );
number_font.setBold( TRUE );
number->setFont( number_font );
dialButtons->insert( number );
layout->addWidget( number, x, y );
if ( y < 2 ) {
y++;
} else {
x++;
y = 0;
}
}
connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) );
mainLayout->addStretch( 0 );
mainLayout->addWidget( textLabel );
mainLayout->addWidget( LCD );
mainLayout->addStretch( 0 );
mainLayout->addLayout( layout );
mainLayout->addStretch( 0 );
}
void DialDialog::slotEnterNumber( int number ) {
// pretty stupid, just for testing .-)
m_number = ( m_number * 10 ) + number;
qDebug( QString("%1").arg( m_number ) );
LCD->display( m_number );
}
DialDialog::~DialDialog() {
}
QString DialDialog::number() {
return QString( "%1").arg( m_number );
+
}
+
+void DialDialog::setNumber( int number )
+{
+ m_number = number;
+ LCD->display( m_number );
+}
+
diff --git a/noncore/apps/opie-console/dialdialog.h b/noncore/apps/opie-console/dialdialog.h
index 5c5b948..bec7b81 100644
--- a/noncore/apps/opie-console/dialdialog.h
+++ b/noncore/apps/opie-console/dialdialog.h
@@ -1,29 +1,31 @@
#ifndef DIALDIALOG_H
#define DIALDIALOG_H
#include <qdialog.h>
#include <qstring.h>
#include <qlcdnumber.h>
class DialDialog : public QDialog {
Q_OBJECT
public:
DialDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~DialDialog();
QString number();
+ void setNumber( int );
+
private:
float m_number;
QLCDNumber *LCD;
private slots:
void slotEnterNumber( int );
};
#endif
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index 90e2b6c..89a0e8d 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -64,153 +64,154 @@ Dialer::Dialer(const Profile& profile, QWidget *parent, const char *name)
vbox->add(status);
vbox->add(cancel);
connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
show();
QTimer::singleShot(500, this, SLOT(slotAutostart()));
}
Dialer::~Dialer()
{
}
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)
{
trydial(number);
}
else break;
}
if(usercancel)
{
reject();
}
}
void Dialer::trydial(const QString& number)
{
if(state != state_cancel)
{
switchState(state_preinit);
// ...
QString response = receive();
}
if(state != state_cancel)
{
switchState(state_init);
- send("ATZ");
+ //send("ATZ");
+ send(m_profile.readEntry("InitString"));
QString response2 = receive();
}
if(state != state_cancel)
{
switchState(state_options);
send("ATM0L0");
QString response3 = receive();
}
if(state != state_cancel)
{
switchState(state_dialtone);
send("ATX1");
QString response4 = receive();
}
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(state != state_cancel)
{
switchState(state_online);
}
}
void Dialer::send(const QString& msg)
{
QString m = msg;
int bytes;
QString termination;
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(0, m.local8Bit(), strlen(m.local8Bit()));
if(bytes < 0)
{
reset();
}
}
QString Dialer::receive()
{
for(int i = 0; i < 200000;i++)
qApp->processEvents();
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"));
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index d93dc5a..22a3673 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -1,80 +1,78 @@
#include "io_modem.h"
#include "dialer.h"
IOModem::IOModem( const Profile &profile )
- : IOSerial( profile ), m_profile( profile ) {
+ : IOSerial( profile ) {
+ m_profile = profile;
}
IOModem::~IOModem() {
}
void IOModem::close() {
+ // maybe do a hangup here just in case...?
IOSerial::close();
-
}
bool IOModem::open() {
bool ret = IOSerial::open();
if(!ret) return false;
- qWarning("IOModem::open continues...");
-
Dialer d(m_profile);
- qWarning("dialer created");
int result = d.exec();
if(result == QDialog::Accepted)
{
return true;
}
else 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();
}
diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h
index d681f66..8453b95 100644
--- a/noncore/apps/opie-console/io_modem.h
+++ b/noncore/apps/opie-console/io_modem.h
@@ -1,71 +1,71 @@
#ifndef OPIE_IO_MODEM
#define OPIE_IO_MODEM
#include <opie/oprocess.h>
#include "io_serial.h"
#include "profile.h"
/* Default values to be used if the profile information is incomplete */
#define MODEM_DEFAULT_DEVICE "/dev/ttyS0"
#define MODEM_DEFAULT_BAUD 9600
#define MODEM_DEFAULT_PARITY 0
#define MODEM_DEFAULT_DBITS 8
#define MODEM_DEFAULT_SBITS 1
#define MODEM_DEFAULT_FLOW 0
#define MODEM_DEFAULT_INIT_STRING "~^M~ATZ^M~"
#define MODEM_DEFAULT_RESET_STRING "~^M~ATZ^M~"
#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT"
#define MODEM_DEFAULT_DIAL_SUFFIX1 "^M"
#define MODEM_DEFAULT_DIAL_PREFIX2 "ATDP"
#define MODEM_DEFAULT_DIAL_SUFFIX2 "^M"
#define MODEM_DEFAULT_DIAL_PREFIX3 "ATX1DT"
#define MODEM_DEFAULT_DIAL_SUFFIX3 ";X4D^M"
#define MODEM_DEFAULT_CONNECT_STRING "CONNECT"
#define MODEM_DEFAULT_HANGUP_STRING "~~+++~~ATH^M"
#define MODEM_DEFAULT_CANCEL_STRING "^M"
#define MODEM_DEFAULT_DIAL_TIME 45
#define MODEM_DEFAULT_DELAY_REDIAL 2
#define MODEM_DEFAULT_NUMBER_TRIES 10
#define MODEM_DEFAULT_DTR_DROP_TIME 1
#define MODEM_DEFAULT_BPS_DETECT 0 // bool
#define MODEM_DEFAULT_DCD_LINES 1 //bool
#define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool
/* IOSerial implements a RS232 IO Layer */
class IOModem : public IOSerial {
Q_OBJECT
public:
IOModem(const Profile &);
~IOModem();
QString identifier() const;
QString name() const;
signals:
void received(const QByteArray &);
void error(int, const QString &);
public slots:
bool open();
void close();
void reload(const Profile &);
private:
QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2,
m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel;
int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime,
m_bpsDetect, m_dcdLines, m_multiLineUntag;
- const Profile& m_profile;
+ Profile m_profile;
private slots:
void slotExited(OProcess* proc);
};
#endif
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index 0f0ce7c..878b0cf 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -1,71 +1,71 @@
#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++ ) {
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" );
@@ -126,69 +126,72 @@ void ModemConfigWidget::load( const Profile& prof ) {
*/
void ModemConfigWidget::save( Profile& prof ) {
int flow, parity, speed;
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() );
}
void ModemConfigWidget::slotAT() {
// ATConfigDialog conf( this, "ATConfig", true );
atConf->showMaximized();
if ( atConf->exec() == QDialog::Accepted ) {
// atConf->writeConfig();
}
}
void ModemConfigWidget::slotDial() {
DialDialog dial( this, "DialConfig", true );
+ if(!m_telNumber->text().isEmpty()) {
+ dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ ]"), "").toInt());
+ }
dial.showMaximized();
if ( dial.exec() == QDialog::Accepted ) {
m_telNumber->setText( dial.number() );
}
}