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 @@ -33,27 +33,38 @@ void USBRun::detectState( NodeCollection * NC ) { } } } - fprintf( stderr, "NUP\n" ); - // definitively not up + fprintf( stderr, "Assigned %p\n", assignedInterface() ); + if( ( Run = assignedInterface() ) ) { + // we already have an interface assigned -> still present ? + if( ! Run->IsUp ) { + // usb is still free -> keep assignment + NC->setCurrentState( Available ); + return; + } // else interface is up but NOT us -> some other profile + } + + // nothing (valid) assigned to us assignInterface( 0 ); // find possible interface for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); It.current(); ++It ) { Run = It.current(); + fprintf( stderr, "%s %d %d=%d %d\n", - Run->Name.latin1(), - handlesInterface( Run->Name ), - Run->CardType, ARPHRD_ETHER, - ! Run->IsUp ); + Run->Name.latin1(), + handlesInterface( Run->Name ), + Run->CardType, ARPHRD_ETHER, + ! Run->IsUp ); + if( handlesInterface( Run->Name ) && Run->CardType == ARPHRD_ETHER && ! Run->IsUp ) { - fprintf( stderr, "OFF\n" ); + fprintf( stderr, "Released(OFF)\n" ); // proper type, and Not UP -> free NC->setCurrentState( Off ); return; } @@ -82,8 +93,9 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) { // because we were OFF the interface // we get back is NOT assigned N->assignNode( netNode() ); assignInterface( N ); + fprintf( stderr, "Assing %p\n", N ); NC->setCurrentState( Available ); return 1; } case Deactivate : @@ -91,10 +103,9 @@ bool USBRun::setState( NodeCollection * NC, Action_t A ) { // bring down first if( ! connection()->setState( Down ) ) // could not ... return 0; - } - if( NC->currentState() != Available ) { + } else if( NC->currentState() != Available ) { return 1; } assignedInterface()->assignNode( 0 ); // release assignInterface( 0 ); |