Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/netnode.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/netnode.cpp | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index f00e0b3..0ab0e5b 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp @@ -122,33 +122,33 @@ void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ void ANetNodeInstance::saveAttributes( QTextStream & TS ) { TS << "__name=" << name() << endl; saveSpecificAttribute( TS ); } ANetNodeInstance * ANetNodeInstance::nextNode( void ) { - return connection()->findNext( this ); + return networkSetup()->findNext( this ); } // // // NODECOLLECTION // // -NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { +NetworkSetup::NetworkSetup( void ) : QList<ANetNodeInstance>() { IsModified = 0; Index = -1; Name=""; IsNew = 1; CurrentState = Unchecked; AssignedInterface = 0; Number = -1; Done = 0; } -NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) : +NetworkSetup::NetworkSetup( QTextStream & TS, bool & Dangling ) : QList<ANetNodeInstance>() { long idx; QString S, A, N; Number = -1; Done = 0; @@ -184,39 +184,39 @@ NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) : ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); Log(( "Find node %s : %p\n", N.latin1(), NNI )); if( NNI ) { append( NNI ); } else { // could not find a node type -> collection invalid - Log(( "Node %s missing -> connection dangling\n", + Log(( "Node %s missing -> NetworkSetup dangling\n", N.latin1() )); // create placeholder for this dangling NNI NNI = new ErrorNNI( N ); Dangling = 1; } } } while( 1 ); Log(( "Profile number %s : %d nodes\n", Name.latin1(), count() )); } -NodeCollection::~NodeCollection( void ) { +NetworkSetup::~NetworkSetup( void ) { } -const QString & NodeCollection::description( void ) { +const QString & NetworkSetup::description( void ) { ANetNodeInstance * NNI = getToplevel(); return (NNI) ? NNI->runtime()->description() : Name; } -void NodeCollection::append( ANetNodeInstance * NNI ) { - NNI->setConnection( this ); +void NetworkSetup::append( ANetNodeInstance * NNI ) { + NNI->setNetworkSetup( this ); QList<ANetNodeInstance>::append( NNI ); } -void NodeCollection::save( QTextStream & TS ) { +void NetworkSetup::save( QTextStream & TS ) { TS << "name=" << quote( Name ) << endl; TS << "number=" << number() << endl; ANetNodeInstance * NNI; for( QListIterator<ANetNodeInstance> it(*this); it.current(); @@ -225,39 +225,39 @@ void NodeCollection::save( QTextStream & TS ) { TS << "node=" << NNI->name() << endl; } TS << endl; IsNew = 0; } -ANetNodeInstance * NodeCollection::getToplevel( void ) { +ANetNodeInstance * NetworkSetup::getToplevel( void ) { ANetNodeInstance * NNI = 0; for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { NNI = it.current(); if( NNI->nodeClass()->isToplevel() ) { return NNI; } } return 0; } -ANetNodeInstance * NodeCollection::findByName( const QString & S ) { +ANetNodeInstance * NetworkSetup::findByName( const QString & S ) { ANetNodeInstance * NNI = 0; for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { NNI = it.current(); if( NNI->name() == S ) { return NNI; } } return 0; } -ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { +ANetNodeInstance * NetworkSetup::findNext( ANetNodeInstance * NNI ) { ANetNodeInstance * NNNI; if( ! NNI ) getToplevel(); for( QListIterator<ANetNodeInstance> it(*this); @@ -269,13 +269,13 @@ ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { return it.current(); } } return 0; // no more next } -int NodeCollection::compareItems( QCollection::Item I1, +int NetworkSetup::compareItems( QCollection::Item I1, QCollection::Item I2 ) { ANetNodeInstance * NNI1, * NNI2; NNI1 = (ANetNodeInstance *)I1; NNI2 = (ANetNodeInstance *)I2; return strcmp( NNI1->name(), NNI2->name() ); } @@ -287,13 +287,13 @@ static char * State2PixmapTbl[] = { "disabled", // disabled "off", // off "disconnected", // available "connected" // up }; -QPixmap NodeCollection::devicePixmap( void ) { +QPixmap NetworkSetup::devicePixmap( void ) { QPixmap pm = NSResources->getPixmap( getToplevel()->nextNode()->pixmapName()+"-large"); QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); @@ -305,17 +305,17 @@ QPixmap NodeCollection::devicePixmap( void ) { pm.height()-Mini.height(), Mini ); pm.setMask( pm.createHeuristicMask( TRUE ) ); return pm; } -QPixmap NodeCollection::statePixmap( State_t S) { +QPixmap NetworkSetup::statePixmap( State_t S) { return NSResources->getPixmap( State2PixmapTbl[S] ); } -QString NodeCollection::stateName( State_t S) { +QString NetworkSetup::stateName( State_t S) { switch( S ) { case Unknown : return qApp->translate( "networksettings2", "Unknown"); case Unavailable : return qApp->translate( "networksettings2", "Unavailable"); case Disabled : @@ -330,47 +330,47 @@ QString NodeCollection::stateName( State_t S) { default : break; } return QString(""); } -void NodeCollection::reassign( void ) { +void NetworkSetup::reassign( void ) { for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { - it.current()->setConnection( this ); + it.current()->setNetworkSetup( this ); } } -const QStringList & NodeCollection::triggers() { +const QStringList & NetworkSetup::triggers() { return getToplevel()->runtime()->triggers(); } -bool NodeCollection::hasDataForFile( SystemFile & S ) { +bool NetworkSetup::hasDataForFile( SystemFile & S ) { return ( firstWithDataForFile( S ) != 0 ); } -ANetNodeInstance * NodeCollection::firstWithDataForFile( SystemFile & S ) { +ANetNodeInstance * NetworkSetup::firstWithDataForFile( SystemFile & S ) { for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { if( it.current()->hasDataForFile( S ) ) { return it.current(); } } return 0; } -State_t NodeCollection::state( bool Update ) { +State_t NetworkSetup::state( bool Update ) { State_t NodeState; if( CurrentState == Unchecked || Update ) { // collect states of all nodes until with get the 'higest' // state possible - Log(( "Connection %s state %s\n", + Log(( "NetworkSetup %s state %s\n", Name.latin1(), StateName[CurrentState] )); CurrentState = Unknown; for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { @@ -392,13 +392,13 @@ State_t NodeCollection::state( bool Update ) { } } return CurrentState; } -QString NodeCollection::setState( Action_t A, bool Force ) { +QString NetworkSetup::setState( Action_t A, bool Force ) { QString msg; Action_t Actions[10]; int NoOfActions = 0; // get current state @@ -489,19 +489,28 @@ QString NodeCollection::setState( Action_t A, bool Force ) { return msg; } } return QString(); } +void NetworkSetup::copyFrom( const NetworkSetup & N ) { + Number = N.Number; + CurrentState = N.CurrentState; + Name = N.Name; + IsNew = N.IsNew; + Index = N.Index; + AssignedInterface = N.AssignedInterface; +} + // // // RuntimeInfo // // -QString RuntimeInfo::setState( NodeCollection * NC, +QString RuntimeInfo::setState( NetworkSetup * NC, Action_t A, bool Force ) { QString M; RuntimeInfo * Deeper = nextNode(); if( Deeper ) { |