Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 88 |
1 files changed, 53 insertions, 35 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 | |||
@@ -116,8 +116,9 @@ void NetworkSettingsData::loadSettings( void ) { | |||
116 | 116 | ||
117 | if( S == "connection" ) { | 117 | if( S == "connection" ) { |
118 | // load connections -> collections of nodes | 118 | // load connections -> collections of nodes |
119 | NodeCollection * NC = new NodeCollection( TS ); | 119 | bool Dangling; |
120 | NSResources->addConnection( NC ); | 120 | NodeCollection * NC = new NodeCollection( TS, Dangling ); |
121 | NSResources->addConnection( NC, Dangling ); | ||
121 | } else { | 122 | } else { |
122 | ANetNode * NN = 0; | 123 | ANetNode * NN = 0; |
123 | ANetNodeInstance* NNI = 0; | 124 | ANetNodeInstance* NNI = 0; |
@@ -133,12 +134,20 @@ void NetworkSettingsData::loadSettings( void ) { | |||
133 | 134 | ||
134 | if( NN == 0 && NNI == 0 ) { | 135 | if( NN == 0 && NNI == 0 ) { |
135 | LeftOvers.append( Line ); | 136 | LeftOvers.append( Line ); |
137 | do { | ||
138 | Line = TS.readLine(); | ||
139 | // store even delimiter | ||
140 | LeftOvers.append( Line ); | ||
141 | } while ( ! Line.isEmpty() ); | ||
142 | |||
143 | //next section | ||
144 | continue; | ||
136 | } | 145 | } |
137 | 146 | ||
147 | // read entries of this section | ||
138 | do { | 148 | do { |
139 | S = Line = TS.readLine(); | 149 | S = Line = TS.readLine(); |
140 | 150 | ||
141 | if( NN || NNI ) { | ||
142 | if( S.isEmpty() ) { | 151 | if( S.isEmpty() ) { |
143 | // empty line | 152 | // empty line |
144 | break; | 153 | break; |
@@ -165,14 +174,6 @@ void NetworkSettingsData::loadSettings( void ) { | |||
165 | // set the attribute | 174 | // set the attribute |
166 | NNI->setAttribute( Attr, Value ); | 175 | NNI->setAttribute( Attr, Value ); |
167 | } | 176 | } |
168 | } else { | ||
169 | LeftOvers.append( Line ); | ||
170 | // add empty line too as delimiter | ||
171 | if( S.isEmpty() ) { | ||
172 | // empty line | ||
173 | break; | ||
174 | } | ||
175 | } | ||
176 | } while( 1 ); | 177 | } while( 1 ); |
177 | 178 | ||
178 | if( NNI ) { | 179 | if( NNI ) { |
@@ -181,6 +182,7 @@ void NetworkSettingsData::loadSettings( void ) { | |||
181 | NNI->setNew( FALSE ); | 182 | NNI->setNew( FALSE ); |
182 | NSResources->addNodeInstance( NNI ); | 183 | NSResources->addNodeInstance( NNI ); |
183 | } | 184 | } |
185 | |||
184 | if( NN ) { | 186 | if( NN ) { |
185 | Log( ( "Node %s : %p\n", NN->name(), NN ) ); | 187 | Log( ( "Node %s : %p\n", NN->name(), NN ) ); |
186 | } | 188 | } |
@@ -211,34 +213,29 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
211 | 213 | ||
212 | QTextStream TS( &F ); | 214 | QTextStream TS( &F ); |
213 | 215 | ||
214 | // save leftovers | ||
215 | for ( QStringList::Iterator it = LeftOvers.begin(); | ||
216 | it != LeftOvers.end(); ++it ) { | ||
217 | TS << (*it) << endl; | ||
218 | } | ||
219 | |||
220 | // save global configs | 216 | // save global configs |
221 | for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); | 217 | for( QDictIterator<ANetNode> it( NSResources->netNodes() ); |
222 | it.current(); | 218 | it.current(); |
223 | ++it ) { | 219 | ++it ) { |
224 | TS << "[nodetype " | 220 | TS << "[nodetype " |
225 | << quote( QString( it.current()->NetNode->name() ) ) | 221 | << quote( QString( it.current()->name() ) ) |
226 | << "]" | 222 | << "]" |
227 | << endl; | 223 | << endl; |
228 | 224 | ||
229 | it.current()->NetNode->saveAttributes( TS ); | 225 | it.current()->saveAttributes( TS ); |
230 | TS << endl; | 226 | TS << endl; |
231 | } | 227 | } |
232 | 228 | ||
233 | { Name2Connection_t & M = NSResources->connections(); | 229 | // save leftovers |
234 | ANetNodeInstance * NNI; | 230 | for ( QStringList::Iterator it = LeftOvers.begin(); |
231 | it != LeftOvers.end(); ++it ) { | ||
232 | TS << (*it) << endl; | ||
233 | } | ||
235 | 234 | ||
236 | // for all connections | 235 | // save all netnode instances |
237 | for( QDictIterator<NodeCollection> it(M); | 236 | { ANetNodeInstance * NNI; |
238 | it.current(); | 237 | for( QDictIterator<ANetNodeInstance> nit( |
239 | ++it ) { | 238 | NSResources->netNodeInstances()); |
240 | // all nodes in those connections | ||
241 | for( QListIterator<ANetNodeInstance> nit(*(it.current())); | ||
242 | nit.current(); | 239 | nit.current(); |
243 | ++nit ) { | 240 | ++nit ) { |
244 | // header | 241 | // header |
@@ -250,7 +247,27 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
250 | NNI->saveAttributes( TS ); | 247 | NNI->saveAttributes( TS ); |
251 | TS << endl; | 248 | TS << endl; |
252 | } | 249 | } |
250 | } | ||
253 | 251 | ||
252 | // good connections | ||
253 | { Name2Connection_t & M = NSResources->connections(); | ||
254 | |||
255 | // for all connections | ||
256 | for( QDictIterator<NodeCollection> it(M); | ||
257 | it.current(); | ||
258 | ++it ) { | ||
259 | TS << "[connection]" << endl; | ||
260 | it.current()->save(TS); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | // save dangling connections | ||
265 | { Name2Connection_t & M = NSResources->danglingConnections(); | ||
266 | |||
267 | // for all connections | ||
268 | for( QDictIterator<NodeCollection> it(M); | ||
269 | it.current(); | ||
270 | ++it ) { | ||
254 | TS << "[connection]" << endl; | 271 | TS << "[connection]" << endl; |
255 | it.current()->save(TS); | 272 | it.current()->save(TS); |
256 | } | 273 | } |
@@ -289,14 +306,15 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
289 | // regenerate system files | 306 | // regenerate system files |
290 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); | 307 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); |
291 | 308 | ||
292 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | 309 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
293 | nnit.current(); | 310 | nnit.current(); |
294 | ++nnit ) { | 311 | ++nnit ) { |
295 | { QStringList SL; | ||
296 | bool FirstItem = 1; | 312 | bool FirstItem = 1; |
297 | bool Generated = 0; | 313 | bool Generated = 0; |
298 | 314 | ||
299 | CurDevNN = nnit.current()->NetNode; | 315 | CurDevNN = nnit.current(); |
316 | |||
317 | { QStringList SL; | ||
300 | SL = CurDevNN->properFiles(); | 318 | SL = CurDevNN->properFiles(); |
301 | 319 | ||
302 | for ( QStringList::Iterator it = SL.begin(); | 320 | for ( QStringList::Iterator it = SL.begin(); |
@@ -395,10 +413,10 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
395 | SF = sfit.current(); | 413 | SF = sfit.current(); |
396 | 414 | ||
397 | // reset all | 415 | // reset all |
398 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | 416 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
399 | nnit.current(); | 417 | nnit.current(); |
400 | ++nnit ) { | 418 | ++nnit ) { |
401 | nnit.current()->NetNode->setDone(0); | 419 | nnit.current()->setDone(0); |
402 | } | 420 | } |
403 | 421 | ||
404 | for( QDictIterator<ANetNodeInstance> nniit( | 422 | for( QDictIterator<ANetNodeInstance> nniit( |
@@ -420,11 +438,11 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
420 | 438 | ||
421 | // are there netnodes that have instances and need | 439 | // are there netnodes that have instances and need |
422 | // to write data in this system file ? | 440 | // to write data in this system file ? |
423 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | 441 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
424 | ! needToGenerate && nnit.current(); | 442 | ! needToGenerate && nnit.current(); |
425 | ++nnit ) { | 443 | ++nnit ) { |
426 | 444 | ||
427 | NN = nnit.current()->NetNode; | 445 | NN = nnit.current(); |
428 | 446 | ||
429 | if( NN->hasDataForFile( *SF ) ) { | 447 | if( NN->hasDataForFile( *SF ) ) { |
430 | // netnode can have data | 448 | // netnode can have data |