author | wimpie <wimpie> | 2005-01-09 00:32:10 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-09 00:32:10 (UTC) |
commit | e54346d28b19d3ac671802a25e8c03f346693291 (patch) (unidiff) | |
tree | 0f8d6561e24a7ba36fd8a6ab1869aa470e1fdb36 /noncore/settings/networksettings2/usb/usbrun.cpp | |
parent | 60a617583d0ccc793d9ea4465998d90ec208db58 (diff) | |
download | opie-e54346d28b19d3ac671802a25e8c03f346693291.zip opie-e54346d28b19d3ac671802a25e8c03f346693291.tar.gz opie-e54346d28b19d3ac671802a25e8c03f346693291.tar.bz2 |
Updated dependencies
NS2->app requires OT2Lib and NS2Lib
OT2Lib requires NS2Lib
Most plugins only require NS2Lib
Except
BTPlugin which requires als OT2Lib
Also renamed owarn -> odebug
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 | |||
@@ -37,8 +37,9 @@ State_t USBRun::detectState( void ) { | |||
37 | } | 37 | } |
38 | } | 38 | } |
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 ? |
43 | if( ! Run->IsUp ) { | 44 | if( ! Run->IsUp ) { |
44 | // usb is still free -> keep assignment | 45 | // usb is still free -> keep assignment |
@@ -49,62 +50,62 @@ State_t USBRun::detectState( void ) { | |||
49 | // nothing (valid) assigned to us | 50 | // nothing (valid) assigned to us |
50 | NC->assignInterface( 0 ); | 51 | NC->assignInterface( 0 ); |
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 | ||
75 | return Unavailable; | 61 | return Unavailable; |
76 | } | 62 | } |
77 | 63 | ||
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 | } |
84 | 78 | ||
85 | // get interface that is free or assigned to us | 79 | // get interface that is free or assigned to us |
86 | InterfaceInfo * USBRun::getInterface( void ) { | 80 | InterfaceInfo * USBRun::getInterface( void ) { |
87 | 81 | ||
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()); |
93 | It.current(); | 86 | It.current(); |
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 |
98 | ) { | 98 | ) { |
99 | // this is a USB card | 99 | // this is a USB card |
100 | if( Run->assignedConnection() == netNode()->connection() ) { | 100 | if( Run->assignedConnection() == netNode()->connection() ) { |
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 | } |
109 | return best; // can be 0 | 110 | return best; // can be 0 |
110 | } | 111 | } |