author | tille <tille> | 2003-05-30 15:06:17 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-30 15:06:17 (UTC) |
commit | 8699d02f6c152afed9490e7e7a4315044261e6e8 (patch) (unidiff) | |
tree | d2ee2ba401c7a9db0e33beaf0617a1456fe01d50 /noncore/settings/networksettings/ppp/connect.cpp | |
parent | d8cec07fe5e54a68afe4feca574f9f4d2433e0c1 (diff) | |
download | opie-8699d02f6c152afed9490e7e7a4315044261e6e8.zip opie-8699d02f6c152afed9490e7e7a4315044261e6e8.tar.gz opie-8699d02f6c152afed9490e7e7a4315044261e6e8.tar.bz2 |
modem and pppdata is now member of interfaceppp
Diffstat (limited to 'noncore/settings/networksettings/ppp/connect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/connect.cpp | 326 |
1 files changed, 161 insertions, 165 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index a3eda9d..2615b60 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -65,7 +65,7 @@ | |||
65 | #include "auth.h" | 65 | #include "auth.h" |
66 | #include "connect.h" | 66 | #include "connect.h" |
67 | //#include "docking.h" | 67 | //#include "docking.h" |
68 | //#include "main.h" | 68 | #include "interfaceppp.h" |
69 | #include "modem.h" | 69 | #include "modem.h" |
70 | #include "kpppconfig.h" | 70 | #include "kpppconfig.h" |
71 | #include "pppdata.h" | 71 | #include "pppdata.h" |
@@ -74,15 +74,12 @@ | |||
74 | //#include "utils.h" | 74 | //#include "utils.h" |
75 | #define execute_command system | 75 | #define execute_command system |
76 | 76 | ||
77 | extern KPPPWidget *p_kppp; | ||
78 | |||
79 | QString old_hostname; | 77 | QString old_hostname; |
80 | bool modified_hostname; | 78 | bool modified_hostname; |
81 | 79 | ||
82 | 80 | ||
83 | ConnectWidget::ConnectWidget(QWidget *parent, const char *name) | 81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) |
84 | : QWidget(parent, name), | 82 | : QWidget(parent, name), |
85 | // initialize some important variables | ||
86 | myreadbuffer(""), | 83 | myreadbuffer(""), |
87 | main_timer_ID(0), | 84 | main_timer_ID(0), |
88 | vmain(0), | 85 | vmain(0), |
@@ -96,9 +93,8 @@ ConnectWidget::ConnectWidget(QWidget *parent, const char *name) | |||
96 | scanvar(""), | 93 | scanvar(""), |
97 | scanning(false), | 94 | scanning(false), |
98 | pausing(false), | 95 | pausing(false), |
99 | // termwindow(0), | 96 | dialnumber(0), |
100 | // stats(st), | 97 | _ifaceppp(ifp) |
101 | dialnumber(0) | ||
102 | { | 98 | { |
103 | modified_hostname = false; | 99 | modified_hostname = false; |
104 | 100 | ||
@@ -179,7 +175,7 @@ void ConnectWidget::preinit() { | |||
179 | 175 | ||
180 | 176 | ||
181 | void ConnectWidget::init() { | 177 | void ConnectWidget::init() { |
182 | PPPData::data()->setpppdError(0); | 178 | _ifaceppp->data()->setpppdError(0); |
183 | inittimer->stop(); | 179 | inittimer->stop(); |
184 | vmain = 0; | 180 | vmain = 0; |
185 | substate = -1; | 181 | substate = -1; |
@@ -194,26 +190,26 @@ void ConnectWidget::init() { | |||
194 | // stats->totalbytes = 0; | 190 | // stats->totalbytes = 0; |
195 | dialnumber = 0; | 191 | dialnumber = 0; |
196 | 192 | ||
197 | p_kppp->con_speed = ""; | 193 | // p_kppp->con_speed = ""; |
198 | 194 | ||
199 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || PPPData::data()->quit_on_disconnect()); | 195 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); |
200 | 196 | ||
201 | comlist = &PPPData::data()->scriptType(); | 197 | comlist = &_ifaceppp->data()->scriptType(); |
202 | arglist = &PPPData::data()->script(); | 198 | arglist = &_ifaceppp->data()->script(); |
203 | 199 | ||
204 | QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname()); | 200 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); |
205 | setCaption(tit); | 201 | setCaption(tit); |
206 | 202 | ||
207 | qApp->processEvents(); | 203 | qApp->processEvents(); |
208 | 204 | ||
209 | // run the "before-connect" command | 205 | // run the "before-connect" command |
210 | if (!PPPData::data()->command_before_connect().isEmpty()) { | 206 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { |
211 | messg->setText(i18n("Running pre-startup command...")); | 207 | messg->setText(i18n("Running pre-startup command...")); |
212 | emit debugMessage(i18n("Running pre-startup command...")); | 208 | emit debugMessage(i18n("Running pre-startup command...")); |
213 | 209 | ||
214 | qApp->processEvents(); | 210 | qApp->processEvents(); |
215 | QApplication::flushX(); | 211 | QApplication::flushX(); |
216 | pid_t id = execute_command(PPPData::data()->command_before_connect()); | 212 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); |
217 | // int i, status; | 213 | // int i, status; |
218 | 214 | ||
219 | // do { | 215 | // do { |
@@ -223,7 +219,7 @@ void ConnectWidget::init() { | |||
223 | // } while (i == 0 && errno == 0); | 219 | // } while (i == 0 && errno == 0); |
224 | } | 220 | } |
225 | 221 | ||
226 | int lock = Modem::modem->lockdevice(); | 222 | int lock = _ifaceppp->modem()->lockdevice(); |
227 | 223 | ||
228 | if (lock == 1) { | 224 | if (lock == 1) { |
229 | messg->setText(i18n("Modem device is locked.")); | 225 | messg->setText(i18n("Modem device is locked.")); |
@@ -237,20 +233,20 @@ void ConnectWidget::init() { | |||
237 | return; | 233 | return; |
238 | } | 234 | } |
239 | 235 | ||
240 | if(Modem::modem->opentty()) { | 236 | if(_ifaceppp->modem()->opentty()) { |
241 | messg->setText(Modem::modem->modemMessage()); | 237 | messg->setText(_ifaceppp->modem()->modemMessage()); |
242 | qApp->processEvents(); | 238 | qApp->processEvents(); |
243 | if(Modem::modem->hangup()) { | 239 | if(_ifaceppp->modem()->hangup()) { |
244 | 240 | ||
245 | qApp->processEvents(); | 241 | qApp->processEvents(); |
246 | 242 | ||
247 | semaphore = false; | 243 | semaphore = false; |
248 | 244 | ||
249 | Modem::modem->stop(); | 245 | _ifaceppp->modem()->stop(); |
250 | Modem::modem->notify(this, SLOT(readChar(unsigned char))); | 246 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); |
251 | 247 | ||
252 | // if we are stuck anywhere we will time out | 248 | // if we are stuck anywhere we will time out |
253 | timeout_timer->start(PPPData::data()->modemTimeout()*1000); | 249 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
254 | 250 | ||
255 | // this timer will run the script etc. | 251 | // this timer will run the script etc. |
256 | main_timer_ID = startTimer(10); | 252 | main_timer_ID = startTimer(10); |
@@ -260,9 +256,9 @@ void ConnectWidget::init() { | |||
260 | } | 256 | } |
261 | 257 | ||
262 | // initialization failed | 258 | // initialization failed |
263 | messg->setText(Modem::modem->modemMessage()); | 259 | messg->setText(_ifaceppp->modem()->modemMessage()); |
264 | vmain = 20; // wait until cancel is pressed | 260 | vmain = 20; // wait until cancel is pressed |
265 | Modem::modem->unlockdevice(); | 261 | _ifaceppp->modem()->unlockdevice(); |
266 | } | 262 | } |
267 | 263 | ||
268 | 264 | ||
@@ -284,18 +280,18 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
284 | substate = 0; | 280 | substate = 0; |
285 | } | 281 | } |
286 | 282 | ||
287 | QString initStr = PPPData::data()->modemInitStr(substate); | 283 | QString initStr = _ifaceppp->data()->modemInitStr(substate); |
288 | if (!initStr.isEmpty()) { | 284 | if (!initStr.isEmpty()) { |
289 | // send a carriage return and then wait a bit so that the modem will | 285 | // send a carriage return and then wait a bit so that the modem will |
290 | // let us issue commands. | 286 | // let us issue commands. |
291 | if(PPPData::data()->modemPreInitDelay() > 0) { | 287 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { |
292 | usleep(PPPData::data()->modemPreInitDelay() * 5000); | 288 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
293 | writeline(""); | 289 | writeline(""); |
294 | usleep(PPPData::data()->modemPreInitDelay() * 5000); | 290 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
295 | } | 291 | } |
296 | setExpect(PPPData::data()->modemInitResp()); | 292 | setExpect(_ifaceppp->data()->modemInitResp()); |
297 | writeline(initStr); | 293 | writeline(initStr); |
298 | usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 294 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
299 | } | 295 | } |
300 | 296 | ||
301 | substate++; | 297 | substate++; |
@@ -306,7 +302,7 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
306 | * Speed Dragon). Even better would be to detect this when doing | 302 | * Speed Dragon). Even better would be to detect this when doing |
307 | * a "Modem Query" | 303 | * a "Modem Query" |
308 | */ | 304 | */ |
309 | if (MODEM_TONEDURATION != PPPData::data()->modemToneDuration()) | 305 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) |
310 | vmain = 5; | 306 | vmain = 5; |
311 | else | 307 | else |
312 | vmain = 3; | 308 | vmain = 3; |
@@ -316,11 +312,11 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
316 | 312 | ||
317 | if (vmain == 5) { | 313 | if (vmain == 5) { |
318 | if(!expecting) { | 314 | if(!expecting) { |
319 | QString sToneDuration = "ATS11=" + QString::number(PPPData::data()->modemToneDuration()); | 315 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); |
320 | QString msg = i18n("Setting ") + sToneDuration; | 316 | QString msg = i18n("Setting ") + sToneDuration; |
321 | messg->setText(msg); | 317 | messg->setText(msg); |
322 | emit debugMessage(msg); | 318 | emit debugMessage(msg); |
323 | setExpect(PPPData::data()->modemInitResp()); | 319 | setExpect(_ifaceppp->data()->modemInitResp()); |
324 | writeline(sToneDuration); | 320 | writeline(sToneDuration); |
325 | } | 321 | } |
326 | vmain = 3; | 322 | vmain = 3; |
@@ -336,18 +332,18 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
336 | } | 332 | } |
337 | substate = -1; | 333 | substate = -1; |
338 | // skip setting the volume if command is empty | 334 | // skip setting the volume if command is empty |
339 | if(PPPData::data()->volumeInitString().isEmpty()) { | 335 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { |
340 | vmain = 4; | 336 | vmain = 4; |
341 | return; | 337 | return; |
342 | } | 338 | } |
343 | messg->setText(i18n("Setting speaker volume...")); | 339 | messg->setText(i18n("Setting speaker volume...")); |
344 | emit debugMessage(i18n("Setting speaker volume...")); | 340 | emit debugMessage(i18n("Setting speaker volume...")); |
345 | 341 | ||
346 | setExpect(PPPData::data()->modemInitResp()); | 342 | setExpect(_ifaceppp->data()->modemInitResp()); |
347 | QString vol("AT"); | 343 | QString vol("AT"); |
348 | vol += PPPData::data()->volumeInitString(); | 344 | vol += _ifaceppp->data()->volumeInitString(); |
349 | writeline(vol); | 345 | writeline(vol); |
350 | usleep(PPPData::data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 346 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
351 | vmain = 4; | 347 | vmain = 4; |
352 | return; | 348 | return; |
353 | } | 349 | } |
@@ -355,12 +351,12 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
355 | 351 | ||
356 | if(vmain == 4) { | 352 | if(vmain == 4) { |
357 | if(!expecting) { | 353 | if(!expecting) { |
358 | if(!PPPData::data()->waitForDialTone()) { | 354 | if(!_ifaceppp->data()->waitForDialTone()) { |
359 | QString msg = i18n("Turning off dial tone waiting..."); | 355 | QString msg = i18n("Turning off dial tone waiting..."); |
360 | messg->setText(msg); | 356 | messg->setText(msg); |
361 | emit debugMessage(msg); | 357 | emit debugMessage(msg); |
362 | setExpect(PPPData::data()->modemInitResp()); | 358 | setExpect(_ifaceppp->data()->modemInitResp()); |
363 | writeline(PPPData::data()->modemNoDialToneDetectionStr()); | 359 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); |
364 | } | 360 | } |
365 | vmain = 1; | 361 | vmain = 1; |
366 | return; | 362 | return; |
@@ -372,23 +368,23 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
372 | if(!expecting) { | 368 | if(!expecting) { |
373 | 369 | ||
374 | timeout_timer->stop(); | 370 | timeout_timer->stop(); |
375 | timeout_timer->start(PPPData::data()->modemTimeout()*1000); | 371 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
376 | 372 | ||
377 | QStringList &plist = PPPData::data()->phonenumbers(); | 373 | QStringList &plist = _ifaceppp->data()->phonenumbers(); |
378 | QString bmarg= PPPData::data()->dialPrefix(); | 374 | QString bmarg= _ifaceppp->data()->dialPrefix(); |
379 | bmarg += *plist.at(dialnumber); | 375 | bmarg += *plist.at(dialnumber); |
380 | QString bm = i18n("Dialing %1").arg(bmarg); | 376 | QString bm = i18n("Dialing %1").arg(bmarg); |
381 | messg->setText(bm); | 377 | messg->setText(bm); |
382 | emit debugMessage(bm); | 378 | emit debugMessage(bm); |
383 | 379 | ||
384 | QString pn = PPPData::data()->modemDialStr(); | 380 | QString pn = _ifaceppp->data()->modemDialStr(); |
385 | pn += PPPData::data()->dialPrefix(); | 381 | pn += _ifaceppp->data()->dialPrefix(); |
386 | pn += *plist.at(dialnumber); | 382 | pn += *plist.at(dialnumber); |
387 | if(++dialnumber >= plist.count()) | 383 | if(++dialnumber >= plist.count()) |
388 | dialnumber = 0; | 384 | dialnumber = 0; |
389 | writeline(pn); | 385 | writeline(pn); |
390 | 386 | ||
391 | setExpect(PPPData::data()->modemConnectResp()); | 387 | setExpect(_ifaceppp->data()->modemConnectResp()); |
392 | vmain = 100; | 388 | vmain = 100; |
393 | return; | 389 | return; |
394 | } | 390 | } |
@@ -398,52 +394,52 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
398 | // if NO CARRIER or NO DIALTONE | 394 | // if NO CARRIER or NO DIALTONE |
399 | if(vmain == 100) { | 395 | if(vmain == 100) { |
400 | if(!expecting) { | 396 | if(!expecting) { |
401 | myreadbuffer = PPPData::data()->modemConnectResp(); | 397 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); |
402 | setExpect("\n"); | 398 | setExpect("\n"); |
403 | vmain = 101; | 399 | vmain = 101; |
404 | return; | 400 | return; |
405 | } | 401 | } |
406 | 402 | ||
407 | if(readbuffer.contains(PPPData::data()->modemBusyResp())) { | 403 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { |
408 | timeout_timer->stop(); | 404 | timeout_timer->stop(); |
409 | timeout_timer->start(PPPData::data()->modemTimeout()*1000); | 405 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
410 | 406 | ||
411 | messg->setText(i18n("Line busy. Hanging up...")); | 407 | messg->setText(i18n("Line busy. Hanging up...")); |
412 | emit debugPutChar('\n'); | 408 | emit debugPutChar('\n'); |
413 | Modem::modem->hangup(); | 409 | _ifaceppp->modem()->hangup(); |
414 | 410 | ||
415 | if(PPPData::data()->busyWait() > 0) { | 411 | if(_ifaceppp->data()->busyWait() > 0) { |
416 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(PPPData::data()->busyWait()); | 412 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); |
417 | messg->setText(bm); | 413 | messg->setText(bm); |
418 | emit debugMessage(bm); | 414 | emit debugMessage(bm); |
419 | 415 | ||
420 | pausing = true; | 416 | pausing = true; |
421 | 417 | ||
422 | pausetimer->start(PPPData::data()->busyWait()*1000, true); | 418 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); |
423 | timeout_timer->stop(); | 419 | timeout_timer->stop(); |
424 | } | 420 | } |
425 | 421 | ||
426 | Modem::modem->setDataMode(false); | 422 | _ifaceppp->modem()->setDataMode(false); |
427 | vmain = 0; | 423 | vmain = 0; |
428 | substate = -1; | 424 | substate = -1; |
429 | return; | 425 | return; |
430 | } | 426 | } |
431 | 427 | ||
432 | if(readbuffer.contains(PPPData::data()->modemNoDialtoneResp())) { | 428 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { |
433 | timeout_timer->stop(); | 429 | timeout_timer->stop(); |
434 | 430 | ||
435 | messg->setText(i18n("No Dialtone")); | 431 | messg->setText(i18n("No Dialtone")); |
436 | vmain = 20; | 432 | vmain = 20; |
437 | Modem::modem->unlockdevice(); | 433 | _ifaceppp->modem()->unlockdevice(); |
438 | return; | 434 | return; |
439 | } | 435 | } |
440 | 436 | ||
441 | if(readbuffer.contains(PPPData::data()->modemNoCarrierResp())) { | 437 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { |
442 | timeout_timer->stop(); | 438 | timeout_timer->stop(); |
443 | 439 | ||
444 | messg->setText(i18n("No Carrier")); | 440 | messg->setText(i18n("No Carrier")); |
445 | vmain = 20; | 441 | vmain = 20; |
446 | Modem::modem->unlockdevice(); | 442 | _ifaceppp->modem()->unlockdevice(); |
447 | return; | 443 | return; |
448 | } | 444 | } |
449 | } | 445 | } |
@@ -451,13 +447,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
451 | // wait for newline after CONNECT response (so we get the speed) | 447 | // wait for newline after CONNECT response (so we get the speed) |
452 | if(vmain == 101) { | 448 | if(vmain == 101) { |
453 | if(!expecting) { | 449 | if(!expecting) { |
454 | Modem::modem->setDataMode(true); // modem will no longer respond to AT commands | 450 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands |
455 | 451 | ||
456 | emit startAccounting(); | 452 | emit startAccounting(); |
457 | // p_kppp->con_win->startClock(); | 453 | // p_kppp->con_win->startClock(); |
458 | 454 | ||
459 | vmain = 2; | 455 | vmain = 2; |
460 | scriptTimeout=PPPData::data()->modemTimeout()*1000; | 456 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; |
461 | return; | 457 | return; |
462 | } | 458 | } |
463 | } | 459 | } |
@@ -494,10 +490,10 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
494 | emit debugMessage(bm); | 490 | emit debugMessage(bm); |
495 | 491 | ||
496 | if (scriptArgument.lower() == "password") { | 492 | if (scriptArgument.lower() == "password") { |
497 | PPPData::data()->setPassword(scanvar); | 493 | _ifaceppp->data()->setPassword(scanvar); |
498 | p_kppp->setPW_Edit(scanvar); | 494 | // p_kppp->setPW_Edit(scanvar); |
499 | if(PPPData::data()->storePassword()) | 495 | if(_ifaceppp->data()->storePassword()) |
500 | PPPData::data()->setStoredPassword(scanvar); | 496 | _ifaceppp->data()->setStoredPassword(scanvar); |
501 | firstrunPW = true; | 497 | firstrunPW = true; |
502 | } | 498 | } |
503 | 499 | ||
@@ -513,8 +509,8 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
513 | QString arg = scriptArgument; | 509 | QString arg = scriptArgument; |
514 | QRegExp re1("%USERNAME%"); | 510 | QRegExp re1("%USERNAME%"); |
515 | QRegExp re2("%PASSWORD%"); | 511 | QRegExp re2("%PASSWORD%"); |
516 | arg = arg.replace(re1, PPPData::data()->storedUsername()); | 512 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); |
517 | arg = arg.replace(re2, PPPData::data()->storedPassword()); | 513 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); |
518 | 514 | ||
519 | if (scriptCommand == "Send") | 515 | if (scriptCommand == "Send") |
520 | bm = bm.arg(scriptArgument); | 516 | bm = bm.arg(scriptArgument); |
@@ -578,8 +574,8 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
578 | messg->setText(i18n("Hangup")); | 574 | messg->setText(i18n("Hangup")); |
579 | emit debugMessage(i18n("Hangup")); | 575 | emit debugMessage(i18n("Hangup")); |
580 | 576 | ||
581 | writeline(PPPData::data()->modemHangupStr()); | 577 | writeline(_ifaceppp->data()->modemHangupStr()); |
582 | setExpect(PPPData::data()->modemHangupResp()); | 578 | setExpect(_ifaceppp->data()->modemHangupResp()); |
583 | 579 | ||
584 | scriptindex++; | 580 | scriptindex++; |
585 | return; | 581 | return; |
@@ -592,7 +588,7 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
592 | messg->setText(i18n("Answer")); | 588 | messg->setText(i18n("Answer")); |
593 | emit debugMessage(i18n("Answer")); | 589 | emit debugMessage(i18n("Answer")); |
594 | 590 | ||
595 | setExpect(PPPData::data()->modemRingResp()); | 591 | setExpect(_ifaceppp->data()->modemRingResp()); |
596 | vmain = 150; | 592 | vmain = 150; |
597 | return; | 593 | return; |
598 | } | 594 | } |
@@ -602,7 +598,7 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
602 | messg->setText(bm); | 598 | messg->setText(bm); |
603 | emit debugMessage(bm); | 599 | emit debugMessage(bm); |
604 | 600 | ||
605 | QString idstring = PPPData::data()->storedUsername(); | 601 | QString idstring = _ifaceppp->data()->storedUsername(); |
606 | 602 | ||
607 | if(!idstring.isEmpty() && firstrunID) { | 603 | if(!idstring.isEmpty() && firstrunID) { |
608 | // the user entered an Id on the main kppp dialog | 604 | // the user entered an Id on the main kppp dialog |
@@ -638,7 +634,7 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
638 | messg->setText(bm); | 634 | messg->setText(bm); |
639 | emit debugMessage(bm); | 635 | emit debugMessage(bm); |
640 | 636 | ||
641 | QString pwstring = PPPData::data()->password(); | 637 | QString pwstring = _ifaceppp->data()->password(); |
642 | 638 | ||
643 | if(!pwstring.isEmpty() && firstrunPW) { | 639 | if(!pwstring.isEmpty() && firstrunPW) { |
644 | // the user entered a password on the main kppp dialog | 640 | // the user entered a password on the main kppp dialog |
@@ -659,7 +655,7 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
659 | } else { | 655 | } else { |
660 | /* if prompt withdrawn ... then, */ | 656 | /* if prompt withdrawn ... then, */ |
661 | if(!(prompt->isVisible())) { | 657 | if(!(prompt->isVisible())) { |
662 | p_kppp->setPW_Edit(prompt->text()); | 658 | // p_kppp->setPW_Edit(prompt->text()); |
663 | writeline(prompt->text()); | 659 | writeline(prompt->text()); |
664 | prompt->setConsumed(); | 660 | prompt->setConsumed(); |
665 | scriptindex++; | 661 | scriptindex++; |
@@ -785,8 +781,8 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
785 | 781 | ||
786 | if(vmain == 150) { | 782 | if(vmain == 150) { |
787 | if(!expecting) { | 783 | if(!expecting) { |
788 | writeline(PPPData::data()->modemAnswerStr()); | 784 | writeline(_ifaceppp->data()->modemAnswerStr()); |
789 | setExpect(PPPData::data()->modemAnswerResp()); | 785 | setExpect(_ifaceppp->data()->modemAnswerResp()); |
790 | 786 | ||
791 | vmain = 2; | 787 | vmain = 2; |
792 | scriptindex++; | 788 | scriptindex++; |
@@ -812,9 +808,9 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
812 | if_timeout_timer->stop(); // better be sure. | 808 | if_timeout_timer->stop(); // better be sure. |
813 | 809 | ||
814 | // stop reading of data | 810 | // stop reading of data |
815 | Modem::modem->stop(); | 811 | _ifaceppp->modem()->stop(); |
816 | 812 | ||
817 | if(PPPData::data()->authMethod() == AUTH_TERMINAL) { | 813 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { |
818 | // if (termwindow) { | 814 | // if (termwindow) { |
819 | // delete termwindow; | 815 | // delete termwindow; |
820 | // termwindow = 0L; | 816 | // termwindow = 0L; |
@@ -831,12 +827,12 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
831 | // Close the tty. This prevents the QTimer::singleShot() in | 827 | // Close the tty. This prevents the QTimer::singleShot() in |
832 | // Modem::readtty() from re-enabling the socket notifier. | 828 | // Modem::readtty() from re-enabling the socket notifier. |
833 | // The port is still held open by the helper process. | 829 | // The port is still held open by the helper process. |
834 | Modem::modem->closetty(); | 830 | _ifaceppp->modem()->closetty(); |
835 | 831 | ||
836 | killTimer( main_timer_ID ); | 832 | killTimer( main_timer_ID ); |
837 | 833 | ||
838 | if_timeout_timer->start(PPPData::data()->pppdTimeout()*1000); | 834 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); |
839 | qDebug( "started if timeout timer with %i", PPPData::data()->pppdTimeout()*1000); | 835 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); |
840 | 836 | ||
841 | // find out PPP interface and notify the stats module | 837 | // find out PPP interface and notify the stats module |
842 | // stats->setUnit(pppInterfaceNumber()); | 838 | // stats->setUnit(pppInterfaceNumber()); |
@@ -849,8 +845,8 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
849 | qDebug("execppp() returned with return-code %i", result ); | 845 | qDebug("execppp() returned with return-code %i", result ); |
850 | 846 | ||
851 | if(result) { | 847 | if(result) { |
852 | if(!PPPData::data()->autoDNS()) | 848 | if(!_ifaceppp->data()->autoDNS()) |
853 | adddns(); | 849 | adddns( _ifaceppp ); |
854 | 850 | ||
855 | // O.K we are done here, let's change over to the if_waiting loop | 851 | // O.K we are done here, let's change over to the if_waiting loop |
856 | // where we wait for the ppp if (interface) to come up. | 852 | // where we wait for the ppp if (interface) to come up. |
@@ -863,14 +859,14 @@ void ConnectWidget::timerEvent(QTimerEvent *) { | |||
863 | if_timeout_timer->stop(); | 859 | if_timeout_timer->stop(); |
864 | this->hide(); | 860 | this->hide(); |
865 | messg->setText(""); | 861 | messg->setText(""); |
866 | p_kppp->quit_b->setFocus(); | 862 | //p_kppp->quit_b->setFocus(); |
867 | p_kppp->show(); | 863 | //p_kppp->show(); |
868 | qApp->processEvents(); | 864 | qApp->processEvents(); |
869 | Modem::modem->hangup(); | 865 | _ifaceppp->modem()->hangup(); |
870 | emit stopAccounting(); | 866 | emit stopAccounting(); |
871 | //p_kppp->con_win->stopClock(); | 867 | //p_kppp->con_win->stopClock(); |
872 | Modem::modem->closetty(); | 868 | _ifaceppp->modem()->closetty(); |
873 | Modem::modem->unlockdevice(); | 869 | _ifaceppp->modem()->unlockdevice(); |
874 | 870 | ||
875 | } | 871 | } |
876 | 872 | ||
@@ -890,7 +886,7 @@ void ConnectWidget::set_con_speed_string() { | |||
890 | // Usually the modem responds after connect with something like | 886 | // Usually the modem responds after connect with something like |
891 | // CONNECT 115200, so all we need to do is find the number after CONNECT | 887 | // CONNECT 115200, so all we need to do is find the number after CONNECT |
892 | // or whatever the modemConnectResp() is. | 888 | // or whatever the modemConnectResp() is. |
893 | p_kppp->con_speed = Modem::modem->parseModemSpeed(myreadbuffer); | 889 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); |
894 | } | 890 | } |
895 | 891 | ||
896 | 892 | ||
@@ -969,7 +965,7 @@ void ConnectWidget::pause() { | |||
969 | 965 | ||
970 | 966 | ||
971 | void ConnectWidget::cancelbutton() { | 967 | void ConnectWidget::cancelbutton() { |
972 | Modem::modem->stop(); | 968 | _ifaceppp->modem()->stop(); |
973 | killTimer(main_timer_ID); | 969 | killTimer(main_timer_ID); |
974 | timeout_timer->stop(); | 970 | timeout_timer->stop(); |
975 | if_timer->stop(); | 971 | if_timer->stop(); |
@@ -984,23 +980,23 @@ void ConnectWidget::cancelbutton() { | |||
984 | messg->setText(i18n("One moment please...")); | 980 | messg->setText(i18n("One moment please...")); |
985 | 981 | ||
986 | // just to be sure | 982 | // just to be sure |
987 | Modem::modem->removeSecret(AUTH_PAP); | 983 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
988 | Modem::modem->removeSecret(AUTH_CHAP); | 984 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
989 | removedns(); | 985 | removedns(_ifaceppp); |
990 | 986 | ||
991 | qApp->processEvents(); | 987 | qApp->processEvents(); |
992 | 988 | ||
993 | Modem::modem->killPPPDaemon(); | 989 | _ifaceppp->modem()->killPPPDaemon(); |
994 | Modem::modem->hangup(); | 990 | _ifaceppp->modem()->hangup(); |
995 | 991 | ||
996 | this->hide(); | 992 | this->hide(); |
997 | messg->setText(""); | 993 | messg->setText(""); |
998 | p_kppp->quit_b->setFocus(); | 994 | // p_kppp->quit_b->setFocus(); |
999 | p_kppp->show(); | 995 | // p_kppp->show(); |
1000 | emit stopAccounting();// just to be sure | 996 | emit stopAccounting();// just to be sure |
1001 | // p_kppp->con_win->stopClock(); | 997 | // p_kppp->con_win->stopClock(); |
1002 | Modem::modem->closetty(); | 998 | _ifaceppp->modem()->closetty(); |
1003 | Modem::modem->unlockdevice(); | 999 | _ifaceppp->modem()->unlockdevice(); |
1004 | 1000 | ||
1005 | //abort prompt window... | 1001 | //abort prompt window... |
1006 | if (prompt->isVisible()) { | 1002 | if (prompt->isVisible()) { |
@@ -1026,7 +1022,7 @@ void ConnectWidget::script_timed_out() { | |||
1026 | 1022 | ||
1027 | prompt->setConsumed(); | 1023 | prompt->setConsumed(); |
1028 | messg->setText(i18n("Script timed out!")); | 1024 | messg->setText(i18n("Script timed out!")); |
1029 | Modem::modem->hangup(); | 1025 | _ifaceppp->modem()->hangup(); |
1030 | emit stopAccounting(); | 1026 | emit stopAccounting(); |
1031 | // p_kppp->con_win->stopClock(); | 1027 | // p_kppp->con_win->stopClock(); |
1032 | 1028 | ||
@@ -1063,10 +1059,10 @@ void ConnectWidget::if_waiting_timed_out() { | |||
1063 | if_timeout_timer->stop(); | 1059 | if_timeout_timer->stop(); |
1064 | qDebug("if_waiting_timed_out()"); | 1060 | qDebug("if_waiting_timed_out()"); |
1065 | 1061 | ||
1066 | PPPData::data()->setpppdError(E_IF_TIMEOUT); | 1062 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); |
1067 | 1063 | ||
1068 | // let's kill the stuck pppd | 1064 | // let's kill the stuck pppd |
1069 | Modem::modem->killPPPDaemon(); | 1065 | _ifaceppp->modem()->killPPPDaemon(); |
1070 | 1066 | ||
1071 | emit stopAccounting(); | 1067 | emit stopAccounting(); |
1072 | // p_kppp->con_win->stopClock(); | 1068 | // p_kppp->con_win->stopClock(); |
@@ -1088,7 +1084,7 @@ void ConnectWidget::if_waiting_slot() { | |||
1088 | 1084 | ||
1089 | // if(!stats->ifIsUp()) { | 1085 | // if(!stats->ifIsUp()) { |
1090 | 1086 | ||
1091 | // if(PPPData::data()->pppdError() != 0) { | 1087 | // if(_ifaceppp->data()->pppdError() != 0) { |
1092 | // // we are here if pppd died immediately after starting it. | 1088 | // // we are here if pppd died immediately after starting it. |
1093 | // pppdDied(); | 1089 | // pppdDied(); |
1094 | // // error message handled in main.cpp: sigPPPDDied() | 1090 | // // error message handled in main.cpp: sigPPPDDied() |
@@ -1105,27 +1101,27 @@ void ConnectWidget::if_waiting_slot() { | |||
1105 | if_timer->stop(); | 1101 | if_timer->stop(); |
1106 | usleep(200000); | 1102 | usleep(200000); |
1107 | 1103 | ||
1108 | if(PPPData::data()->autoDNS()) | 1104 | if(_ifaceppp->data()->autoDNS()) |
1109 | addpeerdns(); | 1105 | addpeerdns( _ifaceppp ); |
1110 | 1106 | ||
1111 | // Close the debugging window. If we are connected, we | 1107 | // Close the debugging window. If we are connected, we |
1112 | // are not really interested in debug output | 1108 | // are not really interested in debug output |
1113 | emit closeDebugWindow(); | 1109 | emit closeDebugWindow(); |
1114 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics | 1110 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics |
1115 | auto_hostname(); | 1111 | auto_hostname(_ifaceppp); |
1116 | 1112 | ||
1117 | if(!PPPData::data()->command_on_connect().isEmpty()) { | 1113 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { |
1118 | messg->setText(i18n("Running startup command...")); | 1114 | messg->setText(i18n("Running startup command...")); |
1119 | 1115 | ||
1120 | // make sure that we don't get any async errors | 1116 | // make sure that we don't get any async errors |
1121 | qApp->flushX(); | 1117 | qApp->flushX(); |
1122 | execute_command(PPPData::data()->command_on_connect()); | 1118 | execute_command(_ifaceppp->data()->command_on_connect()); |
1123 | messg->setText(i18n("Done")); | 1119 | messg->setText(i18n("Done")); |
1124 | } | 1120 | } |
1125 | 1121 | ||
1126 | // remove the authentication file | 1122 | // remove the authentication file |
1127 | Modem::modem->removeSecret(AUTH_PAP); | 1123 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
1128 | Modem::modem->removeSecret(AUTH_CHAP); | 1124 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
1129 | 1125 | ||
1130 | emit debugMessage(i18n("Done")); | 1126 | emit debugMessage(i18n("Done")); |
1131 | set_con_speed_string(); | 1127 | set_con_speed_string(); |
@@ -1141,20 +1137,20 @@ void ConnectWidget::if_waiting_slot() { | |||
1141 | // else | 1137 | // else |
1142 | // p_kppp->con_win->accounting(false); | 1138 | // p_kppp->con_win->accounting(false); |
1143 | 1139 | ||
1144 | if (PPPData::data()->get_dock_into_panel()) { | 1140 | // if (_ifaceppp->data()->get_dock_into_panel()) { |
1145 | // DockWidget::dock_widget->show(); | 1141 | // // DockWidget::dock_widget->show(); |
1146 | // DockWidget::dock_widget->take_stats(); | 1142 | // // DockWidget::dock_widget->take_stats(); |
1147 | // this->hide(); | 1143 | // // this->hide(); |
1148 | } | 1144 | // } |
1149 | else { | 1145 | // else { |
1150 | // p_kppp->con_win->show(); | 1146 | // // p_kppp->con_win->show(); |
1151 | 1147 | ||
1152 | if(PPPData::data()->get_iconify_on_connect()) { | 1148 | // if(_ifaceppp->data()->get_iconify_on_connect()) { |
1153 | // p_kppp->con_win->showMinimized(); | 1149 | // // p_kppp->con_win->showMinimized(); |
1154 | } | 1150 | // } |
1155 | } | 1151 | // } |
1156 | 1152 | ||
1157 | Modem::modem->closetty(); | 1153 | _ifaceppp->modem()->closetty(); |
1158 | } | 1154 | } |
1159 | 1155 | ||
1160 | 1156 | ||
@@ -1168,17 +1164,17 @@ bool ConnectWidget::execppp() { | |||
1168 | // we'll simply leave this argument away. pppd will then use the default tty | 1164 | // we'll simply leave this argument away. pppd will then use the default tty |
1169 | // which is the serial port we connected stdin/stdout to in opener.cpp. | 1165 | // which is the serial port we connected stdin/stdout to in opener.cpp. |
1170 | // command += " "; | 1166 | // command += " "; |
1171 | // command += PPPData::data()->modemDevice(); | 1167 | // command += _ifaceppp->data()->modemDevice(); |
1172 | 1168 | ||
1173 | command += " " + PPPData::data()->speed(); | 1169 | command += " " + _ifaceppp->data()->speed(); |
1174 | 1170 | ||
1175 | command += " -detach"; | 1171 | command += " -detach"; |
1176 | 1172 | ||
1177 | if(PPPData::data()->ipaddr() != "0.0.0.0" || | 1173 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || |
1178 | PPPData::data()->gateway() != "0.0.0.0") { | 1174 | _ifaceppp->data()->gateway() != "0.0.0.0") { |
1179 | if(PPPData::data()->ipaddr() != "0.0.0.0") { | 1175 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { |
1180 | command += " "; | 1176 | command += " "; |
1181 | command += PPPData::data()->ipaddr(); | 1177 | command += _ifaceppp->data()->ipaddr(); |
1182 | command += ":"; | 1178 | command += ":"; |
1183 | } | 1179 | } |
1184 | else { | 1180 | else { |
@@ -1186,27 +1182,27 @@ bool ConnectWidget::execppp() { | |||
1186 | command += ":"; | 1182 | command += ":"; |
1187 | } | 1183 | } |
1188 | 1184 | ||
1189 | if(PPPData::data()->gateway() != "0.0.0.0") | 1185 | if(_ifaceppp->data()->gateway() != "0.0.0.0") |
1190 | command += PPPData::data()->gateway(); | 1186 | command += _ifaceppp->data()->gateway(); |
1191 | } | 1187 | } |
1192 | 1188 | ||
1193 | if(PPPData::data()->subnetmask() != "0.0.0.0") | 1189 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") |
1194 | command += " netmask " + PPPData::data()->subnetmask(); | 1190 | command += " netmask " + _ifaceppp->data()->subnetmask(); |
1195 | 1191 | ||
1196 | if(PPPData::data()->flowcontrol() != "None") { | 1192 | if(_ifaceppp->data()->flowcontrol() != "None") { |
1197 | if(PPPData::data()->flowcontrol() == "CRTSCTS") | 1193 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") |
1198 | command += " crtscts"; | 1194 | command += " crtscts"; |
1199 | else | 1195 | else |
1200 | command += " xonxoff"; | 1196 | command += " xonxoff"; |
1201 | } | 1197 | } |
1202 | 1198 | ||
1203 | if(PPPData::data()->defaultroute()) | 1199 | if(_ifaceppp->data()->defaultroute()) |
1204 | command += " defaultroute"; | 1200 | command += " defaultroute"; |
1205 | 1201 | ||
1206 | if(PPPData::data()->autoDNS()) | 1202 | if(_ifaceppp->data()->autoDNS()) |
1207 | command += " usepeerdns"; | 1203 | command += " usepeerdns"; |
1208 | 1204 | ||
1209 | QStringList &arglist = PPPData::data()->pppdArgument(); | 1205 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); |
1210 | for ( QStringList::Iterator it = arglist.begin(); | 1206 | for ( QStringList::Iterator it = arglist.begin(); |
1211 | it != arglist.end(); | 1207 | it != arglist.end(); |
1212 | ++it ) | 1208 | ++it ) |
@@ -1215,25 +1211,25 @@ bool ConnectWidget::execppp() { | |||
1215 | } | 1211 | } |
1216 | 1212 | ||
1217 | // PAP settings | 1213 | // PAP settings |
1218 | if(PPPData::data()->authMethod() == AUTH_PAP) { | 1214 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { |
1219 | command += " -chap user "; | 1215 | command += " -chap user "; |
1220 | command = command + "\"" + PPPData::data()->storedUsername() + "\""; | 1216 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1221 | } | 1217 | } |
1222 | 1218 | ||
1223 | // CHAP settings | 1219 | // CHAP settings |
1224 | if(PPPData::data()->authMethod() == AUTH_CHAP) { | 1220 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { |
1225 | command += " -pap user "; | 1221 | command += " -pap user "; |
1226 | command = command + "\"" + PPPData::data()->storedUsername() + "\""; | 1222 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1227 | } | 1223 | } |
1228 | 1224 | ||
1229 | // PAP/CHAP settings | 1225 | // PAP/CHAP settings |
1230 | if(PPPData::data()->authMethod() == AUTH_PAPCHAP) { | 1226 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { |
1231 | command += " user "; | 1227 | command += " user "; |
1232 | command = command + "\"" + PPPData::data()->storedUsername() + "\""; | 1228 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; |
1233 | } | 1229 | } |
1234 | 1230 | ||
1235 | // check for debug | 1231 | // check for debug |
1236 | if(PPPData::data()->getPPPDebug()) | 1232 | if(_ifaceppp->data()->getPPPDebug()) |
1237 | command += " debug"; | 1233 | command += " debug"; |
1238 | 1234 | ||
1239 | if (command.length() > MAX_CMDLEN) { | 1235 | if (command.length() > MAX_CMDLEN) { |
@@ -1247,7 +1243,7 @@ bool ConnectWidget::execppp() { | |||
1247 | 1243 | ||
1248 | qApp->flushX(); | 1244 | qApp->flushX(); |
1249 | 1245 | ||
1250 | return Modem::modem->execPPPDaemon(command); | 1246 | return _ifaceppp->modem()->execPPPDaemon(command); |
1251 | } | 1247 | } |
1252 | 1248 | ||
1253 | 1249 | ||
@@ -1262,11 +1258,11 @@ void ConnectWidget::setMsg(const QString &msg) { | |||
1262 | } | 1258 | } |
1263 | 1259 | ||
1264 | void ConnectWidget::writeline(const QString &s) { | 1260 | void ConnectWidget::writeline(const QString &s) { |
1265 | Modem::modem->writeLine(s.local8Bit()); | 1261 | _ifaceppp->modem()->writeLine(s.local8Bit()); |
1266 | } | 1262 | } |
1267 | 1263 | ||
1268 | // Set the hostname and domain from DNS Server | 1264 | // Set the hostname and domain from DNS Server |
1269 | void auto_hostname() { | 1265 | void auto_hostname(InterfacePPP *_ifaceppp) { |
1270 | struct in_addr local_ip; | 1266 | struct in_addr local_ip; |
1271 | struct hostent *hostname_entry; | 1267 | struct hostent *hostname_entry; |
1272 | QString new_hostname; | 1268 | QString new_hostname; |
@@ -1277,8 +1273,8 @@ void auto_hostname() { | |||
1277 | tmp_str[sizeof(tmp_str)-1]=0; // panic | 1273 | tmp_str[sizeof(tmp_str)-1]=0; // panic |
1278 | old_hostname=tmp_str; // copy to QString | 1274 | old_hostname=tmp_str; // copy to QString |
1279 | 1275 | ||
1280 | // if (!p_kppp->stats->local_ip_address.isEmpty() && PPPData::data()->autoname()) { | 1276 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { |
1281 | if ( PPPData::data()->autoname()) { | 1277 | if ( _ifaceppp->data()->autoname()) { |
1282 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); | 1278 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); |
1283 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); | 1279 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); |
1284 | 1280 | ||
@@ -1286,13 +1282,13 @@ void auto_hostname() { | |||
1286 | new_hostname=hostname_entry->h_name; | 1282 | new_hostname=hostname_entry->h_name; |
1287 | dot=new_hostname.find('.'); | 1283 | dot=new_hostname.find('.'); |
1288 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); | 1284 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); |
1289 | Modem::modem->setHostname(new_hostname); | 1285 | _ifaceppp->modem()->setHostname(new_hostname); |
1290 | modified_hostname = TRUE; | 1286 | modified_hostname = TRUE; |
1291 | 1287 | ||
1292 | new_hostname=hostname_entry->h_name; | 1288 | new_hostname=hostname_entry->h_name; |
1293 | new_hostname.remove(0,dot+1); | 1289 | new_hostname.remove(0,dot+1); |
1294 | 1290 | ||
1295 | add_domain(new_hostname); | 1291 | add_domain(new_hostname, _ifaceppp); |
1296 | } | 1292 | } |
1297 | } | 1293 | } |
1298 | 1294 | ||
@@ -1300,7 +1296,7 @@ void auto_hostname() { | |||
1300 | 1296 | ||
1301 | // Replace the DNS domain entry in the /etc/resolv.conf file and | 1297 | // Replace the DNS domain entry in the /etc/resolv.conf file and |
1302 | // disable the nameserver entries if option is enabled | 1298 | // disable the nameserver entries if option is enabled |
1303 | void add_domain(const QString &domain) { | 1299 | void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { |
1304 | 1300 | ||
1305 | int fd; | 1301 | int fd; |
1306 | char c; | 1302 | char c; |
@@ -1309,7 +1305,7 @@ void add_domain(const QString &domain) { | |||
1309 | if (domain.isEmpty()) | 1305 | if (domain.isEmpty()) |
1310 | return; | 1306 | return; |
1311 | 1307 | ||
1312 | if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) { | 1308 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { |
1313 | 1309 | ||
1314 | int i=0; | 1310 | int i=0; |
1315 | while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { | 1311 | while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { |
@@ -1323,7 +1319,7 @@ void add_domain(const QString &domain) { | |||
1323 | close(fd); | 1319 | close(fd); |
1324 | if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; | 1320 | if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; |
1325 | 1321 | ||
1326 | if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) { | 1322 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { |
1327 | QCString tmp = "domain " + domain.local8Bit() + | 1323 | QCString tmp = "domain " + domain.local8Bit() + |
1328 | " \t\t#kppp temp entry\n"; | 1324 | " \t\t#kppp temp entry\n"; |
1329 | write(fd, tmp.data(), tmp.length()); | 1325 | write(fd, tmp.data(), tmp.length()); |
@@ -1332,7 +1328,7 @@ void add_domain(const QString &domain) { | |||
1332 | if((resolv[j].contains("domain") || | 1328 | if((resolv[j].contains("domain") || |
1333 | ( resolv[j].contains("nameserver") | 1329 | ( resolv[j].contains("nameserver") |
1334 | && !resolv[j].contains("#kppp temp entry") | 1330 | && !resolv[j].contains("#kppp temp entry") |
1335 | && PPPData::data()->exDNSDisabled())) | 1331 | && _ifaceppp->data()->exDNSDisabled())) |
1336 | && !resolv[j].contains("#entry disabled by kppp")) { | 1332 | && !resolv[j].contains("#entry disabled by kppp")) { |
1337 | QCString tmp = "# " + resolv[j].local8Bit() + | 1333 | QCString tmp = "# " + resolv[j].local8Bit() + |
1338 | " \t#entry disabled by kppp\n"; | 1334 | " \t#entry disabled by kppp\n"; |
@@ -1350,12 +1346,12 @@ void add_domain(const QString &domain) { | |||
1350 | 1346 | ||
1351 | 1347 | ||
1352 | // adds the DNS entries in the /etc/resolv.conf file | 1348 | // adds the DNS entries in the /etc/resolv.conf file |
1353 | void adddns() | 1349 | void adddns( InterfacePPP *_ifaceppp) |
1354 | { | 1350 | { |
1355 | int fd; | 1351 | int fd; |
1356 | 1352 | ||
1357 | if ((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { | 1353 | if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { |
1358 | QStringList &dnslist = PPPData::data()->dns(); | 1354 | QStringList &dnslist = _ifaceppp->data()->dns(); |
1359 | for ( QStringList::Iterator it = dnslist.begin(); | 1355 | for ( QStringList::Iterator it = dnslist.begin(); |
1360 | it != dnslist.end(); | 1356 | it != dnslist.end(); |
1361 | ++it ) | 1357 | ++it ) |
@@ -1366,13 +1362,13 @@ void adddns() | |||
1366 | } | 1362 | } |
1367 | close(fd); | 1363 | close(fd); |
1368 | } | 1364 | } |
1369 | add_domain(PPPData::data()->domain()); | 1365 | add_domain(_ifaceppp->data()->domain(), _ifaceppp); |
1370 | } | 1366 | } |
1371 | 1367 | ||
1372 | void addpeerdns() { | 1368 | void addpeerdns(InterfacePPP *_ifaceppp) { |
1373 | int fd, fd2; | 1369 | int fd, fd2; |
1374 | 1370 | ||
1375 | if((fd = Modem::modem->openResolv(O_WRONLY|O_APPEND)) >= 0) { | 1371 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { |
1376 | if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { | 1372 | if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { |
1377 | char c; | 1373 | char c; |
1378 | int i = 0; | 1374 | int i = 0; |
@@ -1387,17 +1383,17 @@ void addpeerdns() { | |||
1387 | fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); | 1383 | fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); |
1388 | close(fd); | 1384 | close(fd); |
1389 | } | 1385 | } |
1390 | add_domain(PPPData::data()->domain()); | 1386 | add_domain(_ifaceppp->data()->domain(), _ifaceppp); |
1391 | } | 1387 | } |
1392 | 1388 | ||
1393 | // remove the dns entries from the /etc/resolv.conf file | 1389 | // remove the dns entries from the /etc/resolv.conf file |
1394 | void removedns() { | 1390 | void removedns(InterfacePPP *_ifaceppp) { |
1395 | 1391 | ||
1396 | int fd; | 1392 | int fd; |
1397 | char c; | 1393 | char c; |
1398 | QString resolv[MAX_RESOLVCONF_LINES]; | 1394 | QString resolv[MAX_RESOLVCONF_LINES]; |
1399 | 1395 | ||
1400 | if((fd = Modem::modem->openResolv(O_RDONLY)) >= 0) { | 1396 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { |
1401 | 1397 | ||
1402 | int i=0; | 1398 | int i=0; |
1403 | while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { | 1399 | while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { |
@@ -1410,7 +1406,7 @@ void removedns() { | |||
1410 | } | 1406 | } |
1411 | close(fd); | 1407 | close(fd); |
1412 | 1408 | ||
1413 | if((fd = Modem::modem->openResolv(O_WRONLY|O_TRUNC)) >= 0) { | 1409 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { |
1414 | for(int j=0; j < i; j++) { | 1410 | for(int j=0; j < i; j++) { |
1415 | if(resolv[j].contains("#kppp temp entry")) continue; | 1411 | if(resolv[j].contains("#kppp temp entry")) continue; |
1416 | if(resolv[j].contains("#entry disabled by kppp")) { | 1412 | if(resolv[j].contains("#entry disabled by kppp")) { |
@@ -1429,7 +1425,7 @@ void removedns() { | |||
1429 | } | 1425 | } |
1430 | 1426 | ||
1431 | if ( modified_hostname ) { | 1427 | if ( modified_hostname ) { |
1432 | Modem::modem->setHostname(old_hostname); | 1428 | _ifaceppp->modem()->setHostname(old_hostname); |
1433 | modified_hostname = FALSE; | 1429 | modified_hostname = FALSE; |
1434 | } | 1430 | } |
1435 | 1431 | ||