summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/nsdata.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp55
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
@@ -315,100 +315,122 @@ QString NetworkSettingsData::generateSettings( void ) {
bool Generated = 0;
CurDevNN = nnit.current();
{ QStringList SL;
SL = CurDevNN->properFiles();
for ( QStringList::Iterator it = SL.begin();
it != SL.end();
++it ) {
Generated = 0;
FirstItem = 1;
// iterate over NNI's of this class
for( QDictIterator<ANetNodeInstance> nniit(
NSResources->netNodeInstances() );
nniit.current();
++nniit ) {
if( nniit.current()->nodeClass() != CurDevNN )
// different class
continue;
// open proper file
{ SystemFile SF( (*it) );
+ QStringList SL;
- if( ! CurDevNN->openFile( SF, nniit.current()) ) {
+ if( ! CurDevNN->openFile( SF, nniit.current(), SL) ) {
// cannot open
S = qApp->translate( "NetworkSettings",
- "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
- arg( (*it) ).arg( CurDevNN->name() );
+ "<p>Cannot build proper file \"%1\" for node \"%2\"</p>" ).
+ arg( (*it) ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+
+ if( ! createPath( SL ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Cannot create path \"%1\" for proper file \"%2\" for node \"%3\"</p>" ).
+ arg( SL.join("/") ).
+ arg( (*it) ).
+ arg( CurDevNN->name() );
return S;
}
if( ! SF.open() ) {
S = qApp->translate( "NetworkSettings",
"<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
arg( (*it) ).arg( CurDevNN->name() );
return S;
}
// preamble on first
if( FirstItem ) {
if( CurDevNN->generatePreamble( SF ) == 2 ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ).
arg( (*it) ).
arg( CurDevNN->name() );
return S;
}
}
FirstItem = 0;
Generated = 1;
// item specific
if( nniit.current()->generateFile( SF, -1 ) == 2 ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ).
arg( nniit.current()->name() ).
arg( (*it) ).
arg( CurDevNN->name() );
return S;
}
}
}
if( Generated ) {
SystemFile SF( (*it) );
+ QStringList SL;
- if( CurDevNN->openFile( SF, 0 ) &&
+ if( CurDevNN->openFile( SF, 0, SL ) &&
! SF.path().isEmpty()
) {
+ if( ! createPath( SL ) ) {
+ S = qApp->translate( "NetworkSettings",
+ "<p>Cannot create path \"%1\" for proper file \"%2\" for node \"%3\"</p>" ).
+ arg( SL.join("/") ).
+ arg( (*it) ).
+ arg( CurDevNN->name() );
+ return S;
+ }
+
if( ! SF.open() ) {
S = qApp->translate( "NetworkSettings",
"<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ).
- arg( (*it) ).arg( CurDevNN->name() );
+ arg( (*it) ).
+ arg( CurDevNN->name() );
return S;
}
if( CurDevNN->generatePostamble( SF ) == 2 ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ).
arg( (*it) ).
arg( CurDevNN->name() );
return S;
}
} // no postamble
}
}
}
}
//
// generate all registered files
//
for( QDictIterator<SystemFile> sfit(SFM);
sfit.current();
++sfit ) {
SystemFile * SF;
@@ -764,24 +786,47 @@ QList<NetworkSetup> NetworkSettingsData::collectTriggered(
// collect NetworkSetups that could be triggered by this interface
NetworkSetup * NC;
QList<NetworkSetup> PossibleTriggered;
// for all NetworkSetups
Name2NetworkSetup_t & M = NSResources->networkSetups();
for( QDictIterator<NetworkSetup> it(M);
it.current();
++it ) {
NC = it.current();
// check if this profile handles the requested interface
if( NC->triggeredBy( Interface ) && // if different Intf.
NC->state() != Disabled && // if enabled
NC->state() != IsUp // if already used
) {
Log( ( "Append %s for %s\n",
NC->name().latin1(), Interface.latin1() ));
PossibleTriggered.append( NC );
}
}
return PossibleTriggered;
}
+bool NetworkSettingsData::createPath( const QStringList & SL ) {
+
+ QDir D( SL[0] );
+
+ for ( QStringList::ConstIterator it = SL.begin();
+ it != SL.end();
+ ++it ) {
+
+ printf( "Create %s\n", (*it).latin1() );
+ if( it == SL.begin() )
+ continue;
+
+ if( ! D.exists( *it ) ) {
+ if( ! D.mkdir( *it ) ) {
+ printf( "Failed %s %s\n", D.path().latin1(), (*it).latin1() );
+ return 0;
+ }
+ }
+
+ D.cd( *it );
+ }
+ return 1;
+}