author | zecke <zecke> | 2002-10-29 19:07:22 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-29 19:07:22 (UTC) |
commit | a575fd4c862693705018902b4482c5135a8cb6a2 (patch) (side-by-side diff) | |
tree | bcdfd7b2b8f62b2fb766b8b8808e17c96668563c | |
parent | 5ac67b8aece5aca20419f8953f88a36fd729adfc (diff) | |
download | opie-a575fd4c862693705018902b4482c5135a8cb6a2.zip opie-a575fd4c862693705018902b4482c5135a8cb6a2.tar.gz opie-a575fd4c862693705018902b4482c5135a8cb6a2.tar.bz2 |
Make the Modem take custom Ats again
Supply default values
set labels to richtext this way we achieve word wrap
IO_Layer added a closed(IOLayer*) signal
ProfileEditorDialog make Horizontal scrolling on the QScrollView
possible. Once the Vertical Scrollbar is there the Modem dialog
does not have enough space
-rw-r--r-- | noncore/apps/opie-console/atconfigdialog.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/dialdialog.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 26 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_layer.h | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_modem.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/modemconfigwidget.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 4 |
8 files changed, 30 insertions, 25 deletions
diff --git a/noncore/apps/opie-console/atconfigdialog.cpp b/noncore/apps/opie-console/atconfigdialog.cpp index 5c02692..e683ab3 100644 --- a/noncore/apps/opie-console/atconfigdialog.cpp +++ b/noncore/apps/opie-console/atconfigdialog.cpp @@ -132,48 +132,49 @@ QWidget* ATConfigDialog::tab1( QWidget* parent ) { layout->addWidget( bpsDetectBox, 4, 1 ); bpsDetectBox->insertItem( tr("No") ); bpsDetectBox->insertItem( tr("Yes") ); QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget ); dcdLinesBox = new QComboBox( returnWidget ); layout->addWidget( dcdLinesLabel, 5, 0 ); layout->addWidget( dcdLinesBox, 5, 1 ); dcdLinesBox->insertItem( tr("No") ); dcdLinesBox->insertItem( tr("Yes") ); QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget ); multiLineUntagBox = new QComboBox( returnWidget ); layout->addWidget( multiLineUntagLabel, 6, 0 ); layout->addWidget( multiLineUntagBox, 6, 1 ); multiLineUntagBox->insertItem( tr("No") ); multiLineUntagBox->insertItem( tr("Yes") ); return returnWidget; } void ATConfigDialog::readConfig( const Profile& config ) { + qWarning("config in atconfigdialog"); initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 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 ) ); dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) ); delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) ); numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) ); dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) ); bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) ); dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) ); multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) ); // Not implemented yet resetStringLine->setEnabled(false); dialSuf1Line->setEnabled(false); dialPref2Line->setEnabled(false); dialSuf2Line->setEnabled(false); diff --git a/noncore/apps/opie-console/dialdialog.cpp b/noncore/apps/opie-console/dialdialog.cpp index ac1e1db..b91727b 100644 --- a/noncore/apps/opie-console/dialdialog.cpp +++ b/noncore/apps/opie-console/dialdialog.cpp @@ -1,46 +1,47 @@ #include <qlayout.h> #include <qlabel.h> #include <qcombobox.h> #include <qscrollview.h> #include <qpushbutton.h> #include <qfont.h> #include <qbuttongroup.h> #include "dialdialog.h" DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { setCaption( tr( "Enter number" ) ); QVBoxLayout *mainLayout = new QVBoxLayout( this ); QLabel *textLabel = new QLabel( this ); + textLabel->setTextFormat( QLabel::RichText ); textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") ); m_dialLine = new QLineEdit( this ); m_dialLine->setReadOnly( true ); m_dialLine->setFrame( false ); m_dialLine->setAlignment( Qt::AlignLeft ); QFont dialLine_font( m_dialLine->font() ); dialLine_font.setBold( TRUE ); dialLine_font.setPointSize( 18 ); m_dialLine->setFont( dialLine_font ); QWidget* dialWidget = new QWidget( this ); QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 ); QButtonGroup *dialButtons = new QButtonGroup( ); QPushButton *number0 = new QPushButton( dialWidget ); 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 ); diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 8524422..67ad10e 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp @@ -1,116 +1,114 @@ #include "dialer.h" #include <qlayout.h> #include <qprogressbar.h> #include <qlabel.h> #include <qpushbutton.h> #include <qapp.h> #include <qtimer.h> #include <qmessagebox.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <errno.h> +#include "io_modem.h" + // State machine: | When an error occurs, we don't have to // | reset everything. // (init) <------+ | But if the user wants to reset, // | | | we stop dialing immediately. // v | | // (options) ----+ | Following the state machine is necessary // | \ | to get determinable results. // v ^ | // (dial) ----+ | // | ^ | // v | | // (online) --+ | // | | // v | // from atconfigdialog //initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); //resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); //dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); //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; - send("+++ATH\r"); + send( m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING )+"\r" ); } void Dialer::slotCancel() { if(state != state_online) { usercancel = 1; reset(); } else { accept(); } } void Dialer::reset() { qWarning("reset"); switchState(state_cancel); } void Dialer::slotAutostart() { //state = state_preinit; dial(m_profile.readEntry("Number")); @@ -121,95 +119,93 @@ 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) { qWarning("TryDial:%s", number.latin1() ); if(state != state_cancel) switchState(state_preinit); if(cleanshutdown) { - qWarning("HangupString " + m_profile.readEntry("HangupString")); - //send(m_profile.readEntry("HangupString")); - send("+++ATH\r"); - //send(""); + qWarning("HangupString " + m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING)); + send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); } if(state != state_cancel) { switchState(state_init); - //send("ATZ"); - qWarning("Init String " + m_profile.readEntry("InitString") ); -// send(m_profile.readEntry("InitString", "AT")); - send("AT\r"); +// qWarning("Init String " + m_profile.readEntry("InitString") ); + send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); QString response2 = receive(); if(!response2.contains("\nOK\r")) reset(); } /* if(state != state_cancel) { switchState(state_options); qWarning("ATM3l3"); send("ATM3L3\r"); QString response3 = receive(); if(!response3.contains("\nOK\r")) reset(); } */ if(state != state_cancel) { switchState(state_dialtone); send("ATX1\r"); QString response4 = receive(); if(!response4.contains("\nOK\r")) reset(); } if(state != state_cancel) { qWarning("progress"); switchState(state_dialing); - send(QString("ATDT %1\r").arg(number)); -// send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); +// send(QString("ATDT %1\r").arg(number)); + send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) + .arg(number)); + QString response5 = receive(); if(!response5.contains("CONNECT") ) { 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) { state = state_online; slotCancel(); } } void Dialer::send(const QString& msg) diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h index af61099..ed4478b 100644 --- a/noncore/apps/opie-console/io_layer.h +++ b/noncore/apps/opie-console/io_layer.h @@ -73,49 +73,55 @@ public: */ virtual void closeRawIO(int); /** * What does the IOLayer support? * Bits are related to features */ virtual QBitArray supports()const = 0; virtual bool isConnected() = 0; signals: /** * received input as QCString */ virtual void received( const QByteArray& ); /** * an error occured * int for the error number * and QString for a text */ virtual void error( int, const QString& ); + virtual void closed(); + + /* signal emitted for closure of the IOLayer + * for some reasons + */ + virtual void closed(IOLayer*); public slots: /** * send a QCString to the device */ virtual void send( const QByteArray& ) = 0; /** * bool open */ virtual bool open() = 0; /** * close the io */ virtual void close() = 0; /** * closes and reloads the settings */ virtual void reload( const Profile& ) = 0; /** * set the size * needed for pty diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h index 1328706..17228bd 100644 --- a/noncore/apps/opie-console/io_modem.h +++ b/noncore/apps/opie-console/io_modem.h @@ -1,40 +1,40 @@ #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 "ATZ" +#define MODEM_DEFAULT_INIT_STRING "AT" #define MODEM_DEFAULT_RESET_STRING "ATZ~" #define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" #define MODEM_DEFAULT_DIAL_SUFFIX1 "" #define MODEM_DEFAULT_DIAL_PREFIX2 "" #define MODEM_DEFAULT_DIAL_SUFFIX2 "" #define MODEM_DEFAULT_DIAL_PREFIX3 "" #define MODEM_DEFAULT_DIAL_SUFFIX3 "" #define MODEM_DEFAULT_CONNECT_STRING "CONNECT" #define MODEM_DEFAULT_HANGUP_STRING "+++ATH" #define MODEM_DEFAULT_CANCEL_STRING "" #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 diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index 03e92dd..ddd4994 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp @@ -145,53 +145,49 @@ int IOSerial::baud(int baud) const { 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; - qWarning("got from layer"); - for (int i = 0; i < len; i++ ) { - printf("%c", array[i] ); - } - printf("\n"); + 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())); diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp index 37eb184..f7fb6f3 100644 --- a/noncore/apps/opie-console/modemconfigwidget.cpp +++ b/noncore/apps/opie-console/modemconfigwidget.cpp @@ -111,55 +111,56 @@ void ModemConfigWidget::load( const Profile& prof ) { m_base->setSpeed( IOLayerBase::Baud_9600 ); break; } if ( dbits == 5) { m_base->setData( IOLayerBase::Data_Five ); } else if (rad_flow == 6) { m_base->setData( IOLayerBase::Data_Six ); } else if (rad_flow == 7) { m_base->setData( IOLayerBase::Data_Seven ); } else { m_base->setData( IOLayerBase::Data_Eight ); } if ( sbits == 2) { m_base->setStop( IOLayerBase::Stop_Two ); } else if ( sbits == 15 ) { m_base->setStop( IOLayerBase::Stop_OnePointFive ); } else { m_base->setStop( IOLayerBase::Stop_One ); } - + atConf->readConfig( prof ); if ( prof.readEntry( "Device" ).isEmpty() ) { + qWarning("device empty!"); return; } setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); - atConf->readConfig( prof ); + } /* * save speed, * flow, * parity */ void ModemConfigWidget::save( Profile& prof ) { int flow, parity, speed, data, stop; flow = parity = speed = data = stop = 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; } @@ -213,40 +214,44 @@ void ModemConfigWidget::save( Profile& prof ) { case IOLayerBase::Stop_One: stop = 1; break; case IOLayerBase::Stop_OnePointFive: stop = 15; break; case IOLayerBase::Stop_Two: stop = 2; break; } prof.writeEntry( "Flow", flow ); prof.writeEntry( "Parity", parity ); prof.writeEntry( "Speed", speed ); prof.writeEntry("DataBits", data); prof.writeEntry("StopBits", stop); prof.writeEntry( "Number", m_telNumber->text() ); atConf->writeConfig(prof); } void ModemConfigWidget::slotAT() { // ATConfigDialog conf( this, "ATConfig", true ); + // josef/Max I know why don't you create the stuff on the stack + // but making it a TopLevel Dialog and ignoring + // cancel is not fun either... + // what to do? FIXME!!! -zecke 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/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 36daaef..fd04b6b 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -45,53 +45,53 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 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); m_svCon = new QScrollView( m_tabCon ); m_svCon->setResizePolicy( QScrollView::AutoOneFit ); - m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); + //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); m_svCon->setFrameShape( QFrame::NoFrame ); m_svTerm = new QScrollView( m_tabTerm ); m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); - m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); + //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); m_svTerm->setFrameShape( QFrame::NoFrame ); /* 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 ); m_layCon->addWidget( m_svCon ); m_layTerm->addWidget( m_svTerm ); // 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); |