summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp34
-rw-r--r--noncore/settings/networksettings/ppp/general.h4
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp16
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp12
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h19
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() {
1215 if(_ifaceppp->data()->subnetmask() != "0.0.0.0") 1215 if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
1216 command += " netmask " + _ifaceppp->data()->subnetmask(); 1216 command += " netmask " + _ifaceppp->data()->subnetmask();
1217 1217
1218 if(_ifaceppp->data()->flowcontrol() != "None") { 1218 if(_ifaceppp->data()->flowcontrol() != PPPData::FlowNone) {
1219 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") 1219 if(_ifaceppp->data()->flowcontrol() == PPPData::FlowHardware)
1220 command += " crtscts"; 1220 command += " crtscts";
1221 else 1221 else
1222 command += " xonxoff"; 1222 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 )
192 QWhatsThis::add(baud_label,tmp); 192 QWhatsThis::add(baud_label,tmp);
193 QWhatsThis::add(baud_c,tmp); 193 QWhatsThis::add(baud_c,tmp);
194 194
195 for(int i=0; i <= enter->count()-1; i++)
196 {
197 if(_pppdata->enter() == enter->text(i))
198 enter->setCurrentItem(i);
199 }
200
201 tl->addRowSpacing(5, 10); 195 tl->addRowSpacing(5, 10);
202 196
203 //Modem Lock File 197 //Modem Lock File
204 modemlockfile = new QCheckBox(tr("&Use lock file"), this); 198 modemlockfile = new QCheckBox(tr("&Use lock file"), this);
205
206 modemlockfile->setChecked(_pppdata->modemLockFile()); 199 modemlockfile->setChecked(_pppdata->modemLockFile());
207 // connect(modemlockfile, SIGNAL(toggled(bool)), 200 // connect(modemlockfile, SIGNAL(toggled(bool)),
208 // SLOT(modemlockfilechanged(bool))); 201 // SLOT(modemlockfilechanged(bool)));
@@ -240,11 +233,8 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
240 "recommended value is 30 seconds.")); 233 "recommended value is 30 seconds."));
241 234
242 //set stuff from gpppdata 235 //set stuff from gpppdata
243 for(int i=0; i <= enter->count()-1; i++) 236 enter->setCurrentItem( static_cast<int>(_pppdata->enter()) );
244 { 237 flowcontrol->setCurrentItem( static_cast<int>( _pppdata->flowcontrol() ) );
245 if(_pppdata->enter() == enter->text(i))
246 enter->setCurrentItem(i);
247 }
248 238
249 for(int i=0; i <= modemdevice->count()-1; i++) 239 for(int i=0; i <= modemdevice->count()-1; i++)
250 { 240 {
@@ -252,12 +242,6 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
252 modemdevice->setCurrentItem(i); 242 modemdevice->setCurrentItem(i);
253 } 243 }
254 244
255 for(int i=0; i <= flowcontrol->count()-1; i++)
256 {
257 if(_pppdata->flowcontrol() == flowcontrol->text(i))
258 flowcontrol->setCurrentItem(i);
259 }
260
261 //set the modem speed 245 //set the modem speed
262 for(int i=0; i < baud_c->count(); i++) 246 for(int i=0; i < baud_c->count(); i++)
263 if(baud_c->text(i) == _pppdata->speed()) 247 if(baud_c->text(i) == _pppdata->speed())
@@ -338,8 +322,8 @@ bool ModemWidget::save()
338 322
339 _pppdata->setDevname( modemname->text() ); 323 _pppdata->setDevname( modemname->text() );
340 _pppdata->setModemDevice( modemdevice->currentText() ); 324 _pppdata->setModemDevice( modemdevice->currentText() );
341 _pppdata->setFlowcontrol(flowcontrol->currentText()); 325 _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem()));
342 _pppdata->setFlowcontrol(flowcontrol->currentText()); 326 _pppdata->setEnter( static_cast<PPPData::LineTermination>(enter->currentItem()));
343 _pppdata->setSpeed(baud_c->currentText()); 327 _pppdata->setSpeed(baud_c->currentText());
344 _pppdata->setModemLockFile( modemlockfile->isChecked()); 328 _pppdata->setModemLockFile( modemlockfile->isChecked());
345 _pppdata->setModemTimeout( modemtimeout->value() ); 329 _pppdata->setModemTimeout( modemtimeout->value() );
@@ -350,15 +334,16 @@ bool ModemWidget::save()
350void ModemWidget::slotBeforeModemQuery() 334void ModemWidget::slotBeforeModemQuery()
351{ 335{
352 m_oldModemDev = _pppdata->modemDevice(); 336 m_oldModemDev = _pppdata->modemDevice();
353 m_oldFlowControl = _pppdata->flowcontrol(); 337 m_oldFlowControl = static_cast<int>( _pppdata->flowcontrol() );
354 m_oldSpeed = _pppdata->speed(); 338 m_oldSpeed = _pppdata->speed();
355 m_oldModemLock = _pppdata->modemLockFile(); 339 m_oldModemLock = _pppdata->modemLockFile();
356 m_oldModemTimeout = _pppdata->modemTimeout(); 340 m_oldModemTimeout = _pppdata->modemTimeout();
341 m_oldLineEnd = static_cast<int>( _pppdata->enter() );
357 342
358 343
359 _pppdata->setModemDevice( modemdevice->currentText() ); 344 _pppdata->setModemDevice( modemdevice->currentText() );
360 _pppdata->setFlowcontrol(flowcontrol->currentText()); 345 _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem()));
361 _pppdata->setFlowcontrol(flowcontrol->currentText()); 346 _pppdata->setEnter(static_cast<PPPData::LineTermination>(enter->currentItem()));
362 _pppdata->setSpeed(baud_c->currentText()); 347 _pppdata->setSpeed(baud_c->currentText());
363 _pppdata->setModemLockFile( modemlockfile->isChecked()); 348 _pppdata->setModemLockFile( modemlockfile->isChecked());
364 _pppdata->setModemTimeout( modemtimeout->value() ); 349 _pppdata->setModemTimeout( modemtimeout->value() );
@@ -368,7 +353,8 @@ void ModemWidget::slotBeforeModemQuery()
368void ModemWidget::slotAfterModemQuery() 353void ModemWidget::slotAfterModemQuery()
369{ 354{
370 _pppdata->setModemDevice( m_oldModemDev ); 355 _pppdata->setModemDevice( m_oldModemDev );
371 _pppdata->setFlowcontrol( m_oldFlowControl ); 356 _pppdata->setFlowcontrol( static_cast<PPPData::FlowControl>(m_oldFlowControl) );
357 _pppdata->setEnter( static_cast<PPPData::LineTermination>(m_oldLineEnd) );
372 _pppdata->setSpeed( m_oldSpeed ); 358 _pppdata->setSpeed( m_oldSpeed );
373 _pppdata->setModemLockFile( m_oldModemLock ); 359 _pppdata->setModemLockFile( m_oldModemLock );
374 _pppdata->setModemTimeout( m_oldModemTimeout ); 360 _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:
81 PPPData *_pppdata; 81 PPPData *_pppdata;
82 82
83private: 83private:
84 QString m_oldModemDev, m_oldFlowControl, m_oldSpeed; 84 QString m_oldModemDev, m_oldSpeed;
85 bool m_oldModemLock; 85 bool m_oldModemLock;
86 int m_oldModemTimeout; 86 int m_oldModemTimeout, m_oldFlowControl, m_oldLineEnd;
87}; 87};
88 88
89 89
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() {
225 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); 225 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
226 226
227 227
228 if(_pppdata->flowcontrol() != "None") { 228 if(_pppdata->flowcontrol() != PPPData::FlowNone) {
229 if(_pppdata->flowcontrol() == "CRTSCTS") { 229 if(_pppdata->flowcontrol() == PPPData::FlowHardware) {
230 tty.c_cflag |= CRTSCTS; 230 tty.c_cflag |= CRTSCTS;
231 } 231 }
232 else { 232 else {
@@ -355,15 +355,19 @@ bool Modem::writeLine(const char *buf) {
355 char *b = new char[len+2]; 355 char *b = new char[len+2];
356 memcpy(b, buf, len); 356 memcpy(b, buf, len);
357 // different modems seem to need different line terminations 357 // different modems seem to need different line terminations
358 QString term = _pppdata->enter(); 358 switch( _pppdata->enter() ) {
359 if(term == "LF") 359 case PPPData::EndLF:
360 b[len++]='\n'; 360 b[len++]='\n';
361 else if(term == "CR") 361 break;
362 case PPPData::EndCR:
362 b[len++]='\r'; 363 b[len++]='\r';
363 else if(term == "CR/LF") { 364 break;
365 case PPPData::EndCRLF:
364 b[len++]='\r'; 366 b[len++]='\r';
365 b[len++]='\n'; 367 b[len++]='\n';
368 break;
366 } 369 }
370
367 int l = len; 371 int l = len;
368 while(l) { 372 while(l) {
369 int wr = write(modemfd, &b[len-l], l); 373 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) {
387} 387}
388 388
389 389
390const QString PPPData::flowcontrol() { 390enum PPPData::FlowControl PPPData::flowcontrol() {
391 return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); 391 return static_cast<FlowControl>(readNumConfig(modemGroup(), FLOWCONTROL_KEY, FlowHardware));
392} 392}
393 393
394 394
395void PPPData::setFlowcontrol(const QString &n) { 395void PPPData::setFlowcontrol(enum FlowControl n) {
396 writeConfig(modemGroup(), FLOWCONTROL_KEY, n); 396 writeConfig(modemGroup(), FLOWCONTROL_KEY, n);
397} 397}
398 398
@@ -720,12 +720,12 @@ void PPPData::setModemAnswerResp(const QString &n) {
720} 720}
721 721
722 722
723const QString PPPData::enter() { 723enum PPPData::LineTermination PPPData::enter(){
724 return readConfig(modemGroup(), ENTER_KEY, "CR"); 724 return static_cast<PPPData::LineTermination>(readNumConfig(modemGroup(), ENTER_KEY, EndCR));
725} 725}
726 726
727 727
728void PPPData::setEnter(const QString &n) { 728void PPPData::setEnter(enum PPPData::LineTermination n) {
729 writeConfig(modemGroup(), ENTER_KEY, n); 729 writeConfig(modemGroup(), ENTER_KEY, n);
730} 730}
731 731
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:
165 ~PPPData() {}; 165 ~PPPData() {};
166 166
167 enum { NumInitStrings = 2 }; 167 enum { NumInitStrings = 2 };
168 enum LineTermination {
169 EndCR,
170 EndLF,
171 EndCRLF
172 };
173
174 enum FlowControl {
175 FlowHardware,
176 FlowSoftware,
177 FlowNone
178 };
168 179
169 // general functions 180 // general functions
170 void save(); 181 void save();
@@ -222,8 +233,8 @@ public:
222// void set_dock_into_panel(bool set); 233// void set_dock_into_panel(bool set);
223// bool get_dock_into_panel(); 234// bool get_dock_into_panel();
224 235
225 const QString enter(); 236 enum LineTermination enter();
226 void setEnter(const QString &); 237 void setEnter(enum LineTermination);
227 238
228 QString pppdVersion(); 239 QString pppdVersion();
229 bool pppdVersionMin(int ver, int mod, int patch); 240 bool pppdVersionMin(int ver, int mod, int patch);
@@ -253,8 +264,8 @@ public:
253 const QString modemDevice(); 264 const QString modemDevice();
254 bool setModemDevice(const QString &); 265 bool setModemDevice(const QString &);
255 266
256 const QString flowcontrol(); 267 enum FlowControl flowcontrol();
257 void setFlowcontrol(const QString &); 268 void setFlowcontrol(enum FlowControl);
258 269
259 int modemTimeout(); 270 int modemTimeout();
260 void setModemTimeout(int); 271 void setModemTimeout(int);