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 @@ -118,4 +118,5 @@ void NetworkSettingsData::loadSettings( void ) { // 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 { @@ -135,4 +136,13 @@ void NetworkSettingsData::loadSettings( void ) { 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 { @@ -140,36 +150,27 @@ void NetworkSettingsData::loadSettings( void ) { - 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 ); } @@ -183,2 +184,3 @@ void NetworkSettingsData::loadSettings( void ) { } + if( NN ) { @@ -213,10 +215,4 @@ QString NetworkSettingsData::saveSettings( void ) { - // 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(); @@ -224,3 +220,3 @@ QString NetworkSettingsData::saveSettings( void ) { TS << "[nodetype " - << quote( QString( it.current()->NetNode->name() ) ) + << quote( QString( it.current()->name() ) ) << "]" @@ -228,3 +224,3 @@ QString NetworkSettingsData::saveSettings( void ) { - it.current()->NetNode->saveAttributes( TS ); + it.current()->saveAttributes( TS ); TS << endl; @@ -232,4 +228,27 @@ QString NetworkSettingsData::saveSettings( void ) { + // 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; @@ -239,16 +258,14 @@ QString NetworkSettingsData::saveSettings( void ) { ++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; @@ -291,10 +308,11 @@ QString NetworkSettingsData::generateSettings( void ) { - 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(); @@ -397,6 +415,6 @@ 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); } @@ -422,3 +440,3 @@ QString NetworkSettingsData::generateSettings( void ) { // to write data in this system file ? - for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); + for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); ! needToGenerate && nnit.current(); @@ -426,3 +444,3 @@ QString NetworkSettingsData::generateSettings( void ) { - NN = nnit.current()->NetNode; + NN = nnit.current(); |