Diffstat (limited to 'noncore/settings/networksettings2/lancard') (more/less context) (ignore whitespace changes)
6 files changed, 60 insertions, 99 deletions
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index 20ae7f6..e36f757 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp | |||
@@ -4,3 +4,9 @@ | |||
4 | static const char * LanCardNeeds[] = | 4 | static const char * LanCardNeeds[] = |
5 | { 0 }; | 5 | { 0 |
6 | }; | ||
7 | |||
8 | static const char * LanCardProvides[] = | ||
9 | { "device", | ||
10 | 0 | ||
11 | }; | ||
6 | 12 | ||
@@ -36,4 +42,4 @@ const char ** LanCardNetNode::needs( void ) { | |||
36 | 42 | ||
37 | const char * LanCardNetNode::provides( void ) { | 43 | const char ** LanCardNetNode::provides( void ) { |
38 | return "device"; | 44 | return LanCardProvides; |
39 | } | 45 | } |
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h index 6882af7..dc7566a 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.h +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h | |||
@@ -27,3 +27,3 @@ public: | |||
27 | virtual const char ** needs( void ); | 27 | virtual const char ** needs( void ); |
28 | virtual const char * provides( void ); | 28 | virtual const char ** provides( void ); |
29 | 29 | ||
diff --git a/noncore/settings/networksettings2/lancard/lancarddata.h b/noncore/settings/networksettings2/lancard/lancarddata.h index c76767f..8f5e2b5 100644 --- a/noncore/settings/networksettings2/lancard/lancarddata.h +++ b/noncore/settings/networksettings2/lancard/lancarddata.h | |||
@@ -6,3 +6,4 @@ | |||
6 | 6 | ||
7 | typedef struct LanCardData { | 7 | class LanCardData { |
8 | public : | ||
8 | bool AnyLanCard; | 9 | bool AnyLanCard; |
@@ -10,3 +11,3 @@ typedef struct LanCardData { | |||
10 | 11 | ||
11 | } LanCardData_t; | 12 | } ; |
12 | 13 | ||
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp index 1544ddc..470b797 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.cpp +++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp | |||
@@ -6,3 +6,3 @@ | |||
6 | 6 | ||
7 | void LanCardRun::detectState( NodeCollection * NC ) { | 7 | State_t LanCardRun::detectState( void ) { |
8 | 8 | ||
@@ -12,3 +12,5 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
12 | 12 | ||
13 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 13 | NodeCollection * NC = nodeCollection(); |
14 | QString S = QString( "/tmp/profile-%1.up" ). | ||
15 | arg( NC->number()); | ||
14 | System & Sys = NSResources->system(); | 16 | System & Sys = NSResources->system(); |
@@ -30,6 +32,4 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
30 | if( X == Run->Name ) { | 32 | if( X == Run->Name ) { |
31 | Run->assignNode( netNode() ); | 33 | NC->assignInterface( Run ); |
32 | assignInterface( Run ); | 34 | return IsUp; |
33 | NC->setCurrentState( IsUp ); | ||
34 | return; | ||
35 | } | 35 | } |
@@ -39,3 +39,3 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
39 | 39 | ||
40 | if( ( Run = assignedInterface() ) ) { | 40 | if( ( Run = NC->assignedInterface() ) ) { |
41 | // we already have an interface assigned -> still present ? | 41 | // we already have an interface assigned -> still present ? |
@@ -43,4 +43,3 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
43 | // usb is still free -> keep assignment | 43 | // usb is still free -> keep assignment |
44 | NC->setCurrentState( Available ); | 44 | return Available; |
45 | return; | ||
46 | } // else interface is up but NOT us -> some other profile | 45 | } // else interface is up but NOT us -> some other profile |
@@ -49,3 +48,3 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
49 | // nothing (valid) assigned to us | 48 | // nothing (valid) assigned to us |
50 | assignInterface( 0 ); | 49 | NC->assignInterface( 0 ); |
51 | 50 | ||
@@ -65,4 +64,3 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
65 | // proper type, and Not UP -> free | 64 | // proper type, and Not UP -> free |
66 | NC->setCurrentState( Off ); | 65 | return Off; |
67 | return; | ||
68 | } | 66 | } |
@@ -71,71 +69,29 @@ void LanCardRun::detectState( NodeCollection * NC ) { | |||
71 | 69 | ||
72 | NC->setCurrentState( Unavailable ); | 70 | return Unavailable; |
73 | |||
74 | } | 71 | } |
75 | 72 | ||
76 | bool LanCardRun::setState( NodeCollection * NC, Action_t A, bool ) { | 73 | QString LanCardRun::setMyState( NodeCollection * NC, Action_t A, bool ) { |
77 | 74 | ||
78 | // we only handle activate and deactivate | 75 | if( A == Activate ) { |
79 | switch( A ) { | 76 | InterfaceInfo * N = getInterface(); |
80 | case Activate : | 77 | |
81 | { | 78 | if( ! N ) { |
82 | if( NC->currentState() != Off ) { | 79 | // no interface available |
83 | return 0; | 80 | NC->setCurrentState( Unavailable ); |
84 | } | 81 | return tr("No interface found"); |
85 | InterfaceInfo * N = getInterface(); | 82 | } |
86 | if( ! N ) { | 83 | |
87 | // no interface available | 84 | // because we were OFF the interface |
88 | NC->setCurrentState( Unavailable ); | 85 | // we get back is NOT assigned |
89 | return 0; | 86 | NC->assignInterface( N ); |
90 | } | 87 | NC->setCurrentState( Available ); |
91 | // because we were OFF the interface | 88 | return QString(); |
92 | // we get back is NOT assigned | ||
93 | N->assignNode( netNode() ); | ||
94 | assignInterface( N ); | ||
95 | NC->setCurrentState( Available ); | ||
96 | return 1; | ||
97 | } | ||
98 | case Deactivate : | ||
99 | if( NC->currentState() == IsUp ) { | ||
100 | // bring down first | ||
101 | if( ! connection()->setState( Down ) ) | ||
102 | // could not ... | ||
103 | return 0; | ||
104 | } else if( NC->currentState() != Available ) { | ||
105 | return 1; | ||
106 | } | ||
107 | assignedInterface()->assignNode( 0 ); // release | ||
108 | assignInterface( 0 ); | ||
109 | NC->setCurrentState( Off ); | ||
110 | return 1; | ||
111 | default : | ||
112 | // FT | ||
113 | break; | ||
114 | } | 89 | } |
115 | return 0; | ||
116 | } | ||
117 | 90 | ||
118 | bool LanCardRun::canSetState( State_t Curr, Action_t A ) { | 91 | if( A == Deactivate ) { |
119 | // we only handle up down activate and deactivate | 92 | NC->assignInterface( 0 ); |
120 | switch( A ) { | 93 | NC->setCurrentState( Off ); |
121 | case Activate : | ||
122 | { // at least available | ||
123 | if( Curr == Available ) { | ||
124 | return 1; | ||
125 | } | ||
126 | // or we can make one available | ||
127 | InterfaceInfo * N = getInterface(); | ||
128 | if( ! N || N->assignedNode() != 0 ) { | ||
129 | // non available or assigned | ||
130 | return 0; | ||
131 | } | ||
132 | return 1; | ||
133 | } | ||
134 | case Deactivate : | ||
135 | return ( Curr >= Available ); | ||
136 | default : | ||
137 | // FT | ||
138 | break; | ||
139 | } | 94 | } |
140 | return 0; | 95 | |
96 | return QString(); | ||
141 | } | 97 | } |
@@ -160,6 +116,6 @@ InterfaceInfo * LanCardRun::getInterface( void ) { | |||
160 | // this is a LAN card | 116 | // this is a LAN card |
161 | if( Run->assignedNode() == netNode() ) { | 117 | if( Run->assignedConnection() == netNode()->connection() ) { |
162 | // assigned to us | 118 | // assigned to us |
163 | return Run; | 119 | return Run; |
164 | } else if( Run->assignedNode() == 0 ) { | 120 | } else if( Run->assignedConnection() == 0 ) { |
165 | // free | 121 | // free |
diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h index b28dda7..57ef3fb 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.h +++ b/noncore/settings/networksettings2/lancard/lancardrun.h | |||
@@ -3,3 +3,3 @@ | |||
3 | 3 | ||
4 | #include <asdevice.h> | 4 | #include <netnode.h> |
5 | #include <qregexp.h> | 5 | #include <qregexp.h> |
@@ -7,3 +7,3 @@ | |||
7 | 7 | ||
8 | class LanCardRun : public AsDevice { | 8 | class LanCardRun : public RuntimeInfo { |
9 | 9 | ||
@@ -12,20 +12,18 @@ public : | |||
12 | LanCardRun( ANetNodeInstance * NNI, | 12 | LanCardRun( ANetNodeInstance * NNI, |
13 | LanCardData & D ) : AsDevice( NNI ), | 13 | LanCardData & D ) : RuntimeInfo( NNI ), |
14 | Pat( "eth[0-9]" ) | 14 | Pat( "eth[0-9]" ) { |
15 | { Data = &D; } | 15 | Data = &D; |
16 | } | ||
16 | 17 | ||
17 | virtual AsDevice * device( void ) | 18 | virtual RuntimeInfo * device( void ) |
18 | { return (AsDevice *)this; } | 19 | { return this; } |
19 | 20 | ||
20 | virtual AsDevice * asDevice( void ) | 21 | bool handlesInterface( const QString & I ); |
21 | { return (AsDevice *)this; } | 22 | bool handlesInterface( const InterfaceInfo & II ); |
22 | 23 | ||
23 | protected : | 24 | State_t detectState( void ); |
24 | 25 | ||
25 | void detectState( NodeCollection * NC ); | 26 | protected : |
26 | bool setState( NodeCollection * NC, Action_t A, bool Force ); | ||
27 | bool canSetState( State_t Curr, Action_t A ); | ||
28 | 27 | ||
29 | bool handlesInterface( const QString & I ); | 28 | QString setMyState( NodeCollection * , Action_t, bool ); |
30 | bool handlesInterface( const InterfaceInfo & II ); | ||
31 | 29 | ||
diff --git a/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control b/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control index d5aca66..4f87d04 100644 --- a/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control +++ b/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control | |||
@@ -1,2 +1,2 @@ | |||
1 | Package: opie-networksettingsplugin2-lancard | 1 | Package: opie-networksettings2plugin-lancard |
2 | Files: plugins/networksettings2/liblancard.so* | 2 | Files: plugins/networksettings2/liblancard.so* |