author | wimpie <wimpie> | 2004-04-07 00:09:37 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-07 00:09:37 (UTC) |
commit | b93d9e0c4384be0a6f40be257ba791004388400b (patch) (side-by-side diff) | |
tree | 2ca0e41dc8c99e1af3ce2f0305d458f76d10db45 /noncore/settings/networksettings2/nsdata.cpp | |
parent | 1b7aaf904fa70c16eee03155bd826e921798cc22 (diff) | |
download | opie-b93d9e0c4384be0a6f40be257ba791004388400b.zip opie-b93d9e0c4384be0a6f40be257ba791004388400b.tar.gz opie-b93d9e0c4384be0a6f40be257ba791004388400b.tar.bz2 |
MANY changes ... lancards should be OK now
Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 49 |
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 @@ -10,17 +10,17 @@ #include <resources.h> 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; loadSettings(); } @@ -70,27 +70,33 @@ void NetworkSettingsData::loadSettings( void ) { if( S == "connection" ) { // load connections -> collections of nodes 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; } idx = S.find( '=' ); if( idx > 0 ) { @@ -104,30 +110,31 @@ void NetworkSettingsData::loadSettings( void ) { Value.stripWhiteSpace(); Attr.stripWhiteSpace(); 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 ); // add empty line too as delimiter if( S.isEmpty() ) { // empty line break; } } } while( 1 ); + if( NNI ) { // loading from file -> exists NNI->setNew( FALSE ); NSResources->addNodeInstance( NNI ); } } } @@ -161,37 +168,41 @@ QString NetworkSettingsData::saveSettings( void ) { TS << (*it) << endl; } // 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 for( QDictIterator<NodeCollection> it(M); it.current(); ++it ) { // 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); } } @@ -290,17 +301,17 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { // for all nodes find those that are modified NNI = NNIIt.current(); 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; } } } } // // generate all system files @@ -385,22 +396,21 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa Name2Connection_t & M = NSResources->connections(); // 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; } /* @@ -481,99 +491,92 @@ QString NetworkSettingsData::generateSystemFileNode( QString S=""; ANetNode * CurDevNN = DevNNI->nodeClass(); 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; } } // 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(); ++cncit ) { ANetNodeInstance * NNI = cncit.current(); 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; } |