Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index 835c7c3..6b87399 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -327,30 +327,41 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
327 | FirstItem = 1; | 327 | FirstItem = 1; |
328 | // iterate over NNI's of this class | 328 | // iterate over NNI's of this class |
329 | for( QDictIterator<ANetNodeInstance> nniit( | 329 | for( QDictIterator<ANetNodeInstance> nniit( |
330 | NSResources->netNodeInstances() ); | 330 | NSResources->netNodeInstances() ); |
331 | nniit.current(); | 331 | nniit.current(); |
332 | ++nniit ) { | 332 | ++nniit ) { |
333 | if( nniit.current()->nodeClass() != CurDevNN ) | 333 | if( nniit.current()->nodeClass() != CurDevNN ) |
334 | // different class | 334 | // different class |
335 | continue; | 335 | continue; |
336 | 336 | ||
337 | // open proper file | 337 | // open proper file |
338 | { SystemFile SF( (*it) ); | 338 | { SystemFile SF( (*it) ); |
339 | QStringList SL; | ||
339 | 340 | ||
340 | if( ! CurDevNN->openFile( SF, nniit.current()) ) { | 341 | if( ! CurDevNN->openFile( SF, nniit.current(), SL) ) { |
341 | // cannot open | 342 | // cannot open |
342 | S = qApp->translate( "NetworkSettings", | 343 | S = qApp->translate( "NetworkSettings", |
343 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | 344 | "<p>Cannot build proper file \"%1\" for node \"%2\"</p>" ). |
344 | arg( (*it) ).arg( CurDevNN->name() ); | 345 | arg( (*it) ). |
346 | arg( CurDevNN->name() ); | ||
347 | return S; | ||
348 | } | ||
349 | |||
350 | if( ! createPath( SL ) ) { | ||
351 | S = qApp->translate( "NetworkSettings", | ||
352 | "<p>Cannot create path \"%1\" for proper file \"%2\" for node \"%3\"</p>" ). | ||
353 | arg( SL.join("/") ). | ||
354 | arg( (*it) ). | ||
355 | arg( CurDevNN->name() ); | ||
345 | return S; | 356 | return S; |
346 | } | 357 | } |
347 | 358 | ||
348 | if( ! SF.open() ) { | 359 | if( ! SF.open() ) { |
349 | S = qApp->translate( "NetworkSettings", | 360 | S = qApp->translate( "NetworkSettings", |
350 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | 361 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). |
351 | arg( (*it) ).arg( CurDevNN->name() ); | 362 | arg( (*it) ).arg( CurDevNN->name() ); |
352 | return S; | 363 | return S; |
353 | } | 364 | } |
354 | 365 | ||
355 | // preamble on first | 366 | // preamble on first |
356 | if( FirstItem ) { | 367 | if( FirstItem ) { |
@@ -370,33 +381,44 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
370 | S = qApp->translate( "NetworkSettings", | 381 | S = qApp->translate( "NetworkSettings", |
371 | "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ). | 382 | "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ). |
372 | arg( nniit.current()->name() ). | 383 | arg( nniit.current()->name() ). |
373 | arg( (*it) ). | 384 | arg( (*it) ). |
374 | arg( CurDevNN->name() ); | 385 | arg( CurDevNN->name() ); |
375 | return S; | 386 | return S; |
376 | } | 387 | } |
377 | } | 388 | } |
378 | } | 389 | } |
379 | 390 | ||
380 | if( Generated ) { | 391 | if( Generated ) { |
381 | SystemFile SF( (*it) ); | 392 | SystemFile SF( (*it) ); |
393 | QStringList SL; | ||
382 | 394 | ||
383 | if( CurDevNN->openFile( SF, 0 ) && | 395 | if( CurDevNN->openFile( SF, 0, SL ) && |
384 | ! SF.path().isEmpty() | 396 | ! SF.path().isEmpty() |
385 | ) { | 397 | ) { |
386 | 398 | ||
399 | if( ! createPath( SL ) ) { | ||
400 | S = qApp->translate( "NetworkSettings", | ||
401 | "<p>Cannot create path \"%1\" for proper file \"%2\" for node \"%3\"</p>" ). | ||
402 | arg( SL.join("/") ). | ||
403 | arg( (*it) ). | ||
404 | arg( CurDevNN->name() ); | ||
405 | return S; | ||
406 | } | ||
407 | |||
387 | if( ! SF.open() ) { | 408 | if( ! SF.open() ) { |
388 | S = qApp->translate( "NetworkSettings", | 409 | S = qApp->translate( "NetworkSettings", |
389 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). | 410 | "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). |
390 | arg( (*it) ).arg( CurDevNN->name() ); | 411 | arg( (*it) ). |
412 | arg( CurDevNN->name() ); | ||
391 | return S; | 413 | return S; |
392 | } | 414 | } |
393 | 415 | ||
394 | if( CurDevNN->generatePostamble( SF ) == 2 ) { | 416 | if( CurDevNN->generatePostamble( SF ) == 2 ) { |
395 | S = qApp->translate( "NetworkSettings", | 417 | S = qApp->translate( "NetworkSettings", |
396 | "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ). | 418 | "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ). |
397 | arg( (*it) ). | 419 | arg( (*it) ). |
398 | arg( CurDevNN->name() ); | 420 | arg( CurDevNN->name() ); |
399 | return S; | 421 | return S; |
400 | } | 422 | } |
401 | } // no postamble | 423 | } // no postamble |
402 | } | 424 | } |
@@ -776,12 +798,35 @@ QList<NetworkSetup> NetworkSettingsData::collectTriggered( | |||
776 | if( NC->triggeredBy( Interface ) && // if different Intf. | 798 | if( NC->triggeredBy( Interface ) && // if different Intf. |
777 | NC->state() != Disabled && // if enabled | 799 | NC->state() != Disabled && // if enabled |
778 | NC->state() != IsUp // if already used | 800 | NC->state() != IsUp // if already used |
779 | ) { | 801 | ) { |
780 | Log( ( "Append %s for %s\n", | 802 | Log( ( "Append %s for %s\n", |
781 | NC->name().latin1(), Interface.latin1() )); | 803 | NC->name().latin1(), Interface.latin1() )); |
782 | PossibleTriggered.append( NC ); | 804 | PossibleTriggered.append( NC ); |
783 | } | 805 | } |
784 | } | 806 | } |
785 | return PossibleTriggered; | 807 | return PossibleTriggered; |
786 | } | 808 | } |
787 | 809 | ||
810 | bool NetworkSettingsData::createPath( const QStringList & SL ) { | ||
811 | |||
812 | QDir D( SL[0] ); | ||
813 | |||
814 | for ( QStringList::ConstIterator it = SL.begin(); | ||
815 | it != SL.end(); | ||
816 | ++it ) { | ||
817 | |||
818 | printf( "Create %s\n", (*it).latin1() ); | ||
819 | if( it == SL.begin() ) | ||
820 | continue; | ||
821 | |||
822 | if( ! D.exists( *it ) ) { | ||
823 | if( ! D.mkdir( *it ) ) { | ||
824 | printf( "Failed %s %s\n", D.path().latin1(), (*it).latin1() ); | ||
825 | return 0; | ||
826 | } | ||
827 | } | ||
828 | |||
829 | D.cd( *it ); | ||
830 | } | ||
831 | return 1; | ||
832 | } | ||