Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index b4d9aaa..13979ce 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp @@ -33,4 +33,3 @@ NetworkSettingsData::~NetworkSettingsData( void ) { void NetworkSettingsData::loadSettings( void ) { - QString S; - ANetNodeInstance* NNI; + QString Line, S; QString Attr, Value; @@ -59,3 +58,3 @@ void NetworkSettingsData::loadSettings( void ) { while( ! TS.atEnd() ) { - S = TS.readLine(); + S = Line = TS.readLine(); @@ -75,6 +74,12 @@ void NetworkSettingsData::loadSettings( void ) { } else { - // load nodes + ANetNode * NN = 0; + ANetNodeInstance* NNI = 0; + if( S.startsWith( "nodetype " ) ) { + S = S.mid( 9, S.length()-9-1 ); + fprintf( stderr, "Node %s\n", S.latin1() ); + // try to find netnode + NN = NSResources->findNetNode( S ); + } else { + // try to find instance NNI = NSResources->createNodeInstance( S ); - if( ! NNI ) { - printf( "SKIPPING %s\n", S.latin1() ); } @@ -83,2 +88,4 @@ void NetworkSettingsData::loadSettings( void ) { S = TS.readLine(); + + if( NN || NNI ) { if( S.isEmpty() ) { @@ -87,4 +94,2 @@ void NetworkSettingsData::loadSettings( void ) { } - // node found ? - if( NNI ) { idx = S.find( '=' ); @@ -104,2 +109,6 @@ void NetworkSettingsData::loadSettings( void ) { + if( NN ) { + // set the attribute + NNI->setAttribute( Attr, Value ); + } else { // set the attribute @@ -107,3 +116,10 @@ void NetworkSettingsData::loadSettings( void ) { } - + } else { + LeftOvers.append( Line ); + // add empty line too as delimiter + if( S.isEmpty() ) { + // empty line + break; + } + } } while( 1 ); @@ -140,2 +156,21 @@ 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() ); + it.current(); + ++it ) { + TS << "[nodetype " + << it.current()->NetNode->name() + << "]" + << endl; + + it.current()->NetNode->saveAttributes( TS ); + } + { Name2Connection_t & M = NSResources->connections(); |