Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 252 |
1 files changed, 187 insertions, 65 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index e2dd5b5..698a941 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -1,15 +1,16 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <opie2/odebug.h> | ||
2 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
3 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
4 | #include <qdir.h> | 5 | #include <qdir.h> |
5 | #include <qfile.h> | 6 | #include <qfile.h> |
6 | #include <qfileinfo.h> | 7 | #include <qfileinfo.h> |
7 | 8 | ||
8 | #include "nsdata.h" | 9 | #include "nsdata.h" |
9 | #include <asdevice.h> | 10 | #include <netnode.h> |
10 | #include <resources.h> | 11 | #include <resources.h> |
11 | 12 | ||
12 | static QString CfgFile; | 13 | static QString CfgFile; |
13 | 14 | ||
14 | NetworkSettingsData::NetworkSettingsData( void ) { | 15 | NetworkSettingsData::NetworkSettingsData( void ) { |
15 | // init global resources structure | 16 | // init global resources structure |
@@ -24,14 +25,52 @@ NetworkSettingsData::NetworkSettingsData( void ) { | |||
24 | 25 | ||
25 | CfgFile.sprintf( "%s/Settings/NS2.conf", | 26 | CfgFile.sprintf( "%s/Settings/NS2.conf", |
26 | NSResources->currentUser().HomeDir.latin1() ); | 27 | NSResources->currentUser().HomeDir.latin1() ); |
27 | Log(( "Cfg from %s\n", CfgFile.latin1() )); | 28 | Log(( "Cfg from %s\n", CfgFile.latin1() )); |
28 | 29 | ||
29 | // load settings | 30 | // load settings |
30 | IsModified = 0; | ||
31 | loadSettings(); | 31 | loadSettings(); |
32 | |||
33 | // assign interfaces by scanning /tmp/profile-%s.Up files | ||
34 | { QDir D( "/tmp" ); | ||
35 | QFile * F = new QFile; | ||
36 | int profilenr; | ||
37 | QString interfacename; | ||
38 | QTextStream TS ( F ); | ||
39 | |||
40 | QStringList SL = D.entryList( "profile-*.up"); | ||
41 | |||
42 | Log(( "System reports %d interfaces. Found %d up\n", | ||
43 | NSResources->system().interfaces().count(), | ||
44 | SL.count() )); | ||
45 | |||
46 | for ( QStringList::Iterator it = SL.begin(); | ||
47 | it != SL.end(); | ||
48 | ++it ) { | ||
49 | profilenr = atol( (*it).mid( 8 ).latin1() ); | ||
50 | // read the interface store int 'up' | ||
51 | F->setName( D.path() + "/" + (*it) ); | ||
52 | if( F->open( IO_ReadOnly ) ) { | ||
53 | NodeCollection * NC; | ||
54 | interfacename = TS.readLine(); | ||
55 | F->close(); | ||
56 | |||
57 | Log(( "Assign interface %s to Profile nr %d\n", | ||
58 | interfacename.latin1(), profilenr )); | ||
59 | |||
60 | NC = NSResources->getConnection( profilenr ); | ||
61 | if( NC ) { | ||
62 | NC->assignInterface( | ||
63 | NSResources->system().findInterface( interfacename ) ); | ||
64 | } else { | ||
65 | Log(( "Profile nr %d no longer defined\n", | ||
66 | profilenr )); | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | } | ||
32 | } | 71 | } |
33 | 72 | ||
34 | // saving is done by caller | 73 | // saving is done by caller |
35 | NetworkSettingsData::~NetworkSettingsData( void ) { | 74 | NetworkSettingsData::~NetworkSettingsData( void ) { |
36 | delete NSResources; | 75 | delete NSResources; |
37 | } | 76 | } |
@@ -41,12 +80,14 @@ void NetworkSettingsData::loadSettings( void ) { | |||
41 | QString Attr, Value; | 80 | QString Attr, Value; |
42 | long idx; | 81 | long idx; |
43 | 82 | ||
44 | QFile F( CfgFile ); | 83 | QFile F( CfgFile ); |
45 | QTextStream TS( &F ); | 84 | QTextStream TS( &F ); |
46 | 85 | ||
86 | ForceModified = 0; | ||
87 | |||
47 | do { | 88 | do { |
48 | 89 | ||
49 | if( ! F.open(IO_ReadOnly) ) | 90 | if( ! F.open(IO_ReadOnly) ) |
50 | break; | 91 | break; |
51 | 92 | ||
52 | /* load the file -> | 93 | /* load the file -> |
@@ -82,17 +123,15 @@ void NetworkSettingsData::loadSettings( void ) { | |||
82 | ANetNodeInstance* NNI = 0; | 123 | ANetNodeInstance* NNI = 0; |
83 | if( S.startsWith( "nodetype " ) ) { | 124 | if( S.startsWith( "nodetype " ) ) { |
84 | S = S.mid( 9, S.length()-9 ); | 125 | S = S.mid( 9, S.length()-9 ); |
85 | S = deQuote(S); | 126 | S = deQuote(S); |
86 | // try to find netnode | 127 | // try to find netnode |
87 | NN = NSResources->findNetNode( S ); | 128 | NN = NSResources->findNetNode( S ); |
88 | Log( ( "Node %s : %p\n", S.latin1(), NN ) ); | ||
89 | } else { | 129 | } else { |
90 | // try to find instance | 130 | // try to find instance |
91 | NNI = NSResources->createNodeInstance( S ); | 131 | NNI = NSResources->createNodeInstance( S ); |
92 | Log( ( "NodeInstance %s : %p\n", S.latin1(), NNI )); | ||
93 | } | 132 | } |
94 | 133 | ||
95 | if( NN == 0 && NNI == 0 ) { | 134 | if( NN == 0 && NNI == 0 ) { |
96 | LeftOvers.append( Line ); | 135 | LeftOvers.append( Line ); |
97 | } | 136 | } |
98 | 137 | ||
@@ -135,15 +174,19 @@ void NetworkSettingsData::loadSettings( void ) { | |||
135 | } | 174 | } |
136 | } | 175 | } |
137 | } while( 1 ); | 176 | } while( 1 ); |
138 | 177 | ||
139 | if( NNI ) { | 178 | if( NNI ) { |
140 | // loading from file -> exists | 179 | // loading from file -> exists |
180 | Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI )); | ||
141 | NNI->setNew( FALSE ); | 181 | NNI->setNew( FALSE ); |
142 | NSResources->addNodeInstance( NNI ); | 182 | NSResources->addNodeInstance( NNI ); |
143 | } | 183 | } |
184 | if( NN ) { | ||
185 | Log( ( "Node %s : %p\n", NN->name(), NN ) ); | ||
186 | } | ||
144 | } | 187 | } |
145 | } | 188 | } |
146 | 189 | ||
147 | } while( 0 ); | 190 | } while( 0 ); |
148 | 191 | ||
149 | } | 192 | } |
@@ -217,76 +260,141 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
217 | D.rename( CfgFile + ".bup", CfgFile ); | 260 | D.rename( CfgFile + ".bup", CfgFile ); |
218 | 261 | ||
219 | // | 262 | // |
220 | // proper files AND system files regenerated | 263 | // proper files AND system files regenerated |
221 | // | 264 | // |
222 | 265 | ||
223 | setModified( 0 ); | 266 | |
267 | for( QDictIterator<NodeCollection> it(NSResources->connections()); | ||
268 | it.current(); | ||
269 | ++it ) { | ||
270 | it.current()->setModified( 0 ); | ||
271 | } | ||
272 | |||
224 | return ErrS; | 273 | return ErrS; |
225 | } | 274 | } |
226 | 275 | ||
227 | QString NetworkSettingsData::generateSettings( void ) { | 276 | QString NetworkSettingsData::generateSettings( void ) { |
228 | QString S = ""; | 277 | QString S = ""; |
229 | Name2SystemFile_t & SFM = NSResources->systemFiles(); | 278 | Name2SystemFile_t & SFM = NSResources->systemFiles(); |
230 | Name2Connection_t & M = NSResources->connections(); | 279 | Name2Connection_t & M = NSResources->connections(); |
231 | NodeCollection * NC; | 280 | NodeCollection * NC; |
232 | ANetNodeInstance * NNI; | 281 | ANetNodeInstance * NNI; |
233 | ANetNodeInstance * FirstWithData; | 282 | ANetNodeInstance * FirstWithData; |
234 | SystemFile * SF; | 283 | RuntimeInfo * CurDev; |
235 | AsDevice * CurDev; | ||
236 | ANetNode * NN, * CurDevNN = 0; | 284 | ANetNode * NN, * CurDevNN = 0; |
237 | long NoOfDevs; | 285 | long NoOfDevs; |
238 | long DevCtStart; | 286 | long DevCtStart; |
239 | bool needToGenerate; | 287 | bool needToGenerate; |
240 | 288 | ||
241 | // regenerate system files | 289 | // regenerate system files |
242 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); | 290 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); |
243 | 291 | ||
244 | // | 292 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); |
245 | // generate files proper to each netnodeinstance | 293 | nnit.current(); |
246 | // | 294 | ++nnit ) { |
247 | { Name2Instance_t & NNIs = NSResources->netNodeInstances(); | 295 | { QStringList SL; |
248 | 296 | bool FirstItem = 1; | |
249 | for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); | 297 | bool Generated = 0; |
250 | NNIIt.current(); | 298 | |
251 | ++NNIIt ) { | 299 | CurDevNN = nnit.current()->NetNode; |
252 | // for all nodes find those that are modified | 300 | SL = CurDevNN->properFiles(); |
253 | NNI = NNIIt.current(); | 301 | |
254 | 302 | for ( QStringList::Iterator it = SL.begin(); | |
255 | { // get list of proper files for this nodeclass (if any) | 303 | it != SL.end(); |
256 | QStringList * PF = NNI->nodeClass()->properFiles(); | 304 | ++it ) { |
257 | 305 | ||
258 | if( PF ) { | 306 | Generated = 0; |
259 | for ( QStringList::Iterator it = PF->begin(); | 307 | FirstItem = 1; |
260 | it != PF->end(); | 308 | // iterate over NNI's of this class |
261 | ++it ) { | 309 | for( QDictIterator<ANetNodeInstance> nniit( |
262 | QFile * F = NNI->openFile( (*it) ); | 310 | NSResources->netNodeInstances() ); |
263 | if( F ) { | 311 | nniit.current(); |
264 | QTextStream TS( F ); | 312 | ++nniit ) { |
265 | if( NNI->generateFile( (*it), F->name(), TS, -1 ) == 2 ) { | 313 | if( nniit.current()->nodeClass() != CurDevNN ) |
266 | // problem generating | 314 | // different class |
315 | continue; | ||
316 | |||
317 | // open proper file | ||
318 | { SystemFile SF( (*it) ); | ||
319 | |||
320 | if( ! CurDevNN->openFile( SF, nniit.current()) ) { | ||
321 | // cannot open | ||
322 | S = qApp->translate( "NetworkSettings", | ||
323 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | ||
324 | arg( (*it) ).arg( CurDevNN->name() ); | ||
325 | return S; | ||
326 | } | ||
327 | |||
328 | if( ! SF.open() ) { | ||
329 | S = qApp->translate( "NetworkSettings", | ||
330 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | ||
331 | arg( (*it) ).arg( CurDevNN->name() ); | ||
332 | return S; | ||
333 | } | ||
334 | |||
335 | // preamble on first | ||
336 | if( FirstItem ) { | ||
337 | if( CurDevNN->generatePreamble( SF ) == 2 ) { | ||
267 | S = qApp->translate( "NetworkSettings", | 338 | S = qApp->translate( "NetworkSettings", |
268 | "<p>Cannot generate files proper to \"%1\"</p>" ). | 339 | "<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ). |
269 | arg(NNI->nodeClass()->name()) ; | 340 | arg( (*it) ). |
270 | delete F; | 341 | arg( CurDevNN->name() ); |
271 | return S; | 342 | return S; |
272 | } | 343 | } |
273 | delete F; | 344 | } |
345 | FirstItem = 0; | ||
346 | Generated = 1; | ||
347 | |||
348 | // item specific | ||
349 | if( nniit.current()->generateFile( SF, -1 ) == 2 ) { | ||
350 | S = qApp->translate( "NetworkSettings", | ||
351 | "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ). | ||
352 | arg( nniit.current()->name() ). | ||
353 | arg( (*it) ). | ||
354 | arg( CurDevNN->name() ); | ||
355 | return S; | ||
274 | } | 356 | } |
275 | } | 357 | } |
276 | } | 358 | } |
359 | |||
360 | if( Generated ) { | ||
361 | SystemFile SF( (*it) ); | ||
362 | |||
363 | if( CurDevNN->openFile( SF, 0 ) && | ||
364 | ! SF.path().isEmpty() | ||
365 | ) { | ||
366 | |||
367 | if( ! SF.open() ) { | ||
368 | S = qApp->translate( "NetworkSettings", | ||
369 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | ||
370 | arg( (*it) ).arg( CurDevNN->name() ); | ||
371 | return S; | ||
372 | } | ||
373 | |||
374 | if( CurDevNN->generatePostamble( SF ) == 2 ) { | ||
375 | S = qApp->translate( "NetworkSettings", | ||
376 | "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ). | ||
377 | arg( (*it) ). | ||
378 | arg( CurDevNN->name() ); | ||
379 | return S; | ||
380 | } | ||
381 | } // no postamble | ||
382 | } | ||
277 | } | 383 | } |
278 | } | 384 | } |
279 | } | 385 | } |
280 | 386 | ||
281 | // | 387 | // |
282 | // generate all system files | 388 | // generate all registered files |
283 | // | 389 | // |
284 | for( QDictIterator<SystemFile> sfit(SFM); | 390 | for( QDictIterator<SystemFile> sfit(SFM); |
285 | sfit.current(); | 391 | sfit.current(); |
286 | ++sfit ) { | 392 | ++sfit ) { |
393 | SystemFile * SF; | ||
394 | |||
287 | SF = sfit.current(); | 395 | SF = sfit.current(); |
288 | 396 | ||
289 | // reset all | 397 | // reset all |
290 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | 398 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); |
291 | nnit.current(); | 399 | nnit.current(); |
292 | ++nnit ) { | 400 | ++nnit ) { |
@@ -303,25 +411,25 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
303 | for( QDictIterator<NodeCollection> ncit(M); | 411 | for( QDictIterator<NodeCollection> ncit(M); |
304 | ncit.current(); | 412 | ncit.current(); |
305 | ++ncit ) { | 413 | ++ncit ) { |
306 | ncit.current()->setDone(0); | 414 | ncit.current()->setDone(0); |
307 | } | 415 | } |
308 | 416 | ||
309 | Log( ( "Generating %s\n", SF->name().latin1() )); | 417 | Log( ( "Generating system file %s\n", SF->name().latin1() )); |
310 | 418 | ||
311 | needToGenerate = 0; | 419 | needToGenerate = 0; |
312 | 420 | ||
313 | // are there netnodes that have instances and need | 421 | // are there netnodes that have instances and need |
314 | // to write data in this system file ? | 422 | // to write data in this system file ? |
315 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | 423 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); |
316 | ! needToGenerate && nnit.current(); | 424 | ! needToGenerate && nnit.current(); |
317 | ++nnit ) { | 425 | ++nnit ) { |
318 | 426 | ||
319 | NN = nnit.current()->NetNode; | 427 | NN = nnit.current()->NetNode; |
320 | 428 | ||
321 | if( NN->hasDataForFile( SF->name() ) ) { | 429 | if( NN->hasDataForFile( *SF ) ) { |
322 | // netnode can have data | 430 | // netnode can have data |
323 | 431 | ||
324 | // are there instances of this node ? | 432 | // are there instances of this node ? |
325 | for( QDictIterator<ANetNodeInstance> nniit( | 433 | for( QDictIterator<ANetNodeInstance> nniit( |
326 | NSResources->netNodeInstances() ); | 434 | NSResources->netNodeInstances() ); |
327 | ! needToGenerate && nniit.current(); | 435 | ! needToGenerate && nniit.current(); |
@@ -342,13 +450,18 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
342 | // in this systemfile | 450 | // in this systemfile |
343 | Log(("No nodes for systemfile %s\n", SF->name().latin1() )); | 451 | Log(("No nodes for systemfile %s\n", SF->name().latin1() )); |
344 | continue; | 452 | continue; |
345 | } | 453 | } |
346 | 454 | ||
347 | // ok generate this system file | 455 | // ok generate this system file |
348 | SF->open(); | 456 | if( ! SF->open() ) { |
457 | S = qApp->translate( "NetworkSettings", | ||
458 | "<p>Cannot open system file \"%1\"</p>" ). | ||
459 | arg( SF->name() ); | ||
460 | return S; | ||
461 | } | ||
349 | 462 | ||
350 | // global presection for this system file | 463 | // global presection for this system file |
351 | if( ! SF->preSection() ) { | 464 | if( ! SF->preSection() ) { |
352 | S = qApp->translate( "NetworkSettings", | 465 | S = qApp->translate( "NetworkSettings", |
353 | "<p>Error in section \"Preamble\" for file \"%1\"</p>" ). | 466 | "<p>Error in section \"Preamble\" for file \"%1\"</p>" ). |
354 | arg( SF->name() ); | 467 | arg( SF->name() ); |
@@ -364,78 +477,80 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
364 | 477 | ||
365 | if( NC->done() ) { | 478 | if( NC->done() ) { |
366 | // already done | 479 | // already done |
367 | continue; | 480 | continue; |
368 | } | 481 | } |
369 | 482 | ||
370 | if( ! NC->hasDataForFile( SF->name() ) ) { | 483 | if( ! NC->hasDataForFile( *SF ) ) { |
371 | // no data | 484 | // no data |
372 | continue; | 485 | continue; |
373 | } | 486 | } |
374 | 487 | ||
375 | Log(("Generating %s for connection %s\n", | 488 | Log(("Generating %s for connection %s\n", |
376 | SF->name().latin1(), NC->name().latin1() )); | 489 | SF->name().latin1(), NC->name().latin1() )); |
377 | // find highest item that wants to write data to this file | 490 | // find highest item that wants to write data to this file |
378 | FirstWithData = NC->firstWithDataForFile( SF->name() ); | 491 | FirstWithData = NC->firstWithDataForFile( *SF ); |
379 | 492 | ||
380 | // find device on which this connection works | 493 | // find device on which this connection works |
381 | CurDev = NC->device(); | 494 | CurDev = NC->device(); |
382 | // class of that node | 495 | // class of that node |
383 | CurDevNN = CurDev->netNode()->nodeClass(); | 496 | CurDevNN = CurDev->netNode()->nodeClass(); |
384 | 497 | ||
385 | Log(( "%s is done %d\n", | ||
386 | FirstWithData->nodeClass()->name(), | ||
387 | FirstWithData->nodeClass()->done() )); | ||
388 | |||
389 | if( ! FirstWithData->nodeClass()->done() ) { | 498 | if( ! FirstWithData->nodeClass()->done() ) { |
390 | // generate fixed part | 499 | // generate fixed part |
391 | if( ! SF->preDeviceSection( CurDevNN ) ) { | 500 | if( ! SF->preDeviceSection( CurDevNN ) ) { |
392 | S = qApp->translate( "NetworkSettings", | 501 | S = qApp->translate( "NetworkSettings", |
393 | "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ). | 502 | "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ). |
394 | arg( SF->name() ); | 503 | arg( SF->name() ); |
395 | return S; | 504 | return S; |
396 | } | 505 | } |
397 | 506 | ||
398 | if( FirstWithData->nodeClass()->generateFile( | 507 | if( FirstWithData->nodeClass()->generateFile( |
399 | SF->name(), SF->path(), *SF, -1 ) == 2 ) { | 508 | *SF, |
509 | FirstWithData, | ||
510 | -2 ) == 2 ) { | ||
400 | S = qApp->translate( "NetworkSettings", | 511 | S = qApp->translate( "NetworkSettings", |
401 | "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ). | 512 | "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ). |
402 | arg( SF->name() ). | 513 | arg( SF->name() ). |
403 | arg( CurDevNN->name() ); | 514 | arg( CurDevNN->name() ); |
404 | return S; | 515 | return S; |
405 | } | 516 | } |
406 | FirstWithData->nodeClass()->setDone( 1 ); | 517 | FirstWithData->nodeClass()->setDone( 1 ); |
518 | Log(( "Systemfile %s for node instance %s is done\n", | ||
519 | SF->name().latin1(), | ||
520 | FirstWithData->name() )); | ||
407 | } | 521 | } |
408 | 522 | ||
409 | NoOfDevs = 0; | 523 | NoOfDevs = 0; |
410 | DevCtStart = -1; | 524 | DevCtStart = -1; |
411 | 525 | ||
412 | if( SF->knowsDeviceInstances() ) { | 526 | if( SF->knowsDeviceInstances() ) { |
413 | DevCtStart = 0; | 527 | DevCtStart = 0; |
414 | NoOfDevs = CurDevNN->instanceCount(); | 528 | NoOfDevs = CurDevNN->instanceCount(); |
415 | } | 529 | } |
416 | 530 | ||
417 | Log(( "Node %s is done %d\n", | ||
418 | CurDev->netNode()->nodeClass()->name(), | ||
419 | CurDev->netNode()->nodeClass()->done() )); | ||
420 | |||
421 | if( ! CurDev->netNode()->nodeClass()->done() ) { | 531 | if( ! CurDev->netNode()->nodeClass()->done() ) { |
422 | // first time this device is handled | 532 | // first time this device is handled |
423 | // generate common device specific part | 533 | // generate common device specific part |
424 | for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { | 534 | for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { |
425 | 535 | ||
426 | if( FirstWithData->nodeClass()->generateFile( | 536 | if( FirstWithData->nodeClass()->generateFile( |
427 | SF->name(), SF->path(), *SF, CurDev->netNode(), i ) == 2 ) { | 537 | *SF, CurDev->netNode(), i ) == 2 ) { |
428 | S = qApp->translate( "NetworkSettings", | 538 | S = qApp->translate( "NetworkSettings", |
429 | "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ). | 539 | "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ). |
430 | arg( SF->name() ). | 540 | arg( SF->name() ). |
431 | arg( CurDevNN->name() ); | 541 | arg( CurDevNN->name() ); |
432 | return S; | 542 | return S; |
433 | } | 543 | } |
434 | } | 544 | } |
435 | CurDev->netNode()->nodeClass()->setDone( 1 ); | 545 | CurDev->netNode()->nodeClass()->setDone( 1 ); |
546 | |||
547 | Log(( "Systemfile %s for Nodeclass %s is done\n", | ||
548 | SF->name().latin1(), | ||
549 | CurDev->netNode()->nodeClass()->name() | ||
550 | )); | ||
436 | } | 551 | } |
437 | 552 | ||
438 | // generate profile specific info | 553 | // generate profile specific info |
439 | // for all nodeconnections that work on the same device | 554 | // for all nodeconnections that work on the same device |
440 | for( QDictIterator<NodeCollection> ncit2(M); | 555 | for( QDictIterator<NodeCollection> ncit2(M); |
441 | ncit2.current(); | 556 | ncit2.current(); |
@@ -443,26 +558,27 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
443 | 558 | ||
444 | if( ncit2.current()->device() != CurDev ) { | 559 | if( ncit2.current()->device() != CurDev ) { |
445 | // different device | 560 | // different device |
446 | continue; | 561 | continue; |
447 | } | 562 | } |
448 | 563 | ||
449 | Log(("Connection %s of same family\n", ncit2.current()->name().latin1() )); | 564 | Log(("Connection %s of family %s\n", |
565 | ncit2.current()->name().latin1(), | ||
566 | CurDev->name() )); | ||
450 | // generate | 567 | // generate |
451 | NNI = ncit2.current()->firstWithDataForFile( SF->name() ); | 568 | NNI = ncit2.current()->firstWithDataForFile( *SF ); |
452 | for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { | 569 | for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { |
453 | if( ! SF->preNodeSection( NNI, i ) ) { | 570 | if( ! SF->preNodeSection( NNI, i ) ) { |
454 | S = qApp->translate( "NetworkSettings", | 571 | S = qApp->translate( "NetworkSettings", |
455 | "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). | 572 | "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ). |
456 | arg( SF->name() ). | 573 | arg( SF->name() ). |
457 | arg( CurDevNN->name() ); | 574 | arg( CurDevNN->name() ); |
458 | return S; | 575 | return S; |
459 | } | 576 | } |
460 | 577 | ||
461 | switch( NNI->generateFile( | 578 | switch( NNI->generateFile( *SF, i ) ) { |
462 | SF->name(), SF->path(), *SF, i ) ) { | ||
463 | case 0 : | 579 | case 0 : |
464 | (*SF) << endl; | 580 | (*SF) << endl; |
465 | break; | 581 | break; |
466 | case 1 : | 582 | case 1 : |
467 | break; | 583 | break; |
468 | case 2 : | 584 | case 2 : |
@@ -566,15 +682,20 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
566 | case Disabled : | 682 | case Disabled : |
567 | // this profile does not allow interface to be UP | 683 | // this profile does not allow interface to be UP |
568 | // -> try others | 684 | // -> try others |
569 | break; | 685 | break; |
570 | case Off : | 686 | case Off : |
571 | // try to UP the device | 687 | // try to UP the device |
572 | if( ! NC->setState( Activate ) ) { | 688 | { QString S= NC->setState( Activate ); |
573 | // cannot bring device Online -> try other alters | 689 | if( ! S.isEmpty() ) { |
574 | break; | 690 | // could not bring device Online -> try other alters |
691 | Log(( "%s-c%d-disallowed : %s\n", | ||
692 | Interface, NC->number(), S.latin1() )); | ||
693 | break; | ||
694 | } | ||
695 | // interface assigned | ||
575 | } | 696 | } |
576 | // FT | 697 | // FT |
577 | case Available : | 698 | case Available : |
578 | case IsUp : // also called for 'ifdown' | 699 | case IsUp : // also called for 'ifdown' |
579 | // device is ready -> done | 700 | // device is ready -> done |
580 | Log(( "%s-c%d-allowed\n", Interface, NC->number() )); | 701 | Log(( "%s-c%d-allowed\n", Interface, NC->number() )); |
@@ -586,18 +707,19 @@ bool NetworkSettingsData::canStart( const char * Interface ) { | |||
586 | // if we come here no alternatives are possible | 707 | // if we come here no alternatives are possible |
587 | Log(( "%s-cnn-disallowed\n", Interface )); | 708 | Log(( "%s-cnn-disallowed\n", Interface )); |
588 | printf( "%s-cnn-disallowed\n", Interface ); | 709 | printf( "%s-cnn-disallowed\n", Interface ); |
589 | return 0; | 710 | return 0; |
590 | } | 711 | } |
591 | 712 | ||
592 | /* | 713 | bool NetworkSettingsData::isModified( void ) { |
593 | Called by the system to regenerate config files | 714 | if( ForceModified ) |
594 | */ | ||
595 | |||
596 | bool NetworkSettingsData::regenerate( void ) { | ||
597 | QString S = generateSettings(); | ||
598 | if( ! S.isEmpty() ) { | ||
599 | fprintf( stdout, "%s\n", S.latin1() ); | ||
600 | return 1; | 715 | return 1; |
716 | |||
717 | for( QDictIterator<NodeCollection> it(NSResources->connections()); | ||
718 | it.current(); | ||
719 | ++it ) { | ||
720 | if( it.current()->isModified() ) { | ||
721 | return 1; | ||
722 | } | ||
601 | } | 723 | } |
602 | return 0; | 724 | return 0; |
603 | } | 725 | } |