Diffstat (limited to 'noncore/settings/networksettings2/usb/usbrun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/usb/usbrun.cpp | 51 |
1 files changed, 26 insertions, 25 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 ) { | |||
39 | 39 | ||
40 | Log(("Assigned %p\n", NC->assignedInterface() )); | 40 | Log(("Assigned %p\n", NC->assignedInterface() )); |
41 | |||
41 | if( ( Run = NC->assignedInterface() ) ) { | 42 | if( ( Run = NC->assignedInterface() ) ) { |
42 | // we already have an interface assigned -> still present ? | 43 | // we already have an interface assigned -> still present ? |
@@ -51,24 +52,9 @@ State_t USBRun::detectState( void ) { | |||
51 | 52 | ||
52 | // find possible interface | 53 | // find possible interface |
53 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 54 | if( getInterface() ) { |
54 | It.current(); | 55 | // proper type, and Not UP -> free |
55 | ++It ) { | 56 | // usb cables are currently always available when requested |
56 | Run = It.current(); | 57 | // until we can detect if we are plugged in |
57 | 58 | return Available; | |
58 | Log(("%s %d %d=%d %d\n", | ||
59 | Run->Name.latin1(), | ||
60 | handlesInterface( Run->Name ), | ||
61 | Run->CardType, ARPHRD_ETHER, | ||
62 | ! Run->IsUp )); | ||
63 | |||
64 | if( handlesInterface( Run->Name ) && | ||
65 | Run->CardType == ARPHRD_ETHER && | ||
66 | ! Run->IsUp | ||
67 | ) { | ||
68 | // proper type, and Not UP -> free | ||
69 | // usb cables are currently always available when requested | ||
70 | // until we can detect if we are plugged in | ||
71 | return Available; | ||
72 | } | ||
73 | } | 59 | } |
74 | 60 | ||
@@ -78,6 +64,14 @@ State_t USBRun::detectState( void ) { | |||
78 | QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) { | 64 | QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) { |
79 | 65 | ||
80 | // nothing needs to be done to 'activate' or 'deactivate' | 66 | InterfaceInfo * I = getInterface(); |
81 | // a cable | 67 | |
68 | if( ! I ) { | ||
69 | return QString("No usb device available"); | ||
70 | } | ||
71 | |||
72 | Log(( "Grabbed USB interface %s\n", I->Name.latin1() )); | ||
73 | // grab this interface | ||
74 | NC->assignInterface( I ); | ||
75 | |||
82 | return QString(); | 76 | return QString(); |
83 | } | 77 | } |
@@ -88,5 +82,4 @@ InterfaceInfo * USBRun::getInterface( void ) { | |||
88 | System & S = NSResources->system(); | 82 | System & S = NSResources->system(); |
89 | InterfaceInfo * best = 0, * Run; | 83 | InterfaceInfo * best = 0, * Run; |
90 | QRegExp R( "usb[0-9abcdef]" ); | ||
91 | 84 | ||
92 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 85 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
@@ -94,4 +87,11 @@ InterfaceInfo * USBRun::getInterface( void ) { | |||
94 | ++It ) { | 87 | ++It ) { |
95 | Run = It.current(); | 88 | Run = It.current(); |
89 | |||
90 | Log(("%s %d %d=%d %d\n", | ||
91 | Run->Name.latin1(), | ||
92 | handlesInterface( Run->Name ), | ||
93 | Run->CardType, ARPHRD_ETHER, | ||
94 | ! Run->IsUp )); | ||
95 | |||
96 | if( handlesInterface( Run->Name ) && | 96 | if( handlesInterface( Run->Name ) && |
97 | Run->CardType == ARPHRD_ETHER | 97 | Run->CardType == ARPHRD_ETHER |
@@ -101,8 +101,9 @@ InterfaceInfo * USBRun::getInterface( void ) { | |||
101 | // assigned to us | 101 | // assigned to us |
102 | return Run; | 102 | return Run; |
103 | } else if( Run->assignedConnection() == 0 ) { | 103 | } else if( ! Run->IsUp && |
104 | Run->assignedConnection() == 0 ) { | ||
104 | // free | 105 | // free |
105 | best = Run; | 106 | best = Run; |
106 | } | 107 | } // UP or not assigned to us |
107 | } | 108 | } |
108 | } | 109 | } |