author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (side-by-side diff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/lancard | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2 |
CONTROL files : changed version string
NS2 many changes and first release of OT2
Diffstat (limited to 'noncore/settings/networksettings2/lancard') (more/less context) (ignore whitespace changes)
6 files changed, 60 insertions, 99 deletions
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index 20ae7f6..e36f757 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp @@ -1,71 +1,77 @@ #include "lancard_NN.h" #include "lancard_NNI.h" static const char * LanCardNeeds[] = - { 0 }; + { 0 + }; + +static const char * LanCardProvides[] = + { "device", + 0 + }; /** * Constructor, find all of the possible interfaces */ LanCardNetNode::LanCardNetNode() : ANetNode(tr("LAN card")), NICMACAddresses() { InstanceCount = 2; } /** * Delete any interfaces that we own. */ LanCardNetNode::~LanCardNetNode(){ } const QString LanCardNetNode::nodeDescription(){ return tr("\ <p>Sets up a wired regular LAN card.</p>\ <p>Use this to set up 10/100/1000 MBit LAN cards.</p>\ " ); } ANetNodeInstance * LanCardNetNode::createInstance( void ) { return new ALanCard( this ); } const char ** LanCardNetNode::needs( void ) { return LanCardNeeds; } -const char * LanCardNetNode::provides( void ) { - return "device"; +const char ** LanCardNetNode::provides( void ) { + return LanCardProvides; } QString LanCardNetNode::genNic( long nr ) { QString S; return S.sprintf( "eth%ld", nr ); } void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) { if( A == "interfacecount" ) { InstanceCount = V.toLong(); } else if ( A == "macaddress" ) { NICMACAddresses.append( V ); } } void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) { TS << "interfacecount=" << InstanceCount << endl; for( QStringList::Iterator it = NICMACAddresses.begin(); it != NICMACAddresses.end(); ++it ) { TS << "macaddress=" << (*it) << endl; } } extern "C" { void create_plugin( QList<ANetNode> & PNN ) { PNN.append( new LanCardNetNode() ); } } diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h index 6882af7..dc7566a 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.h +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h @@ -1,50 +1,50 @@ #ifndef LANCARD_NETNODE_H #define LANCARD_NETNODE_H #include <qstringlist.h> #include "netnode.h" class ALanCard; class LanCardNetNode : public ANetNode{ Q_OBJECT public: LanCardNetNode(); virtual ~LanCardNetNode(); virtual const QString pixmapName() { return "Devices/card"; } virtual QString genNic( long ); virtual long instanceCount( void ) { return InstanceCount; } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); QStringList & addressesOfNIC( void ) { return NICMACAddresses; } private: virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); // number of interfaces for this device long InstanceCount; QStringList NICMACAddresses; }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/lancard/lancarddata.h b/noncore/settings/networksettings2/lancard/lancarddata.h index c76767f..8f5e2b5 100644 --- a/noncore/settings/networksettings2/lancard/lancarddata.h +++ b/noncore/settings/networksettings2/lancard/lancarddata.h @@ -1,13 +1,14 @@ #ifndef LANCARD_DATA_H #define LANCARD_DATA_H #include <qstringlist.h> #include <qstring.h> -typedef struct LanCardData { +class LanCardData { +public : bool AnyLanCard; QStringList HWAddresses; -} LanCardData_t; +} ; #endif 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 @@ -1,192 +1,148 @@ #include <qfile.h> #include <qtextstream.h> #include <qstringlist.h> #include <resources.h> #include "lancardrun.h" -void LanCardRun::detectState( NodeCollection * NC ) { +State_t LanCardRun::detectState( void ) { // 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()); + NodeCollection * NC = nodeCollection(); + QString S = QString( "/tmp/profile-%1.up" ). + arg( NC->number()); System & Sys = NSResources->system(); InterfaceInfo * Run; QFile F( S ); if( F.open( IO_ReadOnly ) ) { // could open file -> read interface and assign QString X; QTextStream TS(&F); X = TS.readLine(); // find interface if( handlesInterface( X ) ) { for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); It.current(); ++It ) { Run = It.current(); if( X == Run->Name ) { - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; + NC->assignInterface( Run ); + return IsUp; } } } } - if( ( Run = assignedInterface() ) ) { + if( ( Run = NC->assignedInterface() ) ) { // we already have an interface assigned -> still present ? if( ! Run->IsUp ) { // usb is still free -> keep assignment - NC->setCurrentState( Available ); - return; + return Available; } // else interface is up but NOT us -> some other profile } // nothing (valid) assigned to us - assignInterface( 0 ); + NC->assignInterface( 0 ); // find possible interface for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); It.current(); ++It ) { Run = It.current(); 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; + return Off; } } // no free found - 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(); } // 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 ) && ( Run->CardType == ARPHRD_ETHER #ifdef ARPHRD_IEEE1394 || Run->CardType == ARPHRD_IEEE1394 #endif ) ) { // 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 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 ); } diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h index b28dda7..57ef3fb 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.h +++ b/noncore/settings/networksettings2/lancard/lancardrun.h @@ -1,39 +1,37 @@ #ifndef LANCARDRUN_H #define LANCARDRUN_H -#include <asdevice.h> +#include <netnode.h> #include <qregexp.h> #include "lancarddata.h" -class LanCardRun : public AsDevice { +class LanCardRun : public RuntimeInfo { public : LanCardRun( ANetNodeInstance * NNI, - LanCardData & D ) : AsDevice( NNI ), - Pat( "eth[0-9]" ) - { Data = &D; } + LanCardData & D ) : RuntimeInfo( NNI ), + Pat( "eth[0-9]" ) { + Data = &D; + } - virtual AsDevice * device( void ) - { return (AsDevice *)this; } + virtual RuntimeInfo * device( void ) + { return this; } - virtual AsDevice * asDevice( void ) - { return (AsDevice *)this; } + bool handlesInterface( const QString & I ); + bool handlesInterface( const InterfaceInfo & II ); -protected : + State_t detectState( void ); - void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A, bool Force ); - bool canSetState( State_t Curr, Action_t A ); +protected : - bool handlesInterface( const QString & I ); - bool handlesInterface( const InterfaceInfo & II ); + QString setMyState( NodeCollection * , Action_t, bool ); private : InterfaceInfo * getInterface( void ); QRegExp Pat; LanCardData * Data; }; #endif diff --git a/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control b/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control index d5aca66..4f87d04 100644 --- a/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control +++ b/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control @@ -1,9 +1,9 @@ -Package: opie-networksettingsplugin2-lancard +Package: opie-networksettings2plugin-lancard Files: plugins/networksettings2/liblancard.so* Priority: optional Section: opie/settings Maintainer: Wim Delvaux <wimpie@handhelds.org> Architecture: arm Depends: opie-networksettings2, libopiecore2, libopienet2 Description: Network settings lancard plugin. Version: $QPE_VERSION$EXTRAVERSION |