Diffstat (limited to 'noncore/settings/networksettings2/ppp/ppprun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/ppp/ppprun.cpp | 77 |
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 @@ +#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; +} |