author | wimpie <wimpie> | 2004-04-07 00:09:37 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-07 00:09:37 (UTC) |
commit | b93d9e0c4384be0a6f40be257ba791004388400b (patch) (side-by-side diff) | |
tree | 2ca0e41dc8c99e1af3ce2f0305d458f76d10db45 /noncore/settings/networksettings2/lancard/lancardrun.cpp | |
parent | 1b7aaf904fa70c16eee03155bd826e921798cc22 (diff) | |
download | opie-b93d9e0c4384be0a6f40be257ba791004388400b.zip opie-b93d9e0c4384be0a6f40be257ba791004388400b.tar.gz opie-b93d9e0c4384be0a6f40be257ba791004388400b.tar.bz2 |
MANY changes ... lancards should be OK now
Diffstat (limited to 'noncore/settings/networksettings2/lancard/lancardrun.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/lancard/lancardrun.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp index 951756d..2e4fc43 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.cpp +++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp @@ -1,18 +1,19 @@ #include <qfile.h> #include <qtextstream.h> +#include <qstringlist.h> #include <resources.h> #include "lancardrun.h" void LanCardRun::detectState( NodeCollection * NC ) { // unavailable : no card found // available : card found and assigned to us or free // up : card found and assigned to us and up QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); System & Sys = NSResources->system(); InterfaceInfo * Run; QFile F( S ); if( F.open( IO_ReadOnly ) ) { @@ -40,34 +41,38 @@ void LanCardRun::detectState( NodeCollection * NC ) { // we already have an interface assigned -> still present ? if( ! Run->IsUp ) { // usb is still free -> keep assignment NC->setCurrentState( Available ); return; } // else interface is up but NOT us -> some other profile } // nothing (valid) assigned to us assignInterface( 0 ); // find possible interface for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); It.current(); ++It ) { Run = It.current(); - if( handlesInterface( Run->Name ) && - Run->CardType == ARPHRD_ETHER && + if( handlesInterface( *Run ) && + ( Run->CardType == ARPHRD_ETHER +#ifdef ARPHRD_IEEE1394 + || Run->CardType == ARPHRD_IEEE1394 +#endif + ) && ! Run->IsUp ) { // proper type, and Not UP -> free NC->setCurrentState( Off ); return; } } // no free found NC->setCurrentState( Unavailable ); } bool LanCardRun::setState( NodeCollection * NC, Action_t A ) { // we only handle activate and deactivate @@ -132,35 +137,56 @@ bool LanCardRun::canSetState( State_t Curr, Action_t A ) { // FT break; } return 0; } // get interface that is free or assigned to us InterfaceInfo * LanCardRun::getInterface( void ) { System & S = NSResources->system(); InterfaceInfo * best = 0, * Run; for( QDictIterator<InterfaceInfo> It(S.interfaces()); It.current(); ++It ) { Run = It.current(); - if( handlesInterface( Run->Name ) && - Run->CardType == ARPHRD_ETHER + if( handlesInterface( *Run ) && + ( Run->CardType == ARPHRD_ETHER +#ifdef ARPHRD_IEEE1394 + || Run->CardType == ARPHRD_IEEE1394 +#endif + ) ) { // this is a LAN card if( Run->assignedNode() == netNode() ) { // assigned to us return Run; } else if( Run->assignedNode() == 0 ) { // free best = Run; } } } return best; // can be 0 } bool LanCardRun::handlesInterface( const QString & S ) { + InterfaceInfo * II; + II = NSResources->system().interface( S ); + if( ( II = NSResources->system().interface( S ) ) ) { + return handlesInterface( *II ); + } return Pat.match( S ) >= 0; } + +bool LanCardRun::handlesInterface( const InterfaceInfo & II ) { + if( Pat.match( II.Name ) < 0 ) + return 0; + + if( Data->AnyLanCard ) { + return 1; + } + + // must also match hardware address + return ( Data->HWAddresses.findIndex( II.MACAddress ) >= 0 ); +} |