summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/connect.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/connect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp166
1 files changed, 95 insertions, 71 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 2400d7b..e3fab24 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -29,13 +29,12 @@
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qregexp.h> 30#include <qregexp.h>
31 31
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <kdebug.h> 33//#include <kdebug.h>
34//#include <klocale.h> 34//#include <klocale.h>
35#define i18n QObject::tr
36#include <qmessagebox.h> 35#include <qmessagebox.h>
37#include <qpushbutton.h> 36#include <qpushbutton.h>
38 37
39#include <unistd.h> 38#include <unistd.h>
40#include <stdlib.h> 39#include <stdlib.h>
41#include <string.h> 40#include <string.h>
@@ -96,44 +95,44 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam
96 dialnumber(0), 95 dialnumber(0),
97 _ifaceppp(ifp) 96 _ifaceppp(ifp)
98{ 97{
99 modified_hostname = false; 98 modified_hostname = false;
100 99
101 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); 100 QVBoxLayout *tl = new QVBoxLayout(this, 8, 10);
102 QString tit = i18n("Connecting to: "); 101 QString tit = QObject::tr("Connecting to: ");
103 setCaption(tit); 102 setCaption(tit);
104 103
105 QHBoxLayout *l0 = new QHBoxLayout(10); 104 QHBoxLayout *l0 = new QHBoxLayout(10);
106 tl->addLayout(l0); 105 tl->addLayout(l0);
107 l0->addSpacing(10); 106 l0->addSpacing(10);
108 messg = new QLabel(this, "messg"); 107 messg = new QLabel(this, "messg");
109 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); 108 messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
110 messg->setAlignment(AlignCenter); 109 messg->setAlignment(AlignCenter);
111 messg->setText(i18n("Unable to create modem lock file.")); 110 messg->setText(QObject::tr("Unable to create modem lock file."));
112 messg->setMinimumHeight(messg->sizeHint().height() + 5); 111 messg->setMinimumHeight(messg->sizeHint().height() + 5);
113// int messw = (messg->sizeHint().width() * 12) / 10; 112// int messw = (messg->sizeHint().width() * 12) / 10;
114// messw = QMAX(messw,280); 113// messw = QMAX(messw,280);
115// messg->setMinimumWidth(messw); 114// messg->setMinimumWidth(messw);
116 if (_ifaceppp->getStatus()) 115 if (_ifaceppp->getStatus())
117 messg->setText(i18n("Online")); 116 messg->setText(QObject::tr("Online"));
118 else 117 else
119 messg->setText(i18n("Offline")); 118 messg->setText(QObject::tr("Offline"));
120 l0->addSpacing(10); 119 l0->addSpacing(10);
121 l0->addWidget(messg); 120 l0->addWidget(messg);
122 l0->addSpacing(10); 121 l0->addSpacing(10);
123 122
124 QHBoxLayout *l1 = new QHBoxLayout(10); 123 QHBoxLayout *l1 = new QHBoxLayout(10);
125 tl->addLayout(l1); 124 tl->addLayout(l1);
126 l1->addStretch(1); 125 l1->addStretch(1);
127 126
128 debug = new QPushButton(i18n("Log"), this); 127 debug = new QPushButton(QObject::tr("Log"), this);
129 debug->setToggleButton(true); 128 debug->setToggleButton(true);
130 debug->setEnabled( false ); // FIXME: disable the log button 129 debug->setEnabled( false ); // FIXME: disable the log button
131 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); 130 connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
132 131
133 cancel = new QPushButton(i18n("Cancel"), this); 132 cancel = new QPushButton(QObject::tr("Cancel"), this);
134 cancel->setFocus(); 133 cancel->setFocus();
135 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); 134 connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
136 135
137// int maxw = QMAX(cancel->sizeHint().width(), 136// int maxw = QMAX(cancel->sizeHint().width(),
138 // debug->sizeHint().width()); 137 // debug->sizeHint().width());
139// maxw = QMAX(maxw,65); 138// maxw = QMAX(maxw,65);
@@ -170,13 +169,13 @@ ConnectWidget::~ConnectWidget() {
170} 169}
171 170
172 171
173void ConnectWidget::preinit() { 172void ConnectWidget::preinit() {
174 // this is all just to keep the GUI nice and snappy .... 173 // this is all just to keep the GUI nice and snappy ....
175 // you have to see to believe ... 174 // you have to see to believe ...
176 messg->setText(i18n("Looking for modem...")); 175 messg->setText(QObject::tr("Looking for modem..."));
177 inittimer->start(100); 176 inittimer->start(100);
178} 177}
179 178
180 179
181void ConnectWidget::init() { 180void ConnectWidget::init() {
182 _ifaceppp->data()->setpppdError(0); 181 _ifaceppp->data()->setpppdError(0);
@@ -198,21 +197,21 @@ void ConnectWidget::init() {
198 197
199// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); 198// p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect());
200 199
201 comlist = &_ifaceppp->data()->scriptType(); 200 comlist = &_ifaceppp->data()->scriptType();
202 arglist = &_ifaceppp->data()->script(); 201 arglist = &_ifaceppp->data()->script();
203 202
204 QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); 203 QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname());
205 setCaption(tit); 204 setCaption(tit);
206 205
207 qApp->processEvents(); 206 qApp->processEvents();
208 207
209 // run the "before-connect" command 208 // run the "before-connect" command
210 if (!_ifaceppp->data()->command_before_connect().isEmpty()) { 209 if (!_ifaceppp->data()->command_before_connect().isEmpty()) {
211 messg->setText(i18n("Running pre-startup command...")); 210 messg->setText(QObject::tr("Running pre-startup command..."));
212 emit debugMessage(i18n("Running pre-startup command...")); 211 emit debugMessage(QObject::tr("Running pre-startup command..."));
213 212
214 qApp->processEvents(); 213 qApp->processEvents();
215 QApplication::flushX(); 214 QApplication::flushX();
216 pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); 215 pid_t id = execute_command(_ifaceppp->data()->command_before_connect());
217// int i, status; 216// int i, status;
218 217
@@ -223,19 +222,19 @@ void ConnectWidget::init() {
223// } while (i == 0 && errno == 0); 222// } while (i == 0 && errno == 0);
224 } 223 }
225 224
226 int lock = _ifaceppp->modem()->lockdevice(); 225 int lock = _ifaceppp->modem()->lockdevice();
227 226
228 if (lock == 1) { 227 if (lock == 1) {
229 messg->setText(i18n("Modem device is locked.")); 228 messg->setText(QObject::tr("Modem device is locked."));
230 vmain = 20; // wait until cancel is pressed 229 vmain = 20; // wait until cancel is pressed
231 return; 230 return;
232 } 231 }
233 232
234 if (lock == -1) { 233 if (lock == -1) {
235 messg->setText(i18n("Unable to create modem lock file.")); 234 messg->setText(QObject::tr("Unable to create modem lock file."));
236 vmain = 20; // wait until cancel is pressed 235 vmain = 20; // wait until cancel is pressed
237 return; 236 return;
238 } 237 }
239 238
240 if(_ifaceppp->modem()->opentty()) { 239 if(_ifaceppp->modem()->opentty()) {
241 messg->setText(_ifaceppp->modem()->modemMessage()); 240 messg->setText(_ifaceppp->modem()->modemMessage());
@@ -276,14 +275,14 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
276 return; 275 return;
277#endif 276#endif
278 277
279 assert(PPPData::NumInitStrings > 0); 278 assert(PPPData::NumInitStrings > 0);
280 // first init string ? 279 // first init string ?
281 if(substate == -1) { 280 if(substate == -1) {
282 messg->setText(i18n("Initializing modem...")); 281 messg->setText(QObject::tr("Initializing modem..."));
283 emit debugMessage(i18n("Initializing modem...")); 282 emit debugMessage(QObject::tr("Initializing modem..."));
284 substate = 0; 283 substate = 0;
285 } 284 }
286 285
287 QString initStr = _ifaceppp->data()->modemInitStr(substate); 286 QString initStr = _ifaceppp->data()->modemInitStr(substate);
288 if (!initStr.isEmpty()) { 287 if (!initStr.isEmpty()) {
289 // send a carriage return and then wait a bit so that the modem will 288 // send a carriage return and then wait a bit so that the modem will
@@ -314,13 +313,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
314 return; 313 return;
315 } 314 }
316 315
317 if (vmain == 5) { 316 if (vmain == 5) {
318 if(!expecting) { 317 if(!expecting) {
319 QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); 318 QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration());
320 QString msg = i18n("Setting ") + sToneDuration; 319 QString msg = QObject::tr("Setting ") + sToneDuration;
321 messg->setText(msg); 320 messg->setText(msg);
322 emit debugMessage(msg); 321 emit debugMessage(msg);
323 setExpect(_ifaceppp->data()->modemInitResp()); 322 setExpect(_ifaceppp->data()->modemInitResp());
324 writeline(sToneDuration); 323 writeline(sToneDuration);
325 } 324 }
326 vmain = 3; 325 vmain = 3;
@@ -337,14 +336,14 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
337 substate = -1; 336 substate = -1;
338 // skip setting the volume if command is empty 337 // skip setting the volume if command is empty
339 if(_ifaceppp->data()->volumeInitString().isEmpty()) { 338 if(_ifaceppp->data()->volumeInitString().isEmpty()) {
340 vmain = 4; 339 vmain = 4;
341 return; 340 return;
342 } 341 }
343 messg->setText(i18n("Setting speaker volume...")); 342 messg->setText(QObject::tr("Setting speaker volume..."));
344 emit debugMessage(i18n("Setting speaker volume...")); 343 emit debugMessage(QObject::tr("Setting speaker volume..."));
345 344
346 setExpect(_ifaceppp->data()->modemInitResp()); 345 setExpect(_ifaceppp->data()->modemInitResp());
347 QString vol("AT"); 346 QString vol("AT");
348 vol += _ifaceppp->data()->volumeInitString(); 347 vol += _ifaceppp->data()->volumeInitString();
349 writeline(vol); 348 writeline(vol);
350 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec 349 usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec
@@ -353,13 +352,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
353 } 352 }
354 } 353 }
355 354
356 if(vmain == 4) { 355 if(vmain == 4) {
357 if(!expecting) { 356 if(!expecting) {
358 if(!_ifaceppp->data()->waitForDialTone()) { 357 if(!_ifaceppp->data()->waitForDialTone()) {
359 QString msg = i18n("Turning off dial tone waiting..."); 358 QString msg = QObject::tr("Turning off dial tone waiting...");
360 messg->setText(msg); 359 messg->setText(msg);
361 emit debugMessage(msg); 360 emit debugMessage(msg);
362 setExpect(_ifaceppp->data()->modemInitResp()); 361 setExpect(_ifaceppp->data()->modemInitResp());
363 writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); 362 writeline(_ifaceppp->data()->modemNoDialToneDetectionStr());
364 } 363 }
365 vmain = 1; 364 vmain = 1;
@@ -374,13 +373,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
374 timeout_timer->stop(); 373 timeout_timer->stop();
375 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); 374 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
376 375
377 QStringList &plist = _ifaceppp->data()->phonenumbers(); 376 QStringList &plist = _ifaceppp->data()->phonenumbers();
378 QString bmarg= _ifaceppp->data()->dialPrefix(); 377 QString bmarg= _ifaceppp->data()->dialPrefix();
379 bmarg += *plist.at(dialnumber); 378 bmarg += *plist.at(dialnumber);
380 QString bm = i18n("Dialing %1").arg(bmarg); 379 QString bm = QObject::tr("Dialing %1").arg(bmarg);
381 messg->setText(bm); 380 messg->setText(bm);
382 emit debugMessage(bm); 381 emit debugMessage(bm);
383 382
384 QString pn = _ifaceppp->data()->modemDialStr(); 383 QString pn = _ifaceppp->data()->modemDialStr();
385 pn += _ifaceppp->data()->dialPrefix(); 384 pn += _ifaceppp->data()->dialPrefix();
386 pn += *plist.at(dialnumber); 385 pn += *plist.at(dialnumber);
@@ -405,18 +404,18 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
405 } 404 }
406 405
407 if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { 406 if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) {
408 timeout_timer->stop(); 407 timeout_timer->stop();
409 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); 408 timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000);
410 409
411 messg->setText(i18n("Line busy. Hanging up...")); 410 messg->setText(QObject::tr("Line busy. Hanging up..."));
412 emit debugPutChar('\n'); 411 emit debugPutChar('\n');
413 _ifaceppp->modem()->hangup(); 412 _ifaceppp->modem()->hangup();
414 413
415 if(_ifaceppp->data()->busyWait() > 0) { 414 if(_ifaceppp->data()->busyWait() > 0) {
416 QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); 415 QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait());
417 messg->setText(bm); 416 messg->setText(bm);
418 emit debugMessage(bm); 417 emit debugMessage(bm);
419 418
420 pausing = true; 419 pausing = true;
421 420
422 pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); 421 pausetimer->start(_ifaceppp->data()->busyWait()*1000, true);
@@ -429,22 +428,22 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
429 return; 428 return;
430 } 429 }
431 430
432 if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { 431 if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) {
433 timeout_timer->stop(); 432 timeout_timer->stop();
434 433
435 messg->setText(i18n("No Dialtone")); 434 messg->setText(QObject::tr("No Dialtone"));
436 vmain = 20; 435 vmain = 20;
437 _ifaceppp->modem()->unlockdevice(); 436 _ifaceppp->modem()->unlockdevice();
438 return; 437 return;
439 } 438 }
440 439
441 if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { 440 if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) {
442 timeout_timer->stop(); 441 timeout_timer->stop();
443 442
444 messg->setText(i18n("No Carrier")); 443 messg->setText(QObject::tr("No Carrier"));
445 vmain = 20; 444 vmain = 20;
446 _ifaceppp->modem()->unlockdevice(); 445 _ifaceppp->modem()->unlockdevice();
447 return; 446 return;
448 } 447 }
449 } 448 }
450 449
@@ -476,23 +475,23 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
476 qDebug( "End of script" ); 475 qDebug( "End of script" );
477 vmain = 10; 476 vmain = 10;
478 return; 477 return;
479 } 478 }
480 479
481 if (scriptCommand == "Scan") { 480 if (scriptCommand == "Scan") {
482 QString bm = i18n("Scanning %1").arg(scriptArgument); 481 QString bm = QObject::tr("Scanning %1").arg(scriptArgument);
483 messg->setText(bm); 482 messg->setText(bm);
484 emit debugMessage(bm); 483 emit debugMessage(bm);
485 484
486 setScan(scriptArgument); 485 setScan(scriptArgument);
487 scriptindex++; 486 scriptindex++;
488 return; 487 return;
489 } 488 }
490 489
491 if (scriptCommand == "Save") { 490 if (scriptCommand == "Save") {
492 QString bm = i18n("Saving %1").arg(scriptArgument); 491 QString bm = QObject::tr("Saving %1").arg(scriptArgument);
493 messg->setText(bm); 492 messg->setText(bm);
494 emit debugMessage(bm); 493 emit debugMessage(bm);
495 494
496 if (scriptArgument.lower() == "password") { 495 if (scriptArgument.lower() == "password") {
497 _ifaceppp->data()->setPassword(scanvar); 496 _ifaceppp->data()->setPassword(scanvar);
498 // p_kppp->setPW_Edit(scanvar); 497 // p_kppp->setPW_Edit(scanvar);
@@ -504,13 +503,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
504 scriptindex++; 503 scriptindex++;
505 return; 504 return;
506 } 505 }
507 506
508 507
509 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { 508 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
510 QString bm = i18n("Sending %1"); 509 QString bm = QObject::tr("Sending %1");
511 510
512 // replace %USERNAME% and %PASSWORD% 511 // replace %USERNAME% and %PASSWORD%
513 QString arg = scriptArgument; 512 QString arg = scriptArgument;
514 QRegExp re1("%USERNAME%"); 513 QRegExp re1("%USERNAME%");
515 QRegExp re2("%PASSWORD%"); 514 QRegExp re2("%PASSWORD%");
516 arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); 515 arg = arg.replace(re1, _ifaceppp->data()->storedUsername());
@@ -529,13 +528,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
529 writeline(scriptArgument); 528 writeline(scriptArgument);
530 scriptindex++; 529 scriptindex++;
531 return; 530 return;
532 } 531 }
533 532
534 if (scriptCommand == "Expect") { 533 if (scriptCommand == "Expect") {
535 QString bm = i18n("Expecting %1").arg(scriptArgument); 534 QString bm = QObject::tr("Expecting %1").arg(scriptArgument);
536 messg->setText(bm); 535 messg->setText(bm);
537 emit debugMessage(bm); 536 emit debugMessage(bm);
538 537
539 // The incrementing of the scriptindex MUST be before the 538 // The incrementing of the scriptindex MUST be before the
540 // call to setExpect otherwise the expect will miss a string that is 539 // call to setExpect otherwise the expect will miss a string that is
541 // already in the buffer. 540 // already in the buffer.
@@ -543,13 +542,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
543 setExpect(scriptArgument); 542 setExpect(scriptArgument);
544 return; 543 return;
545 } 544 }
546 545
547 546
548 if (scriptCommand == "Pause") { 547 if (scriptCommand == "Pause") {
549 QString bm = i18n("Pause %1 seconds").arg(scriptArgument); 548 QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument);
550 messg->setText(bm); 549 messg->setText(bm);
551 emit debugMessage(bm); 550 emit debugMessage(bm);
552 551
553 pausing = true; 552 pausing = true;
554 553
555 pausetimer->start(scriptArgument.toInt()*1000, true); 554 pausetimer->start(scriptArgument.toInt()*1000, true);
@@ -560,48 +559,48 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
560 } 559 }
561 560
562 if (scriptCommand == "Timeout") { 561 if (scriptCommand == "Timeout") {
563 562
564 timeout_timer->stop(); 563 timeout_timer->stop();
565 564
566 QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); 565 QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument);
567 messg->setText(bm); 566 messg->setText(bm);
568 emit debugMessage(bm); 567 emit debugMessage(bm);
569 568
570 scriptTimeout=scriptArgument.toInt()*1000; 569 scriptTimeout=scriptArgument.toInt()*1000;
571 timeout_timer->start(scriptTimeout); 570 timeout_timer->start(scriptTimeout);
572 571
573 scriptindex++; 572 scriptindex++;
574 return; 573 return;
575 } 574 }
576 575
577 if (scriptCommand == "Hangup") { 576 if (scriptCommand == "Hangup") {
578 messg->setText(i18n("Hangup")); 577 messg->setText(QObject::tr("Hangup"));
579 emit debugMessage(i18n("Hangup")); 578 emit debugMessage(QObject::tr("Hangup"));
580 579
581 writeline(_ifaceppp->data()->modemHangupStr()); 580 writeline(_ifaceppp->data()->modemHangupStr());
582 setExpect(_ifaceppp->data()->modemHangupResp()); 581 setExpect(_ifaceppp->data()->modemHangupResp());
583 582
584 scriptindex++; 583 scriptindex++;
585 return; 584 return;
586 } 585 }
587 586
588 if (scriptCommand == "Answer") { 587 if (scriptCommand == "Answer") {
589 588
590 timeout_timer->stop(); 589 timeout_timer->stop();
591 590
592 messg->setText(i18n("Answer")); 591 messg->setText(QObject::tr("Answer"));
593 emit debugMessage(i18n("Answer")); 592 emit debugMessage(QObject::tr("Answer"));
594 593
595 setExpect(_ifaceppp->data()->modemRingResp()); 594 setExpect(_ifaceppp->data()->modemRingResp());
596 vmain = 150; 595 vmain = 150;
597 return; 596 return;
598 } 597 }
599 598
600 if (scriptCommand == "ID") { 599 if (scriptCommand == "ID") {
601 QString bm = i18n("ID %1").arg(scriptArgument); 600 QString bm = QObject::tr("ID %1").arg(scriptArgument);
602 messg->setText(bm); 601 messg->setText(bm);
603 emit debugMessage(bm); 602 emit debugMessage(bm);
604 603
605 QString idstring = _ifaceppp->data()->password(); 604 QString idstring = _ifaceppp->data()->password();
606 605
607 if(!idstring.isEmpty() && firstrunID) { 606 if(!idstring.isEmpty() && firstrunID) {
@@ -631,13 +630,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
631 /* replace timeout value */ 630 /* replace timeout value */
632 } 631 }
633 } 632 }
634 } 633 }
635 634
636 if (scriptCommand == "Password") { 635 if (scriptCommand == "Password") {
637 QString bm = i18n("Password %1").arg(scriptArgument); 636 QString bm = QObject::tr("Password %1").arg(scriptArgument);
638 messg->setText(bm); 637 messg->setText(bm);
639 emit debugMessage(bm); 638 emit debugMessage(bm);
640 639
641 QString pwstring = _ifaceppp->data()->password(); 640 QString pwstring = _ifaceppp->data()->password();
642 641
643 if(!pwstring.isEmpty() && firstrunPW) { 642 if(!pwstring.isEmpty() && firstrunPW) {
@@ -668,13 +667,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
668 /* replace timeout value */ 667 /* replace timeout value */
669 } 668 }
670 } 669 }
671 } 670 }
672 671
673 if (scriptCommand == "Prompt") { 672 if (scriptCommand == "Prompt") {
674 QString bm = i18n("Prompting %1"); 673 QString bm = QObject::tr("Prompting %1");
675 674
676 // if the scriptindex (aka the prompt text) includes a ## marker 675 // if the scriptindex (aka the prompt text) includes a ## marker
677 // this marker should get substituted with the contents of our stored 676 // this marker should get substituted with the contents of our stored
678 // variable (from the subsequent scan). 677 // variable (from the subsequent scan).
679 678
680 QString ts = scriptArgument; 679 QString ts = scriptArgument;
@@ -705,13 +704,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
705 } 704 }
706 /* replace timeout value */ 705 /* replace timeout value */
707 } 706 }
708 } 707 }
709 708
710 if (scriptCommand == "PWPrompt") { 709 if (scriptCommand == "PWPrompt") {
711 QString bm = i18n("PW Prompt %1").arg(scriptArgument); 710 QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument);
712 messg->setText(bm); 711 messg->setText(bm);
713 emit debugMessage(bm); 712 emit debugMessage(bm);
714 713
715 /* if not around yet, then post window... */ 714 /* if not around yet, then post window... */
716 if (prompt->Consumed()) { 715 if (prompt->Consumed()) {
717 if (!(prompt->isVisible())) { 716 if (!(prompt->isVisible())) {
@@ -730,24 +729,24 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
730 /* replace timeout value */ 729 /* replace timeout value */
731 } 730 }
732 } 731 }
733 732
734 if (scriptCommand == "LoopStart") { 733 if (scriptCommand == "LoopStart") {
735 734
736 QString bm = i18n("Loop Start %1").arg(scriptArgument); 735 QString bm = QObject::tr("Loop Start %1").arg(scriptArgument);
737 736
738 // The incrementing of the scriptindex MUST be before the 737 // The incrementing of the scriptindex MUST be before the
739 // call to setExpect otherwise the expect will miss a string that is 738 // call to setExpect otherwise the expect will miss a string that is
740 // already in the buffer. 739 // already in the buffer.
741 scriptindex++; 740 scriptindex++;
742 741
743 if ( loopnest > (MAXLOOPNEST-2) ) { 742 if ( loopnest > (MAXLOOPNEST-2) ) {
744 bm += i18n("ERROR: Nested too deep, ignored."); 743 bm += QObject::tr("ERROR: Nested too deep, ignored.");
745 vmain=20; 744 vmain=20;
746 cancelbutton(); 745 cancelbutton();
747 QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); 746 QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!"));
748 } else { 747 } else {
749 setExpect(scriptArgument); 748 setExpect(scriptArgument);
750 loopstartindex[loopnest] = scriptindex; 749 loopstartindex[loopnest] = scriptindex;
751 loopstr[loopnest] = scriptArgument; 750 loopstr[loopnest] = scriptArgument;
752 loopend = false; 751 loopend = false;
753 loopnest++; 752 loopnest++;
@@ -755,15 +754,15 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
755 messg->setText(bm); 754 messg->setText(bm);
756 emit debugMessage(bm); 755 emit debugMessage(bm);
757 756
758 } 757 }
759 758
760 if (scriptCommand == "LoopEnd") { 759 if (scriptCommand == "LoopEnd") {
761 QString bm = i18n("Loop End %1").arg(scriptArgument); 760 QString bm = QObject::tr("Loop End %1").arg(scriptArgument);
762 if ( loopnest <= 0 ) { 761 if ( loopnest <= 0 ) {
763 bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); 762 bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm);
764 vmain=20; 763 vmain=20;
765 cancelbutton(); 764 cancelbutton();
766 QMessageBox::critical(0, "error", bm); 765 QMessageBox::critical(0, "error", bm);
767 return; 766 return;
768 } else { 767 } else {
769 // NB! The incrementing of the scriptindex MUST be before the 768 // NB! The incrementing of the scriptindex MUST be before the
@@ -845,13 +844,13 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
845// stats->setUnit(pppInterfaceNumber()); 844// stats->setUnit(pppInterfaceNumber());
846 845
847 qApp->flushX(); 846 qApp->flushX();
848 semaphore = true; 847 semaphore = true;
849 result = execppp(); 848 result = execppp();
850 849
851 emit debugMessage(i18n("Starting pppd...")); 850 emit debugMessage(QObject::tr("Starting pppd..."));
852 qDebug("execppp() returned with return-code %i", result ); 851 qDebug("execppp() returned with return-code %i", result );
853 852
854 if(result) { 853 if(result) {
855 if(!_ifaceppp->data()->autoDNS()) 854 if(!_ifaceppp->data()->autoDNS())
856 adddns( _ifaceppp ); 855 adddns( _ifaceppp );
857 856
@@ -927,34 +926,34 @@ void ConnectWidget::checkBuffers() {
927 926
928 int vstart = scanbuffer.find( scanstr ) + scanstr.length(); 927 int vstart = scanbuffer.find( scanstr ) + scanstr.length();
929 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); 928 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
930 scanvar = scanvar.stripWhiteSpace(); 929 scanvar = scanvar.stripWhiteSpace();
931 930
932 // Show the Variabel content in the debug window 931 // Show the Variabel content in the debug window
933 QString sv = i18n("Scan Var: %1").arg(scanvar); 932 QString sv = QObject::tr("Scan Var: %1").arg(scanvar);
934 emit debugMessage(sv); 933 emit debugMessage(sv);
935 } 934 }
936 935
937 if(expecting) { 936 if(expecting) {
938 if(readbuffer.contains(expectstr)) { 937 if(readbuffer.contains(expectstr)) {
939 expecting = false; 938 expecting = false;
940 // keep everything after the expected string 939 // keep everything after the expected string
941 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); 940 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
942 941
943 QString ts = i18n("Found: %1").arg(expectstr); 942 QString ts = QObject::tr("Found: %1").arg(expectstr);
944 emit debugMessage(ts); 943 emit debugMessage(ts);
945 944
946 if (loopend) { 945 if (loopend) {
947 loopend=false; 946 loopend=false;
948 } 947 }
949 } 948 }
950 949
951 if (loopend && readbuffer.contains(loopstr[loopnest])) { 950 if (loopend && readbuffer.contains(loopstr[loopnest])) {
952 expecting = false; 951 expecting = false;
953 readbuffer = ""; 952 readbuffer = "";
954 QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); 953 QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]);
955 emit debugMessage(ts); 954 emit debugMessage(ts);
956 scriptindex = loopstartindex[loopnest]; 955 scriptindex = loopstartindex[loopnest];
957 loopend = false; 956 loopend = false;
958 loopnest++; 957 loopnest++;
959 } 958 }
960 // notify event loop if expected string was found 959 // notify event loop if expected string was found
@@ -981,13 +980,13 @@ void ConnectWidget::cancelbutton() {
981// if (termwindow) { 980// if (termwindow) {
982// delete termwindow; 981// delete termwindow;
983// termwindow = 0L; 982// termwindow = 0L;
984// this->show(); 983// this->show();
985// } 984// }
986 985
987 messg->setText(i18n("One moment please...")); 986 messg->setText(QObject::tr("One moment please..."));
988 987
989 // just to be sure 988 // just to be sure
990 _ifaceppp->modem()->removeSecret(AUTH_PAP); 989 _ifaceppp->modem()->removeSecret(AUTH_PAP);
991 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 990 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
992 removedns(_ifaceppp); 991 removedns(_ifaceppp);
993 992
@@ -1003,17 +1002,20 @@ void ConnectWidget::cancelbutton() {
1003// p_kppp->con_win->stopClock(); 1002// p_kppp->con_win->stopClock();
1004 _ifaceppp->modem()->closetty(); 1003 _ifaceppp->modem()->closetty();
1005 _ifaceppp->modem()->unlockdevice(); 1004 _ifaceppp->modem()->unlockdevice();
1006 1005
1007 //abort prompt window... 1006 //abort prompt window...
1008 if (prompt->isVisible()) { 1007 if (prompt->isVisible()) {
1009 prompt->hide(); 1008 prompt->hide();
1010 } 1009 }
1011 prompt->setConsumed(); 1010 prompt->setConsumed();
1012 1011
1013 messg->setText(tr("offline")); 1012 _ifaceppp->setStatus( false );
1013 _ifaceppp->refresh();
1014// messg->setText(tr("offline"));
1015 refresh();
1014} 1016}
1015 1017
1016 1018
1017void ConnectWidget::script_timed_out() { 1019void ConnectWidget::script_timed_out() {
1018 if(vmain == 20) { // we are in the 'wait for the user to cancel' state 1020 if(vmain == 20) { // we are in the 'wait for the user to cancel' state
1019 timeout_timer->stop(); 1021 timeout_timer->stop();
@@ -1023,13 +1025,13 @@ void ConnectWidget::script_timed_out() {
1023 } 1025 }
1024 1026
1025 if (prompt->isVisible()) 1027 if (prompt->isVisible())
1026 prompt->hide(); 1028 prompt->hide();
1027 1029
1028 prompt->setConsumed(); 1030 prompt->setConsumed();
1029 messg->setText(i18n("Script timed out!")); 1031 messg->setText(QObject::tr("Script timed out!"));
1030 _ifaceppp->modem()->hangup(); 1032 _ifaceppp->modem()->hangup();
1031 emit stopAccounting(); 1033 emit stopAccounting();
1032// p_kppp->con_win->stopClock(); 1034// p_kppp->con_win->stopClock();
1033 1035
1034 vmain = 0; // let's try again. 1036 vmain = 0; // let's try again.
1035 substate = -1; 1037 substate = -1;
@@ -1038,22 +1040,22 @@ void ConnectWidget::script_timed_out() {
1038 1040
1039void ConnectWidget::setScan(const QString &n) { 1041void ConnectWidget::setScan(const QString &n) {
1040 scanning = true; 1042 scanning = true;
1041 scanstr = n; 1043 scanstr = n;
1042 scanbuffer = ""; 1044 scanbuffer = "";
1043 1045
1044 QString ts = i18n("Scanning: %1").arg(n); 1046 QString ts = QObject::tr("Scanning: %1").arg(n);
1045 emit debugMessage(ts); 1047 emit debugMessage(ts);
1046} 1048}
1047 1049
1048 1050
1049void ConnectWidget::setExpect(const QString &n) { 1051void ConnectWidget::setExpect(const QString &n) {
1050 expecting = true; 1052 expecting = true;
1051 expectstr = n; 1053 expectstr = n;
1052 1054
1053 QString ts = i18n("Expecting: %1").arg(n); 1055 QString ts = QObject::tr("Expecting: %1").arg(n);
1054 ts.replace(QRegExp("\n"), "<LF>"); 1056 ts.replace(QRegExp("\n"), "<LF>");
1055 emit debugMessage(ts); 1057 emit debugMessage(ts);
1056 1058
1057 // check if the expected string is in the read buffer already. 1059 // check if the expected string is in the read buffer already.
1058 checkBuffers(); 1060 checkBuffers();
1059} 1061}
@@ -1082,13 +1084,13 @@ void ConnectWidget::pppdDied()
1082{ 1084{
1083 if_timer->stop(); 1085 if_timer->stop();
1084 if_timeout_timer->stop(); 1086 if_timeout_timer->stop();
1085} 1087}
1086 1088
1087void ConnectWidget::if_waiting_slot() { 1089void ConnectWidget::if_waiting_slot() {
1088 messg->setText(i18n("Logging on to network...")); 1090 messg->setText(QObject::tr("Logging on to network..."));
1089 1091
1090// if(!stats->ifIsUp()) { 1092// if(!stats->ifIsUp()) {
1091 1093
1092// if(_ifaceppp->data()->pppdError() != 0) { 1094// if(_ifaceppp->data()->pppdError() != 0) {
1093// // we are here if pppd died immediately after starting it. 1095// // we are here if pppd died immediately after starting it.
1094// pppdDied(); 1096// pppdDied();
@@ -1113,32 +1115,37 @@ void ConnectWidget::if_waiting_slot() {
1113 // are not really interested in debug output 1115 // are not really interested in debug output
1114 emit closeDebugWindow(); 1116 emit closeDebugWindow();
1115// p_kppp->statdlg->take_stats(); // start taking ppp statistics 1117// p_kppp->statdlg->take_stats(); // start taking ppp statistics
1116 auto_hostname(_ifaceppp); 1118 auto_hostname(_ifaceppp);
1117 1119
1118 if(!_ifaceppp->data()->command_on_connect().isEmpty()) { 1120 if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
1119 messg->setText(i18n("Running startup command...")); 1121 messg->setText(QObject::tr("Running startup command..."));
1120 1122
1121 // make sure that we don't get any async errors 1123 // make sure that we don't get any async errors
1122 qApp->flushX(); 1124 qApp->flushX();
1123 execute_command(_ifaceppp->data()->command_on_connect()); 1125 execute_command(_ifaceppp->data()->command_on_connect());
1124 messg->setText(i18n("Done")); 1126 messg->setText(QObject::tr("Done"));
1125 } 1127 }
1126 1128
1127 // remove the authentication file 1129 // remove the authentication file
1128 _ifaceppp->modem()->removeSecret(AUTH_PAP); 1130 _ifaceppp->modem()->removeSecret(AUTH_PAP);
1129 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 1131 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
1130 1132
1131 emit debugMessage(i18n("Done")); 1133 emit debugMessage(QObject::tr("Done"));
1132 set_con_speed_string(); 1134 set_con_speed_string();
1133 1135
1134// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); 1136// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
1135 this->hide(); 1137// this->hide();
1136 messg->setText(""); 1138// messg->setText("");
1137 1139
1138 _ifaceppp->setStatus( true ); 1140 _ifaceppp->setStatus( true );
1141
1142 m_refreshTimer = new QTimer( this );
1143 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
1144 m_refreshTimer->start( 3000 );
1145 //_ifaceppp->refresh();
1139 // emit _ifaceppp->updateInterface(_ifaceppp); 1146 // emit _ifaceppp->updateInterface(_ifaceppp);
1140 1147
1141 // prepare the con_win so as to have the right size for 1148 // prepare the con_win so as to have the right size for
1142 // accounting / non-accounting mode 1149 // accounting / non-accounting mode
1143// if(p_kppp->acct != 0) 1150// if(p_kppp->acct != 0)
1144// p_kppp->con_win->accounting(p_kppp->acct->running()); 1151// p_kppp->con_win->accounting(p_kppp->acct->running());
@@ -1158,12 +1165,21 @@ void ConnectWidget::if_waiting_slot() {
1158// } 1165// }
1159// } 1166// }
1160 1167
1161 _ifaceppp->modem()->closetty(); 1168 _ifaceppp->modem()->closetty();
1162} 1169}
1163 1170
1171void ConnectWidget::refresh() {
1172 _ifaceppp->refresh();
1173 if ( _ifaceppp->getStatus() ) {
1174 messg->setText(QObject::tr("Online"));
1175 } else {
1176 messg->setText(QObject::tr("Offline"));
1177 }
1178}
1179
1164 1180
1165bool ConnectWidget::execppp() { 1181bool ConnectWidget::execppp() {
1166 QString command; 1182 QString command;
1167 1183
1168 command = "pppd"; 1184 command = "pppd";
1169 1185
@@ -1207,51 +1223,59 @@ bool ConnectWidget::execppp() {
1207 if(_ifaceppp->data()->defaultroute()) 1223 if(_ifaceppp->data()->defaultroute())
1208 command += " defaultroute"; 1224 command += " defaultroute";
1209 1225
1210 if(_ifaceppp->data()->autoDNS()) 1226 if(_ifaceppp->data()->autoDNS())
1211 command += " usepeerdns"; 1227 command += " usepeerdns";
1212 1228
1213 QStringList &arglist = _ifaceppp->data()->pppdArgument();
1214 for ( QStringList::Iterator it = arglist.begin();
1215 it != arglist.end();
1216 ++it )
1217 {
1218 command += " " + *it;
1219 }
1220 1229
1221 // PAP settings 1230 // PAP settings
1222 if(_ifaceppp->data()->authMethod() == AUTH_PAP) { 1231 if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
1223 command += " -chap user "; 1232 command += " -chap user ";
1224 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; 1233 command = command + _ifaceppp->data()->storedUsername();
1225 } 1234 }
1226 1235
1227 // CHAP settings 1236 // CHAP settings
1228 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { 1237 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
1229 command += " -pap user "; 1238 command += " -pap user ";
1230 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; 1239 command = command + _ifaceppp->data()->storedUsername();
1231 } 1240 }
1232 1241
1233 // PAP/CHAP settings 1242 // PAP/CHAP settings
1234 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { 1243 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
1235 command += " user "; 1244 QString tmpName = _ifaceppp->data()->storedUsername();
1236 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; 1245 if ( !tmpName.isEmpty() ) {
1246 command += " user ";
1247 command = command + tmpName;
1248 }
1237 } 1249 }
1238 1250
1239 // check for debug 1251 // check for debug
1240 if(_ifaceppp->data()->getPPPDebug()) 1252 if(_ifaceppp->data()->getPPPDebug())
1241 command += " debug"; 1253 command += " debug";
1242 1254
1255 QStringList &arglist = _ifaceppp->data()->pppdArgument();
1256 for ( QStringList::Iterator it = arglist.begin();
1257 it != arglist.end();
1258 ++it )
1259 {
1260 command += " " + *it;
1261 }
1262
1263 command += " call opie-kppp logfd 11";
1264
1243 if (command.length() > MAX_CMDLEN) { 1265 if (command.length() > MAX_CMDLEN) {
1244 QMessageBox::critical(this, "error", i18n( 1266 QMessageBox::critical(this, "error", QObject::tr(
1245 "pppd command + command-line arguments exceed " 1267 "pppd command + command-line arguments exceed "
1246 "2024 characters in length." 1268 "2024 characters in length."
1247 )); 1269 ));
1248 1270
1249 return false; // nonsensically long command which would bust my buffer buf. 1271 return false; // nonsensically long command which would bust my buffer buf.
1250 } 1272 }
1251 1273
1274 qWarning("Command IS: %s",command.latin1() );
1275
1252 qApp->flushX(); 1276 qApp->flushX();
1253 1277
1254 return _ifaceppp->modem()->execPPPDaemon(command); 1278 return _ifaceppp->modem()->execPPPDaemon(command);
1255} 1279}
1256 1280
1257 1281