00001 #include <system.h> 00002 #include <netnode.h> 00003 #include <resources.h> 00004 #include "networkrun.h" 00005 00006 State_t NetworkRun::detectState( void ) { 00007 InterfaceInfo * II = networkSetup()->assignedInterface(); 00008 00009 if( II && II->IsUp ) { 00010 // device has assigned interface 00011 return IsUp; 00012 } 00013 00014 // had no interface or interface is no longer up -> release 00015 networkSetup()->assignInterface( 0 ); 00016 00017 return Unknown; 00018 } 00019 00020 QString NetworkRun::setMyState( NetworkSetup * NC, Action_t A, bool ) { 00021 // we handle UP and DOWN 00022 InterfaceInfo * II = NC->assignedInterface(); 00023 00024 if( ! II ) { 00025 Log(( "no interface assigned." )); 00026 return QString(); 00027 } 00028 00029 QStringList SL; 00030 00031 if( A == Up ) { 00032 // we can bring UP if lower level is available 00033 SL << "ifup"; 00034 } else if( A == Down ) { 00035 SL << "ifdown"; 00036 } else { 00037 return QString(); 00038 } 00039 00040 SL << QString().sprintf( "%s=A%ld%s", 00041 II->Name.latin1(), 00042 networkSetup()->number(), 00043 II->Name.latin1() ); 00044 00045 if( ! NSResources->system().runAsRoot( SL ) ) { 00046 return QString("Cannot call %1").arg(SL.join(" ")); 00047 } 00048 00049 return QString(); 00050 }
1.4.2