summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/nsdata.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 13979ce..64b83f7 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -12,13 +12,13 @@
static QString CfgFile;
NetworkSettingsData::NetworkSettingsData( void ) {
// init global resources structure
new TheNSResources();
- CfgFile.sprintf( "%s/NETCONFIG",
+ CfgFile.sprintf( "%s/Settings/NS2.conf",
NSResources->currentUser().HomeDir.latin1() );
fprintf( stderr, "Cfg from %s\n", CfgFile.latin1() );
// load settings
Force = 0;
IsModified = 0;
@@ -72,23 +72,29 @@ void NetworkSettingsData::loadSettings( void ) {
NodeCollection * NC = new NodeCollection( TS );
NSResources->addConnection( NC );
} else {
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() );
+ S = S.mid( 9, S.length()-9 );
+ S = deQuote(S);
// try to find netnode
NN = NSResources->findNetNode( S );
+ fprintf( stderr, "Node %s : %p\n", S.latin1(), NN );
} else {
// try to find instance
NNI = NSResources->createNodeInstance( S );
+ fprintf( stderr, "NodeInstance %s : %p\n", S.latin1(), NNI );
+ }
+
+ if( NN == 0 && NNI == 0 ) {
+ LeftOvers.append( Line );
}
do {
- S = TS.readLine();
+ S = Line = TS.readLine();
if( NN || NNI ) {
if( S.isEmpty() ) {
// empty line
break;
}
@@ -106,13 +112,13 @@ void NetworkSettingsData::loadSettings( void ) {
Attr.lower();
// dequote Attr
Value = deQuote(Value);
if( NN ) {
// set the attribute
- NNI->setAttribute( Attr, Value );
+ NN->setAttribute( Attr, Value );
} else {
// set the attribute
NNI->setAttribute( Attr, Value );
}
} else {
LeftOvers.append( Line );
@@ -120,12 +126,13 @@ void NetworkSettingsData::loadSettings( void ) {
if( S.isEmpty() ) {
// empty line
break;
}
}
} while( 1 );
+
if( NNI ) {
// loading from file -> exists
NNI->setNew( FALSE );
NSResources->addNodeInstance( NNI );
}
}
@@ -163,17 +170,18 @@ QString NetworkSettingsData::saveSettings( void ) {
// save global configs
for( QDictIterator<NetNode_t> it( NSResources->netNodes() );
it.current();
++it ) {
TS << "[nodetype "
- << it.current()->NetNode->name()
+ << quote( QString( it.current()->NetNode->name() ) )
<< "]"
<< endl;
it.current()->NetNode->saveAttributes( TS );
+ TS << endl;
}
{ Name2Connection_t & M = NSResources->connections();
ANetNodeInstance * NNI;
// for all connections
@@ -183,13 +191,16 @@ QString NetworkSettingsData::saveSettings( void ) {
// all nodes in those connections
for( QListIterator<ANetNodeInstance> nit(*(it.current()));
nit.current();
++nit ) {
// header
NNI = nit.current();
- TS << '[' <<NNI->nodeClass()->nodeName() << ']' << endl;
+ TS << '['
+ << QString(NNI->nodeClass()->name())
+ << ']'
+ << endl;
NNI->saveAttributes( TS );
TS << endl;
}
TS << "[connection]" << endl;
it.current()->save(TS);
@@ -292,13 +303,13 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
if( ForceIt || NNI->isModified() ) {
if( ! NNI->nodeClass()->generateProperFilesFor( NNI ) ) {
// problem generating
S = qApp->translate( "NetworkSettings",
"<p>Cannot generate files proper to \"%1\"</p>" ).
- arg(NNI->nodeClass()->nodeName()) ;
+ arg(NNI->nodeClass()->name()) ;
return S;
}
}
}
}
@@ -387,18 +398,17 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa
// for all connections
for( QDictIterator<NodeCollection> it(M);
it.current();
++it ) {
NC = it.current();
// check if this profile handles the requested interface
- fprintf( stderr, "check %s\n", NC->name().latin1() );
if( NC->handlesInterface( Interface ) && // if different Intf.
NC->state() != Disabled && // if not enabled
NC->state() != IsUp // if already used
) {
- fprintf( stderr, "Append %s\n", NC->name().latin1() );
+ fprintf( stderr, "Append %s for %s\n", NC->name().latin1(), Interface);
PossibleConnections.append( NC );
}
}
return PossibleConnections;
}
@@ -483,48 +493,41 @@ QString NetworkSettingsData::generateSystemFileNode(
Name2Connection_t & M = NSResources->connections();
if( SF.preDeviceSection( CurDevNN ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in preDeviceSection for file \"%1\" and nodetype \"%2\"</p>" ).
arg( SF.name() ).
- arg( CurDevNN->nodeName() );
+ arg( CurDevNN->name() );
return S;
}
if( CurDevNN->hasDataFor( SF.name() ) ) {
if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in node Device part for file \"%1\" and node \"%2\"</p>" ).
arg( SF.name() ).
- arg( CurDevNN->nodeName() );
+ arg( CurDevNN->name() );
return S;
}
}
- if( CurDev )
- fprintf( stderr, "Cur %s\n", CurDevNN->nodeName().latin1() );
- else
- fprintf( stderr, "Cur NO\n" );
-
// now generate profile specific data for all
// connections working on a device of the current
// netnode type
for( QDictIterator<NodeCollection> ncit(M);
ncit.current();
++ncit ) {
NodeCollection * NC = ncit.current();
// currenly only those connections that work on
// the current device (or on no device if no current)
AsDevice * Dev = NC->device();
- fprintf( stderr, "%s\n", Dev->netNode()->nodeName().latin1() );
if( CurDev ) {
if( CurDevNN != Dev->netNode()->nodeClass() ) {
// other device type -> later
- fprintf( stderr, "Other Dev type\n" );
continue;
}
} else {
if( Dev ) {
// other
continue;
@@ -533,13 +536,13 @@ QString NetworkSettingsData::generateSystemFileNode(
// generate 'entry'
if( SF.preNodeSection( DevNNI, DevInstNr ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in preNodeSection for file \"%1\" and node \"%2\"</p>" ).
arg( SF.name() ).
- arg( CurDevNN->nodeName() );
+ arg( CurDevNN->name() );
return S;
}
// ask all nodes in connection
for( QListIterator<ANetNodeInstance> cncit(*NC);
cncit.current();
@@ -548,32 +551,32 @@ QString NetworkSettingsData::generateSystemFileNode(
if( NNI->hasDataFor( SF.name() ) ) {
if( NNI->generateDataForCommonFile(SF,DevInstNr) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in node part for file \"%1\" and node \"%2\"</p>" ).
arg( SF.name() ).
- arg( NNI->nodeClass()->nodeName() );
+ arg( NNI->nodeClass()->name() );
return S;
}
}
}
if( SF.postNodeSection( DevNNI, DevInstNr ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in postNodeSection for file \"%1\" and node \"%2\"</p>" ).
arg( SF.name() ).
- arg( CurDevNN->nodeName() );
+ arg( CurDevNN->name() );
return S;
}
SF << endl;
}
if( SF.postDeviceSection( CurDevNN ) ) {
S = qApp->translate( "NetworkSettings",
"<p>Error in postDeviceSection for file \"%1\" and node \"%2\"</p>" ).
arg( SF.name() ).
- arg( CurDevNN->nodeName() );
+ arg( CurDevNN->name() );
return S;
}
return S;
}