Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (show whitespace changes)
4 files changed, 97 insertions, 47 deletions
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index b4313c4..1feffdb 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -1 +1,2 @@ | |||
1 | #include <asdevice.h> | ||
1 | #include "network_NN.h" | 2 | #include "network_NN.h" |
@@ -32,19 +33,38 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) { | |||
32 | 33 | ||
33 | const char ** NetworkNetNode::needs( void ) { | 34 | bool NetworkNetNode::hasDataForFile( const QString & S ) { |
34 | return NetworkNeeds; | 35 | return S == "interfaces"; |
35 | } | 36 | } |
36 | 37 | ||
37 | const char * NetworkNetNode::provides( void ) { | 38 | short NetworkNetNode::generateFile( const QString & ID, |
38 | return "connection"; | 39 | const QString & , |
39 | } | 40 | QTextStream & TS, |
41 | ANetNodeInstance * NNI, | ||
42 | long DevNr ) { | ||
43 | |||
44 | QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | ||
40 | 45 | ||
41 | bool NetworkNetNode::generateProperFilesFor( | 46 | if( ID == "interfaces" ) { |
42 | ANetNodeInstance * ) { | 47 | Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() )); |
48 | // generate mapping stanza for this interface | ||
49 | TS << "# check if " | ||
50 | << NIC | ||
51 | << " can be brought UP" | ||
52 | << endl; | ||
53 | TS << "mapping " | ||
54 | << NIC | ||
55 | << endl; | ||
56 | TS << " script networksettings2-request" | ||
57 | << endl | ||
58 | << endl; | ||
43 | return 0; | 59 | return 0; |
44 | } | 60 | } |
61 | return 1; | ||
62 | } | ||
45 | 63 | ||
46 | bool NetworkNetNode::generateDeviceDataForCommonFile( | 64 | const char ** NetworkNetNode::needs( void ) { |
47 | SystemFile & , | 65 | return NetworkNeeds; |
48 | long ) { | 66 | } |
49 | return 0; | 67 | |
68 | const char * NetworkNetNode::provides( void ) { | ||
69 | return "connection"; | ||
50 | } | 70 | } |
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 6548c32..745d1a7 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h | |||
@@ -16,2 +16,9 @@ public: | |||
16 | 16 | ||
17 | virtual bool hasDataForFile( const QString & S ); | ||
18 | |||
19 | virtual short generateFile( const QString & ID, | ||
20 | const QString & Path, | ||
21 | QTextStream & TS, | ||
22 | ANetNodeInstance * NNI, | ||
23 | long DevNr ); | ||
17 | virtual const QString pixmapName() | 24 | virtual const QString pixmapName() |
@@ -20,5 +27,3 @@ public: | |||
20 | virtual const QString nodeDescription() ; | 27 | virtual const QString nodeDescription() ; |
21 | |||
22 | virtual ANetNodeInstance * createInstance( void ); | 28 | virtual ANetNodeInstance * createInstance( void ); |
23 | |||
24 | virtual const char ** needs( void ); | 29 | virtual const char ** needs( void ); |
@@ -26,8 +31,2 @@ public: | |||
26 | 31 | ||
27 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); | ||
28 | virtual bool hasDataFor( const QString & ) | ||
29 | { return 0; } | ||
30 | virtual bool generateDeviceDataForCommonFile( | ||
31 | SystemFile & SF, long DevNr ); | ||
32 | |||
33 | private: | 32 | private: |
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp index 3e368a2..324c6e2 100644 --- a/noncore/settings/networksettings2/network/network_NNI.cpp +++ b/noncore/settings/networksettings2/network/network_NNI.cpp | |||
@@ -101,3 +101,3 @@ void ANetwork::commit( void ) { | |||
101 | 101 | ||
102 | bool ANetwork::hasDataFor( const QString & S ) { | 102 | bool ANetwork::hasDataForFile( const QString & S ) { |
103 | return S == "interfaces"; | 103 | return S == "interfaces"; |
@@ -105,9 +105,17 @@ bool ANetwork::hasDataFor( const QString & S ) { | |||
105 | 105 | ||
106 | bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | 106 | short ANetwork::generateFile( const QString & ID, |
107 | const QString & Path, | ||
108 | QTextStream &TS, | ||
109 | long DevNr | ||
110 | ) { | ||
111 | |||
112 | short rvl, rvd ; | ||
107 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); | 113 | QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); |
108 | 114 | ||
109 | if( S.name() == "interfaces" ) { | 115 | rvl = 1; |
116 | if( ID == "interfaces" ) { | ||
117 | Log(("Generate Network for %s\n", ID.latin1() )); | ||
110 | // we can safely call from here since device item is deeper | 118 | // we can safely call from here since device item is deeper |
111 | if( Data.UseDHCP ) { | 119 | if( Data.UseDHCP ) { |
112 | S << "iface " | 120 | TS << "iface " |
113 | << NIC | 121 | << NIC |
@@ -117,3 +125,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
117 | << endl; | 125 | << endl; |
118 | S << " up echo \"" | 126 | TS << " up echo \"" |
119 | << NIC | 127 | << NIC |
@@ -124,3 +132,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
124 | if( Data.SendHostname ) { | 132 | if( Data.SendHostname ) { |
125 | S << " hostname " | 133 | TS << " hostname " |
126 | << Data.Hostname | 134 | << Data.Hostname |
@@ -129,3 +137,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
129 | 137 | ||
130 | S << " down rm -f /tmp/profile-" | 138 | TS << " down rm -f /tmp/profile-" |
131 | << connection()->number() | 139 | << connection()->number() |
@@ -134,3 +142,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
134 | } else { | 142 | } else { |
135 | S << "iface " | 143 | TS << "iface " |
136 | << NIC << "-c" | 144 | << NIC << "-c" |
@@ -139,3 +147,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
139 | << endl; | 147 | << endl; |
140 | S << " up echo \"" | 148 | TS << " up echo \"" |
141 | << NIC | 149 | << NIC |
@@ -145,3 +153,3 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
145 | << endl; | 153 | << endl; |
146 | S << " down rm -f /tmp/profile-" | 154 | TS << " down rm -f /tmp/profile-" |
147 | << connection()->number() | 155 | << connection()->number() |
@@ -149,5 +157,11 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
149 | << endl; | 157 | << endl; |
150 | S << " address " << Data.IPAddress << endl; | 158 | TS << " address " |
151 | S << " broadcast " << Data.Broadcast << endl; | 159 | << Data.IPAddress |
152 | S << " netmask " << Data.NetMask << endl; | 160 | << endl; |
161 | TS << " broadcast " | ||
162 | << Data.Broadcast | ||
163 | << endl; | ||
164 | TS << " netmask " | ||
165 | << Data.NetMask | ||
166 | << endl; | ||
153 | 167 | ||
@@ -163,3 +177,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
163 | arg( ipal[3].toShort() & nmal[3].toShort() ); | 177 | arg( ipal[3].toShort() & nmal[3].toShort() ); |
164 | S << " network " << NW << endl; | 178 | TS << " network " |
179 | << NW | ||
180 | << endl; | ||
165 | } | 181 | } |
@@ -169,3 +185,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
169 | ++it ) { | 185 | ++it ) { |
170 | S << " pre-up " << (*it) << endl; | 186 | TS << " pre-up " |
187 | << (*it) | ||
188 | << endl; | ||
171 | } | 189 | } |
@@ -174,3 +192,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
174 | ++it ) { | 192 | ++it ) { |
175 | S << " up " << (*it) << endl; | 193 | TS << " up " |
194 | << (*it) | ||
195 | << endl; | ||
176 | } | 196 | } |
@@ -179,3 +199,5 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
179 | ++it ) { | 199 | ++it ) { |
180 | S << " down " << (*it) << endl; | 200 | TS << " down " |
201 | << (*it) | ||
202 | << endl; | ||
181 | } | 203 | } |
@@ -184,6 +206,14 @@ bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { | |||
184 | ++it ) { | 206 | ++it ) { |
185 | S << " post-down " << (*it) << endl; | 207 | TS << " post-down " |
208 | << (*it) | ||
209 | << endl; | ||
186 | } | 210 | } |
211 | rvl = 0; | ||
187 | } | 212 | } |
188 | return 0; | 213 | |
214 | // embed other info in it | ||
215 | rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr ); | ||
216 | |||
217 | return (rvd == 2 || rvl == 2 ) ? 2 : | ||
218 | (rvd == 0 || rvl == 0 ) ? 0 : 1; | ||
189 | } | 219 | } |
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h index 0058793..5e42503 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h | |||
@@ -17,2 +17,7 @@ public : | |||
17 | 17 | ||
18 | RuntimeInfo * runtime( void ) | ||
19 | { return | ||
20 | ( RT ) ? RT : ( RT = new NetworkRun( this, Data ) ); | ||
21 | } | ||
22 | |||
18 | QWidget * edit( QWidget * parent ); | 23 | QWidget * edit( QWidget * parent ); |
@@ -21,8 +26,2 @@ public : | |||
21 | 26 | ||
22 | RuntimeInfo * runtime( void ) | ||
23 | { if( RT == 0 ) | ||
24 | RT = new NetworkRun( this, Data ); | ||
25 | return RT; | ||
26 | } | ||
27 | |||
28 | virtual void * data( void ) | 27 | virtual void * data( void ) |
@@ -30,5 +29,7 @@ public : | |||
30 | 29 | ||
31 | virtual bool hasDataFor( const QString & S ); | 30 | virtual bool hasDataForFile( const QString & S ); |
32 | virtual bool generateDataForCommonFile( | 31 | virtual short generateFile( const QString & ID, |
33 | SystemFile & SF, long DevNr ); | 32 | const QString & Path, |
33 | QTextStream &TS, | ||
34 | long DevNr ); | ||
34 | 35 | ||