summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/lancard/lancardrun.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/lancard/lancardrun.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/lancard/lancardrun.cpp110
1 files changed, 33 insertions, 77 deletions
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp
index 1544ddc..470b797 100644
--- a/noncore/settings/networksettings2/lancard/lancardrun.cpp
+++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp
@@ -6,3 +6,3 @@
-void LanCardRun::detectState( NodeCollection * NC ) {
+State_t LanCardRun::detectState( void ) {
@@ -12,3 +12,5 @@ void LanCardRun::detectState( NodeCollection * NC ) {
- QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
+ NodeCollection * NC = nodeCollection();
+ QString S = QString( "/tmp/profile-%1.up" ).
+ arg( NC->number());
System & Sys = NSResources->system();
@@ -30,6 +32,4 @@ void LanCardRun::detectState( NodeCollection * NC ) {
if( X == Run->Name ) {
- Run->assignNode( netNode() );
- assignInterface( Run );
- NC->setCurrentState( IsUp );
- return;
+ NC->assignInterface( Run );
+ return IsUp;
}
@@ -39,3 +39,3 @@ void LanCardRun::detectState( NodeCollection * NC ) {
- if( ( Run = assignedInterface() ) ) {
+ if( ( Run = NC->assignedInterface() ) ) {
// we already have an interface assigned -> still present ?
@@ -43,4 +43,3 @@ void LanCardRun::detectState( NodeCollection * NC ) {
// usb is still free -> keep assignment
- NC->setCurrentState( Available );
- return;
+ return Available;
} // else interface is up but NOT us -> some other profile
@@ -49,3 +48,3 @@ void LanCardRun::detectState( NodeCollection * NC ) {
// nothing (valid) assigned to us
- assignInterface( 0 );
+ NC->assignInterface( 0 );
@@ -65,4 +64,3 @@ void LanCardRun::detectState( NodeCollection * NC ) {
// proper type, and Not UP -> free
- NC->setCurrentState( Off );
- return;
+ return Off;
}
@@ -71,71 +69,29 @@ void LanCardRun::detectState( NodeCollection * NC ) {
- NC->setCurrentState( Unavailable );
-
+ return Unavailable;
}
-bool LanCardRun::setState( NodeCollection * NC, Action_t A, bool ) {
+QString LanCardRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
- // we only handle activate and deactivate
- switch( A ) {
- case Activate :
- {
- if( NC->currentState() != Off ) {
- return 0;
- }
- InterfaceInfo * N = getInterface();
- if( ! N ) {
- // no interface available
- NC->setCurrentState( Unavailable );
- return 0;
- }
- // because we were OFF the interface
- // we get back is NOT assigned
- N->assignNode( netNode() );
- assignInterface( N );
- NC->setCurrentState( Available );
- return 1;
- }
- case Deactivate :
- if( NC->currentState() == IsUp ) {
- // bring down first
- if( ! connection()->setState( Down ) )
- // could not ...
- return 0;
- } else if( NC->currentState() != Available ) {
- return 1;
- }
- assignedInterface()->assignNode( 0 ); // release
- assignInterface( 0 );
- NC->setCurrentState( Off );
- return 1;
- default :
- // FT
- break;
+ if( A == Activate ) {
+ InterfaceInfo * N = getInterface();
+
+ if( ! N ) {
+ // no interface available
+ NC->setCurrentState( Unavailable );
+ return tr("No interface found");
+ }
+
+ // because we were OFF the interface
+ // we get back is NOT assigned
+ NC->assignInterface( N );
+ NC->setCurrentState( Available );
+ return QString();
}
- return 0;
-}
-bool LanCardRun::canSetState( State_t Curr, Action_t A ) {
- // we only handle up down activate and deactivate
- switch( A ) {
- case Activate :
- { // at least available
- if( Curr == Available ) {
- return 1;
- }
- // or we can make one available
- InterfaceInfo * N = getInterface();
- if( ! N || N->assignedNode() != 0 ) {
- // non available or assigned
- return 0;
- }
- return 1;
- }
- case Deactivate :
- return ( Curr >= Available );
- default :
- // FT
- break;
+ if( A == Deactivate ) {
+ NC->assignInterface( 0 );
+ NC->setCurrentState( Off );
}
- return 0;
+
+ return QString();
}
@@ -160,6 +116,6 @@ InterfaceInfo * LanCardRun::getInterface( void ) {
// this is a LAN card
- if( Run->assignedNode() == netNode() ) {
+ if( Run->assignedConnection() == netNode()->connection() ) {
// assigned to us
return Run;
- } else if( Run->assignedNode() == 0 ) {
+ } else if( Run->assignedConnection() == 0 ) {
// free