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