summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/profile/profilerun.cpp
blob: 90c37ed245be518e815db772f68c07e3cc3f7dc4 (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
#include <resources.h>

#include "profilerun.h"

void ProfileRun::detectState( NodeCollection * NC ) { 
    if( Data->Disabled ) {
      NC->setCurrentState( Disabled );
    } else {
      // find next item in connection
      // convert to runtime and ask to detect the state
      netNode()->nextNode()->runtime()->detectState( NC );
    }
}

bool ProfileRun::setState( NodeCollection * NC, Action_t A ) { 
    ANetNodeInstance * NNNI;

    NNNI = netNode()->nextNode();
    switch ( A ) {
      case Enable :
        if( NC->currentState() == Disabled ) {
          NC->setCurrentState( Off ); // at least
          // ... but request deeper 
          NNNI->runtime()->detectState(NC);
          return 1;
        }
        return 1;
      case Disable :
        if( NC->currentState() == IsUp ) {
          // bring down -> make available
          NNNI->runtime()->setState(NC, Down);
        }
        if( NC->currentState() == Available ) {
          // make unavailable
          NNNI->runtime()->setState(NC, Deactivate);
        }
        if( NC->currentState() > Available ) {
          // could not disable 
          return 0;
        }
        NC->setCurrentState( Disabled );
        return 1;
      default :
        break;
    }
    return NNNI->runtime()->setState(NC, A);
}

bool ProfileRun::canSetState( State_t Curr, Action_t A ) { 
    RuntimeInfo * RI;
    switch ( A ) {
      case Enable :
      case Disable :
        // always possible
        return 1;
      default :
        break;
    }
    RI = netNode()->nextNode()->runtime();
    return ( Curr != Disabled ) ?
        RI->canSetState(Curr, A) : 0;
}

bool ProfileRun::handlesInterface( const QString & S ) {
    // donno -> pass deeper
    return netNode()->nextNode()->runtime()->handlesInterface(S);
}