Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 66 |
1 files changed, 55 insertions, 11 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index d76353a..39031ed 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -58,12 +58,14 @@ NetworkSettingsData::NetworkSettingsData( void ) { | |||
58 | interfacename.latin1(), profilenr )); | 58 | interfacename.latin1(), profilenr )); |
59 | 59 | ||
60 | NC = NSResources->getConnection( profilenr ); | 60 | NC = NSResources->getConnection( profilenr ); |
61 | if( NC ) { | 61 | if( NC ) { |
62 | NC->assignInterface( | 62 | NC->assignInterface( |
63 | NSResources->system().findInterface( interfacename ) ); | 63 | NSResources->system().findInterface( interfacename ) ); |
64 | Log(( "Assign interface %p\n", | ||
65 | NC->assignedInterface() )); | ||
64 | } else { | 66 | } else { |
65 | Log(( "Profile nr %d no longer defined\n", | 67 | Log(( "Profile nr %d no longer defined\n", |
66 | profilenr )); | 68 | profilenr )); |
67 | } | 69 | } |
68 | } | 70 | } |
69 | } | 71 | } |
@@ -640,29 +642,31 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
640 | // end of file | 642 | // end of file |
641 | SF->close(); | 643 | SF->close(); |
642 | } | 644 | } |
643 | return S; | 645 | return S; |
644 | } | 646 | } |
645 | 647 | ||
646 | QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { | 648 | QList<NodeCollection> NetworkSettingsData::collectPossible( |
649 | const QString & Interface ) { | ||
647 | // collect connections that can work on top of this interface | 650 | // collect connections that can work on top of this interface |
648 | NodeCollection * NC; | 651 | NodeCollection * NC; |
649 | QList<NodeCollection> PossibleConnections; | 652 | QList<NodeCollection> PossibleConnections; |
650 | Name2Connection_t & M = NSResources->connections(); | 653 | Name2Connection_t & M = NSResources->connections(); |
651 | 654 | ||
652 | // for all connections | 655 | // for all connections |
653 | for( QDictIterator<NodeCollection> it(M); | 656 | for( QDictIterator<NodeCollection> it(M); |
654 | it.current(); | 657 | it.current(); |
655 | ++it ) { | 658 | ++it ) { |
656 | NC = it.current(); | 659 | NC = it.current(); |
657 | // check if this profile handles the requested interface | 660 | // check if this profile handles the requested interface |
658 | if( NC->handlesInterface( Interface ) && // if different Intf. | 661 | if( NC->handlesInterface( Interface ) && // if different Intf. |
659 | NC->state() != Disabled && // if not enabled | 662 | NC->state() != Disabled && // if enabled |
660 | NC->state() != IsUp // if already used | 663 | NC->state() != IsUp // if already used |
661 | ) { | 664 | ) { |
662 | Log( ( "Append %s for %s\n", NC->name().latin1(), Interface)); | 665 | Log( ( "Append %s for %s\n", |
666 | NC->name().latin1(), Interface.latin1() )); | ||
663 | PossibleConnections.append( NC ); | 667 | PossibleConnections.append( NC ); |
664 | } | 668 | } |
665 | } | 669 | } |
666 | return PossibleConnections; | 670 | return PossibleConnections; |
667 | } | 671 | } |
668 | 672 | ||
@@ -670,21 +674,21 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa | |||
670 | /* | 674 | /* |
671 | Called by the system to see if interface can be brought UP | 675 | Called by the system to see if interface can be brought UP |
672 | 676 | ||
673 | if allowed, echo Interface-allowed else Interface-disallowed | 677 | if allowed, echo Interface-allowed else Interface-disallowed |
674 | */ | 678 | */ |
675 | 679 | ||
676 | bool NetworkSettingsData::canStart( const char * Interface ) { | 680 | bool NetworkSettingsData::canStart( const QString & Interface ) { |
677 | // load situation | 681 | // load situation |
678 | NodeCollection * NC = 0; | 682 | NodeCollection * NC = 0; |
679 | QList<NodeCollection> PossibleConnections; | 683 | QList<NodeCollection> PossibleConnections; |
680 | 684 | ||
681 | PossibleConnections = collectPossible( Interface ); | 685 | PossibleConnections = collectPossible( Interface ); |
682 | 686 | ||
683 | Log( ( "for %s : Possiblilies %d\n", | 687 | Log( ( "for %s : Possiblilies %d\n", |
684 | Interface, PossibleConnections.count() )); | 688 | Interface.latin1(), PossibleConnections.count() )); |
685 | switch( PossibleConnections.count() ) { | 689 | switch( PossibleConnections.count() ) { |
686 | case 0 : // no connections | 690 | case 0 : // no connections |
687 | break; | 691 | break; |
688 | case 1 : // one connection | 692 | case 1 : // one connection |
689 | NC = PossibleConnections.first(); | 693 | NC = PossibleConnections.first(); |
690 | break; | 694 | break; |
@@ -703,31 +707,31 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
703 | break; | 707 | break; |
704 | case Off : | 708 | case Off : |
705 | // try to UP the device | 709 | // try to UP the device |
706 | { QString S= NC->setState( Activate ); | 710 | { QString S= NC->setState( Activate ); |
707 | if( ! S.isEmpty() ) { | 711 | if( ! S.isEmpty() ) { |
708 | // could not bring device Online -> try other alters | 712 | // could not bring device Online -> try other alters |
709 | Log(( "%s-c%d-disallowed : %s\n", | 713 | Log(( "disallow %ld for %s : %s\n", |
710 | Interface, NC->number(), S.latin1() )); | 714 | NC->number(), Interface.latin1(), S.latin1() )); |
711 | break; | 715 | break; |
712 | } | 716 | } |
713 | // interface assigned | 717 | // interface assigned |
714 | } | 718 | } |
715 | // FT | 719 | // FT |
716 | case Available : | 720 | case Available : |
717 | case IsUp : // also called for 'ifdown' | 721 | case IsUp : // also called for 'ifdown' |
718 | // device is ready -> done | 722 | // device is ready -> done |
719 | Log(( "%s-c%d-allowed\n", Interface, NC->number() )); | 723 | Log(( "allow %ld for %s\n", NC->number(), Interface.latin1())); |
720 | printf( "%s-c%d-allowed\n", Interface, NC->number() ); | 724 | printf( "A%ld%s\n", NC->number(), Interface.latin1() ); |
721 | return 0; | 725 | return 0; |
722 | } | 726 | } |
723 | } | 727 | } |
724 | 728 | ||
725 | // if we come here no alternatives are possible | 729 | // if we come here no alternatives are possible |
726 | Log(( "%s-cnn-disallowed\n", Interface )); | 730 | Log(( "disallow %s\n", Interface.latin1())); |
727 | printf( "%s-cnn-disallowed\n", Interface ); | 731 | printf( "D-%s\n", Interface.latin1() ); |
728 | return 0; | 732 | return 0; |
729 | } | 733 | } |
730 | 734 | ||
731 | bool NetworkSettingsData::isModified( void ) { | 735 | bool NetworkSettingsData::isModified( void ) { |
732 | if( ForceModified ) | 736 | if( ForceModified ) |
733 | return 1; | 737 | return 1; |
@@ -738,6 +742,46 @@ bool NetworkSettingsData::isModified( void ) { | |||
738 | if( it.current()->isModified() ) { | 742 | if( it.current()->isModified() ) { |
739 | return 1; | 743 | return 1; |
740 | } | 744 | } |
741 | } | 745 | } |
742 | return 0; | 746 | return 0; |
743 | } | 747 | } |
748 | |||
749 | bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { | ||
750 | // load situation | ||
751 | QList<NodeCollection> PossibleTriggered; | ||
752 | |||
753 | PossibleTriggered = collectTriggered( Interface ); | ||
754 | |||
755 | Log( ( "for %s : Possiblilies %d\n", | ||
756 | Interface.latin1(), PossibleTriggered.count() )); | ||
757 | |||
758 | return ( PossibleTriggered.count() ) ? 1 : 0; | ||
759 | } | ||
760 | |||
761 | QList<NodeCollection> NetworkSettingsData::collectTriggered( | ||
762 | const QString & Interface ) { | ||
763 | |||
764 | // collect connections that could be triggered by this interface | ||
765 | NodeCollection * NC; | ||
766 | QList<NodeCollection> PossibleTriggered; | ||
767 | |||
768 | // for all connections | ||
769 | Name2Connection_t & M = NSResources->connections(); | ||
770 | |||
771 | for( QDictIterator<NodeCollection> it(M); | ||
772 | it.current(); | ||
773 | ++it ) { | ||
774 | NC = it.current(); | ||
775 | // check if this profile handles the requested interface | ||
776 | if( NC->triggeredBy( Interface ) && // if different Intf. | ||
777 | NC->state() != Disabled && // if enabled | ||
778 | NC->state() != IsUp // if already used | ||
779 | ) { | ||
780 | Log( ( "Append %s for %s\n", | ||
781 | NC->name().latin1(), Interface.latin1() )); | ||
782 | PossibleTriggered.append( NC ); | ||
783 | } | ||
784 | } | ||
785 | return PossibleTriggered; | ||
786 | } | ||
787 | |||