Diffstat (limited to 'noncore/settings/networksettings2/network/network_NNI.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/network/network_NNI.cpp | 50 |
1 files changed, 24 insertions, 26 deletions
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,6 +1,6 @@ | |||
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" |
6 | 6 | ||
@@ -98,71 +98,69 @@ void ANetwork::commit( void ) { | |||
98 | if( GUI && GUI->commit( Data ) ) | 98 | if( GUI && GUI->commit( Data ) ) |
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, | 107 | long DevNr |
108 | QTextStream &TS, | 108 | ) { |
109 | long DevNr | ||
110 | ) { | ||
111 | 109 | ||
112 | short rvl, rvd ; | 110 | short rvl, rvd ; |
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 | ||
168 | // derive network address = IPAddress & netmask | 166 | // derive network address = IPAddress & netmask |
@@ -174,46 +172,46 @@ short ANetwork::generateFile( const QString & ID, | |||
174 | arg( ipal[0].toShort() & nmal[0].toShort() ). | 172 | arg( ipal[0].toShort() & nmal[0].toShort() ). |
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 | } |
182 | } | 180 | } |
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 | } |
211 | rvl = 0; | 209 | rvl = 0; |
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; |
219 | } | 217 | } |