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
@@ -39,4 +39,5 @@ State_t USBRun::detectState( void ) {
Log(("Assigned %p\n", NC->assignedInterface() ));
+
if( ( Run = NC->assignedInterface() ) ) {
// we already have an interface assigned -> still present ?
@@ -51,19 +52,5 @@ 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
// usb cables are currently always available when requested
@@ -71,5 +58,4 @@ State_t USBRun::detectState( void ) {
return Available;
}
- }
return Unavailable;
@@ -78,6 +64,14 @@ State_t USBRun::detectState( void ) {
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();
}
@@ -88,5 +82,4 @@ InterfaceInfo * USBRun::getInterface( void ) {
System & S = NSResources->system();
InterfaceInfo * best = 0, * Run;
- QRegExp R( "usb[0-9abcdef]" );
for( QDictIterator<InterfaceInfo> It(S.interfaces());
@@ -94,4 +87,11 @@ InterfaceInfo * USBRun::getInterface( void ) {
++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
@@ -101,8 +101,9 @@ InterfaceInfo * USBRun::getInterface( void ) {
// assigned to us
return Run;
- } else if( Run->assignedConnection() == 0 ) {
+ } else if( ! Run->IsUp &&
+ Run->assignedConnection() == 0 ) {
// free
best = Run;
- }
+ } // UP or not assigned to us
}
}