summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings2/netnode.h
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/netnode.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h73
1 files changed, 38 insertions, 35 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index 151d546..8aebdc0 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -6,101 +6,101 @@
6#include <qdict.h> 6#include <qdict.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qstringlist.h> 8#include <qstringlist.h>
9#include <qobject.h> 9#include <qobject.h>
10#include <time.h> 10#include <time.h>
11 11
12#include <Utils.h> 12#include <Utils.h>
13#include <system.h> 13#include <system.h>
14 14
15// difference feature interfaces 15// difference feature interfaces
16class AsDevice; 16class AsDevice;
17class AsLine; 17class AsLine;
18class AsConnection; 18class AsNetworkSetup;
19class AsFullSetup; 19class AsFullSetup;
20 20
21// needed for plugin creation function 21// needed for plugin creation function
22#include <qlist.h> 22#include <qlist.h>
23 23
24class ANetNode; 24class ANetNode;
25class ANetNodeInstance; 25class ANetNodeInstance;
26class NodeCollection; 26class NetworkSetup;
27class QTextStream; 27class QTextStream;
28class RuntimeInfo; 28class RuntimeInfo;
29class InterfaceInfo; 29class InterfaceInfo;
30class NSResources; 30class NSResources;
31 31
32extern QString & deQuote( QString & X ); 32extern QString & deQuote( QString & X );
33extern QString quote( QString X ); 33extern QString quote( QString X );
34 34
35#include "systemfile.h" 35#include "systemfile.h"
36 36
37typedef enum State { 37typedef enum State {
38 // if we have not yet detected the state of the device 38 // if we have not yet detected the state of the device
39 Unchecked = 0, 39 Unchecked = 0,
40 // if we cannot determine the state 40 // if we cannot determine the state
41 Unknown = 1, 41 Unknown = 1,
42 // if connection cannot be established e.g. because 42 // if networkSetup cannot be established e.g. because
43 // the hardware is not available 43 // the hardware is not available
44 Unavailable = 2, 44 Unavailable = 2,
45 // if the connection cannot be establishec but NOT 45 // if the networkSetup cannot be establishec but NOT
46 // because it is physically impossible but because 46 // because it is physically impossible but because
47 // it has been disabled for FUNCTIONAL reasons 47 // it has been disabled for FUNCTIONAL reasons
48 Disabled = 3, 48 Disabled = 3,
49 // if connection is available to is currently down 49 // if networkSetup is available to is currently down
50 // i.e. the corresponding hardware is not activated 50 // i.e. the corresponding hardware is not activated
51 Off = 4, 51 Off = 4,
52 // if connection is available to be used (i.e. the 52 // if networkSetup is available to be used (i.e. the
53 // devices if fully ready to be used 53 // devices if fully ready to be used
54 Available = 5, 54 Available = 5,
55 // if connection is being used 55 // if networkSetup is being used
56 IsUp = 6 56 IsUp = 6
57} State_t; 57} State_t;
58 58
59typedef enum Action { 59typedef enum Action {
60 // to make the device unavailable functionally -> to disabled 60 // to make the device unavailable functionally -> to disabled
61 Disable = 0, 61 Disable = 0,
62 // to make the device available functionally -> to off 62 // to make the device available functionally -> to off
63 Enable = 1, 63 Enable = 1,
64 // bring the hardware up -> to Available 64 // bring the hardware up -> to Available
65 Activate = 2, 65 Activate = 2,
66 // bring the hardware down -> to off 66 // bring the hardware down -> to off
67 Deactivate = 3, 67 Deactivate = 3,
68 // bring the connection up -> to IsUp 68 // bring the networkSetup up -> to IsUp
69 Up = 4, 69 Up = 4,
70 // bring the connection down -> to Available 70 // bring the networkSetup down -> to Available
71 Down = 5 71 Down = 5
72} Action_t; 72} Action_t;
73 73
74class ANetNode : public QObject { 74class ANetNode : public QObject {
75 75
76public: 76public:
77 77
78 typedef QArray<ANetNode *> NetNodeList; 78 typedef QArray<ANetNode *> NetNodeList;
79 79
80 ANetNode( const char * Name ) : QObject( 0, Name ) {} 80 ANetNode( const char * Name ) : QObject( 0, Name ) {}
81 virtual ~ANetNode(){}; 81 virtual ~ANetNode(){};
82 82
83 // 83 //
84 // 84 //
85 // standard methods with sensible default 85 // standard methods with sensible default
86 // 86 //
87 // 87 //
88 88
89 inline int done( void ) 89 inline int done( void )
90 { return Done; } 90 { return Done; }
91 inline void setDone( int D ) 91 inline void setDone( int D )
92 { Done = D; } 92 { Done = D; }
93 93
94 // does this Node provide a Connection 94 // does this Node provide a NetworkSetup
95 bool isToplevel( void ); 95 bool isToplevel( void );
96 96
97 // set the value of an attribute 97 // set the value of an attribute
98 void setAttribute( QString & Attr, QString & Value ) ; 98 void setAttribute( QString & Attr, QString & Value ) ;
99 void saveAttributes( QTextStream & TS ) ; 99 void saveAttributes( QTextStream & TS ) ;
100 100
101 // compiled references to 'needed' NetNodes -> needs list 101 // compiled references to 'needed' NetNodes -> needs list
102 inline void setAlternatives( NetNodeList * Alt ) 102 inline void setAlternatives( NetNodeList * Alt )
103 { Alternatives = Alt; } 103 { Alternatives = Alt; }
104 inline NetNodeList & alternatives( void ) 104 inline NetNodeList & alternatives( void )
105 { return *Alternatives; } 105 { return *Alternatives; }
106 106
@@ -236,28 +236,28 @@ public:
236 { Description = S; } 236 { Description = S; }
237 237
238 // pixmap for this instance -> from NetNode 238 // pixmap for this instance -> from NetNode
239 inline const QString pixmapName( void ) 239 inline const QString pixmapName( void )
240 { return NodeType->pixmapName(); } 240 { return NodeType->pixmapName(); }
241 241
242 inline const char ** provides( void ) 242 inline const char ** provides( void )
243 { return NodeType->provides(); } 243 { return NodeType->provides(); }
244 244
245 inline const char ** needs( void ) 245 inline const char ** needs( void )
246 { return NodeType->needs(); } 246 { return NodeType->needs(); }
247 247
248 inline void setConnection( NodeCollection * NC ) 248 inline void setNetworkSetup( NetworkSetup * NC )
249 { Connection = NC; } 249 { TheNetworkSetup = NC; }
250 inline NodeCollection * connection( void ) 250 inline NetworkSetup * networkSetup( void )
251 { return Connection; } 251 { return TheNetworkSetup; }
252 252
253 // 253 //
254 // 254 //
255 // Virtual methods with sensible defaults 255 // Virtual methods with sensible defaults
256 // 256 //
257 // 257 //
258 258
259 259
260 260
261 // open proper file identified by S 261 // open proper file identified by S
262 virtual bool openFile( SystemFile & ) 262 virtual bool openFile( SystemFile & )
263 { return 0; } 263 { return 0; }
@@ -306,26 +306,26 @@ public:
306 // get data from GUI and store in node 306 // get data from GUI and store in node
307 virtual void commit( void ) = 0; 307 virtual void commit( void ) = 0;
308 308
309 // returns node specific data -> only useful for 'buddy' 309 // returns node specific data -> only useful for 'buddy'
310 virtual void * data( void ) = 0; 310 virtual void * data( void ) = 0;
311 311
312protected : 312protected :
313 313
314 virtual void setSpecificAttribute( QString & , QString & ) = 0; 314 virtual void setSpecificAttribute( QString & , QString & ) = 0;
315 virtual void saveSpecificAttribute( QTextStream & ) = 0; 315 virtual void saveSpecificAttribute( QTextStream & ) = 0;
316 316
317 ANetNode * NodeType; 317 ANetNode * NodeType;
318 // connection to which this node belongs to 318 // networkSetup to which this node belongs to
319 NodeCollection * Connection; 319 NetworkSetup * TheNetworkSetup;
320 QString Description; 320 QString Description;
321 bool IsModified; 321 bool IsModified;
322 // true if this nodeinstance was just created (and not 322 // true if this nodeinstance was just created (and not
323 // loaded from file 323 // loaded from file
324 bool IsNew; 324 bool IsNew;
325 int Done; 325 int Done;
326 326
327 static long InstanceCounter; 327 static long InstanceCounter;
328}; 328};
329 329
330class ErrorNNI: public ANetNodeInstance { 330class ErrorNNI: public ANetNodeInstance {
331 331
@@ -369,25 +369,25 @@ protected :
369 369
370class RuntimeInfo : public QObject { 370class RuntimeInfo : public QObject {
371 371
372 Q_OBJECT 372 Q_OBJECT
373 373
374public : 374public :
375 375
376 RuntimeInfo( ANetNodeInstance * TheNNI ) 376 RuntimeInfo( ANetNodeInstance * TheNNI )
377 { NNI = TheNNI; } 377 { NNI = TheNNI; }
378 378
379 // 379 //
380 // 380 //
381 // methods to be overloaded by connection capable 381 // methods to be overloaded by networkSetup capable
382 // runtimes 382 // runtimes
383 // 383 //
384 // 384 //
385 385
386 386
387 // 387 //
388 // 388 //
389 // methods to be overloaded by device capable 389 // methods to be overloaded by device capable
390 // runtimes 390 // runtimes
391 // 391 //
392 // 392 //
393 393
@@ -466,61 +466,64 @@ public :
466 return (RI) ? RI->line() : 0; 466 return (RI) ? RI->line() : 0;
467 } 467 }
468 468
469 // return the node that offers full setup capability 469 // return the node that offers full setup capability
470 virtual RuntimeInfo * fullSetup( void ) 470 virtual RuntimeInfo * fullSetup( void )
471 { RuntimeInfo * RI = nextNode(); 471 { RuntimeInfo * RI = nextNode();
472 return (RI) ? RI->fullSetup() : 0; 472 return (RI) ? RI->fullSetup() : 0;
473 } 473 }
474 474
475 inline ANetNodeInstance * netNode() 475 inline ANetNodeInstance * netNode()
476 { return NNI; } 476 { return NNI; }
477 477
478 inline NodeCollection * nodeCollection() 478 inline NetworkSetup * networkSetup()
479 { return NNI->connection(); } 479 { return NNI->networkSetup(); }
480 480
481 virtual State_t detectState( void ) = 0; 481 virtual State_t detectState( void ) = 0;
482 // public API to set the state 482 // public API to set the state
483 virtual QString setState( NodeCollection * NC, 483 virtual QString setState( NetworkSetup * NC,
484 Action_t A, 484 Action_t A,
485 bool Force = 0 ); 485 bool Force = 0 );
486 486
487 inline RuntimeInfo * nextNode( void ) { 487 inline RuntimeInfo * nextNode( void ) {
488 ANetNodeInstance * NNI = netNode()->nextNode(); 488 ANetNodeInstance * NNI = netNode()->nextNode();
489 return (NNI) ? NNI->runtime() : 0; 489 return (NNI) ? NNI->runtime() : 0;
490 } 490 }
491 491
492signals : 492signals :
493 493
494 // sent by device if state changes 494 // sent by device if state changes
495 void stateChanged( State_t S, ANetNodeInstance * NNI ); 495 void stateChanged( State_t S, ANetNodeInstance * NNI );
496 496
497protected : 497protected :
498 498
499 // set state of this node (private API) 499 // set state of this node (private API)
500 virtual QString setMyState( NodeCollection * NC, 500 virtual QString setMyState( NetworkSetup * NC,
501 Action_t A, 501 Action_t A,
502 bool Force = 0 ) = 0; 502 bool Force = 0 ) = 0;
503 503
504 // connection this runtime info belongs to 504 // networkSetup this runtime info belongs to
505 ANetNodeInstance * NNI; 505 ANetNodeInstance * NNI;
506}; 506};
507 507
508class NodeCollection : public QList<ANetNodeInstance> { 508class NetworkSetup : public QList<ANetNodeInstance> {
509 509
510public : 510public :
511 511
512 NodeCollection( void ); 512 NetworkSetup( void );
513 NodeCollection( QTextStream & TS, bool & Dangling ); 513 NetworkSetup( QTextStream & TS, bool & Dangling );
514 ~NodeCollection( void ); 514 ~NetworkSetup( void );
515
516 // copy settings from NC to this
517 void copyFrom( const NetworkSetup & NC );
515 518
516 inline int done( void ) 519 inline int done( void )
517 { return Done; } 520 { return Done; }
518 inline void setDone( int D ) 521 inline void setDone( int D )
519 { Done = D; } 522 { Done = D; }
520 523
521 inline int number( void ) 524 inline int number( void )
522 { return Number; } 525 { return Number; }
523 inline void setNumber( int i ) 526 inline void setNumber( int i )
524 { Number = i; } 527 { Number = i; }
525 inline bool isNew( void ) 528 inline bool isNew( void )
526 { return IsNew; } 529 { return IsNew; }
@@ -534,33 +537,33 @@ public :
534 inline bool handlesInterface( const QString & S ) { 537 inline bool handlesInterface( const QString & S ) {
535 return getToplevel()->runtime()->handlesInterface( S ); 538 return getToplevel()->runtime()->handlesInterface( S );
536 } 539 }
537 540
538 // return the interface in the OS that is assigned to 541 // return the interface in the OS that is assigned to
539 // this device 542 // this device
540 inline InterfaceInfo * assignedInterface( void ) { 543 inline InterfaceInfo * assignedInterface( void ) {
541 return AssignedInterface; 544 return AssignedInterface;
542 } 545 }
543 546
544 // assign the interface to this device 547 // assign the interface to this device
545 inline void assignInterface( InterfaceInfo * NI ) { 548 inline void assignInterface( InterfaceInfo * NI ) {
546 if( NI == 0 ) { 549 // cleanup previous
547 if( AssignedInterface ) {
548 AssignedInterface->assignConnection( 0 );
549 }
550 }
551 AssignedInterface = NI;
552 if( AssignedInterface ) { 550 if( AssignedInterface ) {
553 AssignedInterface->assignConnection( this ); 551 AssignedInterface->assignToNetworkSetup( 0 );
554 } 552 }
553 if( NI ) {
554 // assign new
555 NI->assignToNetworkSetup( this );
556 }
557 AssignedInterface = NI;
555 } 558 }
556 559
557 inline RuntimeInfo * device() { 560 inline RuntimeInfo * device() {
558 return getToplevel()->runtime()->device(); 561 return getToplevel()->runtime()->device();
559 } 562 }
560 563
561 const QStringList & triggers(); 564 const QStringList & triggers();
562 565
563 State_t state( bool Update = 0 ); 566 State_t state( bool Update = 0 );
564 567
565 // get the ixmap for this device 568 // get the ixmap for this device
566 QPixmap devicePixmap( void ); 569 QPixmap devicePixmap( void );
@@ -568,25 +571,25 @@ public :
568 inline QPixmap statePixmap( bool Update = 0 ) 571 inline QPixmap statePixmap( bool Update = 0 )
569 { return statePixmap( state(Update) ); } 572 { return statePixmap( state(Update) ); }
570 QString stateName( State_t ); 573 QString stateName( State_t );
571 inline QString stateName( bool Update = 0 ) 574 inline QString stateName( bool Update = 0 )
572 { return stateName( state(Update) ); } 575 { return stateName( state(Update) ); }
573 576
574 QString setState( Action_t A, bool Force = 0 ); 577 QString setState( Action_t A, bool Force = 0 );
575 578
576 void save( QTextStream & TS ); 579 void save( QTextStream & TS );
577 580
578 void append( ANetNodeInstance * NNI ); 581 void append( ANetNodeInstance * NNI );
579 582
580 // makes sure that all items in the connection point to 583 // makes sure that all items in the networkSetup point to
581 // that connectoin 584 // that connectoin
582 void reassign( void ); 585 void reassign( void );
583 586
584 ANetNodeInstance * getToplevel( void ); 587 ANetNodeInstance * getToplevel( void );
585 ANetNodeInstance * findNext( ANetNodeInstance * NNI ); 588 ANetNodeInstance * findNext( ANetNodeInstance * NNI );
586 ANetNodeInstance * findByName( const QString & S ); 589 ANetNodeInstance * findByName( const QString & S );
587 590
588 inline const QString & name() 591 inline const QString & name()
589 { return Name; } 592 { return Name; }
590 593
591 const QString & description( void ); 594 const QString & description( void );
592 595
@@ -610,25 +613,25 @@ public :
610 { return getToplevel()->generateFile( SF, DN ); } 613 { return getToplevel()->generateFile( SF, DN ); }
611 614
612 bool triggeredBy( const QString & Trigger ) 615 bool triggeredBy( const QString & Trigger )
613 { return getToplevel()->triggeredBy( Trigger ); } 616 { return getToplevel()->triggeredBy( Trigger ); }
614 617
615private : 618private :
616 619
617 int compareItems ( QCollection::Item item1, 620 int compareItems ( QCollection::Item item1,
618 QCollection::Item item2 ); 621 QCollection::Item item2 );
619 622
620 long Number; 623 long Number;
621 624
622 // state of this connection 625 // state of this networkSetup
623 State_t CurrentState; 626 State_t CurrentState;
624 627
625 QString Name; 628 QString Name;
626 // true if this collection was just created (and not 629 // true if this collection was just created (and not
627 // loaded from file 630 // loaded from file
628 bool IsNew; 631 bool IsNew;
629 // index in listbox 632 // index in listbox
630 int Index; 633 int Index;
631 bool IsModified; 634 bool IsModified;
632 int Done; 635 int Done;
633 636
634 InterfaceInfo * AssignedInterface; 637 InterfaceInfo * AssignedInterface;