#include #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 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; }