summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindow.ui24
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp10
2 files changed, 32 insertions, 2 deletions
diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui
index f61a1ae..a730dd5 100644
--- a/noncore/settings/networksettings/mainwindow.ui
+++ b/noncore/settings/networksettings/mainwindow.ui
@@ -1,427 +1,451 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>MainWindow</class> 2<class>MainWindow</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>MainWindow</cstring> 7 <cstring>MainWindow</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>240</width> 14 <width>240</width>
15 <height>289</height> 15 <height>289</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>Network Settings</string> 20 <string>Network Settings</string>
21 </property> 21 </property>
22 <vbox> 22 <vbox>
23 <property stdset="1"> 23 <property stdset="1">
24 <name>margin</name> 24 <name>margin</name>
25 <number>0</number> 25 <number>0</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> 31 <widget>
32 <class>QTabWidget</class> 32 <class>QTabWidget</class>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>name</name> 34 <name>name</name>
35 <cstring>tabWidget</cstring> 35 <cstring>tabWidget</cstring>
36 </property> 36 </property>
37 <property stdset="1">
38 <name>enabled</name>
39 <bool>true</bool>
40 </property>
37 <property> 41 <property>
38 <name>layoutMargin</name> 42 <name>layoutMargin</name>
39 </property> 43 </property>
40 <widget> 44 <widget>
41 <class>QWidget</class> 45 <class>QWidget</class>
42 <property stdset="1"> 46 <property stdset="1">
43 <name>name</name> 47 <name>name</name>
44 <cstring>Widget3</cstring> 48 <cstring>Widget3</cstring>
45 </property> 49 </property>
46 <attribute> 50 <attribute>
47 <name>title</name> 51 <name>title</name>
48 <string>Connections</string> 52 <string>Connections</string>
49 </attribute> 53 </attribute>
50 <vbox> 54 <vbox>
51 <property stdset="1"> 55 <property stdset="1">
52 <name>margin</name> 56 <name>margin</name>
53 <number>0</number> 57 <number>0</number>
54 </property> 58 </property>
55 <property stdset="1"> 59 <property stdset="1">
56 <name>spacing</name> 60 <name>spacing</name>
57 <number>6</number> 61 <number>6</number>
58 </property> 62 </property>
59 <widget> 63 <widget>
60 <class>QListView</class> 64 <class>QListView</class>
61 <column> 65 <column>
62 <property> 66 <property>
63 <name>text</name> 67 <name>text</name>
64 <string>s</string> 68 <string>s</string>
65 </property> 69 </property>
66 <property> 70 <property>
67 <name>clickable</name> 71 <name>clickable</name>
68 <bool>true</bool> 72 <bool>true</bool>
69 </property> 73 </property>
70 <property> 74 <property>
71 <name>resizeable</name> 75 <name>resizeable</name>
72 <bool>true</bool> 76 <bool>true</bool>
73 </property> 77 </property>
74 </column> 78 </column>
75 <column> 79 <column>
76 <property> 80 <property>
77 <name>text</name> 81 <name>text</name>
78 <string>t</string> 82 <string>t</string>
79 </property> 83 </property>
80 <property> 84 <property>
81 <name>clickable</name> 85 <name>clickable</name>
82 <bool>true</bool> 86 <bool>true</bool>
83 </property> 87 </property>
84 <property> 88 <property>
85 <name>resizeable</name> 89 <name>resizeable</name>
86 <bool>true</bool> 90 <bool>true</bool>
87 </property> 91 </property>
88 </column> 92 </column>
89 <column> 93 <column>
90 <property> 94 <property>
91 <name>text</name> 95 <name>text</name>
92 <string>Name</string> 96 <string>Name</string>
93 </property> 97 </property>
94 <property> 98 <property>
95 <name>clickable</name> 99 <name>clickable</name>
96 <bool>true</bool> 100 <bool>true</bool>
97 </property> 101 </property>
98 <property> 102 <property>
99 <name>resizeable</name> 103 <name>resizeable</name>
100 <bool>true</bool> 104 <bool>true</bool>
101 </property> 105 </property>
102 </column> 106 </column>
103 <column> 107 <column>
104 <property> 108 <property>
105 <name>text</name> 109 <name>text</name>
106 <string>in</string> 110 <string>in</string>
107 </property> 111 </property>
108 <property> 112 <property>
109 <name>clickable</name> 113 <name>clickable</name>
110 <bool>true</bool> 114 <bool>true</bool>
111 </property> 115 </property>
112 <property> 116 <property>
113 <name>resizeable</name> 117 <name>resizeable</name>
114 <bool>true</bool> 118 <bool>true</bool>
115 </property> 119 </property>
116 </column> 120 </column>
117 <column> 121 <column>
118 <property> 122 <property>
119 <name>text</name> 123 <name>text</name>
120 <string>IP</string> 124 <string>IP</string>
121 </property> 125 </property>
122 <property> 126 <property>
123 <name>clickable</name> 127 <name>clickable</name>
124 <bool>true</bool> 128 <bool>true</bool>
125 </property> 129 </property>
126 <property> 130 <property>
127 <name>resizeable</name> 131 <name>resizeable</name>
128 <bool>true</bool> 132 <bool>true</bool>
129 </property> 133 </property>
130 </column> 134 </column>
131 <property stdset="1"> 135 <property stdset="1">
132 <name>name</name> 136 <name>name</name>
133 <cstring>connectionList</cstring> 137 <cstring>connectionList</cstring>
134 </property> 138 </property>
135 <property stdset="1"> 139 <property stdset="1">
136 <name>allColumnsShowFocus</name> 140 <name>allColumnsShowFocus</name>
137 <bool>true</bool> 141 <bool>true</bool>
138 </property> 142 </property>
143 <property>
144 <name>whatsThis</name>
145 <string>A list of network settings to be choosen from</string>
146 </property>
139 </widget> 147 </widget>
140 <widget> 148 <widget>
141 <class>QLayoutWidget</class> 149 <class>QLayoutWidget</class>
142 <property stdset="1"> 150 <property stdset="1">
143 <name>name</name> 151 <name>name</name>
144 <cstring>Layout2</cstring> 152 <cstring>Layout2</cstring>
145 </property> 153 </property>
146 <property> 154 <property>
147 <name>layoutMargin</name> 155 <name>layoutMargin</name>
148 </property> 156 </property>
149 <grid> 157 <grid>
150 <property stdset="1"> 158 <property stdset="1">
151 <name>margin</name> 159 <name>margin</name>
152 <number>5</number> 160 <number>5</number>
153 </property> 161 </property>
154 <property stdset="1"> 162 <property stdset="1">
155 <name>spacing</name> 163 <name>spacing</name>
156 <number>6</number> 164 <number>6</number>
157 </property> 165 </property>
158 <widget row="1" column="0" > 166 <widget row="1" column="0" >
159 <class>QPushButton</class> 167 <class>QPushButton</class>
160 <property stdset="1"> 168 <property stdset="1">
161 <name>name</name> 169 <name>name</name>
162 <cstring>addConnectionButton</cstring> 170 <cstring>addConnectionButton</cstring>
163 </property> 171 </property>
164 <property stdset="1"> 172 <property stdset="1">
165 <name>text</name> 173 <name>text</name>
166 <string>&amp;Add</string> 174 <string>&amp;Add</string>
167 </property> 175 </property>
176 <property>
177 <name>whatsThis</name>
178 <string>Add a new interface to the list.</string>
179 </property>
168 </widget> 180 </widget>
169 <widget row="0" column="0" > 181 <widget row="0" column="0" >
170 <class>QPushButton</class> 182 <class>QPushButton</class>
171 <property stdset="1"> 183 <property stdset="1">
172 <name>name</name> 184 <name>name</name>
173 <cstring>informationConnectionButton</cstring> 185 <cstring>informationConnectionButton</cstring>
174 </property> 186 </property>
175 <property stdset="1"> 187 <property stdset="1">
176 <name>text</name> 188 <name>text</name>
177 <string>&amp;Start/Stop</string> 189 <string>&amp;Start/Stop</string>
178 </property> 190 </property>
191 <property>
192 <name>whatsThis</name>
193 <string>Start and Stop the current interface, gives additional information about the interface.</string>
194 </property>
179 </widget> 195 </widget>
180 <widget row="0" column="1" > 196 <widget row="0" column="1" >
181 <class>QPushButton</class> 197 <class>QPushButton</class>
182 <property stdset="1"> 198 <property stdset="1">
183 <name>name</name> 199 <name>name</name>
184 <cstring>configureConnectionButton</cstring> 200 <cstring>configureConnectionButton</cstring>
185 </property> 201 </property>
186 <property stdset="1"> 202 <property stdset="1">
187 <name>text</name> 203 <name>text</name>
188 <string>&amp;Configure</string> 204 <string>&amp;Configure</string>
189 </property> 205 </property>
206 <property>
207 <name>whatsThis</name>
208 <string>Configure the current interface</string>
209 </property>
190 </widget> 210 </widget>
191 <widget row="1" column="1" > 211 <widget row="1" column="1" >
192 <class>QPushButton</class> 212 <class>QPushButton</class>
193 <property stdset="1"> 213 <property stdset="1">
194 <name>name</name> 214 <name>name</name>
195 <cstring>removeConnectionButton</cstring> 215 <cstring>removeConnectionButton</cstring>
196 </property> 216 </property>
197 <property stdset="1"> 217 <property stdset="1">
198 <name>text</name> 218 <name>text</name>
199 <string>&amp;Remove</string> 219 <string>&amp;Remove</string>
200 </property> 220 </property>
221 <property>
222 <name>whatsThis</name>
223 <string>Remove the current interface from the list.</string>
224 </property>
201 </widget> 225 </widget>
202 </grid> 226 </grid>
203 </widget> 227 </widget>
204 </vbox> 228 </vbox>
205 </widget> 229 </widget>
206 <widget> 230 <widget>
207 <class>QWidget</class> 231 <class>QWidget</class>
208 <property stdset="1"> 232 <property stdset="1">
209 <name>name</name> 233 <name>name</name>
210 <cstring>tab</cstring> 234 <cstring>tab</cstring>
211 </property> 235 </property>
212 <attribute> 236 <attribute>
213 <name>title</name> 237 <name>title</name>
214 <string>Profiles</string> 238 <string>Profiles</string>
215 </attribute> 239 </attribute>
216 <grid> 240 <grid>
217 <property stdset="1"> 241 <property stdset="1">
218 <name>margin</name> 242 <name>margin</name>
219 <number>11</number> 243 <number>11</number>
220 </property> 244 </property>
221 <property stdset="1"> 245 <property stdset="1">
222 <name>spacing</name> 246 <name>spacing</name>
223 <number>6</number> 247 <number>6</number>
224 </property> 248 </property>
225 <spacer row="7" column="2" > 249 <spacer row="7" column="2" >
226 <property> 250 <property>
227 <name>name</name> 251 <name>name</name>
228 <cstring>Spacer16</cstring> 252 <cstring>Spacer16</cstring>
229 </property> 253 </property>
230 <property stdset="1"> 254 <property stdset="1">
231 <name>orientation</name> 255 <name>orientation</name>
232 <enum>Vertical</enum> 256 <enum>Vertical</enum>
233 </property> 257 </property>
234 <property stdset="1"> 258 <property stdset="1">
235 <name>sizeType</name> 259 <name>sizeType</name>
236 <enum>Expanding</enum> 260 <enum>Expanding</enum>
237 </property> 261 </property>
238 <property> 262 <property>
239 <name>sizeHint</name> 263 <name>sizeHint</name>
240 <size> 264 <size>
241 <width>20</width> 265 <width>20</width>
242 <height>20</height> 266 <height>20</height>
243 </size> 267 </size>
244 </property> 268 </property>
245 </spacer> 269 </spacer>
246 <widget row="0" column="1" > 270 <widget row="0" column="1" >
247 <class>QLabel</class> 271 <class>QLabel</class>
248 <property stdset="1"> 272 <property stdset="1">
249 <name>name</name> 273 <name>name</name>
250 <cstring>currentProfileLabel</cstring> 274 <cstring>currentProfileLabel</cstring>
251 </property> 275 </property>
252 <property stdset="1"> 276 <property stdset="1">
253 <name>frameShape</name> 277 <name>frameShape</name>
254 <enum>Panel</enum> 278 <enum>Panel</enum>
255 </property> 279 </property>
256 <property stdset="1"> 280 <property stdset="1">
257 <name>frameShadow</name> 281 <name>frameShadow</name>
258 <enum>Sunken</enum> 282 <enum>Sunken</enum>
259 </property> 283 </property>
260 <property stdset="1"> 284 <property stdset="1">
261 <name>text</name> 285 <name>text</name>
262 <string>All</string> 286 <string>All</string>
263 </property> 287 </property>
264 </widget> 288 </widget>
265 <widget row="3" column="2" > 289 <widget row="3" column="2" >
266 <class>QPushButton</class> 290 <class>QPushButton</class>
267 <property stdset="1"> 291 <property stdset="1">
268 <name>name</name> 292 <name>name</name>
269 <cstring>setCurrentProfileButton</cstring> 293 <cstring>setCurrentProfileButton</cstring>
270 </property> 294 </property>
271 <property stdset="1"> 295 <property stdset="1">
272 <name>text</name> 296 <name>text</name>
273 <string>&amp;Set Current</string> 297 <string>&amp;Set Current</string>
274 </property> 298 </property>
275 </widget> 299 </widget>
276 <widget row="5" column="0" rowspan="1" colspan="3" > 300 <widget row="5" column="0" rowspan="1" colspan="3" >
277 <class>Line</class> 301 <class>Line</class>
278 <property stdset="1"> 302 <property stdset="1">
279 <name>name</name> 303 <name>name</name>
280 <cstring>Line6</cstring> 304 <cstring>Line6</cstring>
281 </property> 305 </property>
282 <property stdset="1"> 306 <property stdset="1">
283 <name>orientation</name> 307 <name>orientation</name>
284 <enum>Horizontal</enum> 308 <enum>Horizontal</enum>
285 </property> 309 </property>
286 </widget> 310 </widget>
287 <widget row="1" column="0" rowspan="1" colspan="3" > 311 <widget row="1" column="0" rowspan="1" colspan="3" >
288 <class>Line</class> 312 <class>Line</class>
289 <property stdset="1"> 313 <property stdset="1">
290 <name>name</name> 314 <name>name</name>
291 <cstring>Line1</cstring> 315 <cstring>Line1</cstring>
292 </property> 316 </property>
293 <property stdset="1"> 317 <property stdset="1">
294 <name>orientation</name> 318 <name>orientation</name>
295 <enum>Horizontal</enum> 319 <enum>Horizontal</enum>
296 </property> 320 </property>
297 </widget> 321 </widget>
298 <widget row="0" column="0" > 322 <widget row="0" column="0" >
299 <class>QLabel</class> 323 <class>QLabel</class>
300 <property stdset="1"> 324 <property stdset="1">
301 <name>name</name> 325 <name>name</name>
302 <cstring>TextLabel1</cstring> 326 <cstring>TextLabel1</cstring>
303 </property> 327 </property>
304 <property stdset="1"> 328 <property stdset="1">
305 <name>text</name> 329 <name>text</name>
306 <string>Current Profile</string> 330 <string>Current Profile</string>
307 </property> 331 </property>
308 </widget> 332 </widget>
309 <widget row="4" column="2" > 333 <widget row="4" column="2" >
310 <class>QPushButton</class> 334 <class>QPushButton</class>
311 <property stdset="1"> 335 <property stdset="1">
312 <name>name</name> 336 <name>name</name>
313 <cstring>removeProfileButton</cstring> 337 <cstring>removeProfileButton</cstring>
314 </property> 338 </property>
315 <property stdset="1"> 339 <property stdset="1">
316 <name>text</name> 340 <name>text</name>
317 <string>&amp;Remove</string> 341 <string>&amp;Remove</string>
318 </property> 342 </property>
319 </widget> 343 </widget>
320 <widget row="3" column="0" rowspan="2" colspan="2" > 344 <widget row="3" column="0" rowspan="2" colspan="2" >
321 <class>QListBox</class> 345 <class>QListBox</class>
322 <property stdset="1"> 346 <property stdset="1">
323 <name>name</name> 347 <name>name</name>
324 <cstring>profilesList</cstring> 348 <cstring>profilesList</cstring>
325 </property> 349 </property>
326 </widget> 350 </widget>
327 <spacer row="0" column="2" > 351 <spacer row="0" column="2" >
328 <property> 352 <property>
329 <name>name</name> 353 <name>name</name>
330 <cstring>Spacer2</cstring> 354 <cstring>Spacer2</cstring>
331 </property> 355 </property>
332 <property stdset="1"> 356 <property stdset="1">
333 <name>orientation</name> 357 <name>orientation</name>
334 <enum>Horizontal</enum> 358 <enum>Horizontal</enum>
335 </property> 359 </property>
336 <property stdset="1"> 360 <property stdset="1">
337 <name>sizeType</name> 361 <name>sizeType</name>
338 <enum>Expanding</enum> 362 <enum>Expanding</enum>
339 </property> 363 </property>
340 <property> 364 <property>
341 <name>sizeHint</name> 365 <name>sizeHint</name>
342 <size> 366 <size>
343 <width>20</width> 367 <width>20</width>
344 <height>20</height> 368 <height>20</height>
345 </size> 369 </size>
346 </property> 370 </property>
347 </spacer> 371 </spacer>
348 <widget row="2" column="0" > 372 <widget row="2" column="0" >
349 <class>QLabel</class> 373 <class>QLabel</class>
350 <property stdset="1"> 374 <property stdset="1">
351 <name>name</name> 375 <name>name</name>
352 <cstring>TextLabel1_2</cstring> 376 <cstring>TextLabel1_2</cstring>
353 </property> 377 </property>
354 <property stdset="1"> 378 <property stdset="1">
355 <name>text</name> 379 <name>text</name>
356 <string>Profiles</string> 380 <string>Profiles</string>
357 </property> 381 </property>
358 </widget> 382 </widget>
359 <widget row="6" column="0" rowspan="1" colspan="3" > 383 <widget row="6" column="0" rowspan="1" colspan="3" >
360 <class>QLayoutWidget</class> 384 <class>QLayoutWidget</class>
361 <property stdset="1"> 385 <property stdset="1">
362 <name>name</name> 386 <name>name</name>
363 <cstring>Layout6</cstring> 387 <cstring>Layout6</cstring>
364 </property> 388 </property>
365 <hbox> 389 <hbox>
366 <property stdset="1"> 390 <property stdset="1">
367 <name>margin</name> 391 <name>margin</name>
368 <number>0</number> 392 <number>0</number>
369 </property> 393 </property>
370 <property stdset="1"> 394 <property stdset="1">
371 <name>spacing</name> 395 <name>spacing</name>
372 <number>6</number> 396 <number>6</number>
373 </property> 397 </property>
374 <widget> 398 <widget>
375 <class>QLabel</class> 399 <class>QLabel</class>
376 <property stdset="1"> 400 <property stdset="1">
377 <name>name</name> 401 <name>name</name>
378 <cstring>TextLabel1_3</cstring> 402 <cstring>TextLabel1_3</cstring>
379 </property> 403 </property>
380 <property stdset="1"> 404 <property stdset="1">
381 <name>text</name> 405 <name>text</name>
382 <string>New Profile</string> 406 <string>New Profile</string>
383 </property> 407 </property>
384 </widget> 408 </widget>
385 <widget> 409 <widget>
386 <class>QLineEdit</class> 410 <class>QLineEdit</class>
387 <property stdset="1"> 411 <property stdset="1">
388 <name>name</name> 412 <name>name</name>
389 <cstring>newProfile</cstring> 413 <cstring>newProfile</cstring>
390 </property> 414 </property>
391 </widget> 415 </widget>
392 <widget> 416 <widget>
393 <class>QPushButton</class> 417 <class>QPushButton</class>
394 <property stdset="1"> 418 <property stdset="1">
395 <name>name</name> 419 <name>name</name>
396 <cstring>newProfileButton</cstring> 420 <cstring>newProfileButton</cstring>
397 </property> 421 </property>
398 <property stdset="1"> 422 <property stdset="1">
399 <name>enabled</name> 423 <name>enabled</name>
400 <bool>false</bool> 424 <bool>false</bool>
401 </property> 425 </property>
402 <property stdset="1"> 426 <property stdset="1">
403 <name>text</name> 427 <name>text</name>
404 <string>&amp;Add</string> 428 <string>&amp;Add</string>
405 </property> 429 </property>
406 </widget> 430 </widget>
407 </hbox> 431 </hbox>
408 </widget> 432 </widget>
409 </grid> 433 </grid>
410 </widget> 434 </widget>
411 </widget> 435 </widget>
412 </vbox> 436 </vbox>
413</widget> 437</widget>
414<tabstops> 438<tabstops>
415 <tabstop>tabWidget</tabstop> 439 <tabstop>tabWidget</tabstop>
416 <tabstop>connectionList</tabstop> 440 <tabstop>connectionList</tabstop>
417 <tabstop>informationConnectionButton</tabstop> 441 <tabstop>informationConnectionButton</tabstop>
418 <tabstop>configureConnectionButton</tabstop> 442 <tabstop>configureConnectionButton</tabstop>
419 <tabstop>addConnectionButton</tabstop> 443 <tabstop>addConnectionButton</tabstop>
420 <tabstop>removeConnectionButton</tabstop> 444 <tabstop>removeConnectionButton</tabstop>
421 <tabstop>profilesList</tabstop> 445 <tabstop>profilesList</tabstop>
422 <tabstop>setCurrentProfileButton</tabstop> 446 <tabstop>setCurrentProfileButton</tabstop>
423 <tabstop>removeProfileButton</tabstop> 447 <tabstop>removeProfileButton</tabstop>
424 <tabstop>newProfile</tabstop> 448 <tabstop>newProfile</tabstop>
425 <tabstop>newProfileButton</tabstop> 449 <tabstop>newProfileButton</tabstop>
426</tabstops> 450</tabstops>
427</UI> 451</UI>
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 63b9603..abf5663 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,621 +1,627 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interfaces.h" 5#include "interfaces.h"
6#include "module.h" 6#include "module.h"
7 7
8#include <qpushbutton.h> 8#include <qpushbutton.h>
9#include <qlistbox.h> 9#include <qlistbox.h>
10#include <qlineedit.h> 10#include <qlineedit.h>
11#include <qlistview.h> 11#include <qlistview.h>
12#include <qheader.h> 12#include <qheader.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qtabwidget.h> // in order to disable the profiles tab
14 15
15#include <qmessagebox.h> 16#include <qmessagebox.h>
16 17
17#ifdef QWS 18#ifdef QWS
18 #include <qpe/config.h> 19 #include <qpe/config.h>
19 #include <qpe/qlibrary.h> 20 #include <qpe/qlibrary.h>
20 #include <qpe/resource.h> 21 #include <qpe/resource.h>
21 #include <qpe/qpeapplication.h> 22 #include <qpe/qpeapplication.h>
22#else 23#else
23 #include <klibloader.h> 24 #include <klibloader.h>
24 #define QLibrary KLibrary 25 #define QLibrary KLibrary
25 #include <kconfig.h> 26 #include <kconfig.h>
26 #define Config KConfig 27 #define Config KConfig
27 #include <kapplication.h> 28 #include <kapplication.h>
28 #include <kstandarddirs.h> 29 #include <kstandarddirs.h>
29 #include <kiconloader.h> 30 #include <kiconloader.h>
30 #define showMaximized show 31 #define showMaximized show
31#endif 32#endif
32 33
33#if QT_VERSION < 300 34#if QT_VERSION < 300
34#include <qlist.h> 35#include <qlist.h>
35#else 36#else
36#include <qptrlist.h> 37#include <qptrlist.h>
37#endif 38#endif
38#include <qdir.h> 39#include <qdir.h>
39#include <qfile.h> 40#include <qfile.h>
40#include <qtextstream.h> 41#include <qtextstream.h>
41#include <qregexp.h> 42#include <qregexp.h>
42 43
43#include <net/if.h> 44#include <net/if.h>
44#include <sys/ioctl.h> 45#include <sys/ioctl.h>
45#include <sys/socket.h> 46#include <sys/socket.h>
46 47
47#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 48#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
48#define _PROCNETDEV "/proc/net/dev" 49#define _PROCNETDEV "/proc/net/dev"
49 50
50MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ 51MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){
51 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 52 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
52 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 53 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
53 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 54 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
54 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 55 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
55 56
56 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 57 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
57 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 58 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
58 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 59 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
59 60
60 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 61 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
62
63 //FIXME: disable profiles for the moment:
64 tabWidget->setTabEnabled( tab, false );
65
61 // Load connections. 66 // Load connections.
62 // /usr/local/kde/lib/libinterfaces.la 67 // /usr/local/kde/lib/libinterfaces.la
63#ifdef QWS 68#ifdef QWS
64 loadModules(QPEApplication::qpeDir() + "/plugins/networksettings"); 69 loadModules(QPEApplication::qpeDir() + "/plugins/networksettings");
65#else 70#else
66 loader = KLibLoader::self(); 71 loader = KLibLoader::self();
67 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); 72 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
68#endif 73#endif
69 getAllInterfaces(); 74 getAllInterfaces();
70 75
71 Interfaces i; 76 Interfaces i;
72 QStringList list = i.getInterfaceList(); 77 QStringList list = i.getInterfaceList();
73 QMap<QString, Interface*>::Iterator it; 78 QMap<QString, Interface*>::Iterator it;
74 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 79 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
75 bool found = false; 80 bool found = false;
76 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 81 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
77 if(it.key() == (*ni)) 82 if(it.key() == (*ni))
78 found = true; 83 found = true;
79 } 84 }
80 if(!found){ 85 if(!found){
81 if(!(*ni).contains("_")){ 86 if(!(*ni).contains("_")){
82 Interface *i = new Interface(this, *ni, false); 87 Interface *i = new Interface(this, *ni, false);
83 i->setAttached(false); 88 i->setAttached(false);
84 i->setHardwareName("Disconnected"); 89 i->setHardwareName("Disconnected");
85 interfaceNames.insert(i->getInterfaceName(), i); 90 interfaceNames.insert(i->getInterfaceName(), i);
86 updateInterface(i); 91 updateInterface(i);
87 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 92 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
88 } 93 }
89 } 94 }
90 } 95 }
91 96
92 //getInterfaceList(); 97 //getInterfaceList();
93 connectionList->header()->hide(); 98 connectionList->header()->hide();
94 99
95 Config cfg("NetworkSetup"); 100 Config cfg("NetworkSetup");
96 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 101 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
97 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 102 for ( QStringList::Iterator it = profiles.begin();
98 profilesList->insertItem((*it)); 103 it != profiles.end(); ++it)
104 profilesList->insertItem((*it));
99 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); 105 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
100 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 106 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
101 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); 107 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
102 108
103 QFile file(scheme); 109 QFile file(scheme);
104 if ( file.open(IO_ReadOnly) ) { // file opened successfully 110 if ( file.open(IO_ReadOnly) ) { // file opened successfully
105 QTextStream stream( &file ); // use a text stream 111 QTextStream stream( &file ); // use a text stream
106 while ( !stream.eof() ) { // until end of file... 112 while ( !stream.eof() ) { // until end of file...
107 QString line = stream.readLine(); // line of text excluding '\n' 113 QString line = stream.readLine(); // line of text excluding '\n'
108 if(line.contains("SCHEME")){ 114 if(line.contains("SCHEME")){
109 line = line.mid(7, line.length()); 115 line = line.mid(7, line.length());
110 currentProfileLabel->setText(line); 116 currentProfileLabel->setText(line);
111 break; 117 break;
112 } 118 }
113 } 119 }
114 file.close(); 120 file.close();
115 } 121 }
116} 122}
117 123
118/** 124/**
119 * Deconstructor. Save profiles. Delete loaded libraries. 125 * Deconstructor. Save profiles. Delete loaded libraries.
120 */ 126 */
121MainWindowImp::~MainWindowImp(){ 127MainWindowImp::~MainWindowImp(){
122 // Save profiles. 128 // Save profiles.
123 Config cfg("NetworkSetup"); 129 Config cfg("NetworkSetup");
124 cfg.setGroup("General"); 130 cfg.setGroup("General");
125 cfg.writeEntry("Profiles", profiles.join(" ")); 131 cfg.writeEntry("Profiles", profiles.join(" "));
126 132
127 // Delete all interfaces that don't have owners. 133 // Delete all interfaces that don't have owners.
128 QMap<Interface*, QListViewItem*>::Iterator iIt; 134 QMap<Interface*, QListViewItem*>::Iterator iIt;
129 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 135 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
130 if(iIt.key()->getModuleOwner() == NULL) 136 if(iIt.key()->getModuleOwner() == NULL)
131 delete iIt.key(); 137 delete iIt.key();
132 } 138 }
133 139
134#ifdef QWS 140#ifdef QWS
135 // Delete Modules and Libraries 141 // Delete Modules and Libraries
136 QMap<Module*, QLibrary*>::Iterator it; 142 QMap<Module*, QLibrary*>::Iterator it;
137 for( it = libraries.begin(); it != libraries.end(); ++it ){ 143 for( it = libraries.begin(); it != libraries.end(); ++it ){
138 delete it.key(); 144 delete it.key();
139 // I wonder why I can't delete the libraries 145 // I wonder why I can't delete the libraries
140 // What fucking shit this is. 146 // What fucking shit this is.
141 //delete it.data(); 147 //delete it.data();
142 } 148 }
143#else 149#else
144 // klibloader automaticly deletes the libraries for us... 150 // klibloader automaticly deletes the libraries for us...
145#endif 151#endif
146} 152}
147 153
148/** 154/**
149 * Query the kernel for all of the interfaces. 155 * Query the kernel for all of the interfaces.
150 */ 156 */
151void MainWindowImp::getAllInterfaces(){ 157void MainWindowImp::getAllInterfaces(){
152 int sockfd = socket(PF_INET, SOCK_DGRAM, 0); 158 int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
153 if(sockfd == -1) 159 if(sockfd == -1)
154 return; 160 return;
155 161
156 struct ifreq ifr; 162 struct ifreq ifr;
157 QStringList ifaces; 163 QStringList ifaces;
158 QFile procFile(QString(_PROCNETDEV)); 164 QFile procFile(QString(_PROCNETDEV));
159 int result; 165 int result;
160 Interface *i; 166 Interface *i;
161 167
162 if (! procFile.exists()) { 168 if (! procFile.exists()) {
163 struct ifreq ifrs[100]; 169 struct ifreq ifrs[100];
164 struct ifconf ifc; 170 struct ifconf ifc;
165 ifc.ifc_len = sizeof(ifrs); 171 ifc.ifc_len = sizeof(ifrs);
166 ifc.ifc_req = ifrs; 172 ifc.ifc_req = ifrs;
167 result = ioctl(sockfd, SIOCGIFCONF, &ifc); 173 result = ioctl(sockfd, SIOCGIFCONF, &ifc);
168 174
169 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { 175 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) {
170 struct ifreq *pifr = &ifrs[i]; 176 struct ifreq *pifr = &ifrs[i];
171 177
172 ifaces += pifr->ifr_name; 178 ifaces += pifr->ifr_name;
173 } 179 }
174 } else { 180 } else {
175 procFile.open(IO_ReadOnly); 181 procFile.open(IO_ReadOnly);
176 QString line; 182 QString line;
177 QTextStream procTs(&procFile); 183 QTextStream procTs(&procFile);
178 int loc = -1; 184 int loc = -1;
179 185
180 procTs.readLine(); // eat a line 186 procTs.readLine(); // eat a line
181 procTs.readLine(); // eat a line 187 procTs.readLine(); // eat a line
182 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { 188 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
183 if((loc = line.find(":")) != -1) { 189 if((loc = line.find(":")) != -1) {
184 ifaces += line.left(loc); 190 ifaces += line.left(loc);
185 } 191 }
186 } 192 }
187 } 193 }
188 194
189 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { 195 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) {
190 int flags = 0, family; 196 int flags = 0, family;
191 i = NULL; 197 i = NULL;
192 198
193 strcpy(ifr.ifr_name, (*it).latin1()); 199 strcpy(ifr.ifr_name, (*it).latin1());
194 200
195 struct ifreq ifcopy; 201 struct ifreq ifcopy;
196 ifcopy = ifr; 202 ifcopy = ifr;
197 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); 203 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
198 flags = ifcopy.ifr_flags; 204 flags = ifcopy.ifr_flags;
199 i = new Interface(this, ifr.ifr_name, false); 205 i = new Interface(this, ifr.ifr_name, false);
200 i->setAttached(true); 206 i->setAttached(true);
201 if ((flags & IFF_UP) == IFF_UP) 207 if ((flags & IFF_UP) == IFF_UP)
202 i->setStatus(true); 208 i->setStatus(true);
203 else 209 else
204 i->setStatus(false); 210 i->setStatus(false);
205 211
206 if ((flags & IFF_BROADCAST) == IFF_BROADCAST) 212 if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
207 i->setHardwareName("Ethernet"); 213 i->setHardwareName("Ethernet");
208 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) 214 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
209 i->setHardwareName("Point to Point"); 215 i->setHardwareName("Point to Point");
210 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) 216 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
211 i->setHardwareName("Multicast"); 217 i->setHardwareName("Multicast");
212 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) 218 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
213 i->setHardwareName("Loopback"); 219 i->setHardwareName("Loopback");
214 else 220 else
215 i->setHardwareName("Unknown"); 221 i->setHardwareName("Unknown");
216 222
217 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); 223 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
218 interfaceNames.insert(i->getInterfaceName(), i); 224 interfaceNames.insert(i->getInterfaceName(), i);
219 updateInterface(i); 225 updateInterface(i);
220 connect(i, SIGNAL(updateInterface(Interface *)), 226 connect(i, SIGNAL(updateInterface(Interface *)),
221 this, SLOT(updateInterface(Interface *))); 227 this, SLOT(updateInterface(Interface *)));
222 } 228 }
223 // now lets ask the plugins too ;) 229 // now lets ask the plugins too ;)
224 QMap<Module*, QLibrary*>::Iterator it; 230 QMap<Module*, QLibrary*>::Iterator it;
225 QList<Interface> ilist; 231 QList<Interface> ilist;
226 for( it = libraries.begin(); it != libraries.end(); ++it ){ 232 for( it = libraries.begin(); it != libraries.end(); ++it ){
227 if(it.key()){ 233 if(it.key()){
228 ilist = it.key()->getInterfaces(); 234 ilist = it.key()->getInterfaces();
229 for( i = ilist.first(); i != 0; i = ilist.next() ){ 235 for( i = ilist.first(); i != 0; i = ilist.next() ){
230 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); 236 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() );
231 interfaceNames.insert(i->getInterfaceName(), i); 237 interfaceNames.insert(i->getInterfaceName(), i);
232 updateInterface(i); 238 updateInterface(i);
233 connect(i, SIGNAL(updateInterface(Interface *)), 239 connect(i, SIGNAL(updateInterface(Interface *)),
234 this, SLOT(updateInterface(Interface *))); 240 this, SLOT(updateInterface(Interface *)));
235 } 241 }
236 } 242 }
237 } 243 }
238} 244}
239 245
240/** 246/**
241 * Load all modules that are found in the path 247 * Load all modules that are found in the path
242 * @param path a directory that is scaned for any plugins that can be loaded 248 * @param path a directory that is scaned for any plugins that can be loaded
243 * and attempts to load them 249 * and attempts to load them
244 */ 250 */
245void MainWindowImp::loadModules(const QString &path){ 251void MainWindowImp::loadModules(const QString &path){
246#ifdef DEBUG 252#ifdef DEBUG
247 qDebug("MainWindowImp::loadModules: %s", path.latin1()); 253 qDebug("MainWindowImp::loadModules: %s", path.latin1());
248#endif 254#endif
249 QDir d(path); 255 QDir d(path);
250 if(!d.exists()) 256 if(!d.exists())
251 return; 257 return;
252 258
253 // Don't want sym links 259 // Don't want sym links
254 d.setFilter( QDir::Files | QDir::NoSymLinks ); 260 d.setFilter( QDir::Files | QDir::NoSymLinks );
255 const QFileInfoList *list = d.entryInfoList(); 261 const QFileInfoList *list = d.entryInfoList();
256 QFileInfoListIterator it( *list ); 262 QFileInfoListIterator it( *list );
257 QFileInfo *fi; 263 QFileInfo *fi;
258 while ( (fi=it.current()) ) { 264 while ( (fi=it.current()) ) {
259#ifdef QWS 265#ifdef QWS
260 if(fi->fileName().contains(".so")){ 266 if(fi->fileName().contains(".so")){
261#else 267#else
262 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ 268 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){
263#endif 269#endif
264 loadPlugin(path + "/" + fi->fileName()); 270 loadPlugin(path + "/" + fi->fileName());
265 qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); 271 qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1());
266 } 272 }
267 ++it; 273 ++it;
268 } 274 }
269} 275}
270 276
271/** 277/**
272 * Attempt to load a function and resolve a function. 278 * Attempt to load a function and resolve a function.
273 * @param pluginFileName - the name of the file in which to attempt to load 279 * @param pluginFileName - the name of the file in which to attempt to load
274 * @param resolveString - function pointer to resolve 280 * @param resolveString - function pointer to resolve
275 * @return pointer to the function with name resolveString or NULL 281 * @return pointer to the function with name resolveString or NULL
276 */ 282 */
277Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ 283Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
278#ifdef DEBUG 284#ifdef DEBUG
279 qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); 285 qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1());
280#endif 286#endif
281#ifdef QWS 287#ifdef QWS
282 QLibrary *lib = new QLibrary(pluginFileName); 288 QLibrary *lib = new QLibrary(pluginFileName);
283 void *functionPointer = lib->resolve(resolveString); 289 void *functionPointer = lib->resolve(resolveString);
284 if( !functionPointer ){ 290 if( !functionPointer ){
285#ifdef DEBUG 291#ifdef DEBUG
286 qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); 292 qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1());
287#endif 293#endif
288 delete lib; 294 delete lib;
289 return NULL; 295 return NULL;
290 } 296 }
291 // Try to get an object. 297 // Try to get an object.
292 Module *object = ((Module* (*)()) functionPointer)(); 298 Module *object = ((Module* (*)()) functionPointer)();
293 if(object == NULL){ 299 if(object == NULL){
294#ifdef DEBUG 300#ifdef DEBUG
295 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 301 qDebug("MainWindowImp: Couldn't create object, but did load library!");
296#endif 302#endif
297 delete lib; 303 delete lib;
298 return NULL; 304 return NULL;
299 } 305 }
300 306
301 // Store for deletion later 307 // Store for deletion later
302 libraries.insert(object, lib); 308 libraries.insert(object, lib);
303 return object; 309 return object;
304 310
305#else 311#else
306 QLibrary *lib = loader->library(pluginFileName); 312 QLibrary *lib = loader->library(pluginFileName);
307 if( !lib || !lib->hasSymbol(resolveString) ){ 313 if( !lib || !lib->hasSymbol(resolveString) ){
308 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 314 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
309 return NULL; 315 return NULL;
310 } 316 }
311 // Try to get an object. 317 // Try to get an object.
312 Module *object = ((Module* (*)()) lib->symbol(resolveString))(); 318 Module *object = ((Module* (*)()) lib->symbol(resolveString))();
313 if(object == NULL){ 319 if(object == NULL){
314#ifdef DEBUG 320#ifdef DEBUG
315 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 321 qDebug("MainWindowImp: Couldn't create object, but did load library!");
316#endif 322#endif
317 return NULL; 323 return NULL;
318 } 324 }
319#ifdef DEBUG 325#ifdef DEBUG
320 qDebug("MainWindowImp::loadPlugin:: Found object, storing."); 326 qDebug("MainWindowImp::loadPlugin:: Found object, storing.");
321#endif 327#endif
322 // Store for deletion later 328 // Store for deletion later
323 libraries.insert(object, lib); 329 libraries.insert(object, lib);
324 return object; 330 return object;
325#endif 331#endif
326} 332}
327 333
328/** 334/**
329 * The Add button was clicked. Bring up the add dialog and if OK is hit 335 * The Add button was clicked. Bring up the add dialog and if OK is hit
330 * load the plugin and append it to the list 336 * load the plugin and append it to the list
331 */ 337 */
332void MainWindowImp::addClicked(){ 338void MainWindowImp::addClicked(){
333 QMap<Module*, QLibrary*>::Iterator it; 339 QMap<Module*, QLibrary*>::Iterator it;
334 QMap<QString, QString> list; 340 QMap<QString, QString> list;
335 QMap<QString, Module*> newInterfaceOwners; 341 QMap<QString, Module*> newInterfaceOwners;
336 342
337 for( it = libraries.begin(); it != libraries.end(); ++it ){ 343 for( it = libraries.begin(); it != libraries.end(); ++it ){
338 if(it.key()){ 344 if(it.key()){
339 (it.key())->possibleNewInterfaces(list); 345 (it.key())->possibleNewInterfaces(list);
340 } 346 }
341 } 347 }
342 // See if the list has anything that we can add. 348 // See if the list has anything that we can add.
343 if(list.count() == 0){ 349 if(list.count() == 0){
344 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); 350 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
345 return; 351 return;
346 } 352 }
347 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 353 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
348 addNewConnection.addConnections(list); 354 addNewConnection.addConnections(list);
349 addNewConnection.showMaximized(); 355 addNewConnection.showMaximized();
350 if(QDialog::Accepted == addNewConnection.exec()){ 356 if(QDialog::Accepted == addNewConnection.exec()){
351 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 357 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
352 if(!item) 358 if(!item)
353 return; 359 return;
354 360
355 for( it = libraries.begin(); it != libraries.end(); ++it ){ 361 for( it = libraries.begin(); it != libraries.end(); ++it ){
356 if(it.key()){ 362 if(it.key()){
357 Interface *i = (it.key())->addNewInterface(item->text(0)); 363 Interface *i = (it.key())->addNewInterface(item->text(0));
358 if(i){ 364 if(i){
359 qDebug("iface name %s",i->getInterfaceName().latin1()); 365 qDebug("iface name %s",i->getInterfaceName().latin1());
360 interfaceNames.insert(i->getInterfaceName(), i); 366 interfaceNames.insert(i->getInterfaceName(), i);
361 updateInterface(i); 367 updateInterface(i);
362 } 368 }
363 } 369 }
364 } 370 }
365 } 371 }
366} 372}
367 373
368/** 374/**
369 * Prompt the user to see if they really want to do this. 375 * Prompt the user to see if they really want to do this.
370 * If they do then remove from the list and unload. 376 * If they do then remove from the list and unload.
371 */ 377 */
372void MainWindowImp::removeClicked(){ 378void MainWindowImp::removeClicked(){
373 QListViewItem *item = connectionList->currentItem(); 379 QListViewItem *item = connectionList->currentItem();
374 if(!item) { 380 if(!item) {
375 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 381 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
376 return; 382 return;
377 } 383 }
378 384
379 Interface *i = interfaceItems[item]; 385 Interface *i = interfaceItems[item];
380 if(i->getModuleOwner() == NULL){ 386 if(i->getModuleOwner() == NULL){
381 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); 387 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
382 } 388 }
383 else{ 389 else{
384 if(!i->getModuleOwner()->remove(i)) 390 if(!i->getModuleOwner()->remove(i))
385 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); 391 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok);
386 else{ 392 else{
387 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); 393 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
388 // TODO memory managment.... 394 // TODO memory managment....
389 // who deletes the interface? 395 // who deletes the interface?
390 } 396 }
391 } 397 }
392} 398}
393 399
394/** 400/**
395 * Pull up the configure about the currently selected interface. 401 * Pull up the configure about the currently selected interface.
396 * Report an error if no interface is selected. 402 * Report an error if no interface is selected.
397 * If the interface has a module owner then request its configure. 403 * If the interface has a module owner then request its configure.
398 */ 404 */
399void MainWindowImp::configureClicked(){ 405void MainWindowImp::configureClicked(){
400 QListViewItem *item = connectionList->currentItem(); 406 QListViewItem *item = connectionList->currentItem();
401 if(!item){ 407 if(!item){
402 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 408 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
403 return; 409 return;
404 } 410 }
405 411
406 QString currentProfileText = currentProfileLabel->text(); 412 QString currentProfileText = currentProfileLabel->text();
407 if(currentProfileText.upper() == "ALL"); 413 if(currentProfileText.upper() == "ALL");
408 currentProfileText = ""; 414 currentProfileText = "";
409 415
410 Interface *i = interfaceItems[item]; 416 Interface *i = interfaceItems[item];
411 417
412 if(i->getModuleOwner()){ 418 if(i->getModuleOwner()){
413 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 419 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
414 if(moduleConfigure != NULL){ 420 if(moduleConfigure != NULL){
415 i->getModuleOwner()->setProfile(currentProfileText); 421 i->getModuleOwner()->setProfile(currentProfileText);
416 moduleConfigure->showMaximized(); 422 moduleConfigure->showMaximized();
417 return; 423 return;
418 } 424 }
419 } 425 }
420 426
421 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); 427 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose );
422 configure->setProfile(currentProfileText); 428 configure->setProfile(currentProfileText);
423 configure->showMaximized(); 429 configure->showMaximized();
424} 430}
425 431
426/** 432/**
427 * Pull up the information about the currently selected interface. 433 * Pull up the information about the currently selected interface.
428 * Report an error if no interface is selected. 434 * Report an error if no interface is selected.
429 * If the interface has a module owner then request its configure. 435 * If the interface has a module owner then request its configure.
430 */ 436 */
431void MainWindowImp::informationClicked(){ 437void MainWindowImp::informationClicked(){
432 QListViewItem *item = connectionList->currentItem(); 438 QListViewItem *item = connectionList->currentItem();
433 if(!item){ 439 if(!item){
434 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 440 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
435 return; 441 return;
436 } 442 }
437 443
438 Interface *i = interfaceItems[item]; 444 Interface *i = interfaceItems[item];
439// if(!i->isAttached()){ 445// if(!i->isAttached()){
440// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 446// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
441// return; 447// return;
442// } 448// }
443 449
444 if(i->getModuleOwner()){ 450 if(i->getModuleOwner()){
445 QWidget *moduleInformation = i->getModuleOwner()->information(i); 451 QWidget *moduleInformation = i->getModuleOwner()->information(i);
446 if(moduleInformation != NULL){ 452 if(moduleInformation != NULL){
447 moduleInformation->showMaximized(); 453 moduleInformation->showMaximized();
448#ifdef DEBUG 454#ifdef DEBUG
449 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); 455 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed.");
450#endif 456#endif
451 return; 457 return;
452 } 458 }
453 } 459 }
454 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); 460 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
455 information->showMaximized(); 461 information->showMaximized();
456} 462}
457 463
458/** 464/**
459 * Update this interface. If no QListViewItem exists create one. 465 * Update this interface. If no QListViewItem exists create one.
460 * @param Interface* pointer to the interface that needs to be updated. 466 * @param Interface* pointer to the interface that needs to be updated.
461 */ 467 */
462void MainWindowImp::updateInterface(Interface *i){ 468void MainWindowImp::updateInterface(Interface *i){
463 if(!advancedUserMode){ 469 if(!advancedUserMode){
464 if(i->getInterfaceName() == "lo") 470 if(i->getInterfaceName() == "lo")
465 return; 471 return;
466 } 472 }
467 473
468 QListViewItem *item = NULL; 474 QListViewItem *item = NULL;
469 475
470 // Find the interface, making it if needed. 476 // Find the interface, making it if needed.
471 if(items.find(i) == items.end()){ 477 if(items.find(i) == items.end()){
472 item = new QListViewItem(connectionList, "", "", ""); 478 item = new QListViewItem(connectionList, "", "", "");
473 // See if you can't find a module owner for this interface 479 // See if you can't find a module owner for this interface
474 QMap<Module*, QLibrary*>::Iterator it; 480 QMap<Module*, QLibrary*>::Iterator it;
475 for( it = libraries.begin(); it != libraries.end(); ++it ){ 481 for( it = libraries.begin(); it != libraries.end(); ++it ){
476 if(it.key()->isOwner(i)) 482 if(it.key()->isOwner(i))
477 i->setModuleOwner(it.key()); 483 i->setModuleOwner(it.key());
478 } 484 }
479 items.insert(i, item); 485 items.insert(i, item);
480 interfaceItems.insert(item, i); 486 interfaceItems.insert(item, i);
481 } 487 }
482 else 488 else
483 item = items[i]; 489 item = items[i];
484 490
485 // Update the icons and information 491 // Update the icons and information
486#ifdef QWS 492#ifdef QWS
487 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 493 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
488#else 494#else
489 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); 495 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
490#endif 496#endif
491 497
492 QString typeName = "lan"; 498 QString typeName = "lan";
493 if(i->getHardwareName().contains("Local Loopback")) 499 if(i->getHardwareName().contains("Local Loopback"))
494 typeName = "lo"; 500 typeName = "lo";
495 if(i->getInterfaceName().contains("irda")) 501 if(i->getInterfaceName().contains("irda"))
496 typeName = "irda"; 502 typeName = "irda";
497 if(i->getInterfaceName().contains("wlan")) 503 if(i->getInterfaceName().contains("wlan"))
498 typeName = "wlan"; 504 typeName = "wlan";
499 if(i->getInterfaceName().contains("usb")) 505 if(i->getInterfaceName().contains("usb"))
500 typeName = "usb"; 506 typeName = "usb";
501 507
502 if(!i->isAttached()) 508 if(!i->isAttached())
503 typeName = "connect_no"; 509 typeName = "connect_no";
504 // Actually try to use the Module 510 // Actually try to use the Module
505 if(i->getModuleOwner() != NULL) 511 if(i->getModuleOwner() != NULL)
506 typeName = i->getModuleOwner()->getPixmapName(i); 512 typeName = i->getModuleOwner()->getPixmapName(i);
507 513
508#ifdef QWS 514#ifdef QWS
509 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); 515 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName)));
510#else 516#else
511 item->setPixmap(1, (SmallIcon(typeName))); 517 item->setPixmap(1, (SmallIcon(typeName)));
512#endif 518#endif
513 item->setText(2, i->getHardwareName()); 519 item->setText(2, i->getHardwareName());
514 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 520 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
515 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 521 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
516} 522}
517 523
518void MainWindowImp::newProfileChanged(const QString& newText){ 524void MainWindowImp::newProfileChanged(const QString& newText){
519 if(newText.length() > 0) 525 if(newText.length() > 0)
520 newProfileButton->setEnabled(true); 526 newProfileButton->setEnabled(true);
521 else 527 else
522 newProfileButton->setEnabled(false); 528 newProfileButton->setEnabled(false);
523} 529}
524 530
525/** 531/**
526 * Adds a new profile to the list of profiles. 532 * Adds a new profile to the list of profiles.
527 * Don't add profiles that already exists. 533 * Don't add profiles that already exists.
528 * Appends to the list and QStringList 534 * Appends to the list and QStringList
529 */ 535 */
530void MainWindowImp::addProfile(){ 536void MainWindowImp::addProfile(){
531 QString newProfileName = newProfile->text(); 537 QString newProfileName = newProfile->text();
532 if(profiles.grep(newProfileName).count() > 0){ 538 if(profiles.grep(newProfileName).count() > 0){
533 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); 539 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
534 return; 540 return;
535 } 541 }
536 profiles.append(newProfileName); 542 profiles.append(newProfileName);
537 profilesList->insertItem(newProfileName); 543 profilesList->insertItem(newProfileName);
538} 544}
539 545
540/** 546/**
541 * Removes the currently selected profile in the combo. 547 * Removes the currently selected profile in the combo.
542 * Doesn't delete if there are less then 2 profiles. 548 * Doesn't delete if there are less then 2 profiles.
543 */ 549 */
544void MainWindowImp::removeProfile(){ 550void MainWindowImp::removeProfile(){
545 if(profilesList->count() <= 1){ 551 if(profilesList->count() <= 1){
546 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); 552 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
547 return; 553 return;
548 } 554 }
549 QString profileToRemove = profilesList->currentText(); 555 QString profileToRemove = profilesList->currentText();
550 if(profileToRemove == "All"){ 556 if(profileToRemove == "All"){
551 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); 557 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
552 return; 558 return;
553 } 559 }
554 // Can't remove the curent profile 560 // Can't remove the curent profile
555 if(profileToRemove == currentProfileLabel->text()){ 561 if(profileToRemove == currentProfileLabel->text()){
556 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); 562 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
557 return; 563 return;
558 564
559 } 565 }
560 566
561 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 567 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
562 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 568 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
563 profilesList->clear(); 569 profilesList->clear();
564 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 570 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
565 profilesList->insertItem((*it)); 571 profilesList->insertItem((*it));
566 572
567 // Remove any interface settings and mappings. 573 // Remove any interface settings and mappings.
568 Interfaces interfaces; 574 Interfaces interfaces;
569 // Go through them one by one 575 // Go through them one by one
570 QMap<Interface*, QListViewItem*>::Iterator it; 576 QMap<Interface*, QListViewItem*>::Iterator it;
571 for( it = items.begin(); it != items.end(); ++it ){ 577 for( it = items.begin(); it != items.end(); ++it ){
572 QString interfaceName = it.key()->getInterfaceName(); 578 QString interfaceName = it.key()->getInterfaceName();
573 qDebug(interfaceName.latin1()); 579 qDebug(interfaceName.latin1());
574 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ 580 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
575 interfaces.removeInterface(); 581 interfaces.removeInterface();
576 if(interfaces.setMapping(interfaceName)){ 582 if(interfaces.setMapping(interfaceName)){
577 if(profilesList->count() == 1) 583 if(profilesList->count() == 1)
578 interfaces.removeMapping(); 584 interfaces.removeMapping();
579 else{ 585 else{
580 interfaces.removeMap("map", interfaceName + "_" + profileToRemove); 586 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
581 } 587 }
582 } 588 }
583 interfaces.write(); 589 interfaces.write();
584 break; 590 break;
585 } 591 }
586 } 592 }
587 } 593 }
588} 594}
589 595
590/** 596/**
591 * A new profile has been selected, change. 597 * A new profile has been selected, change.
592 * @param newProfile the new profile. 598 * @param newProfile the new profile.
593 */ 599 */
594void MainWindowImp::changeProfile(){ 600void MainWindowImp::changeProfile(){
595 if(profilesList->currentItem() == -1){ 601 if(profilesList->currentItem() == -1){
596 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); 602 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
597 return; 603 return;
598 } 604 }
599 QString newProfile = profilesList->text(profilesList->currentItem()); 605 QString newProfile = profilesList->text(profilesList->currentItem());
600 if(newProfile != currentProfileLabel->text()){ 606 if(newProfile != currentProfileLabel->text()){
601 currentProfileLabel->setText(newProfile); 607 currentProfileLabel->setText(newProfile);
602 QFile::remove(scheme); 608 QFile::remove(scheme);
603 QFile file(scheme); 609 QFile file(scheme);
604 if ( file.open(IO_ReadWrite) ) { 610 if ( file.open(IO_ReadWrite) ) {
605 QTextStream stream( &file ); 611 QTextStream stream( &file );
606 stream << QString("SCHEME=%1").arg(newProfile); 612 stream << QString("SCHEME=%1").arg(newProfile);
607 file.close(); 613 file.close();
608 } 614 }
609 // restart all up devices? 615 // restart all up devices?
610 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 616 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
611 // Go through them one by one 617 // Go through them one by one
612 QMap<Interface*, QListViewItem*>::Iterator it; 618 QMap<Interface*, QListViewItem*>::Iterator it;
613 for( it = items.begin(); it != items.end(); ++it ){ 619 for( it = items.begin(); it != items.end(); ++it ){
614 if(it.key()->getStatus() == true) 620 if(it.key()->getStatus() == true)
615 it.key()->restart(); 621 it.key()->restart();
616 } 622 }
617 } 623 }
618 } 624 }
619 // TODO change the profile in the modules 625 // TODO change the profile in the modules
620} 626}
621 627