author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (unidiff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/network | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2 |
CONTROL files : changed version string
NS2 many changes and first release of OT2
Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (show whitespace changes)
10 files changed, 101 insertions, 124 deletions
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index b5c41bf..23b3d44 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <asdevice.h> | 2 | #include <resources.h> |
3 | #include <netnode.h> | ||
3 | #include "network_NN.h" | 4 | #include "network_NN.h" |
4 | #include "network_NNI.h" | 5 | #include "network_NNI.h" |
5 | 6 | ||
@@ -8,10 +9,18 @@ static const char * NetworkNeeds[] = | |||
8 | 0 | 9 | 0 |
9 | }; | 10 | }; |
10 | 11 | ||
12 | static const char * NetworkProvides[] = | ||
13 | { "connection", | ||
14 | 0 | ||
15 | }; | ||
16 | |||
11 | /** | 17 | /** |
12 | * Constructor, find all of the possible interfaces | 18 | * Constructor, find all of the possible interfaces |
13 | */ | 19 | */ |
14 | NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { | 20 | NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { |
21 | |||
22 | NSResources->addSystemFile( | ||
23 | "interfaces", "/etc/network/interfaces", 1 ); | ||
15 | } | 24 | } |
16 | 25 | ||
17 | /** | 26 | /** |
@@ -32,31 +41,34 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) { | |||
32 | return new ANetwork( this ); | 41 | return new ANetwork( this ); |
33 | } | 42 | } |
34 | 43 | ||
35 | bool NetworkNetNode::hasDataForFile( const QString & S ) { | 44 | bool NetworkNetNode::hasDataForFile( SystemFile & S ) { |
36 | return S == "interfaces"; | 45 | return S.name() == "interfaces"; |
37 | } | 46 | } |
38 | 47 | ||
39 | short NetworkNetNode::generateFile( const QString & ID, | 48 | short NetworkNetNode::generateFile( SystemFile & SF, |
40 | const QString & , | ||
41 | QTextStream & TS, | ||
42 | ANetNodeInstance * NNI, | 49 | ANetNodeInstance * NNI, |
43 | long DevNr ) { | 50 | long DevNr ) { |
44 | 51 | ||
52 | if( DevNr < 0 ) { | ||
53 | // generate device specific but common part | ||
54 | return 1; | ||
55 | } | ||
56 | |||
45 | QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | 57 | QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
46 | 58 | ||
47 | if( ID == "interfaces" ) { | 59 | if( SF.name() == "interfaces" ) { |
48 | Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() )); | 60 | Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() )); |
49 | // generate mapping stanza for this interface | 61 | // generate mapping stanza for this interface |
50 | TS << "# check if " | 62 | SF << "# check if " |
51 | << NIC | 63 | << NIC |
52 | << " can be brought UP" | 64 | << " can be brought UP" |
53 | << endl; | 65 | << endl; |
54 | TS << "mapping " | 66 | SF << "mapping " |
55 | << NIC | 67 | << NIC |
56 | << endl; | 68 | << endl; |
57 | TS << " script " | 69 | SF << " script " |
58 | << QPEApplication::qpeDir() | 70 | << QPEApplication::qpeDir() |
59 | << "/bin/networksettings2-request" | 71 | << "bin/networksettings2-request" |
60 | << endl | 72 | << endl |
61 | << endl; | 73 | << endl; |
62 | return 0; | 74 | return 0; |
@@ -68,8 +80,8 @@ const char ** NetworkNetNode::needs( void ) { | |||
68 | return NetworkNeeds; | 80 | return NetworkNeeds; |
69 | } | 81 | } |
70 | 82 | ||
71 | const char * NetworkNetNode::provides( void ) { | 83 | const char ** NetworkNetNode::provides( void ) { |
72 | return "connection"; | 84 | return NetworkProvides; |
73 | } | 85 | } |
74 | 86 | ||
75 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { | 87 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { |
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 745d1a7..b063d4c 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h | |||
@@ -14,11 +14,9 @@ public: | |||
14 | NetworkNetNode(); | 14 | NetworkNetNode(); |
15 | virtual ~NetworkNetNode(); | 15 | virtual ~NetworkNetNode(); |
16 | 16 | ||
17 | virtual bool hasDataForFile( const QString & S ); | 17 | virtual bool hasDataForFile( SystemFile & S ); |
18 | 18 | ||
19 | virtual short generateFile( const QString & ID, | 19 | virtual short generateFile( SystemFile & TS, |
20 | const QString & Path, | ||
21 | QTextStream & TS, | ||
22 | ANetNodeInstance * NNI, | 20 | ANetNodeInstance * NNI, |
23 | long DevNr ); | 21 | long DevNr ); |
24 | virtual const QString pixmapName() | 22 | virtual const QString pixmapName() |
@@ -27,7 +25,7 @@ public: | |||
27 | virtual const QString nodeDescription() ; | 25 | virtual const QString nodeDescription() ; |
28 | virtual ANetNodeInstance * createInstance( void ); | 26 | virtual ANetNodeInstance * createInstance( void ); |
29 | virtual const char ** needs( void ); | 27 | virtual const char ** needs( void ); |
30 | virtual const char * provides( void ); | 28 | virtual const char ** provides( void ); |
31 | 29 | ||
32 | private: | 30 | private: |
33 | 31 | ||
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp index 324c6e2..78e6545 100644 --- a/noncore/settings/networksettings2/network/network_NNI.cpp +++ b/noncore/settings/networksettings2/network/network_NNI.cpp | |||
@@ -1,5 +1,5 @@ | |||
1 | #include <system.h> | 1 | #include <system.h> |
2 | #include <asdevice.h> | 2 | #include <netnode.h> |
3 | #include "networkedit.h" | 3 | #include "networkedit.h" |
4 | #include "network_NNI.h" | 4 | #include "network_NNI.h" |
5 | #include "network_NN.h" | 5 | #include "network_NN.h" |
@@ -99,13 +99,11 @@ void ANetwork::commit( void ) { | |||
99 | setModified( 1 ); | 99 | setModified( 1 ); |
100 | } | 100 | } |
101 | 101 | ||
102 | bool ANetwork::hasDataForFile( const QString & S ) { | 102 | bool ANetwork::hasDataForFile( SystemFile & S ) { |
103 | return S == "interfaces"; | 103 | return S.name() == "interfaces"; |
104 | } | 104 | } |
105 | 105 | ||
106 | short ANetwork::generateFile( const QString & ID, | 106 | short ANetwork::generateFile( SystemFile &SF, |
107 | const QString & Path, | ||
108 | QTextStream &TS, | ||
109 | long DevNr | 107 | long DevNr |
110 | ) { | 108 | ) { |
111 | 109 | ||
@@ -113,55 +111,55 @@ short ANetwork::generateFile( const QString & ID, | |||
113 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | 111 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
114 | 112 | ||
115 | rvl = 1; | 113 | rvl = 1; |
116 | if( ID == "interfaces" ) { | 114 | if( SF.name() == "interfaces" ) { |
117 | Log(("Generate Network for %s\n", ID.latin1() )); | 115 | Log(("Generate Network for %s\n", SF.name().latin1() )); |
118 | // we can safely call from here since device item is deeper | 116 | // we can safely call from here since device item is deeper |
119 | if( Data.UseDHCP ) { | 117 | if( Data.UseDHCP ) { |
120 | TS << "iface " | 118 | SF << "iface " |
121 | << NIC | 119 | << NIC |
122 | << "-c" | 120 | << "-c" |
123 | << connection()->number() | 121 | << connection()->number() |
124 | << "-allowed inet dhcp" | 122 | << "-allowed inet dhcp" |
125 | << endl; | 123 | << endl; |
126 | TS << " up echo \"" | 124 | SF << " up echo \"" |
127 | << NIC | 125 | << NIC |
128 | << "\" > /tmp/profile-" | 126 | << "\" > /tmp/profile-" |
129 | << connection()->number() | 127 | << connection()->number() |
130 | << ".up" | 128 | << ".up" |
131 | << endl; | 129 | << endl; |
132 | if( Data.SendHostname ) { | 130 | if( Data.SendHostname ) { |
133 | TS << " hostname " | 131 | SF << " hostname " |
134 | << Data.Hostname | 132 | << Data.Hostname |
135 | << endl; | 133 | << endl; |
136 | } | 134 | } |
137 | 135 | ||
138 | TS << " down rm -f /tmp/profile-" | 136 | SF << " down rm -f /tmp/profile-" |
139 | << connection()->number() | 137 | << connection()->number() |
140 | << ".up" | 138 | << ".up" |
141 | << endl; | 139 | << endl; |
142 | } else { | 140 | } else { |
143 | TS << "iface " | 141 | SF << "iface " |
144 | << NIC << "-c" | 142 | << NIC << "-c" |
145 | << connection()->number() | 143 | << connection()->number() |
146 | << "-allowed inet static" | 144 | << "-allowed inet static" |
147 | << endl; | 145 | << endl; |
148 | TS << " up echo \"" | 146 | SF << " up echo \"" |
149 | << NIC | 147 | << NIC |
150 | << "\" > /tmp/profile-" | 148 | << "\" > /tmp/profile-" |
151 | << connection()->number() | 149 | << connection()->number() |
152 | << ".up" | 150 | << ".up" |
153 | << endl; | 151 | << endl; |
154 | TS << " down rm -f /tmp/profile-" | 152 | SF << " down rm -f /tmp/profile-" |
155 | << connection()->number() | 153 | << connection()->number() |
156 | << ".up" | 154 | << ".up" |
157 | << endl; | 155 | << endl; |
158 | TS << " address " | 156 | SF << " address " |
159 | << Data.IPAddress | 157 | << Data.IPAddress |
160 | << endl; | 158 | << endl; |
161 | TS << " broadcast " | 159 | SF << " broadcast " |
162 | << Data.Broadcast | 160 | << Data.Broadcast |
163 | << endl; | 161 | << endl; |
164 | TS << " netmask " | 162 | SF << " netmask " |
165 | << Data.NetMask | 163 | << Data.NetMask |
166 | << endl; | 164 | << endl; |
167 | 165 | ||
@@ -175,7 +173,7 @@ short ANetwork::generateFile( const QString & ID, | |||
175 | arg( ipal[1].toShort() & nmal[1].toShort() ). | 173 | arg( ipal[1].toShort() & nmal[1].toShort() ). |
176 | arg( ipal[2].toShort() & nmal[2].toShort() ). | 174 | arg( ipal[2].toShort() & nmal[2].toShort() ). |
177 | arg( ipal[3].toShort() & nmal[3].toShort() ); | 175 | arg( ipal[3].toShort() & nmal[3].toShort() ); |
178 | TS << " network " | 176 | SF << " network " |
179 | << NW | 177 | << NW |
180 | << endl; | 178 | << endl; |
181 | } | 179 | } |
@@ -183,28 +181,28 @@ short ANetwork::generateFile( const QString & ID, | |||
183 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); | 181 | for ( QStringList::Iterator it = Data.PreUp_SL.begin(); |
184 | it != Data.PreUp_SL.end(); | 182 | it != Data.PreUp_SL.end(); |
185 | ++it ) { | 183 | ++it ) { |
186 | TS << " pre-up " | 184 | SF << " pre-up " |
187 | << (*it) | 185 | << (*it) |
188 | << endl; | 186 | << endl; |
189 | } | 187 | } |
190 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); | 188 | for ( QStringList::Iterator it = Data.PostUp_SL.begin(); |
191 | it != Data.PostUp_SL.end(); | 189 | it != Data.PostUp_SL.end(); |
192 | ++it ) { | 190 | ++it ) { |
193 | TS << " up " | 191 | SF << " up " |
194 | << (*it) | 192 | << (*it) |
195 | << endl; | 193 | << endl; |
196 | } | 194 | } |
197 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); | 195 | for ( QStringList::Iterator it = Data.PreDown_SL.begin(); |
198 | it != Data.PreDown_SL.end(); | 196 | it != Data.PreDown_SL.end(); |
199 | ++it ) { | 197 | ++it ) { |
200 | TS << " down " | 198 | SF << " down " |
201 | << (*it) | 199 | << (*it) |
202 | << endl; | 200 | << endl; |
203 | } | 201 | } |
204 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); | 202 | for ( QStringList::Iterator it = Data.PostDown_SL.begin(); |
205 | it != Data.PostDown_SL.end(); | 203 | it != Data.PostDown_SL.end(); |
206 | ++it ) { | 204 | ++it ) { |
207 | TS << " post-down " | 205 | SF << " post-down " |
208 | << (*it) | 206 | << (*it) |
209 | << endl; | 207 | << endl; |
210 | } | 208 | } |
@@ -212,7 +210,7 @@ short ANetwork::generateFile( const QString & ID, | |||
212 | } | 210 | } |
213 | 211 | ||
214 | // embed other info in it | 212 | // embed other info in it |
215 | rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr ); | 213 | rvd = connection()->getToplevel()->generateFileEmbedded( SF, DevNr ); |
216 | 214 | ||
217 | return (rvd == 2 || rvl == 2 ) ? 2 : | 215 | return (rvd == 2 || rvl == 2 ) ? 2 : |
218 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | 216 | (rvd == 0 || rvl == 0 ) ? 0 : 1; |
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h index 5e42503..71c276a 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h | |||
@@ -27,10 +27,8 @@ public : | |||
27 | virtual void * data( void ) | 27 | virtual void * data( void ) |
28 | { return (void *)&Data; } | 28 | { return (void *)&Data; } |
29 | 29 | ||
30 | virtual bool hasDataForFile( const QString & S ); | 30 | virtual bool hasDataForFile( SystemFile & SF ); |
31 | virtual short generateFile( const QString & ID, | 31 | virtual short generateFile( SystemFile &TS, |
32 | const QString & Path, | ||
33 | QTextStream &TS, | ||
34 | long DevNr ); | 32 | long DevNr ); |
35 | 33 | ||
36 | protected : | 34 | protected : |
@@ -41,7 +39,7 @@ protected : | |||
41 | private : | 39 | private : |
42 | 40 | ||
43 | NetworkEdit * GUI; | 41 | NetworkEdit * GUI; |
44 | NetworkData_t Data; | 42 | NetworkData Data; |
45 | NetworkRun * RT; | 43 | NetworkRun * RT; |
46 | }; | 44 | }; |
47 | 45 | ||
diff --git a/noncore/settings/networksettings2/network/networkdata.h b/noncore/settings/networksettings2/network/networkdata.h index 2c5da37..1df9dc4 100644 --- a/noncore/settings/networksettings2/network/networkdata.h +++ b/noncore/settings/networksettings2/network/networkdata.h | |||
@@ -3,7 +3,8 @@ | |||
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qstringlist.h> | 5 | #include <qstringlist.h> |
6 | typedef struct NetworkData { | 6 | class NetworkData { |
7 | public : | ||
7 | bool UseDHCP; | 8 | bool UseDHCP; |
8 | QString Hostname; | 9 | QString Hostname; |
9 | bool SendHostname; | 10 | bool SendHostname; |
@@ -17,6 +18,6 @@ typedef struct NetworkData { | |||
17 | QStringList PostUp_SL; | 18 | QStringList PostUp_SL; |
18 | QStringList PreDown_SL; | 19 | QStringList PreDown_SL; |
19 | QStringList PostDown_SL; | 20 | QStringList PostDown_SL; |
20 | } NetworkData_t; | 21 | } ; |
21 | 22 | ||
22 | #endif | 23 | #endif |
diff --git a/noncore/settings/networksettings2/network/networkedit.cpp b/noncore/settings/networksettings2/network/networkedit.cpp index 05110d9..d13cb66 100644 --- a/noncore/settings/networksettings2/network/networkedit.cpp +++ b/noncore/settings/networksettings2/network/networkedit.cpp | |||
@@ -65,7 +65,7 @@ QString NetworkEdit::acceptable( void ) { | |||
65 | return QString(); | 65 | return QString(); |
66 | } | 66 | } |
67 | 67 | ||
68 | bool NetworkEdit::commit( NetworkData_t & Data ) { | 68 | bool NetworkEdit::commit( NetworkData & Data ) { |
69 | bool SM = 0; | 69 | bool SM = 0; |
70 | CBM( Data.UseDHCP, DHCP_CB, SM ); | 70 | CBM( Data.UseDHCP, DHCP_CB, SM ); |
71 | TXTM( Data.IPAddress, IPAddress_LE, SM ); | 71 | TXTM( Data.IPAddress, IPAddress_LE, SM ); |
@@ -85,7 +85,7 @@ bool NetworkEdit::commit( NetworkData_t & Data ) { | |||
85 | return SM; | 85 | return SM; |
86 | } | 86 | } |
87 | 87 | ||
88 | void NetworkEdit::showData( NetworkData_t & Data ) { | 88 | void NetworkEdit::showData( NetworkData & Data ) { |
89 | DHCP_CB->setChecked( Data.UseDHCP ); | 89 | DHCP_CB->setChecked( Data.UseDHCP ); |
90 | SendHostname_CB->setChecked( Data.SendHostname ); | 90 | SendHostname_CB->setChecked( Data.SendHostname ); |
91 | Hostname_LE->setText( Data.Hostname ); | 91 | Hostname_LE->setText( Data.Hostname ); |
diff --git a/noncore/settings/networksettings2/network/networkedit.h b/noncore/settings/networksettings2/network/networkedit.h index adc20e0..45635c8 100644 --- a/noncore/settings/networksettings2/network/networkedit.h +++ b/noncore/settings/networksettings2/network/networkedit.h | |||
@@ -9,8 +9,8 @@ public : | |||
9 | 9 | ||
10 | NetworkEdit( QWidget * parent ); | 10 | NetworkEdit( QWidget * parent ); |
11 | QString acceptable( void ); | 11 | QString acceptable( void ); |
12 | bool commit( NetworkData_t & Data ); | 12 | bool commit( NetworkData & Data ); |
13 | void showData( NetworkData_t & Data ); | 13 | void showData( NetworkData & Data ); |
14 | 14 | ||
15 | public slots : | 15 | public slots : |
16 | 16 | ||
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index 3e24c5f..c17aa7f 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp | |||
@@ -1,78 +1,51 @@ | |||
1 | #include <system.h> | 1 | #include <system.h> |
2 | #include <asdevice.h> | 2 | #include <netnode.h> |
3 | #include <resources.h> | ||
3 | #include "networkrun.h" | 4 | #include "networkrun.h" |
4 | 5 | ||
5 | void NetworkRun::detectState( NodeCollection * NC ) { | 6 | State_t NetworkRun::detectState( void ) { |
6 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 7 | InterfaceInfo * II = nodeCollection()->assignedInterface(); |
7 | AsDevice * Next = RI->asDevice(); | ||
8 | InterfaceInfo * II = Next->assignedInterface(); | ||
9 | 8 | ||
10 | if( II ) { | 9 | Log(( "Interface %p : %d\n", II, (II) ? II->IsUp : 0 )); |
10 | if( II && II->IsUp ) { | ||
11 | // device has assigned interface | 11 | // device has assigned interface |
12 | NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); | 12 | return IsUp; |
13 | return; | ||
14 | } | 13 | } |
15 | 14 | ||
16 | Log(( "%s not ! UP or ava\n", NC->name().latin1() )); | 15 | // had no interface or interface is no longer up -> release |
17 | // has no interface -> delegate | 16 | nodeCollection()->assignInterface( 0 ); |
18 | RI->detectState( NC ); | 17 | |
18 | return Unknown; | ||
19 | } | 19 | } |
20 | 20 | ||
21 | bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { | 21 | QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) { |
22 | // we handle UP and DOWN | 22 | // we handle UP and DOWN |
23 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 23 | InterfaceInfo * II = NC->assignedInterface(); |
24 | AsDevice * Next = RI->asDevice(); | ||
25 | InterfaceInfo * II = Next->assignedInterface(); | ||
26 | 24 | ||
27 | if( A == Up ) { | 25 | if( A == Up ) { |
28 | // we can bring UP if lower level is available | 26 | // we can bring UP if lower level is available |
29 | if( NC->currentState() == Available || Force ) { | 27 | QStringList SL; |
30 | QString S; | 28 | SL << "ifup" |
31 | S.sprintf( "ifup %s=%s-c%d-allowed", | 29 | << QString().sprintf( "%s=%s-c%d-allowed", |
32 | II->Name.latin1(), II->Name.latin1(), | ||
33 | connection()->number() ); | ||
34 | NSResources->system().runAsRoot( S ); | ||
35 | } | ||
36 | return 1; | ||
37 | } else if( A == Down ) { | ||
38 | QString S; | ||
39 | if( Force ) { | ||
40 | Log(("Force mode %d\n", Force )); | ||
41 | for( int i = 0; | ||
42 | i < RI->netNode()->nodeClass()->instanceCount(); | ||
43 | i ++ ) { | ||
44 | S.sprintf( "ifdown %s", | ||
45 | RI->netNode()->nodeClass()->genNic( i ).latin1() ); | ||
46 | NSResources->system().runAsRoot( S ); | ||
47 | } | ||
48 | } else { | ||
49 | if( NC->currentState() == IsUp ) { | ||
50 | S.sprintf( "ifdown %s=%s-c%d-allowed", | ||
51 | II->Name.latin1(), II->Name.latin1(), | 30 | II->Name.latin1(), II->Name.latin1(), |
52 | connection()->number() ); | 31 | nodeCollection()->number() ); |
53 | NSResources->system().runAsRoot( S ); | 32 | if( ! NSResources->system().runAsRoot( SL ) ) { |
54 | } | 33 | return QString("Cannot call %1").arg(SL.join(" ")); |
55 | } | ||
56 | return 1; | ||
57 | } | 34 | } |
58 | // delegate | 35 | return QString(); |
59 | return RI->setState( NC, A, Force ); | ||
60 | } | 36 | } |
61 | 37 | ||
62 | bool NetworkRun::canSetState( State_t Curr, Action_t A ) { | 38 | if( A == Down ) { |
63 | // we handle UP and DOWN | 39 | QStringList SL; |
64 | RuntimeInfo * RI = netNode()->nextNode()->runtime(); | 40 | if( II ) { |
65 | 41 | SL << "ifdown" | |
66 | if( A == Up ) { | 42 | << II->Name.latin1(); |
67 | return ( Curr == Available ); | 43 | if( ! NSResources->system().runAsRoot( SL ) ) { |
68 | } else if( A == Down ) { | 44 | return QString( "Cannot call %1" ).arg( SL.join( " " )); |
69 | return ( Curr == IsUp ); | ||
70 | } | 45 | } |
71 | // delegate | 46 | } else { |
72 | return RI->canSetState( Curr, A ); | 47 | Log(( "no interface assigned." )); |
73 | } | 48 | } |
74 | 49 | } | |
75 | bool NetworkRun::handlesInterface( const QString & S ) { | 50 | return QString(); |
76 | // donno -> pass deeper | ||
77 | return netNode()->nextNode()->runtime()->handlesInterface(S); | ||
78 | } | 51 | } |
diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h index 522a912..78a1694 100644 --- a/noncore/settings/networksettings2/network/networkrun.h +++ b/noncore/settings/networksettings2/network/networkrun.h | |||
@@ -1,23 +1,20 @@ | |||
1 | #include <asconnection.h> | 1 | #include <netnode.h> |
2 | #include "networkdata.h" | 2 | #include "networkdata.h" |
3 | 3 | ||
4 | class NetworkRun : public AsConnection { | 4 | class NetworkRun : public RuntimeInfo { |
5 | 5 | ||
6 | public : | 6 | public : |
7 | 7 | ||
8 | NetworkRun( ANetNodeInstance * NNI, | 8 | NetworkRun( ANetNodeInstance * NNI, |
9 | NetworkData & Data ) : AsConnection( NNI ) | 9 | NetworkData & Data ) : RuntimeInfo( NNI ) |
10 | { } | 10 | { } |
11 | 11 | ||
12 | virtual AsConnection * asConnection( void ) | 12 | virtual RuntimeInfo * connection( void ) |
13 | { return (AsConnection *)this; } | 13 | { return this; } |
14 | 14 | ||
15 | protected : | 15 | State_t detectState( void ); |
16 | |||
17 | void detectState( NodeCollection * ); | ||
18 | bool setState( NodeCollection * ,Action_t A, bool ); | ||
19 | bool canSetState( State_t , Action_t A ); | ||
20 | 16 | ||
21 | bool handlesInterface( const QString & I ); | 17 | protected : |
22 | 18 | ||
19 | QString setMyState( NodeCollection * , Action_t, bool ); | ||
23 | }; | 20 | }; |
diff --git a/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control b/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control index 3dbb808..7b1056b 100644 --- a/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control +++ b/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control | |||
@@ -1,4 +1,4 @@ | |||
1 | Package: opie-networksettingsplugin2-network | 1 | Package: opie-networksettings2plugin-network |
2 | Files: plugins/networksettings2/libnetwork.so* | 2 | Files: plugins/networksettings2/libnetwork.so* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/settings | 4 | Section: opie/settings |