summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/network/networkrun.cpp
authorwimpie <wimpie>2004-08-09 02:31:25 (UTC)
committer wimpie <wimpie>2004-08-09 02:31:25 (UTC)
commit0784cfdbd261c43856b45be6ab7439841e69b858 (patch) (unidiff)
treef6a27d6b2e1e6d8dcc908b2ef5836cd320ddfab1 /noncore/settings/networksettings2/network/networkrun.cpp
parent5e10278e748608766245ff9f59a54d1ae8ff6f7e (diff)
downloadopie-0784cfdbd261c43856b45be6ab7439841e69b858.zip
opie-0784cfdbd261c43856b45be6ab7439841e69b858.tar.gz
opie-0784cfdbd261c43856b45be6ab7439841e69b858.tar.bz2
Many changes :
bluetooth and usb seems to work added preliminary support for VPN on top of any network This version is still very much crippled yet is does DO some things
Diffstat (limited to 'noncore/settings/networksettings2/network/networkrun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index 41e1c53..3e24c5f 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -4,56 +4,68 @@
4 4
5void NetworkRun::detectState( NodeCollection * NC ) { 5void 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 Log(( "%s not ! UP or ava\n", NC->name().latin1() ));
16 // has no interface -> delegate 17 // has no interface -> delegate
17 RI->detectState( NC ); 18 RI->detectState( NC );
18} 19}
19 20
20bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { 21bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) {
21 // we handle UP and DOWN 22 // we handle UP and DOWN
22 RuntimeInfo * RI = netNode()->nextNode()->runtime(); 23 RuntimeInfo * RI = netNode()->nextNode()->runtime();
23 AsDevice * Next = RI->asDevice(); 24 AsDevice * Next = RI->asDevice();
24 InterfaceInfo * II = Next->assignedInterface(); 25 InterfaceInfo * II = Next->assignedInterface();
25 26
26 if( A == Up ) { 27 if( A == Up ) {
27 // we can bring UP if lower level is available 28 // we can bring UP if lower level is available
28 if( NC->currentState() == Available || Force ) { 29 if( NC->currentState() == Available || Force ) {
29 QString S; 30 QString S;
30 S.sprintf( "ifup %s=%s-c%d-allowed", 31 S.sprintf( "ifup %s=%s-c%d-allowed",
31 II->Name.latin1(), II->Name.latin1(), 32 II->Name.latin1(), II->Name.latin1(),
32 connection()->number() ); 33 connection()->number() );
33 NSResources->system().runAsRoot( S ); 34 NSResources->system().runAsRoot( S );
34 } 35 }
35 return 1; 36 return 1;
36 } else if( A == Down ) { 37 } else if( A == Down ) {
37 if( NC->currentState() == IsUp || Force ) { 38 QString S;
38 QString S; 39 if( Force ) {
39 S.sprintf( "ifdown %s=%s-c%d-allowed", 40 Log(("Force mode %d\n", Force ));
40 II->Name.latin1(), II->Name.latin1(), 41 for( int i = 0;
41 connection()->number() ); 42 i < RI->netNode()->nodeClass()->instanceCount();
42 NSResources->system().runAsRoot( S ); 43 i ++ ) {
44 S.sprintf( "ifdown %s",
45 RI->netNode()->nodeClass()->genNic( i ).latin1() );
46 NSResources->system().runAsRoot( S );
47 }
48 } else {
49 if( NC->currentState() == IsUp ) {
50 S.sprintf( "ifdown %s=%s-c%d-allowed",
51 II->Name.latin1(), II->Name.latin1(),
52 connection()->number() );
53 NSResources->system().runAsRoot( S );
54 }
43 } 55 }
44 return 1; 56 return 1;
45 } 57 }
46 // delegate 58 // delegate
47 return RI->setState( NC, A ); 59 return RI->setState( NC, A, Force );
48} 60}
49 61
50bool NetworkRun::canSetState( State_t Curr, Action_t A ) { 62bool NetworkRun::canSetState( State_t Curr, Action_t A ) {
51 // we handle UP and DOWN 63 // we handle UP and DOWN
52 RuntimeInfo * RI = netNode()->nextNode()->runtime(); 64 RuntimeInfo * RI = netNode()->nextNode()->runtime();
53 65
54 if( A == Up ) { 66 if( A == Up ) {
55 return ( Curr == Available ); 67 return ( Curr == Available );
56 } else if( A == Down ) { 68 } else if( A == Down ) {
57 return ( Curr == IsUp ); 69 return ( Curr == IsUp );
58 } 70 }
59 // delegate 71 // delegate