Diffstat (limited to 'noncore/settings/networksettings2/usb/usbrun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/usb/usbrun.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index 49b5a77..3007e79 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp | |||
@@ -31,31 +31,42 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
31 | return; | 31 | return; |
32 | } | 32 | } |
33 | } | 33 | } |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | fprintf( stderr, "NUP\n" ); | 37 | fprintf( stderr, "Assigned %p\n", assignedInterface() ); |
38 | // definitively not up | 38 | if( ( Run = assignedInterface() ) ) { |
39 | // we already have an interface assigned -> still present ? | ||
40 | if( ! Run->IsUp ) { | ||
41 | // usb is still free -> keep assignment | ||
42 | NC->setCurrentState( Available ); | ||
43 | return; | ||
44 | } // else interface is up but NOT us -> some other profile | ||
45 | } | ||
46 | |||
47 | // nothing (valid) assigned to us | ||
39 | assignInterface( 0 ); | 48 | assignInterface( 0 ); |
40 | 49 | ||
41 | // find possible interface | 50 | // find possible interface |
42 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 51 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
43 | It.current(); | 52 | It.current(); |
44 | ++It ) { | 53 | ++It ) { |
45 | Run = It.current(); | 54 | Run = It.current(); |
55 | |||
46 | fprintf( stderr, "%s %d %d=%d %d\n", | 56 | fprintf( stderr, "%s %d %d=%d %d\n", |
47 | Run->Name.latin1(), | 57 | Run->Name.latin1(), |
48 | handlesInterface( Run->Name ), | 58 | handlesInterface( Run->Name ), |
49 | Run->CardType, ARPHRD_ETHER, | 59 | Run->CardType, ARPHRD_ETHER, |
50 | ! Run->IsUp ); | 60 | ! Run->IsUp ); |
61 | |||
51 | if( handlesInterface( Run->Name ) && | 62 | if( handlesInterface( Run->Name ) && |
52 | Run->CardType == ARPHRD_ETHER && | 63 | Run->CardType == ARPHRD_ETHER && |
53 | ! Run->IsUp | 64 | ! Run->IsUp |
54 | ) { | 65 | ) { |
55 | fprintf( stderr, "OFF\n" ); | 66 | fprintf( stderr, "Released(OFF)\n" ); |
56 | // proper type, and Not UP -> free | 67 | // proper type, and Not UP -> free |
57 | NC->setCurrentState( Off ); | 68 | NC->setCurrentState( Off ); |
58 | return; | 69 | return; |
59 | } | 70 | } |
60 | } | 71 | } |
61 | // no free found | 72 | // no free found |
@@ -80,23 +91,23 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) { | |||
80 | return 0; | 91 | return 0; |
81 | } | 92 | } |
82 | // because we were OFF the interface | 93 | // because we were OFF the interface |
83 | // we get back is NOT assigned | 94 | // we get back is NOT assigned |
84 | N->assignNode( netNode() ); | 95 | N->assignNode( netNode() ); |
85 | assignInterface( N ); | 96 | assignInterface( N ); |
97 | fprintf( stderr, "Assing %p\n", N ); | ||
86 | NC->setCurrentState( Available ); | 98 | NC->setCurrentState( Available ); |
87 | return 1; | 99 | return 1; |
88 | } | 100 | } |
89 | case Deactivate : | 101 | case Deactivate : |
90 | if( NC->currentState() == IsUp ) { | 102 | if( NC->currentState() == IsUp ) { |
91 | // bring down first | 103 | // bring down first |
92 | if( ! connection()->setState( Down ) ) | 104 | if( ! connection()->setState( Down ) ) |
93 | // could not ... | 105 | // could not ... |
94 | return 0; | 106 | return 0; |
95 | } | 107 | } else if( NC->currentState() != Available ) { |
96 | if( NC->currentState() != Available ) { | ||
97 | return 1; | 108 | return 1; |
98 | } | 109 | } |
99 | assignedInterface()->assignNode( 0 ); // release | 110 | assignedInterface()->assignNode( 0 ); // release |
100 | assignInterface( 0 ); | 111 | assignInterface( 0 ); |
101 | NC->setCurrentState( Off ); | 112 | NC->setCurrentState( Off ); |
102 | return 1; | 113 | return 1; |