summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/usb/usbrun.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/usb/usbrun.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index eb439c1..de8c8a2 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -40,2 +40,3 @@ State_t USBRun::detectState( void ) {
Log(("Assigned %p\n", NC->assignedInterface() ));
+
if( ( Run = NC->assignedInterface() ) ) {
@@ -52,17 +53,3 @@ State_t USBRun::detectState( void ) {
// find possible interface
- for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
- It.current();
- ++It ) {
- Run = It.current();
-
- Log(("%s %d %d=%d %d\n",
- Run->Name.latin1(),
- handlesInterface( Run->Name ),
- Run->CardType, ARPHRD_ETHER,
- ! Run->IsUp ));
-
- if( handlesInterface( Run->Name ) &&
- Run->CardType == ARPHRD_ETHER &&
- ! Run->IsUp
- ) {
+ if( getInterface() ) {
// proper type, and Not UP -> free
@@ -72,3 +59,2 @@ State_t USBRun::detectState( void ) {
}
- }
@@ -79,4 +65,12 @@ QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
- // nothing needs to be done to 'activate' or 'deactivate'
- // a cable
+ InterfaceInfo * I = getInterface();
+
+ if( ! I ) {
+ return QString("No usb device available");
+ }
+
+ Log(( "Grabbed USB interface %s\n", I->Name.latin1() ));
+ // grab this interface
+ NC->assignInterface( I );
+
return QString();
@@ -89,3 +83,2 @@ InterfaceInfo * USBRun::getInterface( void ) {
InterfaceInfo * best = 0, * Run;
- QRegExp R( "usb[0-9abcdef]" );
@@ -95,2 +88,9 @@ InterfaceInfo * USBRun::getInterface( void ) {
Run = It.current();
+
+ Log(("%s %d %d=%d %d\n",
+ Run->Name.latin1(),
+ handlesInterface( Run->Name ),
+ Run->CardType, ARPHRD_ETHER,
+ ! Run->IsUp ));
+
if( handlesInterface( Run->Name ) &&
@@ -102,6 +102,7 @@ InterfaceInfo * USBRun::getInterface( void ) {
return Run;
- } else if( Run->assignedConnection() == 0 ) {
+ } else if( ! Run->IsUp &&
+ Run->assignedConnection() == 0 ) {
// free
best = Run;
- }
+ } // UP or not assigned to us
}