Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/netnode.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/netnode.h | 73 |
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 | |||
@@ -12,21 +12,21 @@ | |||
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 |
16 | class AsDevice; | 16 | class AsDevice; |
17 | class AsLine; | 17 | class AsLine; |
18 | class AsConnection; | 18 | class AsNetworkSetup; |
19 | class AsFullSetup; | 19 | class 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 | ||
24 | class ANetNode; | 24 | class ANetNode; |
25 | class ANetNodeInstance; | 25 | class ANetNodeInstance; |
26 | class NodeCollection; | 26 | class NetworkSetup; |
27 | class QTextStream; | 27 | class QTextStream; |
28 | class RuntimeInfo; | 28 | class RuntimeInfo; |
29 | class InterfaceInfo; | 29 | class InterfaceInfo; |
30 | class NSResources; | 30 | class NSResources; |
31 | 31 | ||
32 | extern QString & deQuote( QString & X ); | 32 | extern QString & deQuote( QString & X ); |
@@ -36,41 +36,41 @@ extern QString quote( QString X ); | |||
36 | 36 | ||
37 | typedef enum State { | 37 | typedef 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 | ||
59 | typedef enum Action { | 59 | typedef 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 | ||
74 | class ANetNode : public QObject { | 74 | class ANetNode : public QObject { |
75 | 75 | ||
76 | public: | 76 | public: |
@@ -88,13 +88,13 @@ public: | |||
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 | ||
@@ -242,16 +242,16 @@ public: | |||
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 | // |
@@ -312,14 +312,14 @@ public: | |||
312 | protected : | 312 | protected : |
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; |
@@ -375,13 +375,13 @@ public : | |||
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 | // |
@@ -472,18 +472,18 @@ public : | |||
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; |
@@ -494,27 +494,30 @@ signals : | |||
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 | ||
497 | protected : | 497 | protected : |
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 | ||
508 | class NodeCollection : public QList<ANetNodeInstance> { | 508 | class NetworkSetup : public QList<ANetNodeInstance> { |
509 | 509 | ||
510 | public : | 510 | public : |
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 | ||
@@ -540,21 +543,21 @@ public : | |||
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 | ||
@@ -574,13 +577,13 @@ public : | |||
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 ); |
@@ -616,13 +619,13 @@ private : | |||
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; |