summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings2/resources.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/resources.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp52
1 files changed, 36 insertions, 16 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 2f17693..8b3b4fe 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -45,10 +45,14 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
45 // avoid recursive 45 // avoid recursive
46 continue; 46 continue;
47 47
48 const char * Provides = InnerIt.current()->NetNode->provides(); 48 const char ** Provides = InnerIt.current()->NetNode->provides();
49 NeedsRun = OuterIt.current()->NetNode->needs(); 49 NeedsRun = OuterIt.current()->NetNode->needs();
50
50 for( ; *NeedsRun; NeedsRun ++ ) { 51 for( ; *NeedsRun; NeedsRun ++ ) {
51 if( strcmp( Provides, *NeedsRun ) == 0 ) { 52 const char ** PRun;
53 PRun = Provides;
54 for( ; *PRun; PRun ++ ) {
55 if( strcmp( *PRun, *NeedsRun ) == 0 ) {
52 // inner provides what outer needs 56 // inner provides what outer needs
53 NNL.resize( NNL.size() + 1 ); 57 NNL.resize( NNL.size() + 1 );
54 NNL[NNL.size()-1] = InnerIt.current()->NetNode; 58 NNL[NNL.size()-1] = InnerIt.current()->NetNode;
@@ -57,27 +61,22 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
57 } 61 }
58 } 62 }
59 } 63 }
64 }
60 OuterIt.current()->NetNode->setAlternatives( NNLP ); 65 OuterIt.current()->NetNode->setAlternatives( NNLP );
61 } 66 }
62 } 67 }
63 68
64 // define Node types to Description map 69 // define built in Node types to Description map
65 NodeTypeNameMap.insert( "device", tr( "Network Device" ) ); 70 addNodeType( "device", tr( "Network Device" ),
66 NodeTypeNameMap.insert( "line", tr( "Character device" ) );
67 NodeTypeNameMap.insert( "connection", tr( "IP Connection" ) );
68 NodeTypeNameMap.insert( "fullsetup", tr( "Connection Profile" ) );
69
70 NodeTypeDescriptionMap.insert( "device",
71 tr( "<p>Devices that can handle IP packets</p>" ) ); 71 tr( "<p>Devices that can handle IP packets</p>" ) );
72 NodeTypeDescriptionMap.insert( "line", 72 addNodeType( "line", tr( "Character device" ),
73 tr( "<p>Devices that can handle single bytes</p>" ) ); 73 tr( "<p>Devices that can handle single bytes</p>" ) );
74 NodeTypeDescriptionMap.insert( "connection", 74 addNodeType( "connection", tr( "IP Connection" ),
75 tr( "<p>Nodes that provide working IP connections</p>" ) ); 75 tr( "<p>Nodes that provide working IP connections</p>" ) );
76 NodeTypeDescriptionMap.insert( "fullsetup", 76 addNodeType( "fullsetup", tr( "Connection Profile" ),
77 tr( "<p>Fully configured connection profile</p>" ) ); 77 tr( "<p>Fully configured connection profile</p>" ) );
78 78 addNodeType( "GPRS", tr( "Connection to GPRS device" ),
79 // define system files 79 tr( "<p>Connection to a GPRS capable device</p>" ) );
80 addSystemFile( "interfaces", "/tmp/interfaces", 1 );
81 80
82 // get access to the system 81 // get access to the system
83 TheSystem = new System(); 82 TheSystem = new System();
@@ -88,6 +87,15 @@ TheNSResources::~TheNSResources( void ) {
88 delete TheSystem; 87 delete TheSystem;
89} 88}
90 89
90void TheNSResources::addNodeType( const QString & ID,
91 const QString & Name,
92 const QString & Descr ) {
93 if( NodeTypeNameMap[ID].isEmpty() ) {
94 NodeTypeNameMap.insert( ID, Name );
95 NodeTypeDescriptionMap.insert( ID, Descr );
96 }
97}
98
91void TheNSResources::addSystemFile( const QString & ID, 99void TheNSResources::addSystemFile( const QString & ID,
92 const QString & P, 100 const QString & P,
93 bool KDI ) { 101 bool KDI ) {
@@ -220,8 +228,10 @@ QPixmap TheNSResources::getPixmap( const QString & QS ) {
220 QPixmap P; 228 QPixmap P;
221 QString S("networksettings2/"); 229 QString S("networksettings2/");
222 S += QS; 230 S += QS;
223 Log(("%s\n", S.latin1() ));
224 P = Resource::loadPixmap( S ); 231 P = Resource::loadPixmap( S );
232 if( P.isNull() ) {
233 Log(( "Cannot load %s\n", S.latin1() ));
234 }
225 return ( P.isNull() ) ? QPixmap() : P; 235 return ( P.isNull() ) ? QPixmap() : P;
226} 236}
227 237
@@ -269,6 +279,16 @@ NodeCollection * TheNSResources::findConnection( const QString & S ) {
269 return ConnectionsMap[ S ]; 279 return ConnectionsMap[ S ];
270} 280}
271 281
282NodeCollection * TheNSResources::getConnection( int nr ) {
283 for( QDictIterator<NodeCollection> it(ConnectionsMap);
284 it.current();
285 ++it ) {
286 if( it.current()->number() == nr ) {
287 return it.current();
288 }
289 }
290 return 0;
291}
272/* 292/*
273void TheNSResources::renumberConnections( void ) { 293void TheNSResources::renumberConnections( void ) {
274 Name2Connection_t & M = NSResources->connections(); 294 Name2Connection_t & M = NSResources->connections();