summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-10-18 18:12:53 (UTC)
committer benmeyer <benmeyer>2002-10-18 18:12:53 (UTC)
commita63b3b36cf4d665b67733e069bfaad8f96388276 (patch) (unidiff)
tree0089ca8d5bacd31982d8bec367d091b4f58cace1
parent5ec0d959ca9d3ade0c7271885028fd4309cf2b4c (diff)
downloadopie-a63b3b36cf4d665b67733e069bfaad8f96388276.zip
opie-a63b3b36cf4d665b67733e069bfaad8f96388276.tar.gz
opie-a63b3b36cf4d665b67733e069bfaad8f96388276.tar.bz2
interfaces now watches for # in most cases
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interfaceinformation.ui12
-rw-r--r--noncore/net/networksetup/interfaces.cpp10
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp4
-rw-r--r--noncore/net/networksetup/module.h8
-rw-r--r--noncore/settings/networksettings/interfaceinformation.ui12
-rw-r--r--noncore/settings/networksettings/interfaces.cpp10
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp4
-rw-r--r--noncore/settings/networksettings/module.h8
8 files changed, 34 insertions, 34 deletions
diff --git a/noncore/net/networksetup/interfaceinformation.ui b/noncore/net/networksetup/interfaceinformation.ui
index fc99fce..2838d19 100644
--- a/noncore/net/networksetup/interfaceinformation.ui
+++ b/noncore/net/networksetup/interfaceinformation.ui
@@ -1,183 +1,183 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>InterfaceInformation</class> 2<class>InterfaceInformation</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>InterfaceInformation</cstring> 7 <cstring>InterfaceInformation</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>219</width> 14 <width>219</width>
15 <height>255</height> 15 <height>255</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Interface Information</string> 20 <string>Interface Information</string>
21 </property> 21 </property>
22 <grid> 22 <grid>
23 <property stdset="1"> 23 <property stdset="1">
24 <name>margin</name> 24 <name>margin</name>
25 <number>11</number> 25 <number>11</number>
26 </property> 26 </property>
27 <property stdset="1"> 27 <property stdset="1">
28 <name>spacing</name> 28 <name>spacing</name>
29 <number>6</number> 29 <number>6</number>
30 </property> 30 </property>
31 <widget row="4" column="0" rowspan="1" colspan="2" > 31 <widget row="4" column="0" rowspan="1" colspan="2" >
32 <class>QLayoutWidget</class> 32 <class>QLayoutWidget</class>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>name</name> 34 <name>name</name>
35 <cstring>Layout1</cstring> 35 <cstring>Layout1</cstring>
36 </property> 36 </property>
37 <grid> 37 <grid>
38 <property stdset="1"> 38 <property stdset="1">
39 <name>margin</name> 39 <name>margin</name>
40 <number>0</number> 40 <number>0</number>
41 </property> 41 </property>
42 <property stdset="1"> 42 <property stdset="1">
43 <name>spacing</name> 43 <name>spacing</name>
44 <number>6</number> 44 <number>6</number>
45 </property> 45 </property>
46 <widget row="1" column="0" > 46 <widget row="1" column="0" >
47 <class>QPushButton</class> 47 <class>QPushButton</class>
48 <property stdset="1"> 48 <property stdset="1">
49 <name>name</name> 49 <name>name</name>
50 <cstring>refreshButton</cstring> 50 <cstring>refreshButton</cstring>
51 </property> 51 </property>
52 <property stdset="1"> 52 <property stdset="1">
53 <name>text</name> 53 <name>text</name>
54 <string>Refresh</string> 54 <string>&amp;Refresh</string>
55 </property> 55 </property>
56 </widget> 56 </widget>
57 <widget row="0" column="1" > 57 <widget row="0" column="1" >
58 <class>QPushButton</class> 58 <class>QPushButton</class>
59 <property stdset="1"> 59 <property stdset="1">
60 <name>name</name> 60 <name>name</name>
61 <cstring>stopButton</cstring> 61 <cstring>stopButton</cstring>
62 </property> 62 </property>
63 <property stdset="1"> 63 <property stdset="1">
64 <name>text</name> 64 <name>text</name>
65 <string>Stop</string> 65 <string>S&amp;top</string>
66 </property> 66 </property>
67 </widget> 67 </widget>
68 <widget row="1" column="1" > 68 <widget row="1" column="1" >
69 <class>QPushButton</class> 69 <class>QPushButton</class>
70 <property stdset="1"> 70 <property stdset="1">
71 <name>name</name> 71 <name>name</name>
72 <cstring>restartButton</cstring> 72 <cstring>restartButton</cstring>
73 </property> 73 </property>
74 <property stdset="1"> 74 <property stdset="1">
75 <name>text</name> 75 <name>text</name>
76 <string>Restart</string> 76 <string>R&amp;estart</string>
77 </property> 77 </property>
78 </widget> 78 </widget>
79 <widget row="0" column="0" > 79 <widget row="0" column="0" >
80 <class>QPushButton</class> 80 <class>QPushButton</class>
81 <property stdset="1"> 81 <property stdset="1">
82 <name>name</name> 82 <name>name</name>
83 <cstring>startButton</cstring> 83 <cstring>startButton</cstring>
84 </property> 84 </property>
85 <property stdset="1"> 85 <property stdset="1">
86 <name>text</name> 86 <name>text</name>
87 <string>Start</string> 87 <string>&amp;Start</string>
88 </property> 88 </property>
89 </widget> 89 </widget>
90 </grid> 90 </grid>
91 </widget> 91 </widget>
92 <widget row="0" column="0" > 92 <widget row="0" column="0" >
93 <class>Line</class> 93 <class>Line</class>
94 <property stdset="1"> 94 <property stdset="1">
95 <name>name</name> 95 <name>name</name>
96 <cstring>Line1</cstring> 96 <cstring>Line1</cstring>
97 </property> 97 </property>
98 <property stdset="1"> 98 <property stdset="1">
99 <name>orientation</name> 99 <name>orientation</name>
100 <enum>Horizontal</enum> 100 <enum>Horizontal</enum>
101 </property> 101 </property>
102 </widget> 102 </widget>
103 <widget row="0" column="0" > 103 <widget row="0" column="0" >
104 <class>QLabel</class> 104 <class>QLabel</class>
105 <property stdset="1"> 105 <property stdset="1">
106 <name>name</name> 106 <name>name</name>
107 <cstring>TextLabel22</cstring> 107 <cstring>TextLabel22</cstring>
108 </property> 108 </property>
109 <property stdset="1"> 109 <property stdset="1">
110 <name>text</name> 110 <name>text</name>
111 <string>IP Address</string> 111 <string>IP Address</string>
112 </property> 112 </property>
113 </widget> 113 </widget>
114 <widget row="1" column="0" > 114 <widget row="1" column="0" >
115 <class>QLabel</class> 115 <class>QLabel</class>
116 <property stdset="1"> 116 <property stdset="1">
117 <name>name</name> 117 <name>name</name>
118 <cstring>TextLabel23</cstring> 118 <cstring>TextLabel23</cstring>
119 </property> 119 </property>
120 <property stdset="1"> 120 <property stdset="1">
121 <name>text</name> 121 <name>text</name>
122 <string>Subnet Mask</string> 122 <string>Subnet Mask</string>
123 </property> 123 </property>
124 </widget> 124 </widget>
125 <widget row="2" column="0" > 125 <widget row="2" column="0" >
126 <class>QLabel</class> 126 <class>QLabel</class>
127 <property stdset="1"> 127 <property stdset="1">
128 <name>name</name> 128 <name>name</name>
129 <cstring>TextLabel21</cstring> 129 <cstring>TextLabel21</cstring>
130 </property> 130 </property>
131 <property stdset="1"> 131 <property stdset="1">
132 <name>text</name> 132 <name>text</name>
133 <string>MAC Address</string> 133 <string>MAC Address</string>
134 </property> 134 </property>
135 </widget> 135 </widget>
136 <widget row="3" column="0" > 136 <widget row="3" column="0" >
137 <class>QLabel</class> 137 <class>QLabel</class>
138 <property stdset="1"> 138 <property stdset="1">
139 <name>name</name> 139 <name>name</name>
140 <cstring>TextLabel24</cstring> 140 <cstring>TextLabel24</cstring>
141 </property> 141 </property>
142 <property stdset="1"> 142 <property stdset="1">
143 <name>frameShape</name> 143 <name>frameShape</name>
144 <enum>MShape</enum> 144 <enum>MShape</enum>
145 </property> 145 </property>
146 <property stdset="1"> 146 <property stdset="1">
147 <name>frameShadow</name> 147 <name>frameShadow</name>
148 <enum>MShadow</enum> 148 <enum>MShadow</enum>
149 </property> 149 </property>
150 <property stdset="1"> 150 <property stdset="1">
151 <name>text</name> 151 <name>text</name>
152 <string>Broadcast</string> 152 <string>Broadcast</string>
153 </property> 153 </property>
154 </widget> 154 </widget>
155 <widget row="1" column="1" > 155 <widget row="1" column="1" >
156 <class>QLabel</class> 156 <class>QLabel</class>
157 <property stdset="1"> 157 <property stdset="1">
158 <name>name</name> 158 <name>name</name>
159 <cstring>subnetMaskLabel</cstring> 159 <cstring>subnetMaskLabel</cstring>
160 </property> 160 </property>
161 <property stdset="1"> 161 <property stdset="1">
162 <name>frameShape</name> 162 <name>frameShape</name>
163 <enum>Panel</enum> 163 <enum>Panel</enum>
164 </property> 164 </property>
165 <property stdset="1"> 165 <property stdset="1">
166 <name>frameShadow</name> 166 <name>frameShadow</name>
167 <enum>Sunken</enum> 167 <enum>Sunken</enum>
168 </property> 168 </property>
169 <property stdset="1"> 169 <property stdset="1">
170 <name>text</name> 170 <name>text</name>
171 <string>0.0.0.0</string> 171 <string>0.0.0.0</string>
172 </property> 172 </property>
173 </widget> 173 </widget>
174 <widget row="2" column="1" > 174 <widget row="2" column="1" >
175 <class>QLabel</class> 175 <class>QLabel</class>
176 <property stdset="1"> 176 <property stdset="1">
177 <name>name</name> 177 <name>name</name>
178 <cstring>macAddressLabel</cstring> 178 <cstring>macAddressLabel</cstring>
179 </property> 179 </property>
180 <property stdset="1"> 180 <property stdset="1">
181 <name>frameShape</name> 181 <name>frameShape</name>
182 <enum>Panel</enum> 182 <enum>Panel</enum>
183 </property> 183 </property>
@@ -200,146 +200,144 @@
200 <name>frameShape</name> 200 <name>frameShape</name>
201 <enum>Panel</enum> 201 <enum>Panel</enum>
202 </property> 202 </property>
203 <property stdset="1"> 203 <property stdset="1">
204 <name>frameShadow</name> 204 <name>frameShadow</name>
205 <enum>Sunken</enum> 205 <enum>Sunken</enum>
206 </property> 206 </property>
207 <property stdset="1"> 207 <property stdset="1">
208 <name>text</name> 208 <name>text</name>
209 <string></string> 209 <string></string>
210 </property> 210 </property>
211 </widget> 211 </widget>
212 <widget row="0" column="1" > 212 <widget row="0" column="1" >
213 <class>QLabel</class> 213 <class>QLabel</class>
214 <property stdset="1"> 214 <property stdset="1">
215 <name>name</name> 215 <name>name</name>
216 <cstring>ipAddressLabel</cstring> 216 <cstring>ipAddressLabel</cstring>
217 </property> 217 </property>
218 <property stdset="1"> 218 <property stdset="1">
219 <name>frameShape</name> 219 <name>frameShape</name>
220 <enum>Panel</enum> 220 <enum>Panel</enum>
221 </property> 221 </property>
222 <property stdset="1"> 222 <property stdset="1">
223 <name>frameShadow</name> 223 <name>frameShadow</name>
224 <enum>Sunken</enum> 224 <enum>Sunken</enum>
225 </property> 225 </property>
226 <property stdset="1"> 226 <property stdset="1">
227 <name>text</name> 227 <name>text</name>
228 <string>0.0.0.0</string> 228 <string>0.0.0.0</string>
229 </property> 229 </property>
230 </widget> 230 </widget>
231 <spacer row="7" column="1" > 231 <spacer row="7" column="1" >
232 <property> 232 <property>
233 <name>name</name> 233 <name>name</name>
234 <cstring>Spacer18</cstring> 234 <cstring>Spacer18</cstring>
235 </property> 235 </property>
236 <property stdset="1"> 236 <property stdset="1">
237 <name>orientation</name> 237 <name>orientation</name>
238 <enum>Vertical</enum> 238 <enum>Vertical</enum>
239 </property> 239 </property>
240 <property stdset="1"> 240 <property stdset="1">
241 <name>sizeType</name> 241 <name>sizeType</name>
242 <enum>Expanding</enum> 242 <enum>Expanding</enum>
243 </property> 243 </property>
244 <property> 244 <property>
245 <name>sizeHint</name> 245 <name>sizeHint</name>
246 <size> 246 <size>
247 <width>20</width> 247 <width>20</width>
248 <height>20</height> 248 <height>20</height>
249 </size> 249 </size>
250 </property> 250 </property>
251 </spacer> 251 </spacer>
252 <widget row="6" column="0" rowspan="1" colspan="2" > 252 <widget row="6" column="0" rowspan="1" colspan="2" >
253 <class>QLayoutWidget</class> 253 <class>QLayoutWidget</class>
254 <property stdset="1"> 254 <property stdset="1">
255 <name>name</name> 255 <name>name</name>
256 <cstring>Layout2</cstring> 256 <cstring>Layout2</cstring>
257 </property> 257 </property>
258 <hbox> 258 <hbox>
259 <property stdset="1"> 259 <property stdset="1">
260 <name>margin</name> 260 <name>margin</name>
261 <number>0</number> 261 <number>0</number>
262 </property> 262 </property>
263 <property stdset="1"> 263 <property stdset="1">
264 <name>spacing</name> 264 <name>spacing</name>
265 <number>6</number> 265 <number>6</number>
266 </property> 266 </property>
267 <spacer> 267 <spacer>
268 <property> 268 <property>
269 <name>name</name> 269 <name>name</name>
270 <cstring>Spacer10</cstring> 270 <cstring>Spacer10</cstring>
271 </property> 271 </property>
272 <property stdset="1"> 272 <property stdset="1">
273 <name>orientation</name> 273 <name>orientation</name>
274 <enum>Horizontal</enum> 274 <enum>Horizontal</enum>
275 </property> 275 </property>
276 <property stdset="1"> 276 <property stdset="1">
277 <name>sizeType</name> 277 <name>sizeType</name>
278 <enum>Expanding</enum> 278 <enum>Expanding</enum>
279 </property> 279 </property>
280 <property> 280 <property>
281 <name>sizeHint</name> 281 <name>sizeHint</name>
282 <size> 282 <size>
283 <width>20</width> 283 <width>20</width>
284 <height>20</height> 284 <height>20</height>
285 </size> 285 </size>
286 </property> 286 </property>
287 </spacer> 287 </spacer>
288 <widget> 288 <widget>
289 <class>QPushButton</class> 289 <class>QPushButton</class>
290 <property stdset="1"> 290 <property stdset="1">
291 <name>name</name> 291 <name>name</name>
292 <cstring>advancedButton</cstring> 292 <cstring>advancedButton</cstring>
293 </property> 293 </property>
294 <property stdset="1"> 294 <property stdset="1">
295 <name>text</name> 295 <name>text</name>
296 <string>View Advanced Information</string> 296 <string>View &amp;Advanced Information</string>
297 </property> 297 </property>
298 </widget> 298 </widget>
299 </hbox> 299 </hbox>
300 </widget> 300 </widget>
301 <widget row="5" column="0" rowspan="1" colspan="2" > 301 <widget row="5" column="0" rowspan="1" colspan="2" >
302 <class>Line</class> 302 <class>Line</class>
303 <property stdset="1"> 303 <property stdset="1">
304 <name>name</name> 304 <name>name</name>
305 <cstring>Line5</cstring> 305 <cstring>Line5</cstring>
306 </property> 306 </property>
307 <property stdset="1"> 307 <property stdset="1">
308 <name>orientation</name> 308 <name>orientation</name>
309 <enum>Horizontal</enum> 309 <enum>Horizontal</enum>
310 </property> 310 </property>
311 </widget> 311 </widget>
312 </grid> 312 </grid>
313</widget> 313</widget>
314<customwidgets> 314<customwidgets>
315 <customwidget> 315 <customwidget>
316 <class>QWidget</class> 316 <class>QWidget</class>
317 <header location="local">qwidget.h</header> 317 <header location="local">qwidget.h</header>
318 <sizehint> 318 <sizehint>
319 <width>100</width> 319 <width>100</width>
320 <height>100</height> 320 <height>100</height>
321 </sizehint> 321 </sizehint>
322 <container>0</container> 322 <container>0</container>
323 <sizepolicy> 323 <sizepolicy>
324 <hordata>7</hordata> 324 <hordata>7</hordata>
325 <verdata>7</verdata> 325 <verdata>7</verdata>
326 </sizepolicy> 326 </sizepolicy>
327 <pixmap>image0</pixmap> 327 <pixmap>image0</pixmap>
328 </customwidget> 328 </customwidget>
329</customwidgets> 329</customwidgets>
330<images> 330<images>
331 <image> 331 <image>
332 <name>image0</name> 332 <name>image0</name>
333 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> 333 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
334 </image> 334 </image>
335</images> 335</images>
336<connections>
337</connections>
338<tabstops> 336<tabstops>
339 <tabstop>startButton</tabstop> 337 <tabstop>startButton</tabstop>
340 <tabstop>stopButton</tabstop> 338 <tabstop>stopButton</tabstop>
341 <tabstop>refreshButton</tabstop> 339 <tabstop>refreshButton</tabstop>
342 <tabstop>restartButton</tabstop> 340 <tabstop>restartButton</tabstop>
343 <tabstop>advancedButton</tabstop> 341 <tabstop>advancedButton</tabstop>
344</tabstops> 342</tabstops>
345</UI> 343</UI>
diff --git a/noncore/net/networksetup/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp
index 9155890..377a6db 100644
--- a/noncore/net/networksetup/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces.cpp
@@ -1,150 +1,150 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qregexp.h> 5#include <qregexp.h>
6 6
7#define AUTO "auto" 7#define AUTO "auto"
8#define IFACE "iface" 8#define IFACE "iface"
9#define MAPPING "mapping" 9#define MAPPING "mapping"
10 10
11/** 11/**
12 * Constructor. Reads in the interfaces file and then split the file up by 12 * Constructor. Reads in the interfaces file and then split the file up by
13 * the \n for interfaces variable. 13 * the \n for interfaces variable.
14 * @param useInterfacesFile if an interface file other then the default is 14 * @param useInterfacesFile if an interface file other then the default is
15 * desired to be used it should be passed in. 15 * desired to be used it should be passed in.
16 */ 16 */
17Interfaces::Interfaces(QString useInterfacesFile){ 17Interfaces::Interfaces(QString useInterfacesFile){
18 acceptedFamily.append(INTERFACES_FAMILY_INET); 18 acceptedFamily.append(INTERFACES_FAMILY_INET);
19 acceptedFamily.append(INTERFACES_FAMILY_IPX); 19 acceptedFamily.append(INTERFACES_FAMILY_IPX);
20 acceptedFamily.append(INTERFACES_FAMILY_INET6); 20 acceptedFamily.append(INTERFACES_FAMILY_INET6);
21 21
22 interfacesFile = useInterfacesFile; 22 interfacesFile = useInterfacesFile;
23 QFile file(interfacesFile); 23 QFile file(interfacesFile);
24 if (!file.open(IO_ReadOnly)){ 24 if (!file.open(IO_ReadOnly)){
25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); 25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
26 currentIface = interfaces.end(); 26 currentIface = interfaces.end();
27 currentMapping = interfaces.end(); 27 currentMapping = interfaces.end();
28 return; 28 return;
29 } 29 }
30 QTextStream stream( &file ); 30 QTextStream stream( &file );
31 QString line; 31 QString line;
32 while ( !stream.eof() ) { 32 while ( !stream.eof() ) {
33 line += stream.readLine(); 33 line += stream.readLine();
34 line += "\n"; 34 line += "\n";
35 } 35 }
36 file.close(); 36 file.close();
37 interfaces = QStringList::split("\n", line, true); 37 interfaces = QStringList::split("\n", line, true);
38 38
39 currentIface = interfaces.end(); 39 currentIface = interfaces.end();
40 currentMapping = interfaces.end(); 40 currentMapping = interfaces.end();
41} 41}
42 42
43 43
44/** 44/**
45 * Get a list of all interfaces in the interface file. Usefull for 45 * Get a list of all interfaces in the interface file. Usefull for
46 * hardware that is not currently connected such as an 802.11b card 46 * hardware that is not currently connected such as an 802.11b card
47 * not plugged in, but configured for when it is plugged in. 47 * not plugged in, but configured for when it is plugged in.
48 * @return Return string list of interfaces. 48 * @return Return string list of interfaces.
49 **/ 49 **/
50QStringList Interfaces::getInterfaceList(){ 50QStringList Interfaces::getInterfaceList(){
51 QStringList list; 51 QStringList list;
52 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 52 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
53 QString line = (*it).simplifyWhiteSpace(); 53 QString line = (*it).simplifyWhiteSpace();
54 if(line.contains(IFACE)){ 54 if(line.contains(IFACE) && line.at(0) != '#'){
55 line = line.mid(QString(IFACE).length() +1, line.length()); 55 line = line.mid(QString(IFACE).length() +1, line.length());
56 line = line.simplifyWhiteSpace(); 56 line = line.simplifyWhiteSpace();
57 int findSpace = line.find(" "); 57 int findSpace = line.find(" ");
58 if( findSpace >= 0){ 58 if( findSpace >= 0){
59 line = line.mid(0, findSpace); 59 line = line.mid(0, findSpace);
60 list.append(line); 60 list.append(line);
61 } 61 }
62 } 62 }
63 } 63 }
64 return list; 64 return list;
65} 65}
66 66
67/** 67/**
68 * Find out if interface is in an "auto" group or not. 68 * Find out if interface is in an "auto" group or not.
69 * Report any duplicates such as eth0 being in two differnt auto's 69 * Report any duplicates such as eth0 being in two differnt auto's
70 * @param interface interface to check to see if it is on or not. 70 * @param interface interface to check to see if it is on or not.
71 * @return true is interface is in auto 71 * @return true is interface is in auto
72 */ 72 */
73bool Interfaces::isAuto(QString interface){ 73bool Interfaces::isAuto(QString interface){
74 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 74 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
75 QStringList awi = autoLines.grep(QRegExp(interface)); 75 QStringList awi = autoLines.grep(QRegExp(interface));
76 if(awi.count() > 1) 76 if(awi.count() > 1)
77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
78 if(awi.count() < 1) 78 if(awi.count() < 1)
79 return false; 79 return false;
80 return true; 80 return true;
81} 81}
82 82
83/** 83/**
84 * Attempt to set the auto option for interface to setAuto. 84 * Attempt to set the auto option for interface to setAuto.
85 * @param interface the interface to set 85 * @param interface the interface to set
86 * @param setAuto the value to set interface to. 86 * @param setAuto the value to set interface to.
87 * @return false if already set to setAuto. 87 * @return false if already set to setAuto.
88 * */ 88 * */
89bool Interfaces::setAuto(QString interface, bool setAuto){ 89bool Interfaces::setAuto(QString interface, bool setAuto){
90 // Don't need to set it if it is already set. 90 // Don't need to set it if it is already set.
91 if(isAuto(interface) == setAuto) 91 if(isAuto(interface) == setAuto)
92 return false; 92 return false;
93 93
94 bool changed = false; 94 bool changed = false;
95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
96 if((*it).contains(AUTO)){ 96 if((*it).contains(AUTO)){
97 //We know that they are not in any group so let add to this auto. 97 //We know that they are not in any group so let add to this auto.
98 if(setAuto){ 98 if(setAuto){
99 (*it) = (*it) += " " + interface; 99 (*it) = (*it) += " " + interface;
100 // Don't care to have such thins as: auto eth0 lo usb0 100 // Don't care to have such thins as: auto eth0 lo usb0
101 (*it) = (*it).simplifyWhiteSpace(); 101 (*it) = (*it).simplifyWhiteSpace();
102 changed = true; 102 changed = true;
103 break; 103 break;
104 } 104 }
105 else{ 105 else{
106 if((*it).contains(interface)){ 106 if((*it).contains(interface)){
107 (*it) = (*it).replace(QRegExp(interface), ""); 107 (*it) = (*it).replace(QRegExp(interface), "");
108 // clean up 108 // clean up
109 QString line = (*it).simplifyWhiteSpace(); 109 QString line = (*it).simplifyWhiteSpace();
110 line = line.replace(QRegExp(" "),""); 110 line = line.replace(QRegExp(" "),"");
111 if(line == AUTO) 111 if(line == AUTO)
112 (*it) = ""; 112 (*it) = "";
113 changed = true; 113 changed = true;
114 // Don't break because we want to make sure we remove all cases. 114 // Don't break because we want to make sure we remove all cases.
115 } 115 }
116 } 116 }
117 } 117 }
118 } 118 }
119 if(changed == false){ 119 if(changed == false){
120 if(setAuto == true) 120 if(setAuto == true)
121 interfaces.append(QString(AUTO" %1").arg(interface)); 121 interfaces.append(QString(AUTO" %1").arg(interface));
122 else{ 122 else{
123 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1()); 123 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1());
124 } 124 }
125 } 125 }
126 return true; 126 return true;
127} 127}
128 128
129/** 129/**
130 * Set the current interface to interface. This needs to be done before you 130 * Set the current interface to interface. This needs to be done before you
131 * can call getFamily(), getMethod, and get/setOption(). 131 * can call getFamily(), getMethod, and get/setOption().
132 * @param interface the name of the interface to set. All whitespace is 132 * @param interface the name of the interface to set. All whitespace is
133 * removed from the interface name. 133 * removed from the interface name.
134 * @return bool true if it is successfull. 134 * @return bool true if it is successfull.
135 */ 135 */
136bool Interfaces::setInterface(QString interface){ 136bool Interfaces::setInterface(QString interface){
137 interface = interface.simplifyWhiteSpace(); 137 interface = interface.simplifyWhiteSpace();
138 interface = interface.replace(QRegExp(" "), ""); 138 interface = interface.replace(QRegExp(" "), "");
139 return setStanza(IFACE, interface, currentIface); 139 return setStanza(IFACE, interface, currentIface);
140} 140}
141 141
142/** 142/**
143 * A quick helper funtion to see if the current interface is set. 143 * A quick helper funtion to see if the current interface is set.
144 * @return bool true if set, false otherwise. 144 * @return bool true if set, false otherwise.
145 */ 145 */
146bool Interfaces::isInterfaceSet(){ 146bool Interfaces::isInterfaceSet(){
147 return (currentIface != interfaces.end()); 147 return (currentIface != interfaces.end());
148} 148}
149 149
150/** 150/**
@@ -364,275 +364,275 @@ bool Interfaces::removeAllInterfaceOptions(){
364 return removeAllOptions(currentIface); 364 return removeAllOptions(currentIface);
365} 365}
366 366
367/** 367/**
368 * Set the current map to interface's map. This needs to be done before you 368 * Set the current map to interface's map. This needs to be done before you
369 * can call addMapping(), set/getMap(), and get/setScript(). 369 * can call addMapping(), set/getMap(), and get/setScript().
370 * @param interface the name of the interface to set. All whitespace is 370 * @param interface the name of the interface to set. All whitespace is
371 * removed from the interface name. 371 * removed from the interface name.
372 * @return bool true if it is successfull. 372 * @return bool true if it is successfull.
373 */ 373 */
374bool Interfaces::setMapping(QString interface){ 374bool Interfaces::setMapping(QString interface){
375 interface = interface.simplifyWhiteSpace(); 375 interface = interface.simplifyWhiteSpace();
376 interface = interface.replace(QRegExp(" "), ""); 376 interface = interface.replace(QRegExp(" "), "");
377 return setStanza(MAPPING, interface, currentMapping); 377 return setStanza(MAPPING, interface, currentMapping);
378} 378}
379 379
380/** 380/**
381 * Adds a new Mapping to the interfaces file with interfaces. 381 * Adds a new Mapping to the interfaces file with interfaces.
382 * @param interface the name(s) of the interfaces to set to this mapping 382 * @param interface the name(s) of the interfaces to set to this mapping
383 */ 383 */
384void Interfaces::addMapping(QString option){ 384void Interfaces::addMapping(QString option){
385 interfaces.append(""); 385 interfaces.append("");
386 interfaces.append(QString(MAPPING " %1").arg(option)); 386 interfaces.append(QString(MAPPING " %1").arg(option));
387} 387}
388 388
389/** 389/**
390 * Remove the currently selected map and all of its options. 390 * Remove the currently selected map and all of its options.
391 * @return bool if successfull or not. 391 * @return bool if successfull or not.
392 */ 392 */
393bool Interfaces::removeMapping(){ 393bool Interfaces::removeMapping(){
394 if(currentMapping == interfaces.end()) 394 if(currentMapping == interfaces.end())
395 return false; 395 return false;
396 (*currentMapping) = ""; 396 (*currentMapping) = "";
397 return removeAllOptions(currentMapping); 397 return removeAllOptions(currentMapping);
398} 398}
399 399
400/** 400/**
401 * Set a map option within a mapping. 401 * Set a map option within a mapping.
402 * @param map map to use 402 * @param map map to use
403 * @param value value to go with map 403 * @param value value to go with map
404 * @return bool true if it is successfull. 404 * @return bool true if it is successfull.
405 */ 405 */
406bool Interfaces::setMap(QString map, QString value){ 406bool Interfaces::setMap(QString map, QString value){
407 return setOption(currentMapping, map, value); 407 return setOption(currentMapping, map, value);
408} 408}
409 409
410/** 410/**
411 * Removes a map option within a mapping. 411 * Removes a map option within a mapping.
412 * @param map map to use 412 * @param map map to use
413 * @param value value to go with map 413 * @param value value to go with map
414 * @return bool true if it is successfull. 414 * @return bool true if it is successfull.
415 */ 415 */
416bool Interfaces::removeMap(QString map, QString value){ 416bool Interfaces::removeMap(QString map, QString value){
417 return removeOption(currentMapping, map, value); 417 return removeOption(currentMapping, map, value);
418} 418}
419 419
420/** 420/**
421 * Get a map value within a mapping. 421 * Get a map value within a mapping.
422 * @param map map to get value of 422 * @param map map to get value of
423 * @param bool true if it is successfull. 423 * @param bool true if it is successfull.
424 * @return value that goes to the map 424 * @return value that goes to the map
425 */ 425 */
426QString Interfaces::getMap(QString map, bool &error){ 426QString Interfaces::getMap(QString map, bool &error){
427 return getOption(currentMapping, map, error); 427 return getOption(currentMapping, map, error);
428} 428}
429 429
430/** 430/**
431 * Sets a script value of the current mapping to argument. 431 * Sets a script value of the current mapping to argument.
432 * @param argument the script name. 432 * @param argument the script name.
433 * @return true if successfull. 433 * @return true if successfull.
434 */ 434 */
435bool Interfaces::setScript(QString argument){ 435bool Interfaces::setScript(QString argument){
436 return setOption(currentMapping, "script", argument); 436 return setOption(currentMapping, "script", argument);
437} 437}
438 438
439/** 439/**
440 * @param error true if could not retrieve the current script argument. 440 * @param error true if could not retrieve the current script argument.
441 * @return QString the argument of the script for the current mapping. 441 * @return QString the argument of the script for the current mapping.
442 */ 442 */
443QString Interfaces::getScript(bool &error){ 443QString Interfaces::getScript(bool &error){
444 return getOption(currentMapping, "script", error); 444 return getOption(currentMapping, "script", error);
445} 445}
446 446
447/** 447/**
448 * Helper function used to parse through the QStringList and put pointers in 448 * Helper function used to parse through the QStringList and put pointers in
449 * the correct place. 449 * the correct place.
450 * @param stanza The stanza (auto, iface, mapping) to look for. 450 * @param stanza The stanza (auto, iface, mapping) to look for.
451 * @param option string that must be in the stanza's main line. 451 * @param option string that must be in the stanza's main line.
452 * @param interator interator to place at location of stanza if successfull. 452 * @param interator interator to place at location of stanza if successfull.
453 * @return bool true if the stanza is found. 453 * @return bool true if the stanza is found.
454 */ 454 */
455bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ 455bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){
456 bool found = false; 456 bool found = false;
457 iterator = interfaces.end(); 457 iterator = interfaces.end();
458 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 458 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
459 QString line = (*it).simplifyWhiteSpace(); 459 QString line = (*it).simplifyWhiteSpace();
460 if(line.contains(stanza) && line.contains(option)){ 460 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
461 uint point = line.find(option); 461 uint point = line.find(option);
462 bool valid = true; 462 bool valid = true;
463 if(point > 0){ 463 if(point > 0){
464 // There are more chars in the line. check +1 464 // There are more chars in the line. check +1
465 if(line.at(point-1) != ' ') 465 if(line.at(point-1) != ' ')
466 valid = false; 466 valid = false;
467 } 467 }
468 point += option.length(); 468 point += option.length();
469 if(point < line.length()-1){ 469 if(point < line.length()-1){
470 // There are more chars in the line. check -1 470 // There are more chars in the line. check -1
471 if(line.at(point) != ' ') 471 if(line.at(point) != ' ')
472 valid = false; 472 valid = false;
473 } 473 }
474 if(valid){ 474 if(valid){
475 if(found == true){ 475 if(found == true){
476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
477 } 477 }
478 found = true; 478 found = true;
479 iterator = it; 479 iterator = it;
480 } 480 }
481 } 481 }
482 } 482 }
483 return found; 483 return found;
484} 484}
485 485
486/** 486/**
487 * Sets a value of an option in a stanza 487 * Sets a value of an option in a stanza
488 * @param start the start of the stanza 488 * @param start the start of the stanza
489 * @param option the option to use when setting value. 489 * @param option the option to use when setting value.
490 * @return bool true if successfull, false otherwise. 490 * @return bool true if successfull, false otherwise.
491 */ 491 */
492bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ 492bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){
493 if(start == interfaces.end()) 493 if(start == interfaces.end())
494 return false; 494 return false;
495 495
496 bool found = false; 496 bool found = false;
497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
499 if(!found && value != ""){ 499 if(!found && value != ""){
500 // Got to the end of the stanza without finding it, so append it. 500 // Got to the end of the stanza without finding it, so append it.
501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
502 } 502 }
503 found = true; 503 found = true;
504 break; 504 break;
505 } 505 }
506 if((*it).contains(option) && it != start){ 506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
507 // Found it in stanza so replace it. 507 // Found it in stanza so replace it.
508 if(found) 508 if(found)
509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
510 found = true; 510 found = true;
511 (*it) = QString("\t%1 %2").arg(option).arg(value); 511 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 } 512 }
513 } 513 }
514 if(!found){ 514 if(!found){
515 QStringList::Iterator p = start; 515 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true; 517 found = true;
518 } 518 }
519 return found; 519 return found;
520} 520}
521/** 521/**
522 * Removes a option in a stanza 522 * Removes a option in a stanza
523 * @param start the start of the stanza 523 * @param start the start of the stanza
524 * @param option the option to use when setting value. 524 * @param option the option to use when setting value.
525 * @return bool true if successfull, false otherwise. 525 * @return bool true if successfull, false otherwise.
526 */ 526 */
527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ 527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){
528 if(start == interfaces.end()) 528 if(start == interfaces.end())
529 return false; 529 return false;
530 530
531 bool found = false; 531 bool found = false;
532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
534 // got to the end without finding it 534 // got to the end without finding it
535 break; 535 break;
536 } 536 }
537 if((*it).contains(option) && (*it).contains(value) &&it != start){ 537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
538 // Found it in stanza so replace it. 538 // Found it in stanza so replace it.
539 if(found) 539 if(found)
540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
541 found = true; 541 found = true;
542 (*it) = ""; 542 (*it) = "";
543 } 543 }
544 } 544 }
545 return found; 545 return found;
546} 546}
547 547
548/** 548/**
549 * Removes all options in a stanza 549 * Removes all options in a stanza
550 * @param start the start of the stanza 550 * @param start the start of the stanza
551 * @return bool true if successfull, false otherwise. 551 * @return bool true if successfull, false otherwise.
552 */ 552 */
553bool Interfaces::removeAllOptions(QStringList::Iterator start){ 553bool Interfaces::removeAllOptions(QStringList::Iterator start){
554 if(start == interfaces.end()) 554 if(start == interfaces.end())
555 return false; 555 return false;
556 556
557 QStringList::Iterator it = start; 557 QStringList::Iterator it = start;
558 it = ++it; 558 it = ++it;
559 for (it; it != interfaces.end(); ++it ) { 559 for (it; it != interfaces.end(); ++it ) {
560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
561 break; 561 break;
562 } 562 }
563 it = interfaces.remove(it); 563 it = interfaces.remove(it);
564 it = --it; 564 it = --it;
565 } 565 }
566 // Leave a space between this interface and the next. 566 // Leave a space between this interface and the next.
567 interfaces.insert(it, QString("")); 567 interfaces.insert(it, QString(""));
568 return true; 568 return true;
569} 569}
570 570
571/** 571/**
572 * Gets a value of an option in a stanza 572 * Gets a value of an option in a stanza
573 * @param start the start of the stanza 573 * @param start the start of the stanza
574 * @param option the option to use when getting the value. 574 * @param option the option to use when getting the value.
575 * @param bool true if errors false otherwise. 575 * @param bool true if errors false otherwise.
576 * @return QString the value of option QString::null() if error == true. 576 * @return QString the value of option QString::null() if error == true.
577 */ 577 */
578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ 578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){
579 if(start == interfaces.end()){ 579 if(start == interfaces.end()){
580 error = false; 580 error = false;
581 return QString(); 581 return QString();
582 } 582 }
583 583
584 QString value; 584 QString value;
585 bool found = false; 585 bool found = false;
586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
588 break; 588 break;
589 } 589 }
590 if((*it).contains(option)){ 590 if((*it).contains(option) && (*it).at(0) != '#'){
591 if(found) 591 if(found)
592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); 592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
593 found = true; 593 found = true;
594 QString line = (*it).simplifyWhiteSpace(); 594 QString line = (*it).simplifyWhiteSpace();
595 int space = line.find(" ", option.length()); 595 int space = line.find(" ", option.length());
596 if(space != -1) 596 if(space != -1)
597 value = line.mid(space+1, line.length()); 597 value = line.mid(space+1, line.length());
598 else 598 else
599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); 599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1());
600 } 600 }
601 } 601 }
602 error = !found; 602 error = !found;
603 return value; 603 return value;
604} 604}
605 605
606/** 606/**
607 * Write out the interfaces file to the file passed into the constructor. 607 * Write out the interfaces file to the file passed into the constructor.
608 * Removes any excess blank lines over 1 line long. 608 * Removes any excess blank lines over 1 line long.
609 * @return bool true if successfull, false if not. 609 * @return bool true if successfull, false if not.
610 */ 610 */
611bool Interfaces::write(){ 611bool Interfaces::write(){
612 QFile::remove(interfacesFile); 612 QFile::remove(interfacesFile);
613 QFile file(interfacesFile); 613 QFile file(interfacesFile);
614 614
615 if (!file.open(IO_ReadWrite)){ 615 if (!file.open(IO_ReadWrite)){
616 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); 616 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
617 return false; 617 return false;
618 } 618 }
619 QTextStream stream( &file ); 619 QTextStream stream( &file );
620 int whiteSpaceCount = 0; 620 int whiteSpaceCount = 0;
621 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 621 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
622 QString line = (*it).simplifyWhiteSpace(); 622 QString line = (*it).simplifyWhiteSpace();
623 line = line.replace(QRegExp(" "),""); 623 line = line.replace(QRegExp(" "),"");
624 if(line.length() == 0) 624 if(line.length() == 0)
625 whiteSpaceCount++; 625 whiteSpaceCount++;
626 else 626 else
627 whiteSpaceCount = 0; 627 whiteSpaceCount = 0;
628 if(whiteSpaceCount < 2){ 628 if(whiteSpaceCount < 2){
629 qDebug((*it).latin1()); 629 qDebug((*it).latin1());
630 stream << (*it) << '\n'; 630 stream << (*it) << '\n';
631 } 631 }
632 } 632 }
633 file.close(); 633 file.close();
634 return true; 634 return true;
635} 635}
636 636
637// interfaces.cpp 637// interfaces.cpp
638 638
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 01063c2..8e4e898 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -139,239 +139,239 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
139 return NULL; 139 return NULL;
140 } 140 }
141 141
142 // Store for deletion later 142 // Store for deletion later
143 libraries.insert(object, lib); 143 libraries.insert(object, lib);
144 return object; 144 return object;
145} 145}
146 146
147/** 147/**
148 * The Add button was clicked. Bring up the add dialog and if OK is hit 148 * The Add button was clicked. Bring up the add dialog and if OK is hit
149 * load the plugin and append it to the list 149 * load the plugin and append it to the list
150 */ 150 */
151void MainWindowImp::addClicked(){ 151void MainWindowImp::addClicked(){
152 QMap<Module*, QLibrary*>::Iterator it; 152 QMap<Module*, QLibrary*>::Iterator it;
153 QMap<QString, QString> list; 153 QMap<QString, QString> list;
154 QMap<QString, Module*> newInterfaceOwners; 154 QMap<QString, Module*> newInterfaceOwners;
155 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 155 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
156 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 156 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
157 for( it = libraries.begin(); it != libraries.end(); ++it ){ 157 for( it = libraries.begin(); it != libraries.end(); ++it ){
158 if(it.key()){ 158 if(it.key()){
159 (it.key())->possibleNewInterfaces(list); 159 (it.key())->possibleNewInterfaces(list);
160 } 160 }
161 } 161 }
162 // See if the list has anything that we can add. 162 // See if the list has anything that we can add.
163 if(list.count() == 0){ 163 if(list.count() == 0){
164 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 164 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
165 return; 165 return;
166 } 166 }
167 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 167 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
168 addNewConnection.addConnections(list); 168 addNewConnection.addConnections(list);
169 addNewConnection.showMaximized(); 169 addNewConnection.showMaximized();
170 if(QDialog::Accepted == addNewConnection.exec()){ 170 if(QDialog::Accepted == addNewConnection.exec()){
171 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 171 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
172 if(!item) 172 if(!item)
173 return; 173 return;
174 174
175 for( it = libraries.begin(); it != libraries.end(); ++it ){ 175 for( it = libraries.begin(); it != libraries.end(); ++it ){
176 if(it.key()){ 176 if(it.key()){
177 Interface *i = (it.key())->addNewInterface(item->text(0)); 177 Interface *i = (it.key())->addNewInterface(item->text(0));
178 if(i){ 178 if(i){
179 interfaceNames.insert(i->getInterfaceName(), i); 179 interfaceNames.insert(i->getInterfaceName(), i);
180 updateInterface(i); 180 updateInterface(i);
181 } 181 }
182 } 182 }
183 } 183 }
184 } 184 }
185} 185}
186 186
187/** 187/**
188 * Prompt the user to see if they really want to do this. 188 * Prompt the user to see if they really want to do this.
189 * If they do then remove from the list and unload. 189 * If they do then remove from the list and unload.
190 */ 190 */
191void MainWindowImp::removeClicked(){ 191void MainWindowImp::removeClicked(){
192 QListViewItem *item = connectionList->currentItem(); 192 QListViewItem *item = connectionList->currentItem();
193 if(!item) { 193 if(!item) {
194 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); 194 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
195 return; 195 return;
196 } 196 }
197 197
198 Interface *i = interfaceItems[item]; 198 Interface *i = interfaceItems[item];
199 if(i->getModuleOwner() == NULL){ 199 if(i->getModuleOwner() == NULL){
200 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 200 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
201 } 201 }
202 else{ 202 else{
203 if(!i->getModuleOwner()->remove(i)) 203 if(!i->getModuleOwner()->remove(i))
204 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 204 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
205 else{ 205 else{
206 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 206 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
207 // TODO memory managment.... 207 // TODO memory managment....
208 // who deletes the interface? 208 // who deletes the interface?
209 } 209 }
210 } 210 }
211} 211}
212 212
213/** 213/**
214 * Pull up the configure about the currently selected interface. 214 * Pull up the configure about the currently selected interface.
215 * Report an error if no interface is selected. 215 * Report an error if no interface is selected.
216 * If the interface has a module owner then request its configure with a empty 216 * If the interface has a module owner then request its configure with a empty
217 * tab. If tab is !NULL then append the interfaces setup widget to it. 217 * tab. If tab is !NULL then append the interfaces setup widget to it.
218 */ 218 */
219void MainWindowImp::configureClicked(){ 219void MainWindowImp::configureClicked(){
220 QListViewItem *item = connectionList->currentItem(); 220 QListViewItem *item = connectionList->currentItem();
221 if(!item){ 221 if(!item){
222 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 222 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
223 return; 223 return;
224 } 224 }
225 225
226 QString currentProfile = currentProfileLabel->text(); 226 QString currentProfile = currentProfileLabel->text();
227 if(profilesList->count() <= 1 || currentProfile == "All"){ 227 if(profilesList->count() <= 1 || currentProfile == "All"){
228 currentProfile = ""; 228 currentProfile = "";
229 } 229 }
230 230
231 Interface *i = interfaceItems[item]; 231 Interface *i = interfaceItems[item];
232 if(i->getModuleOwner()){ 232 if(i->getModuleOwner()){
233 i->getModuleOwner()->setProfile(currentProfile); 233 i->getModuleOwner()->setProfile(currentProfile);
234 QTabWidget *tabWidget = NULL; 234 QTabWidget *tabWidget = NULL;
235 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 235 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
236 if(moduleConfigure != NULL){ 236 if(moduleConfigure != NULL){
237 if(tabWidget != NULL){ 237 if(tabWidget != NULL){
238 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 238 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
239 configure->setProfile(currentProfile); 239 configure->setProfile(currentProfile);
240 tabWidget->insertTab(configure, "TCP/IP"); 240 tabWidget->insertTab(configure, "TCP/IP");
241 241
242 } 242 }
243 moduleConfigure->showMaximized(); 243 moduleConfigure->showMaximized();
244 moduleConfigure->show(); 244 moduleConfigure->show();
245 return; 245 return;
246 } 246 }
247 } 247 }
248 248
249 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 249 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
250 configure->setProfile(currentProfile); 250 configure->setProfile(currentProfile);
251 configure->showMaximized(); 251 configure->showMaximized();
252 configure->show(); 252 configure->show();
253} 253}
254 254
255/** 255/**
256 * Pull up the information about the currently selected interface. 256 * Pull up the information about the currently selected interface.
257 * Report an error if no interface is selected. 257 * Report an error if no interface is selected.
258 * If the interface has a module owner then request its configure with a empty 258 * If the interface has a module owner then request its configure with a empty
259 * tab. If tab is !NULL then append the interfaces setup widget to it. 259 * tab. If tab is !NULL then append the interfaces setup widget to it.
260 */ 260 */
261void MainWindowImp::informationClicked(){ 261void MainWindowImp::informationClicked(){
262 QListViewItem *item = connectionList->currentItem(); 262 QListViewItem *item = connectionList->currentItem();
263 if(!item){ 263 if(!item){
264 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 264 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
265 return; 265 return;
266 } 266 }
267 267
268 Interface *i = interfaceItems[item]; 268 Interface *i = interfaceItems[item];
269 if(!i->isAttached()){ 269 if(!i->isAttached()){
270 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); 270 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
271 return; 271 return;
272 } 272 }
273 273
274 QStringList list; 274 QStringList list;
275 for(uint i = 0; i < profilesList->count(); i++){ 275 for(uint i = 0; i < profilesList->count(); i++){
276 list.append(profilesList->text(i)); 276 list.append(profilesList->text(i));
277 } 277 }
278 278
279 if(i->getModuleOwner()){ 279 if(i->getModuleOwner()){
280 QTabWidget *tabWidget = NULL; 280 QTabWidget *tabWidget = NULL;
281 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 281 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
282 if(moduleInformation != NULL){ 282 if(moduleInformation != NULL){
283 if(tabWidget != NULL){ 283 if(tabWidget != NULL){
284 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 284 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
285 tabWidget->insertTab(information, "TCP/IP"); 285 tabWidget->insertTab(information, "TCP/IP");
286 } 286 }
287 moduleInformation->showMaximized(); 287 moduleInformation->showMaximized();
288 moduleInformation->show(); 288 moduleInformation->show();
289 return; 289 return;
290 } 290 }
291 } 291 }
292 292
293 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 293 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
294 information->showMaximized(); 294 information->showMaximized();
295 information->show(); 295 information->show();
296} 296}
297 297
298/** 298/**
299 * Aquire the list of active interfaces from ifconfig 299 * Aquire the list of active interfaces from ifconfig
300 * Call ifconfig and ifconfig -a 300 * Call ifconfig and ifconfig -a
301 */ 301 */
302void MainWindowImp::getInterfaceList(){ 302void MainWindowImp::getInterfaceList(){
303 KShellProcess *processAll = new KShellProcess(); 303 KShellProcess *processAll = new KShellProcess();
304 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 304 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
305 connect(processAll, SIGNAL(processExited(KProcess *)), 305 connect(processAll, SIGNAL(processExited(KProcess *)),
306 this, SLOT(jobDone(KProcess *))); 306 this, SLOT(jobDone(KProcess *)));
307 threads.insert(processAll, TEMP_ALL); 307 threads.insert(processAll, TEMP_ALL);
308 308
309 KShellProcess *process = new KShellProcess(); 309 KShellProcess *process = new KShellProcess();
310 *process << "/sbin/ifconfig" << " > " TEMP_UP; 310 *process << "/sbin/ifconfig" << " > " TEMP_UP;
311 connect(process, SIGNAL(processExited(KProcess *)), 311 connect(process, SIGNAL(processExited(KProcess *)),
312 this, SLOT(jobDone(KProcess *))); 312 this, SLOT(jobDone(KProcess *)));
313 threads.insert(process, TEMP_UP); 313 threads.insert(process, TEMP_UP);
314 314
315 processAll->start(KShellProcess::NotifyOnExit); 315 processAll->start(KShellProcess::NotifyOnExit);
316 process->start(KShellProcess::NotifyOnExit); 316 process->start(KShellProcess::NotifyOnExit);
317} 317}
318 318
319void MainWindowImp::jobDone(KProcess *process){ 319void MainWindowImp::jobDone(KProcess *process){
320 QString fileName = threads[process]; 320 QString fileName = threads[process];
321 threads.remove(process); 321 threads.remove(process);
322 delete process; 322 delete process;
323 323
324 QFile file(fileName); 324 QFile file(fileName);
325 if (!file.open(IO_ReadOnly)){ 325 if (!file.open(IO_ReadOnly)){
326 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 326 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
327 return; 327 return;
328 } 328 }
329 329
330 QTextStream stream( &file ); 330 QTextStream stream( &file );
331 QString line; 331 QString line;
332 while ( !stream.eof() ) { 332 while ( !stream.eof() ) {
333 line = stream.readLine(); 333 line = stream.readLine();
334 int space = line.find(" "); 334 int space = line.find(" ");
335 if(space > 1){ 335 if(space > 1){
336 // We have found an interface 336 // We have found an interface
337 QString interfaceName = line.mid(0, space); 337 QString interfaceName = line.mid(0, space);
338 Interface *i; 338 Interface *i;
339 // We have found an interface 339 // We have found an interface
340 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 340 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
341 // See if we already have it 341 // See if we already have it
342 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 342 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
343 if(fileName == TEMP_ALL) 343 if(fileName == TEMP_ALL)
344 i = new Interface(this, interfaceName, false); 344 i = new Interface(this, interfaceName, false);
345 else 345 else
346 i = new Interface(this, interfaceName, true); 346 i = new Interface(this, interfaceName, true);
347 i->setAttached(true); 347 i->setAttached(true);
348 348
349 QString hardName = "Ethernet"; 349 QString hardName = "Ethernet";
350 int hardwareName = line.find("Link encap:"); 350 int hardwareName = line.find("Link encap:");
351 int macAddress = line.find("HWaddr"); 351 int macAddress = line.find("HWaddr");
352 if(macAddress == -1) 352 if(macAddress == -1)
353 macAddress = line.length(); 353 macAddress = line.length();
354 if(hardwareName != -1) 354 if(hardwareName != -1)
355 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); 355 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
356 356
357 interfaceNames.insert(i->getInterfaceName(), i); 357 interfaceNames.insert(i->getInterfaceName(), i);
358 updateInterface(i); 358 updateInterface(i);
359 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 359 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
360 } 360 }
361 // It was an interface we already had. 361 // It was an interface we already had.
362 else{ 362 else{
363 if(fileName != TEMP_ALL) 363 if(fileName != TEMP_ALL)
364 (interfaceNames[interfaceName])->setStatus(true); 364 (interfaceNames[interfaceName])->setStatus(true);
365 } 365 }
366 } 366 }
367 } 367 }
368 file.close(); 368 file.close();
369 QFile::remove(fileName); 369 QFile::remove(fileName);
370 370
371 if(threads.count() == 0){ 371 if(threads.count() == 0){
372 Interfaces i; 372 Interfaces i;
373 QStringList list = i.getInterfaceList(); 373 QStringList list = i.getInterfaceList();
374 QMap<QString, Interface*>::Iterator it; 374 QMap<QString, Interface*>::Iterator it;
375 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 375 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
376 bool found = false; 376 bool found = false;
377 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 377 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
diff --git a/noncore/net/networksetup/module.h b/noncore/net/networksetup/module.h
index a30f492..96db5b3 100644
--- a/noncore/net/networksetup/module.h
+++ b/noncore/net/networksetup/module.h
@@ -1,86 +1,88 @@
1#ifndef NETCONF_MODULE_H 1#ifndef NETCONF_MODULE_H
2#define NETCONF_MODULE_H 2#define NETCONF_MODULE_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <qmap.h> 6#include <qmap.h>
7#include "interface.h" 7#include "interface.h"
8 8
9class QWidget; 9class QWidget;
10class QTabWidget; 10class QTabWidget;
11 11
12class Module : QObject{ 12class Module : QObject{
13 13
14signals: 14signals:
15 void updateInterface(Interface *i); 15 void updateInterface(Interface *i);
16 16
17public: 17public:
18 Module(){}; 18 Module(){};
19 19
20 /** 20 /**
21 * The current profile has been changed and the module should do any 21 * The current profile has been changed and the module should do any
22 * neccesary changes also. 22 * neccesary changes also.
23 * @param newProfile what the profile should be changed to. 23 * @param newProfile what the profile should be changed to.
24 */ 24 */
25 virtual void setProfile(QString newProfile) = 0; 25 virtual void setProfile(QString newProfile) = 0;
26 26
27 /** 27 /**
28 * get the icon name for this device. 28 * get the icon name for this device.
29 * @param Interface* can be used in determining the icon. 29 * @param Interface* can be used in determining the icon.
30 * @return QString the icon name (minus .png, .gif etc) 30 * @return QString the icon name (minus .png, .gif etc)
31 */ 31 */
32 virtual QString getPixmapName(Interface* i) = 0; 32 virtual QString getPixmapName(Interface *) = 0;
33 33
34 /** 34 /**
35 * Check to see if the interface i is owned by this module. 35 * Check to see if the interface i is owned by this module.
36 * @param Interface* interface to check against 36 * @param Interface* interface to check against
37 * @return bool true if i is owned by this module, false otherwise. 37 * @return bool true if i is owned by this module, false otherwise.
38 */ 38 */
39 virtual bool isOwner(Interface *){ return false; }; 39 virtual bool isOwner(Interface *){ return false; };
40 40
41 /** 41 /**
42 * Create, set tabWiget and return the WLANConfigure Module 42 * Create, set tabWiget and return the WLANConfigure Module
43 * @param Interface *i the interface to configure.
43 * @param tabWidget a pointer to the tab widget that this configure has. 44 * @param tabWidget a pointer to the tab widget that this configure has.
44 * @return QWidget* pointer to the tab widget in this modules configure. 45 * @return QWidget* pointer to the tab widget in this modules configure.
45 */ 46 */
46 virtual QWidget *configure(QTabWidget **){ return NULL; } ; 47 virtual QWidget *configure(Interface *, QTabWidget **){ return NULL; } ;
47 48
48 /** 49 /**
49 * Create, set tabWiget and return the Information Module 50 * Create, set tabWiget and return the Information Module
51 * @param Interface *i the interface to get info on.
50 * @param tabWidget a pointer to the tab widget that this information has. 52 * @param tabWidget a pointer to the tab widget that this information has.
51 * @return QWidget* pointer to the tab widget in this modules info. 53 * @return QWidget* pointer to the tab widget in this modules info.
52 */ 54 */
53 virtual QWidget *information(QTabWidget **){ return NULL; }; 55 virtual QWidget *information(Interface *, QTabWidget **){ return NULL; };
54 56
55 /** 57 /**
56 * Get all active (up or down) interfaces 58 * Get all active (up or down) interfaces
57 * @return QList<Interface> A list of interfaces that exsist that havn't 59 * @return QList<Interface> A list of interfaces that exsist that havn't
58 * been called by isOwner() 60 * been called by isOwner()
59 */ 61 */
60 virtual QList<Interface> getInterfaces() = 0; 62 virtual QList<Interface> getInterfaces() = 0;
61 63
62 /** 64 /**
63 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), 65 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
64 * modem ppp) 66 * modem ppp)
65 */ 67 */
66 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; 68 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
67 69
68 /** 70 /**
69 * Attempts to create a new interface from name 71 * Attempts to create a new interface from name
70 * @return Interface* NULL if it was unable to be created. 72 * @return Interface* NULL if it was unable to be created.
71 * @param name the type of interface to create 73 * @param name the type of interface to create
72 */ 74 */
73 virtual Interface *addNewInterface(QString name) = 0; 75 virtual Interface *addNewInterface(QString name) = 0;
74 76
75 /** 77 /**
76 * Attempts to remove the interface, doesn't delete i 78 * Attempts to remove the interface, doesn't delete i
77 * @return bool true if successfull, false otherwise. 79 * @return bool true if successfull, false otherwise.
78 */ 80 */
79 virtual bool remove(Interface* i) = 0; 81 virtual bool remove(Interface* i) = 0;
80 82
81}; 83};
82 84
83#endif 85#endif
84 86
85// module.h 87// module.h
86 88
diff --git a/noncore/settings/networksettings/interfaceinformation.ui b/noncore/settings/networksettings/interfaceinformation.ui
index fc99fce..2838d19 100644
--- a/noncore/settings/networksettings/interfaceinformation.ui
+++ b/noncore/settings/networksettings/interfaceinformation.ui
@@ -1,183 +1,183 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>InterfaceInformation</class> 2<class>InterfaceInformation</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>InterfaceInformation</cstring> 7 <cstring>InterfaceInformation</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>219</width> 14 <width>219</width>
15 <height>255</height> 15 <height>255</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Interface Information</string> 20 <string>Interface Information</string>
21 </property> 21 </property>
22 <grid> 22 <grid>
23 <property stdset="1"> 23 <property stdset="1">
24 <name>margin</name> 24 <name>margin</name>
25 <number>11</number> 25 <number>11</number>
26 </property> 26 </property>
27 <property stdset="1"> 27 <property stdset="1">
28 <name>spacing</name> 28 <name>spacing</name>
29 <number>6</number> 29 <number>6</number>
30 </property> 30 </property>
31 <widget row="4" column="0" rowspan="1" colspan="2" > 31 <widget row="4" column="0" rowspan="1" colspan="2" >
32 <class>QLayoutWidget</class> 32 <class>QLayoutWidget</class>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>name</name> 34 <name>name</name>
35 <cstring>Layout1</cstring> 35 <cstring>Layout1</cstring>
36 </property> 36 </property>
37 <grid> 37 <grid>
38 <property stdset="1"> 38 <property stdset="1">
39 <name>margin</name> 39 <name>margin</name>
40 <number>0</number> 40 <number>0</number>
41 </property> 41 </property>
42 <property stdset="1"> 42 <property stdset="1">
43 <name>spacing</name> 43 <name>spacing</name>
44 <number>6</number> 44 <number>6</number>
45 </property> 45 </property>
46 <widget row="1" column="0" > 46 <widget row="1" column="0" >
47 <class>QPushButton</class> 47 <class>QPushButton</class>
48 <property stdset="1"> 48 <property stdset="1">
49 <name>name</name> 49 <name>name</name>
50 <cstring>refreshButton</cstring> 50 <cstring>refreshButton</cstring>
51 </property> 51 </property>
52 <property stdset="1"> 52 <property stdset="1">
53 <name>text</name> 53 <name>text</name>
54 <string>Refresh</string> 54 <string>&amp;Refresh</string>
55 </property> 55 </property>
56 </widget> 56 </widget>
57 <widget row="0" column="1" > 57 <widget row="0" column="1" >
58 <class>QPushButton</class> 58 <class>QPushButton</class>
59 <property stdset="1"> 59 <property stdset="1">
60 <name>name</name> 60 <name>name</name>
61 <cstring>stopButton</cstring> 61 <cstring>stopButton</cstring>
62 </property> 62 </property>
63 <property stdset="1"> 63 <property stdset="1">
64 <name>text</name> 64 <name>text</name>
65 <string>Stop</string> 65 <string>S&amp;top</string>
66 </property> 66 </property>
67 </widget> 67 </widget>
68 <widget row="1" column="1" > 68 <widget row="1" column="1" >
69 <class>QPushButton</class> 69 <class>QPushButton</class>
70 <property stdset="1"> 70 <property stdset="1">
71 <name>name</name> 71 <name>name</name>
72 <cstring>restartButton</cstring> 72 <cstring>restartButton</cstring>
73 </property> 73 </property>
74 <property stdset="1"> 74 <property stdset="1">
75 <name>text</name> 75 <name>text</name>
76 <string>Restart</string> 76 <string>R&amp;estart</string>
77 </property> 77 </property>
78 </widget> 78 </widget>
79 <widget row="0" column="0" > 79 <widget row="0" column="0" >
80 <class>QPushButton</class> 80 <class>QPushButton</class>
81 <property stdset="1"> 81 <property stdset="1">
82 <name>name</name> 82 <name>name</name>
83 <cstring>startButton</cstring> 83 <cstring>startButton</cstring>
84 </property> 84 </property>
85 <property stdset="1"> 85 <property stdset="1">
86 <name>text</name> 86 <name>text</name>
87 <string>Start</string> 87 <string>&amp;Start</string>
88 </property> 88 </property>
89 </widget> 89 </widget>
90 </grid> 90 </grid>
91 </widget> 91 </widget>
92 <widget row="0" column="0" > 92 <widget row="0" column="0" >
93 <class>Line</class> 93 <class>Line</class>
94 <property stdset="1"> 94 <property stdset="1">
95 <name>name</name> 95 <name>name</name>
96 <cstring>Line1</cstring> 96 <cstring>Line1</cstring>
97 </property> 97 </property>
98 <property stdset="1"> 98 <property stdset="1">
99 <name>orientation</name> 99 <name>orientation</name>
100 <enum>Horizontal</enum> 100 <enum>Horizontal</enum>
101 </property> 101 </property>
102 </widget> 102 </widget>
103 <widget row="0" column="0" > 103 <widget row="0" column="0" >
104 <class>QLabel</class> 104 <class>QLabel</class>
105 <property stdset="1"> 105 <property stdset="1">
106 <name>name</name> 106 <name>name</name>
107 <cstring>TextLabel22</cstring> 107 <cstring>TextLabel22</cstring>
108 </property> 108 </property>
109 <property stdset="1"> 109 <property stdset="1">
110 <name>text</name> 110 <name>text</name>
111 <string>IP Address</string> 111 <string>IP Address</string>
112 </property> 112 </property>
113 </widget> 113 </widget>
114 <widget row="1" column="0" > 114 <widget row="1" column="0" >
115 <class>QLabel</class> 115 <class>QLabel</class>
116 <property stdset="1"> 116 <property stdset="1">
117 <name>name</name> 117 <name>name</name>
118 <cstring>TextLabel23</cstring> 118 <cstring>TextLabel23</cstring>
119 </property> 119 </property>
120 <property stdset="1"> 120 <property stdset="1">
121 <name>text</name> 121 <name>text</name>
122 <string>Subnet Mask</string> 122 <string>Subnet Mask</string>
123 </property> 123 </property>
124 </widget> 124 </widget>
125 <widget row="2" column="0" > 125 <widget row="2" column="0" >
126 <class>QLabel</class> 126 <class>QLabel</class>
127 <property stdset="1"> 127 <property stdset="1">
128 <name>name</name> 128 <name>name</name>
129 <cstring>TextLabel21</cstring> 129 <cstring>TextLabel21</cstring>
130 </property> 130 </property>
131 <property stdset="1"> 131 <property stdset="1">
132 <name>text</name> 132 <name>text</name>
133 <string>MAC Address</string> 133 <string>MAC Address</string>
134 </property> 134 </property>
135 </widget> 135 </widget>
136 <widget row="3" column="0" > 136 <widget row="3" column="0" >
137 <class>QLabel</class> 137 <class>QLabel</class>
138 <property stdset="1"> 138 <property stdset="1">
139 <name>name</name> 139 <name>name</name>
140 <cstring>TextLabel24</cstring> 140 <cstring>TextLabel24</cstring>
141 </property> 141 </property>
142 <property stdset="1"> 142 <property stdset="1">
143 <name>frameShape</name> 143 <name>frameShape</name>
144 <enum>MShape</enum> 144 <enum>MShape</enum>
145 </property> 145 </property>
146 <property stdset="1"> 146 <property stdset="1">
147 <name>frameShadow</name> 147 <name>frameShadow</name>
148 <enum>MShadow</enum> 148 <enum>MShadow</enum>
149 </property> 149 </property>
150 <property stdset="1"> 150 <property stdset="1">
151 <name>text</name> 151 <name>text</name>
152 <string>Broadcast</string> 152 <string>Broadcast</string>
153 </property> 153 </property>
154 </widget> 154 </widget>
155 <widget row="1" column="1" > 155 <widget row="1" column="1" >
156 <class>QLabel</class> 156 <class>QLabel</class>
157 <property stdset="1"> 157 <property stdset="1">
158 <name>name</name> 158 <name>name</name>
159 <cstring>subnetMaskLabel</cstring> 159 <cstring>subnetMaskLabel</cstring>
160 </property> 160 </property>
161 <property stdset="1"> 161 <property stdset="1">
162 <name>frameShape</name> 162 <name>frameShape</name>
163 <enum>Panel</enum> 163 <enum>Panel</enum>
164 </property> 164 </property>
165 <property stdset="1"> 165 <property stdset="1">
166 <name>frameShadow</name> 166 <name>frameShadow</name>
167 <enum>Sunken</enum> 167 <enum>Sunken</enum>
168 </property> 168 </property>
169 <property stdset="1"> 169 <property stdset="1">
170 <name>text</name> 170 <name>text</name>
171 <string>0.0.0.0</string> 171 <string>0.0.0.0</string>
172 </property> 172 </property>
173 </widget> 173 </widget>
174 <widget row="2" column="1" > 174 <widget row="2" column="1" >
175 <class>QLabel</class> 175 <class>QLabel</class>
176 <property stdset="1"> 176 <property stdset="1">
177 <name>name</name> 177 <name>name</name>
178 <cstring>macAddressLabel</cstring> 178 <cstring>macAddressLabel</cstring>
179 </property> 179 </property>
180 <property stdset="1"> 180 <property stdset="1">
181 <name>frameShape</name> 181 <name>frameShape</name>
182 <enum>Panel</enum> 182 <enum>Panel</enum>
183 </property> 183 </property>
@@ -200,146 +200,144 @@
200 <name>frameShape</name> 200 <name>frameShape</name>
201 <enum>Panel</enum> 201 <enum>Panel</enum>
202 </property> 202 </property>
203 <property stdset="1"> 203 <property stdset="1">
204 <name>frameShadow</name> 204 <name>frameShadow</name>
205 <enum>Sunken</enum> 205 <enum>Sunken</enum>
206 </property> 206 </property>
207 <property stdset="1"> 207 <property stdset="1">
208 <name>text</name> 208 <name>text</name>
209 <string></string> 209 <string></string>
210 </property> 210 </property>
211 </widget> 211 </widget>
212 <widget row="0" column="1" > 212 <widget row="0" column="1" >
213 <class>QLabel</class> 213 <class>QLabel</class>
214 <property stdset="1"> 214 <property stdset="1">
215 <name>name</name> 215 <name>name</name>
216 <cstring>ipAddressLabel</cstring> 216 <cstring>ipAddressLabel</cstring>
217 </property> 217 </property>
218 <property stdset="1"> 218 <property stdset="1">
219 <name>frameShape</name> 219 <name>frameShape</name>
220 <enum>Panel</enum> 220 <enum>Panel</enum>
221 </property> 221 </property>
222 <property stdset="1"> 222 <property stdset="1">
223 <name>frameShadow</name> 223 <name>frameShadow</name>
224 <enum>Sunken</enum> 224 <enum>Sunken</enum>
225 </property> 225 </property>
226 <property stdset="1"> 226 <property stdset="1">
227 <name>text</name> 227 <name>text</name>
228 <string>0.0.0.0</string> 228 <string>0.0.0.0</string>
229 </property> 229 </property>
230 </widget> 230 </widget>
231 <spacer row="7" column="1" > 231 <spacer row="7" column="1" >
232 <property> 232 <property>
233 <name>name</name> 233 <name>name</name>
234 <cstring>Spacer18</cstring> 234 <cstring>Spacer18</cstring>
235 </property> 235 </property>
236 <property stdset="1"> 236 <property stdset="1">
237 <name>orientation</name> 237 <name>orientation</name>
238 <enum>Vertical</enum> 238 <enum>Vertical</enum>
239 </property> 239 </property>
240 <property stdset="1"> 240 <property stdset="1">
241 <name>sizeType</name> 241 <name>sizeType</name>
242 <enum>Expanding</enum> 242 <enum>Expanding</enum>
243 </property> 243 </property>
244 <property> 244 <property>
245 <name>sizeHint</name> 245 <name>sizeHint</name>
246 <size> 246 <size>
247 <width>20</width> 247 <width>20</width>
248 <height>20</height> 248 <height>20</height>
249 </size> 249 </size>
250 </property> 250 </property>
251 </spacer> 251 </spacer>
252 <widget row="6" column="0" rowspan="1" colspan="2" > 252 <widget row="6" column="0" rowspan="1" colspan="2" >
253 <class>QLayoutWidget</class> 253 <class>QLayoutWidget</class>
254 <property stdset="1"> 254 <property stdset="1">
255 <name>name</name> 255 <name>name</name>
256 <cstring>Layout2</cstring> 256 <cstring>Layout2</cstring>
257 </property> 257 </property>
258 <hbox> 258 <hbox>
259 <property stdset="1"> 259 <property stdset="1">
260 <name>margin</name> 260 <name>margin</name>
261 <number>0</number> 261 <number>0</number>
262 </property> 262 </property>
263 <property stdset="1"> 263 <property stdset="1">
264 <name>spacing</name> 264 <name>spacing</name>
265 <number>6</number> 265 <number>6</number>
266 </property> 266 </property>
267 <spacer> 267 <spacer>
268 <property> 268 <property>
269 <name>name</name> 269 <name>name</name>
270 <cstring>Spacer10</cstring> 270 <cstring>Spacer10</cstring>
271 </property> 271 </property>
272 <property stdset="1"> 272 <property stdset="1">
273 <name>orientation</name> 273 <name>orientation</name>
274 <enum>Horizontal</enum> 274 <enum>Horizontal</enum>
275 </property> 275 </property>
276 <property stdset="1"> 276 <property stdset="1">
277 <name>sizeType</name> 277 <name>sizeType</name>
278 <enum>Expanding</enum> 278 <enum>Expanding</enum>
279 </property> 279 </property>
280 <property> 280 <property>
281 <name>sizeHint</name> 281 <name>sizeHint</name>
282 <size> 282 <size>
283 <width>20</width> 283 <width>20</width>
284 <height>20</height> 284 <height>20</height>
285 </size> 285 </size>
286 </property> 286 </property>
287 </spacer> 287 </spacer>
288 <widget> 288 <widget>
289 <class>QPushButton</class> 289 <class>QPushButton</class>
290 <property stdset="1"> 290 <property stdset="1">
291 <name>name</name> 291 <name>name</name>
292 <cstring>advancedButton</cstring> 292 <cstring>advancedButton</cstring>
293 </property> 293 </property>
294 <property stdset="1"> 294 <property stdset="1">
295 <name>text</name> 295 <name>text</name>
296 <string>View Advanced Information</string> 296 <string>View &amp;Advanced Information</string>
297 </property> 297 </property>
298 </widget> 298 </widget>
299 </hbox> 299 </hbox>
300 </widget> 300 </widget>
301 <widget row="5" column="0" rowspan="1" colspan="2" > 301 <widget row="5" column="0" rowspan="1" colspan="2" >
302 <class>Line</class> 302 <class>Line</class>
303 <property stdset="1"> 303 <property stdset="1">
304 <name>name</name> 304 <name>name</name>
305 <cstring>Line5</cstring> 305 <cstring>Line5</cstring>
306 </property> 306 </property>
307 <property stdset="1"> 307 <property stdset="1">
308 <name>orientation</name> 308 <name>orientation</name>
309 <enum>Horizontal</enum> 309 <enum>Horizontal</enum>
310 </property> 310 </property>
311 </widget> 311 </widget>
312 </grid> 312 </grid>
313</widget> 313</widget>
314<customwidgets> 314<customwidgets>
315 <customwidget> 315 <customwidget>
316 <class>QWidget</class> 316 <class>QWidget</class>
317 <header location="local">qwidget.h</header> 317 <header location="local">qwidget.h</header>
318 <sizehint> 318 <sizehint>
319 <width>100</width> 319 <width>100</width>
320 <height>100</height> 320 <height>100</height>
321 </sizehint> 321 </sizehint>
322 <container>0</container> 322 <container>0</container>
323 <sizepolicy> 323 <sizepolicy>
324 <hordata>7</hordata> 324 <hordata>7</hordata>
325 <verdata>7</verdata> 325 <verdata>7</verdata>
326 </sizepolicy> 326 </sizepolicy>
327 <pixmap>image0</pixmap> 327 <pixmap>image0</pixmap>
328 </customwidget> 328 </customwidget>
329</customwidgets> 329</customwidgets>
330<images> 330<images>
331 <image> 331 <image>
332 <name>image0</name> 332 <name>image0</name>
333 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> 333 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
334 </image> 334 </image>
335</images> 335</images>
336<connections>
337</connections>
338<tabstops> 336<tabstops>
339 <tabstop>startButton</tabstop> 337 <tabstop>startButton</tabstop>
340 <tabstop>stopButton</tabstop> 338 <tabstop>stopButton</tabstop>
341 <tabstop>refreshButton</tabstop> 339 <tabstop>refreshButton</tabstop>
342 <tabstop>restartButton</tabstop> 340 <tabstop>restartButton</tabstop>
343 <tabstop>advancedButton</tabstop> 341 <tabstop>advancedButton</tabstop>
344</tabstops> 342</tabstops>
345</UI> 343</UI>
diff --git a/noncore/settings/networksettings/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp
index 9155890..377a6db 100644
--- a/noncore/settings/networksettings/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces.cpp
@@ -1,150 +1,150 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qregexp.h> 5#include <qregexp.h>
6 6
7#define AUTO "auto" 7#define AUTO "auto"
8#define IFACE "iface" 8#define IFACE "iface"
9#define MAPPING "mapping" 9#define MAPPING "mapping"
10 10
11/** 11/**
12 * Constructor. Reads in the interfaces file and then split the file up by 12 * Constructor. Reads in the interfaces file and then split the file up by
13 * the \n for interfaces variable. 13 * the \n for interfaces variable.
14 * @param useInterfacesFile if an interface file other then the default is 14 * @param useInterfacesFile if an interface file other then the default is
15 * desired to be used it should be passed in. 15 * desired to be used it should be passed in.
16 */ 16 */
17Interfaces::Interfaces(QString useInterfacesFile){ 17Interfaces::Interfaces(QString useInterfacesFile){
18 acceptedFamily.append(INTERFACES_FAMILY_INET); 18 acceptedFamily.append(INTERFACES_FAMILY_INET);
19 acceptedFamily.append(INTERFACES_FAMILY_IPX); 19 acceptedFamily.append(INTERFACES_FAMILY_IPX);
20 acceptedFamily.append(INTERFACES_FAMILY_INET6); 20 acceptedFamily.append(INTERFACES_FAMILY_INET6);
21 21
22 interfacesFile = useInterfacesFile; 22 interfacesFile = useInterfacesFile;
23 QFile file(interfacesFile); 23 QFile file(interfacesFile);
24 if (!file.open(IO_ReadOnly)){ 24 if (!file.open(IO_ReadOnly)){
25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); 25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
26 currentIface = interfaces.end(); 26 currentIface = interfaces.end();
27 currentMapping = interfaces.end(); 27 currentMapping = interfaces.end();
28 return; 28 return;
29 } 29 }
30 QTextStream stream( &file ); 30 QTextStream stream( &file );
31 QString line; 31 QString line;
32 while ( !stream.eof() ) { 32 while ( !stream.eof() ) {
33 line += stream.readLine(); 33 line += stream.readLine();
34 line += "\n"; 34 line += "\n";
35 } 35 }
36 file.close(); 36 file.close();
37 interfaces = QStringList::split("\n", line, true); 37 interfaces = QStringList::split("\n", line, true);
38 38
39 currentIface = interfaces.end(); 39 currentIface = interfaces.end();
40 currentMapping = interfaces.end(); 40 currentMapping = interfaces.end();
41} 41}
42 42
43 43
44/** 44/**
45 * Get a list of all interfaces in the interface file. Usefull for 45 * Get a list of all interfaces in the interface file. Usefull for
46 * hardware that is not currently connected such as an 802.11b card 46 * hardware that is not currently connected such as an 802.11b card
47 * not plugged in, but configured for when it is plugged in. 47 * not plugged in, but configured for when it is plugged in.
48 * @return Return string list of interfaces. 48 * @return Return string list of interfaces.
49 **/ 49 **/
50QStringList Interfaces::getInterfaceList(){ 50QStringList Interfaces::getInterfaceList(){
51 QStringList list; 51 QStringList list;
52 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 52 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
53 QString line = (*it).simplifyWhiteSpace(); 53 QString line = (*it).simplifyWhiteSpace();
54 if(line.contains(IFACE)){ 54 if(line.contains(IFACE) && line.at(0) != '#'){
55 line = line.mid(QString(IFACE).length() +1, line.length()); 55 line = line.mid(QString(IFACE).length() +1, line.length());
56 line = line.simplifyWhiteSpace(); 56 line = line.simplifyWhiteSpace();
57 int findSpace = line.find(" "); 57 int findSpace = line.find(" ");
58 if( findSpace >= 0){ 58 if( findSpace >= 0){
59 line = line.mid(0, findSpace); 59 line = line.mid(0, findSpace);
60 list.append(line); 60 list.append(line);
61 } 61 }
62 } 62 }
63 } 63 }
64 return list; 64 return list;
65} 65}
66 66
67/** 67/**
68 * Find out if interface is in an "auto" group or not. 68 * Find out if interface is in an "auto" group or not.
69 * Report any duplicates such as eth0 being in two differnt auto's 69 * Report any duplicates such as eth0 being in two differnt auto's
70 * @param interface interface to check to see if it is on or not. 70 * @param interface interface to check to see if it is on or not.
71 * @return true is interface is in auto 71 * @return true is interface is in auto
72 */ 72 */
73bool Interfaces::isAuto(QString interface){ 73bool Interfaces::isAuto(QString interface){
74 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 74 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
75 QStringList awi = autoLines.grep(QRegExp(interface)); 75 QStringList awi = autoLines.grep(QRegExp(interface));
76 if(awi.count() > 1) 76 if(awi.count() > 1)
77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
78 if(awi.count() < 1) 78 if(awi.count() < 1)
79 return false; 79 return false;
80 return true; 80 return true;
81} 81}
82 82
83/** 83/**
84 * Attempt to set the auto option for interface to setAuto. 84 * Attempt to set the auto option for interface to setAuto.
85 * @param interface the interface to set 85 * @param interface the interface to set
86 * @param setAuto the value to set interface to. 86 * @param setAuto the value to set interface to.
87 * @return false if already set to setAuto. 87 * @return false if already set to setAuto.
88 * */ 88 * */
89bool Interfaces::setAuto(QString interface, bool setAuto){ 89bool Interfaces::setAuto(QString interface, bool setAuto){
90 // Don't need to set it if it is already set. 90 // Don't need to set it if it is already set.
91 if(isAuto(interface) == setAuto) 91 if(isAuto(interface) == setAuto)
92 return false; 92 return false;
93 93
94 bool changed = false; 94 bool changed = false;
95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
96 if((*it).contains(AUTO)){ 96 if((*it).contains(AUTO)){
97 //We know that they are not in any group so let add to this auto. 97 //We know that they are not in any group so let add to this auto.
98 if(setAuto){ 98 if(setAuto){
99 (*it) = (*it) += " " + interface; 99 (*it) = (*it) += " " + interface;
100 // Don't care to have such thins as: auto eth0 lo usb0 100 // Don't care to have such thins as: auto eth0 lo usb0
101 (*it) = (*it).simplifyWhiteSpace(); 101 (*it) = (*it).simplifyWhiteSpace();
102 changed = true; 102 changed = true;
103 break; 103 break;
104 } 104 }
105 else{ 105 else{
106 if((*it).contains(interface)){ 106 if((*it).contains(interface)){
107 (*it) = (*it).replace(QRegExp(interface), ""); 107 (*it) = (*it).replace(QRegExp(interface), "");
108 // clean up 108 // clean up
109 QString line = (*it).simplifyWhiteSpace(); 109 QString line = (*it).simplifyWhiteSpace();
110 line = line.replace(QRegExp(" "),""); 110 line = line.replace(QRegExp(" "),"");
111 if(line == AUTO) 111 if(line == AUTO)
112 (*it) = ""; 112 (*it) = "";
113 changed = true; 113 changed = true;
114 // Don't break because we want to make sure we remove all cases. 114 // Don't break because we want to make sure we remove all cases.
115 } 115 }
116 } 116 }
117 } 117 }
118 } 118 }
119 if(changed == false){ 119 if(changed == false){
120 if(setAuto == true) 120 if(setAuto == true)
121 interfaces.append(QString(AUTO" %1").arg(interface)); 121 interfaces.append(QString(AUTO" %1").arg(interface));
122 else{ 122 else{
123 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1()); 123 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1());
124 } 124 }
125 } 125 }
126 return true; 126 return true;
127} 127}
128 128
129/** 129/**
130 * Set the current interface to interface. This needs to be done before you 130 * Set the current interface to interface. This needs to be done before you
131 * can call getFamily(), getMethod, and get/setOption(). 131 * can call getFamily(), getMethod, and get/setOption().
132 * @param interface the name of the interface to set. All whitespace is 132 * @param interface the name of the interface to set. All whitespace is
133 * removed from the interface name. 133 * removed from the interface name.
134 * @return bool true if it is successfull. 134 * @return bool true if it is successfull.
135 */ 135 */
136bool Interfaces::setInterface(QString interface){ 136bool Interfaces::setInterface(QString interface){
137 interface = interface.simplifyWhiteSpace(); 137 interface = interface.simplifyWhiteSpace();
138 interface = interface.replace(QRegExp(" "), ""); 138 interface = interface.replace(QRegExp(" "), "");
139 return setStanza(IFACE, interface, currentIface); 139 return setStanza(IFACE, interface, currentIface);
140} 140}
141 141
142/** 142/**
143 * A quick helper funtion to see if the current interface is set. 143 * A quick helper funtion to see if the current interface is set.
144 * @return bool true if set, false otherwise. 144 * @return bool true if set, false otherwise.
145 */ 145 */
146bool Interfaces::isInterfaceSet(){ 146bool Interfaces::isInterfaceSet(){
147 return (currentIface != interfaces.end()); 147 return (currentIface != interfaces.end());
148} 148}
149 149
150/** 150/**
@@ -364,275 +364,275 @@ bool Interfaces::removeAllInterfaceOptions(){
364 return removeAllOptions(currentIface); 364 return removeAllOptions(currentIface);
365} 365}
366 366
367/** 367/**
368 * Set the current map to interface's map. This needs to be done before you 368 * Set the current map to interface's map. This needs to be done before you
369 * can call addMapping(), set/getMap(), and get/setScript(). 369 * can call addMapping(), set/getMap(), and get/setScript().
370 * @param interface the name of the interface to set. All whitespace is 370 * @param interface the name of the interface to set. All whitespace is
371 * removed from the interface name. 371 * removed from the interface name.
372 * @return bool true if it is successfull. 372 * @return bool true if it is successfull.
373 */ 373 */
374bool Interfaces::setMapping(QString interface){ 374bool Interfaces::setMapping(QString interface){
375 interface = interface.simplifyWhiteSpace(); 375 interface = interface.simplifyWhiteSpace();
376 interface = interface.replace(QRegExp(" "), ""); 376 interface = interface.replace(QRegExp(" "), "");
377 return setStanza(MAPPING, interface, currentMapping); 377 return setStanza(MAPPING, interface, currentMapping);
378} 378}
379 379
380/** 380/**
381 * Adds a new Mapping to the interfaces file with interfaces. 381 * Adds a new Mapping to the interfaces file with interfaces.
382 * @param interface the name(s) of the interfaces to set to this mapping 382 * @param interface the name(s) of the interfaces to set to this mapping
383 */ 383 */
384void Interfaces::addMapping(QString option){ 384void Interfaces::addMapping(QString option){
385 interfaces.append(""); 385 interfaces.append("");
386 interfaces.append(QString(MAPPING " %1").arg(option)); 386 interfaces.append(QString(MAPPING " %1").arg(option));
387} 387}
388 388
389/** 389/**
390 * Remove the currently selected map and all of its options. 390 * Remove the currently selected map and all of its options.
391 * @return bool if successfull or not. 391 * @return bool if successfull or not.
392 */ 392 */
393bool Interfaces::removeMapping(){ 393bool Interfaces::removeMapping(){
394 if(currentMapping == interfaces.end()) 394 if(currentMapping == interfaces.end())
395 return false; 395 return false;
396 (*currentMapping) = ""; 396 (*currentMapping) = "";
397 return removeAllOptions(currentMapping); 397 return removeAllOptions(currentMapping);
398} 398}
399 399
400/** 400/**
401 * Set a map option within a mapping. 401 * Set a map option within a mapping.
402 * @param map map to use 402 * @param map map to use
403 * @param value value to go with map 403 * @param value value to go with map
404 * @return bool true if it is successfull. 404 * @return bool true if it is successfull.
405 */ 405 */
406bool Interfaces::setMap(QString map, QString value){ 406bool Interfaces::setMap(QString map, QString value){
407 return setOption(currentMapping, map, value); 407 return setOption(currentMapping, map, value);
408} 408}
409 409
410/** 410/**
411 * Removes a map option within a mapping. 411 * Removes a map option within a mapping.
412 * @param map map to use 412 * @param map map to use
413 * @param value value to go with map 413 * @param value value to go with map
414 * @return bool true if it is successfull. 414 * @return bool true if it is successfull.
415 */ 415 */
416bool Interfaces::removeMap(QString map, QString value){ 416bool Interfaces::removeMap(QString map, QString value){
417 return removeOption(currentMapping, map, value); 417 return removeOption(currentMapping, map, value);
418} 418}
419 419
420/** 420/**
421 * Get a map value within a mapping. 421 * Get a map value within a mapping.
422 * @param map map to get value of 422 * @param map map to get value of
423 * @param bool true if it is successfull. 423 * @param bool true if it is successfull.
424 * @return value that goes to the map 424 * @return value that goes to the map
425 */ 425 */
426QString Interfaces::getMap(QString map, bool &error){ 426QString Interfaces::getMap(QString map, bool &error){
427 return getOption(currentMapping, map, error); 427 return getOption(currentMapping, map, error);
428} 428}
429 429
430/** 430/**
431 * Sets a script value of the current mapping to argument. 431 * Sets a script value of the current mapping to argument.
432 * @param argument the script name. 432 * @param argument the script name.
433 * @return true if successfull. 433 * @return true if successfull.
434 */ 434 */
435bool Interfaces::setScript(QString argument){ 435bool Interfaces::setScript(QString argument){
436 return setOption(currentMapping, "script", argument); 436 return setOption(currentMapping, "script", argument);
437} 437}
438 438
439/** 439/**
440 * @param error true if could not retrieve the current script argument. 440 * @param error true if could not retrieve the current script argument.
441 * @return QString the argument of the script for the current mapping. 441 * @return QString the argument of the script for the current mapping.
442 */ 442 */
443QString Interfaces::getScript(bool &error){ 443QString Interfaces::getScript(bool &error){
444 return getOption(currentMapping, "script", error); 444 return getOption(currentMapping, "script", error);
445} 445}
446 446
447/** 447/**
448 * Helper function used to parse through the QStringList and put pointers in 448 * Helper function used to parse through the QStringList and put pointers in
449 * the correct place. 449 * the correct place.
450 * @param stanza The stanza (auto, iface, mapping) to look for. 450 * @param stanza The stanza (auto, iface, mapping) to look for.
451 * @param option string that must be in the stanza's main line. 451 * @param option string that must be in the stanza's main line.
452 * @param interator interator to place at location of stanza if successfull. 452 * @param interator interator to place at location of stanza if successfull.
453 * @return bool true if the stanza is found. 453 * @return bool true if the stanza is found.
454 */ 454 */
455bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ 455bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){
456 bool found = false; 456 bool found = false;
457 iterator = interfaces.end(); 457 iterator = interfaces.end();
458 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 458 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
459 QString line = (*it).simplifyWhiteSpace(); 459 QString line = (*it).simplifyWhiteSpace();
460 if(line.contains(stanza) && line.contains(option)){ 460 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
461 uint point = line.find(option); 461 uint point = line.find(option);
462 bool valid = true; 462 bool valid = true;
463 if(point > 0){ 463 if(point > 0){
464 // There are more chars in the line. check +1 464 // There are more chars in the line. check +1
465 if(line.at(point-1) != ' ') 465 if(line.at(point-1) != ' ')
466 valid = false; 466 valid = false;
467 } 467 }
468 point += option.length(); 468 point += option.length();
469 if(point < line.length()-1){ 469 if(point < line.length()-1){
470 // There are more chars in the line. check -1 470 // There are more chars in the line. check -1
471 if(line.at(point) != ' ') 471 if(line.at(point) != ' ')
472 valid = false; 472 valid = false;
473 } 473 }
474 if(valid){ 474 if(valid){
475 if(found == true){ 475 if(found == true){
476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
477 } 477 }
478 found = true; 478 found = true;
479 iterator = it; 479 iterator = it;
480 } 480 }
481 } 481 }
482 } 482 }
483 return found; 483 return found;
484} 484}
485 485
486/** 486/**
487 * Sets a value of an option in a stanza 487 * Sets a value of an option in a stanza
488 * @param start the start of the stanza 488 * @param start the start of the stanza
489 * @param option the option to use when setting value. 489 * @param option the option to use when setting value.
490 * @return bool true if successfull, false otherwise. 490 * @return bool true if successfull, false otherwise.
491 */ 491 */
492bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ 492bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){
493 if(start == interfaces.end()) 493 if(start == interfaces.end())
494 return false; 494 return false;
495 495
496 bool found = false; 496 bool found = false;
497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
499 if(!found && value != ""){ 499 if(!found && value != ""){
500 // Got to the end of the stanza without finding it, so append it. 500 // Got to the end of the stanza without finding it, so append it.
501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
502 } 502 }
503 found = true; 503 found = true;
504 break; 504 break;
505 } 505 }
506 if((*it).contains(option) && it != start){ 506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
507 // Found it in stanza so replace it. 507 // Found it in stanza so replace it.
508 if(found) 508 if(found)
509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
510 found = true; 510 found = true;
511 (*it) = QString("\t%1 %2").arg(option).arg(value); 511 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 } 512 }
513 } 513 }
514 if(!found){ 514 if(!found){
515 QStringList::Iterator p = start; 515 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true; 517 found = true;
518 } 518 }
519 return found; 519 return found;
520} 520}
521/** 521/**
522 * Removes a option in a stanza 522 * Removes a option in a stanza
523 * @param start the start of the stanza 523 * @param start the start of the stanza
524 * @param option the option to use when setting value. 524 * @param option the option to use when setting value.
525 * @return bool true if successfull, false otherwise. 525 * @return bool true if successfull, false otherwise.
526 */ 526 */
527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ 527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){
528 if(start == interfaces.end()) 528 if(start == interfaces.end())
529 return false; 529 return false;
530 530
531 bool found = false; 531 bool found = false;
532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
534 // got to the end without finding it 534 // got to the end without finding it
535 break; 535 break;
536 } 536 }
537 if((*it).contains(option) && (*it).contains(value) &&it != start){ 537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
538 // Found it in stanza so replace it. 538 // Found it in stanza so replace it.
539 if(found) 539 if(found)
540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
541 found = true; 541 found = true;
542 (*it) = ""; 542 (*it) = "";
543 } 543 }
544 } 544 }
545 return found; 545 return found;
546} 546}
547 547
548/** 548/**
549 * Removes all options in a stanza 549 * Removes all options in a stanza
550 * @param start the start of the stanza 550 * @param start the start of the stanza
551 * @return bool true if successfull, false otherwise. 551 * @return bool true if successfull, false otherwise.
552 */ 552 */
553bool Interfaces::removeAllOptions(QStringList::Iterator start){ 553bool Interfaces::removeAllOptions(QStringList::Iterator start){
554 if(start == interfaces.end()) 554 if(start == interfaces.end())
555 return false; 555 return false;
556 556
557 QStringList::Iterator it = start; 557 QStringList::Iterator it = start;
558 it = ++it; 558 it = ++it;
559 for (it; it != interfaces.end(); ++it ) { 559 for (it; it != interfaces.end(); ++it ) {
560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
561 break; 561 break;
562 } 562 }
563 it = interfaces.remove(it); 563 it = interfaces.remove(it);
564 it = --it; 564 it = --it;
565 } 565 }
566 // Leave a space between this interface and the next. 566 // Leave a space between this interface and the next.
567 interfaces.insert(it, QString("")); 567 interfaces.insert(it, QString(""));
568 return true; 568 return true;
569} 569}
570 570
571/** 571/**
572 * Gets a value of an option in a stanza 572 * Gets a value of an option in a stanza
573 * @param start the start of the stanza 573 * @param start the start of the stanza
574 * @param option the option to use when getting the value. 574 * @param option the option to use when getting the value.
575 * @param bool true if errors false otherwise. 575 * @param bool true if errors false otherwise.
576 * @return QString the value of option QString::null() if error == true. 576 * @return QString the value of option QString::null() if error == true.
577 */ 577 */
578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ 578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){
579 if(start == interfaces.end()){ 579 if(start == interfaces.end()){
580 error = false; 580 error = false;
581 return QString(); 581 return QString();
582 } 582 }
583 583
584 QString value; 584 QString value;
585 bool found = false; 585 bool found = false;
586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
588 break; 588 break;
589 } 589 }
590 if((*it).contains(option)){ 590 if((*it).contains(option) && (*it).at(0) != '#'){
591 if(found) 591 if(found)
592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); 592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
593 found = true; 593 found = true;
594 QString line = (*it).simplifyWhiteSpace(); 594 QString line = (*it).simplifyWhiteSpace();
595 int space = line.find(" ", option.length()); 595 int space = line.find(" ", option.length());
596 if(space != -1) 596 if(space != -1)
597 value = line.mid(space+1, line.length()); 597 value = line.mid(space+1, line.length());
598 else 598 else
599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); 599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1());
600 } 600 }
601 } 601 }
602 error = !found; 602 error = !found;
603 return value; 603 return value;
604} 604}
605 605
606/** 606/**
607 * Write out the interfaces file to the file passed into the constructor. 607 * Write out the interfaces file to the file passed into the constructor.
608 * Removes any excess blank lines over 1 line long. 608 * Removes any excess blank lines over 1 line long.
609 * @return bool true if successfull, false if not. 609 * @return bool true if successfull, false if not.
610 */ 610 */
611bool Interfaces::write(){ 611bool Interfaces::write(){
612 QFile::remove(interfacesFile); 612 QFile::remove(interfacesFile);
613 QFile file(interfacesFile); 613 QFile file(interfacesFile);
614 614
615 if (!file.open(IO_ReadWrite)){ 615 if (!file.open(IO_ReadWrite)){
616 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); 616 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
617 return false; 617 return false;
618 } 618 }
619 QTextStream stream( &file ); 619 QTextStream stream( &file );
620 int whiteSpaceCount = 0; 620 int whiteSpaceCount = 0;
621 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 621 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
622 QString line = (*it).simplifyWhiteSpace(); 622 QString line = (*it).simplifyWhiteSpace();
623 line = line.replace(QRegExp(" "),""); 623 line = line.replace(QRegExp(" "),"");
624 if(line.length() == 0) 624 if(line.length() == 0)
625 whiteSpaceCount++; 625 whiteSpaceCount++;
626 else 626 else
627 whiteSpaceCount = 0; 627 whiteSpaceCount = 0;
628 if(whiteSpaceCount < 2){ 628 if(whiteSpaceCount < 2){
629 qDebug((*it).latin1()); 629 qDebug((*it).latin1());
630 stream << (*it) << '\n'; 630 stream << (*it) << '\n';
631 } 631 }
632 } 632 }
633 file.close(); 633 file.close();
634 return true; 634 return true;
635} 635}
636 636
637// interfaces.cpp 637// interfaces.cpp
638 638
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 01063c2..8e4e898 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -139,239 +139,239 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
139 return NULL; 139 return NULL;
140 } 140 }
141 141
142 // Store for deletion later 142 // Store for deletion later
143 libraries.insert(object, lib); 143 libraries.insert(object, lib);
144 return object; 144 return object;
145} 145}
146 146
147/** 147/**
148 * The Add button was clicked. Bring up the add dialog and if OK is hit 148 * The Add button was clicked. Bring up the add dialog and if OK is hit
149 * load the plugin and append it to the list 149 * load the plugin and append it to the list
150 */ 150 */
151void MainWindowImp::addClicked(){ 151void MainWindowImp::addClicked(){
152 QMap<Module*, QLibrary*>::Iterator it; 152 QMap<Module*, QLibrary*>::Iterator it;
153 QMap<QString, QString> list; 153 QMap<QString, QString> list;
154 QMap<QString, Module*> newInterfaceOwners; 154 QMap<QString, Module*> newInterfaceOwners;
155 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 155 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
156 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 156 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
157 for( it = libraries.begin(); it != libraries.end(); ++it ){ 157 for( it = libraries.begin(); it != libraries.end(); ++it ){
158 if(it.key()){ 158 if(it.key()){
159 (it.key())->possibleNewInterfaces(list); 159 (it.key())->possibleNewInterfaces(list);
160 } 160 }
161 } 161 }
162 // See if the list has anything that we can add. 162 // See if the list has anything that we can add.
163 if(list.count() == 0){ 163 if(list.count() == 0){
164 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 164 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
165 return; 165 return;
166 } 166 }
167 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 167 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
168 addNewConnection.addConnections(list); 168 addNewConnection.addConnections(list);
169 addNewConnection.showMaximized(); 169 addNewConnection.showMaximized();
170 if(QDialog::Accepted == addNewConnection.exec()){ 170 if(QDialog::Accepted == addNewConnection.exec()){
171 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 171 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
172 if(!item) 172 if(!item)
173 return; 173 return;
174 174
175 for( it = libraries.begin(); it != libraries.end(); ++it ){ 175 for( it = libraries.begin(); it != libraries.end(); ++it ){
176 if(it.key()){ 176 if(it.key()){
177 Interface *i = (it.key())->addNewInterface(item->text(0)); 177 Interface *i = (it.key())->addNewInterface(item->text(0));
178 if(i){ 178 if(i){
179 interfaceNames.insert(i->getInterfaceName(), i); 179 interfaceNames.insert(i->getInterfaceName(), i);
180 updateInterface(i); 180 updateInterface(i);
181 } 181 }
182 } 182 }
183 } 183 }
184 } 184 }
185} 185}
186 186
187/** 187/**
188 * Prompt the user to see if they really want to do this. 188 * Prompt the user to see if they really want to do this.
189 * If they do then remove from the list and unload. 189 * If they do then remove from the list and unload.
190 */ 190 */
191void MainWindowImp::removeClicked(){ 191void MainWindowImp::removeClicked(){
192 QListViewItem *item = connectionList->currentItem(); 192 QListViewItem *item = connectionList->currentItem();
193 if(!item) { 193 if(!item) {
194 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); 194 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
195 return; 195 return;
196 } 196 }
197 197
198 Interface *i = interfaceItems[item]; 198 Interface *i = interfaceItems[item];
199 if(i->getModuleOwner() == NULL){ 199 if(i->getModuleOwner() == NULL){
200 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 200 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
201 } 201 }
202 else{ 202 else{
203 if(!i->getModuleOwner()->remove(i)) 203 if(!i->getModuleOwner()->remove(i))
204 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 204 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
205 else{ 205 else{
206 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 206 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
207 // TODO memory managment.... 207 // TODO memory managment....
208 // who deletes the interface? 208 // who deletes the interface?
209 } 209 }
210 } 210 }
211} 211}
212 212
213/** 213/**
214 * Pull up the configure about the currently selected interface. 214 * Pull up the configure about the currently selected interface.
215 * Report an error if no interface is selected. 215 * Report an error if no interface is selected.
216 * If the interface has a module owner then request its configure with a empty 216 * If the interface has a module owner then request its configure with a empty
217 * tab. If tab is !NULL then append the interfaces setup widget to it. 217 * tab. If tab is !NULL then append the interfaces setup widget to it.
218 */ 218 */
219void MainWindowImp::configureClicked(){ 219void MainWindowImp::configureClicked(){
220 QListViewItem *item = connectionList->currentItem(); 220 QListViewItem *item = connectionList->currentItem();
221 if(!item){ 221 if(!item){
222 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 222 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
223 return; 223 return;
224 } 224 }
225 225
226 QString currentProfile = currentProfileLabel->text(); 226 QString currentProfile = currentProfileLabel->text();
227 if(profilesList->count() <= 1 || currentProfile == "All"){ 227 if(profilesList->count() <= 1 || currentProfile == "All"){
228 currentProfile = ""; 228 currentProfile = "";
229 } 229 }
230 230
231 Interface *i = interfaceItems[item]; 231 Interface *i = interfaceItems[item];
232 if(i->getModuleOwner()){ 232 if(i->getModuleOwner()){
233 i->getModuleOwner()->setProfile(currentProfile); 233 i->getModuleOwner()->setProfile(currentProfile);
234 QTabWidget *tabWidget = NULL; 234 QTabWidget *tabWidget = NULL;
235 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 235 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
236 if(moduleConfigure != NULL){ 236 if(moduleConfigure != NULL){
237 if(tabWidget != NULL){ 237 if(tabWidget != NULL){
238 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 238 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
239 configure->setProfile(currentProfile); 239 configure->setProfile(currentProfile);
240 tabWidget->insertTab(configure, "TCP/IP"); 240 tabWidget->insertTab(configure, "TCP/IP");
241 241
242 } 242 }
243 moduleConfigure->showMaximized(); 243 moduleConfigure->showMaximized();
244 moduleConfigure->show(); 244 moduleConfigure->show();
245 return; 245 return;
246 } 246 }
247 } 247 }
248 248
249 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 249 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
250 configure->setProfile(currentProfile); 250 configure->setProfile(currentProfile);
251 configure->showMaximized(); 251 configure->showMaximized();
252 configure->show(); 252 configure->show();
253} 253}
254 254
255/** 255/**
256 * Pull up the information about the currently selected interface. 256 * Pull up the information about the currently selected interface.
257 * Report an error if no interface is selected. 257 * Report an error if no interface is selected.
258 * If the interface has a module owner then request its configure with a empty 258 * If the interface has a module owner then request its configure with a empty
259 * tab. If tab is !NULL then append the interfaces setup widget to it. 259 * tab. If tab is !NULL then append the interfaces setup widget to it.
260 */ 260 */
261void MainWindowImp::informationClicked(){ 261void MainWindowImp::informationClicked(){
262 QListViewItem *item = connectionList->currentItem(); 262 QListViewItem *item = connectionList->currentItem();
263 if(!item){ 263 if(!item){
264 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 264 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
265 return; 265 return;
266 } 266 }
267 267
268 Interface *i = interfaceItems[item]; 268 Interface *i = interfaceItems[item];
269 if(!i->isAttached()){ 269 if(!i->isAttached()){
270 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); 270 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
271 return; 271 return;
272 } 272 }
273 273
274 QStringList list; 274 QStringList list;
275 for(uint i = 0; i < profilesList->count(); i++){ 275 for(uint i = 0; i < profilesList->count(); i++){
276 list.append(profilesList->text(i)); 276 list.append(profilesList->text(i));
277 } 277 }
278 278
279 if(i->getModuleOwner()){ 279 if(i->getModuleOwner()){
280 QTabWidget *tabWidget = NULL; 280 QTabWidget *tabWidget = NULL;
281 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 281 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
282 if(moduleInformation != NULL){ 282 if(moduleInformation != NULL){
283 if(tabWidget != NULL){ 283 if(tabWidget != NULL){
284 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 284 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
285 tabWidget->insertTab(information, "TCP/IP"); 285 tabWidget->insertTab(information, "TCP/IP");
286 } 286 }
287 moduleInformation->showMaximized(); 287 moduleInformation->showMaximized();
288 moduleInformation->show(); 288 moduleInformation->show();
289 return; 289 return;
290 } 290 }
291 } 291 }
292 292
293 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 293 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
294 information->showMaximized(); 294 information->showMaximized();
295 information->show(); 295 information->show();
296} 296}
297 297
298/** 298/**
299 * Aquire the list of active interfaces from ifconfig 299 * Aquire the list of active interfaces from ifconfig
300 * Call ifconfig and ifconfig -a 300 * Call ifconfig and ifconfig -a
301 */ 301 */
302void MainWindowImp::getInterfaceList(){ 302void MainWindowImp::getInterfaceList(){
303 KShellProcess *processAll = new KShellProcess(); 303 KShellProcess *processAll = new KShellProcess();
304 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 304 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
305 connect(processAll, SIGNAL(processExited(KProcess *)), 305 connect(processAll, SIGNAL(processExited(KProcess *)),
306 this, SLOT(jobDone(KProcess *))); 306 this, SLOT(jobDone(KProcess *)));
307 threads.insert(processAll, TEMP_ALL); 307 threads.insert(processAll, TEMP_ALL);
308 308
309 KShellProcess *process = new KShellProcess(); 309 KShellProcess *process = new KShellProcess();
310 *process << "/sbin/ifconfig" << " > " TEMP_UP; 310 *process << "/sbin/ifconfig" << " > " TEMP_UP;
311 connect(process, SIGNAL(processExited(KProcess *)), 311 connect(process, SIGNAL(processExited(KProcess *)),
312 this, SLOT(jobDone(KProcess *))); 312 this, SLOT(jobDone(KProcess *)));
313 threads.insert(process, TEMP_UP); 313 threads.insert(process, TEMP_UP);
314 314
315 processAll->start(KShellProcess::NotifyOnExit); 315 processAll->start(KShellProcess::NotifyOnExit);
316 process->start(KShellProcess::NotifyOnExit); 316 process->start(KShellProcess::NotifyOnExit);
317} 317}
318 318
319void MainWindowImp::jobDone(KProcess *process){ 319void MainWindowImp::jobDone(KProcess *process){
320 QString fileName = threads[process]; 320 QString fileName = threads[process];
321 threads.remove(process); 321 threads.remove(process);
322 delete process; 322 delete process;
323 323
324 QFile file(fileName); 324 QFile file(fileName);
325 if (!file.open(IO_ReadOnly)){ 325 if (!file.open(IO_ReadOnly)){
326 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 326 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
327 return; 327 return;
328 } 328 }
329 329
330 QTextStream stream( &file ); 330 QTextStream stream( &file );
331 QString line; 331 QString line;
332 while ( !stream.eof() ) { 332 while ( !stream.eof() ) {
333 line = stream.readLine(); 333 line = stream.readLine();
334 int space = line.find(" "); 334 int space = line.find(" ");
335 if(space > 1){ 335 if(space > 1){
336 // We have found an interface 336 // We have found an interface
337 QString interfaceName = line.mid(0, space); 337 QString interfaceName = line.mid(0, space);
338 Interface *i; 338 Interface *i;
339 // We have found an interface 339 // We have found an interface
340 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 340 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
341 // See if we already have it 341 // See if we already have it
342 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 342 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
343 if(fileName == TEMP_ALL) 343 if(fileName == TEMP_ALL)
344 i = new Interface(this, interfaceName, false); 344 i = new Interface(this, interfaceName, false);
345 else 345 else
346 i = new Interface(this, interfaceName, true); 346 i = new Interface(this, interfaceName, true);
347 i->setAttached(true); 347 i->setAttached(true);
348 348
349 QString hardName = "Ethernet"; 349 QString hardName = "Ethernet";
350 int hardwareName = line.find("Link encap:"); 350 int hardwareName = line.find("Link encap:");
351 int macAddress = line.find("HWaddr"); 351 int macAddress = line.find("HWaddr");
352 if(macAddress == -1) 352 if(macAddress == -1)
353 macAddress = line.length(); 353 macAddress = line.length();
354 if(hardwareName != -1) 354 if(hardwareName != -1)
355 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); 355 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
356 356
357 interfaceNames.insert(i->getInterfaceName(), i); 357 interfaceNames.insert(i->getInterfaceName(), i);
358 updateInterface(i); 358 updateInterface(i);
359 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 359 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
360 } 360 }
361 // It was an interface we already had. 361 // It was an interface we already had.
362 else{ 362 else{
363 if(fileName != TEMP_ALL) 363 if(fileName != TEMP_ALL)
364 (interfaceNames[interfaceName])->setStatus(true); 364 (interfaceNames[interfaceName])->setStatus(true);
365 } 365 }
366 } 366 }
367 } 367 }
368 file.close(); 368 file.close();
369 QFile::remove(fileName); 369 QFile::remove(fileName);
370 370
371 if(threads.count() == 0){ 371 if(threads.count() == 0){
372 Interfaces i; 372 Interfaces i;
373 QStringList list = i.getInterfaceList(); 373 QStringList list = i.getInterfaceList();
374 QMap<QString, Interface*>::Iterator it; 374 QMap<QString, Interface*>::Iterator it;
375 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 375 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
376 bool found = false; 376 bool found = false;
377 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 377 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h
index a30f492..96db5b3 100644
--- a/noncore/settings/networksettings/module.h
+++ b/noncore/settings/networksettings/module.h
@@ -1,86 +1,88 @@
1#ifndef NETCONF_MODULE_H 1#ifndef NETCONF_MODULE_H
2#define NETCONF_MODULE_H 2#define NETCONF_MODULE_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <qmap.h> 6#include <qmap.h>
7#include "interface.h" 7#include "interface.h"
8 8
9class QWidget; 9class QWidget;
10class QTabWidget; 10class QTabWidget;
11 11
12class Module : QObject{ 12class Module : QObject{
13 13
14signals: 14signals:
15 void updateInterface(Interface *i); 15 void updateInterface(Interface *i);
16 16
17public: 17public:
18 Module(){}; 18 Module(){};
19 19
20 /** 20 /**
21 * The current profile has been changed and the module should do any 21 * The current profile has been changed and the module should do any
22 * neccesary changes also. 22 * neccesary changes also.
23 * @param newProfile what the profile should be changed to. 23 * @param newProfile what the profile should be changed to.
24 */ 24 */
25 virtual void setProfile(QString newProfile) = 0; 25 virtual void setProfile(QString newProfile) = 0;
26 26
27 /** 27 /**
28 * get the icon name for this device. 28 * get the icon name for this device.
29 * @param Interface* can be used in determining the icon. 29 * @param Interface* can be used in determining the icon.
30 * @return QString the icon name (minus .png, .gif etc) 30 * @return QString the icon name (minus .png, .gif etc)
31 */ 31 */
32 virtual QString getPixmapName(Interface* i) = 0; 32 virtual QString getPixmapName(Interface *) = 0;
33 33
34 /** 34 /**
35 * Check to see if the interface i is owned by this module. 35 * Check to see if the interface i is owned by this module.
36 * @param Interface* interface to check against 36 * @param Interface* interface to check against
37 * @return bool true if i is owned by this module, false otherwise. 37 * @return bool true if i is owned by this module, false otherwise.
38 */ 38 */
39 virtual bool isOwner(Interface *){ return false; }; 39 virtual bool isOwner(Interface *){ return false; };
40 40
41 /** 41 /**
42 * Create, set tabWiget and return the WLANConfigure Module 42 * Create, set tabWiget and return the WLANConfigure Module
43 * @param Interface *i the interface to configure.
43 * @param tabWidget a pointer to the tab widget that this configure has. 44 * @param tabWidget a pointer to the tab widget that this configure has.
44 * @return QWidget* pointer to the tab widget in this modules configure. 45 * @return QWidget* pointer to the tab widget in this modules configure.
45 */ 46 */
46 virtual QWidget *configure(QTabWidget **){ return NULL; } ; 47 virtual QWidget *configure(Interface *, QTabWidget **){ return NULL; } ;
47 48
48 /** 49 /**
49 * Create, set tabWiget and return the Information Module 50 * Create, set tabWiget and return the Information Module
51 * @param Interface *i the interface to get info on.
50 * @param tabWidget a pointer to the tab widget that this information has. 52 * @param tabWidget a pointer to the tab widget that this information has.
51 * @return QWidget* pointer to the tab widget in this modules info. 53 * @return QWidget* pointer to the tab widget in this modules info.
52 */ 54 */
53 virtual QWidget *information(QTabWidget **){ return NULL; }; 55 virtual QWidget *information(Interface *, QTabWidget **){ return NULL; };
54 56
55 /** 57 /**
56 * Get all active (up or down) interfaces 58 * Get all active (up or down) interfaces
57 * @return QList<Interface> A list of interfaces that exsist that havn't 59 * @return QList<Interface> A list of interfaces that exsist that havn't
58 * been called by isOwner() 60 * been called by isOwner()
59 */ 61 */
60 virtual QList<Interface> getInterfaces() = 0; 62 virtual QList<Interface> getInterfaces() = 0;
61 63
62 /** 64 /**
63 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), 65 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
64 * modem ppp) 66 * modem ppp)
65 */ 67 */
66 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; 68 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
67 69
68 /** 70 /**
69 * Attempts to create a new interface from name 71 * Attempts to create a new interface from name
70 * @return Interface* NULL if it was unable to be created. 72 * @return Interface* NULL if it was unable to be created.
71 * @param name the type of interface to create 73 * @param name the type of interface to create
72 */ 74 */
73 virtual Interface *addNewInterface(QString name) = 0; 75 virtual Interface *addNewInterface(QString name) = 0;
74 76
75 /** 77 /**
76 * Attempts to remove the interface, doesn't delete i 78 * Attempts to remove the interface, doesn't delete i
77 * @return bool true if successfull, false otherwise. 79 * @return bool true if successfull, false otherwise.
78 */ 80 */
79 virtual bool remove(Interface* i) = 0; 81 virtual bool remove(Interface* i) = 0;
80 82
81}; 83};
82 84
83#endif 85#endif
84 86
85// module.h 87// module.h
86 88