summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 798431b..6905d79 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -447,769 +447,772 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
447 447
448 // wait for newline after CONNECT response (so we get the speed) 448 // wait for newline after CONNECT response (so we get the speed)
449 if(vmain == 101) { 449 if(vmain == 101) {
450 if(!expecting) { 450 if(!expecting) {
451 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands 451 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands
452 452
453 emit startAccounting(); 453 emit startAccounting();
454// p_kppp->con_win->startClock(); 454// p_kppp->con_win->startClock();
455 455
456 vmain = 2; 456 vmain = 2;
457 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; 457 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000;
458 return; 458 return;
459 } 459 }
460 } 460 }
461 461
462 // execute the script 462 // execute the script
463 if(vmain == 2) { 463 if(vmain == 2) {
464 if(!expecting && !pausing && !scanning) { 464 if(!expecting && !pausing && !scanning) {
465 465
466 timeout_timer->stop(); 466 timeout_timer->stop();
467 timeout_timer->start(scriptTimeout); 467 timeout_timer->start(scriptTimeout);
468 468
469 if((unsigned) scriptindex < comlist->count()) { 469 if((unsigned) scriptindex < comlist->count()) {
470 scriptCommand = *(comlist->at(scriptindex)); 470 scriptCommand = *(comlist->at(scriptindex));
471 scriptArgument = *(arglist->at(scriptindex)); 471 scriptArgument = *(arglist->at(scriptindex));
472 } else { 472 } else {
473 qDebug( "End of script" ); 473 qDebug( "End of script" );
474 vmain = 10; 474 vmain = 10;
475 return; 475 return;
476 } 476 }
477 477
478 if (scriptCommand == "Scan") { 478 if (scriptCommand == "Scan") {
479 QString bm = i18n("Scanning %1").arg(scriptArgument); 479 QString bm = i18n("Scanning %1").arg(scriptArgument);
480 messg->setText(bm); 480 messg->setText(bm);
481 emit debugMessage(bm); 481 emit debugMessage(bm);
482 482
483 setScan(scriptArgument); 483 setScan(scriptArgument);
484 scriptindex++; 484 scriptindex++;
485 return; 485 return;
486 } 486 }
487 487
488 if (scriptCommand == "Save") { 488 if (scriptCommand == "Save") {
489 QString bm = i18n("Saving %1").arg(scriptArgument); 489 QString bm = i18n("Saving %1").arg(scriptArgument);
490 messg->setText(bm); 490 messg->setText(bm);
491 emit debugMessage(bm); 491 emit debugMessage(bm);
492 492
493 if (scriptArgument.lower() == "password") { 493 if (scriptArgument.lower() == "password") {
494 _ifaceppp->data()->setPassword(scanvar); 494 _ifaceppp->data()->setPassword(scanvar);
495 // p_kppp->setPW_Edit(scanvar); 495 // p_kppp->setPW_Edit(scanvar);
496 if(_ifaceppp->data()->storePassword()) 496 if(_ifaceppp->data()->storePassword())
497 _ifaceppp->data()->setStoredPassword(scanvar); 497 _ifaceppp->data()->setStoredPassword(scanvar);
498 firstrunPW = true; 498 firstrunPW = true;
499 } 499 }
500 500
501 scriptindex++; 501 scriptindex++;
502 return; 502 return;
503 } 503 }
504 504
505 505
506 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { 506 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
507 QString bm = i18n("Sending %1"); 507 QString bm = i18n("Sending %1");
508 508
509 // replace %USERNAME% and %PASSWORD% 509 // replace %USERNAME% and %PASSWORD%
510 QString arg = scriptArgument; 510 QString arg = scriptArgument;
511 QRegExp re1("%USERNAME%"); 511 QRegExp re1("%USERNAME%");
512 QRegExp re2("%PASSWORD%"); 512 QRegExp re2("%PASSWORD%");
513 arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); 513 arg = arg.replace(re1, _ifaceppp->data()->storedUsername());
514 arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); 514 arg = arg.replace(re2, _ifaceppp->data()->storedPassword());
515 515
516 if (scriptCommand == "Send") 516 if (scriptCommand == "Send")
517 bm = bm.arg(scriptArgument); 517 bm = bm.arg(scriptArgument);
518 else { 518 else {
519 for(uint i = 0; i < scriptArgument.length(); i++) 519 for(uint i = 0; i < scriptArgument.length(); i++)
520 bm = bm.arg("*"); 520 bm = bm.arg("*");
521 } 521 }
522 522
523 messg->setText(bm); 523 messg->setText(bm);
524 emit debugMessage(bm); 524 emit debugMessage(bm);
525 525
526 writeline(scriptArgument); 526 writeline(scriptArgument);
527 scriptindex++; 527 scriptindex++;
528 return; 528 return;
529 } 529 }
530 530
531 if (scriptCommand == "Expect") { 531 if (scriptCommand == "Expect") {
532 QString bm = i18n("Expecting %1").arg(scriptArgument); 532 QString bm = i18n("Expecting %1").arg(scriptArgument);
533 messg->setText(bm); 533 messg->setText(bm);
534 emit debugMessage(bm); 534 emit debugMessage(bm);
535 535
536 // The incrementing of the scriptindex MUST be before the 536 // The incrementing of the scriptindex MUST be before the
537 // call to setExpect otherwise the expect will miss a string that is 537 // call to setExpect otherwise the expect will miss a string that is
538 // already in the buffer. 538 // already in the buffer.
539 scriptindex++; 539 scriptindex++;
540 setExpect(scriptArgument); 540 setExpect(scriptArgument);
541 return; 541 return;
542 } 542 }
543 543
544 544
545 if (scriptCommand == "Pause") { 545 if (scriptCommand == "Pause") {
546 QString bm = i18n("Pause %1 seconds").arg(scriptArgument); 546 QString bm = i18n("Pause %1 seconds").arg(scriptArgument);
547 messg->setText(bm); 547 messg->setText(bm);
548 emit debugMessage(bm); 548 emit debugMessage(bm);
549 549
550 pausing = true; 550 pausing = true;
551 551
552 pausetimer->start(scriptArgument.toInt()*1000, true); 552 pausetimer->start(scriptArgument.toInt()*1000, true);
553 timeout_timer->stop(); 553 timeout_timer->stop();
554 554
555 scriptindex++; 555 scriptindex++;
556 return; 556 return;
557 } 557 }
558 558
559 if (scriptCommand == "Timeout") { 559 if (scriptCommand == "Timeout") {
560 560
561 timeout_timer->stop(); 561 timeout_timer->stop();
562 562
563 QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); 563 QString bm = i18n("Timeout %1 seconds").arg(scriptArgument);
564 messg->setText(bm); 564 messg->setText(bm);
565 emit debugMessage(bm); 565 emit debugMessage(bm);
566 566
567 scriptTimeout=scriptArgument.toInt()*1000; 567 scriptTimeout=scriptArgument.toInt()*1000;
568 timeout_timer->start(scriptTimeout); 568 timeout_timer->start(scriptTimeout);
569 569
570 scriptindex++; 570 scriptindex++;
571 return; 571 return;
572 } 572 }
573 573
574 if (scriptCommand == "Hangup") { 574 if (scriptCommand == "Hangup") {
575 messg->setText(i18n("Hangup")); 575 messg->setText(i18n("Hangup"));
576 emit debugMessage(i18n("Hangup")); 576 emit debugMessage(i18n("Hangup"));
577 577
578 writeline(_ifaceppp->data()->modemHangupStr()); 578 writeline(_ifaceppp->data()->modemHangupStr());
579 setExpect(_ifaceppp->data()->modemHangupResp()); 579 setExpect(_ifaceppp->data()->modemHangupResp());
580 580
581 scriptindex++; 581 scriptindex++;
582 return; 582 return;
583 } 583 }
584 584
585 if (scriptCommand == "Answer") { 585 if (scriptCommand == "Answer") {
586 586
587 timeout_timer->stop(); 587 timeout_timer->stop();
588 588
589 messg->setText(i18n("Answer")); 589 messg->setText(i18n("Answer"));
590 emit debugMessage(i18n("Answer")); 590 emit debugMessage(i18n("Answer"));
591 591
592 setExpect(_ifaceppp->data()->modemRingResp()); 592 setExpect(_ifaceppp->data()->modemRingResp());
593 vmain = 150; 593 vmain = 150;
594 return; 594 return;
595 } 595 }
596 596
597 if (scriptCommand == "ID") { 597 if (scriptCommand == "ID") {
598 QString bm = i18n("ID %1").arg(scriptArgument); 598 QString bm = i18n("ID %1").arg(scriptArgument);
599 messg->setText(bm); 599 messg->setText(bm);
600 emit debugMessage(bm); 600 emit debugMessage(bm);
601 601
602 QString idstring = _ifaceppp->data()->password(); 602 QString idstring = _ifaceppp->data()->password();
603 603
604 if(!idstring.isEmpty() && firstrunID) { 604 if(!idstring.isEmpty() && firstrunID) {
605 // the user entered an Id on the main kppp dialog 605 // the user entered an Id on the main kppp dialog
606 writeline(idstring); 606 writeline(idstring);
607 firstrunID = false; 607 firstrunID = false;
608 scriptindex++; 608 scriptindex++;
609 } 609 }
610 else { 610 else {
611 // the user didn't enter and Id on the main kppp dialog 611 // the user didn't enter and Id on the main kppp dialog
612 // let's query for an ID 612 // let's query for an ID
613 /* if not around yet, then post window... */ 613 /* if not around yet, then post window... */
614 if (prompt->Consumed()) { 614 if (prompt->Consumed()) {
615 if (!(prompt->isVisible())) { 615 if (!(prompt->isVisible())) {
616 prompt->setPrompt(scriptArgument); 616 prompt->setPrompt(scriptArgument);
617 prompt->setEchoModeNormal(); 617 prompt->setEchoModeNormal();
618 prompt->show(); 618 prompt->show();
619 } 619 }
620 } else { 620 } else {
621 /* if prompt withdrawn ... then, */ 621 /* if prompt withdrawn ... then, */
622 if(!(prompt->isVisible())) { 622 if(!(prompt->isVisible())) {
623 writeline(prompt->text()); 623 writeline(prompt->text());
624 prompt->setConsumed(); 624 prompt->setConsumed();
625 scriptindex++; 625 scriptindex++;
626 return; 626 return;
627 } 627 }
628 /* replace timeout value */ 628 /* replace timeout value */
629 } 629 }
630 } 630 }
631 } 631 }
632 632
633 if (scriptCommand == "Password") { 633 if (scriptCommand == "Password") {
634 QString bm = i18n("Password %1").arg(scriptArgument); 634 QString bm = i18n("Password %1").arg(scriptArgument);
635 messg->setText(bm); 635 messg->setText(bm);
636 emit debugMessage(bm); 636 emit debugMessage(bm);
637 637
638 QString pwstring = _ifaceppp->data()->password(); 638 QString pwstring = _ifaceppp->data()->password();
639 639
640 if(!pwstring.isEmpty() && firstrunPW) { 640 if(!pwstring.isEmpty() && firstrunPW) {
641 // the user entered a password on the main kppp dialog 641 // the user entered a password on the main kppp dialog
642 writeline(pwstring); 642 writeline(pwstring);
643 firstrunPW = false; 643 firstrunPW = false;
644 scriptindex++; 644 scriptindex++;
645 } 645 }
646 else { 646 else {
647 // the user didn't enter a password on the main kppp dialog 647 // the user didn't enter a password on the main kppp dialog
648 // let's query for a password 648 // let's query for a password
649 /* if not around yet, then post window... */ 649 /* if not around yet, then post window... */
650 if (prompt->Consumed()) { 650 if (prompt->Consumed()) {
651 if (!(prompt->isVisible())) { 651 if (!(prompt->isVisible())) {
652 prompt->setPrompt(scriptArgument); 652 prompt->setPrompt(scriptArgument);
653 prompt->setEchoModePassword(); 653 prompt->setEchoModePassword();
654 prompt->show(); 654 prompt->show();
655 } 655 }
656 } else { 656 } else {
657 /* if prompt withdrawn ... then, */ 657 /* if prompt withdrawn ... then, */
658 if(!(prompt->isVisible())) { 658 if(!(prompt->isVisible())) {
659 // p_kppp->setPW_Edit(prompt->text()); 659 // p_kppp->setPW_Edit(prompt->text());
660 writeline(prompt->text()); 660 writeline(prompt->text());
661 prompt->setConsumed(); 661 prompt->setConsumed();
662 scriptindex++; 662 scriptindex++;
663 return; 663 return;
664 } 664 }
665 /* replace timeout value */ 665 /* replace timeout value */
666 } 666 }
667 } 667 }
668 } 668 }
669 669
670 if (scriptCommand == "Prompt") { 670 if (scriptCommand == "Prompt") {
671 QString bm = i18n("Prompting %1"); 671 QString bm = i18n("Prompting %1");
672 672
673 // if the scriptindex (aka the prompt text) includes a ## marker 673 // if the scriptindex (aka the prompt text) includes a ## marker
674 // this marker should get substituted with the contents of our stored 674 // this marker should get substituted with the contents of our stored
675 // variable (from the subsequent scan). 675 // variable (from the subsequent scan).
676 676
677 QString ts = scriptArgument; 677 QString ts = scriptArgument;
678 int vstart = ts.find( "##" ); 678 int vstart = ts.find( "##" );
679 if( vstart != -1 ) { 679 if( vstart != -1 ) {
680 ts.remove( vstart, 2 ); 680 ts.remove( vstart, 2 );
681 ts.insert( vstart, scanvar ); 681 ts.insert( vstart, scanvar );
682 } 682 }
683 683
684 bm = bm.arg(ts); 684 bm = bm.arg(ts);
685 messg->setText(bm); 685 messg->setText(bm);
686 emit debugMessage(bm); 686 emit debugMessage(bm);
687 687
688 /* if not around yet, then post window... */ 688 /* if not around yet, then post window... */
689 if (prompt->Consumed()) { 689 if (prompt->Consumed()) {
690 if (!(prompt->isVisible())) { 690 if (!(prompt->isVisible())) {
691 prompt->setPrompt( ts ); 691 prompt->setPrompt( ts );
692 prompt->setEchoModeNormal(); 692 prompt->setEchoModeNormal();
693 prompt->show(); 693 prompt->show();
694 } 694 }
695 } else { 695 } else {
696 /* if prompt withdrawn ... then, */ 696 /* if prompt withdrawn ... then, */
697 if (!(prompt->isVisible())) { 697 if (!(prompt->isVisible())) {
698 writeline(prompt->text()); 698 writeline(prompt->text());
699 prompt->setConsumed(); 699 prompt->setConsumed();
700 scriptindex++; 700 scriptindex++;
701 return; 701 return;
702 } 702 }
703 /* replace timeout value */ 703 /* replace timeout value */
704 } 704 }
705 } 705 }
706 706
707 if (scriptCommand == "PWPrompt") { 707 if (scriptCommand == "PWPrompt") {
708 QString bm = i18n("PW Prompt %1").arg(scriptArgument); 708 QString bm = i18n("PW Prompt %1").arg(scriptArgument);
709 messg->setText(bm); 709 messg->setText(bm);
710 emit debugMessage(bm); 710 emit debugMessage(bm);
711 711
712 /* if not around yet, then post window... */ 712 /* if not around yet, then post window... */
713 if (prompt->Consumed()) { 713 if (prompt->Consumed()) {
714 if (!(prompt->isVisible())) { 714 if (!(prompt->isVisible())) {
715 prompt->setPrompt(scriptArgument); 715 prompt->setPrompt(scriptArgument);
716 prompt->setEchoModePassword(); 716 prompt->setEchoModePassword();
717 prompt->show(); 717 prompt->show();
718 } 718 }
719 } else { 719 } else {
720 /* if prompt withdrawn ... then, */ 720 /* if prompt withdrawn ... then, */
721 if (!(prompt->isVisible())) { 721 if (!(prompt->isVisible())) {
722 writeline(prompt->text()); 722 writeline(prompt->text());
723 prompt->setConsumed(); 723 prompt->setConsumed();
724 scriptindex++; 724 scriptindex++;
725 return; 725 return;
726 } 726 }
727 /* replace timeout value */ 727 /* replace timeout value */
728 } 728 }
729 } 729 }
730 730
731 if (scriptCommand == "LoopStart") { 731 if (scriptCommand == "LoopStart") {
732 732
733 QString bm = i18n("Loop Start %1").arg(scriptArgument); 733 QString bm = i18n("Loop Start %1").arg(scriptArgument);
734 734
735 // The incrementing of the scriptindex MUST be before the 735 // The incrementing of the scriptindex MUST be before the
736 // call to setExpect otherwise the expect will miss a string that is 736 // call to setExpect otherwise the expect will miss a string that is
737 // already in the buffer. 737 // already in the buffer.
738 scriptindex++; 738 scriptindex++;
739 739
740 if ( loopnest > (MAXLOOPNEST-2) ) { 740 if ( loopnest > (MAXLOOPNEST-2) ) {
741 bm += i18n("ERROR: Nested too deep, ignored."); 741 bm += i18n("ERROR: Nested too deep, ignored.");
742 vmain=20; 742 vmain=20;
743 cancelbutton(); 743 cancelbutton();
744 QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); 744 QMessageBox::critical(0, "error", i18n("Loops nested too deeply!"));
745 } else { 745 } else {
746 setExpect(scriptArgument); 746 setExpect(scriptArgument);
747 loopstartindex[loopnest] = scriptindex; 747 loopstartindex[loopnest] = scriptindex;
748 loopstr[loopnest] = scriptArgument; 748 loopstr[loopnest] = scriptArgument;
749 loopend = false; 749 loopend = false;
750 loopnest++; 750 loopnest++;
751 } 751 }
752 messg->setText(bm); 752 messg->setText(bm);
753 emit debugMessage(bm); 753 emit debugMessage(bm);
754 754
755 } 755 }
756 756
757 if (scriptCommand == "LoopEnd") { 757 if (scriptCommand == "LoopEnd") {
758 QString bm = i18n("Loop End %1").arg(scriptArgument); 758 QString bm = i18n("Loop End %1").arg(scriptArgument);
759 if ( loopnest <= 0 ) { 759 if ( loopnest <= 0 ) {
760 bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); 760 bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm);
761 vmain=20; 761 vmain=20;
762 cancelbutton(); 762 cancelbutton();
763 QMessageBox::critical(0, "error", bm); 763 QMessageBox::critical(0, "error", bm);
764 return; 764 return;
765 } else { 765 } else {
766 // NB! The incrementing of the scriptindex MUST be before the 766 // NB! The incrementing of the scriptindex MUST be before the
767 // call to setExpect otherwise the expect will miss a string 767 // call to setExpect otherwise the expect will miss a string
768 // that is already in the buffer. 768 // that is already in the buffer.
769 scriptindex++; 769 scriptindex++;
770 setExpect(scriptArgument); 770 setExpect(scriptArgument);
771 loopnest--; 771 loopnest--;
772 loopend = true; 772 loopend = true;
773 } 773 }
774 messg->setText(bm); 774 messg->setText(bm);
775 emit debugMessage(bm); 775 emit debugMessage(bm);
776 776
777 } 777 }
778 } 778 }
779 } 779 }
780 780
781 // this is a subroutine for the "Answer" script option 781 // this is a subroutine for the "Answer" script option
782 782
783 if(vmain == 150) { 783 if(vmain == 150) {
784 if(!expecting) { 784 if(!expecting) {
785 writeline(_ifaceppp->data()->modemAnswerStr()); 785 writeline(_ifaceppp->data()->modemAnswerStr());
786 setExpect(_ifaceppp->data()->modemAnswerResp()); 786 setExpect(_ifaceppp->data()->modemAnswerResp());
787 787
788 vmain = 2; 788 vmain = 2;
789 scriptindex++; 789 scriptindex++;
790 return; 790 return;
791 } 791 }
792 } 792 }
793 793
794 if(vmain == 30) { 794 if(vmain == 30) {
795// if (termwindow->isVisible()) 795// if (termwindow->isVisible())
796// return; 796// return;
797// if (termwindow->pressedContinue()) 797// if (termwindow->pressedContinue())
798// vmain = 10; 798// vmain = 10;
799// else 799// else
800 cancelbutton(); 800 cancelbutton();
801 } 801 }
802 802
803 if(vmain == 10) { 803 if(vmain == 10) {
804 if(!expecting) { 804 if(!expecting) {
805 805
806 int result; 806 int result;
807 807
808 timeout_timer->stop(); 808 timeout_timer->stop();
809 if_timeout_timer->stop(); // better be sure. 809 if_timeout_timer->stop(); // better be sure.
810 810
811 // stop reading of data 811 // stop reading of data
812 _ifaceppp->modem()->stop(); 812 _ifaceppp->modem()->stop();
813 813
814 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { 814 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) {
815 // if (termwindow) { 815 // if (termwindow) {
816 // delete termwindow; 816 // delete termwindow;
817 // termwindow = 0L; 817 // termwindow = 0L;
818 // this->show(); 818 // this->show();
819 // } else { 819 // } else {
820 // termwindow = new LoginTerm(0L, 0L); 820 // termwindow = new LoginTerm(0L, 0L);
821 // hide(); 821 // hide();
822 // termwindow->show(); 822 // termwindow->show();
823 // vmain = 30; 823 // vmain = 30;
824 // return; 824 // return;
825 // } 825 // }
826 } 826 }
827 827
828 // Close the tty. This prevents the QTimer::singleShot() in 828 // Close the tty. This prevents the QTimer::singleShot() in
829 // Modem::readtty() from re-enabling the socket notifier. 829 // Modem::readtty() from re-enabling the socket notifier.
830 // The port is still held open by the helper process. 830 // The port is still held open by the helper process.
831 _ifaceppp->modem()->closetty(); 831
832 /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(),
833 and closing the thing prevents pppd from using it later. */
834 //_ifaceppp->modem()->closetty();
832 835
833 killTimer( main_timer_ID ); 836 killTimer( main_timer_ID );
834 837
835 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); 838 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000);
836 qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); 839 qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000);
837 840
838 // find out PPP interface and notify the stats module 841 // find out PPP interface and notify the stats module
839// stats->setUnit(pppInterfaceNumber()); 842// stats->setUnit(pppInterfaceNumber());
840 843
841 qApp->flushX(); 844 qApp->flushX();
842 semaphore = true; 845 semaphore = true;
843 result = execppp(); 846 result = execppp();
844 847
845 emit debugMessage(i18n("Starting pppd...")); 848 emit debugMessage(i18n("Starting pppd..."));
846 qDebug("execppp() returned with return-code %i", result ); 849 qDebug("execppp() returned with return-code %i", result );
847 850
848 if(result) { 851 if(result) {
849 if(!_ifaceppp->data()->autoDNS()) 852 if(!_ifaceppp->data()->autoDNS())
850 adddns( _ifaceppp ); 853 adddns( _ifaceppp );
851 854
852 // O.K we are done here, let's change over to the if_waiting loop 855 // O.K we are done here, let's change over to the if_waiting loop
853 // where we wait for the ppp if (interface) to come up. 856 // where we wait for the ppp if (interface) to come up.
854 857
855 emit if_waiting_signal(); 858 emit if_waiting_signal();
856 } else { 859 } else {
857 860
858 // starting pppd wasn't successful. Error messages were 861 // starting pppd wasn't successful. Error messages were
859 // handled by execppp(); 862 // handled by execppp();
860 if_timeout_timer->stop(); 863 if_timeout_timer->stop();
861 this->hide(); 864 this->hide();
862 messg->setText(""); 865 messg->setText("");
863 //p_kppp->quit_b->setFocus(); 866 //p_kppp->quit_b->setFocus();
864 //p_kppp->show(); 867 //p_kppp->show();
865 qApp->processEvents(); 868 qApp->processEvents();
866 _ifaceppp->modem()->hangup(); 869 _ifaceppp->modem()->hangup();
867 emit stopAccounting(); 870 emit stopAccounting();
868 //p_kppp->con_win->stopClock(); 871 //p_kppp->con_win->stopClock();
869 _ifaceppp->modem()->closetty(); 872 _ifaceppp->modem()->closetty();
870 _ifaceppp->modem()->unlockdevice(); 873 _ifaceppp->modem()->unlockdevice();
871 874
872 } 875 }
873 876
874 return; 877 return;
875 } 878 }
876 } 879 }
877 880
878 // this is a "wait until cancel" entry 881 // this is a "wait until cancel" entry
879 882
880 if(vmain == 20) { 883 if(vmain == 20) {
881 } 884 }
882} 885}
883 886
884 887
885void ConnectWidget::set_con_speed_string() { 888void ConnectWidget::set_con_speed_string() {
886 // Here we are trying to determine the speed at which we are connected. 889 // Here we are trying to determine the speed at which we are connected.
887 // Usually the modem responds after connect with something like 890 // Usually the modem responds after connect with something like
888 // CONNECT 115200, so all we need to do is find the number after CONNECT 891 // CONNECT 115200, so all we need to do is find the number after CONNECT
889 // or whatever the modemConnectResp() is. 892 // or whatever the modemConnectResp() is.
890// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); 893// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer);
891} 894}
892 895
893 896
894 897
895void ConnectWidget::readChar(unsigned char c) { 898void ConnectWidget::readChar(unsigned char c) {
896 if(semaphore) 899 if(semaphore)
897 return; 900 return;
898 901
899 readbuffer += c; 902 readbuffer += c;
900 myreadbuffer += c; 903 myreadbuffer += c;
901 904
902 // While in scanning mode store each char to the scan buffer 905 // While in scanning mode store each char to the scan buffer
903 // for use in the prompt command 906 // for use in the prompt command
904 if( scanning ) 907 if( scanning )
905 scanbuffer += c; 908 scanbuffer += c;
906 909
907 // add to debug window 910 // add to debug window
908 emit debugPutChar(c); 911 emit debugPutChar(c);
909 912
910 checkBuffers(); 913 checkBuffers();
911} 914}
912 915
913 916
914void ConnectWidget::checkBuffers() { 917void ConnectWidget::checkBuffers() {
915 // Let's check if we are finished with scanning: 918 // Let's check if we are finished with scanning:
916 // The scanstring have to be in the buffer and the latest character 919 // The scanstring have to be in the buffer and the latest character
917 // was a carriage return or an linefeed (depending on modem setup) 920 // was a carriage return or an linefeed (depending on modem setup)
918 if( scanning && scanbuffer.contains(scanstr) && 921 if( scanning && scanbuffer.contains(scanstr) &&
919 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { 922 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) {
920 scanning = false; 923 scanning = false;
921 924
922 int vstart = scanbuffer.find( scanstr ) + scanstr.length(); 925 int vstart = scanbuffer.find( scanstr ) + scanstr.length();
923 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); 926 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
924 scanvar = scanvar.stripWhiteSpace(); 927 scanvar = scanvar.stripWhiteSpace();
925 928
926 // Show the Variabel content in the debug window 929 // Show the Variabel content in the debug window
927 QString sv = i18n("Scan Var: %1").arg(scanvar); 930 QString sv = i18n("Scan Var: %1").arg(scanvar);
928 emit debugMessage(sv); 931 emit debugMessage(sv);
929 } 932 }
930 933
931 if(expecting) { 934 if(expecting) {
932 if(readbuffer.contains(expectstr)) { 935 if(readbuffer.contains(expectstr)) {
933 expecting = false; 936 expecting = false;
934 // keep everything after the expected string 937 // keep everything after the expected string
935 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); 938 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
936 939
937 QString ts = i18n("Found: %1").arg(expectstr); 940 QString ts = i18n("Found: %1").arg(expectstr);
938 emit debugMessage(ts); 941 emit debugMessage(ts);
939 942
940 if (loopend) { 943 if (loopend) {
941 loopend=false; 944 loopend=false;
942 } 945 }
943 } 946 }
944 947
945 if (loopend && readbuffer.contains(loopstr[loopnest])) { 948 if (loopend && readbuffer.contains(loopstr[loopnest])) {
946 expecting = false; 949 expecting = false;
947 readbuffer = ""; 950 readbuffer = "";
948 QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); 951 QString ts = i18n("Looping: %1").arg(loopstr[loopnest]);
949 emit debugMessage(ts); 952 emit debugMessage(ts);
950 scriptindex = loopstartindex[loopnest]; 953 scriptindex = loopstartindex[loopnest];
951 loopend = false; 954 loopend = false;
952 loopnest++; 955 loopnest++;
953 } 956 }
954 // notify event loop if expected string was found 957 // notify event loop if expected string was found
955 if(!expecting) 958 if(!expecting)
956 timerEvent((QTimerEvent *) 0); 959 timerEvent((QTimerEvent *) 0);
957 } 960 }
958} 961}
959 962
960 963
961 964
962void ConnectWidget::pause() { 965void ConnectWidget::pause() {
963 pausing = false; 966 pausing = false;
964 pausetimer->stop(); 967 pausetimer->stop();
965} 968}
966 969
967 970
968void ConnectWidget::cancelbutton() { 971void ConnectWidget::cancelbutton() {
969 _ifaceppp->modem()->stop(); 972 _ifaceppp->modem()->stop();
970 killTimer(main_timer_ID); 973 killTimer(main_timer_ID);
971 timeout_timer->stop(); 974 timeout_timer->stop();
972 if_timer->stop(); 975 if_timer->stop();
973 if_timeout_timer->stop(); 976 if_timeout_timer->stop();
974 977
975// if (termwindow) { 978// if (termwindow) {
976// delete termwindow; 979// delete termwindow;
977// termwindow = 0L; 980// termwindow = 0L;
978// this->show(); 981// this->show();
979// } 982// }
980 983
981 messg->setText(i18n("One moment please...")); 984 messg->setText(i18n("One moment please..."));
982 985
983 // just to be sure 986 // just to be sure
984 _ifaceppp->modem()->removeSecret(AUTH_PAP); 987 _ifaceppp->modem()->removeSecret(AUTH_PAP);
985 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 988 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
986 removedns(_ifaceppp); 989 removedns(_ifaceppp);
987 990
988 qApp->processEvents(); 991 qApp->processEvents();
989 992
990 _ifaceppp->modem()->killPPPDaemon(); 993 _ifaceppp->modem()->killPPPDaemon();
991 _ifaceppp->modem()->hangup(); 994 _ifaceppp->modem()->hangup();
992 995
993 996
994// p_kppp->quit_b->setFocus(); 997// p_kppp->quit_b->setFocus();
995// p_kppp->show(); 998// p_kppp->show();
996 // emit stopAccounting();// just to be sure 999 // emit stopAccounting();// just to be sure
997// p_kppp->con_win->stopClock(); 1000// p_kppp->con_win->stopClock();
998 _ifaceppp->modem()->closetty(); 1001 _ifaceppp->modem()->closetty();
999 _ifaceppp->modem()->unlockdevice(); 1002 _ifaceppp->modem()->unlockdevice();
1000 1003
1001 //abort prompt window... 1004 //abort prompt window...
1002 if (prompt->isVisible()) { 1005 if (prompt->isVisible()) {
1003 prompt->hide(); 1006 prompt->hide();
1004 } 1007 }
1005 prompt->setConsumed(); 1008 prompt->setConsumed();
1006 1009
1007 messg->setText(tr("offline")); 1010 messg->setText(tr("offline"));
1008} 1011}
1009 1012
1010 1013
1011void ConnectWidget::script_timed_out() { 1014void ConnectWidget::script_timed_out() {
1012 if(vmain == 20) { // we are in the 'wait for the user to cancel' state 1015 if(vmain == 20) { // we are in the 'wait for the user to cancel' state
1013 timeout_timer->stop(); 1016 timeout_timer->stop();
1014 emit stopAccounting(); 1017 emit stopAccounting();
1015// p_kppp->con_win->stopClock(); 1018// p_kppp->con_win->stopClock();
1016 return; 1019 return;
1017 } 1020 }
1018 1021
1019 if (prompt->isVisible()) 1022 if (prompt->isVisible())
1020 prompt->hide(); 1023 prompt->hide();
1021 1024
1022 prompt->setConsumed(); 1025 prompt->setConsumed();
1023 messg->setText(i18n("Script timed out!")); 1026 messg->setText(i18n("Script timed out!"));
1024 _ifaceppp->modem()->hangup(); 1027 _ifaceppp->modem()->hangup();
1025 emit stopAccounting(); 1028 emit stopAccounting();
1026// p_kppp->con_win->stopClock(); 1029// p_kppp->con_win->stopClock();
1027 1030
1028 vmain = 0; // let's try again. 1031 vmain = 0; // let's try again.
1029 substate = -1; 1032 substate = -1;
1030} 1033}
1031 1034
1032 1035
1033void ConnectWidget::setScan(const QString &n) { 1036void ConnectWidget::setScan(const QString &n) {
1034 scanning = true; 1037 scanning = true;
1035 scanstr = n; 1038 scanstr = n;
1036 scanbuffer = ""; 1039 scanbuffer = "";
1037 1040
1038 QString ts = i18n("Scanning: %1").arg(n); 1041 QString ts = i18n("Scanning: %1").arg(n);
1039 emit debugMessage(ts); 1042 emit debugMessage(ts);
1040} 1043}
1041 1044
1042 1045
1043void ConnectWidget::setExpect(const QString &n) { 1046void ConnectWidget::setExpect(const QString &n) {
1044 expecting = true; 1047 expecting = true;
1045 expectstr = n; 1048 expectstr = n;
1046 1049
1047 QString ts = i18n("Expecting: %1").arg(n); 1050 QString ts = i18n("Expecting: %1").arg(n);
1048 ts.replace(QRegExp("\n"), "<LF>"); 1051 ts.replace(QRegExp("\n"), "<LF>");
1049 emit debugMessage(ts); 1052 emit debugMessage(ts);
1050 1053
1051 // check if the expected string is in the read buffer already. 1054 // check if the expected string is in the read buffer already.
1052 checkBuffers(); 1055 checkBuffers();
1053} 1056}
1054 1057
1055 1058
1056void ConnectWidget::if_waiting_timed_out() { 1059void ConnectWidget::if_waiting_timed_out() {
1057 if_timer->stop(); 1060 if_timer->stop();
1058 if_timeout_timer->stop(); 1061 if_timeout_timer->stop();
1059 qDebug("if_waiting_timed_out()"); 1062 qDebug("if_waiting_timed_out()");
1060 1063
1061 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); 1064 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT);
1062 1065
1063 // let's kill the stuck pppd 1066 // let's kill the stuck pppd
1064 _ifaceppp->modem()->killPPPDaemon(); 1067 _ifaceppp->modem()->killPPPDaemon();
1065 1068
1066 emit stopAccounting(); 1069 emit stopAccounting();
1067// p_kppp->con_win->stopClock(); 1070// p_kppp->con_win->stopClock();
1068 1071
1069 1072
1070 // killing ppp will generate a SIGCHLD which will be caught in pppdie() 1073 // killing ppp will generate a SIGCHLD which will be caught in pppdie()
1071 // in main.cpp what happens next will depend on the boolean 1074 // in main.cpp what happens next will depend on the boolean
1072 // reconnect_on_disconnect which is set in ConnectWidget::init(); 1075 // reconnect_on_disconnect which is set in ConnectWidget::init();
1073} 1076}
1074 1077
1075void ConnectWidget::pppdDied() 1078void ConnectWidget::pppdDied()
1076{ 1079{
1077 if_timer->stop(); 1080 if_timer->stop();
1078 if_timeout_timer->stop(); 1081 if_timeout_timer->stop();
1079} 1082}
1080 1083
1081void ConnectWidget::if_waiting_slot() { 1084void ConnectWidget::if_waiting_slot() {
1082 messg->setText(i18n("Logging on to network...")); 1085 messg->setText(i18n("Logging on to network..."));
1083 1086
1084// if(!stats->ifIsUp()) { 1087// if(!stats->ifIsUp()) {
1085 1088
1086// if(_ifaceppp->data()->pppdError() != 0) { 1089// if(_ifaceppp->data()->pppdError() != 0) {
1087// // we are here if pppd died immediately after starting it. 1090// // we are here if pppd died immediately after starting it.
1088// pppdDied(); 1091// pppdDied();
1089// // error message handled in main.cpp: sigPPPDDied() 1092// // error message handled in main.cpp: sigPPPDDied()
1090// return; 1093// return;
1091// } 1094// }
1092 1095
1093// if_timer->start(100, TRUE); // single shot 1096// if_timer->start(100, TRUE); // single shot
1094// return; 1097// return;
1095// } 1098// }
1096 1099
1097 // O.K the ppp interface is up and running 1100 // O.K the ppp interface is up and running
1098 // give it a few time to come up completly (0.2 seconds) 1101 // give it a few time to come up completly (0.2 seconds)
1099 if_timeout_timer->stop(); 1102 if_timeout_timer->stop();
1100 if_timer->stop(); 1103 if_timer->stop();
1101 usleep(200000); 1104 usleep(200000);
1102 1105
1103 if(_ifaceppp->data()->autoDNS()) 1106 if(_ifaceppp->data()->autoDNS())
1104 addpeerdns( _ifaceppp ); 1107 addpeerdns( _ifaceppp );
1105 1108
1106 // Close the debugging window. If we are connected, we 1109 // Close the debugging window. If we are connected, we
1107 // are not really interested in debug output 1110 // are not really interested in debug output
1108 emit closeDebugWindow(); 1111 emit closeDebugWindow();
1109// p_kppp->statdlg->take_stats(); // start taking ppp statistics 1112// p_kppp->statdlg->take_stats(); // start taking ppp statistics
1110 auto_hostname(_ifaceppp); 1113 auto_hostname(_ifaceppp);
1111 1114
1112 if(!_ifaceppp->data()->command_on_connect().isEmpty()) { 1115 if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
1113 messg->setText(i18n("Running startup command...")); 1116 messg->setText(i18n("Running startup command..."));
1114 1117
1115 // make sure that we don't get any async errors 1118 // make sure that we don't get any async errors
1116 qApp->flushX(); 1119 qApp->flushX();
1117 execute_command(_ifaceppp->data()->command_on_connect()); 1120 execute_command(_ifaceppp->data()->command_on_connect());
1118 messg->setText(i18n("Done")); 1121 messg->setText(i18n("Done"));
1119 } 1122 }
1120 1123
1121 // remove the authentication file 1124 // remove the authentication file
1122 _ifaceppp->modem()->removeSecret(AUTH_PAP); 1125 _ifaceppp->modem()->removeSecret(AUTH_PAP);
1123 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 1126 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
1124 1127
1125 emit debugMessage(i18n("Done")); 1128 emit debugMessage(i18n("Done"));
1126 set_con_speed_string(); 1129 set_con_speed_string();
1127 1130
1128// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); 1131// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
1129 this->hide(); 1132 this->hide();
1130 messg->setText(""); 1133 messg->setText("");
1131 1134
1132 // prepare the con_win so as to have the right size for 1135 // prepare the con_win so as to have the right size for
1133 // accounting / non-accounting mode 1136 // accounting / non-accounting mode
1134// if(p_kppp->acct != 0) 1137// if(p_kppp->acct != 0)
1135// p_kppp->con_win->accounting(p_kppp->acct->running()); 1138// p_kppp->con_win->accounting(p_kppp->acct->running());
1136// else 1139// else
1137// p_kppp->con_win->accounting(false); 1140// p_kppp->con_win->accounting(false);
1138 1141
1139// if (_ifaceppp->data()->get_dock_into_panel()) { 1142// if (_ifaceppp->data()->get_dock_into_panel()) {
1140// // DockWidget::dock_widget->show(); 1143// // DockWidget::dock_widget->show();
1141// // DockWidget::dock_widget->take_stats(); 1144// // DockWidget::dock_widget->take_stats();
1142// // this->hide(); 1145// // this->hide();
1143// } 1146// }
1144// else { 1147// else {
1145// // p_kppp->con_win->show(); 1148// // p_kppp->con_win->show();
1146 1149
1147// if(_ifaceppp->data()->get_iconify_on_connect()) { 1150// if(_ifaceppp->data()->get_iconify_on_connect()) {
1148// // p_kppp->con_win->showMinimized(); 1151// // p_kppp->con_win->showMinimized();
1149// } 1152// }
1150// } 1153// }
1151 1154
1152 _ifaceppp->modem()->closetty(); 1155 _ifaceppp->modem()->closetty();
1153} 1156}
1154 1157
1155 1158
1156bool ConnectWidget::execppp() { 1159bool ConnectWidget::execppp() {
1157 QString command; 1160 QString command;
1158 1161
1159 command = "pppd"; 1162 command = "pppd";
1160 1163
1161 // as of version 2.3.6 pppd falls back to the real user rights when 1164 // as of version 2.3.6 pppd falls back to the real user rights when
1162 // opening a device given in a command line. To avoid permission conflicts 1165 // opening a device given in a command line. To avoid permission conflicts
1163 // we'll simply leave this argument away. pppd will then use the default tty 1166 // we'll simply leave this argument away. pppd will then use the default tty
1164 // which is the serial port we connected stdin/stdout to in opener.cpp. 1167 // which is the serial port we connected stdin/stdout to in opener.cpp.
1165 // command += " "; 1168 // command += " ";
1166 // command += _ifaceppp->data()->modemDevice(); 1169 // command += _ifaceppp->data()->modemDevice();
1167 1170
1168 command += " " + _ifaceppp->data()->speed(); 1171 command += " " + _ifaceppp->data()->speed();
1169 1172
1170 command += " -detach"; 1173 command += " -detach";
1171 1174
1172 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || 1175 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
1173 _ifaceppp->data()->gateway() != "0.0.0.0") { 1176 _ifaceppp->data()->gateway() != "0.0.0.0") {
1174 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { 1177 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
1175 command += " "; 1178 command += " ";
1176 command += _ifaceppp->data()->ipaddr(); 1179 command += _ifaceppp->data()->ipaddr();
1177 command += ":"; 1180 command += ":";
1178 } 1181 }
1179 else { 1182 else {
1180 command += " "; 1183 command += " ";
1181 command += ":"; 1184 command += ":";
1182 } 1185 }
1183 1186
1184 if(_ifaceppp->data()->gateway() != "0.0.0.0") 1187 if(_ifaceppp->data()->gateway() != "0.0.0.0")
1185 command += _ifaceppp->data()->gateway(); 1188 command += _ifaceppp->data()->gateway();
1186 } 1189 }
1187 1190
1188 if(_ifaceppp->data()->subnetmask() != "0.0.0.0") 1191 if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
1189 command += " netmask " + _ifaceppp->data()->subnetmask(); 1192 command += " netmask " + _ifaceppp->data()->subnetmask();
1190 1193
1191 if(_ifaceppp->data()->flowcontrol() != "None") { 1194 if(_ifaceppp->data()->flowcontrol() != "None") {
1192 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") 1195 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS")
1193 command += " crtscts"; 1196 command += " crtscts";
1194 else 1197 else
1195 command += " xonxoff"; 1198 command += " xonxoff";
1196 } 1199 }
1197 1200
1198 if(_ifaceppp->data()->defaultroute()) 1201 if(_ifaceppp->data()->defaultroute())
1199 command += " defaultroute"; 1202 command += " defaultroute";
1200 1203
1201 if(_ifaceppp->data()->autoDNS()) 1204 if(_ifaceppp->data()->autoDNS())
1202 command += " usepeerdns"; 1205 command += " usepeerdns";
1203 1206
1204 QStringList &arglist = _ifaceppp->data()->pppdArgument(); 1207 QStringList &arglist = _ifaceppp->data()->pppdArgument();
1205 for ( QStringList::Iterator it = arglist.begin(); 1208 for ( QStringList::Iterator it = arglist.begin();
1206 it != arglist.end(); 1209 it != arglist.end();
1207 ++it ) 1210 ++it )
1208 { 1211 {
1209 command += " " + *it; 1212 command += " " + *it;
1210 } 1213 }
1211 1214
1212 // PAP settings 1215 // PAP settings
1213 if(_ifaceppp->data()->authMethod() == AUTH_PAP) { 1216 if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
1214 command += " -chap user "; 1217 command += " -chap user ";
1215 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; 1218 command = command + "\"" + _ifaceppp->data()->storedUsername() + "\"";