Diffstat (limited to 'noncore/settings/networksettings2/wlan/wlanrun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/wlan/wlanrun.cpp | 91 |
1 files changed, 13 insertions, 78 deletions
diff --git a/noncore/settings/networksettings2/wlan/wlanrun.cpp b/noncore/settings/networksettings2/wlan/wlanrun.cpp index 3f1d4a9..fe49c4e 100644 --- a/noncore/settings/networksettings2/wlan/wlanrun.cpp +++ b/noncore/settings/networksettings2/wlan/wlanrun.cpp | |||
@@ -7,3 +7,3 @@ | |||
7 | 7 | ||
8 | void WLanRun::detectState( NodeCollection * NC ) { | 8 | State_t WLanRun::detectState( void ) { |
9 | 9 | ||
@@ -13,2 +13,3 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
13 | 13 | ||
14 | NodeCollection * NC = nodeCollection(); | ||
14 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 15 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); |
@@ -31,6 +32,4 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
31 | if( X == Run->Name ) { | 32 | if( X == Run->Name ) { |
32 | Run->assignNode( netNode() ); | 33 | NC->assignInterface( Run ); |
33 | assignInterface( Run ); | 34 | return IsUp; |
34 | NC->setCurrentState( IsUp ); | ||
35 | return; | ||
36 | } | 35 | } |
@@ -40,3 +39,3 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
40 | 39 | ||
41 | if( ( Run = assignedInterface() ) ) { | 40 | if( ( Run = NC->assignedInterface() ) ) { |
42 | // we already have an interface assigned -> still present ? | 41 | // we already have an interface assigned -> still present ? |
@@ -44,4 +43,3 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
44 | // usb is still free -> keep assignment | 43 | // usb is still free -> keep assignment |
45 | NC->setCurrentState( Available ); | 44 | return Available; |
46 | return; | ||
47 | } // else interface is up but NOT us -> some other profile | 45 | } // else interface is up but NOT us -> some other profile |
@@ -50,3 +48,3 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
50 | // nothing (valid) assigned to us | 48 | // nothing (valid) assigned to us |
51 | assignInterface( 0 ); | 49 | NC->assignInterface( 0 ); |
52 | 50 | ||
@@ -66,9 +64,7 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
66 | // proper type, and Not UP -> free | 64 | // proper type, and Not UP -> free |
67 | NC->setCurrentState( Off ); | 65 | return Off; |
68 | return; | ||
69 | } | 66 | } |
70 | } | 67 | } |
71 | // no free found | ||
72 | 68 | ||
73 | NC->setCurrentState( Unavailable ); | 69 | return Unavailable; |
74 | 70 | ||
@@ -76,67 +72,6 @@ void WLanRun::detectState( NodeCollection * NC ) { | |||
76 | 72 | ||
77 | bool WLanRun::setState( NodeCollection * NC, Action_t A, bool ) { | 73 | QString WLanRun::setMyState( NodeCollection * , Action_t , bool ) { |
78 | 74 | ||
79 | // we only handle activate and deactivate | 75 | // we only handle activate and deactivate |
80 | switch( A ) { | 76 | return QString(); |
81 | case Activate : | ||
82 | { | ||
83 | if( NC->currentState() != Off ) { | ||
84 | return 0; | ||
85 | } | ||
86 | InterfaceInfo * N = getInterface(); | ||
87 | if( ! N ) { | ||
88 | // no interface available | ||
89 | NC->setCurrentState( Unavailable ); | ||
90 | return 0; | ||
91 | } | ||
92 | // because we were OFF the interface | ||
93 | // we get back is NOT assigned | ||
94 | N->assignNode( netNode() ); | ||
95 | assignInterface( N ); | ||
96 | NC->setCurrentState( Available ); | ||
97 | return 1; | ||
98 | } | ||
99 | case Deactivate : | ||
100 | if( NC->currentState() == IsUp ) { | ||
101 | // bring down first | ||
102 | if( ! connection()->setState( Down ) ) | ||
103 | // could not ... | ||
104 | return 0; | ||
105 | } else if( NC->currentState() != Available ) { | ||
106 | return 1; | ||
107 | } | ||
108 | assignedInterface()->assignNode( 0 ); // release | ||
109 | assignInterface( 0 ); | ||
110 | NC->setCurrentState( Off ); | ||
111 | return 1; | ||
112 | default : | ||
113 | // FT | ||
114 | break; | ||
115 | } | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | bool WLanRun::canSetState( State_t Curr, Action_t A ) { | ||
120 | // we only handle up down activate and deactivate | ||
121 | switch( A ) { | ||
122 | case Activate : | ||
123 | { // at least available | ||
124 | if( Curr == Available ) { | ||
125 | return 1; | ||
126 | } | ||
127 | // or we can make one available | ||
128 | InterfaceInfo * N = getInterface(); | ||
129 | if( ! N || N->assignedNode() != 0 ) { | ||
130 | // non available or assigned | ||
131 | return 0; | ||
132 | } | ||
133 | return 1; | ||
134 | } | ||
135 | case Deactivate : | ||
136 | return ( Curr >= Available ); | ||
137 | default : | ||
138 | // FT | ||
139 | break; | ||
140 | } | ||
141 | return 0; | ||
142 | } | 77 | } |
@@ -161,6 +96,6 @@ InterfaceInfo * WLanRun::getInterface( void ) { | |||
161 | // this is a LAN card | 96 | // this is a LAN card |
162 | if( Run->assignedNode() == netNode() ) { | 97 | if( Run->assignedConnection() == netNode()->connection() ) { |
163 | // assigned to us | 98 | // assigned to us |
164 | return Run; | 99 | return Run; |
165 | } else if( Run->assignedNode() == 0 ) { | 100 | } else if( Run->assignedConnection() == 0 ) { |
166 | // free | 101 | // free |