summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/ppp/ppprun.cpp
authorwimpie <wimpie>2004-04-02 18:29:49 (UTC)
committer wimpie <wimpie>2004-04-02 18:29:49 (UTC)
commit5334b639c9f97793bcae4f50f7b47c7a2ada4e2f (patch) (side-by-side diff)
treef55aebd4314ab878bc39b6b08b8323a8ef78d803 /noncore/settings/networksettings2/ppp/ppprun.cpp
parent7c8922b37b5bb7696c0ff2cbc999e2936b9b509f (diff)
downloadopie-5334b639c9f97793bcae4f50f7b47c7a2ada4e2f.zip
opie-5334b639c9f97793bcae4f50f7b47c7a2ada4e2f.tar.gz
opie-5334b639c9f97793bcae4f50f7b47c7a2ada4e2f.tar.bz2
First import of NS2 app
Diffstat (limited to 'noncore/settings/networksettings2/ppp/ppprun.cpp') (more/less context) (ignore 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 @@
+#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;
+}