author | wimpie <wimpie> | 2005-01-07 15:23:23 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-07 15:23:23 (UTC) |
commit | b4eced64efad35beeb2004243ca26bf7eb20eaba (patch) (side-by-side diff) | |
tree | 14caf32705c787a8bffc917ecdf216ad40cfbdc0 /noncore/settings/networksettings2/nsdata.cpp | |
parent | 7af7203a51ddcf85f9f60e39157fcad21f7d9e34 (diff) | |
download | opie-b4eced64efad35beeb2004243ca26bf7eb20eaba.zip opie-b4eced64efad35beeb2004243ca26bf7eb20eaba.tar.gz opie-b4eced64efad35beeb2004243ca26bf7eb20eaba.tar.bz2 |
All NS2 libraries are now properly working plugins
Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 152 |
1 files changed, 85 insertions, 67 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index 698a941..d76353a 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp @@ -117,6 +117,7 @@ void NetworkSettingsData::loadSettings( void ) { if( S == "connection" ) { // load connections -> collections of nodes - NodeCollection * NC = new NodeCollection( TS ); - NSResources->addConnection( NC ); + bool Dangling; + NodeCollection * NC = new NodeCollection( TS, Dangling ); + NSResources->addConnection( NC, Dangling ); } else { ANetNode * NN = 0; @@ -134,43 +135,43 @@ void NetworkSettingsData::loadSettings( void ) { if( NN == 0 && NNI == 0 ) { LeftOvers.append( Line ); - } + do { + Line = TS.readLine(); + // store even delimiter + LeftOvers.append( Line ); + } while ( ! Line.isEmpty() ); + + //next section + continue; + } + // read entries of this section do { S = Line = TS.readLine(); - if( NN || NNI ) { - if( S.isEmpty() ) { - // empty line - break; - } - idx = S.find( '=' ); - if( idx > 0 ) { - Attr = S.left( idx ); - Value = S.mid( idx+1, S.length() ); - } else { - Value=""; - Attr = S; - } + if( S.isEmpty() ) { + // empty line + break; + } + idx = S.find( '=' ); + if( idx > 0 ) { + Attr = S.left( idx ); + Value = S.mid( idx+1, S.length() ); + } else { + Value=""; + Attr = S; + } - Value.stripWhiteSpace(); - Attr.stripWhiteSpace(); - Attr.lower(); - // dequote Attr - Value = deQuote(Value); - - if( NN ) { - // set the attribute - NN->setAttribute( Attr, Value ); - } else { - // set the attribute - NNI->setAttribute( Attr, Value ); - } + Value.stripWhiteSpace(); + Attr.stripWhiteSpace(); + Attr.lower(); + // dequote Attr + Value = deQuote(Value); + + if( NN ) { + // set the attribute + NN->setAttribute( Attr, Value ); } else { - LeftOvers.append( Line ); - // add empty line too as delimiter - if( S.isEmpty() ) { - // empty line - break; - } + // set the attribute + NNI->setAttribute( Attr, Value ); } } while( 1 ); @@ -182,4 +183,5 @@ void NetworkSettingsData::loadSettings( void ) { NSResources->addNodeInstance( NNI ); } + if( NN ) { Log( ( "Node %s : %p\n", NN->name(), NN ) ); @@ -212,25 +214,42 @@ QString NetworkSettingsData::saveSettings( void ) { QTextStream TS( &F ); - // save leftovers - for ( QStringList::Iterator it = LeftOvers.begin(); - it != LeftOvers.end(); ++it ) { - TS << (*it) << endl; - } - // save global configs - for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); + for( QDictIterator<ANetNode> it( NSResources->netNodes() ); it.current(); ++it ) { TS << "[nodetype " - << quote( QString( it.current()->NetNode->name() ) ) + << quote( QString( it.current()->name() ) ) << "]" << endl; - it.current()->NetNode->saveAttributes( TS ); + it.current()->saveAttributes( TS ); TS << endl; } + // save leftovers + for ( QStringList::Iterator it = LeftOvers.begin(); + it != LeftOvers.end(); ++it ) { + TS << (*it) << endl; + } + + // save all netnode instances + { ANetNodeInstance * NNI; + for( QDictIterator<ANetNodeInstance> nit( + NSResources->netNodeInstances()); + nit.current(); + ++nit ) { + // header + NNI = nit.current(); + TS << '[' + << QString(NNI->nodeClass()->name()) + << ']' + << endl; + NNI->saveAttributes( TS ); + TS << endl; + } + } + + // good connections { Name2Connection_t & M = NSResources->connections(); - ANetNodeInstance * NNI; // for all connections @@ -238,18 +257,16 @@ QString NetworkSettingsData::saveSettings( void ) { it.current(); ++it ) { - // all nodes in those connections - for( QListIterator<ANetNodeInstance> nit(*(it.current())); - nit.current(); - ++nit ) { - // header - NNI = nit.current(); - TS << '[' - << QString(NNI->nodeClass()->name()) - << ']' - << endl; - NNI->saveAttributes( TS ); - TS << endl; - } + TS << "[connection]" << endl; + it.current()->save(TS); + } + } + // save dangling connections + { Name2Connection_t & M = NSResources->danglingConnections(); + + // for all connections + for( QDictIterator<NodeCollection> it(M); + it.current(); + ++it ) { TS << "[connection]" << endl; it.current()->save(TS); @@ -290,12 +307,13 @@ QString NetworkSettingsData::generateSettings( void ) { Log( ( "Generating settings from %s\n", CfgFile.latin1() )); - for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); + for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); nnit.current(); ++nnit ) { - { QStringList SL; - bool FirstItem = 1; - bool Generated = 0; + bool FirstItem = 1; + bool Generated = 0; - CurDevNN = nnit.current()->NetNode; + CurDevNN = nnit.current(); + + { QStringList SL; SL = CurDevNN->properFiles(); @@ -396,8 +414,8 @@ QString NetworkSettingsData::generateSettings( void ) { // reset all - for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); + for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); nnit.current(); ++nnit ) { - nnit.current()->NetNode->setDone(0); + nnit.current()->setDone(0); } @@ -421,9 +439,9 @@ QString NetworkSettingsData::generateSettings( void ) { // are there netnodes that have instances and need // to write data in this system file ? - for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); + for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); ! needToGenerate && nnit.current(); ++nnit ) { - NN = nnit.current()->NetNode; + NN = nnit.current(); if( NN->hasDataForFile( *SF ) ) { |