Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/network/networkrun.cpp | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings2/network/networkrun.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index c19235a..41e1c53 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp | |||
@@ -1,66 +1,66 @@ | |||
1 | #include <system.h> | 1 | #include <system.h> |
2 | #include <asdevice.h> | 2 | #include <asdevice.h> |
3 | #include "networkrun.h" | 3 | #include "networkrun.h" |
4 | 4 | ||
5 | void NetworkRun::detectState( NodeCollection * NC ) { | 5 | void NetworkRun::detectState( NodeCollection * NC ) { |
6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
7 | AsDevice * Next = RI->asDevice(); | 7 | AsDevice * Next = RI->asDevice(); |
8 | InterfaceInfo * II = Next->assignedInterface(); | 8 | InterfaceInfo * II = Next->assignedInterface(); |
9 | 9 | ||
10 | if( II ) { | 10 | if( II ) { |
11 | // device has assigned interface | 11 | // device has assigned interface |
12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); | 12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); |
13 | return; | 13 | return; |
14 | } | 14 | } |
15 | 15 | ||
16 | // has no interface -> delegate | 16 | // has no interface -> delegate |
17 | RI->detectState( NC ); | 17 | RI->detectState( NC ); |
18 | } | 18 | } |
19 | 19 | ||
20 | bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { | 20 | bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { |
21 | // we handle UP and DOWN | 21 | // we handle UP and DOWN |
22 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 22 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
23 | AsDevice * Next = RI->asDevice(); | 23 | AsDevice * Next = RI->asDevice(); |
24 | InterfaceInfo * II = Next->assignedInterface(); | 24 | InterfaceInfo * II = Next->assignedInterface(); |
25 | 25 | ||
26 | if( A == Up ) { | 26 | if( A == Up ) { |
27 | // we can bring UP if lower level is available | 27 | // we can bring UP if lower level is available |
28 | if( NC->currentState() == Available ) { | 28 | if( NC->currentState() == Available || Force ) { |
29 | QString S; | 29 | QString S; |
30 | S.sprintf( "ifup %s=%s-c%d-allowed", | 30 | S.sprintf( "ifup %s=%s-c%d-allowed", |
31 | II->Name.latin1(), II->Name.latin1(), | 31 | II->Name.latin1(), II->Name.latin1(), |
32 | connection()->number() ); | 32 | connection()->number() ); |
33 | NSResources->system().runAsRoot( S ); | 33 | NSResources->system().runAsRoot( S ); |
34 | } | 34 | } |
35 | return 1; | 35 | return 1; |
36 | } else if( A == Down ) { | 36 | } else if( A == Down ) { |
37 | if( NC->currentState() == IsUp ) { | 37 | if( NC->currentState() == IsUp || Force ) { |
38 | QString S; | 38 | QString S; |
39 | S.sprintf( "ifdown %s=%s-c%d-allowed", | 39 | S.sprintf( "ifdown %s=%s-c%d-allowed", |
40 | II->Name.latin1(), II->Name.latin1(), | 40 | II->Name.latin1(), II->Name.latin1(), |
41 | connection()->number() ); | 41 | connection()->number() ); |
42 | NSResources->system().runAsRoot( S ); | 42 | NSResources->system().runAsRoot( S ); |
43 | } | 43 | } |
44 | return 1; | 44 | return 1; |
45 | } | 45 | } |
46 | // delegate | 46 | // delegate |
47 | return RI->setState( NC, A ); | 47 | return RI->setState( NC, A ); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { | 50 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { |
51 | // we handle UP and DOWN | 51 | // we handle UP and DOWN |
52 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 52 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); |
53 | 53 | ||
54 | if( A == Up ) { | 54 | if( A == Up ) { |
55 | return ( Curr == Available ); | 55 | return ( Curr == Available ); |
56 | } else if( A == Down ) { | 56 | } else if( A == Down ) { |
57 | return ( Curr == IsUp ); | 57 | return ( Curr == IsUp ); |
58 | } | 58 | } |
59 | // delegate | 59 | // delegate |
60 | return RI->canSetState( Curr, A ); | 60 | return RI->canSetState( Curr, A ); |
61 | } | 61 | } |
62 | 62 | ||
63 | bool NetworkRun::handlesInterface( const QString & S ) { | 63 | bool NetworkRun::handlesInterface( const QString & S ) { |
64 | // donno -> pass deeper | 64 | // donno -> pass deeper |
65 | return netNode()->nextNode()->runtime()->handlesInterface(S); | 65 | return netNode()->nextNode()->runtime()->handlesInterface(S); |
66 | } | 66 | } |
diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h index fa16365..522a912 100644 --- a/noncore/settings/networksettings2/network/networkrun.h +++ b/noncore/settings/networksettings2/network/networkrun.h | |||
@@ -1,23 +1,23 @@ | |||
1 | #include <asconnection.h> | 1 | #include <asconnection.h> |
2 | #include "networkdata.h" | 2 | #include "networkdata.h" |
3 | 3 | ||
4 | class NetworkRun : public AsConnection { | 4 | class NetworkRun : public AsConnection { |
5 | 5 | ||
6 | public : | 6 | public : |
7 | 7 | ||
8 | NetworkRun( ANetNodeInstance * NNI, | 8 | NetworkRun( ANetNodeInstance * NNI, |
9 | NetworkData & Data ) : AsConnection( NNI ) | 9 | NetworkData & Data ) : AsConnection( NNI ) |
10 | { } | 10 | { } |
11 | 11 | ||
12 | virtual AsConnection * asConnection( void ) | 12 | virtual AsConnection * asConnection( void ) |
13 | { return (AsConnection *)this; } | 13 | { return (AsConnection *)this; } |
14 | 14 | ||
15 | protected : | 15 | protected : |
16 | 16 | ||
17 | void detectState( NodeCollection * ); | 17 | void detectState( NodeCollection * ); |
18 | bool setState( NodeCollection * ,Action_t A ); | 18 | bool setState( NodeCollection * ,Action_t A, bool ); |
19 | bool canSetState( State_t , Action_t A ); | 19 | bool canSetState( State_t , Action_t A ); |
20 | 20 | ||
21 | bool handlesInterface( const QString & I ); | 21 | bool handlesInterface( const QString & I ); |
22 | 22 | ||
23 | }; | 23 | }; |