summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings2/netnode.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/netnode.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp59
1 files changed, 34 insertions, 25 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index f00e0b3..0ab0e5b 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -122,33 +122,33 @@ void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){
122void ANetNodeInstance::saveAttributes( QTextStream & TS ) { 122void ANetNodeInstance::saveAttributes( QTextStream & TS ) {
123 TS << "__name=" << name() << endl; 123 TS << "__name=" << name() << endl;
124 saveSpecificAttribute( TS ); 124 saveSpecificAttribute( TS );
125} 125}
126 126
127ANetNodeInstance * ANetNodeInstance::nextNode( void ) { 127ANetNodeInstance * ANetNodeInstance::nextNode( void ) {
128 return connection()->findNext( this ); 128 return networkSetup()->findNext( this );
129} 129}
130 130
131// 131//
132// 132//
133// NODECOLLECTION 133// NODECOLLECTION
134// 134//
135// 135//
136 136
137NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { 137NetworkSetup::NetworkSetup( void ) : QList<ANetNodeInstance>() {
138 IsModified = 0; 138 IsModified = 0;
139 Index = -1; 139 Index = -1;
140 Name=""; 140 Name="";
141 IsNew = 1; 141 IsNew = 1;
142 CurrentState = Unchecked; 142 CurrentState = Unchecked;
143 AssignedInterface = 0; 143 AssignedInterface = 0;
144 Number = -1; 144 Number = -1;
145 Done = 0; 145 Done = 0;
146} 146}
147 147
148NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) : 148NetworkSetup::NetworkSetup( QTextStream & TS, bool & Dangling ) :
149 QList<ANetNodeInstance>() { 149 QList<ANetNodeInstance>() {
150 long idx; 150 long idx;
151 QString S, A, N; 151 QString S, A, N;
152 152
153 Number = -1; 153 Number = -1;
154 Done = 0; 154 Done = 0;
@@ -184,39 +184,39 @@ NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) :
184 ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); 184 ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
185 Log(( "Find node %s : %p\n", N.latin1(), NNI )); 185 Log(( "Find node %s : %p\n", N.latin1(), NNI ));
186 if( NNI ) { 186 if( NNI ) {
187 append( NNI ); 187 append( NNI );
188 } else { 188 } else {
189 // could not find a node type -> collection invalid 189 // could not find a node type -> collection invalid
190 Log(( "Node %s missing -> connection dangling\n", 190 Log(( "Node %s missing -> NetworkSetup dangling\n",
191 N.latin1() )); 191 N.latin1() ));
192 // create placeholder for this dangling NNI 192 // create placeholder for this dangling NNI
193 NNI = new ErrorNNI( N ); 193 NNI = new ErrorNNI( N );
194 Dangling = 1; 194 Dangling = 1;
195 } 195 }
196 } 196 }
197 } while( 1 ); 197 } while( 1 );
198 198
199 Log(( "Profile number %s : %d nodes\n", 199 Log(( "Profile number %s : %d nodes\n",
200 Name.latin1(), count() )); 200 Name.latin1(), count() ));
201} 201}
202 202
203NodeCollection::~NodeCollection( void ) { 203NetworkSetup::~NetworkSetup( void ) {
204} 204}
205 205
206const QString & NodeCollection::description( void ) { 206const QString & NetworkSetup::description( void ) {
207 ANetNodeInstance * NNI = getToplevel(); 207 ANetNodeInstance * NNI = getToplevel();
208 return (NNI) ? NNI->runtime()->description() : Name; 208 return (NNI) ? NNI->runtime()->description() : Name;
209} 209}
210 210
211void NodeCollection::append( ANetNodeInstance * NNI ) { 211void NetworkSetup::append( ANetNodeInstance * NNI ) {
212 NNI->setConnection( this ); 212 NNI->setNetworkSetup( this );
213 QList<ANetNodeInstance>::append( NNI ); 213 QList<ANetNodeInstance>::append( NNI );
214} 214}
215 215
216void NodeCollection::save( QTextStream & TS ) { 216void NetworkSetup::save( QTextStream & TS ) {
217 217
218 TS << "name=" << quote( Name ) << endl; 218 TS << "name=" << quote( Name ) << endl;
219 TS << "number=" << number() << endl; 219 TS << "number=" << number() << endl;
220 ANetNodeInstance * NNI; 220 ANetNodeInstance * NNI;
221 for( QListIterator<ANetNodeInstance> it(*this); 221 for( QListIterator<ANetNodeInstance> it(*this);
222 it.current(); 222 it.current();
@@ -225,39 +225,39 @@ void NodeCollection::save( QTextStream & TS ) {
225 TS << "node=" << NNI->name() << endl; 225 TS << "node=" << NNI->name() << endl;
226 } 226 }
227 TS << endl; 227 TS << endl;
228 IsNew = 0; 228 IsNew = 0;
229} 229}
230 230
231ANetNodeInstance * NodeCollection::getToplevel( void ) { 231ANetNodeInstance * NetworkSetup::getToplevel( void ) {
232 ANetNodeInstance * NNI = 0; 232 ANetNodeInstance * NNI = 0;
233 for( QListIterator<ANetNodeInstance> it(*this); 233 for( QListIterator<ANetNodeInstance> it(*this);
234 it.current(); 234 it.current();
235 ++it ) { 235 ++it ) {
236 NNI = it.current(); 236 NNI = it.current();
237 if( NNI->nodeClass()->isToplevel() ) { 237 if( NNI->nodeClass()->isToplevel() ) {
238 return NNI; 238 return NNI;
239 } 239 }
240 } 240 }
241 return 0; 241 return 0;
242} 242}
243 243
244ANetNodeInstance * NodeCollection::findByName( const QString & S ) { 244ANetNodeInstance * NetworkSetup::findByName( const QString & S ) {
245 ANetNodeInstance * NNI = 0; 245 ANetNodeInstance * NNI = 0;
246 for( QListIterator<ANetNodeInstance> it(*this); 246 for( QListIterator<ANetNodeInstance> it(*this);
247 it.current(); 247 it.current();
248 ++it ) { 248 ++it ) {
249 NNI = it.current(); 249 NNI = it.current();
250 if( NNI->name() == S ) { 250 if( NNI->name() == S ) {
251 return NNI; 251 return NNI;
252 } 252 }
253 } 253 }
254 return 0; 254 return 0;
255} 255}
256 256
257ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { 257ANetNodeInstance * NetworkSetup::findNext( ANetNodeInstance * NNI ) {
258 ANetNodeInstance * NNNI; 258 ANetNodeInstance * NNNI;
259 259
260 if( ! NNI ) 260 if( ! NNI )
261 getToplevel(); 261 getToplevel();
262 262
263 for( QListIterator<ANetNodeInstance> it(*this); 263 for( QListIterator<ANetNodeInstance> it(*this);
@@ -269,13 +269,13 @@ ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) {
269 return it.current(); 269 return it.current();
270 } 270 }
271 } 271 }
272 return 0; // no more next 272 return 0; // no more next
273} 273}
274 274
275int NodeCollection::compareItems( QCollection::Item I1, 275int NetworkSetup::compareItems( QCollection::Item I1,
276 QCollection::Item I2 ) { 276 QCollection::Item I2 ) {
277 ANetNodeInstance * NNI1, * NNI2; 277 ANetNodeInstance * NNI1, * NNI2;
278 NNI1 = (ANetNodeInstance *)I1; 278 NNI1 = (ANetNodeInstance *)I1;
279 NNI2 = (ANetNodeInstance *)I2; 279 NNI2 = (ANetNodeInstance *)I2;
280 return strcmp( NNI1->name(), NNI2->name() ); 280 return strcmp( NNI1->name(), NNI2->name() );
281} 281}
@@ -287,13 +287,13 @@ static char * State2PixmapTbl[] = {
287 "disabled", // disabled 287 "disabled", // disabled
288 "off", // off 288 "off", // off
289 "disconnected", // available 289 "disconnected", // available
290 "connected" // up 290 "connected" // up
291}; 291};
292 292
293QPixmap NodeCollection::devicePixmap( void ) { 293QPixmap NetworkSetup::devicePixmap( void ) {
294 QPixmap pm = NSResources->getPixmap( 294 QPixmap pm = NSResources->getPixmap(
295 getToplevel()->nextNode()->pixmapName()+"-large"); 295 getToplevel()->nextNode()->pixmapName()+"-large");
296 296
297 QPixmap Mini = NSResources->getPixmap( 297 QPixmap Mini = NSResources->getPixmap(
298 device()->netNode()->pixmapName() ); 298 device()->netNode()->pixmapName() );
299 299
@@ -305,17 +305,17 @@ QPixmap NodeCollection::devicePixmap( void ) {
305 pm.height()-Mini.height(), 305 pm.height()-Mini.height(),
306 Mini ); 306 Mini );
307 pm.setMask( pm.createHeuristicMask( TRUE ) ); 307 pm.setMask( pm.createHeuristicMask( TRUE ) );
308 return pm; 308 return pm;
309} 309}
310 310
311QPixmap NodeCollection::statePixmap( State_t S) { 311QPixmap NetworkSetup::statePixmap( State_t S) {
312 return NSResources->getPixmap( State2PixmapTbl[S] ); 312 return NSResources->getPixmap( State2PixmapTbl[S] );
313} 313}
314 314
315QString NodeCollection::stateName( State_t S) { 315QString NetworkSetup::stateName( State_t S) {
316 switch( S ) { 316 switch( S ) {
317 case Unknown : 317 case Unknown :
318 return qApp->translate( "networksettings2", "Unknown"); 318 return qApp->translate( "networksettings2", "Unknown");
319 case Unavailable : 319 case Unavailable :
320 return qApp->translate( "networksettings2", "Unavailable"); 320 return qApp->translate( "networksettings2", "Unavailable");
321 case Disabled : 321 case Disabled :
@@ -330,47 +330,47 @@ QString NodeCollection::stateName( State_t S) {
330 default : 330 default :
331 break; 331 break;
332 } 332 }
333 return QString(""); 333 return QString("");
334} 334}
335 335
336void NodeCollection::reassign( void ) { 336void NetworkSetup::reassign( void ) {
337 for( QListIterator<ANetNodeInstance> it(*this); 337 for( QListIterator<ANetNodeInstance> it(*this);
338 it.current(); 338 it.current();
339 ++it ) { 339 ++it ) {
340 it.current()->setConnection( this ); 340 it.current()->setNetworkSetup( this );
341 } 341 }
342} 342}
343 343
344const QStringList & NodeCollection::triggers() { 344const QStringList & NetworkSetup::triggers() {
345 return getToplevel()->runtime()->triggers(); 345 return getToplevel()->runtime()->triggers();
346} 346}
347 347
348bool NodeCollection::hasDataForFile( SystemFile & S ) { 348bool NetworkSetup::hasDataForFile( SystemFile & S ) {
349 return ( firstWithDataForFile( S ) != 0 ); 349 return ( firstWithDataForFile( S ) != 0 );
350} 350}
351 351
352ANetNodeInstance * NodeCollection::firstWithDataForFile( SystemFile & S ) { 352ANetNodeInstance * NetworkSetup::firstWithDataForFile( SystemFile & S ) {
353 for( QListIterator<ANetNodeInstance> it(*this); 353 for( QListIterator<ANetNodeInstance> it(*this);
354 it.current(); 354 it.current();
355 ++it ) { 355 ++it ) {
356 if( it.current()->hasDataForFile( S ) ) { 356 if( it.current()->hasDataForFile( S ) ) {
357 return it.current(); 357 return it.current();
358 } 358 }
359 } 359 }
360 return 0; 360 return 0;
361} 361}
362 362
363State_t NodeCollection::state( bool Update ) { 363State_t NetworkSetup::state( bool Update ) {
364 State_t NodeState; 364 State_t NodeState;
365 365
366 if( CurrentState == Unchecked || Update ) { 366 if( CurrentState == Unchecked || Update ) {
367 // collect states of all nodes until with get the 'higest' 367 // collect states of all nodes until with get the 'higest'
368 // state possible 368 // state possible
369 369
370 Log(( "Connection %s state %s\n", 370 Log(( "NetworkSetup %s state %s\n",
371 Name.latin1(), StateName[CurrentState] )); 371 Name.latin1(), StateName[CurrentState] ));
372 372
373 CurrentState = Unknown; 373 CurrentState = Unknown;
374 for( QListIterator<ANetNodeInstance> it(*this); 374 for( QListIterator<ANetNodeInstance> it(*this);
375 it.current(); 375 it.current();
376 ++it ) { 376 ++it ) {
@@ -392,13 +392,13 @@ State_t NodeCollection::state( bool Update ) {
392 } 392 }
393 } 393 }
394 394
395 return CurrentState; 395 return CurrentState;
396} 396}
397 397
398QString NodeCollection::setState( Action_t A, bool Force ) { 398QString NetworkSetup::setState( Action_t A, bool Force ) {
399 399
400 QString msg; 400 QString msg;
401 Action_t Actions[10]; 401 Action_t Actions[10];
402 int NoOfActions = 0; 402 int NoOfActions = 0;
403 403
404 // get current state 404 // get current state
@@ -489,19 +489,28 @@ QString NodeCollection::setState( Action_t A, bool Force ) {
489 return msg; 489 return msg;
490 } 490 }
491 } 491 }
492 return QString(); 492 return QString();
493} 493}
494 494
495void NetworkSetup::copyFrom( const NetworkSetup & N ) {
496 Number = N.Number;
497 CurrentState = N.CurrentState;
498 Name = N.Name;
499 IsNew = N.IsNew;
500 Index = N.Index;
501 AssignedInterface = N.AssignedInterface;
502}
503
495// 504//
496// 505//
497// RuntimeInfo 506// RuntimeInfo
498// 507//
499// 508//
500 509
501QString RuntimeInfo::setState( NodeCollection * NC, 510QString RuntimeInfo::setState( NetworkSetup * NC,
502 Action_t A, 511 Action_t A,
503 bool Force ) { 512 bool Force ) {
504 QString M; 513 QString M;
505 RuntimeInfo * Deeper = nextNode(); 514 RuntimeInfo * Deeper = nextNode();
506 515
507 if( Deeper ) { 516 if( Deeper ) {