summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/profile/profilerun.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/profile/profilerun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp
index 90c37ed..feebf86 100644
--- a/noncore/settings/networksettings2/profile/profilerun.cpp
+++ b/noncore/settings/networksettings2/profile/profilerun.cpp
@@ -1,64 +1,62 @@
1#include <resources.h> 1#include <resources.h>
2 2
3#include "profilerun.h" 3#include "profilerun.h"
4 4
5void ProfileRun::detectState( NodeCollection * NC ) { 5void ProfileRun::detectState( NodeCollection * NC ) {
6 if( Data->Disabled ) { 6 if( Data->Disabled ) {
7 NC->setCurrentState( Disabled ); 7 NC->setCurrentState( Disabled );
8 } else { 8 } else {
9 // find next item in connection 9 // find next item in connection
10 // convert to runtime and ask to detect the state 10 // convert to runtime and ask to detect the state
11 netNode()->nextNode()->runtime()->detectState( NC ); 11 netNode()->nextNode()->runtime()->detectState( NC );
12 } 12 }
13} 13}
14 14
15bool ProfileRun::setState( NodeCollection * NC, Action_t A ) { 15bool ProfileRun::setState( NodeCollection * NC, Action_t A ) {
16 ANetNodeInstance * NNNI; 16 ANetNodeInstance * NNNI;
17 17
18 NNNI = netNode()->nextNode(); 18 NNNI = netNode()->nextNode();
19 switch ( A ) { 19 switch ( A ) {
20 case Enable : 20 case Enable :
21 if( NC->currentState() == Disabled ) { 21 if( NC->currentState() == Disabled ) {
22 Data->Disabled = 0;
22 NC->setCurrentState( Off ); // at least 23 NC->setCurrentState( Off ); // at least
23 // ... but request deeper 24 // ... but request deeper
24 NNNI->runtime()->detectState(NC); 25 NNNI->runtime()->detectState(NC);
25 return 1;
26 } 26 }
27 return 1; 27 return 1;
28 case Disable : 28 case Disable :
29 if( NC->currentState() == IsUp ) { 29 switch( NC->currentState() ) {
30 // bring down -> make available 30 case IsUp :
31 NNNI->runtime()->setState(NC, Down); 31 case Available :
32 } 32 // bring Deactivate (will bring down)
33 if( NC->currentState() == Available ) { 33 if( ! NNNI->runtime()->setState(NC, Deactivate) )
34 // make unavailable 34 return 0;
35 NNNI->runtime()->setState(NC, Deactivate); 35 default :
36 } 36 break;
37 if( NC->currentState() > Available ) {
38 // could not disable
39 return 0;
40 } 37 }
38 Data->Disabled = 1;
41 NC->setCurrentState( Disabled ); 39 NC->setCurrentState( Disabled );
42 return 1; 40 return 1;
43 default : 41 default :
44 break; 42 break;
45 } 43 }
46 return NNNI->runtime()->setState(NC, A); 44 return NNNI->runtime()->setState(NC, A);
47} 45}
48 46
49bool ProfileRun::canSetState( State_t Curr, Action_t A ) { 47bool ProfileRun::canSetState( State_t Curr, Action_t A ) {
50 RuntimeInfo * RI; 48 RuntimeInfo * RI;
51 switch ( A ) { 49 switch ( A ) {
52 case Enable : 50 case Enable :
53 case Disable : 51 case Disable :
54 // always possible 52 // always possible
55 return 1; 53 return 1;
56 default : 54 default :
57 break; 55 break;
58 } 56 }
59 RI = netNode()->nextNode()->runtime(); 57 RI = netNode()->nextNode()->runtime();
60 return ( Curr != Disabled ) ? 58 return ( Curr != Disabled ) ?
61 RI->canSetState(Curr, A) : 0; 59 RI->canSetState(Curr, A) : 0;
62} 60}
63 61
64bool ProfileRun::handlesInterface( const QString & S ) { 62bool ProfileRun::handlesInterface( const QString & S ) {