summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/ppp/ppprun.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/ppp/ppprun.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/ppp/ppprun.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp
new file mode 100644
index 0000000..8933f85
--- a/dev/null
+++ b/noncore/settings/networksettings2/ppp/ppprun.cpp
@@ -0,0 +1,77 @@
1#include <resources.h>
2#include "ppprun.h"
3
4void PPPRun::detectState( NodeCollection * NC ) {
5 if( isMyPPPDRunning( ) ) {
6 if( isMyPPPUp() ) {
7 NC->setCurrentState( IsUp );
8 } else {
9 NC->setCurrentState( Available );
10 }
11 } else {
12 NC->setCurrentState( Off ); // at least this
13 // but could also be unavailable
14 netNode()->nextNode()->runtime()->detectState( NC );
15 }
16}
17
18bool PPPRun::setState( NodeCollection * NC, Action_t A ) {
19 switch( A ) {
20 case Activate :
21 NC->setCurrentState( Available );
22 // no
23 break;
24 case Deactivate :
25 if( NC->currentState() == IsUp ) {
26 NC->state( Down );
27 }
28 // cannot really disable
29 NC->setCurrentState( Available );
30 break;
31 case Up :
32 if( NC->currentState() != IsUp ) {
33 // start my PPPD
34 NC->setCurrentState( IsUp );
35 }
36 break;
37 case Down :
38 if( NC->currentState() == IsUp ) {
39 // stop my PPPD
40 NC->setCurrentState( Available );
41 }
42 break;
43 default : // FT
44 break;
45 }
46 return 1;
47}
48
49bool PPPRun::isMyPPPDRunning( void ) {
50 return 0;
51}
52
53bool PPPRun::isMyPPPUp( void ) {
54 System & S = NSResources->system();
55 InterfaceInfo * best = 0, * Run;
56 QRegExp R( "ppp[0-9]" );
57
58 for( QDictIterator<InterfaceInfo> It(S.interfaces());
59 It.current();
60 ++It ) {
61 Run = It.current();
62 if( R.match( Run->Name ) >= 0 &&
63 Run->IsPointToPoint
64 ) {
65 // this is a LAN card
66 if( Run->assignedNode() == netNode() ) {
67 // assigned to us
68 return 1;
69 }
70 }
71 }
72 return 0;
73}
74
75bool PPPRun::handlesInterface( const QString & S ) {
76 return Pat.match( S ) >= 0;
77}