summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/ppp/ppprun.cpp
blob: 8933f850f725220f13a622903f5bdab1cab3b167 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <resources.h>
#include "ppprun.h"

void PPPRun::detectState( NodeCollection * NC ) {
    if( isMyPPPDRunning( ) ) {
      if( isMyPPPUp() ) {
        NC->setCurrentState( IsUp );
      } else {
        NC->setCurrentState( Available );
      }
    } else {
      NC->setCurrentState( Off ); // at least this
      // but could also be unavailable
      netNode()->nextNode()->runtime()->detectState( NC ); 
    }
}

bool PPPRun::setState( NodeCollection * NC, Action_t A ) { 
    switch( A ) {
      case Activate :
        NC->setCurrentState( Available );
        // no
        break;
      case Deactivate :
        if( NC->currentState() == IsUp ) {
          NC->state( Down );
        }
        // cannot really disable
        NC->setCurrentState( Available );
        break;
      case Up :
        if( NC->currentState() != IsUp ) {
          // start my PPPD
          NC->setCurrentState( IsUp );
        } 
        break;
      case Down :
        if( NC->currentState() == IsUp ) {
          // stop my PPPD
          NC->setCurrentState( Available );
        } 
        break;
      default : // FT
        break;
    }
    return 1;
}

bool PPPRun::isMyPPPDRunning( void ) {
    return 0;
}

bool PPPRun::isMyPPPUp( void ) {
    System & S = NSResources->system();
    InterfaceInfo * best = 0, * Run;
    QRegExp R( "ppp[0-9]" );

    for( QDictIterator<InterfaceInfo> It(S.interfaces());
         It.current();
         ++It ) {
      Run = It.current();
      if( R.match( Run->Name ) >= 0 &&
          Run->IsPointToPoint 
        ) {
        // this is a LAN card
        if( Run->assignedNode() == netNode() ) {
          // assigned to us
          return 1;
        } 
      }
    }
    return 0;
}

bool PPPRun::handlesInterface( const QString & S ) {
    return Pat.match( S ) >= 0;
}