author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (unidiff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/usb/usbrun.cpp | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2 |
CONTROL files : changed version string
NS2 many changes and first release of OT2
Diffstat (limited to 'noncore/settings/networksettings2/usb/usbrun.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/usb/usbrun.cpp | 102 |
1 files changed, 18 insertions, 84 deletions
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index b8ac8a8..f8824e0 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp | |||
@@ -4,10 +4,11 @@ | |||
4 | #include <resources.h> | 4 | #include <resources.h> |
5 | #include "usbrun.h" | 5 | #include "usbrun.h" |
6 | 6 | ||
7 | void USBRun::detectState( NodeCollection * NC ) { | 7 | State_t USBRun::detectState( void ) { |
8 | // unavailable : no card found | 8 | // unavailable : no card found |
9 | // available : card found and assigned to us or free | 9 | // available : card found and assigned to us or free |
10 | // up : card found and assigned to us and up | 10 | // up : card found and assigned to us and up |
11 | NodeCollection * NC = nodeCollection(); | ||
11 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 12 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); |
12 | System & Sys = NSResources->system(); | 13 | System & Sys = NSResources->system(); |
13 | InterfaceInfo * Run; | 14 | InterfaceInfo * Run; |
@@ -27,27 +28,24 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
27 | ++It ) { | 28 | ++It ) { |
28 | Run = It.current(); | 29 | Run = It.current(); |
29 | if( X == Run->Name ) { | 30 | if( X == Run->Name ) { |
30 | Run->assignNode( netNode() ); | 31 | NC->assignInterface( Run ); |
31 | assignInterface( Run ); | 32 | return IsUp; |
32 | NC->setCurrentState( IsUp ); | ||
33 | return; | ||
34 | } | 33 | } |
35 | } | 34 | } |
36 | } | 35 | } |
37 | } | 36 | } |
38 | 37 | ||
39 | Log(("Assigned %p\n", assignedInterface() )); | 38 | Log(("Assigned %p\n", NC->assignedInterface() )); |
40 | if( ( Run = assignedInterface() ) ) { | 39 | if( ( Run = NC->assignedInterface() ) ) { |
41 | // we already have an interface assigned -> still present ? | 40 | // we already have an interface assigned -> still present ? |
42 | if( ! Run->IsUp ) { | 41 | if( ! Run->IsUp ) { |
43 | // usb is still free -> keep assignment | 42 | // usb is still free -> keep assignment |
44 | NC->setCurrentState( Available ); | 43 | return Available; |
45 | return; | ||
46 | } // else interface is up but NOT us -> some other profile | 44 | } // else interface is up but NOT us -> some other profile |
47 | } | 45 | } |
48 | 46 | ||
49 | // nothing (valid) assigned to us | 47 | // nothing (valid) assigned to us |
50 | assignInterface( 0 ); | 48 | NC->assignInterface( 0 ); |
51 | 49 | ||
52 | // find possible interface | 50 | // find possible interface |
53 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); | 51 | for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); |
@@ -65,84 +63,16 @@ void USBRun::detectState( NodeCollection * NC ) { | |||
65 | Run->CardType == ARPHRD_ETHER && | 63 | Run->CardType == ARPHRD_ETHER && |
66 | ! Run->IsUp | 64 | ! Run->IsUp |
67 | ) { | 65 | ) { |
68 | Log(("Released(OFF)\n" )); | ||
69 | // proper type, and Not UP -> free | 66 | // proper type, and Not UP -> free |
70 | NC->setCurrentState( Off ); | 67 | return Off; |
71 | return; | ||
72 | } | 68 | } |
73 | } | 69 | } |
74 | // no free found | ||
75 | Log(("UNA\n" )); | ||
76 | 70 | ||
77 | NC->setCurrentState( Unavailable ); | 71 | return Unavailable; |
78 | } | 72 | } |
79 | 73 | ||
80 | bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) { | 74 | QString USBRun::setMyState( NodeCollection *, Action_t , bool ) { |
81 | 75 | return QString(); | |
82 | // we only handle activate and deactivate | ||
83 | switch( A ) { | ||
84 | case Activate : | ||
85 | { | ||
86 | if( NC->currentState() != Off ) { | ||
87 | return 0; | ||
88 | } | ||
89 | InterfaceInfo * N = getInterface(); | ||
90 | if( ! N ) { | ||
91 | // no interface available | ||
92 | NC->setCurrentState( Unavailable ); | ||
93 | return 0; | ||
94 | } | ||
95 | // because we were OFF the interface | ||
96 | // we get back is NOT assigned | ||
97 | N->assignNode( netNode() ); | ||
98 | assignInterface( N ); | ||
99 | Log(("Assing %p\n", N )); | ||
100 | NC->setCurrentState( Available ); | ||
101 | return 1; | ||
102 | } | ||
103 | case Deactivate : | ||
104 | if( NC->currentState() == IsUp ) { | ||
105 | // bring down first | ||
106 | if( ! connection()->setState( Down ) ) | ||
107 | // could not ... | ||
108 | return 0; | ||
109 | } else if( NC->currentState() != Available ) { | ||
110 | return 1; | ||
111 | } | ||
112 | assignedInterface()->assignNode( 0 ); // release | ||
113 | assignInterface( 0 ); | ||
114 | NC->setCurrentState( Off ); | ||
115 | return 1; | ||
116 | default : | ||
117 | // FT | ||
118 | break; | ||
119 | } | ||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | bool USBRun::canSetState( State_t Curr, Action_t A ) { | ||
124 | // we only handle up down activate and deactivate | ||
125 | switch( A ) { | ||
126 | case Activate : | ||
127 | { // at least available | ||
128 | if( Curr == Available ) { | ||
129 | return 1; | ||
130 | } | ||
131 | // or we can make one available | ||
132 | InterfaceInfo * N = getInterface(); | ||
133 | if( ! N || N->assignedNode() != 0 ) { | ||
134 | // non available or assigned | ||
135 | return 0; | ||
136 | } | ||
137 | return 1; | ||
138 | } | ||
139 | case Deactivate : | ||
140 | return ( Curr >= Available ); | ||
141 | default : | ||
142 | // FT | ||
143 | break; | ||
144 | } | ||
145 | return 0; | ||
146 | } | 76 | } |
147 | 77 | ||
148 | // get interface that is free or assigned to us | 78 | // get interface that is free or assigned to us |
@@ -160,10 +90,10 @@ InterfaceInfo * USBRun::getInterface( void ) { | |||
160 | Run->CardType == ARPHRD_ETHER | 90 | Run->CardType == ARPHRD_ETHER |
161 | ) { | 91 | ) { |
162 | // this is a USB card | 92 | // this is a USB card |
163 | if( Run->assignedNode() == netNode() ) { | 93 | if( Run->assignedConnection() == netNode()->connection() ) { |
164 | // assigned to us | 94 | // assigned to us |
165 | return Run; | 95 | return Run; |
166 | } else if( Run->assignedNode() == 0 ) { | 96 | } else if( Run->assignedConnection() == 0 ) { |
167 | // free | 97 | // free |
168 | best = Run; | 98 | best = Run; |
169 | } | 99 | } |
@@ -176,3 +106,7 @@ bool USBRun::handlesInterface( const QString & S ) { | |||
176 | return Pat.match( S ) >= 0; | 106 | return Pat.match( S ) >= 0; |
177 | } | 107 | } |
178 | 108 | ||
109 | bool USBRun::handlesInterface( InterfaceInfo * I ) { | ||
110 | return handlesInterface( I->Name ); | ||
111 | } | ||
112 | |||