summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp34
-rw-r--r--noncore/settings/networksettings/ppp/general.h4
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp16
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp12
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h19
6 files changed, 45 insertions, 44 deletions
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 128877a..8981e01 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -450,1019 +450,1019 @@ void ConnectWidget::timerEvent(QTimerEvent *) {
450 } 450 }
451 451
452 // wait for newline after CONNECT response (so we get the speed) 452 // wait for newline after CONNECT response (so we get the speed)
453 if(vmain == 101) { 453 if(vmain == 101) {
454 if(!expecting) { 454 if(!expecting) {
455 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands 455 _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands
456 456
457 emit startAccounting(); 457 emit startAccounting();
458// p_kppp->con_win->startClock(); 458// p_kppp->con_win->startClock();
459 459
460 vmain = 2; 460 vmain = 2;
461 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; 461 scriptTimeout=_ifaceppp->data()->modemTimeout()*1000;
462 return; 462 return;
463 } 463 }
464 } 464 }
465 465
466 // execute the script 466 // execute the script
467 if(vmain == 2) { 467 if(vmain == 2) {
468 if(!expecting && !pausing && !scanning) { 468 if(!expecting && !pausing && !scanning) {
469 469
470 timeout_timer->stop(); 470 timeout_timer->stop();
471 timeout_timer->start(scriptTimeout); 471 timeout_timer->start(scriptTimeout);
472 472
473 if((unsigned) scriptindex < comlist->count()) { 473 if((unsigned) scriptindex < comlist->count()) {
474 scriptCommand = *(comlist->at(scriptindex)); 474 scriptCommand = *(comlist->at(scriptindex));
475 scriptArgument = *(arglist->at(scriptindex)); 475 scriptArgument = *(arglist->at(scriptindex));
476 } else { 476 } else {
477 odebug << "End of script" << oendl; 477 odebug << "End of script" << oendl;
478 vmain = 10; 478 vmain = 10;
479 return; 479 return;
480 } 480 }
481 481
482 if (scriptCommand == "Scan") { 482 if (scriptCommand == "Scan") {
483 QString bm = QObject::tr("Scanning %1").arg(scriptArgument); 483 QString bm = QObject::tr("Scanning %1").arg(scriptArgument);
484 messg->setText(bm); 484 messg->setText(bm);
485 emit debugMessage(bm); 485 emit debugMessage(bm);
486 486
487 setScan(scriptArgument); 487 setScan(scriptArgument);
488 scriptindex++; 488 scriptindex++;
489 return; 489 return;
490 } 490 }
491 491
492 if (scriptCommand == "Save") { 492 if (scriptCommand == "Save") {
493 QString bm = QObject::tr("Saving %1").arg(scriptArgument); 493 QString bm = QObject::tr("Saving %1").arg(scriptArgument);
494 messg->setText(bm); 494 messg->setText(bm);
495 emit debugMessage(bm); 495 emit debugMessage(bm);
496 496
497 if (scriptArgument.lower() == "password") { 497 if (scriptArgument.lower() == "password") {
498 _ifaceppp->data()->setPassword(scanvar); 498 _ifaceppp->data()->setPassword(scanvar);
499 // p_kppp->setPW_Edit(scanvar); 499 // p_kppp->setPW_Edit(scanvar);
500 if(_ifaceppp->data()->storePassword()) 500 if(_ifaceppp->data()->storePassword())
501 _ifaceppp->data()->setStoredPassword(scanvar); 501 _ifaceppp->data()->setStoredPassword(scanvar);
502 firstrunPW = true; 502 firstrunPW = true;
503 } 503 }
504 504
505 scriptindex++; 505 scriptindex++;
506 return; 506 return;
507 } 507 }
508 508
509 509
510 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { 510 if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") {
511 QString bm = QObject::tr("Sending %1"); 511 QString bm = QObject::tr("Sending %1");
512 512
513 // replace %USERNAME% and %PASSWORD% 513 // replace %USERNAME% and %PASSWORD%
514 QString arg = scriptArgument; 514 QString arg = scriptArgument;
515 QRegExp re1("%USERNAME%"); 515 QRegExp re1("%USERNAME%");
516 QRegExp re2("%PASSWORD%"); 516 QRegExp re2("%PASSWORD%");
517 arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); 517 arg = arg.replace(re1, _ifaceppp->data()->storedUsername());
518 arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); 518 arg = arg.replace(re2, _ifaceppp->data()->storedPassword());
519 519
520 if (scriptCommand == "Send") 520 if (scriptCommand == "Send")
521 bm = bm.arg(scriptArgument); 521 bm = bm.arg(scriptArgument);
522 else { 522 else {
523 for(uint i = 0; i < scriptArgument.length(); i++) 523 for(uint i = 0; i < scriptArgument.length(); i++)
524 bm = bm.arg("*"); 524 bm = bm.arg("*");
525 } 525 }
526 526
527 messg->setText(bm); 527 messg->setText(bm);
528 emit debugMessage(bm); 528 emit debugMessage(bm);
529 529
530 writeline(scriptArgument); 530 writeline(scriptArgument);
531 scriptindex++; 531 scriptindex++;
532 return; 532 return;
533 } 533 }
534 534
535 if (scriptCommand == "Expect") { 535 if (scriptCommand == "Expect") {
536 QString bm = QObject::tr("Expecting %1").arg(scriptArgument); 536 QString bm = QObject::tr("Expecting %1").arg(scriptArgument);
537 messg->setText(bm); 537 messg->setText(bm);
538 emit debugMessage(bm); 538 emit debugMessage(bm);
539 539
540 // The incrementing of the scriptindex MUST be before the 540 // The incrementing of the scriptindex MUST be before the
541 // call to setExpect otherwise the expect will miss a string that is 541 // call to setExpect otherwise the expect will miss a string that is
542 // already in the buffer. 542 // already in the buffer.
543 scriptindex++; 543 scriptindex++;
544 setExpect(scriptArgument); 544 setExpect(scriptArgument);
545 return; 545 return;
546 } 546 }
547 547
548 548
549 if (scriptCommand == "Pause") { 549 if (scriptCommand == "Pause") {
550 QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument); 550 QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument);
551 messg->setText(bm); 551 messg->setText(bm);
552 emit debugMessage(bm); 552 emit debugMessage(bm);
553 553
554 pausing = true; 554 pausing = true;
555 555
556 pausetimer->start(scriptArgument.toInt()*1000, true); 556 pausetimer->start(scriptArgument.toInt()*1000, true);
557 timeout_timer->stop(); 557 timeout_timer->stop();
558 558
559 scriptindex++; 559 scriptindex++;
560 return; 560 return;
561 } 561 }
562 562
563 if (scriptCommand == "Timeout") { 563 if (scriptCommand == "Timeout") {
564 564
565 timeout_timer->stop(); 565 timeout_timer->stop();
566 566
567 QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument); 567 QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument);
568 messg->setText(bm); 568 messg->setText(bm);
569 emit debugMessage(bm); 569 emit debugMessage(bm);
570 570
571 scriptTimeout=scriptArgument.toInt()*1000; 571 scriptTimeout=scriptArgument.toInt()*1000;
572 timeout_timer->start(scriptTimeout); 572 timeout_timer->start(scriptTimeout);
573 573
574 scriptindex++; 574 scriptindex++;
575 return; 575 return;
576 } 576 }
577 577
578 if (scriptCommand == "Hangup") { 578 if (scriptCommand == "Hangup") {
579 messg->setText(QObject::tr("Hangup")); 579 messg->setText(QObject::tr("Hangup"));
580 emit debugMessage(QObject::tr("Hangup")); 580 emit debugMessage(QObject::tr("Hangup"));
581 581
582 writeline(_ifaceppp->data()->modemHangupStr()); 582 writeline(_ifaceppp->data()->modemHangupStr());
583 setExpect(_ifaceppp->data()->modemHangupResp()); 583 setExpect(_ifaceppp->data()->modemHangupResp());
584 584
585 scriptindex++; 585 scriptindex++;
586 return; 586 return;
587 } 587 }
588 588
589 if (scriptCommand == "Answer") { 589 if (scriptCommand == "Answer") {
590 590
591 timeout_timer->stop(); 591 timeout_timer->stop();
592 592
593 messg->setText(QObject::tr("Answer")); 593 messg->setText(QObject::tr("Answer"));
594 emit debugMessage(QObject::tr("Answer")); 594 emit debugMessage(QObject::tr("Answer"));
595 595
596 setExpect(_ifaceppp->data()->modemRingResp()); 596 setExpect(_ifaceppp->data()->modemRingResp());
597 vmain = 150; 597 vmain = 150;
598 return; 598 return;
599 } 599 }
600 600
601 if (scriptCommand == "ID") { 601 if (scriptCommand == "ID") {
602 QString bm = QObject::tr("ID %1").arg(scriptArgument); 602 QString bm = QObject::tr("ID %1").arg(scriptArgument);
603 messg->setText(bm); 603 messg->setText(bm);
604 emit debugMessage(bm); 604 emit debugMessage(bm);
605 605
606 QString idstring = _ifaceppp->data()->password(); 606 QString idstring = _ifaceppp->data()->password();
607 607
608 if(!idstring.isEmpty() && firstrunID) { 608 if(!idstring.isEmpty() && firstrunID) {
609 // the user entered an Id on the main kppp dialog 609 // the user entered an Id on the main kppp dialog
610 writeline(idstring); 610 writeline(idstring);
611 firstrunID = false; 611 firstrunID = false;
612 scriptindex++; 612 scriptindex++;
613 } 613 }
614 else { 614 else {
615 // the user didn't enter and Id on the main kppp dialog 615 // the user didn't enter and Id on the main kppp dialog
616 // let's query for an ID 616 // let's query for an ID
617 /* if not around yet, then post window... */ 617 /* if not around yet, then post window... */
618 if (prompt->Consumed()) { 618 if (prompt->Consumed()) {
619 if (!(prompt->isVisible())) { 619 if (!(prompt->isVisible())) {
620 prompt->setPrompt(scriptArgument); 620 prompt->setPrompt(scriptArgument);
621 prompt->setEchoModeNormal(); 621 prompt->setEchoModeNormal();
622 prompt->show(); 622 prompt->show();
623 } 623 }
624 } else { 624 } else {
625 /* if prompt withdrawn ... then, */ 625 /* if prompt withdrawn ... then, */
626 if(!(prompt->isVisible())) { 626 if(!(prompt->isVisible())) {
627 writeline(prompt->text()); 627 writeline(prompt->text());
628 prompt->setConsumed(); 628 prompt->setConsumed();
629 scriptindex++; 629 scriptindex++;
630 return; 630 return;
631 } 631 }
632 /* replace timeout value */ 632 /* replace timeout value */
633 } 633 }
634 } 634 }
635 } 635 }
636 636
637 if (scriptCommand == "Password") { 637 if (scriptCommand == "Password") {
638 QString bm = QObject::tr("Password %1").arg(scriptArgument); 638 QString bm = QObject::tr("Password %1").arg(scriptArgument);
639 messg->setText(bm); 639 messg->setText(bm);
640 emit debugMessage(bm); 640 emit debugMessage(bm);
641 641
642 QString pwstring = _ifaceppp->data()->password(); 642 QString pwstring = _ifaceppp->data()->password();
643 643
644 if(!pwstring.isEmpty() && firstrunPW) { 644 if(!pwstring.isEmpty() && firstrunPW) {
645 // the user entered a password on the main kppp dialog 645 // the user entered a password on the main kppp dialog
646 writeline(pwstring); 646 writeline(pwstring);
647 firstrunPW = false; 647 firstrunPW = false;
648 scriptindex++; 648 scriptindex++;
649 } 649 }
650 else { 650 else {
651 // the user didn't enter a password on the main kppp dialog 651 // the user didn't enter a password on the main kppp dialog
652 // let's query for a password 652 // let's query for a password
653 /* if not around yet, then post window... */ 653 /* if not around yet, then post window... */
654 if (prompt->Consumed()) { 654 if (prompt->Consumed()) {
655 if (!(prompt->isVisible())) { 655 if (!(prompt->isVisible())) {
656 prompt->setPrompt(scriptArgument); 656 prompt->setPrompt(scriptArgument);
657 prompt->setEchoModePassword(); 657 prompt->setEchoModePassword();
658 prompt->show(); 658 prompt->show();
659 } 659 }
660 } else { 660 } else {
661 /* if prompt withdrawn ... then, */ 661 /* if prompt withdrawn ... then, */
662 if(!(prompt->isVisible())) { 662 if(!(prompt->isVisible())) {
663 // p_kppp->setPW_Edit(prompt->text()); 663 // p_kppp->setPW_Edit(prompt->text());
664 writeline(prompt->text()); 664 writeline(prompt->text());
665 prompt->setConsumed(); 665 prompt->setConsumed();
666 scriptindex++; 666 scriptindex++;
667 return; 667 return;
668 } 668 }
669 /* replace timeout value */ 669 /* replace timeout value */
670 } 670 }
671 } 671 }
672 } 672 }
673 673
674 if (scriptCommand == "Prompt") { 674 if (scriptCommand == "Prompt") {
675 QString bm = QObject::tr("Prompting %1"); 675 QString bm = QObject::tr("Prompting %1");
676 676
677 // if the scriptindex (aka the prompt text) includes a ## marker 677 // if the scriptindex (aka the prompt text) includes a ## marker
678 // this marker should get substituted with the contents of our stored 678 // this marker should get substituted with the contents of our stored
679 // variable (from the subsequent scan). 679 // variable (from the subsequent scan).
680 680
681 QString ts = scriptArgument; 681 QString ts = scriptArgument;
682 int vstart = ts.find( "##" ); 682 int vstart = ts.find( "##" );
683 if( vstart != -1 ) { 683 if( vstart != -1 ) {
684 ts.remove( vstart, 2 ); 684 ts.remove( vstart, 2 );
685 ts.insert( vstart, scanvar ); 685 ts.insert( vstart, scanvar );
686 } 686 }
687 687
688 bm = bm.arg(ts); 688 bm = bm.arg(ts);
689 messg->setText(bm); 689 messg->setText(bm);
690 emit debugMessage(bm); 690 emit debugMessage(bm);
691 691
692 /* if not around yet, then post window... */ 692 /* if not around yet, then post window... */
693 if (prompt->Consumed()) { 693 if (prompt->Consumed()) {
694 if (!(prompt->isVisible())) { 694 if (!(prompt->isVisible())) {
695 prompt->setPrompt( ts ); 695 prompt->setPrompt( ts );
696 prompt->setEchoModeNormal(); 696 prompt->setEchoModeNormal();
697 prompt->show(); 697 prompt->show();
698 } 698 }
699 } else { 699 } else {
700 /* if prompt withdrawn ... then, */ 700 /* if prompt withdrawn ... then, */
701 if (!(prompt->isVisible())) { 701 if (!(prompt->isVisible())) {
702 writeline(prompt->text()); 702 writeline(prompt->text());
703 prompt->setConsumed(); 703 prompt->setConsumed();
704 scriptindex++; 704 scriptindex++;
705 return; 705 return;
706 } 706 }
707 /* replace timeout value */ 707 /* replace timeout value */
708 } 708 }
709 } 709 }
710 710
711 if (scriptCommand == "PWPrompt") { 711 if (scriptCommand == "PWPrompt") {
712 QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument); 712 QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument);
713 messg->setText(bm); 713 messg->setText(bm);
714 emit debugMessage(bm); 714 emit debugMessage(bm);
715 715
716 /* if not around yet, then post window... */ 716 /* if not around yet, then post window... */
717 if (prompt->Consumed()) { 717 if (prompt->Consumed()) {
718 if (!(prompt->isVisible())) { 718 if (!(prompt->isVisible())) {
719 prompt->setPrompt(scriptArgument); 719 prompt->setPrompt(scriptArgument);
720 prompt->setEchoModePassword(); 720 prompt->setEchoModePassword();
721 prompt->show(); 721 prompt->show();
722 } 722 }
723 } else { 723 } else {
724 /* if prompt withdrawn ... then, */ 724 /* if prompt withdrawn ... then, */
725 if (!(prompt->isVisible())) { 725 if (!(prompt->isVisible())) {
726 writeline(prompt->text()); 726 writeline(prompt->text());
727 prompt->setConsumed(); 727 prompt->setConsumed();
728 scriptindex++; 728 scriptindex++;
729 return; 729 return;
730 } 730 }
731 /* replace timeout value */ 731 /* replace timeout value */
732 } 732 }
733 } 733 }
734 734
735 if (scriptCommand == "LoopStart") { 735 if (scriptCommand == "LoopStart") {
736 736
737 QString bm = QObject::tr("Loop Start %1").arg(scriptArgument); 737 QString bm = QObject::tr("Loop Start %1").arg(scriptArgument);
738 738
739 // The incrementing of the scriptindex MUST be before the 739 // The incrementing of the scriptindex MUST be before the
740 // call to setExpect otherwise the expect will miss a string that is 740 // call to setExpect otherwise the expect will miss a string that is
741 // already in the buffer. 741 // already in the buffer.
742 scriptindex++; 742 scriptindex++;
743 743
744 if ( loopnest > (MAXLOOPNEST-2) ) { 744 if ( loopnest > (MAXLOOPNEST-2) ) {
745 bm += QObject::tr("ERROR: Nested too deep, ignored."); 745 bm += QObject::tr("ERROR: Nested too deep, ignored.");
746 vmain=20; 746 vmain=20;
747 cancelbutton(); 747 cancelbutton();
748 QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!")); 748 QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!"));
749 } else { 749 } else {
750 setExpect(scriptArgument); 750 setExpect(scriptArgument);
751 loopstartindex[loopnest] = scriptindex; 751 loopstartindex[loopnest] = scriptindex;
752 loopstr[loopnest] = scriptArgument; 752 loopstr[loopnest] = scriptArgument;
753 loopend = false; 753 loopend = false;
754 loopnest++; 754 loopnest++;
755 } 755 }
756 messg->setText(bm); 756 messg->setText(bm);
757 emit debugMessage(bm); 757 emit debugMessage(bm);
758 758
759 } 759 }
760 760
761 if (scriptCommand == "LoopEnd") { 761 if (scriptCommand == "LoopEnd") {
762 QString bm = QObject::tr("Loop End %1").arg(scriptArgument); 762 QString bm = QObject::tr("Loop End %1").arg(scriptArgument);
763 if ( loopnest <= 0 ) { 763 if ( loopnest <= 0 ) {
764 bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm); 764 bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm);
765 vmain=20; 765 vmain=20;
766 cancelbutton(); 766 cancelbutton();
767 QMessageBox::critical(0, "error", bm); 767 QMessageBox::critical(0, "error", bm);
768 return; 768 return;
769 } else { 769 } else {
770 // NB! The incrementing of the scriptindex MUST be before the 770 // NB! The incrementing of the scriptindex MUST be before the
771 // call to setExpect otherwise the expect will miss a string 771 // call to setExpect otherwise the expect will miss a string
772 // that is already in the buffer. 772 // that is already in the buffer.
773 scriptindex++; 773 scriptindex++;
774 setExpect(scriptArgument); 774 setExpect(scriptArgument);
775 loopnest--; 775 loopnest--;
776 loopend = true; 776 loopend = true;
777 } 777 }
778 messg->setText(bm); 778 messg->setText(bm);
779 emit debugMessage(bm); 779 emit debugMessage(bm);
780 780
781 } 781 }
782 } 782 }
783 } 783 }
784 784
785 // this is a subroutine for the "Answer" script option 785 // this is a subroutine for the "Answer" script option
786 786
787 if(vmain == 150) { 787 if(vmain == 150) {
788 if(!expecting) { 788 if(!expecting) {
789 writeline(_ifaceppp->data()->modemAnswerStr()); 789 writeline(_ifaceppp->data()->modemAnswerStr());
790 setExpect(_ifaceppp->data()->modemAnswerResp()); 790 setExpect(_ifaceppp->data()->modemAnswerResp());
791 791
792 vmain = 2; 792 vmain = 2;
793 scriptindex++; 793 scriptindex++;
794 return; 794 return;
795 } 795 }
796 } 796 }
797 797
798 if(vmain == 30) { 798 if(vmain == 30) {
799// if (termwindow->isVisible()) 799// if (termwindow->isVisible())
800// return; 800// return;
801// if (termwindow->pressedContinue()) 801// if (termwindow->pressedContinue())
802// vmain = 10; 802// vmain = 10;
803// else 803// else
804 cancelbutton(); 804 cancelbutton();
805 } 805 }
806 806
807 if(vmain == 10) { 807 if(vmain == 10) {
808 if(!expecting) { 808 if(!expecting) {
809 809
810 int result; 810 int result;
811 811
812 timeout_timer->stop(); 812 timeout_timer->stop();
813 if_timeout_timer->stop(); // better be sure. 813 if_timeout_timer->stop(); // better be sure.
814 814
815 // stop reading of data 815 // stop reading of data
816 _ifaceppp->modem()->stop(); 816 _ifaceppp->modem()->stop();
817 817
818 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { 818 if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) {
819 // if (termwindow) { 819 // if (termwindow) {
820 // delete termwindow; 820 // delete termwindow;
821 // termwindow = 0L; 821 // termwindow = 0L;
822 // this->show(); 822 // this->show();
823 // } else { 823 // } else {
824 // termwindow = new LoginTerm(0L, 0L); 824 // termwindow = new LoginTerm(0L, 0L);
825 // hide(); 825 // hide();
826 // termwindow->show(); 826 // termwindow->show();
827 // vmain = 30; 827 // vmain = 30;
828 // return; 828 // return;
829 // } 829 // }
830 } 830 }
831 831
832 // Close the tty. This prevents the QTimer::singleShot() in 832 // Close the tty. This prevents the QTimer::singleShot() in
833 // Modem::readtty() from re-enabling the socket notifier. 833 // Modem::readtty() from re-enabling the socket notifier.
834 // The port is still held open by the helper process. 834 // The port is still held open by the helper process.
835 835
836 /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), 836 /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(),
837 and closing the thing prevents pppd from using it later. */ 837 and closing the thing prevents pppd from using it later. */
838 //_ifaceppp->modem()->closetty(); 838 //_ifaceppp->modem()->closetty();
839 839
840 killTimer( main_timer_ID ); 840 killTimer( main_timer_ID );
841 841
842 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); 842 if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000);
843 odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl; 843 odebug << "started if timeout timer with " << _ifaceppp->data()->pppdTimeout()*1000 << "" << oendl;
844 844
845 // find out PPP interface and notify the stats module 845 // find out PPP interface and notify the stats module
846// stats->setUnit(pppInterfaceNumber()); 846// stats->setUnit(pppInterfaceNumber());
847 847
848 qApp->flushX(); 848 qApp->flushX();
849 semaphore = true; 849 semaphore = true;
850 result = execppp(); 850 result = execppp();
851 851
852 emit debugMessage(QObject::tr("Starting pppd...")); 852 emit debugMessage(QObject::tr("Starting pppd..."));
853 odebug << "execppp() returned with return-code " << result << "" << oendl; 853 odebug << "execppp() returned with return-code " << result << "" << oendl;
854 854
855 if(result) { 855 if(result) {
856 if(!_ifaceppp->data()->autoDNS()) 856 if(!_ifaceppp->data()->autoDNS())
857 adddns( _ifaceppp ); 857 adddns( _ifaceppp );
858 858
859 // O.K we are done here, let's change over to the if_waiting loop 859 // O.K we are done here, let's change over to the if_waiting loop
860 // where we wait for the ppp if (interface) to come up. 860 // where we wait for the ppp if (interface) to come up.
861 861
862 emit if_waiting_signal(); 862 emit if_waiting_signal();
863 } else { 863 } else {
864 864
865 // starting pppd wasn't successful. Error messages were 865 // starting pppd wasn't successful. Error messages were
866 // handled by execppp(); 866 // handled by execppp();
867 if_timeout_timer->stop(); 867 if_timeout_timer->stop();
868 this->hide(); 868 this->hide();
869 messg->setText(""); 869 messg->setText("");
870 //p_kppp->quit_b->setFocus(); 870 //p_kppp->quit_b->setFocus();
871 //p_kppp->show(); 871 //p_kppp->show();
872 qApp->processEvents(); 872 qApp->processEvents();
873 _ifaceppp->modem()->hangup(); 873 _ifaceppp->modem()->hangup();
874 emit stopAccounting(); 874 emit stopAccounting();
875 //p_kppp->con_win->stopClock(); 875 //p_kppp->con_win->stopClock();
876 _ifaceppp->modem()->closetty(); 876 _ifaceppp->modem()->closetty();
877 _ifaceppp->modem()->unlockdevice(); 877 _ifaceppp->modem()->unlockdevice();
878 878
879 } 879 }
880 880
881 return; 881 return;
882 } 882 }
883 } 883 }
884 884
885 // this is a "wait until cancel" entry 885 // this is a "wait until cancel" entry
886 886
887 if(vmain == 20) { 887 if(vmain == 20) {
888 } 888 }
889} 889}
890 890
891 891
892void ConnectWidget::set_con_speed_string() { 892void ConnectWidget::set_con_speed_string() {
893 // Here we are trying to determine the speed at which we are connected. 893 // Here we are trying to determine the speed at which we are connected.
894 // Usually the modem responds after connect with something like 894 // Usually the modem responds after connect with something like
895 // CONNECT 115200, so all we need to do is find the number after CONNECT 895 // CONNECT 115200, so all we need to do is find the number after CONNECT
896 // or whatever the modemConnectResp() is. 896 // or whatever the modemConnectResp() is.
897// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); 897// p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer);
898} 898}
899 899
900 900
901 901
902void ConnectWidget::readChar(unsigned char c) { 902void ConnectWidget::readChar(unsigned char c) {
903 if(semaphore) 903 if(semaphore)
904 return; 904 return;
905 905
906 readbuffer += c; 906 readbuffer += c;
907 myreadbuffer += c; 907 myreadbuffer += c;
908 908
909 // While in scanning mode store each char to the scan buffer 909 // While in scanning mode store each char to the scan buffer
910 // for use in the prompt command 910 // for use in the prompt command
911 if( scanning ) 911 if( scanning )
912 scanbuffer += c; 912 scanbuffer += c;
913 913
914 // add to debug window 914 // add to debug window
915 emit debugPutChar(c); 915 emit debugPutChar(c);
916 916
917 checkBuffers(); 917 checkBuffers();
918} 918}
919 919
920 920
921void ConnectWidget::checkBuffers() { 921void ConnectWidget::checkBuffers() {
922 // Let's check if we are finished with scanning: 922 // Let's check if we are finished with scanning:
923 // The scanstring have to be in the buffer and the latest character 923 // The scanstring have to be in the buffer and the latest character
924 // was a carriage return or an linefeed (depending on modem setup) 924 // was a carriage return or an linefeed (depending on modem setup)
925 if( scanning && scanbuffer.contains(scanstr) && 925 if( scanning && scanbuffer.contains(scanstr) &&
926 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { 926 ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) {
927 scanning = false; 927 scanning = false;
928 928
929 int vstart = scanbuffer.find( scanstr ) + scanstr.length(); 929 int vstart = scanbuffer.find( scanstr ) + scanstr.length();
930 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); 930 scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart);
931 scanvar = scanvar.stripWhiteSpace(); 931 scanvar = scanvar.stripWhiteSpace();
932 932
933 // Show the Variabel content in the debug window 933 // Show the Variabel content in the debug window
934 QString sv = QObject::tr("Scan Var: %1").arg(scanvar); 934 QString sv = QObject::tr("Scan Var: %1").arg(scanvar);
935 emit debugMessage(sv); 935 emit debugMessage(sv);
936 } 936 }
937 937
938 if(expecting) { 938 if(expecting) {
939 if(readbuffer.contains(expectstr)) { 939 if(readbuffer.contains(expectstr)) {
940 expecting = false; 940 expecting = false;
941 // keep everything after the expected string 941 // keep everything after the expected string
942 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); 942 readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length());
943 943
944 QString ts = QObject::tr("Found: %1").arg(expectstr); 944 QString ts = QObject::tr("Found: %1").arg(expectstr);
945 emit debugMessage(ts); 945 emit debugMessage(ts);
946 946
947 if (loopend) { 947 if (loopend) {
948 loopend=false; 948 loopend=false;
949 } 949 }
950 } 950 }
951 951
952 if (loopend && readbuffer.contains(loopstr[loopnest])) { 952 if (loopend && readbuffer.contains(loopstr[loopnest])) {
953 expecting = false; 953 expecting = false;
954 readbuffer = ""; 954 readbuffer = "";
955 QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]); 955 QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]);
956 emit debugMessage(ts); 956 emit debugMessage(ts);
957 scriptindex = loopstartindex[loopnest]; 957 scriptindex = loopstartindex[loopnest];
958 loopend = false; 958 loopend = false;
959 loopnest++; 959 loopnest++;
960 } 960 }
961 // notify event loop if expected string was found 961 // notify event loop if expected string was found
962 if(!expecting) 962 if(!expecting)
963 timerEvent((QTimerEvent *) 0); 963 timerEvent((QTimerEvent *) 0);
964 } 964 }
965} 965}
966 966
967 967
968 968
969void ConnectWidget::pause() { 969void ConnectWidget::pause() {
970 pausing = false; 970 pausing = false;
971 pausetimer->stop(); 971 pausetimer->stop();
972} 972}
973 973
974 974
975void ConnectWidget::cancelbutton() { 975void ConnectWidget::cancelbutton() {
976 _ifaceppp->modem()->stop(); 976 _ifaceppp->modem()->stop();
977 killTimer(main_timer_ID); 977 killTimer(main_timer_ID);
978 timeout_timer->stop(); 978 timeout_timer->stop();
979 if_timer->stop(); 979 if_timer->stop();
980 if_timeout_timer->stop(); 980 if_timeout_timer->stop();
981 981
982// if (termwindow) { 982// if (termwindow) {
983// delete termwindow; 983// delete termwindow;
984// termwindow = 0L; 984// termwindow = 0L;
985// this->show(); 985// this->show();
986// } 986// }
987 987
988 messg->setText(QObject::tr("One moment please...")); 988 messg->setText(QObject::tr("One moment please..."));
989 989
990 // just to be sure 990 // just to be sure
991 _ifaceppp->modem()->removeSecret(AUTH_PAP); 991 _ifaceppp->modem()->removeSecret(AUTH_PAP);
992 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 992 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
993 removedns(_ifaceppp); 993 removedns(_ifaceppp);
994 994
995 qApp->processEvents(); 995 qApp->processEvents();
996 996
997 _ifaceppp->modem()->killPPPDaemon(); 997 _ifaceppp->modem()->killPPPDaemon();
998 _ifaceppp->modem()->hangup(); 998 _ifaceppp->modem()->hangup();
999 999
1000 1000
1001// p_kppp->quit_b->setFocus(); 1001// p_kppp->quit_b->setFocus();
1002// p_kppp->show(); 1002// p_kppp->show();
1003 // emit stopAccounting();// just to be sure 1003 // emit stopAccounting();// just to be sure
1004// p_kppp->con_win->stopClock(); 1004// p_kppp->con_win->stopClock();
1005 _ifaceppp->modem()->closetty(); 1005 _ifaceppp->modem()->closetty();
1006 _ifaceppp->modem()->unlockdevice(); 1006 _ifaceppp->modem()->unlockdevice();
1007 1007
1008 //abort prompt window... 1008 //abort prompt window...
1009 if (prompt->isVisible()) { 1009 if (prompt->isVisible()) {
1010 prompt->hide(); 1010 prompt->hide();
1011 } 1011 }
1012 prompt->setConsumed(); 1012 prompt->setConsumed();
1013 1013
1014 _ifaceppp->setStatus( false ); 1014 _ifaceppp->setStatus( false );
1015 _ifaceppp->refresh(); 1015 _ifaceppp->refresh();
1016// messg->setText(tr("offline")); 1016// messg->setText(tr("offline"));
1017 refresh(); 1017 refresh();
1018} 1018}
1019 1019
1020 1020
1021void ConnectWidget::script_timed_out() { 1021void ConnectWidget::script_timed_out() {
1022 if(vmain == 20) { // we are in the 'wait for the user to cancel' state 1022 if(vmain == 20) { // we are in the 'wait for the user to cancel' state
1023 timeout_timer->stop(); 1023 timeout_timer->stop();
1024 emit stopAccounting(); 1024 emit stopAccounting();
1025// p_kppp->con_win->stopClock(); 1025// p_kppp->con_win->stopClock();
1026 return; 1026 return;
1027 } 1027 }
1028 1028
1029 if (prompt->isVisible()) 1029 if (prompt->isVisible())
1030 prompt->hide(); 1030 prompt->hide();
1031 1031
1032 prompt->setConsumed(); 1032 prompt->setConsumed();
1033 messg->setText(QObject::tr("Script timed out!")); 1033 messg->setText(QObject::tr("Script timed out!"));
1034 _ifaceppp->modem()->hangup(); 1034 _ifaceppp->modem()->hangup();
1035 emit stopAccounting(); 1035 emit stopAccounting();
1036// p_kppp->con_win->stopClock(); 1036// p_kppp->con_win->stopClock();
1037 1037
1038 vmain = 0; // let's try again. 1038 vmain = 0; // let's try again.
1039 substate = -1; 1039 substate = -1;
1040} 1040}
1041 1041
1042 1042
1043void ConnectWidget::setScan(const QString &n) { 1043void ConnectWidget::setScan(const QString &n) {
1044 scanning = true; 1044 scanning = true;
1045 scanstr = n; 1045 scanstr = n;
1046 scanbuffer = ""; 1046 scanbuffer = "";
1047 1047
1048 QString ts = QObject::tr("Scanning: %1").arg(n); 1048 QString ts = QObject::tr("Scanning: %1").arg(n);
1049 emit debugMessage(ts); 1049 emit debugMessage(ts);
1050} 1050}
1051 1051
1052 1052
1053void ConnectWidget::setExpect(const QString &n) { 1053void ConnectWidget::setExpect(const QString &n) {
1054 expecting = true; 1054 expecting = true;
1055 expectstr = n; 1055 expectstr = n;
1056 1056
1057 QString ts = QObject::tr("Expecting: %1").arg(n); 1057 QString ts = QObject::tr("Expecting: %1").arg(n);
1058 ts.replace(QRegExp("\n"), "<LF>"); 1058 ts.replace(QRegExp("\n"), "<LF>");
1059 emit debugMessage(ts); 1059 emit debugMessage(ts);
1060 1060
1061 // check if the expected string is in the read buffer already. 1061 // check if the expected string is in the read buffer already.
1062 checkBuffers(); 1062 checkBuffers();
1063} 1063}
1064 1064
1065 1065
1066void ConnectWidget::if_waiting_timed_out() { 1066void ConnectWidget::if_waiting_timed_out() {
1067 if_timer->stop(); 1067 if_timer->stop();
1068 if_timeout_timer->stop(); 1068 if_timeout_timer->stop();
1069 odebug << "if_waiting_timed_out()" << oendl; 1069 odebug << "if_waiting_timed_out()" << oendl;
1070 1070
1071 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); 1071 _ifaceppp->data()->setpppdError(E_IF_TIMEOUT);
1072 1072
1073 // let's kill the stuck pppd 1073 // let's kill the stuck pppd
1074 _ifaceppp->modem()->killPPPDaemon(); 1074 _ifaceppp->modem()->killPPPDaemon();
1075 1075
1076 emit stopAccounting(); 1076 emit stopAccounting();
1077// p_kppp->con_win->stopClock(); 1077// p_kppp->con_win->stopClock();
1078 1078
1079 1079
1080 // killing ppp will generate a SIGCHLD which will be caught in pppdie() 1080 // killing ppp will generate a SIGCHLD which will be caught in pppdie()
1081 // in main.cpp what happens next will depend on the boolean 1081 // in main.cpp what happens next will depend on the boolean
1082 // reconnect_on_disconnect which is set in ConnectWidget::init(); 1082 // reconnect_on_disconnect which is set in ConnectWidget::init();
1083} 1083}
1084 1084
1085void ConnectWidget::pppdDied() 1085void ConnectWidget::pppdDied()
1086{ 1086{
1087 if_timer->stop(); 1087 if_timer->stop();
1088 if_timeout_timer->stop(); 1088 if_timeout_timer->stop();
1089} 1089}
1090 1090
1091void ConnectWidget::if_waiting_slot() { 1091void ConnectWidget::if_waiting_slot() {
1092 messg->setText(QObject::tr("Logging on to network...")); 1092 messg->setText(QObject::tr("Logging on to network..."));
1093 1093
1094// if(!stats->ifIsUp()) { 1094// if(!stats->ifIsUp()) {
1095 1095
1096// if(_ifaceppp->data()->pppdError() != 0) { 1096// if(_ifaceppp->data()->pppdError() != 0) {
1097// // we are here if pppd died immediately after starting it. 1097// // we are here if pppd died immediately after starting it.
1098// pppdDied(); 1098// pppdDied();
1099// // error message handled in main.cpp: sigPPPDDied() 1099// // error message handled in main.cpp: sigPPPDDied()
1100// return; 1100// return;
1101// } 1101// }
1102 1102
1103// if_timer->start(100, TRUE); // single shot 1103// if_timer->start(100, TRUE); // single shot
1104// return; 1104// return;
1105// } 1105// }
1106 1106
1107 // O.K the ppp interface is up and running 1107 // O.K the ppp interface is up and running
1108 // give it a few time to come up completly (0.2 seconds) 1108 // give it a few time to come up completly (0.2 seconds)
1109 if_timeout_timer->stop(); 1109 if_timeout_timer->stop();
1110 if_timer->stop(); 1110 if_timer->stop();
1111 usleep(200000); 1111 usleep(200000);
1112 1112
1113 if(_ifaceppp->data()->autoDNS()) 1113 if(_ifaceppp->data()->autoDNS())
1114 addpeerdns( _ifaceppp ); 1114 addpeerdns( _ifaceppp );
1115 1115
1116 // Close the debugging window. If we are connected, we 1116 // Close the debugging window. If we are connected, we
1117 // are not really interested in debug output 1117 // are not really interested in debug output
1118 emit closeDebugWindow(); 1118 emit closeDebugWindow();
1119// p_kppp->statdlg->take_stats(); // start taking ppp statistics 1119// p_kppp->statdlg->take_stats(); // start taking ppp statistics
1120 auto_hostname(_ifaceppp); 1120 auto_hostname(_ifaceppp);
1121 1121
1122 if(!_ifaceppp->data()->command_on_connect().isEmpty()) { 1122 if(!_ifaceppp->data()->command_on_connect().isEmpty()) {
1123 messg->setText(QObject::tr("Running startup command...")); 1123 messg->setText(QObject::tr("Running startup command..."));
1124 1124
1125 // make sure that we don't get any async errors 1125 // make sure that we don't get any async errors
1126 qApp->flushX(); 1126 qApp->flushX();
1127 execute_command(_ifaceppp->data()->command_on_connect()); 1127 execute_command(_ifaceppp->data()->command_on_connect());
1128 messg->setText(QObject::tr("Done")); 1128 messg->setText(QObject::tr("Done"));
1129 } 1129 }
1130 1130
1131 // remove the authentication file 1131 // remove the authentication file
1132 _ifaceppp->modem()->removeSecret(AUTH_PAP); 1132 _ifaceppp->modem()->removeSecret(AUTH_PAP);
1133 _ifaceppp->modem()->removeSecret(AUTH_CHAP); 1133 _ifaceppp->modem()->removeSecret(AUTH_CHAP);
1134 1134
1135 emit debugMessage(QObject::tr("Done")); 1135 emit debugMessage(QObject::tr("Done"));
1136 set_con_speed_string(); 1136 set_con_speed_string();
1137 1137
1138// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); 1138// p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed);
1139// this->hide(); 1139// this->hide();
1140// messg->setText(""); 1140// messg->setText("");
1141 1141
1142 _ifaceppp->setStatus( true ); 1142 _ifaceppp->setStatus( true );
1143 1143
1144 m_refreshTimer = new QTimer( this ); 1144 m_refreshTimer = new QTimer( this );
1145 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 1145 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
1146 m_refreshTimer->start( 3000 ); 1146 m_refreshTimer->start( 3000 );
1147 //_ifaceppp->refresh(); 1147 //_ifaceppp->refresh();
1148 // emit _ifaceppp->updateInterface(_ifaceppp); 1148 // emit _ifaceppp->updateInterface(_ifaceppp);
1149 1149
1150 // prepare the con_win so as to have the right size for 1150 // prepare the con_win so as to have the right size for
1151 // accounting / non-accounting mode 1151 // accounting / non-accounting mode
1152// if(p_kppp->acct != 0) 1152// if(p_kppp->acct != 0)
1153// p_kppp->con_win->accounting(p_kppp->acct->running()); 1153// p_kppp->con_win->accounting(p_kppp->acct->running());
1154// else 1154// else
1155// p_kppp->con_win->accounting(false); 1155// p_kppp->con_win->accounting(false);
1156 1156
1157// if (_ifaceppp->data()->get_dock_into_panel()) { 1157// if (_ifaceppp->data()->get_dock_into_panel()) {
1158// // DockWidget::dock_widget->show(); 1158// // DockWidget::dock_widget->show();
1159// // DockWidget::dock_widget->take_stats(); 1159// // DockWidget::dock_widget->take_stats();
1160// // this->hide(); 1160// // this->hide();
1161// } 1161// }
1162// else { 1162// else {
1163// // p_kppp->con_win->show(); 1163// // p_kppp->con_win->show();
1164 1164
1165// if(_ifaceppp->data()->get_iconify_on_connect()) { 1165// if(_ifaceppp->data()->get_iconify_on_connect()) {
1166// // p_kppp->con_win->showMinimized(); 1166// // p_kppp->con_win->showMinimized();
1167// } 1167// }
1168// } 1168// }
1169 1169
1170 _ifaceppp->modem()->closetty(); 1170 _ifaceppp->modem()->closetty();
1171} 1171}
1172 1172
1173void ConnectWidget::refresh() { 1173void ConnectWidget::refresh() {
1174 _ifaceppp->refresh(); 1174 _ifaceppp->refresh();
1175 if ( _ifaceppp->getStatus() ) { 1175 if ( _ifaceppp->getStatus() ) {
1176 messg->setText(QObject::tr("Online")); 1176 messg->setText(QObject::tr("Online"));
1177 } else { 1177 } else {
1178 messg->setText(QObject::tr("Offline")); 1178 messg->setText(QObject::tr("Offline"));
1179 } 1179 }
1180} 1180}
1181 1181
1182 1182
1183bool ConnectWidget::execppp() { 1183bool ConnectWidget::execppp() {
1184 QString command; 1184 QString command;
1185 1185
1186 command = "pppd"; 1186 command = "pppd";
1187 1187
1188 // as of version 2.3.6 pppd falls back to the real user rights when 1188 // as of version 2.3.6 pppd falls back to the real user rights when
1189 // opening a device given in a command line. To avoid permission conflicts 1189 // opening a device given in a command line. To avoid permission conflicts
1190 // we'll simply leave this argument away. pppd will then use the default tty 1190 // we'll simply leave this argument away. pppd will then use the default tty
1191 // which is the serial port we connected stdin/stdout to in opener.cpp. 1191 // which is the serial port we connected stdin/stdout to in opener.cpp.
1192 // command += " "; 1192 // command += " ";
1193 // command += _ifaceppp->data()->modemDevice(); 1193 // command += _ifaceppp->data()->modemDevice();
1194 1194
1195 command += " " + _ifaceppp->data()->speed(); 1195 command += " " + _ifaceppp->data()->speed();
1196 1196
1197 command += " -detach"; 1197 command += " -detach";
1198 1198
1199 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || 1199 if(_ifaceppp->data()->ipaddr() != "0.0.0.0" ||
1200 _ifaceppp->data()->gateway() != "0.0.0.0") { 1200 _ifaceppp->data()->gateway() != "0.0.0.0") {
1201 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { 1201 if(_ifaceppp->data()->ipaddr() != "0.0.0.0") {
1202 command += " "; 1202 command += " ";
1203 command += _ifaceppp->data()->ipaddr(); 1203 command += _ifaceppp->data()->ipaddr();
1204 command += ":"; 1204 command += ":";
1205 } 1205 }
1206 else { 1206 else {
1207 command += " "; 1207 command += " ";
1208 command += ":"; 1208 command += ":";
1209 } 1209 }
1210 1210
1211 if(_ifaceppp->data()->gateway() != "0.0.0.0") 1211 if(_ifaceppp->data()->gateway() != "0.0.0.0")
1212 command += _ifaceppp->data()->gateway(); 1212 command += _ifaceppp->data()->gateway();
1213 } 1213 }
1214 1214
1215 if(_ifaceppp->data()->subnetmask() != "0.0.0.0") 1215 if(_ifaceppp->data()->subnetmask() != "0.0.0.0")
1216 command += " netmask " + _ifaceppp->data()->subnetmask(); 1216 command += " netmask " + _ifaceppp->data()->subnetmask();
1217 1217
1218 if(_ifaceppp->data()->flowcontrol() != "None") { 1218 if(_ifaceppp->data()->flowcontrol() != PPPData::FlowNone) {
1219 if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") 1219 if(_ifaceppp->data()->flowcontrol() == PPPData::FlowHardware)
1220 command += " crtscts"; 1220 command += " crtscts";
1221 else 1221 else
1222 command += " xonxoff"; 1222 command += " xonxoff";
1223 } 1223 }
1224 1224
1225 if(_ifaceppp->data()->defaultroute()) 1225 if(_ifaceppp->data()->defaultroute())
1226 command += " defaultroute"; 1226 command += " defaultroute";
1227 1227
1228 if(_ifaceppp->data()->autoDNS()) 1228 if(_ifaceppp->data()->autoDNS())
1229 command += " usepeerdns"; 1229 command += " usepeerdns";
1230 1230
1231 1231
1232 // PAP settings 1232 // PAP settings
1233 if(_ifaceppp->data()->authMethod() == AUTH_PAP) { 1233 if(_ifaceppp->data()->authMethod() == AUTH_PAP) {
1234 command += " -chap user "; 1234 command += " -chap user ";
1235 command = command + _ifaceppp->data()->storedUsername(); 1235 command = command + _ifaceppp->data()->storedUsername();
1236 } 1236 }
1237 1237
1238 // CHAP settings 1238 // CHAP settings
1239 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { 1239 if(_ifaceppp->data()->authMethod() == AUTH_CHAP) {
1240 command += " -pap user "; 1240 command += " -pap user ";
1241 command = command + _ifaceppp->data()->storedUsername(); 1241 command = command + _ifaceppp->data()->storedUsername();
1242 } 1242 }
1243 1243
1244 // PAP/CHAP settings 1244 // PAP/CHAP settings
1245 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { 1245 if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) {
1246 QString tmpName = _ifaceppp->data()->storedUsername(); 1246 QString tmpName = _ifaceppp->data()->storedUsername();
1247 if ( !tmpName.isEmpty() ) { 1247 if ( !tmpName.isEmpty() ) {
1248 command += " user "; 1248 command += " user ";
1249 command = command + tmpName; 1249 command = command + tmpName;
1250 } 1250 }
1251 } 1251 }
1252 1252
1253 // check for debug 1253 // check for debug
1254 if(_ifaceppp->data()->getPPPDebug()) 1254 if(_ifaceppp->data()->getPPPDebug())
1255 command += " debug"; 1255 command += " debug";
1256 1256
1257 QStringList &arglist = _ifaceppp->data()->pppdArgument(); 1257 QStringList &arglist = _ifaceppp->data()->pppdArgument();
1258 for ( QStringList::Iterator it = arglist.begin(); 1258 for ( QStringList::Iterator it = arglist.begin();
1259 it != arglist.end(); 1259 it != arglist.end();
1260 ++it ) 1260 ++it )
1261 { 1261 {
1262 command += " " + *it; 1262 command += " " + *it;
1263 } 1263 }
1264 1264
1265 command += " call opie-kppp logfd 11"; 1265 command += " call opie-kppp logfd 11";
1266 1266
1267 if (command.length() > MAX_CMDLEN) { 1267 if (command.length() > MAX_CMDLEN) {
1268 QMessageBox::critical(this, "error", QObject::tr( 1268 QMessageBox::critical(this, "error", QObject::tr(
1269 "pppd command + command-line arguments exceed " 1269 "pppd command + command-line arguments exceed "
1270 "2024 characters in length." 1270 "2024 characters in length."
1271 )); 1271 ));
1272 1272
1273 return false; // nonsensically long command which would bust my buffer buf. 1273 return false; // nonsensically long command which would bust my buffer buf.
1274 } 1274 }
1275 1275
1276 owarn << "Command IS: " << command.latin1() << "" << oendl; 1276 owarn << "Command IS: " << command.latin1() << "" << oendl;
1277 1277
1278 qApp->flushX(); 1278 qApp->flushX();
1279 1279
1280 return _ifaceppp->modem()->execPPPDaemon(command); 1280 return _ifaceppp->modem()->execPPPDaemon(command);
1281} 1281}
1282 1282
1283 1283
1284void ConnectWidget::closeEvent( QCloseEvent *e ) { 1284void ConnectWidget::closeEvent( QCloseEvent *e ) {
1285 e->ignore(); 1285 e->ignore();
1286 emit cancelbutton(); 1286 emit cancelbutton();
1287} 1287}
1288 1288
1289 1289
1290void ConnectWidget::setMsg(const QString &msg) { 1290void ConnectWidget::setMsg(const QString &msg) {
1291 messg->setText(msg); 1291 messg->setText(msg);
1292} 1292}
1293 1293
1294void ConnectWidget::writeline(const QString &s) { 1294void ConnectWidget::writeline(const QString &s) {
1295 _ifaceppp->modem()->writeLine(s.local8Bit()); 1295 _ifaceppp->modem()->writeLine(s.local8Bit());
1296} 1296}
1297 1297
1298// Set the hostname and domain from DNS Server 1298// Set the hostname and domain from DNS Server
1299void auto_hostname(InterfacePPP *_ifaceppp) { 1299void auto_hostname(InterfacePPP *_ifaceppp) {
1300 struct in_addr local_ip; 1300 struct in_addr local_ip;
1301 struct hostent *hostname_entry; 1301 struct hostent *hostname_entry;
1302 QString new_hostname; 1302 QString new_hostname;
1303 int dot; 1303 int dot;
1304 char tmp_str[100]; // buffer overflow safe 1304 char tmp_str[100]; // buffer overflow safe
1305 1305
1306 gethostname(tmp_str, sizeof(tmp_str)); 1306 gethostname(tmp_str, sizeof(tmp_str));
1307 tmp_str[sizeof(tmp_str)-1]=0; // panic 1307 tmp_str[sizeof(tmp_str)-1]=0; // panic
1308 old_hostname=tmp_str; // copy to QString 1308 old_hostname=tmp_str; // copy to QString
1309 1309
1310 // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { 1310 // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) {
1311 if ( _ifaceppp->data()->autoname()) { 1311 if ( _ifaceppp->data()->autoname()) {
1312// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); 1312// local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii());
1313 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); 1313 hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET);
1314 1314
1315 if (hostname_entry != 0L) { 1315 if (hostname_entry != 0L) {
1316 new_hostname=hostname_entry->h_name; 1316 new_hostname=hostname_entry->h_name;
1317 dot=new_hostname.find('.'); 1317 dot=new_hostname.find('.');
1318 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); 1318 new_hostname=new_hostname.remove(dot,new_hostname.length()-dot);
1319 _ifaceppp->modem()->setHostname(new_hostname); 1319 _ifaceppp->modem()->setHostname(new_hostname);
1320 modified_hostname = TRUE; 1320 modified_hostname = TRUE;
1321 1321
1322 new_hostname=hostname_entry->h_name; 1322 new_hostname=hostname_entry->h_name;
1323 new_hostname.remove(0,dot+1); 1323 new_hostname.remove(0,dot+1);
1324 1324
1325 add_domain(new_hostname, _ifaceppp); 1325 add_domain(new_hostname, _ifaceppp);
1326 } 1326 }
1327 } 1327 }
1328 1328
1329} 1329}
1330 1330
1331// Replace the DNS domain entry in the /etc/resolv.conf file and 1331// Replace the DNS domain entry in the /etc/resolv.conf file and
1332// disable the nameserver entries if option is enabled 1332// disable the nameserver entries if option is enabled
1333void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { 1333void add_domain(const QString &domain, InterfacePPP *_ifaceppp) {
1334 1334
1335 int fd; 1335 int fd;
1336 char c; 1336 char c;
1337 QString resolv[MAX_RESOLVCONF_LINES]; 1337 QString resolv[MAX_RESOLVCONF_LINES];
1338 1338
1339 if (domain.isEmpty()) 1339 if (domain.isEmpty())
1340 return; 1340 return;
1341 1341
1342 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { 1342 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
1343 1343
1344 int i=0; 1344 int i=0;
1345 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { 1345 while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) {
1346 if(c == '\n') { 1346 if(c == '\n') {
1347 i++; 1347 i++;
1348 } 1348 }
1349 else { 1349 else {
1350 resolv[i] += c; 1350 resolv[i] += c;
1351 } 1351 }
1352 } 1352 }
1353 close(fd); 1353 close(fd);
1354 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; 1354 if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++;
1355 1355
1356 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1356 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1357 QCString tmp = "domain " + domain.local8Bit() + 1357 QCString tmp = "domain " + domain.local8Bit() +
1358 " \t\t#kppp temp entry\n"; 1358 " \t\t#kppp temp entry\n";
1359 write(fd, tmp.data(), tmp.length()); 1359 write(fd, tmp.data(), tmp.length());
1360 1360
1361 for(int j=0; j < i; j++) { 1361 for(int j=0; j < i; j++) {
1362 if((resolv[j].contains("domain") || 1362 if((resolv[j].contains("domain") ||
1363 ( resolv[j].contains("nameserver") 1363 ( resolv[j].contains("nameserver")
1364 && !resolv[j].contains("#kppp temp entry") 1364 && !resolv[j].contains("#kppp temp entry")
1365 && _ifaceppp->data()->exDNSDisabled())) 1365 && _ifaceppp->data()->exDNSDisabled()))
1366 && !resolv[j].contains("#entry disabled by kppp")) { 1366 && !resolv[j].contains("#entry disabled by kppp")) {
1367 QCString tmp = "# " + resolv[j].local8Bit() + 1367 QCString tmp = "# " + resolv[j].local8Bit() +
1368 " \t#entry disabled by kppp\n"; 1368 " \t#entry disabled by kppp\n";
1369 write(fd, tmp, tmp.length()); 1369 write(fd, tmp, tmp.length());
1370 } 1370 }
1371 else { 1371 else {
1372 QCString tmp = resolv[j].local8Bit() + "\n"; 1372 QCString tmp = resolv[j].local8Bit() + "\n";
1373 write(fd, tmp, tmp.length()); 1373 write(fd, tmp, tmp.length());
1374 } 1374 }
1375 } 1375 }
1376 } 1376 }
1377 close(fd); 1377 close(fd);
1378 } 1378 }
1379} 1379}
1380 1380
1381 1381
1382// adds the DNS entries in the /etc/resolv.conf file 1382// adds the DNS entries in the /etc/resolv.conf file
1383void adddns( InterfacePPP *_ifaceppp) 1383void adddns( InterfacePPP *_ifaceppp)
1384{ 1384{
1385 int fd; 1385 int fd;
1386 1386
1387 if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1387 if ((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1388 QStringList &dnslist = _ifaceppp->data()->dns(); 1388 QStringList &dnslist = _ifaceppp->data()->dns();
1389 for ( QStringList::Iterator it = dnslist.begin(); 1389 for ( QStringList::Iterator it = dnslist.begin();
1390 it != dnslist.end(); 1390 it != dnslist.end();
1391 ++it ) 1391 ++it )
1392 { 1392 {
1393 QCString dns = "nameserver " + (*it).local8Bit() + 1393 QCString dns = "nameserver " + (*it).local8Bit() +
1394 " \t#kppp temp entry\n"; 1394 " \t#kppp temp entry\n";
1395 write(fd, dns.data(), dns.length()); 1395 write(fd, dns.data(), dns.length());
1396 } 1396 }
1397 close(fd); 1397 close(fd);
1398 } 1398 }
1399 add_domain(_ifaceppp->data()->domain(), _ifaceppp); 1399 add_domain(_ifaceppp->data()->domain(), _ifaceppp);
1400} 1400}
1401 1401
1402void addpeerdns(InterfacePPP *_ifaceppp) { 1402void addpeerdns(InterfacePPP *_ifaceppp) {
1403 int fd, fd2; 1403 int fd, fd2;
1404 1404
1405 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) { 1405 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_APPEND)) >= 0) {
1406 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) { 1406 if((fd2 = open("/etc/ppp/resolv.conf", O_RDONLY)) >= 0) {
1407 char c; 1407 char c;
1408 int i = 0; 1408 int i = 0;
1409 while(i++ < 100 && read(fd2, &c, 1) == 1) { 1409 while(i++ < 100 && read(fd2, &c, 1) == 1) {
1410 if(c == '\n') 1410 if(c == '\n')
1411 write(fd, "\t#kppp temp entry\n", 18); 1411 write(fd, "\t#kppp temp entry\n", 18);
1412 else 1412 else
1413 write(fd, &c, 1); 1413 write(fd, &c, 1);
1414 } 1414 }
1415 close(fd2); 1415 close(fd2);
1416 } else 1416 } else
1417 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n"); 1417 fprintf(stderr, "failed to read from /etc/ppp/resolv.conf\n");
1418 close(fd); 1418 close(fd);
1419 } 1419 }
1420 add_domain(_ifaceppp->data()->domain(), _ifaceppp); 1420 add_domain(_ifaceppp->data()->domain(), _ifaceppp);
1421} 1421}
1422 1422
1423// remove the dns entries from the /etc/resolv.conf file 1423// remove the dns entries from the /etc/resolv.conf file
1424void removedns(InterfacePPP *_ifaceppp) { 1424void removedns(InterfacePPP *_ifaceppp) {
1425 1425
1426 int fd; 1426 int fd;
1427 char c; 1427 char c;
1428 QString resolv[MAX_RESOLVCONF_LINES]; 1428 QString resolv[MAX_RESOLVCONF_LINES];
1429 1429
1430 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { 1430 if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) {
1431 1431
1432 int i=0; 1432 int i=0;
1433 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) { 1433 while(read(fd, &c, 1) == 1 && i < MAX_RESOLVCONF_LINES) {
1434 if(c == '\n') { 1434 if(c == '\n') {
1435 i++; 1435 i++;
1436 } 1436 }
1437 else { 1437 else {
1438 resolv[i] += c; 1438 resolv[i] += c;
1439 } 1439 }
1440 } 1440 }
1441 close(fd); 1441 close(fd);
1442 1442
1443 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { 1443 if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) {
1444 for(int j=0; j < i; j++) { 1444 for(int j=0; j < i; j++) {
1445 if(resolv[j].contains("#kppp temp entry")) continue; 1445 if(resolv[j].contains("#kppp temp entry")) continue;
1446 if(resolv[j].contains("#entry disabled by kppp")) { 1446 if(resolv[j].contains("#entry disabled by kppp")) {
1447 QCString tmp = resolv[j].local8Bit(); 1447 QCString tmp = resolv[j].local8Bit();
1448 write(fd, tmp.data()+2, tmp.length() - 27); 1448 write(fd, tmp.data()+2, tmp.length() - 27);
1449 write(fd, "\n", 1); 1449 write(fd, "\n", 1);
1450 } 1450 }
1451 else { 1451 else {
1452 QCString tmp = resolv[j].local8Bit() + "\n"; 1452 QCString tmp = resolv[j].local8Bit() + "\n";
1453 write(fd, tmp, tmp.length()); 1453 write(fd, tmp, tmp.length());
1454 } 1454 }
1455 } 1455 }
1456 } 1456 }
1457 close(fd); 1457 close(fd);
1458 1458
1459 } 1459 }
1460 1460
1461 if ( modified_hostname ) { 1461 if ( modified_hostname ) {
1462 _ifaceppp->modem()->setHostname(old_hostname); 1462 _ifaceppp->modem()->setHostname(old_hostname);
1463 modified_hostname = FALSE; 1463 modified_hostname = FALSE;
1464 } 1464 }
1465 1465
1466} 1466}
1467 1467
1468 1468
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index 5e2a04f..9457173 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -1,558 +1,544 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "general.h" 27#include "general.h"
28#include "interfaceppp.h" 28#include "interfaceppp.h"
29#include "modeminfo.h" 29#include "modeminfo.h"
30#include "modemcmds.h" 30#include "modemcmds.h"
31#include "pppdata.h" 31#include "pppdata.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37using namespace Opie::Core; 37using namespace Opie::Core;
38 38
39/* QT */ 39/* QT */
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qcombobox.h> 41#include <qcombobox.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qslider.h> 45#include <qslider.h>
46#include <qspinbox.h> 46#include <qspinbox.h>
47#include <qwhatsthis.h> 47#include <qwhatsthis.h>
48 48
49/* STD */ 49/* STD */
50#include <termios.h> 50#include <termios.h>
51#include <string.h> 51#include <string.h>
52 52
53 53
54ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) 54ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
55 : QWidget(parent, name), _pppdata(pd) 55 : QWidget(parent, name), _pppdata(pd)
56{ 56{
57 int k; 57 int k;
58 58
59 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); 59 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint());
60 60
61 QLabel *label1; 61 QLabel *label1;
62 62
63 label1 = new QLabel(tr("Modem &name:"), this); 63 label1 = new QLabel(tr("Modem &name:"), this);
64 tl->addWidget(label1, 0, 0); 64 tl->addWidget(label1, 0, 0);
65 65
66 modemname = new QLineEdit(this, "modemName"); 66 modemname = new QLineEdit(this, "modemName");
67 modemname->setText( _pppdata->devname() ); 67 modemname->setText( _pppdata->devname() );
68 label1->setBuddy(modemname); 68 label1->setBuddy(modemname);
69 tl->addWidget(modemname, 0, 1); 69 tl->addWidget(modemname, 0, 1);
70 70
71 label1 = new QLabel(tr("Modem de&vice:"), this); 71 label1 = new QLabel(tr("Modem de&vice:"), this);
72 tl->addWidget(label1, 1, 0); 72 tl->addWidget(label1, 1, 0);
73 73
74 modemdevice = new QComboBox(false, this); 74 modemdevice = new QComboBox(false, this);
75 modemdevice->setEditable( true ); 75 modemdevice->setEditable( true );
76 modemdevice->setDuplicatesEnabled ( false ); 76 modemdevice->setDuplicatesEnabled ( false );
77 modemdevice->setInsertionPolicy( QComboBox::AtTop ); 77 modemdevice->setInsertionPolicy( QComboBox::AtTop );
78 label1->setBuddy(modemdevice); 78 label1->setBuddy(modemdevice);
79 79
80 Config cfg("NetworkSetupPPP"); 80 Config cfg("NetworkSetupPPP");
81 cfg.setGroup("Devices_General"); 81 cfg.setGroup("Devices_General");
82 QStringList devs = cfg.readListEntry("devices",','); 82 QStringList devs = cfg.readListEntry("devices",',');
83 if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; 83 if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0";
84 modemdevice->insertStringList( devs ); 84 modemdevice->insertStringList( devs );
85 tl->addWidget(modemdevice, 1, 1); 85 tl->addWidget(modemdevice, 1, 1);
86 86
87 // connect(modemdevice, SIGNAL(activated(int)), 87 // connect(modemdevice, SIGNAL(activated(int)),
88 // SLOT(setmodemdc(int))); 88 // SLOT(setmodemdc(int)));
89 // connect(modemdevice, SIGNAL(textChanged(const QString&) ), 89 // connect(modemdevice, SIGNAL(textChanged(const QString&) ),
90 // SLOT( setmodemdc(const QString&) ) ); 90 // SLOT( setmodemdc(const QString&) ) );
91 91
92 QString tmp = tr("This specifies the serial port your modem is attached \n" 92 QString tmp = tr("This specifies the serial port your modem is attached \n"
93 "to. On Linux/x86, typically this is either /dev/ttyS0 \n" 93 "to. On Linux/x86, typically this is either /dev/ttyS0 \n"
94 "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" 94 "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n"
95 "\n" 95 "\n"
96 "If you have an internal ISDN card with AT command\n" 96 "If you have an internal ISDN card with AT command\n"
97 "emulation (most cards under Linux support this), you\n" 97 "emulation (most cards under Linux support this), you\n"
98 "should select one of the /dev/ttyIx devices."); 98 "should select one of the /dev/ttyIx devices.");
99 99
100 QWhatsThis::add(label1,tmp); 100 QWhatsThis::add(label1,tmp);
101 QWhatsThis::add(modemdevice,tmp); 101 QWhatsThis::add(modemdevice,tmp);
102 102
103 103
104 label1 = new QLabel(tr("&Flow control:"), this); 104 label1 = new QLabel(tr("&Flow control:"), this);
105 tl->addWidget(label1, 2, 0); 105 tl->addWidget(label1, 2, 0);
106 106
107 flowcontrol = new QComboBox(false, this); 107 flowcontrol = new QComboBox(false, this);
108 label1->setBuddy(flowcontrol); 108 label1->setBuddy(flowcontrol);
109 flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); 109 flowcontrol->insertItem(tr("Hardware [CRTSCTS]"));
110 flowcontrol->insertItem(tr("Software [XON/XOFF]")); 110 flowcontrol->insertItem(tr("Software [XON/XOFF]"));
111 flowcontrol->insertItem(tr("None")); 111 flowcontrol->insertItem(tr("None"));
112 tl->addWidget(flowcontrol, 2, 1); 112 tl->addWidget(flowcontrol, 2, 1);
113 // connect(flowcontrol, SIGNAL(activated(int)), 113 // connect(flowcontrol, SIGNAL(activated(int)),
114 // SLOT(setflowcontrol(int))); 114 // SLOT(setflowcontrol(int)));
115 115
116 tmp = tr("<p>Specifies how the serial port and modem\n" 116 tmp = tr("<p>Specifies how the serial port and modem\n"
117 "communicate. You should not change this unless\n" 117 "communicate. You should not change this unless\n"
118 "you know what you are doing.\n" 118 "you know what you are doing.\n"
119 "\n" 119 "\n"
120 "<b>Default</b>: CRTSCTS"); 120 "<b>Default</b>: CRTSCTS");
121 121
122 QWhatsThis::add(label1,tmp); 122 QWhatsThis::add(label1,tmp);
123 QWhatsThis::add(flowcontrol,tmp); 123 QWhatsThis::add(flowcontrol,tmp);
124 124
125 QLabel *labelenter = new QLabel(tr("&Line termination:"), this); 125 QLabel *labelenter = new QLabel(tr("&Line termination:"), this);
126 tl->addWidget(labelenter, 3, 0); 126 tl->addWidget(labelenter, 3, 0);
127 127
128 enter = new QComboBox(false, this); 128 enter = new QComboBox(false, this);
129 labelenter->setBuddy(enter); 129 labelenter->setBuddy(enter);
130 enter->insertItem("CR"); 130 enter->insertItem("CR");
131 enter->insertItem("LF"); 131 enter->insertItem("LF");
132 enter->insertItem("CR/LF"); 132 enter->insertItem("CR/LF");
133 tl->addWidget(enter, 3, 1); 133 tl->addWidget(enter, 3, 1);
134 // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); 134 // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int)));
135 tmp = tr("<p>Specifies how AT commands are sent to your\n" 135 tmp = tr("<p>Specifies how AT commands are sent to your\n"
136 "modem. Most modems will work fine with the\n" 136 "modem. Most modems will work fine with the\n"
137 "default <i>CR/LF</i>. If your modem does not react\n" 137 "default <i>CR/LF</i>. If your modem does not react\n"
138 "to the init string, you should try different\n" 138 "to the init string, you should try different\n"
139 "settings here\n" 139 "settings here\n"
140 "\n" 140 "\n"
141 "<b>Default</b>: CR/LF"); 141 "<b>Default</b>: CR/LF");
142 142
143 QWhatsThis::add(labelenter,tmp); 143 QWhatsThis::add(labelenter,tmp);
144 QWhatsThis::add(enter, tmp); 144 QWhatsThis::add(enter, tmp);
145 145
146 QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); 146 QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this);
147 tl->addWidget(baud_label, 4, 0); 147 tl->addWidget(baud_label, 4, 0);
148 baud_c = new QComboBox(this); 148 baud_c = new QComboBox(this);
149 baud_label->setBuddy(baud_c); 149 baud_label->setBuddy(baud_c);
150 150
151 static const char *baudrates[] = 151 static const char *baudrates[] =
152 { 152 {
153 153
154#ifdef B460800 154#ifdef B460800
155 "460800", 155 "460800",
156#endif 156#endif
157 157
158#ifdef B230400 158#ifdef B230400
159 "230400", 159 "230400",
160#endif 160#endif
161 161
162#ifdef B115200 162#ifdef B115200
163 "115200", 163 "115200",
164#endif 164#endif
165 165
166#ifdef B57600 166#ifdef B57600
167 "57600", 167 "57600",
168#endif 168#endif
169 169
170 "38400", 170 "38400",
171 "19200", 171 "19200",
172 "9600", 172 "9600",
173 "2400", 173 "2400",
174 0 174 0
175 }; 175 };
176 176
177 for(k = 0; baudrates[k]; k++) 177 for(k = 0; baudrates[k]; k++)
178 baud_c->insertItem(baudrates[k]); 178 baud_c->insertItem(baudrates[k]);
179 179
180 baud_c->setCurrentItem(3); 180 baud_c->setCurrentItem(3);
181 // connect(baud_c, SIGNAL(activated(int)), 181 // connect(baud_c, SIGNAL(activated(int)),
182 // this, SLOT(speed_selection(int))); 182 // this, SLOT(speed_selection(int)));
183 tl->addWidget(baud_c, 4, 1); 183 tl->addWidget(baud_c, 4, 1);
184 184
185 tmp = tr("Specifies the speed your modem and the serial\n" 185 tmp = tr("Specifies the speed your modem and the serial\n"
186 "port talk to each other. You should begin with\n" 186 "port talk to each other. You should begin with\n"
187 "the default of 38400 bits/sec. If everything\n" 187 "the default of 38400 bits/sec. If everything\n"
188 "works you can try to increase this value, but to\n" 188 "works you can try to increase this value, but to\n"
189 "no more than 115200 bits/sec (unless you know\n" 189 "no more than 115200 bits/sec (unless you know\n"
190 "that your serial port supports higher speeds)."); 190 "that your serial port supports higher speeds).");
191 191
192 QWhatsThis::add(baud_label,tmp); 192 QWhatsThis::add(baud_label,tmp);
193 QWhatsThis::add(baud_c,tmp); 193 QWhatsThis::add(baud_c,tmp);
194 194
195 for(int i=0; i <= enter->count()-1; i++)
196 {
197 if(_pppdata->enter() == enter->text(i))
198 enter->setCurrentItem(i);
199 }
200
201 tl->addRowSpacing(5, 10); 195 tl->addRowSpacing(5, 10);
202 196
203 //Modem Lock File 197 //Modem Lock File
204 modemlockfile = new QCheckBox(tr("&Use lock file"), this); 198 modemlockfile = new QCheckBox(tr("&Use lock file"), this);
205
206 modemlockfile->setChecked(_pppdata->modemLockFile()); 199 modemlockfile->setChecked(_pppdata->modemLockFile());
207 // connect(modemlockfile, SIGNAL(toggled(bool)), 200 // connect(modemlockfile, SIGNAL(toggled(bool)),
208 // SLOT(modemlockfilechanged(bool))); 201 // SLOT(modemlockfilechanged(bool)));
209 tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); 202 tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1);
210 // l12->addStretch(1); 203 // l12->addStretch(1);
211 QWhatsThis::add(modemlockfile, 204 QWhatsThis::add(modemlockfile,
212 tr("<p>To prevent other programs from accessing the\n" 205 tr("<p>To prevent other programs from accessing the\n"
213 "modem while a connection is established, a\n" 206 "modem while a connection is established, a\n"
214 "file can be created to indicate that the modem\n" 207 "file can be created to indicate that the modem\n"
215 "is in use. On Linux an example file would be\n" 208 "is in use. On Linux an example file would be\n"
216 "<tt>/var/lock/LCK..ttyS1</tt>\n" 209 "<tt>/var/lock/LCK..ttyS1</tt>\n"
217 "Here you can select whether this locking will\n" 210 "Here you can select whether this locking will\n"
218 "be done.\n" 211 "be done.\n"
219 "\n" 212 "\n"
220 "<b>Default</b>: On")); 213 "<b>Default</b>: On"));
221 214
222 // Modem Timeout Line Edit Box 215 // Modem Timeout Line Edit Box
223 QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); 216 QHBoxLayout *timeoutLayout = new QHBoxLayout( this );
224 QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); 217 QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" );
225 modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); 218 modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" );
226 // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); 219 // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this);
227 // modemtimeout->setLabel(tr("Modem &timeout:")); 220 // modemtimeout->setLabel(tr("Modem &timeout:"));
228 // modemtimeout->setRange(1, 120, 1); 221 // modemtimeout->setRange(1, 120, 1);
229 modemtimeout->setSuffix(tr(" sec")); 222 modemtimeout->setSuffix(tr(" sec"));
230 modemtimeout->setValue( _pppdata->modemTimeout() ); 223 modemtimeout->setValue( _pppdata->modemTimeout() );
231 // connect(modemtimeout, SIGNAL(valueChanged(int)), 224 // connect(modemtimeout, SIGNAL(valueChanged(int)),
232 // SLOT(modemtimeoutchanged(int))); 225 // SLOT(modemtimeoutchanged(int)));
233 timeoutLayout->addWidget(timeoutlabel); 226 timeoutLayout->addWidget(timeoutlabel);
234 timeoutLayout->addWidget(modemtimeout); 227 timeoutLayout->addWidget(modemtimeout);
235 tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); 228 tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1);
236 229
237 QWhatsThis::add(modemtimeout, 230 QWhatsThis::add(modemtimeout,
238 tr("This specifies how long <i>kppp</i> waits for a\n" 231 tr("This specifies how long <i>kppp</i> waits for a\n"
239 "<i>CONNECT</i> response from your modem. The\n" 232 "<i>CONNECT</i> response from your modem. The\n"
240 "recommended value is 30 seconds.")); 233 "recommended value is 30 seconds."));
241 234
242 //set stuff from gpppdata 235 //set stuff from gpppdata
243 for(int i=0; i <= enter->count()-1; i++) 236 enter->setCurrentItem( static_cast<int>(_pppdata->enter()) );
244 { 237 flowcontrol->setCurrentItem( static_cast<int>( _pppdata->flowcontrol() ) );
245 if(_pppdata->enter() == enter->text(i))
246 enter->setCurrentItem(i);
247 }
248 238
249 for(int i=0; i <= modemdevice->count()-1; i++) 239 for(int i=0; i <= modemdevice->count()-1; i++)
250 { 240 {
251 if(_pppdata->modemDevice() == modemdevice->text(i)) 241 if(_pppdata->modemDevice() == modemdevice->text(i))
252 modemdevice->setCurrentItem(i); 242 modemdevice->setCurrentItem(i);
253 } 243 }
254 244
255 for(int i=0; i <= flowcontrol->count()-1; i++)
256 {
257 if(_pppdata->flowcontrol() == flowcontrol->text(i))
258 flowcontrol->setCurrentItem(i);
259 }
260
261 //set the modem speed 245 //set the modem speed
262 for(int i=0; i < baud_c->count(); i++) 246 for(int i=0; i < baud_c->count(); i++)
263 if(baud_c->text(i) == _pppdata->speed()) 247 if(baud_c->text(i) == _pppdata->speed())
264 baud_c->setCurrentItem(i); 248 baud_c->setCurrentItem(i);
265 249
266 tl->setRowStretch(1, 1); 250 tl->setRowStretch(1, 1);
267} 251}
268 252
269ModemWidget::~ModemWidget() 253ModemWidget::~ModemWidget()
270{ 254{
271 QStringList devs; 255 QStringList devs;
272 256
273 for (int i=0;i<modemdevice->count();i++) 257 for (int i=0;i<modemdevice->count();i++)
274 { 258 {
275 QString s = modemdevice->text(i); 259 QString s = modemdevice->text(i);
276 s.simplifyWhiteSpace(); 260 s.simplifyWhiteSpace();
277 if (! s.isEmpty() ) devs << s; 261 if (! s.isEmpty() ) devs << s;
278 } 262 }
279 263
280 264
281 QString edited = modemdevice->currentText(); 265 QString edited = modemdevice->currentText();
282 if ( !( edited ).isEmpty() ) 266 if ( !( edited ).isEmpty() )
283 { 267 {
284 edited.simplifyWhiteSpace(); 268 edited.simplifyWhiteSpace();
285 if ( devs.contains( edited ) == 0 ) 269 if ( devs.contains( edited ) == 0 )
286 { 270 {
287 devs << edited; 271 devs << edited;
288 } 272 }
289 } 273 }
290 274
291 275
292 Config cfg("NetworkSetupPPP"); 276 Config cfg("NetworkSetupPPP");
293 cfg.setGroup("Devices_General"); 277 cfg.setGroup("Devices_General");
294 cfg.writeEntry("devices",devs,','); 278 cfg.writeEntry("devices",devs,',');
295 279
296} 280}
297 281
298// void ModemWidget::speed_selection(int) { 282// void ModemWidget::speed_selection(int) {
299// _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); 283// _pppdata->setSpeed(baud_c->text(baud_c->currentItem()));
300// } 284// }
301 285
302 286
303// void ModemWidget::setenter(int ) { 287// void ModemWidget::setenter(int ) {
304// _pppdata->setEnter(enter->text(enter->currentItem())); 288// _pppdata->setEnter(enter->text(enter->currentItem()));
305// } 289// }
306 290
307 291
308// void ModemWidget::setmodemdc(int i) { 292// void ModemWidget::setmodemdc(int i) {
309// _pppdata->setModemDevice(modemdevice->text(i)); 293// _pppdata->setModemDevice(modemdevice->text(i));
310// } 294// }
311 295
312// void ModemWidget::setmodemdc( const QString &string ) { 296// void ModemWidget::setmodemdc( const QString &string ) {
313// _pppdata->setModemDevice( string ); 297// _pppdata->setModemDevice( string );
314// } 298// }
315 299
316// void ModemWidget::setflowcontrol(int i) { 300// void ModemWidget::setflowcontrol(int i) {
317// _pppdata->setFlowcontrol(flowcontrol->text(i)); 301// _pppdata->setFlowcontrol(flowcontrol->text(i));
318// } 302// }
319 303
320 304
321// void ModemWidget::modemlockfilechanged(bool set) { 305// void ModemWidget::modemlockfilechanged(bool set) {
322// _pppdata->setModemLockFile(set); 306// _pppdata->setModemLockFile(set);
323// } 307// }
324 308
325 309
326// void ModemWidget::modemtimeoutchanged(int n) { 310// void ModemWidget::modemtimeoutchanged(int n) {
327// _pppdata->setModemTimeout(n); 311// _pppdata->setModemTimeout(n);
328// } 312// }
329 313
330 314
331 315
332bool ModemWidget::save() 316bool ModemWidget::save()
333{ 317{
334 //first check to make sure that the device name is unique! 318 //first check to make sure that the device name is unique!
335 if(modemname->text().isEmpty() || 319 if(modemname->text().isEmpty() ||
336 !_pppdata->isUniqueDevname(modemname->text())) 320 !_pppdata->isUniqueDevname(modemname->text()))
337 return false; 321 return false;
338 322
339 _pppdata->setDevname( modemname->text() ); 323 _pppdata->setDevname( modemname->text() );
340 _pppdata->setModemDevice( modemdevice->currentText() ); 324 _pppdata->setModemDevice( modemdevice->currentText() );
341 _pppdata->setFlowcontrol(flowcontrol->currentText()); 325 _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem()));
342 _pppdata->setFlowcontrol(flowcontrol->currentText()); 326 _pppdata->setEnter( static_cast<PPPData::LineTermination>(enter->currentItem()));
343 _pppdata->setSpeed(baud_c->currentText()); 327 _pppdata->setSpeed(baud_c->currentText());
344 _pppdata->setModemLockFile( modemlockfile->isChecked()); 328 _pppdata->setModemLockFile( modemlockfile->isChecked());
345 _pppdata->setModemTimeout( modemtimeout->value() ); 329 _pppdata->setModemTimeout( modemtimeout->value() );
346 return true; 330 return true;
347 331
348} 332}
349 333
350void ModemWidget::slotBeforeModemQuery() 334void ModemWidget::slotBeforeModemQuery()
351{ 335{
352 m_oldModemDev = _pppdata->modemDevice(); 336 m_oldModemDev = _pppdata->modemDevice();
353 m_oldFlowControl = _pppdata->flowcontrol(); 337 m_oldFlowControl = static_cast<int>( _pppdata->flowcontrol() );
354 m_oldSpeed = _pppdata->speed(); 338 m_oldSpeed = _pppdata->speed();
355 m_oldModemLock = _pppdata->modemLockFile(); 339 m_oldModemLock = _pppdata->modemLockFile();
356 m_oldModemTimeout = _pppdata->modemTimeout(); 340 m_oldModemTimeout = _pppdata->modemTimeout();
341 m_oldLineEnd = static_cast<int>( _pppdata->enter() );
357 342
358 343
359 _pppdata->setModemDevice( modemdevice->currentText() ); 344 _pppdata->setModemDevice( modemdevice->currentText() );
360 _pppdata->setFlowcontrol(flowcontrol->currentText()); 345 _pppdata->setFlowcontrol(static_cast<PPPData::FlowControl>(flowcontrol->currentItem()));
361 _pppdata->setFlowcontrol(flowcontrol->currentText()); 346 _pppdata->setEnter(static_cast<PPPData::LineTermination>(enter->currentItem()));
362 _pppdata->setSpeed(baud_c->currentText()); 347 _pppdata->setSpeed(baud_c->currentText());
363 _pppdata->setModemLockFile( modemlockfile->isChecked()); 348 _pppdata->setModemLockFile( modemlockfile->isChecked());
364 _pppdata->setModemTimeout( modemtimeout->value() ); 349 _pppdata->setModemTimeout( modemtimeout->value() );
365} 350}
366 351
367 352
368void ModemWidget::slotAfterModemQuery() 353void ModemWidget::slotAfterModemQuery()
369{ 354{
370 _pppdata->setModemDevice( m_oldModemDev ); 355 _pppdata->setModemDevice( m_oldModemDev );
371 _pppdata->setFlowcontrol( m_oldFlowControl ); 356 _pppdata->setFlowcontrol( static_cast<PPPData::FlowControl>(m_oldFlowControl) );
357 _pppdata->setEnter( static_cast<PPPData::LineTermination>(m_oldLineEnd) );
372 _pppdata->setSpeed( m_oldSpeed ); 358 _pppdata->setSpeed( m_oldSpeed );
373 _pppdata->setModemLockFile( m_oldModemLock ); 359 _pppdata->setModemLockFile( m_oldModemLock );
374 _pppdata->setModemTimeout( m_oldModemTimeout ); 360 _pppdata->setModemTimeout( m_oldModemTimeout );
375} 361}
376 362
377 363
378ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, 364ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent,
379 const char *name) 365 const char *name)
380 : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) 366 : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip)
381{ 367{
382 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); 368 QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
383 369
384 370
385 waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); 371 waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this);
386 waitfordt->setChecked(_pppdata->waitForDialTone()); 372 waitfordt->setChecked(_pppdata->waitForDialTone());
387 // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); 373 // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool)));
388 l1->addWidget(waitfordt); 374 l1->addWidget(waitfordt);
389 QWhatsThis::add(waitfordt, 375 QWhatsThis::add(waitfordt,
390 tr("<p>Normally the modem waits for a dial tone\n" 376 tr("<p>Normally the modem waits for a dial tone\n"
391 "from your phone line, indicating that it can\n" 377 "from your phone line, indicating that it can\n"
392 "start to dial a number. If your modem does not\n" 378 "start to dial a number. If your modem does not\n"
393 "recognize this sound, or your local phone system\n" 379 "recognize this sound, or your local phone system\n"
394 "does not emit such a tone, uncheck this option\n" 380 "does not emit such a tone, uncheck this option\n"
395 "\n" 381 "\n"
396 "<b>Default:</b>: On")); 382 "<b>Default:</b>: On"));
397 383
398 QHBoxLayout *waitLayout = new QHBoxLayout( this ); 384 QHBoxLayout *waitLayout = new QHBoxLayout( this );
399 QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); 385 QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" );
400 busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); 386 busywait = new QSpinBox( 0, 300, 5, this, "busyWait" );
401 // busywait = new KIntNumInput(_pppdata->busyWait(), this); 387 // busywait = new KIntNumInput(_pppdata->busyWait(), this);
402 // busywait->setLabel(tr("B&usy wait:")); 388 // busywait->setLabel(tr("B&usy wait:"));
403 // busywait->setRange(0, 300, 5, true); 389 // busywait->setRange(0, 300, 5, true);
404 busywait->setSuffix(tr(" sec")); 390 busywait->setSuffix(tr(" sec"));
405 // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); 391 // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int)));
406 waitLayout->addWidget(waitLabel); 392 waitLayout->addWidget(waitLabel);
407 waitLayout->addWidget(busywait); 393 waitLayout->addWidget(busywait);
408 l1->addLayout( waitLayout ); 394 l1->addLayout( waitLayout );
409 395
410 QWhatsThis::add(busywait, 396 QWhatsThis::add(busywait,
411 tr("Specifies the number of seconds to wait before\n" 397 tr("Specifies the number of seconds to wait before\n"
412 "redial if all dialed numbers are busy. This is\n" 398 "redial if all dialed numbers are busy. This is\n"
413 "necessary because some modems get stuck if the\n" 399 "necessary because some modems get stuck if the\n"
414 "same number is busy too often.\n" 400 "same number is busy too often.\n"
415 "\n" 401 "\n"
416 "The default is 0 seconds, you should not change\n" 402 "The default is 0 seconds, you should not change\n"
417 "this unless you need to.")); 403 "this unless you need to."));
418 404
419 l1->addSpacing(10); 405 l1->addSpacing(10);
420 406
421 QHBoxLayout *hbl = new QHBoxLayout; 407 QHBoxLayout *hbl = new QHBoxLayout;
422 hbl->setSpacing(2);//KDialog::spacingHint()); 408 hbl->setSpacing(2);//KDialog::spacingHint());
423 409
424 QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); 410 QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this);
425 hbl->addWidget(volumeLabel); 411 hbl->addWidget(volumeLabel);
426 volume = new QSlider(0, 2, 1, _pppdata->volume(), 412 volume = new QSlider(0, 2, 1, _pppdata->volume(),
427 QSlider::Horizontal, this); 413 QSlider::Horizontal, this);
428 volumeLabel->setBuddy(volume); 414 volumeLabel->setBuddy(volume);
429 volume->setTickmarks(QSlider::Below); 415 volume->setTickmarks(QSlider::Below);
430 hbl->addWidget(volume); 416 hbl->addWidget(volume);
431 417
432 l1->addLayout(hbl); 418 l1->addLayout(hbl);
433 419
434 // connect(volume, SIGNAL(valueChanged(int)), 420 // connect(volume, SIGNAL(valueChanged(int)),
435 // this, SLOT(volumeChanged(int))); 421 // this, SLOT(volumeChanged(int)));
436 QString tmp = tr("Most modems have a speaker which makes\n" 422 QString tmp = tr("Most modems have a speaker which makes\n"
437 "a lot of noise when dialing. Here you can\n" 423 "a lot of noise when dialing. Here you can\n"
438 "either turn this completely off or select a\n" 424 "either turn this completely off or select a\n"
439 "lower volume.\n" 425 "lower volume.\n"
440 "\n" 426 "\n"
441 "If this does not work for your modem,\n" 427 "If this does not work for your modem,\n"
442 "you must modify the modem volume command."); 428 "you must modify the modem volume command.");
443 429
444 QWhatsThis::add(volumeLabel,tmp); 430 QWhatsThis::add(volumeLabel,tmp);
445 QWhatsThis::add(volume, tmp); 431 QWhatsThis::add(volume, tmp);
446 432
447 l1->addSpacing(20); 433 l1->addSpacing(20);
448 434
449#if 0 435#if 0
450 chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); 436 chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this);
451 chkbox1->setChecked(_pppdata->UseCDLine()); 437 chkbox1->setChecked(_pppdata->UseCDLine());
452 connect(chkbox1,SIGNAL(toggled(bool)), 438 connect(chkbox1,SIGNAL(toggled(bool)),
453 this,SLOT(use_cdline_toggled(bool))); 439 this,SLOT(use_cdline_toggled(bool)));
454 l12->addWidget(chkbox1); 440 l12->addWidget(chkbox1);
455 l12->addStretch(1); 441 l12->addStretch(1);
456 l1->addStretch(1); 442 l1->addStretch(1);
457 QWhatsThis::add(chkbox1, 443 QWhatsThis::add(chkbox1,
458 tr("This controls how <i>kppp</i> detects that the modem\n" 444 tr("This controls how <i>kppp</i> detects that the modem\n"
459 "is not responding. Unless you are having\n" 445 "is not responding. Unless you are having\n"
460 "problems with this, do not modify this setting.\n" 446 "problems with this, do not modify this setting.\n"
461 "\n" 447 "\n"
462 "<b>Default</b>: Off")); 448 "<b>Default</b>: Off"));
463#endif 449#endif
464 450
465 modemcmds = new QPushButton(tr("Mod&em Commands..."), this); 451 modemcmds = new QPushButton(tr("Mod&em Commands..."), this);
466 QWhatsThis::add(modemcmds, 452 QWhatsThis::add(modemcmds,
467 tr("Allows you to change the AT command for\n" 453 tr("Allows you to change the AT command for\n"
468 "your modem.")); 454 "your modem."));
469 455
470 modeminfo_button = new QPushButton(tr("&Query Modem..."), this); 456 modeminfo_button = new QPushButton(tr("&Query Modem..."), this);
471 QWhatsThis::add(modeminfo_button, 457 QWhatsThis::add(modeminfo_button,
472 tr("Most modems support the ATI command set to\n" 458 tr("Most modems support the ATI command set to\n"
473 "find out vendor and revision of your modem.\n" 459 "find out vendor and revision of your modem.\n"
474 "\n" 460 "\n"
475 "Press this button to query your modem for\n" 461 "Press this button to query your modem for\n"
476 "this information. It can be useful to help\n" 462 "this information. It can be useful to help\n"
477 "you setup the modem")); 463 "you setup the modem"));
478 464
479 // terminal_button = new QPushButton(tr("&Terminal..."), this); 465 // terminal_button = new QPushButton(tr("&Terminal..."), this);
480 // QWhatsThis::add(terminal_button, 466 // QWhatsThis::add(terminal_button,
481 // tr("Opens the built-in terminal program. You\n" 467 // tr("Opens the built-in terminal program. You\n"
482 // "can use this if you want to play around\n" 468 // "can use this if you want to play around\n"
483 // "with your modem's AT command set")); 469 // "with your modem's AT command set"));
484 470
485 QHBoxLayout *hbox = new QHBoxLayout(); 471 QHBoxLayout *hbox = new QHBoxLayout();
486 l1->addLayout(hbox); 472 l1->addLayout(hbox);
487 hbox->addStretch(1); 473 hbox->addStretch(1);
488 QVBoxLayout *vbox = new QVBoxLayout(); 474 QVBoxLayout *vbox = new QVBoxLayout();
489 hbox->addLayout(vbox); 475 hbox->addLayout(vbox);
490 476
491 vbox->addWidget(modemcmds); 477 vbox->addWidget(modemcmds);
492 vbox->addWidget(modeminfo_button); 478 vbox->addWidget(modeminfo_button);
493 // vbox->addWidget(terminal_button); 479 // vbox->addWidget(terminal_button);
494 480
495 hbox->addStretch(1); 481 hbox->addStretch(1);
496 l1->addStretch(1); 482 l1->addStretch(1);
497 483
498 connect(modemcmds, SIGNAL(clicked()), 484 connect(modemcmds, SIGNAL(clicked()),
499 SLOT(modemcmdsbutton())); 485 SLOT(modemcmdsbutton()));
500 connect(modeminfo_button, SIGNAL(clicked()), 486 connect(modeminfo_button, SIGNAL(clicked()),
501 SLOT(query_modem())); 487 SLOT(query_modem()));
502 // connect(terminal_button, SIGNAL(clicked()), 488 // connect(terminal_button, SIGNAL(clicked()),
503 // SLOT(terminal())); 489 // SLOT(terminal()));
504} 490}
505 491
506 492
507void ModemWidget2::modemcmdsbutton() 493void ModemWidget2::modemcmdsbutton()
508{ 494{
509 ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp); 495 ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp);
510 496
511 QPEApplication::execDialog( &mc ); 497 QPEApplication::execDialog( &mc );
512} 498}
513 499
514 500
515void ModemWidget2::query_modem() 501void ModemWidget2::query_modem()
516{ 502{
517 emit sig_beforeQueryModem(); 503 emit sig_beforeQueryModem();
518 504
519 ModemTransfer mt(_ifaceppp->modem(), this); 505 ModemTransfer mt(_ifaceppp->modem(), this);
520 mt.exec(); 506 mt.exec();
521 507
522 emit sig_afterQueryModem(); 508 emit sig_afterQueryModem();
523} 509}
524 510
525 511
526// void ModemWidget2::terminal() { 512// void ModemWidget2::terminal() {
527// MiniTerm terminal(NULL,NULL); 513// MiniTerm terminal(NULL,NULL);
528// terminal.exec(); 514// terminal.exec();
529// } 515// }
530 516
531 517
532// #if 0 518// #if 0
533// void ModemWidget2::use_cdline_toggled(bool on) { 519// void ModemWidget2::use_cdline_toggled(bool on) {
534// _pppdata->setUseCDLine(on); 520// _pppdata->setUseCDLine(on);
535// } 521// }
536// #endif 522// #endif
537 523
538// void ModemWidget2::waitfordtchanged(bool b) { 524// void ModemWidget2::waitfordtchanged(bool b) {
539// _pppdata->setWaitForDialTone((int)b); 525// _pppdata->setWaitForDialTone((int)b);
540// } 526// }
541 527
542// void ModemWidget2::busywaitchanged(int n) { 528// void ModemWidget2::busywaitchanged(int n) {
543// _pppdata->setbusyWait(n); 529// _pppdata->setbusyWait(n);
544// } 530// }
545 531
546 532
547// void ModemWidget2::volumeChanged(int v) { 533// void ModemWidget2::volumeChanged(int v) {
548// _pppdata->setVolume(v); 534// _pppdata->setVolume(v);
549// } 535// }
550 536
551bool ModemWidget2::save() 537bool ModemWidget2::save()
552{ 538{
553 _pppdata->setWaitForDialTone(waitfordt->isChecked()); 539 _pppdata->setWaitForDialTone(waitfordt->isChecked());
554 _pppdata->setbusyWait(busywait->value()); 540 _pppdata->setbusyWait(busywait->value());
555 _pppdata->setVolume(volume->value()); 541 _pppdata->setVolume(volume->value());
556 return true; 542 return true;
557} 543}
558 544
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h
index a4dece4..0bb3136 100644
--- a/noncore/settings/networksettings/ppp/general.h
+++ b/noncore/settings/networksettings/ppp/general.h
@@ -1,125 +1,125 @@
1/* 1/*
2 * 2 *
3 * kPPP: A pppd front end for the KDE project 3 * kPPP: A pppd front end for the KDE project
4 * 4 *
5 * $Id$ 5 * $Id$
6 * 6 *
7 * Copyright (C) 1997 Bernd Johannes Wuebben 7 * Copyright (C) 1997 Bernd Johannes Wuebben
8 * wuebben@math.cornell.edu 8 * wuebben@math.cornell.edu
9 * 9 *
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 19 * Library General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU Library General Public 21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free 22 * License along with this program; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26#ifndef _GENERAL_H_ 26#ifndef _GENERAL_H_
27#define _GENERAL_H_ 27#define _GENERAL_H_
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30 30
31class QSlider; 31class QSlider;
32class QSpinBox; 32class QSpinBox;
33class QCombobox; 33class QCombobox;
34class QLabel; 34class QLabel;
35class QCheckBox; 35class QCheckBox;
36class QComboBox; 36class QComboBox;
37class PPPData; 37class PPPData;
38class InterfacePPP; 38class InterfacePPP;
39class QLineEdit; 39class QLineEdit;
40 40
41class ModemWidget : public QWidget { 41class ModemWidget : public QWidget {
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 ); 44 ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 );
45 ~ModemWidget(); 45 ~ModemWidget();
46 46
47 bool save(); 47 bool save();
48 48
49private slots: 49private slots:
50 /* 50 /*
51 * temporarily commit configuration so queryModem 51 * temporarily commit configuration so queryModem
52 * will use 'current' settings 52 * will use 'current' settings
53 */ 53 */
54 void slotBeforeModemQuery(); 54 void slotBeforeModemQuery();
55 void slotAfterModemQuery(); 55 void slotAfterModemQuery();
56 56
57/* private slots: */ 57/* private slots: */
58 /* void setmodemdc(int); */ 58 /* void setmodemdc(int); */
59/* void setmodemdc(const QString &); */ 59/* void setmodemdc(const QString &); */
60 /* void setflowcontrol(int); */ 60 /* void setflowcontrol(int); */
61 /* void modemtimeoutchanged(int); */ 61 /* void modemtimeoutchanged(int); */
62 /* void modemlockfilechanged(bool); */ 62 /* void modemlockfilechanged(bool); */
63 /* void setenter(int); */ 63 /* void setenter(int); */
64/* void speed_selection(int); */ 64/* void speed_selection(int); */
65 65
66private: 66private:
67 QComboBox *enter; 67 QComboBox *enter;
68 /* QLabel *label1; */ 68 /* QLabel *label1; */
69 /* QLabel *label2; */ 69 /* QLabel *label2; */
70 /* QLabel *labeltmp; */ 70 /* QLabel *labeltmp; */
71 /* QLabel *labelenter; */ 71 /* QLabel *labelenter; */
72 QLineEdit *modemname; 72 QLineEdit *modemname;
73 QComboBox *modemdevice; 73 QComboBox *modemdevice;
74 QComboBox *flowcontrol; 74 QComboBox *flowcontrol;
75 75
76 QComboBox *baud_c; 76 QComboBox *baud_c;
77 QLabel *baud_label; 77 QLabel *baud_label;
78 78
79 QSpinBox *modemtimeout; 79 QSpinBox *modemtimeout;
80 QCheckBox *modemlockfile; 80 QCheckBox *modemlockfile;
81 PPPData *_pppdata; 81 PPPData *_pppdata;
82 82
83private: 83private:
84 QString m_oldModemDev, m_oldFlowControl, m_oldSpeed; 84 QString m_oldModemDev, m_oldSpeed;
85 bool m_oldModemLock; 85 bool m_oldModemLock;
86 int m_oldModemTimeout; 86 int m_oldModemTimeout, m_oldFlowControl, m_oldLineEnd;
87}; 87};
88 88
89 89
90class ModemWidget2 : public QWidget { 90class ModemWidget2 : public QWidget {
91 Q_OBJECT 91 Q_OBJECT
92public: 92public:
93 ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 ); 93 ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 );
94 bool save(); 94 bool save();
95 95
96signals: 96signals:
97 void sig_beforeQueryModem(); 97 void sig_beforeQueryModem();
98 void sig_afterQueryModem(); 98 void sig_afterQueryModem();
99 99
100private slots: 100private slots:
101/* void waitfordtchanged(bool); */ 101/* void waitfordtchanged(bool); */
102 /* void busywaitchanged(int); */ 102 /* void busywaitchanged(int); */
103 // void use_cdline_toggled(bool); 103 // void use_cdline_toggled(bool);
104 void modemcmdsbutton(); 104 void modemcmdsbutton();
105 // void terminal(); 105 // void terminal();
106 void query_modem(); 106 void query_modem();
107 // void volumeChanged(int); 107 // void volumeChanged(int);
108 108
109private: 109private:
110 QLabel *labeltmp; 110 QLabel *labeltmp;
111 QPushButton *modemcmds; 111 QPushButton *modemcmds;
112 QPushButton *modeminfo_button; 112 QPushButton *modeminfo_button;
113 // QPushButton *terminal_button; 113 // QPushButton *terminal_button;
114 // QFrame *fline; 114 // QFrame *fline;
115 QCheckBox *waitfordt; 115 QCheckBox *waitfordt;
116 QSpinBox *busywait; 116 QSpinBox *busywait;
117 QCheckBox *chkbox1; 117 QCheckBox *chkbox1;
118 QSlider *volume; 118 QSlider *volume;
119 PPPData *_pppdata; 119 PPPData *_pppdata;
120 InterfacePPP *_ifaceppp; 120 InterfacePPP *_ifaceppp;
121}; 121};
122 122
123#endif 123#endif
124 124
125 125
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index 79f015b..7b2e2a3 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -1,1084 +1,1088 @@
1/* 1/*
2 * kPPP: A pppd Front End for the KDE project 2 * kPPP: A pppd Front End for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * This file was added by Harri Porten <porten@tu-harburg.de> 9 * This file was added by Harri Porten <porten@tu-harburg.de>
10 * 10 *
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27/* OPIE */ 27/* OPIE */
28#include <opie2/odebug.h> 28#include <opie2/odebug.h>
29using namespace Opie::Core; 29using namespace Opie::Core;
30 30
31/* STD */ 31/* STD */
32#include <errno.h> 32#include <errno.h>
33#include <stdlib.h> 33#include <stdlib.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <fcntl.h> 35#include <fcntl.h>
36#include <signal.h> 36#include <signal.h>
37#include <sys/ioctl.h> 37#include <sys/ioctl.h>
38#include <sys/types.h> 38#include <sys/types.h>
39#include <sys/stat.h> 39#include <sys/stat.h>
40#include <setjmp.h> 40#include <setjmp.h>
41#include <regex.h> 41#include <regex.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <assert.h> 43#include <assert.h>
44#include <string.h> 44#include <string.h>
45 45
46#ifdef HAVE_RESOLV_H 46#ifdef HAVE_RESOLV_H
47# include <arpa/nameser.h> 47# include <arpa/nameser.h>
48# include <resolv.h> 48# include <resolv.h>
49#endif 49#endif
50 50
51#ifndef _PATH_RESCONF 51#ifndef _PATH_RESCONF
52#define _PATH_RESCONF "/etc/resolv.conf" 52#define _PATH_RESCONF "/etc/resolv.conf"
53#endif 53#endif
54 54
55#define strlcpy strcpy 55#define strlcpy strcpy
56#include "auth.h" 56#include "auth.h"
57#include "modem.h" 57#include "modem.h"
58#include "pppdata.h" 58#include "pppdata.h"
59 59
60 60
61#define MY_ASSERT(x) if (!(x)) { \ 61#define MY_ASSERT(x) if (!(x)) { \
62 ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \ 62 ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \
63 exit(1); } 63 exit(1); }
64 64
65 65
66static sigjmp_buf jmp_buffer; 66static sigjmp_buf jmp_buffer;
67 67
68//Modem *Modem::modem = 0; 68//Modem *Modem::modem = 0;
69 69
70 70
71const char* pppdPath() { 71const char* pppdPath() {
72 // wasting a few bytes 72 // wasting a few bytes
73 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; 73 static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)];
74 static char *pppdPath = 0L; 74 static char *pppdPath = 0L;
75 char *p; 75 char *p;
76 76
77 if(pppdPath == 0L) { 77 if(pppdPath == 0L) {
78 const char *c = PPPDSEARCHPATH; 78 const char *c = PPPDSEARCHPATH;
79 while(*c != '\0') { 79 while(*c != '\0') {
80 while(*c == ':') 80 while(*c == ':')
81 c++; 81 c++;
82 p = buffer; 82 p = buffer;
83 while(*c != '\0' && *c != ':') 83 while(*c != '\0' && *c != ':')
84 *p++ = *c++; 84 *p++ = *c++;
85 *p = '\0'; 85 *p = '\0';
86 strcat(p, "/"); 86 strcat(p, "/");
87 strcat(p, PPPDNAME); 87 strcat(p, PPPDNAME);
88 if(access(buffer, F_OK) == 0) 88 if(access(buffer, F_OK) == 0)
89 return (pppdPath = buffer); 89 return (pppdPath = buffer);
90 } 90 }
91 } 91 }
92 92
93 return pppdPath; 93 return pppdPath;
94} 94}
95 95
96 96
97Modem::Modem( PPPData* pd ) 97Modem::Modem( PPPData* pd )
98{ 98{
99 _pppdata = pd; 99 _pppdata = pd;
100 modemfd = -1; 100 modemfd = -1;
101 _pppdExitStatus = -1; 101 _pppdExitStatus = -1;
102 pppdPid = -1; 102 pppdPid = -1;
103 sn = m_modemDebug = 0L; 103 sn = m_modemDebug = 0L;
104 data_mode = false; 104 data_mode = false;
105 modem_is_locked = false; 105 modem_is_locked = false;
106 lockfile[0] = '\0'; 106 lockfile[0] = '\0';
107 device = "/dev/modem"; 107 device = "/dev/modem";
108} 108}
109 109
110 110
111Modem::~Modem() 111Modem::~Modem()
112{ 112{
113} 113}
114 114
115 115
116speed_t Modem::modemspeed() { 116speed_t Modem::modemspeed() {
117 // convert the string modem speed int the gpppdata object to a t_speed type 117 // convert the string modem speed int the gpppdata object to a t_speed type
118 // to set the modem. The constants here should all be ifdef'd because 118 // to set the modem. The constants here should all be ifdef'd because
119 // other systems may not have them 119 // other systems may not have them
120 int i = _pppdata->speed().toInt()/100; 120 int i = _pppdata->speed().toInt()/100;
121 121
122 switch(i) { 122 switch(i) {
123 case 24: 123 case 24:
124 return B2400; 124 return B2400;
125 break; 125 break;
126 case 96: 126 case 96:
127 return B9600; 127 return B9600;
128 break; 128 break;
129 case 192: 129 case 192:
130 return B19200; 130 return B19200;
131 break; 131 break;
132 case 384: 132 case 384:
133 return B38400; 133 return B38400;
134 break; 134 break;
135#ifdef B57600 135#ifdef B57600
136 case 576: 136 case 576:
137 return B57600; 137 return B57600;
138 break; 138 break;
139#endif 139#endif
140 140
141#ifdef B115200 141#ifdef B115200
142 case 1152: 142 case 1152:
143 return B115200; 143 return B115200;
144 break; 144 break;
145#endif 145#endif
146 146
147#ifdef B230400 147#ifdef B230400
148 case 2304: 148 case 2304:
149 return B230400; 149 return B230400;
150 break; 150 break;
151#endif 151#endif
152 152
153#ifdef B460800 153#ifdef B460800
154 case 4608: 154 case 4608:
155 return B460800; 155 return B460800;
156 break; 156 break;
157#endif 157#endif
158 158
159 default: 159 default:
160 return B38400; 160 return B38400;
161 break; 161 break;
162 } 162 }
163} 163}
164 164
165bool Modem::opentty() { 165bool Modem::opentty() {
166 // int flags; 166 // int flags;
167 167
168//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { 168//begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
169 close(modemfd); 169 close(modemfd);
170 device = _pppdata->modemDevice(); 170 device = _pppdata->modemDevice();
171 if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { 171 if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) {
172 odebug << "error opening modem device !" << oendl; 172 odebug << "error opening modem device !" << oendl;
173 errmsg = QObject::tr("Unable to open modem."); 173 errmsg = QObject::tr("Unable to open modem.");
174 return false; 174 return false;
175 } 175 }
176//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { 176//bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) {
177//} 177//}
178 178
179#if 0 179#if 0
180 if(_pppdata->UseCDLine()) { 180 if(_pppdata->UseCDLine()) {
181 if(ioctl(modemfd, TIOCMGET, &flags) == -1) { 181 if(ioctl(modemfd, TIOCMGET, &flags) == -1) {
182 errmsg = QObject::tr("Unable to detect state of CD line."); 182 errmsg = QObject::tr("Unable to detect state of CD line.");
183 ::close(modemfd); 183 ::close(modemfd);
184 modemfd = -1; 184 modemfd = -1;
185 return false; 185 return false;
186 } 186 }
187 if ((flags&TIOCM_CD) == 0) { 187 if ((flags&TIOCM_CD) == 0) {
188 errmsg = QObject::tr("The modem is not ready."); 188 errmsg = QObject::tr("The modem is not ready.");
189 ::close(modemfd); 189 ::close(modemfd);
190 modemfd = -1; 190 modemfd = -1;
191 return false; 191 return false;
192 } 192 }
193 } 193 }
194#endif 194#endif
195 195
196 tcdrain (modemfd); 196 tcdrain (modemfd);
197 tcflush (modemfd, TCIOFLUSH); 197 tcflush (modemfd, TCIOFLUSH);
198 198
199 if(tcgetattr(modemfd, &tty) < 0){ 199 if(tcgetattr(modemfd, &tty) < 0){
200 // this helps in some cases 200 // this helps in some cases
201 tcsendbreak(modemfd, 0); 201 tcsendbreak(modemfd, 0);
202 sleep(1); 202 sleep(1);
203 if(tcgetattr(modemfd, &tty) < 0){ 203 if(tcgetattr(modemfd, &tty) < 0){
204 errmsg = QObject::tr("The modem is busy."); 204 errmsg = QObject::tr("The modem is busy.");
205 ::close(modemfd); 205 ::close(modemfd);
206 modemfd = -1; 206 modemfd = -1;
207 return false; 207 return false;
208 } 208 }
209 } 209 }
210 210
211 memset(&initial_tty,'\0',sizeof(initial_tty)); 211 memset(&initial_tty,'\0',sizeof(initial_tty));
212 212
213 initial_tty = tty; 213 initial_tty = tty;
214 214
215 tty.c_cc[VMIN] = 0; // nonblocking 215 tty.c_cc[VMIN] = 0; // nonblocking
216 tty.c_cc[VTIME] = 0; 216 tty.c_cc[VTIME] = 0;
217 tty.c_oflag = 0; 217 tty.c_oflag = 0;
218 tty.c_lflag = 0; 218 tty.c_lflag = 0;
219 219
220 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); 220 tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB);
221 tty.c_cflag |= CS8 | CREAD; 221 tty.c_cflag |= CS8 | CREAD;
222 tty.c_cflag |= CLOCAL; // ignore modem status lines 222 tty.c_cflag |= CLOCAL; // ignore modem status lines
223 tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; 223 tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ;
224 tty.c_lflag &= ~ICANON; // non-canonical mode 224 tty.c_lflag &= ~ICANON; // non-canonical mode
225 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); 225 tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE);
226 226
227 227
228 if(_pppdata->flowcontrol() != "None") { 228 if(_pppdata->flowcontrol() != PPPData::FlowNone) {
229 if(_pppdata->flowcontrol() == "CRTSCTS") { 229 if(_pppdata->flowcontrol() == PPPData::FlowHardware) {
230 tty.c_cflag |= CRTSCTS; 230 tty.c_cflag |= CRTSCTS;
231 } 231 }
232 else { 232 else {
233 tty.c_iflag |= IXON | IXOFF; 233 tty.c_iflag |= IXON | IXOFF;
234 tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ 234 tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */
235 tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ 235 tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */
236 } 236 }
237 } 237 }
238 else { 238 else {
239 tty.c_cflag &= ~CRTSCTS; 239 tty.c_cflag &= ~CRTSCTS;
240 tty.c_iflag &= ~(IXON | IXOFF); 240 tty.c_iflag &= ~(IXON | IXOFF);
241 } 241 }
242 242
243 cfsetospeed(&tty, modemspeed()); 243 cfsetospeed(&tty, modemspeed());
244 cfsetispeed(&tty, modemspeed()); 244 cfsetispeed(&tty, modemspeed());
245 245
246 tcdrain(modemfd); 246 tcdrain(modemfd);
247 247
248 if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ 248 if(tcsetattr(modemfd, TCSANOW, &tty) < 0){
249 errmsg = QObject::tr("The modem is busy."); 249 errmsg = QObject::tr("The modem is busy.");
250 ::close(modemfd); 250 ::close(modemfd);
251 modemfd=-1; 251 modemfd=-1;
252 return false; 252 return false;
253 } 253 }
254 254
255 errmsg = QObject::tr("Modem Ready."); 255 errmsg = QObject::tr("Modem Ready.");
256 return true; 256 return true;
257} 257}
258 258
259 259
260bool Modem::closetty() { 260bool Modem::closetty() {
261 if(modemfd >=0 ) { 261 if(modemfd >=0 ) {
262 stop(); 262 stop();
263 /* discard data not read or transmitted */ 263 /* discard data not read or transmitted */
264 tcflush(modemfd, TCIOFLUSH); 264 tcflush(modemfd, TCIOFLUSH);
265 265
266 if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ 266 if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){
267 errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n"); 267 errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n");
268 ::close(modemfd); 268 ::close(modemfd);
269 modemfd = -1; 269 modemfd = -1;
270 return false; 270 return false;
271 } 271 }
272 ::close(modemfd); 272 ::close(modemfd);
273 modemfd = -1; 273 modemfd = -1;
274 } 274 }
275 275
276 return true; 276 return true;
277} 277}
278 278
279 279
280void Modem::readtty(int) { 280void Modem::readtty(int) {
281 char buffer[200]; 281 char buffer[200];
282 unsigned char c; 282 unsigned char c;
283 int len; 283 int len;
284 284
285 // read data in chunks of up to 200 bytes 285 // read data in chunks of up to 200 bytes
286 if((len = ::read(modemfd, buffer, 200)) > 0) { 286 if((len = ::read(modemfd, buffer, 200)) > 0) {
287 // split buffer into single characters for further processing 287 // split buffer into single characters for further processing
288 for(int i = 0; i < len; i++) { 288 for(int i = 0; i < len; i++) {
289 c = buffer[i] & 0x7F; 289 c = buffer[i] & 0x7F;
290 emit charWaiting(c); 290 emit charWaiting(c);
291 } 291 }
292 } 292 }
293} 293}
294 294
295 295
296void Modem::notify(const QObject *receiver, const char *member) { 296void Modem::notify(const QObject *receiver, const char *member) {
297 connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); 297 connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member);
298 startNotifier(); 298 startNotifier();
299} 299}
300 300
301 301
302void Modem::stop() { 302void Modem::stop() {
303 disconnect(SIGNAL(charWaiting(unsigned char))); 303 disconnect(SIGNAL(charWaiting(unsigned char)));
304 stopNotifier(); 304 stopNotifier();
305} 305}
306 306
307 307
308void Modem::startNotifier() { 308void Modem::startNotifier() {
309 if(modemfd >= 0) { 309 if(modemfd >= 0) {
310 if(sn == 0) { 310 if(sn == 0) {
311 sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); 311 sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this);
312 connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); 312 connect(sn, SIGNAL(activated(int)), SLOT(readtty(int)));
313 odebug << "QSocketNotifier started!" << oendl; 313 odebug << "QSocketNotifier started!" << oendl;
314 } else { 314 } else {
315 odebug << "QSocketNotifier re-enabled!" << oendl; 315 odebug << "QSocketNotifier re-enabled!" << oendl;
316 sn->setEnabled(true); 316 sn->setEnabled(true);
317 } 317 }
318 } 318 }
319} 319}
320 320
321 321
322void Modem::stopNotifier() { 322void Modem::stopNotifier() {
323 if(sn != 0) { 323 if(sn != 0) {
324 sn->setEnabled(false); 324 sn->setEnabled(false);
325 disconnect(sn); 325 disconnect(sn);
326 delete sn; 326 delete sn;
327 sn = 0; 327 sn = 0;
328 odebug << "QSocketNotifier stopped!" << oendl; 328 odebug << "QSocketNotifier stopped!" << oendl;
329 } 329 }
330} 330}
331 331
332 332
333void Modem::flush() { 333void Modem::flush() {
334 char c; 334 char c;
335 while(read(modemfd, &c, 1) == 1); 335 while(read(modemfd, &c, 1) == 1);
336} 336}
337 337
338 338
339bool Modem::writeChar(unsigned char c) { 339bool Modem::writeChar(unsigned char c) {
340 int s; 340 int s;
341 do { 341 do {
342 s = write(modemfd, &c, 1); 342 s = write(modemfd, &c, 1);
343 if (s < 0) { 343 if (s < 0) {
344 oerr << "write() in Modem::writeChar failed" << oendl; 344 oerr << "write() in Modem::writeChar failed" << oendl;
345 return false; 345 return false;
346 } 346 }
347 } while(s == 0); 347 } while(s == 0);
348 348
349 return true; 349 return true;
350} 350}
351 351
352 352
353bool Modem::writeLine(const char *buf) { 353bool Modem::writeLine(const char *buf) {
354 int len = strlen(buf); 354 int len = strlen(buf);
355 char *b = new char[len+2]; 355 char *b = new char[len+2];
356 memcpy(b, buf, len); 356 memcpy(b, buf, len);
357 // different modems seem to need different line terminations 357 // different modems seem to need different line terminations
358 QString term = _pppdata->enter(); 358 switch( _pppdata->enter() ) {
359 if(term == "LF") 359 case PPPData::EndLF:
360 b[len++]='\n'; 360 b[len++]='\n';
361 else if(term == "CR") 361 break;
362 case PPPData::EndCR:
362 b[len++]='\r'; 363 b[len++]='\r';
363 else if(term == "CR/LF") { 364 break;
365 case PPPData::EndCRLF:
364 b[len++]='\r'; 366 b[len++]='\r';
365 b[len++]='\n'; 367 b[len++]='\n';
368 break;
366 } 369 }
370
367 int l = len; 371 int l = len;
368 while(l) { 372 while(l) {
369 int wr = write(modemfd, &b[len-l], l); 373 int wr = write(modemfd, &b[len-l], l);
370 if(wr < 0) { 374 if(wr < 0) {
371 // TODO do something meaningful with the error code (or ignore it 375 // TODO do something meaningful with the error code (or ignore it
372 oerr << "write() in Modem::writeLine failed" << oendl; 376 oerr << "write() in Modem::writeLine failed" << oendl;
373 delete[] b; 377 delete[] b;
374 return false; 378 return false;
375 } 379 }
376 l -= wr; 380 l -= wr;
377 } 381 }
378 delete[] b; 382 delete[] b;
379 return true; 383 return true;
380} 384}
381 385
382 386
383bool Modem::hangup() { 387bool Modem::hangup() {
384 // this should really get the modem to hang up and go into command mode 388 // this should really get the modem to hang up and go into command mode
385 // If anyone sees a fault in the following please let me know, since 389 // If anyone sees a fault in the following please let me know, since
386 // this is probably the most imporant snippet of code in the whole of 390 // this is probably the most imporant snippet of code in the whole of
387 // kppp. If people complain about kppp being stuck, this piece of code 391 // kppp. If people complain about kppp being stuck, this piece of code
388 // is most likely the reason. 392 // is most likely the reason.
389 struct termios temptty; 393 struct termios temptty;
390 394
391 if(modemfd >= 0) { 395 if(modemfd >= 0) {
392 396
393 // is this Escape & HangupStr stuff really necessary ? (Harri) 397 // is this Escape & HangupStr stuff really necessary ? (Harri)
394 398
395 if (data_mode) escape_to_command_mode(); 399 if (data_mode) escape_to_command_mode();
396 400
397 // Then hangup command 401 // Then hangup command
398 writeLine(_pppdata->modemHangupStr().local8Bit()); 402 writeLine(_pppdata->modemHangupStr().local8Bit());
399 403
400 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec 404 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec
401 405
402#ifndef DEBUG_WO_DIALING 406#ifndef DEBUG_WO_DIALING
403 if (sigsetjmp(jmp_buffer, 1) == 0) { 407 if (sigsetjmp(jmp_buffer, 1) == 0) {
404 // set alarm in case tcsendbreak() hangs 408 // set alarm in case tcsendbreak() hangs
405 signal(SIGALRM, alarm_handler); 409 signal(SIGALRM, alarm_handler);
406 alarm(2); 410 alarm(2);
407 411
408 tcsendbreak(modemfd, 0); 412 tcsendbreak(modemfd, 0);
409 413
410 alarm(0); 414 alarm(0);
411 signal(SIGALRM, SIG_IGN); 415 signal(SIGALRM, SIG_IGN);
412 } else { 416 } else {
413 // we reach this point if the alarm handler got called 417 // we reach this point if the alarm handler got called
414 closetty(); 418 closetty();
415 close(modemfd); 419 close(modemfd);
416 modemfd = -1; 420 modemfd = -1;
417 errmsg = QObject::tr("The modem does not respond."); 421 errmsg = QObject::tr("The modem does not respond.");
418 return false; 422 return false;
419 } 423 }
420 424
421#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. 425#ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init.
422 tcgetattr(modemfd, &temptty); 426 tcgetattr(modemfd, &temptty);
423 cfsetospeed(&temptty, B0); 427 cfsetospeed(&temptty, B0);
424 cfsetispeed(&temptty, B0); 428 cfsetispeed(&temptty, B0);
425 tcsetattr(modemfd, TCSAFLUSH, &temptty); 429 tcsetattr(modemfd, TCSAFLUSH, &temptty);
426#else 430#else
427 int modemstat; 431 int modemstat;
428 ioctl(modemfd, TIOCMGET, &modemstat); 432 ioctl(modemfd, TIOCMGET, &modemstat);
429 modemstat &= ~TIOCM_DTR; 433 modemstat &= ~TIOCM_DTR;
430 ioctl(modemfd, TIOCMSET, &modemstat); 434 ioctl(modemfd, TIOCMSET, &modemstat);
431 ioctl(modemfd, TIOCMGET, &modemstat); 435 ioctl(modemfd, TIOCMGET, &modemstat);
432 modemstat |= TIOCM_DTR; 436 modemstat |= TIOCM_DTR;
433 ioctl(modemfd, TIOCMSET, &modemstat); 437 ioctl(modemfd, TIOCMSET, &modemstat);
434#endif 438#endif
435 439
436 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs 440 usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs
437 441
438 cfsetospeed(&temptty, modemspeed()); 442 cfsetospeed(&temptty, modemspeed());
439 cfsetispeed(&temptty, modemspeed()); 443 cfsetispeed(&temptty, modemspeed());
440 tcsetattr(modemfd, TCSAFLUSH, &temptty); 444 tcsetattr(modemfd, TCSAFLUSH, &temptty);
441#endif 445#endif
442 return true; 446 return true;
443 } else 447 } else
444 return false; 448 return false;
445} 449}
446 450
447 451
448void Modem::escape_to_command_mode() { 452void Modem::escape_to_command_mode() {
449 // Send Properly bracketed escape code to put the modem back into command state. 453 // Send Properly bracketed escape code to put the modem back into command state.
450 // A modem will accept AT commands only when it is in command state. 454 // A modem will accept AT commands only when it is in command state.
451 // When a modem sends the host the CONNECT string, that signals 455 // When a modem sends the host the CONNECT string, that signals
452 // that the modem is now in the connect state (no long accepts AT commands.) 456 // that the modem is now in the connect state (no long accepts AT commands.)
453 // Need to send properly timed escape sequence to put modem in command state. 457 // Need to send properly timed escape sequence to put modem in command state.
454 // Escape codes and guard times are controlled by S2 and S12 values. 458 // Escape codes and guard times are controlled by S2 and S12 values.
455 // 459 //
456 tcflush(modemfd, TCIOFLUSH); 460 tcflush(modemfd, TCIOFLUSH);
457 461
458 // +3 because quiet time must be greater than guard time. 462 // +3 because quiet time must be greater than guard time.
459 usleep((_pppdata->modemEscapeGuardTime()+3)*20000); 463 usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
460 QCString tmp = _pppdata->modemEscapeStr().local8Bit(); 464 QCString tmp = _pppdata->modemEscapeStr().local8Bit();
461 write(modemfd, tmp.data(), tmp.length()); 465 write(modemfd, tmp.data(), tmp.length());
462 tcflush(modemfd, TCIOFLUSH); 466 tcflush(modemfd, TCIOFLUSH);
463 usleep((_pppdata->modemEscapeGuardTime()+3)*20000); 467 usleep((_pppdata->modemEscapeGuardTime()+3)*20000);
464 468
465 data_mode = false; 469 data_mode = false;
466} 470}
467 471
468 472
469const QString Modem::modemMessage() { 473const QString Modem::modemMessage() {
470 return errmsg; 474 return errmsg;
471} 475}
472 476
473 477
474QString Modem::parseModemSpeed(const QString &s) { 478QString Modem::parseModemSpeed(const QString &s) {
475 // this is a small (and bad) parser for modem speeds 479 // this is a small (and bad) parser for modem speeds
476 int rx = -1; 480 int rx = -1;
477 int tx = -1; 481 int tx = -1;
478 int i; 482 int i;
479 QString result; 483 QString result;
480 484
481 odebug << "Modem reported result string: " << s.latin1() << "" << oendl; 485 odebug << "Modem reported result string: " << s.latin1() << "" << oendl;
482 486
483 const int RXMAX = 7; 487 const int RXMAX = 7;
484 const int TXMAX = 2; 488 const int TXMAX = 2;
485 QRegExp rrx[RXMAX] = { 489 QRegExp rrx[RXMAX] = {
486 QRegExp("[0-9]+[:/ ]RX", false), 490 QRegExp("[0-9]+[:/ ]RX", false),
487 QRegExp("[0-9]+RX", false), 491 QRegExp("[0-9]+RX", false),
488 QRegExp("[/: -][0-9]+[/: ]", false), 492 QRegExp("[/: -][0-9]+[/: ]", false),
489 QRegExp("[/: -][0-9]+$", false), 493 QRegExp("[/: -][0-9]+$", false),
490 QRegExp("CARRIER [^0-9]*[0-9]+", false), 494 QRegExp("CARRIER [^0-9]*[0-9]+", false),
491 QRegExp("CONNECT [^0-9]*[0-9]+", false), 495 QRegExp("CONNECT [^0-9]*[0-9]+", false),
492 QRegExp("[0-9]+") // panic mode 496 QRegExp("[0-9]+") // panic mode
493 }; 497 };
494 498
495 QRegExp trx[TXMAX] = { 499 QRegExp trx[TXMAX] = {
496 QRegExp("[0-9]+[:/ ]TX", false), 500 QRegExp("[0-9]+[:/ ]TX", false),
497 QRegExp("[0-9]+TX", false) 501 QRegExp("[0-9]+TX", false)
498 }; 502 };
499 503
500 for(i = 0; i < RXMAX; i++) { 504 for(i = 0; i < RXMAX; i++) {
501 int len, idx, result; 505 int len, idx, result;
502 if((idx = rrx[i].match(s,0,&len)) > -1) { 506 if((idx = rrx[i].match(s,0,&len)) > -1) {
503// if((idx = rrx[i].search(s)) > -1) { 507// if((idx = rrx[i].search(s)) > -1) {
504 // len = rrx[i].matchedLength(); 508 // len = rrx[i].matchedLength();
505 509
506 // 510 //
507 // rrx[i] has been matched, idx contains the start of the match 511 // rrx[i] has been matched, idx contains the start of the match
508 // and len contains how long the match is. Extract the match. 512 // and len contains how long the match is. Extract the match.
509 // 513 //
510 QString sub = s.mid(idx, len); 514 QString sub = s.mid(idx, len);
511 515
512 // 516 //
513 // Now extract the digits only from the match, which will 517 // Now extract the digits only from the match, which will
514 // then be converted to an int. 518 // then be converted to an int.
515 // 519 //
516 if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { 520 if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) {
517// if ((idx = rrx[RXMAX-1].search( sub )) > -1) { 521// if ((idx = rrx[RXMAX-1].search( sub )) > -1) {
518// len = rrx[RXMAX-1].matchedLength(); 522// len = rrx[RXMAX-1].matchedLength();
519 sub = sub.mid(idx, len); 523 sub = sub.mid(idx, len);
520 result = sub.toInt(); 524 result = sub.toInt();
521 if(result > 0) { 525 if(result > 0) {
522 rx = result; 526 rx = result;
523 break; 527 break;
524 } 528 }
525 } 529 }
526 } 530 }
527 } 531 }
528 532
529 for(i = 0; i < TXMAX; i++) { 533 for(i = 0; i < TXMAX; i++) {
530 int len, idx, result; 534 int len, idx, result;
531 if((idx = trx[i].match(s,0,&len)) > -1) { 535 if((idx = trx[i].match(s,0,&len)) > -1) {
532// if((idx = trx[i].search(s)) > -1) { 536// if((idx = trx[i].search(s)) > -1) {
533// len = trx[i].matchedLength(); 537// len = trx[i].matchedLength();
534 538
535 // 539 //
536 // trx[i] has been matched, idx contains the start of the match 540 // trx[i] has been matched, idx contains the start of the match
537 // and len contains how long the match is. Extract the match. 541 // and len contains how long the match is. Extract the match.
538 // 542 //
539 QString sub = s.mid(idx, len); 543 QString sub = s.mid(idx, len);
540 544
541 // 545 //
542 // Now extract the digits only from the match, which will then 546 // Now extract the digits only from the match, which will then
543 // be converted to an int. 547 // be converted to an int.
544 // 548 //
545 if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { 549 if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) {
546// if((idx = rrx[RXMAX-1].search(sub)) > -1) { 550// if((idx = rrx[RXMAX-1].search(sub)) > -1) {
547// len = rrx[RXMAX-1].matchedLength(); 551// len = rrx[RXMAX-1].matchedLength();
548 sub = sub.mid(idx, len); 552 sub = sub.mid(idx, len);
549 result = sub.toInt(); 553 result = sub.toInt();
550 if(result > 0) { 554 if(result > 0) {
551 tx = result; 555 tx = result;
552 break; 556 break;
553 } 557 }
554 } 558 }
555 } 559 }
556 } 560 }
557 561
558 if(rx == -1 && tx == -1) 562 if(rx == -1 && tx == -1)
559 result = QObject::tr("Unknown speed"); 563 result = QObject::tr("Unknown speed");
560 else if(tx == -1) 564 else if(tx == -1)
561 result.setNum(rx); 565 result.setNum(rx);
562 else if(rx == -1) // should not happen 566 else if(rx == -1) // should not happen
563 result.setNum(tx); 567 result.setNum(tx);
564 else 568 else
565 result.sprintf("%d/%d", rx, tx); 569 result.sprintf("%d/%d", rx, tx);
566 570
567 odebug << "The parsed result is: " << result.latin1() << "" << oendl; 571 odebug << "The parsed result is: " << result.latin1() << "" << oendl;
568 572
569 return result; 573 return result;
570} 574}
571 575
572 576
573// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if 577// Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if
574// a lock file can't be created ( permission problem ) 578// a lock file can't be created ( permission problem )
575int Modem::lockdevice() { 579int Modem::lockdevice() {
576 int fd; 580 int fd;
577 char newlock[80]=""; // safe 581 char newlock[80]=""; // safe
578 582
579 if(!_pppdata->modemLockFile()) { 583 if(!_pppdata->modemLockFile()) {
580 odebug << "The user doesn't want a lockfile." << oendl; 584 odebug << "The user doesn't want a lockfile." << oendl;
581 return 0; 585 return 0;
582 } 586 }
583 587
584 if (modem_is_locked) 588 if (modem_is_locked)
585 return 1; 589 return 1;
586 590
587 QString lockfile = LOCK_DIR"/LCK.."; 591 QString lockfile = LOCK_DIR"/LCK..";
588 lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ 592 lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/
589 593
590 if(access(QFile::encodeName(lockfile), F_OK) == 0) { 594 if(access(QFile::encodeName(lockfile), F_OK) == 0) {
591// if ((fd = Requester::rq-> 595// if ((fd = Requester::rq->
592if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { 596if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) {
593 // Mario: it's not necessary to read more than lets say 32 bytes. If 597 // Mario: it's not necessary to read more than lets say 32 bytes. If
594 // file has more than 32 bytes, skip the rest 598 // file has more than 32 bytes, skip the rest
595 char oldlock[33]; // safe 599 char oldlock[33]; // safe
596 int sz = read(fd, &oldlock, 32); 600 int sz = read(fd, &oldlock, 32);
597 close (fd); 601 close (fd);
598 if (sz <= 0) 602 if (sz <= 0)
599 return 1; 603 return 1;
600 oldlock[sz] = '\0'; 604 oldlock[sz] = '\0';
601 605
602 odebug << "Device is locked by: " << oldlock << "" << oendl; 606 odebug << "Device is locked by: " << oldlock << "" << oendl;
603 607
604 int oldpid; 608 int oldpid;
605 int match = sscanf(oldlock, "%d", &oldpid); 609 int match = sscanf(oldlock, "%d", &oldpid);
606 610
607 // found a pid in lockfile ? 611 // found a pid in lockfile ?
608 if (match < 1 || oldpid <= 0) 612 if (match < 1 || oldpid <= 0)
609 return 1; 613 return 1;
610 614
611 // check if process exists 615 // check if process exists
612 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) 616 if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH)
613 return 1; 617 return 1;
614 618
615 odebug << "lockfile is stale" << oendl; 619 odebug << "lockfile is stale" << oendl;
616 } 620 }
617 } 621 }
618 622
619 fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); 623 fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT);
620 if(fd >= 0) { 624 if(fd >= 0) {
621 sprintf(newlock,"%010d\n", getpid()); 625 sprintf(newlock,"%010d\n", getpid());
622 odebug << "Locking Device: " << newlock << "" << oendl; 626 odebug << "Locking Device: " << newlock << "" << oendl;
623 627
624 write(fd, newlock, strlen(newlock)); 628 write(fd, newlock, strlen(newlock));
625 close(fd); 629 close(fd);
626 modem_is_locked=true; 630 modem_is_locked=true;
627 631
628 return 0; 632 return 0;
629 } 633 }
630 634
631 return -1; 635 return -1;
632 636
633} 637}
634 638
635 639
636// UnLock modem device 640// UnLock modem device
637void Modem::unlockdevice() { 641void Modem::unlockdevice() {
638 if (modem_is_locked) { 642 if (modem_is_locked) {
639 odebug << "UnLocking Modem Device" << oendl; 643 odebug << "UnLocking Modem Device" << oendl;
640 close(modemfd); 644 close(modemfd);
641 modemfd = -1; 645 modemfd = -1;
642 unlink(lockfile); 646 unlink(lockfile);
643 lockfile[0] = '\0'; 647 lockfile[0] = '\0';
644 modem_is_locked=false; 648 modem_is_locked=false;
645 } 649 }
646} 650}
647 651
648int Modem::openLockfile( QString lockfile, int flags) 652int Modem::openLockfile( QString lockfile, int flags)
649{ 653{
650 int fd; 654 int fd;
651 int mode; 655 int mode;
652 flags = O_RDONLY; 656 flags = O_RDONLY;
653 if(flags == O_WRONLY|O_TRUNC|O_CREAT) 657 if(flags == O_WRONLY|O_TRUNC|O_CREAT)
654 mode = 0644; 658 mode = 0644;
655 else 659 else
656 mode = 0; 660 mode = 0;
657 661
658 lockfile = LOCK_DIR; 662 lockfile = LOCK_DIR;
659 lockfile += "/LCK.."; 663 lockfile += "/LCK..";
660 lockfile += device.right( device.length() - device.findRev("/") -1 ); 664 lockfile += device.right( device.length() - device.findRev("/") -1 );
661 odebug << "lockfile >" << lockfile.latin1() << "<" << oendl; 665 odebug << "lockfile >" << lockfile.latin1() << "<" << oendl;
662 // TODO: 666 // TODO:
663 // struct stat st; 667 // struct stat st;
664 // if(stat(lockfile.data(), &st) == -1) { 668 // if(stat(lockfile.data(), &st) == -1) {
665 // if(errno == EBADF) 669 // if(errno == EBADF)
666 // return -1; 670 // return -1;
667 // } else { 671 // } else {
668 // // make sure that this is a regular file 672 // // make sure that this is a regular file
669 // if(!S_ISREG(st.st_mode)) 673 // if(!S_ISREG(st.st_mode))
670 // return -1; 674 // return -1;
671 // } 675 // }
672 if ((fd = open(lockfile, flags, mode)) == -1) { 676 if ((fd = open(lockfile, flags, mode)) == -1) {
673 odebug << "error opening lockfile!" << oendl; 677 odebug << "error opening lockfile!" << oendl;
674 lockfile = QString::null; 678 lockfile = QString::null;
675 fd = open(DEVNULL, O_RDONLY); 679 fd = open(DEVNULL, O_RDONLY);
676 } else 680 } else
677 fchown(fd, 0, 0); 681 fchown(fd, 0, 0);
678 return fd; 682 return fd;
679} 683}
680 684
681 685
682 686
683void alarm_handler(int) { 687void alarm_handler(int) {
684 // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); 688 // fprintf(stderr, "alarm_handler(): Received SIGALRM\n");
685 689
686 // jump 690 // jump
687 siglongjmp(jmp_buffer, 1); 691 siglongjmp(jmp_buffer, 1);
688} 692}
689 693
690 694
691const char* Modem::authFile(Auth method, int version) { 695const char* Modem::authFile(Auth method, int version) {
692 switch(method|version) { 696 switch(method|version) {
693 case PAP|Original: 697 case PAP|Original:
694 return PAP_AUTH_FILE; 698 return PAP_AUTH_FILE;
695 break; 699 break;
696 case PAP|New: 700 case PAP|New:
697 return PAP_AUTH_FILE".new"; 701 return PAP_AUTH_FILE".new";
698 break; 702 break;
699 case PAP|Old: 703 case PAP|Old:
700 return PAP_AUTH_FILE".old"; 704 return PAP_AUTH_FILE".old";
701 break; 705 break;
702 case CHAP|Original: 706 case CHAP|Original:
703 return CHAP_AUTH_FILE; 707 return CHAP_AUTH_FILE;
704 break; 708 break;
705 case CHAP|New: 709 case CHAP|New:
706 return CHAP_AUTH_FILE".new"; 710 return CHAP_AUTH_FILE".new";
707 break; 711 break;
708 case CHAP|Old: 712 case CHAP|Old:
709 return CHAP_AUTH_FILE".old"; 713 return CHAP_AUTH_FILE".old";
710 break; 714 break;
711 default: 715 default:
712 return 0L; 716 return 0L;
713 } 717 }
714} 718}
715 719
716 720
717bool Modem::createAuthFile(Auth method, const char *username, const char *password) { 721bool Modem::createAuthFile(Auth method, const char *username, const char *password) {
718 const char *authfile, *oldName, *newName; 722 const char *authfile, *oldName, *newName;
719 char line[100]; 723 char line[100];
720 char regexp[2*MaxStrLen+30]; 724 char regexp[2*MaxStrLen+30];
721 regex_t preg; 725 regex_t preg;
722 726
723 if(!(authfile = authFile(method))) 727 if(!(authfile = authFile(method)))
724 return false; 728 return false;
725 729
726 if(!(newName = authFile(method, New))) 730 if(!(newName = authFile(method, New)))
727 return false; 731 return false;
728 732
729 // look for username, "username" or 'username' 733 // look for username, "username" or 'username'
730 // if you modify this RE you have to adapt regexp's size above 734 // if you modify this RE you have to adapt regexp's size above
731 snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']", 735 snprintf(regexp, sizeof(regexp), "^[ \t]*%s[ \t]\\|^[ \t]*[\"\']%s[\"\']",
732 username,username); 736 username,username);
733 MY_ASSERT(regcomp(&preg, regexp, 0) == 0); 737 MY_ASSERT(regcomp(&preg, regexp, 0) == 0);
734 738
735 // copy to new file pap- or chap-secrets 739 // copy to new file pap- or chap-secrets
736 int old_umask = umask(0077); 740 int old_umask = umask(0077);
737 FILE *fout = fopen(newName, "w"); 741 FILE *fout = fopen(newName, "w");
738 if(fout) { 742 if(fout) {
739 // copy old file 743 // copy old file
740 FILE *fin = fopen(authfile, "r"); 744 FILE *fin = fopen(authfile, "r");
741 if(fin) { 745 if(fin) {
742 while(fgets(line, sizeof(line), fin)) { 746 while(fgets(line, sizeof(line), fin)) {
743 if(regexec(&preg, line, 0, 0L, 0) == 0) 747 if(regexec(&preg, line, 0, 0L, 0) == 0)
744 continue; 748 continue;
745 fputs(line, fout); 749 fputs(line, fout);
746 } 750 }
747 fclose(fin); 751 fclose(fin);
748 } 752 }
749 753
750 // append user/pass pair 754 // append user/pass pair
751 fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password); 755 fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password);
752 fclose(fout); 756 fclose(fout);
753 } 757 }
754 758
755 // restore umask 759 // restore umask
756 umask(old_umask); 760 umask(old_umask);
757 761
758 // free memory allocated by regcomp 762 // free memory allocated by regcomp
759 regfree(&preg); 763 regfree(&preg);
760 764
761 if(!(oldName = authFile(method, Old))) 765 if(!(oldName = authFile(method, Old)))
762 return false; 766 return false;
763 767
764 // delete old file if any 768 // delete old file if any
765 unlink(oldName); 769 unlink(oldName);
766 770
767 rename(authfile, oldName); 771 rename(authfile, oldName);
768 rename(newName, authfile); 772 rename(newName, authfile);
769 773
770 return true; 774 return true;
771} 775}
772 776
773 777
774bool Modem::removeAuthFile(Auth method) { 778bool Modem::removeAuthFile(Auth method) {
775 const char *authfile, *oldName; 779 const char *authfile, *oldName;
776 780
777 if(!(authfile = authFile(method))) 781 if(!(authfile = authFile(method)))
778 return false; 782 return false;
779 if(!(oldName = authFile(method, Old))) 783 if(!(oldName = authFile(method, Old)))
780 return false; 784 return false;
781 785
782 if(access(oldName, F_OK) == 0) { 786 if(access(oldName, F_OK) == 0) {
783 unlink(authfile); 787 unlink(authfile);
784 return (rename(oldName, authfile) == 0); 788 return (rename(oldName, authfile) == 0);
785 } else 789 } else
786 return false; 790 return false;
787} 791}
788 792
789 793
790bool Modem::setSecret(int method, const char* name, const char* password) 794bool Modem::setSecret(int method, const char* name, const char* password)
791{ 795{
792 796
793 Auth auth; 797 Auth auth;
794 if(method == AUTH_PAPCHAP) 798 if(method == AUTH_PAPCHAP)
795 return setSecret(AUTH_PAP, name, password) && 799 return setSecret(AUTH_PAP, name, password) &&
796 setSecret(AUTH_CHAP, name, password); 800 setSecret(AUTH_CHAP, name, password);
797 801
798 switch(method) { 802 switch(method) {
799 case AUTH_PAP: 803 case AUTH_PAP:
800 auth = Modem::PAP; 804 auth = Modem::PAP;
801 break; 805 break;
802 case AUTH_CHAP: 806 case AUTH_CHAP:
803 auth = Modem::CHAP; 807 auth = Modem::CHAP;
804 break; 808 break;
805 default: 809 default:
806 return false; 810 return false;
807 } 811 }
808 812
809 return createAuthFile(auth, name, password); 813 return createAuthFile(auth, name, password);
810 814
811} 815}
812 816
813bool Modem::removeSecret(int method) 817bool Modem::removeSecret(int method)
814{ 818{
815 Auth auth; 819 Auth auth;
816 820
817 switch(method) { 821 switch(method) {
818 case AUTH_PAP: 822 case AUTH_PAP:
819 auth = Modem::PAP; 823 auth = Modem::PAP;
820 break; 824 break;
821 case AUTH_CHAP: 825 case AUTH_CHAP:
822 auth = Modem::CHAP; 826 auth = Modem::CHAP;
823 break; 827 break;
824 default: 828 default:
825 return false; 829 return false;
826 } 830 }
827 return removeAuthFile( auth ); 831 return removeAuthFile( auth );
828} 832}
829 833
830int checkForInterface() 834int checkForInterface()
831{ 835{
832// I don't know if Linux needs more initialization to get the ioctl to 836// I don't know if Linux needs more initialization to get the ioctl to
833// work, pppd seems to hint it does. But BSD doesn't, and the following 837// work, pppd seems to hint it does. But BSD doesn't, and the following
834// code should compile. 838// code should compile.
835#if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) 839#if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__)
836 int s, ok; 840 int s, ok;
837 struct ifreq ifr; 841 struct ifreq ifr;
838 // extern char *no_ppp_msg; 842 // extern char *no_ppp_msg;
839 843
840 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) 844 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
841 return 1; /* can't tell */ 845 return 1; /* can't tell */
842 846
843 strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); 847 strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
844 ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; 848 ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
845 close(s); 849 close(s);
846 850
847 if (ok == -1) { 851 if (ok == -1) {
848// This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports 852// This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports
849// KLDs, the old LKM interface couldn't handle loading devices 853// KLDs, the old LKM interface couldn't handle loading devices
850// dynamically, and thus can't load ppp support on the fly 854// dynamically, and thus can't load ppp support on the fly
851#ifdef __FreeBSD__ 855#ifdef __FreeBSD__
852 // If we failed to load ppp support and don't have it already. 856 // If we failed to load ppp support and don't have it already.
853 if (kldload("if_ppp") == -1) { 857 if (kldload("if_ppp") == -1) {
854 return -1; 858 return -1;
855 } 859 }
856 return 0; 860 return 0;
857#else 861#else
858 return -1; 862 return -1;
859#endif 863#endif
860 } 864 }
861 return 0; 865 return 0;
862#else 866#else
863// We attempt to use the SunOS/SysVr4 method and stat /dev/ppp 867// We attempt to use the SunOS/SysVr4 method and stat /dev/ppp
864 struct stat buf; 868 struct stat buf;
865 869
866 memset(&buf, 0, sizeof(buf)); 870 memset(&buf, 0, sizeof(buf));
867 return stat("/dev/ppp", &buf); 871 return stat("/dev/ppp", &buf);
868#endif 872#endif
869} 873}
870 874
871bool Modem::execpppd(const char *arguments) { 875bool Modem::execpppd(const char *arguments) {
872 char buf[MAX_CMDLEN]; 876 char buf[MAX_CMDLEN];
873 char *args[MaxArgs]; 877 char *args[MaxArgs];
874 pid_t pgrpid; 878 pid_t pgrpid;
875 879
876 if(modemfd<0) 880 if(modemfd<0)
877 return false; 881 return false;
878 882
879 _pppdExitStatus = -1; 883 _pppdExitStatus = -1;
880 884
881 (void)::pipe( m_pppdLOG ); 885 (void)::pipe( m_pppdLOG );
882 886
883 switch(pppdPid = fork()) 887 switch(pppdPid = fork())
884 { 888 {
885 case -1: 889 case -1:
886 fprintf(stderr,"In parent: fork() failed\n"); 890 fprintf(stderr,"In parent: fork() failed\n");
887 ::close( m_pppdLOG[0] ); 891 ::close( m_pppdLOG[0] );
888 ::close( m_pppdLOG[1] ); 892 ::close( m_pppdLOG[1] );
889 return false; 893 return false;
890 break; 894 break;
891 895
892 case 0: 896 case 0:
893 // let's parse the arguments the user supplied into UNIX suitable form 897 // let's parse the arguments the user supplied into UNIX suitable form
894 // that is a list of pointers each pointing to exactly one word 898 // that is a list of pointers each pointing to exactly one word
895 strlcpy(buf, arguments); 899 strlcpy(buf, arguments);
896 parseargs(buf, args); 900 parseargs(buf, args);
897 // become a session leader and let /dev/ttySx 901 // become a session leader and let /dev/ttySx
898 // be the controlling terminal. 902 // be the controlling terminal.
899 pgrpid = setsid(); 903 pgrpid = setsid();
900#ifdef TIOCSCTTY 904#ifdef TIOCSCTTY
901 if(ioctl(modemfd, TIOCSCTTY, 0)<0) 905 if(ioctl(modemfd, TIOCSCTTY, 0)<0)
902 fprintf(stderr, "ioctl() failed.\n"); 906 fprintf(stderr, "ioctl() failed.\n");
903#elif defined (TIOCSPGRP) 907#elif defined (TIOCSPGRP)
904 if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) 908 if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0)
905 fprintf(stderr, "ioctl() failed.\n"); 909 fprintf(stderr, "ioctl() failed.\n");
906#endif 910#endif
907 if(tcsetpgrp(modemfd, pgrpid)<0) 911 if(tcsetpgrp(modemfd, pgrpid)<0)
908 fprintf(stderr, "tcsetpgrp() failed.\n"); 912 fprintf(stderr, "tcsetpgrp() failed.\n");
909 913
910 ::close( m_pppdLOG[0] ); 914 ::close( m_pppdLOG[0] );
911 ::setenv( "LANG", "C", 1 ); // overwrite 915 ::setenv( "LANG", "C", 1 ); // overwrite
912 dup2(m_pppdLOG[1], 11 ); // for logfd 11 916 dup2(m_pppdLOG[1], 11 ); // for logfd 11
913 dup2(modemfd, 0); 917 dup2(modemfd, 0);
914 dup2(modemfd, 1); 918 dup2(modemfd, 1);
915 919
916 920
917 switch (checkForInterface()) { 921 switch (checkForInterface()) {
918 case 1: 922 case 1:
919 fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); 923 fprintf(stderr, "Cannot determine if kernel supports ppp.\n");
920 break; 924 break;
921 case -1: 925 case -1:
922 fprintf(stderr, "Kernel does not support ppp, oops.\n"); 926 fprintf(stderr, "Kernel does not support ppp, oops.\n");
923 break; 927 break;
924 case 0: 928 case 0:
925 fprintf(stderr, "Kernel supports ppp alright.\n"); 929 fprintf(stderr, "Kernel supports ppp alright.\n");
926 break; 930 break;
927 } 931 }
928 932
929 execve(pppdPath(), args, 0L); 933 execve(pppdPath(), args, 0L);
930 _exit(0); 934 _exit(0);
931 break; 935 break;
932 936
933 default: 937 default:
934 odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl; 938 odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl;
935 close(modemfd); 939 close(modemfd);
936 940
937 ::close( m_pppdLOG[1] ); 941 ::close( m_pppdLOG[1] );
938 // set it to nonblocking io 942 // set it to nonblocking io
939 int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); 943 int flag = ::fcntl( m_pppdLOG[0], F_GETFL );
940 944
941 if ( !(flag & O_NONBLOCK) ) { 945 if ( !(flag & O_NONBLOCK) ) {
942 odebug << "Setting nonblocking io" << oendl; 946 odebug << "Setting nonblocking io" << oendl;
943 flag |= O_NONBLOCK; 947 flag |= O_NONBLOCK;
944 ::fcntl(m_pppdLOG[0], F_SETFL, flag ); 948 ::fcntl(m_pppdLOG[0], F_SETFL, flag );
945 } 949 }
946 950
947 delete m_modemDebug; 951 delete m_modemDebug;
948 m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); 952 m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this );
949 connect(m_modemDebug, SIGNAL(activated(int) ), 953 connect(m_modemDebug, SIGNAL(activated(int) ),
950 this, SLOT(slotModemDebug(int) ) ); 954 this, SLOT(slotModemDebug(int) ) );
951 955
952 modemfd = -1; 956 modemfd = -1;
953 m_pppdDev = QString::fromLatin1("ppp0"); 957 m_pppdDev = QString::fromLatin1("ppp0");
954 return true; 958 return true;
955 break; 959 break;
956 } 960 }
957} 961}
958 962
959 963
960bool Modem::killpppd() { 964bool Modem::killpppd() {
961 odebug << "In killpppd and pid is " << pppdPid << "" << oendl; 965 odebug << "In killpppd and pid is " << pppdPid << "" << oendl;
962 if(pppdPid > 0) { 966 if(pppdPid > 0) {
963 delete m_modemDebug; 967 delete m_modemDebug;
964 m_modemDebug = 0; 968 m_modemDebug = 0;
965 odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl; 969 odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl;
966 if(kill(pppdPid, SIGTERM) < 0) { 970 if(kill(pppdPid, SIGTERM) < 0) {
967 odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl; 971 odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl;
968 if(kill(pppdPid, SIGKILL) < 0) { 972 if(kill(pppdPid, SIGKILL) < 0) {
969 odebug << "Error killing " << pppdPid << "\n" << oendl; 973 odebug << "Error killing " << pppdPid << "\n" << oendl;
970 return false; 974 return false;
971 } 975 }
972 } 976 }
973 } 977 }
974 return true; 978 return true;
975} 979}
976 980
977 981
978void Modem::parseargs(char* buf, char** args) { 982void Modem::parseargs(char* buf, char** args) {
979 int nargs = 0; 983 int nargs = 0;
980 int quotes; 984 int quotes;
981 985
982 while(nargs < MaxArgs-1 && *buf != '\0') { 986 while(nargs < MaxArgs-1 && *buf != '\0') {
983 987
984 quotes = 0; 988 quotes = 0;
985 989
986 // Strip whitespace. Use nulls, so that the previous argument is 990 // Strip whitespace. Use nulls, so that the previous argument is
987 // terminated automatically. 991 // terminated automatically.
988 992
989 while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) 993 while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) )
990 *buf++ = '\0'; 994 *buf++ = '\0';
991 995
992 // detect begin of quoted argument 996 // detect begin of quoted argument
993 if (*buf == '"' || *buf == '\'') { 997 if (*buf == '"' || *buf == '\'') {
994 quotes = *buf; 998 quotes = *buf;
995 *buf++ = '\0'; 999 *buf++ = '\0';
996 } 1000 }
997 1001
998 // save the argument 1002 // save the argument
999 if(*buf != '\0') { 1003 if(*buf != '\0') {
1000 *args++ = buf; 1004 *args++ = buf;
1001 nargs++; 1005 nargs++;
1002 } 1006 }
1003 1007
1004 if (!quotes) 1008 if (!quotes)
1005 while ((*buf != '\0') && (*buf != '\n') && 1009 while ((*buf != '\0') && (*buf != '\n') &&
1006 (*buf != '\t') && (*buf != ' ')) 1010 (*buf != '\t') && (*buf != ' '))
1007 buf++; 1011 buf++;
1008 else { 1012 else {
1009 while ((*buf != '\0') && (*buf != quotes)) 1013 while ((*buf != '\0') && (*buf != quotes))
1010 buf++; 1014 buf++;
1011 *buf++ = '\0'; 1015 *buf++ = '\0';
1012 } 1016 }
1013 } 1017 }
1014 1018
1015 *args = 0L; 1019 *args = 0L;
1016} 1020}
1017 1021
1018bool Modem::execPPPDaemon(const QString & arguments) 1022bool Modem::execPPPDaemon(const QString & arguments)
1019{ 1023{
1020 if(execpppd(arguments)) { 1024 if(execpppd(arguments)) {
1021 _pppdata->setpppdRunning(true); 1025 _pppdata->setpppdRunning(true);
1022 return true; 1026 return true;
1023 } else 1027 } else
1024 return false; 1028 return false;
1025} 1029}
1026 1030
1027void Modem::killPPPDaemon() 1031void Modem::killPPPDaemon()
1028{ 1032{
1029 _pppdata->setpppdRunning(false); 1033 _pppdata->setpppdRunning(false);
1030 killpppd(); 1034 killpppd();
1031} 1035}
1032 1036
1033int Modem::pppdExitStatus() 1037int Modem::pppdExitStatus()
1034{ 1038{
1035 return _pppdExitStatus; 1039 return _pppdExitStatus;
1036} 1040}
1037 1041
1038int Modem::openResolv(int flags) 1042int Modem::openResolv(int flags)
1039{ 1043{
1040 int fd; 1044 int fd;
1041 if ((fd = open(_PATH_RESCONF, flags)) == -1) { 1045 if ((fd = open(_PATH_RESCONF, flags)) == -1) {
1042 odebug << "error opening resolv.conf!" << oendl; 1046 odebug << "error opening resolv.conf!" << oendl;
1043 fd = open(DEVNULL, O_RDONLY); 1047 fd = open(DEVNULL, O_RDONLY);
1044 } 1048 }
1045 return fd; 1049 return fd;
1046} 1050}
1047 1051
1048bool Modem::setHostname(const QString & name) 1052bool Modem::setHostname(const QString & name)
1049{ 1053{
1050 return sethostname(name, name.length()) == 0; 1054 return sethostname(name, name.length()) == 0;
1051} 1055}
1052 1056
1053QString Modem::pppDevice()const { 1057QString Modem::pppDevice()const {
1054 return m_pppdDev; 1058 return m_pppdDev;
1055} 1059}
1056void Modem::setPPPDevice( const QString& dev ) { 1060void Modem::setPPPDevice( const QString& dev ) {
1057 m_pppdDev = dev; 1061 m_pppdDev = dev;
1058} 1062}
1059pid_t Modem::pppPID()const { 1063pid_t Modem::pppPID()const {
1060 return pppdPid; 1064 return pppdPid;
1061} 1065}
1062void Modem::setPPPDPid( pid_t pid ) { 1066void Modem::setPPPDPid( pid_t pid ) {
1063 odebug << "Modem setting pid" << oendl; 1067 odebug << "Modem setting pid" << oendl;
1064 _pppdExitStatus = -1; 1068 _pppdExitStatus = -1;
1065 pppdPid = pid; 1069 pppdPid = pid;
1066 modemfd = -1; 1070 modemfd = -1;
1067} 1071}
1068void Modem::slotModemDebug(int fd) { 1072void Modem::slotModemDebug(int fd) {
1069 char buf[2049]; 1073 char buf[2049];
1070 int len; 1074 int len;
1071 1075
1072 // read in pppd data look for Using interface 1076 // read in pppd data look for Using interface
1073 // then read the interface 1077 // then read the interface
1074 // we limit to 10 device now 0-9 1078 // we limit to 10 device now 0-9
1075 if((len = ::read(fd, buf, 2048)) > 0) { 1079 if((len = ::read(fd, buf, 2048)) > 0) {
1076 buf[len+1] = '\0'; 1080 buf[len+1] = '\0';
1077 char *found; 1081 char *found;
1078 if ( (found = ::strstr(buf, "Using interface ") ) ) { 1082 if ( (found = ::strstr(buf, "Using interface ") ) ) {
1079 found += 16; 1083 found += 16;
1080 m_pppdDev = QString::fromLatin1(found, 5 ); 1084 m_pppdDev = QString::fromLatin1(found, 5 );
1081 m_pppdDev = m_pppdDev.simplifyWhiteSpace(); 1085 m_pppdDev = m_pppdDev.simplifyWhiteSpace();
1082 } 1086 }
1083 } 1087 }
1084} 1088}
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index eb03ef4..1491ea2 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -1,1496 +1,1496 @@
1/* 1/*
2 * kPPP: A pppd front end for the KDE project 2 * kPPP: A pppd front end for the KDE project
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (C) 1997 Bernd Johannes Wuebben 6 * Copyright (C) 1997 Bernd Johannes Wuebben
7 * wuebben@math.cornell.edu 7 * wuebben@math.cornell.edu
8 * 8 *
9 * based on EzPPP: 9 * based on EzPPP:
10 * Copyright (C) 1997 Jay Painter 10 * Copyright (C) 1997 Jay Painter
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public 13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either 14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "pppdata.h" 27#include "pppdata.h"
28#include "runtests.h" 28#include "runtests.h"
29 29
30/* OPIE */ 30/* OPIE */
31#include <opie2/odebug.h> 31#include <opie2/odebug.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33using namespace Opie::Core; 33using namespace Opie::Core;
34 34
35/* QT */ 35/* QT */
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qapplication.h> 37#include <qapplication.h>
38 38
39/* STD */ 39/* STD */
40#include <assert.h> 40#include <assert.h>
41 41
42#define SEPARATOR -sseepp- 42#define SEPARATOR -sseepp-
43#define SEP QString("%1SEPARATOR%1") 43#define SEP QString("%1SEPARATOR%1")
44 44
45PPPData::PPPData() 45PPPData::PPPData()
46 : passwd(""), 46 : passwd(""),
47 _modemName(""), 47 _modemName(""),
48 highcount(-1), // start out with no entries 48 highcount(-1), // start out with no entries
49 highcountdev(-1), // start out with no entries 49 highcountdev(-1), // start out with no entries
50// caccount(-1), // set the current account index also 50// caccount(-1), // set the current account index also
51 suidprocessid(-1), // process ID of setuid child 51 suidprocessid(-1), // process ID of setuid child
52 pppdisrunning(false), 52 pppdisrunning(false),
53 pppderror(0) 53 pppderror(0)
54{ 54{
55 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; 55 highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
56 highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; 56 highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1;
57 Config cfg = config(); 57 Config cfg = config();
58 cfg.setGroup(GENERAL_GRP); 58 cfg.setGroup(GENERAL_GRP);
59 accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); 59 accountList = cfg.readListEntry(ACCOUNT_LIST, ',' );
60 deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); 60 deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' );
61 odebug << "PPPData::PPPData has a accountList " << accountList.join("---").latin1() << "" << oendl; 61 odebug << "PPPData::PPPData has a accountList " << accountList.join("---").latin1() << "" << oendl;
62 odebug << "PPPData::PPPData has a deviceList " << deviceList.join("---").latin1() << "" << oendl; 62 odebug << "PPPData::PPPData has a deviceList " << deviceList.join("---").latin1() << "" << oendl;
63 63
64// if (highcount > MAX_ACCOUNTS) 64// if (highcount > MAX_ACCOUNTS)
65// highcount = MAX_ACCOUNTS; 65// highcount = MAX_ACCOUNTS;
66 66
67 // if(highcount >= 0 && defaultAccount().isEmpty()) { 67 // if(highcount >= 0 && defaultAccount().isEmpty()) {
68// setAccountbyIndex(0); 68// setAccountbyIndex(0);
69// setDefaultAccount(accname()); 69// setDefaultAccount(accname());
70// } else if(!setAccount(defaultAccount())) 70// } else if(!setAccount(defaultAccount()))
71 setDefaultAccount(accname()); 71 setDefaultAccount(accname());
72 72
73 // start out with internal debugging disabled 73 // start out with internal debugging disabled
74 // the user is still free to specify `debug' on his own 74 // the user is still free to specify `debug' on his own
75 setPPPDebug(false); 75 setPPPDebug(false);
76 76
77 ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); 77 ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
78 78
79} 79}
80 80
81Config PPPData::config() 81Config PPPData::config()
82{ 82{
83 return Config("NetworkSetupPPP"); 83 return Config("NetworkSetupPPP");
84} 84}
85 85
86// 86//
87// save configuration 87// save configuration
88// 88//
89void PPPData::save() 89void PPPData::save()
90{ 90{
91 odebug << "PPPData saving data" << oendl; 91 odebug << "PPPData saving data" << oendl;
92 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); 92 writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
93 writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); 93 writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1);
94 QString key; 94 QString key;
95 QStringList keys; 95 QStringList keys;
96 Config cfg = config(); 96 Config cfg = config();
97 cfg.setGroup(GENERAL_GRP); 97 cfg.setGroup(GENERAL_GRP);
98 cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); 98 cfg.writeEntry(ACCOUNT_LIST, accountList, ',' );
99 cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); 99 cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' );
100 100
101 for( QMap<QString,QString>::Iterator it = stringEntries.begin(); 101 for( QMap<QString,QString>::Iterator it = stringEntries.begin();
102 it != stringEntries.end(); ++it ){ 102 it != stringEntries.end(); ++it ){
103 QString val = it.data(); 103 QString val = it.data();
104 key = it.key(); 104 key = it.key();
105// odebug << "saving " << key.latin1() << " -> " << val.latin1() << "" << oendl; 105// odebug << "saving " << key.latin1() << " -> " << val.latin1() << "" << oendl;
106 keys = QStringList::split( "SEPARATOR", key ); 106 keys = QStringList::split( "SEPARATOR", key );
107 //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; 107 //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
108 cfg.setGroup(keys[0]); 108 cfg.setGroup(keys[0]);
109 cfg.writeEntry(keys[1], val); 109 cfg.writeEntry(keys[1], val);
110 } 110 }
111 for( QMap<QString,int>::Iterator it = intEntries.begin(); 111 for( QMap<QString,int>::Iterator it = intEntries.begin();
112 it != intEntries.end(); ++it ){ 112 it != intEntries.end(); ++it ){
113 int val = it.data(); 113 int val = it.data();
114 key = it.key(); 114 key = it.key();
115// odebug << "saving " << key.latin1() << " -> " << val << "" << oendl; 115// odebug << "saving " << key.latin1() << " -> " << val << "" << oendl;
116 keys = QStringList::split( "SEPARATOR", key ); 116 keys = QStringList::split( "SEPARATOR", key );
117 //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< val " << val << "" << oendl; 117 //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< val " << val << "" << oendl;
118 cfg.setGroup(keys[0]); 118 cfg.setGroup(keys[0]);
119 cfg.writeEntry(keys[1], val); 119 cfg.writeEntry(keys[1], val);
120 } 120 }
121 for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); 121 for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
122 it != listEntries.end(); ++it ){ 122 it != listEntries.end(); ++it ){
123 QStringList val = it.data(); 123 QStringList val = it.data();
124 key = it.key(); 124 key = it.key();
125 QChar sep = sepEntries[key]; 125 QChar sep = sepEntries[key];
126// odebug << "saving " << key.latin1() << " -> " << val.join(sep).latin1() << "" << oendl; 126// odebug << "saving " << key.latin1() << " -> " << val.join(sep).latin1() << "" << oendl;
127 keys = QStringList::split( "SEPARATOR", key ); 127 keys = QStringList::split( "SEPARATOR", key );
128 cfg.setGroup(keys[0]); 128 cfg.setGroup(keys[0]);
129 cfg.writeEntry(keys[1], val, sep); 129 cfg.writeEntry(keys[1], val, sep);
130 } 130 }
131} 131}
132 132
133 133
134// 134//
135// cancel changes 135// cancel changes
136// 136//
137void PPPData::cancel() { 137void PPPData::cancel() {
138 stringEntries.clear(); 138 stringEntries.clear();
139 intEntries.clear(); 139 intEntries.clear();
140 listEntries.clear(); 140 listEntries.clear();
141} 141}
142 142
143// functions to read/write date to configuration file 143// functions to read/write date to configuration file
144QString PPPData::readConfig(const QString &group, const QString &key, 144QString PPPData::readConfig(const QString &group, const QString &key,
145 const QString &defvalue = "") 145 const QString &defvalue = "")
146{ 146{
147// odebug << "PPPData::readConfig key >" << key.latin1() << "< group >" << group.latin1() << "<" << oendl; 147// odebug << "PPPData::readConfig key >" << key.latin1() << "< group >" << group.latin1() << "<" << oendl;
148 QString idx = SEP.arg(group).arg(key); 148 QString idx = SEP.arg(group).arg(key);
149 if (stringEntries.find(idx) != stringEntries.end()) 149 if (stringEntries.find(idx) != stringEntries.end())
150 return stringEntries[idx]; 150 return stringEntries[idx];
151 Config cfg = config(); 151 Config cfg = config();
152 cfg.setGroup(group); 152 cfg.setGroup(group);
153 return cfg.readEntry(key, defvalue); 153 return cfg.readEntry(key, defvalue);
154} 154}
155 155
156 156
157int PPPData::readNumConfig(const QString &group, const QString &key, 157int PPPData::readNumConfig(const QString &group, const QString &key,
158 int defvalue) 158 int defvalue)
159{ 159{
160 QString idx = SEP.arg(group).arg(key); 160 QString idx = SEP.arg(group).arg(key);
161 if (intEntries.find(idx) != intEntries.end()) 161 if (intEntries.find(idx) != intEntries.end())
162 return intEntries[idx]; 162 return intEntries[idx];
163 Config cfg = config(); 163 Config cfg = config();
164 cfg.setGroup(group); 164 cfg.setGroup(group);
165 return cfg.readNumEntry(key, defvalue); 165 return cfg.readNumEntry(key, defvalue);
166 166
167// if (config) { 167// if (config) {
168// config->setGroup(group); 168// config->setGroup(group);
169// return config->readNumEntry(key, defvalue); 169// return config->readNumEntry(key, defvalue);
170// } else 170// } else
171// return defvalue; 171// return defvalue;
172 172
173} 173}
174 174
175 175
176bool PPPData::readListConfig(const QString &group, const QString &key, 176bool PPPData::readListConfig(const QString &group, const QString &key,
177 QStringList &list, char sep) { 177 QStringList &list, char sep) {
178 list.clear(); 178 list.clear();
179 QString idx = SEP.arg(group).arg(key); 179 QString idx = SEP.arg(group).arg(key);
180 if (listEntries.find(idx) != listEntries.end()){ 180 if (listEntries.find(idx) != listEntries.end()){
181 list = listEntries[idx]; 181 list = listEntries[idx];
182 return true; 182 return true;
183 } 183 }
184 Config cfg = config(); 184 Config cfg = config();
185 cfg.setGroup(group); 185 cfg.setGroup(group);
186 list = cfg.readListEntry(key, sep); 186 list = cfg.readListEntry(key, sep);
187 if (list.count() > 0) return true; 187 if (list.count() > 0) return true;
188 return false; 188 return false;
189 189
190// if (config) { 190// if (config) {
191// config->setGroup(group); 191// config->setGroup(group);
192// list = config->readListEntry(key, sep); 192// list = config->readListEntry(key, sep);
193// return true; 193// return true;
194// } else 194// } else
195// return false; 195// return false;
196} 196}
197 197
198 198
199void PPPData::writeConfig(const QString &group, const QString &key, 199void PPPData::writeConfig(const QString &group, const QString &key,
200 const QString &value) { 200 const QString &value) {
201 stringEntries.insert( SEP.arg(group).arg(key), value ); 201 stringEntries.insert( SEP.arg(group).arg(key), value );
202// if (config) { 202// if (config) {
203// config->setGroup(group); 203// config->setGroup(group);
204// config->writeEntry(key, value); 204// config->writeEntry(key, value);
205// } 205// }
206} 206}
207 207
208 208
209void PPPData::writeConfig(const QString &group, const QString &key, int value) 209void PPPData::writeConfig(const QString &group, const QString &key, int value)
210{ 210{
211 intEntries.insert( SEP.arg(group).arg(key), value ); 211 intEntries.insert( SEP.arg(group).arg(key), value );
212// if (config) { 212// if (config) {
213// config->setGroup(group); 213// config->setGroup(group);
214// config->writeEntry(key, value); 214// config->writeEntry(key, value);
215// } 215// }
216} 216}
217 217
218 218
219void PPPData::writeListConfig(const QString &group, const QString &key, 219void PPPData::writeListConfig(const QString &group, const QString &key,
220 QStringList &list, char sep) 220 QStringList &list, char sep)
221{ 221{
222 listEntries.insert( SEP.arg(group).arg(key), list ); 222 listEntries.insert( SEP.arg(group).arg(key), list );
223 sepEntries.insert( SEP.arg(group).arg(key), sep ); 223 sepEntries.insert( SEP.arg(group).arg(key), sep );
224// if (config) { 224// if (config) {
225// config->setGroup(group); 225// config->setGroup(group);
226// config->writeEntry(key, list, sep); 226// config->writeEntry(key, list, sep);
227// } 227// }
228} 228}
229 229
230 230
231// 231//
232// functions to set/return general information 232// functions to set/return general information
233// 233//
234QString PPPData::password(){ 234QString PPPData::password(){
235 if ( storePassword() ) return storedPassword(); 235 if ( storePassword() ) return storedPassword();
236 else return passwd; 236 else return passwd;
237} 237}
238 238
239 239
240void PPPData::setPassword(const QString &pw) { 240void PPPData::setPassword(const QString &pw) {
241 passwd = pw; 241 passwd = pw;
242} 242}
243 243
244 244
245const QString PPPData::defaultAccount() { 245const QString PPPData::defaultAccount() {
246 return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); 246 return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY);
247} 247}
248 248
249 249
250void PPPData::setDefaultAccount(const QString &n) { 250void PPPData::setDefaultAccount(const QString &n) {
251 writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); 251 writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n);
252 252
253 //now set the current account index to the default account 253 //now set the current account index to the default account
254 setAccount(defaultAccount()); 254 setAccount(defaultAccount());
255} 255}
256 256
257 257
258bool PPPData::get_show_clock_on_caption() { 258bool PPPData::get_show_clock_on_caption() {
259 return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); 259 return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true);
260} 260}
261 261
262 262
263void PPPData::set_show_clock_on_caption(bool set) { 263void PPPData::set_show_clock_on_caption(bool set) {
264 writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); 264 writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set);
265} 265}
266 266
267 267
268bool PPPData::get_xserver_exit_disconnect() { 268bool PPPData::get_xserver_exit_disconnect() {
269 return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); 269 return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true);
270} 270}
271 271
272 272
273void PPPData::setPPPDebug(bool set) { 273void PPPData::setPPPDebug(bool set) {
274 writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); 274 writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set);
275} 275}
276 276
277 277
278bool PPPData::getPPPDebug() { 278bool PPPData::getPPPDebug() {
279 return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); 279 return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false);
280} 280}
281 281
282 282
283void PPPData::set_xserver_exit_disconnect(bool set) { 283void PPPData::set_xserver_exit_disconnect(bool set) {
284 writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); 284 writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set);
285} 285}
286 286
287 287
288bool PPPData::quit_on_disconnect() { 288bool PPPData::quit_on_disconnect() {
289 return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); 289 return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false);
290} 290}
291 291
292 292
293void PPPData::set_quit_on_disconnect(bool set) { 293void PPPData::set_quit_on_disconnect(bool set) {
294 writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); 294 writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set);
295} 295}
296 296
297 297
298bool PPPData::get_show_log_window() { 298bool PPPData::get_show_log_window() {
299 return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); 299 return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false);
300} 300}
301 301
302 302
303void PPPData::set_show_log_window(bool set) { 303void PPPData::set_show_log_window(bool set) {
304 writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); 304 writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set);
305} 305}
306 306
307 307
308bool PPPData::automatic_redial() { 308bool PPPData::automatic_redial() {
309 return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); 309 return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE);
310} 310}
311 311
312 312
313void PPPData::set_automatic_redial(bool set) { 313void PPPData::set_automatic_redial(bool set) {
314 writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); 314 writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set);
315} 315}
316 316
317 317
318// bool PPPData::get_iconify_on_connect() { 318// bool PPPData::get_iconify_on_connect() {
319// return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); 319// return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
320// } 320// }
321 321
322 322
323// void PPPData::set_iconify_on_connect(bool set) { 323// void PPPData::set_iconify_on_connect(bool set) {
324// writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); 324// writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
325// } 325// }
326 326
327 327
328// bool PPPData::get_dock_into_panel() { 328// bool PPPData::get_dock_into_panel() {
329// return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); 329// return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
330// } 330// }
331 331
332 332
333// void PPPData::set_dock_into_panel(bool set) { 333// void PPPData::set_dock_into_panel(bool set) {
334// writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); 334// writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
335// } 335// }
336 336
337 337
338QString PPPData::pppdVersion() { 338QString PPPData::pppdVersion() {
339 return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); 339 return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch);
340} 340}
341 341
342bool PPPData::pppdVersionMin(int ver, int mod, int patch) { 342bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
343 // check if pppd version fulfills minimum requirement 343 // check if pppd version fulfills minimum requirement
344 return (pppdVer > ver 344 return (pppdVer > ver
345 || (pppdVer == ver && pppdMod > mod) 345 || (pppdVer == ver && pppdMod > mod)
346 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); 346 || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
347} 347}
348 348
349int PPPData::pppdTimeout() { 349int PPPData::pppdTimeout() {
350 return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); 350 return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT);
351} 351}
352 352
353 353
354void PPPData::setpppdTimeout(int n) { 354void PPPData::setpppdTimeout(int n) {
355 writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); 355 writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n);
356} 356}
357 357
358 358
359const QString PPPData::modemDevice() { 359const QString PPPData::modemDevice() {
360 return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); 360 return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" );
361} 361}
362 362
363 363
364// const QString PPPData::modemName() 364// const QString PPPData::modemName()
365// { 365// {
366// return readConfig(modemGroup(), MODEMNAME_KEY); 366// return readConfig(modemGroup(), MODEMNAME_KEY);
367// } 367// }
368 368
369// bool PPPData::setModemName(const QString &n) { 369// bool PPPData::setModemName(const QString &n) {
370// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; 370// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl;
371// _modemName = n; 371// _modemName = n;
372// writeConfig(cgroup, MODEMNAME_KEY, n); 372// writeConfig(cgroup, MODEMNAME_KEY, n);
373// return true; //FIXME 373// return true; //FIXME
374// } 374// }
375 375
376// bool PPPData::changeModemName(const QString &n) { 376// bool PPPData::changeModemName(const QString &n) {
377// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl; 377// odebug << "Setting modem name to >" << n.latin1() << "<" << oendl;
378// _modemName = n; 378// _modemName = n;
379// writeConfig(modemGroup(), MODEMNAME_KEY, n); 379// writeConfig(modemGroup(), MODEMNAME_KEY, n);
380// return true; //FIXME 380// return true; //FIXME
381// } 381// }
382 382
383bool PPPData::setModemDevice(const QString &n) { 383bool PPPData::setModemDevice(const QString &n) {
384 odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl; 384 odebug << "Setting modem dev to >" << n.latin1() << "<" << oendl;
385 writeConfig(modemGroup(), MODEMDEV_KEY, n); 385 writeConfig(modemGroup(), MODEMDEV_KEY, n);
386 return true; //FIXME 386 return true; //FIXME
387} 387}
388 388
389 389
390const QString PPPData::flowcontrol() { 390enum PPPData::FlowControl PPPData::flowcontrol() {
391 return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); 391 return static_cast<FlowControl>(readNumConfig(modemGroup(), FLOWCONTROL_KEY, FlowHardware));
392} 392}
393 393
394 394
395void PPPData::setFlowcontrol(const QString &n) { 395void PPPData::setFlowcontrol(enum FlowControl n) {
396 writeConfig(modemGroup(), FLOWCONTROL_KEY, n); 396 writeConfig(modemGroup(), FLOWCONTROL_KEY, n);
397} 397}
398 398
399 399
400const QString PPPData::speed() { 400const QString PPPData::speed() {
401 QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); 401 QString s = readConfig(modemGroup(), SPEED_KEY, "57600");
402 // undo the damage of a bug in former versions. It left an empty Speed= 402 // undo the damage of a bug in former versions. It left an empty Speed=
403 // entry in kppprc. kppp did set the serial port to 57600 as default but 403 // entry in kppprc. kppp did set the serial port to 57600 as default but
404 // pppd wouldn't receive the speed via the command line. 404 // pppd wouldn't receive the speed via the command line.
405 if(s.toUInt() == 0) 405 if(s.toUInt() == 0)
406 s = "57600"; 406 s = "57600";
407 return s; 407 return s;
408} 408}
409 409
410 410
411void PPPData::setSpeed(const QString &n) { 411void PPPData::setSpeed(const QString &n) {
412 writeConfig(modemGroup(), SPEED_KEY, n); 412 writeConfig(modemGroup(), SPEED_KEY, n);
413} 413}
414 414
415 415
416#if 0 416#if 0
417void PPPData::setUseCDLine(const int n) { 417void PPPData::setUseCDLine(const int n) {
418 writeConfig(modemGroup(),USECDLINE_KEY,n); 418 writeConfig(modemGroup(),USECDLINE_KEY,n);
419} 419}
420 420
421 421
422int PPPData::UseCDLine() { 422int PPPData::UseCDLine() {
423 return readNumConfig(modemGroup(),USECDLINE_KEY,0); 423 return readNumConfig(modemGroup(),USECDLINE_KEY,0);
424} 424}
425#endif 425#endif
426 426
427const QString PPPData::modemEscapeStr() { 427const QString PPPData::modemEscapeStr() {
428 return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); 428 return readConfig(modemGroup(),ESCAPESTR_KEY,"+++");
429} 429}
430 430
431 431
432void PPPData::setModemEscapeStr(const QString &n) { 432void PPPData::setModemEscapeStr(const QString &n) {
433 writeConfig(modemGroup(),ESCAPESTR_KEY,n); 433 writeConfig(modemGroup(),ESCAPESTR_KEY,n);
434} 434}
435 435
436 436
437const QString PPPData::modemEscapeResp() { 437const QString PPPData::modemEscapeResp() {
438 return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); 438 return readConfig(modemGroup(),ESCAPERESP_KEY,"OK");
439} 439}
440 440
441 441
442void PPPData::setModemEscapeResp(const QString &n) { 442void PPPData::setModemEscapeResp(const QString &n) {
443 writeConfig(modemGroup(),ESCAPERESP_KEY,n); 443 writeConfig(modemGroup(),ESCAPERESP_KEY,n);
444} 444}
445 445
446 446
447int PPPData::modemEscapeGuardTime() { 447int PPPData::modemEscapeGuardTime() {
448 return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); 448 return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50);
449} 449}
450 450
451 451
452void PPPData::setModemEscapeGuardTime(int n) { 452void PPPData::setModemEscapeGuardTime(int n) {
453 writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); 453 writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n);
454} 454}
455 455
456 456
457bool PPPData::modemLockFile() { 457bool PPPData::modemLockFile() {
458 return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); 458 return readNumConfig(modemGroup(), LOCKFILE_KEY, 1);
459} 459}
460 460
461 461
462void PPPData::setModemLockFile(bool set) { 462void PPPData::setModemLockFile(bool set) {
463 writeConfig(modemGroup(), LOCKFILE_KEY, set); 463 writeConfig(modemGroup(), LOCKFILE_KEY, set);
464} 464}
465 465
466 466
467int PPPData::modemTimeout() { 467int PPPData::modemTimeout() {
468 return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); 468 return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT);
469} 469}
470 470
471 471
472void PPPData::setModemTimeout(int n) { 472void PPPData::setModemTimeout(int n) {
473 writeConfig(modemGroup(), TIMEOUT_KEY, n); 473 writeConfig(modemGroup(), TIMEOUT_KEY, n);
474} 474}
475 475
476 476
477int PPPData::modemToneDuration() { 477int PPPData::modemToneDuration() {
478 return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); 478 return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION);
479} 479}
480 480
481 481
482void PPPData::setModemToneDuration(int n) { 482void PPPData::setModemToneDuration(int n) {
483 writeConfig(modemGroup(), TONEDURATION_KEY, n); 483 writeConfig(modemGroup(), TONEDURATION_KEY, n);
484} 484}
485 485
486 486
487int PPPData::busyWait() { 487int PPPData::busyWait() {
488 return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); 488 return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT);
489} 489}
490 490
491 491
492void PPPData::setbusyWait(int n) { 492void PPPData::setbusyWait(int n) {
493 writeConfig(modemGroup(), BUSYWAIT_KEY, n); 493 writeConfig(modemGroup(), BUSYWAIT_KEY, n);
494} 494}
495 495
496 496
497// 497//
498//Advanced "Modem" dialog 498//Advanced "Modem" dialog
499// 499//
500// defaults: InitString=ATZ, InitString1="" etc. 500// defaults: InitString=ATZ, InitString1="" etc.
501const QString PPPData::modemInitStr(int i) { 501const QString PPPData::modemInitStr(int i) {
502 assert(i >= 0 && i < NumInitStrings); 502 assert(i >= 0 && i < NumInitStrings);
503 if(i == 0) 503 if(i == 0)
504 return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); 504 return readConfig(modemGroup(), INITSTR_KEY, "ATZ");
505 else 505 else
506 return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); 506 return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), "");
507} 507}
508 508
509 509
510void PPPData::setModemInitStr(int i, const QString &n) { 510void PPPData::setModemInitStr(int i, const QString &n) {
511 assert(i >= 0 && i < NumInitStrings); 511 assert(i >= 0 && i < NumInitStrings);
512 QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : QString("")); 512 QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : QString(""));
513 writeConfig(modemGroup(), k, n); 513 writeConfig(modemGroup(), k, n);
514} 514}
515 515
516 516
517const QString PPPData::modemInitResp() { 517const QString PPPData::modemInitResp() {
518 return readConfig(modemGroup(), INITRESP_KEY, "OK"); 518 return readConfig(modemGroup(), INITRESP_KEY, "OK");
519} 519}
520 520
521 521
522void PPPData::setModemInitResp(const QString &n) { 522void PPPData::setModemInitResp(const QString &n) {
523 writeConfig(modemGroup(), INITRESP_KEY, n); 523 writeConfig(modemGroup(), INITRESP_KEY, n);
524} 524}
525 525
526 526
527int PPPData::modemPreInitDelay() { 527int PPPData::modemPreInitDelay() {
528 return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); 528 return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50);
529} 529}
530 530
531 531
532void PPPData::setModemPreInitDelay(int n) { 532void PPPData::setModemPreInitDelay(int n) {
533 writeConfig(modemGroup(), PREINITDELAY_KEY, n); 533 writeConfig(modemGroup(), PREINITDELAY_KEY, n);
534} 534}
535 535
536 536
537int PPPData::modemInitDelay() { 537int PPPData::modemInitDelay() {
538 return readNumConfig(modemGroup(), INITDELAY_KEY, 50); 538 return readNumConfig(modemGroup(), INITDELAY_KEY, 50);
539} 539}
540 540
541 541
542void PPPData::setModemInitDelay(int n) { 542void PPPData::setModemInitDelay(int n) {
543 writeConfig(modemGroup(), INITDELAY_KEY, n); 543 writeConfig(modemGroup(), INITDELAY_KEY, n);
544} 544}
545 545
546QString PPPData::modemNoDialToneDetectionStr() { 546QString PPPData::modemNoDialToneDetectionStr() {
547 return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); 547 return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3");
548} 548}
549 549
550void PPPData::setModemNoDialToneDetectionStr(const QString &n) { 550void PPPData::setModemNoDialToneDetectionStr(const QString &n) {
551 writeConfig(modemGroup(), NODTDETECT_KEY, n); 551 writeConfig(modemGroup(), NODTDETECT_KEY, n);
552} 552}
553 553
554const QString PPPData::modemDialStr() { 554const QString PPPData::modemDialStr() {
555 return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); 555 return readConfig(modemGroup(), DIALSTR_KEY, "ATDT");
556} 556}
557 557
558 558
559void PPPData::setModemDialStr(const QString &n) { 559void PPPData::setModemDialStr(const QString &n) {
560 writeConfig(modemGroup(), DIALSTR_KEY, n); 560 writeConfig(modemGroup(), DIALSTR_KEY, n);
561} 561}
562 562
563 563
564const QString PPPData::modemConnectResp() { 564const QString PPPData::modemConnectResp() {
565 return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); 565 return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT");
566} 566}
567 567
568 568
569void PPPData::setModemConnectResp(const QString &n) { 569void PPPData::setModemConnectResp(const QString &n) {
570 writeConfig(modemGroup(), CONNECTRESP_KEY, n); 570 writeConfig(modemGroup(), CONNECTRESP_KEY, n);
571} 571}
572 572
573 573
574const QString PPPData::modemBusyResp() { 574const QString PPPData::modemBusyResp() {
575 return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); 575 return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY");
576} 576}
577 577
578 578
579void PPPData::setModemBusyResp(const QString &n) { 579void PPPData::setModemBusyResp(const QString &n) {
580 writeConfig(modemGroup(), BUSYRESP_KEY, n); 580 writeConfig(modemGroup(), BUSYRESP_KEY, n);
581} 581}
582 582
583 583
584const QString PPPData::modemNoCarrierResp() { 584const QString PPPData::modemNoCarrierResp() {
585 return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); 585 return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER");
586} 586}
587 587
588 588
589void PPPData::setModemNoCarrierResp(const QString &n) { 589void PPPData::setModemNoCarrierResp(const QString &n) {
590 writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); 590 writeConfig(modemGroup(), NOCARRIERRESP_KEY, n);
591} 591}
592 592
593 593
594const QString PPPData::modemNoDialtoneResp() { 594const QString PPPData::modemNoDialtoneResp() {
595 return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); 595 return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE");
596} 596}
597 597
598 598
599void PPPData::setModemNoDialtoneResp(const QString &n) { 599void PPPData::setModemNoDialtoneResp(const QString &n) {
600 writeConfig(modemGroup(), NODIALTONERESP_KEY, n); 600 writeConfig(modemGroup(), NODIALTONERESP_KEY, n);
601} 601}
602 602
603 603
604const QString PPPData::modemHangupStr() { 604const QString PPPData::modemHangupStr() {
605 return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); 605 return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH");
606} 606}
607 607
608void PPPData::setModemHangupStr(const QString &n) { 608void PPPData::setModemHangupStr(const QString &n) {
609 writeConfig(modemGroup(), HANGUPSTR_KEY, n); 609 writeConfig(modemGroup(), HANGUPSTR_KEY, n);
610} 610}
611 611
612 612
613const QString PPPData::modemHangupResp() { 613const QString PPPData::modemHangupResp() {
614 return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); 614 return readConfig(modemGroup(), HANGUPRESP_KEY, "OK");
615} 615}
616 616
617void PPPData::setModemHangupResp(const QString &n) { 617void PPPData::setModemHangupResp(const QString &n) {
618 writeConfig(modemGroup(), HANGUPRESP_KEY, n); 618 writeConfig(modemGroup(), HANGUPRESP_KEY, n);
619} 619}
620 620
621 621
622const QString PPPData::modemAnswerStr() { 622const QString PPPData::modemAnswerStr() {
623 return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); 623 return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA");
624} 624}
625 625
626 626
627QString PPPData::volumeOff() { 627QString PPPData::volumeOff() {
628 return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); 628 return readConfig(modemGroup(), VOLUME_OFF, "M0L0");
629} 629}
630 630
631 631
632void PPPData::setVolumeOff(const QString &s) { 632void PPPData::setVolumeOff(const QString &s) {
633 writeConfig(modemGroup(), VOLUME_OFF, s); 633 writeConfig(modemGroup(), VOLUME_OFF, s);
634} 634}
635 635
636 636
637QString PPPData::volumeMedium() { 637QString PPPData::volumeMedium() {
638 return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); 638 return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1");
639} 639}
640 640
641 641
642void PPPData::setVolumeMedium(const QString &s) { 642void PPPData::setVolumeMedium(const QString &s) {
643 writeConfig(modemGroup(), VOLUME_MEDIUM, s); 643 writeConfig(modemGroup(), VOLUME_MEDIUM, s);
644} 644}
645 645
646 646
647QString PPPData::volumeHigh() { 647QString PPPData::volumeHigh() {
648 QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); 648 QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3");
649 if(tmp == "M1L4") 649 if(tmp == "M1L4")
650 tmp = "M1L3"; 650 tmp = "M1L3";
651 return tmp; 651 return tmp;
652} 652}
653 653
654 654
655void PPPData::setVolumeHigh(const QString &s) { 655void PPPData::setVolumeHigh(const QString &s) {
656 writeConfig(modemGroup(), VOLUME_HIGH, s); 656 writeConfig(modemGroup(), VOLUME_HIGH, s);
657} 657}
658 658
659 659
660QString PPPData::volumeInitString() { 660QString PPPData::volumeInitString() {
661 QString s; 661 QString s;
662 662
663 switch(volume()) { 663 switch(volume()) {
664 case 0: 664 case 0:
665 s = volumeOff(); 665 s = volumeOff();
666 break; 666 break;
667 case 1: 667 case 1:
668 s = volumeMedium(); 668 s = volumeMedium();
669 break; 669 break;
670 case 2: 670 case 2:
671 s = volumeHigh(); 671 s = volumeHigh();
672 break; 672 break;
673 default: 673 default:
674 s = volumeMedium(); 674 s = volumeMedium();
675 } 675 }
676 676
677 return s; 677 return s;
678} 678}
679 679
680 680
681int PPPData::volume() { 681int PPPData::volume() {
682 return readNumConfig(modemGroup(), VOLUME_KEY, 1); 682 return readNumConfig(modemGroup(), VOLUME_KEY, 1);
683} 683}
684 684
685 685
686void PPPData::setVolume(int i) { 686void PPPData::setVolume(int i) {
687 writeConfig(modemGroup(), VOLUME_KEY, i); 687 writeConfig(modemGroup(), VOLUME_KEY, i);
688} 688}
689 689
690int PPPData::waitForDialTone() { 690int PPPData::waitForDialTone() {
691 return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); 691 return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1);
692} 692}
693 693
694void PPPData::setWaitForDialTone(int i) { 694void PPPData::setWaitForDialTone(int i) {
695 writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); 695 writeConfig(modemGroup(), DIALTONEWAIT_KEY, i);
696} 696}
697 697
698void PPPData::setModemAnswerStr(const QString &n) { 698void PPPData::setModemAnswerStr(const QString &n) {
699 writeConfig(modemGroup(), ANSWERSTR_KEY, n); 699 writeConfig(modemGroup(), ANSWERSTR_KEY, n);
700} 700}
701 701
702 702
703const QString PPPData::modemRingResp() { 703const QString PPPData::modemRingResp() {
704 return readConfig(modemGroup(), RINGRESP_KEY, "RING"); 704 return readConfig(modemGroup(), RINGRESP_KEY, "RING");
705} 705}
706 706
707 707
708void PPPData::setModemRingResp(const QString &n) { 708void PPPData::setModemRingResp(const QString &n) {
709 writeConfig(modemGroup(), RINGRESP_KEY, n); 709 writeConfig(modemGroup(), RINGRESP_KEY, n);
710} 710}
711 711
712 712
713const QString PPPData::modemAnswerResp() { 713const QString PPPData::modemAnswerResp() {
714 return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); 714 return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT");
715} 715}
716 716
717 717
718void PPPData::setModemAnswerResp(const QString &n) { 718void PPPData::setModemAnswerResp(const QString &n) {
719 writeConfig(modemGroup(), ANSWERRESP_KEY, n); 719 writeConfig(modemGroup(), ANSWERRESP_KEY, n);
720} 720}
721 721
722 722
723const QString PPPData::enter() { 723enum PPPData::LineTermination PPPData::enter(){
724 return readConfig(modemGroup(), ENTER_KEY, "CR"); 724 return static_cast<PPPData::LineTermination>(readNumConfig(modemGroup(), ENTER_KEY, EndCR));
725} 725}
726 726
727 727
728void PPPData::setEnter(const QString &n) { 728void PPPData::setEnter(enum PPPData::LineTermination n) {
729 writeConfig(modemGroup(), ENTER_KEY, n); 729 writeConfig(modemGroup(), ENTER_KEY, n);
730} 730}
731 731
732 732
733// 733//
734// functions to set/return account information 734// functions to set/return account information
735// 735//
736 736
737//returns number of accounts 737//returns number of accounts
738int PPPData::count() const { 738int PPPData::count() const {
739 return highcount + 1; 739 return highcount + 1;
740} 740}
741 741
742 742
743bool PPPData::setAccount(const QString &aname) { 743bool PPPData::setAccount(const QString &aname) {
744 odebug << "setting account to >" << aname.latin1() << "<" << oendl; 744 odebug << "setting account to >" << aname.latin1() << "<" << oendl;
745 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { 745 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
746 cgroup = *it; 746 cgroup = *it;
747 odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; 747 odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl;
748 odebug << "iterator " << (*it).latin1() << "" << oendl; 748 odebug << "iterator " << (*it).latin1() << "" << oendl;
749 if(accname() == aname) { 749 if(accname() == aname) {
750 odebug << "SUCCESS" << oendl; 750 odebug << "SUCCESS" << oendl;
751 return true; 751 return true;
752 } 752 }
753 753
754 } 754 }
755 odebug << "FAILURE" << oendl; 755 odebug << "FAILURE" << oendl;
756 return false; 756 return false;
757} 757}
758 758
759/* 759/*
760bool PPPData::setAccountbyIndex(int i) { 760bool PPPData::setAccountbyIndex(int i) {
761 if(i >= 0 && i <= highcount) { 761 if(i >= 0 && i <= highcount) {
762 QString tmp; 762 QString tmp;
763 tmp.sprintf("%s%i", ACCOUNT_GRP, i); 763 tmp.sprintf("%s%i", ACCOUNT_GRP, i);
764 if (_deleted.find(tmp)!=_deleted.end()) return false; 764 if (_deleted.find(tmp)!=_deleted.end()) return false;
765 caccount = i; 765 caccount = i;
766 cgroup = tmp; 766 cgroup = tmp;
767 return true; 767 return true;
768 } 768 }
769 return false; 769 return false;
770} 770}
771*/ 771*/
772 772
773bool PPPData::isUniqueAccname(const QString &n) { 773bool PPPData::isUniqueAccname(const QString &n) {
774 QString save_cgroup = cgroup; 774 QString save_cgroup = cgroup;
775 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { 775 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
776 cgroup = *it; 776 cgroup = *it;
777 odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl; 777 odebug << "PPPData::setAccount " << cgroup.latin1() << "" << oendl;
778 odebug << "" << (*it).latin1() << " \n" << oendl; 778 odebug << "" << (*it).latin1() << " \n" << oendl;
779 if(accname() == n && cgroup != save_cgroup) { 779 if(accname() == n && cgroup != save_cgroup) {
780 cgroup = save_cgroup; 780 cgroup = save_cgroup;
781 odebug << "SUCCESS" << oendl; 781 odebug << "SUCCESS" << oendl;
782 return false; 782 return false;
783 } 783 }
784 784
785 } 785 }
786 cgroup = save_cgroup; 786 cgroup = save_cgroup;
787 return true; 787 return true;
788} 788}
789 789
790 790
791bool PPPData::isUniqueDevname(const QString &n) { 791bool PPPData::isUniqueDevname(const QString &n) {
792 QString save_mName = _modemName; 792 QString save_mName = _modemName;
793 odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl; 793 odebug << "PPPData::isUniqueDevname checking if " << n.latin1() << " is unique" << oendl;
794 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { 794 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
795 _modemName = *it; 795 _modemName = *it;
796 odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl; 796 odebug << "PPPData::isUniqueDevname " << n.latin1() << " == " << devname().latin1() << "" << oendl;
797 if(devname() == n && _modemName != save_mName) { 797 if(devname() == n && _modemName != save_mName) {
798 _modemName = save_mName; 798 _modemName = save_mName;
799 odebug << "NOT UNIQUE" << oendl; 799 odebug << "NOT UNIQUE" << oendl;
800 return false; 800 return false;
801 } 801 }
802 802
803 } 803 }
804 _modemName = save_mName; 804 _modemName = save_mName;
805 return true; 805 return true;
806} 806}
807 807
808 808
809bool PPPData::deleteAccount() { 809bool PPPData::deleteAccount() {
810 // FIXME: check if this account exists in a config... 810 // FIXME: check if this account exists in a config...
811 Config cfg = PPPData::config(); 811 Config cfg = PPPData::config();
812 cfg.setGroup(cgroup); 812 cfg.setGroup(cgroup);
813 cfg.clearGroup(); 813 cfg.clearGroup();
814 accountList.remove(cgroup); 814 accountList.remove(cgroup);
815 815
816 QString key; 816 QString key;
817 QStringList keys; 817 QStringList keys;
818 for( QMap<QString,QString>::Iterator it = stringEntries.begin(); 818 for( QMap<QString,QString>::Iterator it = stringEntries.begin();
819 it != stringEntries.end(); ++it ){ 819 it != stringEntries.end(); ++it ){
820 QString val = it.data(); 820 QString val = it.data();
821 key = it.key(); 821 key = it.key();
822 keys = QStringList::split( "SEPARATOR", key ); 822 keys = QStringList::split( "SEPARATOR", key );
823 if(keys[0]==cgroup){ 823 if(keys[0]==cgroup){
824 stringEntries.remove( it ); 824 stringEntries.remove( it );
825 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; 825 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
826 } 826 }
827 } 827 }
828 for( QMap<QString,int>::Iterator it = intEntries.begin(); 828 for( QMap<QString,int>::Iterator it = intEntries.begin();
829 it != intEntries.end(); ++it ){ 829 it != intEntries.end(); ++it ){
830 int val = it.data(); 830 int val = it.data();
831 key = it.key(); 831 key = it.key();
832 keys = QStringList::split( "SEPARATOR", key ); 832 keys = QStringList::split( "SEPARATOR", key );
833 if(keys[0]==cgroup){ 833 if(keys[0]==cgroup){
834 intEntries.remove( it ); 834 intEntries.remove( it );
835 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl; 835 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl;
836 } 836 }
837 } 837 }
838 for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); 838 for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
839 it != listEntries.end(); ++it ){ 839 it != listEntries.end(); ++it ){
840 QStringList val = it.data(); 840 QStringList val = it.data();
841 key = it.key(); 841 key = it.key();
842 if(keys[0]==cgroup){ 842 if(keys[0]==cgroup){
843 listEntries.remove( it ); 843 listEntries.remove( it );
844 sepEntries.remove( key ); 844 sepEntries.remove( key );
845 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl; 845 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl;
846 } 846 }
847 } 847 }
848 848
849 return true; 849 return true;
850} 850}
851 851
852 852
853bool PPPData::deleteAccount(const QString &aname) { 853bool PPPData::deleteAccount(const QString &aname) {
854 if(!setAccount(aname)) 854 if(!setAccount(aname))
855 return false; 855 return false;
856 856
857 deleteAccount(); 857 deleteAccount();
858 858
859 return true; 859 return true;
860} 860}
861 861
862 862
863int PPPData::newaccount() { 863int PPPData::newaccount() {
864 864
865 odebug << "PPPData::newaccount highcount " << highcount << "/" << MAX_ACCOUNTS << "" << oendl; 865 odebug << "PPPData::newaccount highcount " << highcount << "/" << MAX_ACCOUNTS << "" << oendl;
866// if(!config) open(); 866// if(!config) open();
867// if (highcount >= MAX_ACCOUNTS) return -1; 867// if (highcount >= MAX_ACCOUNTS) return -1;
868 868
869 869
870 QString tmp; 870 QString tmp;
871 tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount); 871 tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount);
872 cgroup = QString(tmp); 872 cgroup = QString(tmp);
873 accountList << tmp; 873 accountList << tmp;
874 odebug << "PPPData::newaccount() Group: >" << cgroup.latin1() << "<" << oendl; 874 odebug << "PPPData::newaccount() Group: >" << cgroup.latin1() << "<" << oendl;
875 setpppdArgumentDefaults(); 875 setpppdArgumentDefaults();
876 return highcount; 876 return highcount;
877} 877}
878 878
879int PPPData::copyaccount(const QString&) { 879int PPPData::copyaccount(const QString&) {
880// FIXME: PPPData::copyaccount 880// FIXME: PPPData::copyaccount
881// if(highcount >= MAX_ACCOUNTS) 881// if(highcount >= MAX_ACCOUNTS)
882 return -1; 882 return -1;
883 883
884// setAccountbyIndex(i); 884// setAccountbyIndex(i);
885 885
886// QMap <QString, QString> map = config->entryMap(cgroup); 886// QMap <QString, QString> map = config->entryMap(cgroup);
887// QMap <QString, QString>::ConstIterator it = map.begin(); 887// QMap <QString, QString>::ConstIterator it = map.begin();
888 888
889// QString newname = QObject::tr("%1_copy").arg(accname()); 889// QString newname = QObject::tr("%1_copy").arg(accname());
890 890
891// newaccount(); 891// newaccount();
892 892
893// while (it != map.end()) { 893// while (it != map.end()) {
894// config->writeEntry(it.key(), *it); 894// config->writeEntry(it.key(), *it);
895// it++; 895// it++;
896// } 896// }
897 897
898// setAccname(newname); 898// setAccname(newname);
899 899
900// return caccount; 900// return caccount;
901} 901}
902 902
903 903
904const QString PPPData::accname() { 904const QString PPPData::accname() {
905 return readConfig(cgroup, NAME_KEY); 905 return readConfig(cgroup, NAME_KEY);
906} 906}
907 907
908void PPPData::setAccname(const QString &n) { 908void PPPData::setAccname(const QString &n) {
909 if(!cgroup.isNull()) { 909 if(!cgroup.isNull()) {
910 // are we manipulating the default account's name ? then change it, too. 910 // are we manipulating the default account's name ? then change it, too.
911 bool def = accname() == defaultAccount(); 911 bool def = accname() == defaultAccount();
912 writeConfig(cgroup, NAME_KEY, n); 912 writeConfig(cgroup, NAME_KEY, n);
913 if (def) 913 if (def)
914 setDefaultAccount(n); 914 setDefaultAccount(n);
915 } 915 }
916 writeConfig(cgroup, NAME_KEY, n); 916 writeConfig(cgroup, NAME_KEY, n);
917} 917}
918 918
919 919
920#define SEPARATOR_CHAR '&' 920#define SEPARATOR_CHAR '&'
921QStringList &PPPData::phonenumbers() { 921QStringList &PPPData::phonenumbers() {
922 922
923 readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); 923 readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR);
924 return phonelist; 924 return phonelist;
925 925
926} 926}
927 927
928 928
929const QString PPPData::phonenumber() { 929const QString PPPData::phonenumber() {
930 return readConfig(cgroup, PHONENUMBER_KEY); 930 return readConfig(cgroup, PHONENUMBER_KEY);
931} 931}
932 932
933 933
934void PPPData::setPhonenumber(const QString &n) { 934void PPPData::setPhonenumber(const QString &n) {
935 writeConfig(cgroup, PHONENUMBER_KEY, n); 935 writeConfig(cgroup, PHONENUMBER_KEY, n);
936} 936}
937 937
938 938
939const QString PPPData::dialPrefix() { 939const QString PPPData::dialPrefix() {
940 return readConfig(cgroup, DIAL_PREFIX_KEY, ""); 940 return readConfig(cgroup, DIAL_PREFIX_KEY, "");
941} 941}
942 942
943 943
944void PPPData::setDialPrefix(const QString &s) { 944void PPPData::setDialPrefix(const QString &s) {
945 writeConfig(cgroup, DIAL_PREFIX_KEY, s); 945 writeConfig(cgroup, DIAL_PREFIX_KEY, s);
946} 946}
947 947
948 948
949int PPPData::authMethod() { 949int PPPData::authMethod() {
950 return readNumConfig(cgroup, AUTH_KEY, 0); 950 return readNumConfig(cgroup, AUTH_KEY, 0);
951} 951}
952 952
953 953
954void PPPData::setAuthMethod(int value) { 954void PPPData::setAuthMethod(int value) {
955 writeConfig(cgroup, AUTH_KEY, value); 955 writeConfig(cgroup, AUTH_KEY, value);
956} 956}
957 957
958 958
959const QString PPPData::storedUsername() { 959const QString PPPData::storedUsername() {
960 return readConfig(cgroup, STORED_USERNAME_KEY, ""); 960 return readConfig(cgroup, STORED_USERNAME_KEY, "");
961} 961}
962 962
963 963
964void PPPData::setStoredUsername(const QString &b) { 964void PPPData::setStoredUsername(const QString &b) {
965 writeConfig(cgroup, STORED_USERNAME_KEY, b); 965 writeConfig(cgroup, STORED_USERNAME_KEY, b);
966} 966}
967 967
968 968
969const QString PPPData::storedPassword() { 969const QString PPPData::storedPassword() {
970 odebug << "getting stored pw" << oendl; 970 odebug << "getting stored pw" << oendl;
971 odebug << "g " << cgroup.latin1() << "" << oendl; 971 odebug << "g " << cgroup.latin1() << "" << oendl;
972 odebug << "k " << STORED_PASSWORD_KEY << "" << oendl; 972 odebug << "k " << STORED_PASSWORD_KEY << "" << oendl;
973 return readConfig(cgroup, STORED_PASSWORD_KEY, ""); 973 return readConfig(cgroup, STORED_PASSWORD_KEY, "");
974} 974}
975 975
976 976
977void PPPData::setStoredPassword(const QString &b) { 977void PPPData::setStoredPassword(const QString &b) {
978 writeConfig(cgroup, STORED_PASSWORD_KEY, b); 978 writeConfig(cgroup, STORED_PASSWORD_KEY, b);
979} 979}
980 980
981 981
982bool PPPData::storePassword() { 982bool PPPData::storePassword() {
983 return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); 983 return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1);
984} 984}
985 985
986 986
987const QString PPPData::command_before_connect() { 987const QString PPPData::command_before_connect() {
988 return readConfig(cgroup, BEFORE_CONNECT_KEY); 988 return readConfig(cgroup, BEFORE_CONNECT_KEY);
989} 989}
990 990
991 991
992void PPPData::setCommand_before_connect(const QString &n) { 992void PPPData::setCommand_before_connect(const QString &n) {
993 writeConfig(cgroup, BEFORE_CONNECT_KEY, n); 993 writeConfig(cgroup, BEFORE_CONNECT_KEY, n);
994} 994}
995 995
996 996
997void PPPData::setStorePassword(bool b) { 997void PPPData::setStorePassword(bool b) {
998 writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); 998 writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b);
999} 999}
1000 1000
1001 1001
1002const QString PPPData::command_on_connect() { 1002const QString PPPData::command_on_connect() {
1003 return readConfig(cgroup, COMMAND_KEY); 1003 return readConfig(cgroup, COMMAND_KEY);
1004} 1004}
1005 1005
1006 1006
1007void PPPData::setCommand_on_connect(const QString &n) { 1007void PPPData::setCommand_on_connect(const QString &n) {
1008 writeConfig(cgroup, COMMAND_KEY, n); 1008 writeConfig(cgroup, COMMAND_KEY, n);
1009} 1009}
1010 1010
1011 1011
1012const QString PPPData::command_on_disconnect() { 1012const QString PPPData::command_on_disconnect() {
1013 return readConfig(cgroup, DISCONNECT_COMMAND_KEY); 1013 return readConfig(cgroup, DISCONNECT_COMMAND_KEY);
1014} 1014}
1015 1015
1016 1016
1017void PPPData::setCommand_on_disconnect(const QString &n) { 1017void PPPData::setCommand_on_disconnect(const QString &n) {
1018 writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); 1018 writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n);
1019} 1019}
1020 1020
1021 1021
1022const QString PPPData::command_before_disconnect() { 1022const QString PPPData::command_before_disconnect() {
1023 return readConfig(cgroup, BEFORE_DISCONNECT_KEY); 1023 return readConfig(cgroup, BEFORE_DISCONNECT_KEY);
1024} 1024}
1025 1025
1026 1026
1027void PPPData::setCommand_before_disconnect(const QString &n) { 1027void PPPData::setCommand_before_disconnect(const QString &n) {
1028 writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); 1028 writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n);
1029} 1029}
1030 1030
1031 1031
1032const QString PPPData::ipaddr() { 1032const QString PPPData::ipaddr() {
1033 return readConfig(cgroup, IPADDR_KEY); 1033 return readConfig(cgroup, IPADDR_KEY);
1034} 1034}
1035 1035
1036 1036
1037void PPPData::setIpaddr(const QString &n) { 1037void PPPData::setIpaddr(const QString &n) {
1038 writeConfig(cgroup, IPADDR_KEY, n); 1038 writeConfig(cgroup, IPADDR_KEY, n);
1039} 1039}
1040 1040
1041 1041
1042const QString PPPData::subnetmask() { 1042const QString PPPData::subnetmask() {
1043 return readConfig(cgroup, SUBNETMASK_KEY); 1043 return readConfig(cgroup, SUBNETMASK_KEY);
1044} 1044}
1045 1045
1046 1046
1047void PPPData::setSubnetmask(const QString &n) { 1047void PPPData::setSubnetmask(const QString &n) {
1048 writeConfig(cgroup, SUBNETMASK_KEY, n); 1048 writeConfig(cgroup, SUBNETMASK_KEY, n);
1049} 1049}
1050 1050
1051 1051
1052bool PPPData::autoname() { 1052bool PPPData::autoname() {
1053 return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); 1053 return (bool) readNumConfig(cgroup, AUTONAME_KEY, false);
1054} 1054}
1055 1055
1056 1056
1057void PPPData::setAutoname(bool set) { 1057void PPPData::setAutoname(bool set) {
1058 writeConfig(cgroup, AUTONAME_KEY, (int) set); 1058 writeConfig(cgroup, AUTONAME_KEY, (int) set);
1059} 1059}
1060 1060
1061 1061
1062bool PPPData::AcctEnabled() { 1062bool PPPData::AcctEnabled() {
1063 return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); 1063 return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false);
1064} 1064}
1065 1065
1066 1066
1067void PPPData::setAcctEnabled(bool set) { 1067void PPPData::setAcctEnabled(bool set) {
1068 writeConfig(cgroup, ACCTENABLED_KEY, (int) set); 1068 writeConfig(cgroup, ACCTENABLED_KEY, (int) set);
1069} 1069}
1070 1070
1071 1071
1072// int PPPData::VolAcctEnabled() { 1072// int PPPData::VolAcctEnabled() {
1073// return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); 1073// return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0);
1074// } 1074// }
1075 1075
1076 1076
1077// void PPPData::setVolAcctEnabled(int set) { 1077// void PPPData::setVolAcctEnabled(int set) {
1078// writeConfig(cgroup, VOLACCTENABLED_KEY, set); 1078// writeConfig(cgroup, VOLACCTENABLED_KEY, set);
1079// } 1079// }
1080 1080
1081 1081
1082const QString PPPData::gateway() { 1082const QString PPPData::gateway() {
1083 return readConfig(cgroup, GATEWAY_KEY); 1083 return readConfig(cgroup, GATEWAY_KEY);
1084} 1084}
1085 1085
1086 1086
1087void PPPData::setGateway(const QString &n ) { 1087void PPPData::setGateway(const QString &n ) {
1088 writeConfig(cgroup, GATEWAY_KEY, n); 1088 writeConfig(cgroup, GATEWAY_KEY, n);
1089} 1089}
1090 1090
1091 1091
1092bool PPPData::defaultroute() { 1092bool PPPData::defaultroute() {
1093 // default route is by default 'on'. 1093 // default route is by default 'on'.
1094 return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true); 1094 return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true);
1095} 1095}
1096 1096
1097 1097
1098void PPPData::setDefaultroute(bool set) { 1098void PPPData::setDefaultroute(bool set) {
1099 writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set); 1099 writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set);
1100} 1100}
1101 1101
1102 1102
1103bool PPPData::autoDNS() { 1103bool PPPData::autoDNS() {
1104 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true); 1104 bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
1105 return (set && pppdVersionMin(2, 3, 7)); 1105 return (set && pppdVersionMin(2, 3, 7));
1106} 1106}
1107 1107
1108 1108
1109void PPPData::setAutoDNS(bool set) { 1109void PPPData::setAutoDNS(bool set) {
1110 writeConfig(cgroup, AUTODNS_KEY, (int) set); 1110 writeConfig(cgroup, AUTODNS_KEY, (int) set);
1111} 1111}
1112 1112
1113 1113
1114void PPPData::setExDNSDisabled(bool set) { 1114void PPPData::setExDNSDisabled(bool set) {
1115 writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set); 1115 writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set);
1116} 1116}
1117 1117
1118 1118
1119bool PPPData::exDNSDisabled() { 1119bool PPPData::exDNSDisabled() {
1120 return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0); 1120 return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0);
1121} 1121}
1122 1122
1123 1123
1124QStringList &PPPData::dns() { 1124QStringList &PPPData::dns() {
1125 static QStringList dnslist; 1125 static QStringList dnslist;
1126 1126
1127 readListConfig(cgroup, DNS_KEY, dnslist); 1127 readListConfig(cgroup, DNS_KEY, dnslist);
1128 while(dnslist.count() > MAX_DNS_ENTRIES) 1128 while(dnslist.count() > MAX_DNS_ENTRIES)
1129 dnslist.remove(dnslist.last()); 1129 dnslist.remove(dnslist.last());
1130 1130
1131 return dnslist; 1131 return dnslist;
1132} 1132}
1133 1133
1134 1134
1135void PPPData::setDns(QStringList &list) { 1135void PPPData::setDns(QStringList &list) {
1136 writeListConfig(cgroup, DNS_KEY, list); 1136 writeListConfig(cgroup, DNS_KEY, list);
1137} 1137}
1138 1138
1139 1139
1140const QString PPPData::domain() { 1140const QString PPPData::domain() {
1141 return readConfig(cgroup, DOMAIN_KEY); 1141 return readConfig(cgroup, DOMAIN_KEY);
1142} 1142}
1143 1143
1144 1144
1145void PPPData::setDomain(const QString &n ) { 1145void PPPData::setDomain(const QString &n ) {
1146 writeConfig(cgroup, DOMAIN_KEY, n); 1146 writeConfig(cgroup, DOMAIN_KEY, n);
1147} 1147}
1148 1148
1149 1149
1150QStringList &PPPData::scriptType() { 1150QStringList &PPPData::scriptType() {
1151 static QStringList typelist; 1151 static QStringList typelist;
1152 1152
1153 readListConfig(cgroup, SCRIPTCOM_KEY, typelist); 1153 readListConfig(cgroup, SCRIPTCOM_KEY, typelist);
1154 while(typelist.count() > MAX_SCRIPT_ENTRIES) 1154 while(typelist.count() > MAX_SCRIPT_ENTRIES)
1155 typelist.remove(typelist.last()); 1155 typelist.remove(typelist.last());
1156 1156
1157 return typelist; 1157 return typelist;
1158} 1158}
1159 1159
1160 1160
1161void PPPData::setScriptType(QStringList &list) { 1161void PPPData::setScriptType(QStringList &list) {
1162 writeListConfig(cgroup, SCRIPTCOM_KEY, list); 1162 writeListConfig(cgroup, SCRIPTCOM_KEY, list);
1163} 1163}
1164 1164
1165 1165
1166QStringList &PPPData::script() { 1166QStringList &PPPData::script() {
1167 static QStringList scriptlist; 1167 static QStringList scriptlist;
1168 1168
1169 readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); 1169 readListConfig(cgroup, SCRIPTARG_KEY, scriptlist);
1170 while(scriptlist.count() > MAX_SCRIPT_ENTRIES) 1170 while(scriptlist.count() > MAX_SCRIPT_ENTRIES)
1171 scriptlist.remove(scriptlist.last()); 1171 scriptlist.remove(scriptlist.last());
1172 1172
1173 return scriptlist; 1173 return scriptlist;
1174} 1174}
1175 1175
1176 1176
1177void PPPData::setScript(QStringList &list) { 1177void PPPData::setScript(QStringList &list) {
1178 writeListConfig(cgroup, SCRIPTARG_KEY, list); 1178 writeListConfig(cgroup, SCRIPTARG_KEY, list);
1179} 1179}
1180 1180
1181 1181
1182// const QString PPPData::accountingFile() { 1182// const QString PPPData::accountingFile() {
1183// return readConfig(cgroup, ACCTFILE_KEY); 1183// return readConfig(cgroup, ACCTFILE_KEY);
1184// } 1184// }
1185 1185
1186 1186
1187// void PPPData::setAccountingFile(const QString &n) { 1187// void PPPData::setAccountingFile(const QString &n) {
1188// writeConfig(cgroup, ACCTFILE_KEY, n); 1188// writeConfig(cgroup, ACCTFILE_KEY, n);
1189// } 1189// }
1190 1190
1191 1191
1192// const QString PPPData::totalCosts() { 1192// const QString PPPData::totalCosts() {
1193// return readConfig(cgroup, TOTALCOSTS_KEY); 1193// return readConfig(cgroup, TOTALCOSTS_KEY);
1194// } 1194// }
1195 1195
1196 1196
1197// void PPPData::setTotalCosts(const QString &n) { 1197// void PPPData::setTotalCosts(const QString &n) {
1198// writeConfig(cgroup, TOTALCOSTS_KEY, n); 1198// writeConfig(cgroup, TOTALCOSTS_KEY, n);
1199// } 1199// }
1200 1200
1201 1201
1202// int PPPData::totalBytes() { 1202// int PPPData::totalBytes() {
1203// return readNumConfig(cgroup, TOTALBYTES_KEY, 0); 1203// return readNumConfig(cgroup, TOTALBYTES_KEY, 0);
1204// } 1204// }
1205 1205
1206// void PPPData::setTotalBytes(int n) { 1206// void PPPData::setTotalBytes(int n) {
1207// writeConfig(cgroup, TOTALBYTES_KEY, n); 1207// writeConfig(cgroup, TOTALBYTES_KEY, n);
1208// } 1208// }
1209 1209
1210 1210
1211QStringList &PPPData::pppdArgument() { 1211QStringList &PPPData::pppdArgument() {
1212 static QStringList arglist; 1212 static QStringList arglist;
1213 1213
1214 while(arglist.count() > MAX_PPPD_ARGUMENTS) 1214 while(arglist.count() > MAX_PPPD_ARGUMENTS)
1215 arglist.remove(arglist.last()); 1215 arglist.remove(arglist.last());
1216 readListConfig(cgroup, PPPDARG_KEY, arglist); 1216 readListConfig(cgroup, PPPDARG_KEY, arglist);
1217 1217
1218 return arglist; 1218 return arglist;
1219} 1219}
1220 1220
1221 1221
1222void PPPData::setpppdArgument(QStringList &args) { 1222void PPPData::setpppdArgument(QStringList &args) {
1223 writeListConfig(cgroup, PPPDARG_KEY, args); 1223 writeListConfig(cgroup, PPPDARG_KEY, args);
1224} 1224}
1225 1225
1226 1226
1227void PPPData::setpppdArgumentDefaults() { 1227void PPPData::setpppdArgumentDefaults() {
1228 QStringList arg; 1228 QStringList arg;
1229 arg << "lcp-echo-failure 0"; 1229 arg << "lcp-echo-failure 0";
1230 setpppdArgument(arg); 1230 setpppdArgument(arg);
1231} 1231}
1232 1232
1233 1233
1234// // graphing widget 1234// // graphing widget
1235// void PPPData::setGraphingOptions(bool enable, 1235// void PPPData::setGraphingOptions(bool enable,
1236 // QColor bg, 1236 // QColor bg,
1237 // QColor text, 1237 // QColor text,
1238 // QColor in, 1238 // QColor in,
1239 // QColor out) 1239 // QColor out)
1240// { 1240// {
1241// if(config) { 1241// if(config) {
1242// config->setGroup(GRAPH_GRP); 1242// config->setGroup(GRAPH_GRP);
1243// config->writeEntry(GENABLED, enable); 1243// config->writeEntry(GENABLED, enable);
1244// // config->writeEntry(GCOLOR_BG, bg); 1244// // config->writeEntry(GCOLOR_BG, bg);
1245// // config->writeEntry(GCOLOR_TEXT, text); 1245// // config->writeEntry(GCOLOR_TEXT, text);
1246// // config->writeEntry(GCOLOR_IN, in); 1246// // config->writeEntry(GCOLOR_IN, in);
1247// // config->writeEntry(GCOLOR_OUT, out); 1247// // config->writeEntry(GCOLOR_OUT, out);
1248// } 1248// }
1249// } 1249// }
1250 1250
1251// void PPPData::graphingOptions(bool &enable, 1251// void PPPData::graphingOptions(bool &enable,
1252 // QColor &bg, 1252 // QColor &bg,
1253 // QColor &text, 1253 // QColor &text,
1254 // QColor &in, 1254 // QColor &in,
1255 // QColor &out) 1255 // QColor &out)
1256// { 1256// {
1257// QColor c; 1257// QColor c;
1258 1258
1259// if(config) { 1259// if(config) {
1260// config->setGroup(GRAPH_GRP); 1260// config->setGroup(GRAPH_GRP);
1261// enable = config->readBoolEntry(GENABLED, true); 1261// enable = config->readBoolEntry(GENABLED, true);
1262// bg = Qt::white; 1262// bg = Qt::white;
1263// //bg = config->readColorEntry(GCOLOR_BG, &c); 1263// //bg = config->readColorEntry(GCOLOR_BG, &c);
1264// text = Qt::black; 1264// text = Qt::black;
1265// //text = config->readColorEntry(GCOLOR_TEXT, &c); 1265// //text = config->readColorEntry(GCOLOR_TEXT, &c);
1266// in = Qt::blue; 1266// in = Qt::blue;
1267// //in = config->readColorEntry(GCOLOR_IN, &c); 1267// //in = config->readColorEntry(GCOLOR_IN, &c);
1268// out = Qt::red; 1268// out = Qt::red;
1269// //out = config->readColorEntry(GCOLOR_OUT, &c); 1269// //out = config->readColorEntry(GCOLOR_OUT, &c);
1270// } 1270// }
1271// } 1271// }
1272 1272
1273 1273
1274// bool PPPData::graphingEnabled() { 1274// bool PPPData::graphingEnabled() {
1275// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); 1275// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
1276// } 1276// }
1277 1277
1278 1278
1279 1279
1280// 1280//
1281//functions to change/set the child pppd process info 1281//functions to change/set the child pppd process info
1282// 1282//
1283bool PPPData::pppdRunning() const { 1283bool PPPData::pppdRunning() const {
1284 return pppdisrunning; 1284 return pppdisrunning;
1285} 1285}
1286 1286
1287void PPPData::setpppdRunning(bool set) { 1287void PPPData::setpppdRunning(bool set) {
1288 pppdisrunning = set; 1288 pppdisrunning = set;
1289} 1289}
1290 1290
1291int PPPData::pppdError() const { 1291int PPPData::pppdError() const {
1292 return pppderror; 1292 return pppderror;
1293} 1293}
1294 1294
1295void PPPData::setpppdError(int err) { 1295void PPPData::setpppdError(int err) {
1296 pppderror = err; 1296 pppderror = err;
1297} 1297}
1298 1298
1299QString PPPData::modemGroup() 1299QString PPPData::modemGroup()
1300{ 1300{
1301 if (_modemName.isEmpty()) 1301 if (_modemName.isEmpty())
1302 _modemName = deviceList[0]; 1302 _modemName = deviceList[0];
1303 return _modemName; 1303 return _modemName;
1304} 1304}
1305 1305
1306 1306
1307QMap<QString,QString> PPPData::getConfiguredInterfaces() 1307QMap<QString,QString> PPPData::getConfiguredInterfaces()
1308{ 1308{
1309 QMap<QString,QString> ifaces; 1309 QMap<QString,QString> ifaces;
1310 Config config = PPPData::config(); 1310 Config config = PPPData::config();
1311 config.setGroup(ACCLIST_GRP); 1311 config.setGroup(ACCLIST_GRP);
1312 int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); 1312 int count = config.readNumEntry( ACCOUNTS_COUNT, -1 );
1313 QString accGrp, dev, acc; 1313 QString accGrp, dev, acc;
1314 for (int i = 0; i < count; i++){ 1314 for (int i = 0; i < count; i++){
1315 accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); 1315 accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i);
1316 config.setGroup(accGrp); 1316 config.setGroup(accGrp);
1317 dev = config.readEntry( ACOUNTS_DEV, "error" ); 1317 dev = config.readEntry( ACOUNTS_DEV, "error" );
1318 acc = config.readEntry( ACOUNTS_ACC, "error" ); 1318 acc = config.readEntry( ACOUNTS_ACC, "error" );
1319 ifaces.insert( dev, acc ); 1319 ifaces.insert( dev, acc );
1320 } 1320 }
1321 1321
1322 return ifaces; 1322 return ifaces;
1323} 1323}
1324 1324
1325void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) 1325void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces )
1326{ 1326{
1327 QMap<QString,QString>::Iterator it; 1327 QMap<QString,QString>::Iterator it;
1328 int i = 0; 1328 int i = 0;
1329 Config cfg = config(); 1329 Config cfg = config();
1330 for( it = ifaces.begin(); it != ifaces.end(); ++it ){ 1330 for( it = ifaces.begin(); it != ifaces.end(); ++it ){
1331 cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); 1331 cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++));
1332 cfg.writeEntry( ACOUNTS_DEV, it.key() ); 1332 cfg.writeEntry( ACOUNTS_DEV, it.key() );
1333 cfg.writeEntry( ACOUNTS_ACC, it.data() ); 1333 cfg.writeEntry( ACOUNTS_ACC, it.data() );
1334 odebug << "I " << i << "" << oendl; 1334 odebug << "I " << i << "" << oendl;
1335 } 1335 }
1336 cfg.setGroup( ACCLIST_GRP ); 1336 cfg.setGroup( ACCLIST_GRP );
1337 odebug << "saved " << i << " account settings" << oendl; 1337 odebug << "saved " << i << " account settings" << oendl;
1338 cfg.writeEntry( ACCOUNTS_COUNT, i ); 1338 cfg.writeEntry( ACCOUNTS_COUNT, i );
1339 1339
1340} 1340}
1341 1341
1342/** 1342/**
1343 * pppd's getword() function knows about escape characters. 1343 * pppd's getword() function knows about escape characters.
1344 * If we write the username and password to the secrets file 1344 * If we write the username and password to the secrets file
1345 * we'll therefore have to escape back slashes. 1345 * we'll therefore have to escape back slashes.
1346 */ 1346 */
1347QString PPPData::encodeWord(const QString &s) { 1347QString PPPData::encodeWord(const QString &s) {
1348 QString r = s; 1348 QString r = s;
1349 r.replace(QRegExp("\\"), "\\\\"); 1349 r.replace(QRegExp("\\"), "\\\\");
1350 return r; 1350 return r;
1351} 1351}
1352 1352
1353QStringList PPPData::getDevicesList() 1353QStringList PPPData::getDevicesList()
1354{ 1354{
1355 Config cfg("NetworkSetupPPP"); 1355 Config cfg("NetworkSetupPPP");
1356 cfg.setGroup("Devices_General"); 1356 cfg.setGroup("Devices_General");
1357 return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP); 1357 return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP);
1358} 1358}
1359 1359
1360QStringList PPPData::getAccountList() 1360QStringList PPPData::getAccountList()
1361{ 1361{
1362 QStringList list; 1362 QStringList list;
1363 QString save_cgroup; 1363 QString save_cgroup;
1364 save_cgroup = cgroup; 1364 save_cgroup = cgroup;
1365 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { 1365 for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) {
1366 cgroup = *it; 1366 cgroup = *it;
1367 list << accname(); 1367 list << accname();
1368 } 1368 }
1369 cgroup = save_cgroup; 1369 cgroup = save_cgroup;
1370 return list; 1370 return list;
1371}; 1371};
1372 1372
1373 1373
1374const QString PPPData::devname() 1374const QString PPPData::devname()
1375{ 1375{
1376 QString tmp = readConfig(modemGroup(), MODEMNAME_KEY ); 1376 QString tmp = readConfig(modemGroup(), MODEMNAME_KEY );
1377 odebug << "PPPData::devname() of " << modemGroup().latin1() << " is " << tmp.latin1() << "" << oendl; 1377 odebug << "PPPData::devname() of " << modemGroup().latin1() << " is " << tmp.latin1() << "" << oendl;
1378 return tmp; 1378 return tmp;
1379} 1379}
1380 1380
1381void PPPData::setDevname(const QString &n) { 1381void PPPData::setDevname(const QString &n) {
1382 // if(!cgroup.isNull()) { 1382 // if(!cgroup.isNull()) {
1383// // are we manipulating the default account's name ? then change it, too. 1383// // are we manipulating the default account's name ? then change it, too.
1384// bool def = accname() == defaultAccount(); 1384// bool def = accname() == defaultAccount();
1385// writeConfig(cgroup, NAME_KEY, n); 1385// writeConfig(cgroup, NAME_KEY, n);
1386// if (def) 1386// if (def)
1387// setDefaultAccount(n); 1387// setDefaultAccount(n);
1388// } 1388// }
1389 writeConfig(modemGroup(), MODEMNAME_KEY, n ); 1389 writeConfig(modemGroup(), MODEMNAME_KEY, n );
1390} 1390}
1391 1391
1392 1392
1393bool PPPData::setDevice(const QString &dev ) 1393bool PPPData::setDevice(const QString &dev )
1394{ 1394{
1395 odebug << "setting device to >" << dev.latin1() << "<" << oendl; 1395 odebug << "setting device to >" << dev.latin1() << "<" << oendl;
1396 QString save_mName = _modemName; 1396 QString save_mName = _modemName;
1397 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { 1397 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
1398 _modemName = *it; 1398 _modemName = *it;
1399 odebug << "PPPData::setDevice " << _modemName.latin1() << " is named " << devname().latin1() << "" << oendl; 1399 odebug << "PPPData::setDevice " << _modemName.latin1() << " is named " << devname().latin1() << "" << oendl;
1400 odebug << "iterator " << (*it).latin1() << "" << oendl; 1400 odebug << "iterator " << (*it).latin1() << "" << oendl;
1401 if(devname() == dev) { 1401 if(devname() == dev) {
1402 odebug << "SUCCESS" << oendl; 1402 odebug << "SUCCESS" << oendl;
1403 return true; 1403 return true;
1404 } 1404 }
1405 1405
1406 } 1406 }
1407 _modemName = save_mName; 1407 _modemName = save_mName;
1408 odebug << "FAILURE" << oendl; 1408 odebug << "FAILURE" << oendl;
1409 return false; 1409 return false;
1410} 1410}
1411 1411
1412bool PPPData::deleteDevice() 1412bool PPPData::deleteDevice()
1413{ 1413{
1414 // FIXME: check if this account exists in a config... 1414 // FIXME: check if this account exists in a config...
1415 Config cfg = PPPData::config(); 1415 Config cfg = PPPData::config();
1416 cfg.setGroup(modemGroup()); 1416 cfg.setGroup(modemGroup());
1417 cfg.clearGroup(); 1417 cfg.clearGroup();
1418 deviceList.remove(modemGroup()); 1418 deviceList.remove(modemGroup());
1419 1419
1420 QString key; 1420 QString key;
1421 QStringList keys; 1421 QStringList keys;
1422 for( QMap<QString,QString>::Iterator it = stringEntries.begin(); 1422 for( QMap<QString,QString>::Iterator it = stringEntries.begin();
1423 it != stringEntries.end(); ++it ){ 1423 it != stringEntries.end(); ++it ){
1424 QString val = it.data(); 1424 QString val = it.data();
1425 key = it.key(); 1425 key = it.key();
1426 keys = QStringList::split( "SEPARATOR", key ); 1426 keys = QStringList::split( "SEPARATOR", key );
1427 if(keys[0]==modemGroup()){ 1427 if(keys[0]==modemGroup()){
1428 stringEntries.remove( it ); 1428 stringEntries.remove( it );
1429 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; 1429 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl;
1430 } 1430 }
1431 } 1431 }
1432 for( QMap<QString,int>::Iterator it = intEntries.begin(); 1432 for( QMap<QString,int>::Iterator it = intEntries.begin();
1433 it != intEntries.end(); ++it ){ 1433 it != intEntries.end(); ++it ){
1434 int val = it.data(); 1434 int val = it.data();
1435 key = it.key(); 1435 key = it.key();
1436 keys = QStringList::split( "SEPARATOR", key ); 1436 keys = QStringList::split( "SEPARATOR", key );
1437 if(keys[0]==modemGroup()){ 1437 if(keys[0]==modemGroup()){
1438 intEntries.remove( it ); 1438 intEntries.remove( it );
1439 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl; 1439 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val << "<" << oendl;
1440 } 1440 }
1441 } 1441 }
1442 for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); 1442 for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
1443 it != listEntries.end(); ++it ){ 1443 it != listEntries.end(); ++it ){
1444 QStringList val = it.data(); 1444 QStringList val = it.data();
1445 key = it.key(); 1445 key = it.key();
1446 if(keys[0]==modemGroup()){ 1446 if(keys[0]==modemGroup()){
1447 listEntries.remove( it ); 1447 listEntries.remove( it );
1448 sepEntries.remove( key ); 1448 sepEntries.remove( key );
1449 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl; 1449 odebug << "deleting >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.join("").latin1() << "<" << oendl;
1450 } 1450 }
1451 } 1451 }
1452 1452
1453 return true; 1453 return true;
1454 1454
1455} 1455}
1456 1456
1457bool PPPData::deleteDevice(const QString &dev) 1457bool PPPData::deleteDevice(const QString &dev)
1458{ 1458{
1459 if(!setDevice(dev)) 1459 if(!setDevice(dev))
1460 return false; 1460 return false;
1461 1461
1462 return deleteDevice(); 1462 return deleteDevice();
1463} 1463}
1464 1464
1465int PPPData::newdevice() 1465int PPPData::newdevice()
1466{ 1466{
1467 1467
1468 odebug << "PPPData::newdevice highcount " << highcountdev << "" << oendl; 1468 odebug << "PPPData::newdevice highcount " << highcountdev << "" << oendl;
1469 1469
1470 1470
1471 QString tmp; 1471 QString tmp;
1472 tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev); 1472 tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev);
1473 _modemName = QString(tmp); 1473 _modemName = QString(tmp);
1474 deviceList << tmp; 1474 deviceList << tmp;
1475 odebug << "PPPData::newdevice() Group: >" << cgroup.latin1() << "<" << oendl; 1475 odebug << "PPPData::newdevice() Group: >" << cgroup.latin1() << "<" << oendl;
1476 return highcountdev; 1476 return highcountdev;
1477} 1477}
1478 1478
1479int PPPData::copydevice(const QString&) 1479int PPPData::copydevice(const QString&)
1480{ 1480{
1481 return false; 1481 return false;
1482} 1482}
1483 1483
1484 1484
1485QStringList PPPData::getDevicesNamesList() 1485QStringList PPPData::getDevicesNamesList()
1486{ 1486{
1487 QStringList list; 1487 QStringList list;
1488 QString save_mName = _modemName; 1488 QString save_mName = _modemName;
1489 odebug << "PPPData::getDevicesNamesList has " << deviceList.join("---").latin1() << "" << oendl; 1489 odebug << "PPPData::getDevicesNamesList has " << deviceList.join("---").latin1() << "" << oendl;
1490 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { 1490 for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) {
1491 _modemName = *it; 1491 _modemName = *it;
1492 odebug << "PPPData::getDevicesNamesList adding " << _modemName.latin1() << " as " << devname().latin1() << "" << oendl; 1492 odebug << "PPPData::getDevicesNamesList adding " << _modemName.latin1() << " as " << devname().latin1() << "" << oendl;
1493 list << devname(); 1493 list << devname();
1494 } 1494 }
1495 _modemName = save_mName; 1495 _modemName = save_mName;
1496 return list; 1496 return list;
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index d1cbeb5..d731b62 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -1,467 +1,478 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 * 2 *
3 * kPPP: A pppd front end for the KDE project 3 * kPPP: A pppd front end for the KDE project
4 * 4 *
5 * $Id$ 5 * $Id$
6 * 6 *
7 * Copyright (C) 1997 Bernd Johannes Wuebben 7 * Copyright (C) 1997 Bernd Johannes Wuebben
8 * wuebben@math.cornell.edu 8 * wuebben@math.cornell.edu
9 * 9 *
10 * based on EzPPP: 10 * based on EzPPP:
11 * Copyright (C) 1997 Jay Painter 11 * Copyright (C) 1997 Jay Painter
12 * 12 *
13 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public 14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either 15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version. 16 * version 2 of the License, or (at your option) any later version.
17 * 17 *
18 * This program is distributed in the hope that it will be useful, 18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details. 21 * Library General Public License for more details.
22 * 22 *
23 * You should have received a copy of the GNU Library General Public 23 * You should have received a copy of the GNU Library General Public
24 * License along with this program; if not, write to the Free 24 * License along with this program; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 26 */
27 27
28#ifndef _PPPDATA_H_ 28#ifndef _PPPDATA_H_
29#define _PPPDATA_H_ 29#define _PPPDATA_H_
30 30
31#include <unistd.h> 31#include <unistd.h>
32#include <sys/types.h> 32#include <sys/types.h>
33 33
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qmap.h> 35#include <qmap.h>
36#include <qstring.h> 36#include <qstring.h>
37#include <qstringlist.h> 37#include <qstringlist.h>
38 38
39#include "kpppconfig.h" 39#include "kpppconfig.h"
40 40
41class Config; 41class Config;
42 42
43// string lengths 43// string lengths
44 44
45#define PATH_SIZE 120 45#define PATH_SIZE 120
46#define MODEMSTR_SIZE 80 46#define MODEMSTR_SIZE 80
47#define ACCNAME_SIZE 50 47#define ACCNAME_SIZE 50
48#define PHONENUMBER_SIZE 60 48#define PHONENUMBER_SIZE 60
49#define COMMAND_SIZE 255 49#define COMMAND_SIZE 255
50#define IPADDR_SIZE 15 50#define IPADDR_SIZE 15
51#define DOMAIN_SIZE 50 51#define DOMAIN_SIZE 50
52#define TIMEOUT_SIZE 60 52#define TIMEOUT_SIZE 60
53 53
54// 54//
55// keys for config file 55// keys for config file
56// 56//
57 57
58// groups 58// groups
59#define GENERAL_GRP "PPP_General" 59#define GENERAL_GRP "PPP_General"
60#define MODEM_GRP "PPP_Modem" 60#define MODEM_GRP "PPP_Modem"
61#define ACCOUNT_GRP "PPP_Account" 61#define ACCOUNT_GRP "PPP_Account"
62#define ACCLIST_GRP "PPP_Accounts_List" 62#define ACCLIST_GRP "PPP_Accounts_List"
63//#define GRAPH_GRP "Graph" 63//#define GRAPH_GRP "Graph"
64//#define WINPOS_GRP "WindowPosition" 64//#define WINPOS_GRP "WindowPosition"
65 65
66// general 66// general
67#define ACCOUNT_LIST "AccountList" 67#define ACCOUNT_LIST "AccountList"
68#define DEVICE_LIST "DeviceList" 68#define DEVICE_LIST "DeviceList"
69#define DEFAULTACCOUNT_KEY "DefaultAccount" 69#define DEFAULTACCOUNT_KEY "DefaultAccount"
70#define PPPDVERSION_KEY "pppdVersion" 70#define PPPDVERSION_KEY "pppdVersion"
71#define PPPDTIMEOUT_KEY "pppdTimeout" 71#define PPPDTIMEOUT_KEY "pppdTimeout"
72#define SHOWCLOCK_KEY "ShowClock" 72#define SHOWCLOCK_KEY "ShowClock"
73#define SHOWLOGWIN_KEY "ShowLogWindow" 73#define SHOWLOGWIN_KEY "ShowLogWindow"
74#define AUTOREDIAL_KEY "AutomaticRedial" 74#define AUTOREDIAL_KEY "AutomaticRedial"
75#define DISCONNECT_KEY "DisconnectOnXServerExit" 75#define DISCONNECT_KEY "DisconnectOnXServerExit"
76#define QUITONDISCONNECT_KEY "QuitOnDisconnect" 76#define QUITONDISCONNECT_KEY "QuitOnDisconnect"
77#define NUMACCOUNTS_KEY "HighcountAccounts" 77#define NUMACCOUNTS_KEY "HighcountAccounts"
78#define NUMDEVICES_KEY "HighcountDevices" 78#define NUMDEVICES_KEY "HighcountDevices"
79 #define ID_KEY "ID" 79 #define ID_KEY "ID"
80 80
81// modem 81// modem
82#define MODEMNAME_KEY "Modem_Name" 82#define MODEMNAME_KEY "Modem_Name"
83#define MODEMDEV_KEY "Device" 83#define MODEMDEV_KEY "Device"
84#define LOCKFILE_KEY "UseLockFile" 84#define LOCKFILE_KEY "UseLockFile"
85#define FLOWCONTROL_KEY "FlowControl" 85#define FLOWCONTROL_KEY "FlowControl"
86#define SPEED_KEY "Speed" 86#define SPEED_KEY "Speed"
87#define TIMEOUT_KEY "Timeout" 87#define TIMEOUT_KEY "Timeout"
88#define TONEDURATION_KEY "ToneDuration" 88#define TONEDURATION_KEY "ToneDuration"
89#define BUSYWAIT_KEY "BusyWait" 89#define BUSYWAIT_KEY "BusyWait"
90#define INITSTR_KEY "InitString" 90#define INITSTR_KEY "InitString"
91#define INITRESP_KEY "InitResponse" 91#define INITRESP_KEY "InitResponse"
92#define PREINITDELAY_KEY "PreInitDelay" 92#define PREINITDELAY_KEY "PreInitDelay"
93#define INITDELAY_KEY "InitDelay" 93#define INITDELAY_KEY "InitDelay"
94#define NODTDETECT_KEY "NoDialToneDetection" 94#define NODTDETECT_KEY "NoDialToneDetection"
95#define DIALTONEWAIT_KEY "WaitForDialTone" 95#define DIALTONEWAIT_KEY "WaitForDialTone"
96#define DIALSTR_KEY "DialString" 96#define DIALSTR_KEY "DialString"
97#define CONNECTRESP_KEY "ConnectResponse" 97#define CONNECTRESP_KEY "ConnectResponse"
98#define BUSYRESP_KEY "BusyResponse" 98#define BUSYRESP_KEY "BusyResponse"
99#define NOCARRIERRESP_KEY "NoCarrierResponse" 99#define NOCARRIERRESP_KEY "NoCarrierResponse"
100#define NODIALTONERESP_KEY "NoDialToneResp" 100#define NODIALTONERESP_KEY "NoDialToneResp"
101#define HANGUPSTR_KEY "HangupString" 101#define HANGUPSTR_KEY "HangupString"
102#define HANGUPRESP_KEY "HangUpResponse" 102#define HANGUPRESP_KEY "HangUpResponse"
103#define ANSWERSTR_KEY "AnswerString" 103#define ANSWERSTR_KEY "AnswerString"
104#define RINGRESP_KEY "RingResponse" 104#define RINGRESP_KEY "RingResponse"
105#define ANSWERRESP_KEY "AnswerResponse" 105#define ANSWERRESP_KEY "AnswerResponse"
106#define ENTER_KEY "Enter" 106#define ENTER_KEY "Enter"
107#define ESCAPESTR_KEY "EscapeString" 107#define ESCAPESTR_KEY "EscapeString"
108#define ESCAPERESP_KEY "EscapeResponse" 108#define ESCAPERESP_KEY "EscapeResponse"
109#define ESCAPEGUARDTIME_KEY "EscapeGuardTime" 109#define ESCAPEGUARDTIME_KEY "EscapeGuardTime"
110#define USECDLINE_KEY "UseCDLine" 110#define USECDLINE_KEY "UseCDLine"
111#define VOLUME_HIGH "VolumeHigh" 111#define VOLUME_HIGH "VolumeHigh"
112#define VOLUME_MEDIUM "VolumeMedium" 112#define VOLUME_MEDIUM "VolumeMedium"
113#define VOLUME_OFF "VolumeOff" 113#define VOLUME_OFF "VolumeOff"
114#define VOLUME_KEY "Volume" 114#define VOLUME_KEY "Volume"
115 115
116// account 116// account
117#define NAME_KEY "Name" 117#define NAME_KEY "Name"
118#define PHONENUMBER_KEY "Phonenumber" 118#define PHONENUMBER_KEY "Phonenumber"
119#define DIAL_PREFIX_KEY "DialPrefix" 119#define DIAL_PREFIX_KEY "DialPrefix"
120#define AUTH_KEY "Authentication" 120#define AUTH_KEY "Authentication"
121#define STORED_PASSWORD_KEY "Password" 121#define STORED_PASSWORD_KEY "Password"
122#define STORED_USERNAME_KEY "Username" 122#define STORED_USERNAME_KEY "Username"
123#define STORE_PASSWORD_KEY "StorePassword" 123#define STORE_PASSWORD_KEY "StorePassword"
124#define BEFORE_CONNECT_KEY "BeforeConnect" 124#define BEFORE_CONNECT_KEY "BeforeConnect"
125#define COMMAND_KEY "Command" 125#define COMMAND_KEY "Command"
126#define DISCONNECT_COMMAND_KEY "DisconnectCommand" 126#define DISCONNECT_COMMAND_KEY "DisconnectCommand"
127#define BEFORE_DISCONNECT_KEY "BeforeDisconnect" 127#define BEFORE_DISCONNECT_KEY "BeforeDisconnect"
128#define IPADDR_KEY "IPAddr" 128#define IPADDR_KEY "IPAddr"
129#define SUBNETMASK_KEY "SubnetMask" 129#define SUBNETMASK_KEY "SubnetMask"
130#define ACCTENABLED_KEY "AccountingEnabled" 130#define ACCTENABLED_KEY "AccountingEnabled"
131#define VOLACCTENABLED_KEY "VolumeAccountingEnabled" 131#define VOLACCTENABLED_KEY "VolumeAccountingEnabled"
132#define ACCTFILE_KEY "AccountingFile" 132#define ACCTFILE_KEY "AccountingFile"
133#define AUTONAME_KEY "AutoName" 133#define AUTONAME_KEY "AutoName"
134#define GATEWAY_KEY "Gateway" 134#define GATEWAY_KEY "Gateway"
135#define DEFAULTROUTE_KEY "DefaultRoute" 135#define DEFAULTROUTE_KEY "DefaultRoute"
136#define DOMAIN_KEY "Domain" 136#define DOMAIN_KEY "Domain"
137#define DNS_KEY "DNS" 137#define DNS_KEY "DNS"
138#define AUTODNS_KEY "AutoDNS" 138#define AUTODNS_KEY "AutoDNS"
139#define EXDNSDISABLED_KEY "ExDNSDisabled" 139#define EXDNSDISABLED_KEY "ExDNSDisabled"
140#define SCRIPTCOM_KEY "ScriptCommands" 140#define SCRIPTCOM_KEY "ScriptCommands"
141#define SCRIPTARG_KEY "ScriptArguments" 141#define SCRIPTARG_KEY "ScriptArguments"
142#define PPPDARG_KEY "pppdArguments" 142#define PPPDARG_KEY "pppdArguments"
143#define PPP_DEBUG_OPTION "PPPDebug" 143#define PPP_DEBUG_OPTION "PPPDebug"
144#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" 144#define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect"
145#define DOCKING_KEY "DockIntoPanel" 145#define DOCKING_KEY "DockIntoPanel"
146#define TOTALCOSTS_KEY "TotalCosts" 146#define TOTALCOSTS_KEY "TotalCosts"
147#define TOTALBYTES_KEY "TotalBytes" 147#define TOTALBYTES_KEY "TotalBytes"
148 148
149// pppd errors 149// pppd errors
150#define E_IF_TIMEOUT 1 150#define E_IF_TIMEOUT 1
151#define E_PPPD_DIED 2 151#define E_PPPD_DIED 2
152 152
153// account list 153// account list
154#define ACCOUNTS_COUNT "Accounts_Count" 154#define ACCOUNTS_COUNT "Accounts_Count"
155#define ACOUNTS_DEV "Accounts_Modem" 155#define ACOUNTS_DEV "Accounts_Modem"
156#define ACOUNTS_ACC "Accounts_Account" 156#define ACOUNTS_ACC "Accounts_Account"
157 157
158#define DEVICESNAMES_LIST "DevicesNames_List" 158#define DEVICESNAMES_LIST "DevicesNames_List"
159#define DEVICES_LIST "Devices_List" 159#define DEVICES_LIST "Devices_List"
160#define DEVICES_LIST_SEP ',' 160#define DEVICES_LIST_SEP ','
161 161
162class PPPData { 162class PPPData {
163public: 163public:
164 PPPData(); 164 PPPData();
165 ~PPPData() {}; 165 ~PPPData() {};
166 166
167 enum { NumInitStrings = 2 }; 167 enum { NumInitStrings = 2 };
168 enum LineTermination {
169 EndCR,
170 EndLF,
171 EndCRLF
172 };
173
174 enum FlowControl {
175 FlowHardware,
176 FlowSoftware,
177 FlowNone
178 };
168 179
169 // general functions 180 // general functions
170 void save(); 181 void save();
171 void cancel(); 182 void cancel();
172 183
173 QStringList getAccountList(); 184 QStringList getAccountList();
174 185
175 static QMap<QString,QString> getConfiguredInterfaces(); 186 static QMap<QString,QString> getConfiguredInterfaces();
176 static void setConfiguredInterfaces( QMap<QString,QString> ); 187 static void setConfiguredInterfaces( QMap<QString,QString> );
177 188
178 // function to read/write date to configuration file 189 // function to read/write date to configuration file
179 static Config config(); 190 static Config config();
180 QString readConfig(const QString &, const QString &, const QString &); 191 QString readConfig(const QString &, const QString &, const QString &);
181 int readNumConfig(const QString &, const QString &, int); 192 int readNumConfig(const QString &, const QString &, int);
182 bool readListConfig(const QString &, const QString &, 193 bool readListConfig(const QString &, const QString &,
183 QStringList &, char sep = ','); 194 QStringList &, char sep = ',');
184 void writeConfig(const QString &, const QString &, const QString &); 195 void writeConfig(const QString &, const QString &, const QString &);
185 void writeConfig(const QString &, const QString &, int); 196 void writeConfig(const QString &, const QString &, int);
186 void writeListConfig(const QString &, const QString &, 197 void writeListConfig(const QString &, const QString &,
187 QStringList &, char sep = ','); 198 QStringList &, char sep = ',');
188 199
189 // return the current account group 200 // return the current account group
190 QString currentGroup() { return cgroup; } 201 QString currentGroup() { return cgroup; }
191 QString modemGroup(); 202 QString modemGroup();
192 203
193 // functions to set/get general kppp info 204 // functions to set/get general kppp info
194 QString password(); 205 QString password();
195 void setPassword(const QString &); 206 void setPassword(const QString &);
196 207
197// int currentAccountID() { return caccount; }; 208// int currentAccountID() { return caccount; };
198 const QString defaultAccount(); 209 const QString defaultAccount();
199 void setDefaultAccount(const QString &); 210 void setDefaultAccount(const QString &);
200 211
201 void set_xserver_exit_disconnect(bool set); 212 void set_xserver_exit_disconnect(bool set);
202 bool get_xserver_exit_disconnect(); 213 bool get_xserver_exit_disconnect();
203 214
204 void setPPPDebug(bool set); 215 void setPPPDebug(bool set);
205 bool getPPPDebug(); 216 bool getPPPDebug();
206 217
207 void set_quit_on_disconnect(bool); 218 void set_quit_on_disconnect(bool);
208 bool quit_on_disconnect(); 219 bool quit_on_disconnect();
209 220
210 void set_show_clock_on_caption(bool set); 221 void set_show_clock_on_caption(bool set);
211 bool get_show_clock_on_caption(); 222 bool get_show_clock_on_caption();
212 223
213 void set_show_log_window(bool set); 224 void set_show_log_window(bool set);
214 bool get_show_log_window(); 225 bool get_show_log_window();
215 226
216 void set_automatic_redial(bool set); 227 void set_automatic_redial(bool set);
217 bool automatic_redial(); 228 bool automatic_redial();
218 229
219// void set_iconify_on_connect(bool set); 230// void set_iconify_on_connect(bool set);
220// bool get_iconify_on_connect(); 231// bool get_iconify_on_connect();
221 232
222// void set_dock_into_panel(bool set); 233// void set_dock_into_panel(bool set);
223// bool get_dock_into_panel(); 234// bool get_dock_into_panel();
224 235
225 const QString enter(); 236 enum LineTermination enter();
226 void setEnter(const QString &); 237 void setEnter(enum LineTermination);
227 238
228 QString pppdVersion(); 239 QString pppdVersion();
229 bool pppdVersionMin(int ver, int mod, int patch); 240 bool pppdVersionMin(int ver, int mod, int patch);
230 241
231 int pppdTimeout(); 242 int pppdTimeout();
232 void setpppdTimeout(int); 243 void setpppdTimeout(int);
233 244
234 int busyWait(); 245 int busyWait();
235 void setbusyWait(int); 246 void setbusyWait(int);
236 247
237 bool modemLockFile(); 248 bool modemLockFile();
238 void setModemLockFile(bool set); 249 void setModemLockFile(bool set);
239 250
240 int modemEscapeGuardTime(); 251 int modemEscapeGuardTime();
241 void setModemEscapeGuardTime(int i); 252 void setModemEscapeGuardTime(int i);
242 253
243 void setModemEscapeStr(const QString &); 254 void setModemEscapeStr(const QString &);
244 const QString modemEscapeStr(); 255 const QString modemEscapeStr();
245 256
246 void setModemEscapeResp(const QString &); 257 void setModemEscapeResp(const QString &);
247 const QString modemEscapeResp(); 258 const QString modemEscapeResp();
248 259
249// const QString modemName(); 260// const QString modemName();
250// bool setModemName(const QString &); 261// bool setModemName(const QString &);
251// bool changeModemName(const QString &); 262// bool changeModemName(const QString &);
252 263
253 const QString modemDevice(); 264 const QString modemDevice();
254 bool setModemDevice(const QString &); 265 bool setModemDevice(const QString &);
255 266
256 const QString flowcontrol(); 267 enum FlowControl flowcontrol();
257 void setFlowcontrol(const QString &); 268 void setFlowcontrol(enum FlowControl);
258 269
259 int modemTimeout(); 270 int modemTimeout();
260 void setModemTimeout(int); 271 void setModemTimeout(int);
261 272
262 int modemToneDuration(); 273 int modemToneDuration();
263 void setModemToneDuration(int); 274 void setModemToneDuration(int);
264 275
265 QString volumeInitString(); 276 QString volumeInitString();
266 int volume(); 277 int volume();
267 void setVolume(int); 278 void setVolume(int);
268 279
269 int waitForDialTone(); 280 int waitForDialTone();
270 void setWaitForDialTone(int i); 281 void setWaitForDialTone(int i);
271 282
272 // modem command strings/responses 283 // modem command strings/responses
273 const QString modemInitStr(int i); 284 const QString modemInitStr(int i);
274 void setModemInitStr(int i, const QString &); 285 void setModemInitStr(int i, const QString &);
275 286
276 const QString modemInitResp(); 287 const QString modemInitResp();
277 void setModemInitResp(const QString &); 288 void setModemInitResp(const QString &);
278 289
279 int modemPreInitDelay(); 290 int modemPreInitDelay();
280 void setModemPreInitDelay(int); 291 void setModemPreInitDelay(int);
281 292
282 int modemInitDelay(); 293 int modemInitDelay();
283 void setModemInitDelay(int); 294 void setModemInitDelay(int);
284 295
285 QString modemNoDialToneDetectionStr(); 296 QString modemNoDialToneDetectionStr();
286 void setModemNoDialToneDetectionStr(const QString &); 297 void setModemNoDialToneDetectionStr(const QString &);
287 298
288 const QString modemDialStr(); 299 const QString modemDialStr();
289 void setModemDialStr(const QString &); 300 void setModemDialStr(const QString &);
290 301
291 const QString modemConnectResp(); 302 const QString modemConnectResp();
292 void setModemConnectResp(const QString &); 303 void setModemConnectResp(const QString &);
293 304
294 const QString modemBusyResp(); 305 const QString modemBusyResp();
295 void setModemBusyResp(const QString &); 306 void setModemBusyResp(const QString &);
296 307
297 const QString modemNoCarrierResp(); 308 const QString modemNoCarrierResp();
298 void setModemNoCarrierResp(const QString &); 309 void setModemNoCarrierResp(const QString &);
299 310
300 const QString modemNoDialtoneResp(); 311 const QString modemNoDialtoneResp();
301 void setModemNoDialtoneResp(const QString &); 312 void setModemNoDialtoneResp(const QString &);
302 313
303 const QString modemHangupStr(); 314 const QString modemHangupStr();
304 void setModemHangupStr(const QString &); 315 void setModemHangupStr(const QString &);
305 316
306 const QString modemHangupResp(); 317 const QString modemHangupResp();
307 void setModemHangupResp(const QString &); 318 void setModemHangupResp(const QString &);
308 319
309 const QString modemAnswerStr(); 320 const QString modemAnswerStr();
310 void setModemAnswerStr(const QString &); 321 void setModemAnswerStr(const QString &);
311 322
312 const QString modemRingResp(); 323 const QString modemRingResp();
313 void setModemRingResp(const QString &); 324 void setModemRingResp(const QString &);
314 325
315 const QString modemAnswerResp(); 326 const QString modemAnswerResp();
316 void setModemAnswerResp(const QString &); 327 void setModemAnswerResp(const QString &);
317 328
318 QString volumeOff(); 329 QString volumeOff();
319 void setVolumeOff(const QString &); 330 void setVolumeOff(const QString &);
320 331
321 QString volumeMedium(); 332 QString volumeMedium();
322 void setVolumeMedium(const QString &); 333 void setVolumeMedium(const QString &);
323 334
324 QString volumeHigh(); 335 QString volumeHigh();
325 void setVolumeHigh(const QString &); 336 void setVolumeHigh(const QString &);
326 337
327 // functions to set/get account information 338 // functions to set/get account information
328 int count() const; 339 int count() const;
329 bool setAccount(const QString &); 340 bool setAccount(const QString &);
330// bool setAccountbyIndex(int); 341// bool setAccountbyIndex(int);
331 342
332 bool isUniqueAccname(const QString &); 343 bool isUniqueAccname(const QString &);
333 bool isUniqueDevname(const QString &); 344 bool isUniqueDevname(const QString &);
334 345
335 bool deleteAccount(); 346 bool deleteAccount();
336 bool deleteAccount(const QString &); 347 bool deleteAccount(const QString &);
337 int newaccount(); 348 int newaccount();
338 int copyaccount(const QString&); 349 int copyaccount(const QString&);
339 350
340 const QString accname(); 351 const QString accname();
341 void setAccname(const QString &); 352 void setAccname(const QString &);
342 353
343 QStringList &phonenumbers(); 354 QStringList &phonenumbers();
344 const QString phonenumber(); 355 const QString phonenumber();
345 void setPhonenumber(const QString &); 356 void setPhonenumber(const QString &);
346 357
347 const QString dialPrefix(); 358 const QString dialPrefix();
348 void setDialPrefix(const QString &); 359 void setDialPrefix(const QString &);
349 360
350 int authMethod(); 361 int authMethod();
351 void setAuthMethod(int); 362 void setAuthMethod(int);
352 363
353 const QString storedUsername(); 364 const QString storedUsername();
354 void setStoredUsername(const QString &); 365 void setStoredUsername(const QString &);
355 366
356 const QString storedPassword(); 367 const QString storedPassword();
357 void setStoredPassword(const QString &); 368 void setStoredPassword(const QString &);
358 369
359 bool storePassword(); 370 bool storePassword();
360 void setStorePassword(bool); 371 void setStorePassword(bool);
361 372
362 const QString speed(); 373 const QString speed();
363 void setSpeed(const QString &); 374 void setSpeed(const QString &);
364 375
365 const QString command_before_connect(); 376 const QString command_before_connect();
366 void setCommand_before_connect(const QString &); 377 void setCommand_before_connect(const QString &);
367 378
368 const QString command_on_connect(); 379 const QString command_on_connect();
369 void setCommand_on_connect(const QString &); 380 void setCommand_on_connect(const QString &);
370 381
371 const QString command_on_disconnect(); 382 const QString command_on_disconnect();
372 void setCommand_on_disconnect(const QString &); 383 void setCommand_on_disconnect(const QString &);
373 384
374 const QString command_before_disconnect(); 385 const QString command_before_disconnect();
375 void setCommand_before_disconnect(const QString &); 386 void setCommand_before_disconnect(const QString &);
376 387
377 const QString ipaddr(); 388 const QString ipaddr();
378 void setIpaddr(const QString &); 389 void setIpaddr(const QString &);
379 390
380 const QString subnetmask(); 391 const QString subnetmask();
381 void setSubnetmask(const QString &); 392 void setSubnetmask(const QString &);
382 393
383 bool AcctEnabled(); 394 bool AcctEnabled();
384 void setAcctEnabled(bool set); 395 void setAcctEnabled(bool set);
385 396
386// int VolAcctEnabled(); 397// int VolAcctEnabled();
387// void setVolAcctEnabled(int set); 398// void setVolAcctEnabled(int set);
388 399
389 bool autoDNS(); 400 bool autoDNS();
390 void setAutoDNS(bool set); 401 void setAutoDNS(bool set);
391 402
392 bool exDNSDisabled(); 403 bool exDNSDisabled();
393 void setExDNSDisabled(bool set); 404 void setExDNSDisabled(bool set);
394 405
395 bool autoname(); 406 bool autoname();
396 void setAutoname(bool set); 407 void setAutoname(bool set);
397 408
398 const QString gateway(); 409 const QString gateway();
399 void setGateway(const QString &); 410 void setGateway(const QString &);
400 411
401 bool defaultroute(); 412 bool defaultroute();
402 void setDefaultroute(bool set); 413 void setDefaultroute(bool set);
403 414
404 QStringList &dns(); 415 QStringList &dns();
405 void setDns(QStringList &); 416 void setDns(QStringList &);
406 417
407 const QString domain(); 418 const QString domain();
408 void setDomain(const QString &); 419 void setDomain(const QString &);
409 420
410 QStringList &scriptType(); 421 QStringList &scriptType();
411 void setScriptType(QStringList &); 422 void setScriptType(QStringList &);
412 423
413 QStringList &script(); 424 QStringList &script();
414 void setScript(QStringList &); 425 void setScript(QStringList &);
415 426
416 QStringList &pppdArgument(); 427 QStringList &pppdArgument();
417 void setpppdArgumentDefaults(); 428 void setpppdArgumentDefaults();
418 void setpppdArgument(QStringList &); 429 void setpppdArgument(QStringList &);
419 430
420 //functions to change/set the child pppd process info 431 //functions to change/set the child pppd process info
421 bool pppdRunning() const; 432 bool pppdRunning() const;
422 void setpppdRunning(bool set); 433 void setpppdRunning(bool set);
423 434
424 int pppdError() const; 435 int pppdError() const;
425 void setpppdError(int err); 436 void setpppdError(int err);
426 437
427 QStringList getDevicesList(); 438 QStringList getDevicesList();
428 439
429 static QString encodeWord(const QString &s); 440 static QString encodeWord(const QString &s);
430 441
431 const QString devname(); 442 const QString devname();
432 void setDevname(const QString &); 443 void setDevname(const QString &);
433 bool setDevice(const QString& ); 444 bool setDevice(const QString& );
434 bool deleteDevice(); 445 bool deleteDevice();
435 bool deleteDevice(const QString &); 446 bool deleteDevice(const QString &);
436 int newdevice(); 447 int newdevice();
437 int copydevice(const QString&); 448 int copydevice(const QString&);
438 QStringList getDevicesNamesList(); 449 QStringList getDevicesNamesList();
439 450
440private: 451private:
441 452
442 //static PPPData *_data; 453 //static PPPData *_data;
443// int modemDeviceGroup; 454// int modemDeviceGroup;
444 QString passwd; 455 QString passwd;
445 QString _modemName; 456 QString _modemName;
446 int highcount; // index of highest account 457 int highcount; // index of highest account
447 int highcountdev; // index of highest device 458 int highcountdev; // index of highest device
448// int caccount; // index of the current account 459// int caccount; // index of the current account
449 QString cgroup; // name of current config group 460 QString cgroup; // name of current config group
450 pid_t suidprocessid; // process ID of setuid child 461 pid_t suidprocessid; // process ID of setuid child
451 bool pppdisrunning; // pppd process 462 bool pppdisrunning; // pppd process
452 // daemon 463 // daemon
453 int pppderror; // error encounterd running pppd 464 int pppderror; // error encounterd running pppd
454 int pppdVer, pppdMod, pppdPatch; // pppd version 465 int pppdVer, pppdMod, pppdPatch; // pppd version
455 466
456 467
457 QStringList phonelist; 468 QStringList phonelist;
458 QStringList accountList; 469 QStringList accountList;
459 QStringList deviceList; 470 QStringList deviceList;
460 QMap<QString,QString> stringEntries; 471 QMap<QString,QString> stringEntries;
461 QMap<QString,int> intEntries; 472 QMap<QString,int> intEntries;
462 QMap<QString,QStringList> listEntries; 473 QMap<QString,QStringList> listEntries;
463 QMap<QString,QChar> sepEntries; 474 QMap<QString,QChar> sepEntries;
464 475
465}; 476};
466 477
467#endif 478#endif