summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/nsdata.cpp
Unidiff
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
@@ -15,7 +15,7 @@ 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
@@ -75,17 +75,23 @@ void NetworkSettingsData::loadSettings( void ) {
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() ) {
@@ -109,7 +115,7 @@ void NetworkSettingsData::loadSettings( void ) {
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 );
@@ -123,6 +129,7 @@ void NetworkSettingsData::loadSettings( void ) {
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 );
@@ -166,11 +173,12 @@ QString NetworkSettingsData::saveSettings( void ) {
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();
@@ -186,7 +194,10 @@ QString NetworkSettingsData::saveSettings( void ) {
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 }
@@ -295,7 +306,7 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
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 }
@@ -390,12 +401,11 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa
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 }
@@ -486,7 +496,7 @@ QString NetworkSettingsData::generateSystemFileNode(
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
@@ -495,16 +505,11 @@ QString NetworkSettingsData::generateSystemFileNode(
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
@@ -517,11 +522,9 @@ QString NetworkSettingsData::generateSystemFileNode(
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 {
@@ -536,7 +539,7 @@ QString NetworkSettingsData::generateSystemFileNode(
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
@@ -551,7 +554,7 @@ QString NetworkSettingsData::generateSystemFileNode(
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 }
@@ -561,7 +564,7 @@ QString NetworkSettingsData::generateSystemFileNode(
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;
@@ -571,7 +574,7 @@ QString NetworkSettingsData::generateSystemFileNode(
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