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 | |||
@@ -14,9 +14,9 @@ static QString CfgFile; | |||
14 | NetworkSettingsData::NetworkSettingsData( void ) { | 14 | NetworkSettingsData::NetworkSettingsData( void ) { |
15 | // init global resources structure | 15 | // init global resources structure |
16 | new TheNSResources(); | 16 | new TheNSResources(); |
17 | 17 | ||
18 | CfgFile.sprintf( "%s/NETCONFIG", | 18 | CfgFile.sprintf( "%s/Settings/NS2.conf", |
19 | NSResources->currentUser().HomeDir.latin1() ); | 19 | NSResources->currentUser().HomeDir.latin1() ); |
20 | fprintf( stderr, "Cfg from %s\n", CfgFile.latin1() ); | 20 | fprintf( stderr, "Cfg from %s\n", CfgFile.latin1() ); |
21 | 21 | ||
22 | // load settings | 22 | // load settings |
@@ -74,19 +74,25 @@ void NetworkSettingsData::loadSettings( void ) { | |||
74 | } else { | 74 | } else { |
75 | ANetNode * NN = 0; | 75 | ANetNode * NN = 0; |
76 | ANetNodeInstance* NNI = 0; | 76 | ANetNodeInstance* NNI = 0; |
77 | if( S.startsWith( "nodetype " ) ) { | 77 | if( S.startsWith( "nodetype " ) ) { |
78 | S = S.mid( 9, S.length()-9-1 ); | 78 | S = S.mid( 9, S.length()-9 ); |
79 | fprintf( stderr, "Node %s\n", S.latin1() ); | 79 | S = deQuote(S); |
80 | // try to find netnode | 80 | // try to find netnode |
81 | NN = NSResources->findNetNode( S ); | 81 | NN = NSResources->findNetNode( S ); |
82 | fprintf( stderr, "Node %s : %p\n", S.latin1(), NN ); | ||
82 | } else { | 83 | } else { |
83 | // try to find instance | 84 | // try to find instance |
84 | NNI = NSResources->createNodeInstance( S ); | 85 | NNI = NSResources->createNodeInstance( S ); |
86 | fprintf( stderr, "NodeInstance %s : %p\n", S.latin1(), NNI ); | ||
87 | } | ||
88 | |||
89 | if( NN == 0 && NNI == 0 ) { | ||
90 | LeftOvers.append( Line ); | ||
85 | } | 91 | } |
86 | 92 | ||
87 | do { | 93 | do { |
88 | S = TS.readLine(); | 94 | S = Line = TS.readLine(); |
89 | 95 | ||
90 | if( NN || NNI ) { | 96 | if( NN || NNI ) { |
91 | if( S.isEmpty() ) { | 97 | if( S.isEmpty() ) { |
92 | // empty line | 98 | // empty line |
@@ -108,9 +114,9 @@ void NetworkSettingsData::loadSettings( void ) { | |||
108 | Value = deQuote(Value); | 114 | Value = deQuote(Value); |
109 | 115 | ||
110 | if( NN ) { | 116 | if( NN ) { |
111 | // set the attribute | 117 | // set the attribute |
112 | NNI->setAttribute( Attr, Value ); | 118 | NN->setAttribute( Attr, Value ); |
113 | } else { | 119 | } else { |
114 | // set the attribute | 120 | // set the attribute |
115 | NNI->setAttribute( Attr, Value ); | 121 | NNI->setAttribute( Attr, Value ); |
116 | } | 122 | } |
@@ -122,8 +128,9 @@ void NetworkSettingsData::loadSettings( void ) { | |||
122 | break; | 128 | break; |
123 | } | 129 | } |
124 | } | 130 | } |
125 | } while( 1 ); | 131 | } while( 1 ); |
132 | |||
126 | if( NNI ) { | 133 | if( NNI ) { |
127 | // loading from file -> exists | 134 | // loading from file -> exists |
128 | NNI->setNew( FALSE ); | 135 | NNI->setNew( FALSE ); |
129 | NSResources->addNodeInstance( NNI ); | 136 | NSResources->addNodeInstance( NNI ); |
@@ -165,13 +172,14 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
165 | for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); | 172 | for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); |
166 | it.current(); | 173 | it.current(); |
167 | ++it ) { | 174 | ++it ) { |
168 | TS << "[nodetype " | 175 | TS << "[nodetype " |
169 | << it.current()->NetNode->name() | 176 | << quote( QString( it.current()->NetNode->name() ) ) |
170 | << "]" | 177 | << "]" |
171 | << endl; | 178 | << endl; |
172 | 179 | ||
173 | it.current()->NetNode->saveAttributes( TS ); | 180 | it.current()->NetNode->saveAttributes( TS ); |
181 | TS << endl; | ||
174 | } | 182 | } |
175 | 183 | ||
176 | { Name2Connection_t & M = NSResources->connections(); | 184 | { Name2Connection_t & M = NSResources->connections(); |
177 | ANetNodeInstance * NNI; | 185 | ANetNodeInstance * NNI; |
@@ -185,9 +193,12 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
185 | nit.current(); | 193 | nit.current(); |
186 | ++nit ) { | 194 | ++nit ) { |
187 | // header | 195 | // header |
188 | NNI = nit.current(); | 196 | NNI = nit.current(); |
189 | TS << '[' <<NNI->nodeClass()->nodeName() << ']' << endl; | 197 | TS << '[' |
198 | << QString(NNI->nodeClass()->name()) | ||
199 | << ']' | ||
200 | << endl; | ||
190 | NNI->saveAttributes( TS ); | 201 | NNI->saveAttributes( TS ); |
191 | TS << endl; | 202 | TS << endl; |
192 | } | 203 | } |
193 | 204 | ||
@@ -294,9 +305,9 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) { | |||
294 | if( ! NNI->nodeClass()->generateProperFilesFor( NNI ) ) { | 305 | if( ! NNI->nodeClass()->generateProperFilesFor( NNI ) ) { |
295 | // problem generating | 306 | // problem generating |
296 | S = qApp->translate( "NetworkSettings", | 307 | S = qApp->translate( "NetworkSettings", |
297 | "<p>Cannot generate files proper to \"%1\"</p>" ). | 308 | "<p>Cannot generate files proper to \"%1\"</p>" ). |
298 | arg(NNI->nodeClass()->nodeName()) ; | 309 | arg(NNI->nodeClass()->name()) ; |
299 | return S; | 310 | return S; |
300 | } | 311 | } |
301 | } | 312 | } |
302 | } | 313 | } |
@@ -389,14 +400,13 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa | |||
389 | it.current(); | 400 | it.current(); |
390 | ++it ) { | 401 | ++it ) { |
391 | NC = it.current(); | 402 | NC = it.current(); |
392 | // check if this profile handles the requested interface | 403 | // check if this profile handles the requested interface |
393 | fprintf( stderr, "check %s\n", NC->name().latin1() ); | ||
394 | if( NC->handlesInterface( Interface ) && // if different Intf. | 404 | if( NC->handlesInterface( Interface ) && // if different Intf. |
395 | NC->state() != Disabled && // if not enabled | 405 | NC->state() != Disabled && // if not enabled |
396 | NC->state() != IsUp // if already used | 406 | NC->state() != IsUp // if already used |
397 | ) { | 407 | ) { |
398 | fprintf( stderr, "Append %s\n", NC->name().latin1() ); | 408 | fprintf( stderr, "Append %s for %s\n", NC->name().latin1(), Interface); |
399 | PossibleConnections.append( NC ); | 409 | PossibleConnections.append( NC ); |
400 | } | 410 | } |
401 | } | 411 | } |
402 | return PossibleConnections; | 412 | return PossibleConnections; |
@@ -485,27 +495,22 @@ QString NetworkSettingsData::generateSystemFileNode( | |||
485 | if( SF.preDeviceSection( CurDevNN ) ) { | 495 | if( SF.preDeviceSection( CurDevNN ) ) { |
486 | S = qApp->translate( "NetworkSettings", | 496 | S = qApp->translate( "NetworkSettings", |
487 | "<p>Error in preDeviceSection for file \"%1\" and nodetype \"%2\"</p>" ). | 497 | "<p>Error in preDeviceSection for file \"%1\" and nodetype \"%2\"</p>" ). |
488 | arg( SF.name() ). | 498 | arg( SF.name() ). |
489 | arg( CurDevNN->nodeName() ); | 499 | arg( CurDevNN->name() ); |
490 | return S; | 500 | return S; |
491 | } | 501 | } |
492 | 502 | ||
493 | if( CurDevNN->hasDataFor( SF.name() ) ) { | 503 | if( CurDevNN->hasDataFor( SF.name() ) ) { |
494 | if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) { | 504 | if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) { |
495 | S = qApp->translate( "NetworkSettings", | 505 | S = qApp->translate( "NetworkSettings", |
496 | "<p>Error in node Device part for file \"%1\" and node \"%2\"</p>" ). | 506 | "<p>Error in node Device part for file \"%1\" and node \"%2\"</p>" ). |
497 | arg( SF.name() ). | 507 | arg( SF.name() ). |
498 | arg( CurDevNN->nodeName() ); | 508 | arg( CurDevNN->name() ); |
499 | return S; | 509 | return S; |
500 | } | 510 | } |
501 | } | 511 | } |
502 | 512 | ||
503 | if( CurDev ) | ||
504 | fprintf( stderr, "Cur %s\n", CurDevNN->nodeName().latin1() ); | ||
505 | else | ||
506 | fprintf( stderr, "Cur NO\n" ); | ||
507 | |||
508 | // now generate profile specific data for all | 513 | // now generate profile specific data for all |
509 | // connections working on a device of the current | 514 | // connections working on a device of the current |
510 | // netnode type | 515 | // netnode type |
511 | for( QDictIterator<NodeCollection> ncit(M); | 516 | for( QDictIterator<NodeCollection> ncit(M); |
@@ -516,13 +521,11 @@ QString NetworkSettingsData::generateSystemFileNode( | |||
516 | // currenly only those connections that work on | 521 | // currenly only those connections that work on |
517 | // the current device (or on no device if no current) | 522 | // the current device (or on no device if no current) |
518 | AsDevice * Dev = NC->device(); | 523 | AsDevice * Dev = NC->device(); |
519 | 524 | ||
520 | fprintf( stderr, "%s\n", Dev->netNode()->nodeName().latin1() ); | ||
521 | if( CurDev ) { | 525 | if( CurDev ) { |
522 | if( CurDevNN != Dev->netNode()->nodeClass() ) { | 526 | if( CurDevNN != Dev->netNode()->nodeClass() ) { |
523 | // other device type -> later | 527 | // other device type -> later |
524 | fprintf( stderr, "Other Dev type\n" ); | ||
525 | continue; | 528 | continue; |
526 | } | 529 | } |
527 | } else { | 530 | } else { |
528 | if( Dev ) { | 531 | if( Dev ) { |
@@ -535,9 +538,9 @@ QString NetworkSettingsData::generateSystemFileNode( | |||
535 | if( SF.preNodeSection( DevNNI, DevInstNr ) ) { | 538 | if( SF.preNodeSection( DevNNI, DevInstNr ) ) { |
536 | S = qApp->translate( "NetworkSettings", | 539 | S = qApp->translate( "NetworkSettings", |
537 | "<p>Error in preNodeSection for file \"%1\" and node \"%2\"</p>" ). | 540 | "<p>Error in preNodeSection for file \"%1\" and node \"%2\"</p>" ). |
538 | arg( SF.name() ). | 541 | arg( SF.name() ). |
539 | arg( CurDevNN->nodeName() ); | 542 | arg( CurDevNN->name() ); |
540 | return S; | 543 | return S; |
541 | } | 544 | } |
542 | 545 | ||
543 | // ask all nodes in connection | 546 | // ask all nodes in connection |
@@ -550,9 +553,9 @@ QString NetworkSettingsData::generateSystemFileNode( | |||
550 | if( NNI->generateDataForCommonFile(SF,DevInstNr) ) { | 553 | if( NNI->generateDataForCommonFile(SF,DevInstNr) ) { |
551 | S = qApp->translate( "NetworkSettings", | 554 | S = qApp->translate( "NetworkSettings", |
552 | "<p>Error in node part for file \"%1\" and node \"%2\"</p>" ). | 555 | "<p>Error in node part for file \"%1\" and node \"%2\"</p>" ). |
553 | arg( SF.name() ). | 556 | arg( SF.name() ). |
554 | arg( NNI->nodeClass()->nodeName() ); | 557 | arg( NNI->nodeClass()->name() ); |
555 | return S; | 558 | return S; |
556 | } | 559 | } |
557 | } | 560 | } |
558 | } | 561 | } |
@@ -560,9 +563,9 @@ QString NetworkSettingsData::generateSystemFileNode( | |||
560 | if( SF.postNodeSection( DevNNI, DevInstNr ) ) { | 563 | if( SF.postNodeSection( DevNNI, DevInstNr ) ) { |
561 | S = qApp->translate( "NetworkSettings", | 564 | S = qApp->translate( "NetworkSettings", |
562 | "<p>Error in postNodeSection for file \"%1\" and node \"%2\"</p>" ). | 565 | "<p>Error in postNodeSection for file \"%1\" and node \"%2\"</p>" ). |
563 | arg( SF.name() ). | 566 | arg( SF.name() ). |
564 | arg( CurDevNN->nodeName() ); | 567 | arg( CurDevNN->name() ); |
565 | return S; | 568 | return S; |
566 | } | 569 | } |
567 | SF << endl; | 570 | SF << endl; |
568 | } | 571 | } |
@@ -570,9 +573,9 @@ QString NetworkSettingsData::generateSystemFileNode( | |||
570 | if( SF.postDeviceSection( CurDevNN ) ) { | 573 | if( SF.postDeviceSection( CurDevNN ) ) { |
571 | S = qApp->translate( "NetworkSettings", | 574 | S = qApp->translate( "NetworkSettings", |
572 | "<p>Error in postDeviceSection for file \"%1\" and node \"%2\"</p>" ). | 575 | "<p>Error in postDeviceSection for file \"%1\" and node \"%2\"</p>" ). |
573 | arg( SF.name() ). | 576 | arg( SF.name() ). |
574 | arg( CurDevNN->nodeName() ); | 577 | arg( CurDevNN->name() ); |
575 | return S; | 578 | return S; |
576 | } | 579 | } |
577 | 580 | ||
578 | return S; | 581 | return S; |