summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/nsdata.cpp
authorwimpie <wimpie>2004-08-09 02:31:25 (UTC)
committer wimpie <wimpie>2004-08-09 02:31:25 (UTC)
commit0784cfdbd261c43856b45be6ab7439841e69b858 (patch) (unidiff)
treef6a27d6b2e1e6d8dcc908b2ef5836cd320ddfab1 /noncore/settings/networksettings2/nsdata.cpp
parent5e10278e748608766245ff9f59a54d1ae8ff6f7e (diff)
downloadopie-0784cfdbd261c43856b45be6ab7439841e69b858.zip
opie-0784cfdbd261c43856b45be6ab7439841e69b858.tar.gz
opie-0784cfdbd261c43856b45be6ab7439841e69b858.tar.bz2
Many changes :
bluetooth and usb seems to work added preliminary support for VPN on top of any network This version is still very much crippled yet is does DO some things
Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index bb37f10..3b17548 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -14,13 +14,13 @@ static QString CfgFile;
14NetworkSettingsData::NetworkSettingsData( void ) { 14NetworkSettingsData::NetworkSettingsData( void ) {
15 // init global resources structure 15 // init global resources structure
16 new TheNSResources(); 16 new TheNSResources();
17 17
18 CfgFile.sprintf( "%s/Settings/NS2.conf", 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 Log(( "Cfg from %s\n", CfgFile.latin1() ));
21 21
22 // load settings 22 // load settings
23 Force = 0; 23 Force = 0;
24 IsModified = 0; 24 IsModified = 0;
25 loadSettings(); 25 loadSettings();
26} 26}
@@ -76,17 +76,17 @@ void NetworkSettingsData::loadSettings( void ) {
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 ); 78 S = S.mid( 9, S.length()-9 );
79 S = deQuote(S); 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 Log( ( "Node %s : %p\n", S.latin1(), NN ) );
83 } else { 83 } else {
84 // try to find instance 84 // try to find instance
85 NNI = NSResources->createNodeInstance( S ); 85 NNI = NSResources->createNodeInstance( S );
86 fprintf( stderr, "NodeInstance %s : %p\n", S.latin1(), NNI ); 86 Log( ( "NodeInstance %s : %p\n", S.latin1(), NNI ));
87 } 87 }
88 88
89 if( NN == 0 && NNI == 0 ) { 89 if( NN == 0 && NNI == 0 ) {
90 LeftOvers.append( Line ); 90 LeftOvers.append( Line );
91 } 91 }
92 92
@@ -148,13 +148,13 @@ QString NetworkSettingsData::saveSettings( void ) {
148 if( ! isModified() ) 148 if( ! isModified() )
149 return ErrS; 149 return ErrS;
150 150
151 QString S; 151 QString S;
152 QFile F( CfgFile + ".bup" ); 152 QFile F( CfgFile + ".bup" );
153 153
154 printf( "Saving settings to %s\n", CfgFile.latin1() ); 154 Log( ( "Saving settings to %s\n", CfgFile.latin1() ));
155 if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { 155 if( ! F.open( IO_WriteOnly | IO_Truncate ) ) {
156 ErrS = qApp->translate( "NetworkSettings", 156 ErrS = qApp->translate( "NetworkSettings",
157 "<p>Could not save setup to \"%1\" !</p>" ). 157 "<p>Could not save setup to \"%1\" !</p>" ).
158 arg(CfgFile); 158 arg(CfgFile);
159 // problem 159 // problem
160 return ErrS; 160 return ErrS;
@@ -226,13 +226,13 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
226 ForceIt = (Force) ? 1 : ForceReq; 226 ForceIt = (Force) ? 1 : ForceReq;
227 227
228 if( ! ForceIt && ! isModified() ) 228 if( ! ForceIt && ! isModified() )
229 return S; 229 return S;
230 230
231 // regenerate system files 231 // regenerate system files
232 fprintf( stderr, "Generating settings from %s\n", CfgFile.latin1() ); 232 Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
233 233
234 { Name2SystemFile_t & SFM = NSResources->systemFiles(); 234 { Name2SystemFile_t & SFM = NSResources->systemFiles();
235 Name2Connection_t & M = NSResources->connections(); 235 Name2Connection_t & M = NSResources->connections();
236 NodeCollection * NC; 236 NodeCollection * NC;
237 ANetNodeInstance * NNI; 237 ANetNodeInstance * NNI;
238 SystemFile * SF; 238 SystemFile * SF;
@@ -278,20 +278,12 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
278 } 278 }
279 if( needToRegenerate ) 279 if( needToRegenerate )
280 break; 280 break;
281 } 281 }
282 } 282 }
283 283
284 // we cannot renumber with a FORCE request since
285 // we probably are NOT going to save the config
286 // e.g. when using --regen option
287 if( ! ForceReq && needToRegenerate ) {
288 NSResources->renumberConnections();
289 setModified(1);
290 }
291
292 // 284 //
293 // generate files proper to each netnodeinstance 285 // generate files proper to each netnodeinstance
294 // 286 //
295 { Name2Instance_t & NNIs = NSResources->netNodeInstances(); 287 { Name2Instance_t & NNIs = NSResources->netNodeInstances();
296 288
297 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); 289 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs);
@@ -318,13 +310,13 @@ QString NetworkSettingsData::generateSettings( bool ForceReq ) {
318 // 310 //
319 for( QDictIterator<SystemFile> sfit(SFM); 311 for( QDictIterator<SystemFile> sfit(SFM);
320 sfit.current(); 312 sfit.current();
321 ++sfit ) { 313 ++sfit ) {
322 SF = sfit.current(); 314 SF = sfit.current();
323 315
324 fprintf( stderr, "Generating %s\n", SF->name().latin1() ); 316 Log( ( "Generating %s\n", SF->name().latin1() ));
325 SF->open(); 317 SF->open();
326 318
327 do { // so we can break; 319 do { // so we can break;
328 320
329 // global presection for this system file 321 // global presection for this system file
330 if( SF->preSection() ) { 322 if( SF->preSection() ) {
@@ -402,13 +394,13 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa
402 NC = it.current(); 394 NC = it.current();
403 // check if this profile handles the requested interface 395 // check if this profile handles the requested interface
404 if( NC->handlesInterface( Interface ) && // if different Intf. 396 if( NC->handlesInterface( Interface ) && // if different Intf.
405 NC->state() != Disabled && // if not enabled 397 NC->state() != Disabled && // if not enabled
406 NC->state() != IsUp // if already used 398 NC->state() != IsUp // if already used
407 ) { 399 ) {
408 fprintf( stderr, "Append %s for %s\n", NC->name().latin1(), Interface); 400 Log( ( "Append %s for %s\n", NC->name().latin1(), Interface));
409 PossibleConnections.append( NC ); 401 PossibleConnections.append( NC );
410 } 402 }
411 } 403 }
412 return PossibleConnections; 404 return PossibleConnections;
413} 405}
414 406
@@ -423,14 +415,13 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
423 // load situation 415 // load situation
424 NodeCollection * NC = 0; 416 NodeCollection * NC = 0;
425 QList<NodeCollection> PossibleConnections; 417 QList<NodeCollection> PossibleConnections;
426 418
427 PossibleConnections = collectPossible( Interface ); 419 PossibleConnections = collectPossible( Interface );
428 420
429 fprintf( stderr, "Possiblilies %d\n", 421 Log( ( "Possiblilies %d\n", PossibleConnections.count() ));
430 PossibleConnections.count() );
431 switch( PossibleConnections.count() ) { 422 switch( PossibleConnections.count() ) {
432 case 0 : // no connections 423 case 0 : // no connections
433 break; 424 break;
434 case 1 : // one connection 425 case 1 : // one connection
435 NC = PossibleConnections.first(); 426 NC = PossibleConnections.first();
436 break; 427 break;