Diffstat (limited to 'noncore/settings/networksettings/ppp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/connect.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/general.cpp | 34 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/general.h | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 12 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.h | 19 |
6 files changed, 45 insertions, 44 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 128877a..8981e01 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp @@ -1215,8 +1215,8 @@ bool ConnectWidget::execppp() { if(_ifaceppp->data()->subnetmask() != "0.0.0.0") command += " netmask " + _ifaceppp->data()->subnetmask(); - if(_ifaceppp->data()->flowcontrol() != "None") { - if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") + if(_ifaceppp->data()->flowcontrol() != PPPData::FlowNone) { + if(_ifaceppp->data()->flowcontrol() == PPPData::FlowHardware) command += " crtscts"; else command += " xonxoff"; diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index 5e2a04f..9457173 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp @@ -192,17 +192,10 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) QWhatsThis::add(baud_label,tmp); QWhatsThis::add(baud_c,tmp); - for(int i=0; i <= enter->count()-1; i++) - { - if(_pppdata->enter() == enter->text(i)) - enter->setCurrentItem(i); - } - tl->addRowSpacing(5, 10); //Modem Lock File modemlockfile = new QCheckBox(tr("&Use lock file"), this); - modemlockfile->setChecked(_pppdata->modemLockFile()); // connect(modemlockfile, SIGNAL(toggled(bool)), // SLOT(modemlockfilechanged(bool))); @@ -240,11 +233,8 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) "recommended value is 30 seconds.")); //set stuff from gpppdata - for(int i=0; i <= enter->count()-1; i++) - { - if(_pppdata->enter() == enter->text(i)) - enter->setCurrentItem(i); - } + enter->setCurrentItem( static_cast<int>(_pppdata->enter()) ); + flowcontrol->setCurrentItem( static_cast<int>( _pppdata->flowcontrol() ) ); for(int i=0; i <= modemdevice->count()-1; i++) { @@ -252,12 +242,6 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) modemdevice->setCurrentItem(i); } - for(int i=0; i <= flowcontrol->count()-1; i++) - { - if(_pppdata->flowcontrol() == flowcontrol->text(i)) - flowcontrol->setCurrentItem(i); - } - //set the modem speed for(int i=0; i < baud_c->count(); i++) if(baud_c->text(i) == _pppdata->speed()) @@ -338,8 +322,8 @@ bool ModemWidget::save() _pppdata->setDevname( modemname->text() ); _pppdata->setModemDevice( modemdevice->currentText() ); - _pppdata->setFlowcontrol(flowcontrol->currentText()); - _pppdata->setFlowcontrol(flowcontrol->currentText()); + _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem())); + _pppdata->setEnter( static_cast<PPPData::LineTermination>(enter->currentItem())); _pppdata->setSpeed(baud_c->currentText()); _pppdata->setModemLockFile( modemlockfile->isChecked()); _pppdata->setModemTimeout( modemtimeout->value() ); @@ -350,15 +334,16 @@ bool ModemWidget::save() void ModemWidget::slotBeforeModemQuery() { m_oldModemDev = _pppdata->modemDevice(); - m_oldFlowControl = _pppdata->flowcontrol(); + m_oldFlowControl = static_cast<int>( _pppdata->flowcontrol() ); m_oldSpeed = _pppdata->speed(); m_oldModemLock = _pppdata->modemLockFile(); m_oldModemTimeout = _pppdata->modemTimeout(); + m_oldLineEnd = static_cast<int>( _pppdata->enter() ); _pppdata->setModemDevice( modemdevice->currentText() ); - _pppdata->setFlowcontrol(flowcontrol->currentText()); - _pppdata->setFlowcontrol(flowcontrol->currentText()); + _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem())); + _pppdata->setEnter(static_cast<PPPData::LineTermination>(enter->currentItem())); _pppdata->setSpeed(baud_c->currentText()); _pppdata->setModemLockFile( modemlockfile->isChecked()); _pppdata->setModemTimeout( modemtimeout->value() ); @@ -368,7 +353,8 @@ void ModemWidget::slotBeforeModemQuery() void ModemWidget::slotAfterModemQuery() { _pppdata->setModemDevice( m_oldModemDev ); - _pppdata->setFlowcontrol( m_oldFlowControl ); + _pppdata->setFlowcontrol( static_cast<PPPData::FlowControl>(m_oldFlowControl) ); + _pppdata->setEnter( static_cast<PPPData::LineTermination>(m_oldLineEnd) ); _pppdata->setSpeed( m_oldSpeed ); _pppdata->setModemLockFile( m_oldModemLock ); _pppdata->setModemTimeout( m_oldModemTimeout ); diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h index a4dece4..0bb3136 100644 --- a/noncore/settings/networksettings/ppp/general.h +++ b/noncore/settings/networksettings/ppp/general.h @@ -81,9 +81,9 @@ private: PPPData *_pppdata; private: - QString m_oldModemDev, m_oldFlowControl, m_oldSpeed; + QString m_oldModemDev, m_oldSpeed; bool m_oldModemLock; - int m_oldModemTimeout; + int m_oldModemTimeout, m_oldFlowControl, m_oldLineEnd; }; diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index 79f015b..7b2e2a3 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp @@ -225,8 +225,8 @@ bool Modem::opentty() { tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); - if(_pppdata->flowcontrol() != "None") { - if(_pppdata->flowcontrol() == "CRTSCTS") { + if(_pppdata->flowcontrol() != PPPData::FlowNone) { + if(_pppdata->flowcontrol() == PPPData::FlowHardware) { tty.c_cflag |= CRTSCTS; } else { @@ -355,15 +355,19 @@ bool Modem::writeLine(const char *buf) { char *b = new char[len+2]; memcpy(b, buf, len); // different modems seem to need different line terminations - QString term = _pppdata->enter(); - if(term == "LF") + switch( _pppdata->enter() ) { + case PPPData::EndLF: b[len++]='\n'; - else if(term == "CR") + break; + case PPPData::EndCR: b[len++]='\r'; - else if(term == "CR/LF") { + break; + case PPPData::EndCRLF: b[len++]='\r'; b[len++]='\n'; + break; } + int l = len; while(l) { int wr = write(modemfd, &b[len-l], l); diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index eb03ef4..1491ea2 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp @@ -387,12 +387,12 @@ bool PPPData::setModemDevice(const QString &n) { } -const QString PPPData::flowcontrol() { - return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); +enum PPPData::FlowControl PPPData::flowcontrol() { + return static_cast<FlowControl>(readNumConfig(modemGroup(), FLOWCONTROL_KEY, FlowHardware)); } -void PPPData::setFlowcontrol(const QString &n) { +void PPPData::setFlowcontrol(enum FlowControl n) { writeConfig(modemGroup(), FLOWCONTROL_KEY, n); } @@ -720,12 +720,12 @@ void PPPData::setModemAnswerResp(const QString &n) { } -const QString PPPData::enter() { - return readConfig(modemGroup(), ENTER_KEY, "CR"); +enum PPPData::LineTermination PPPData::enter(){ + return static_cast<PPPData::LineTermination>(readNumConfig(modemGroup(), ENTER_KEY, EndCR)); } -void PPPData::setEnter(const QString &n) { +void PPPData::setEnter(enum PPPData::LineTermination n) { writeConfig(modemGroup(), ENTER_KEY, n); } diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index d1cbeb5..d731b62 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h @@ -165,6 +165,17 @@ public: ~PPPData() {}; enum { NumInitStrings = 2 }; + enum LineTermination { + EndCR, + EndLF, + EndCRLF + }; + + enum FlowControl { + FlowHardware, + FlowSoftware, + FlowNone + }; // general functions void save(); @@ -222,8 +233,8 @@ public: // void set_dock_into_panel(bool set); // bool get_dock_into_panel(); - const QString enter(); - void setEnter(const QString &); + enum LineTermination enter(); + void setEnter(enum LineTermination); QString pppdVersion(); bool pppdVersionMin(int ver, int mod, int patch); @@ -253,8 +264,8 @@ public: const QString modemDevice(); bool setModemDevice(const QString &); - const QString flowcontrol(); - void setFlowcontrol(const QString &); + enum FlowControl flowcontrol(); + void setFlowcontrol(enum FlowControl); int modemTimeout(); void setModemTimeout(int); |