summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-09-30 15:49:39 (UTC)
committer benmeyer <benmeyer>2002-09-30 15:49:39 (UTC)
commit4a090f5954bd5523d214685610c6582975b3d855 (patch) (unidiff)
tree3c9add7dad5df41cdd4e04d00e1d468389c331f4
parentd2a7ac3311bda821ee07ff070c24f17958657129 (diff)
downloadopie-4a090f5954bd5523d214685610c6582975b3d855.zip
opie-4a090f5954bd5523d214685610c6582975b3d855.tar.gz
opie-4a090f5954bd5523d214685610c6582975b3d855.tar.bz2
Profile Changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindow.ui89
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp56
-rw-r--r--noncore/net/networksetup/mainwindowimp.h1
-rw-r--r--noncore/settings/networksettings/mainwindow.ui89
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp56
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h1
6 files changed, 198 insertions, 94 deletions
diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui
index b8c0675..f7efe99 100644
--- a/noncore/net/networksetup/mainwindow.ui
+++ b/noncore/net/networksetup/mainwindow.ui
@@ -1,321 +1,326 @@
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>222</width> 14 <width>218</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 Setup</string> 20 <string>Network Setup</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> 37 <property>
38 <name>layoutMargin</name> 38 <name>layoutMargin</name>
39 </property> 39 </property>
40 <widget> 40 <widget>
41 <class>QWidget</class> 41 <class>QWidget</class>
42 <property stdset="1"> 42 <property stdset="1">
43 <name>name</name> 43 <name>name</name>
44 <cstring>Widget3</cstring> 44 <cstring>Widget3</cstring>
45 </property> 45 </property>
46 <attribute> 46 <attribute>
47 <name>title</name> 47 <name>title</name>
48 <string>Interfaces</string> 48 <string>Interfaces</string>
49 </attribute> 49 </attribute>
50 <vbox> 50 <vbox>
51 <property stdset="1"> 51 <property stdset="1">
52 <name>margin</name> 52 <name>margin</name>
53 <number>0</number> 53 <number>0</number>
54 </property> 54 </property>
55 <property stdset="1"> 55 <property stdset="1">
56 <name>spacing</name> 56 <name>spacing</name>
57 <number>6</number> 57 <number>6</number>
58 </property> 58 </property>
59 <widget> 59 <widget>
60 <class>QListView</class> 60 <class>QListView</class>
61 <column> 61 <column>
62 <property> 62 <property>
63 <name>text</name> 63 <name>text</name>
64 <string>i</string> 64 <string>i</string>
65 </property> 65 </property>
66 <property> 66 <property>
67 <name>clickable</name> 67 <name>clickable</name>
68 <bool>true</bool> 68 <bool>true</bool>
69 </property> 69 </property>
70 <property> 70 <property>
71 <name>resizeable</name> 71 <name>resizeable</name>
72 <bool>true</bool> 72 <bool>true</bool>
73 </property> 73 </property>
74 </column> 74 </column>
75 <column> 75 <column>
76 <property> 76 <property>
77 <name>text</name> 77 <name>text</name>
78 <string>t</string> 78 <string>t</string>
79 </property> 79 </property>
80 <property> 80 <property>
81 <name>clickable</name> 81 <name>clickable</name>
82 <bool>true</bool> 82 <bool>true</bool>
83 </property> 83 </property>
84 <property> 84 <property>
85 <name>resizeable</name> 85 <name>resizeable</name>
86 <bool>true</bool> 86 <bool>true</bool>
87 </property> 87 </property>
88 </column> 88 </column>
89 <column> 89 <column>
90 <property> 90 <property>
91 <name>text</name> 91 <name>text</name>
92 <string>Name</string> 92 <string>Name</string>
93 </property> 93 </property>
94 <property> 94 <property>
95 <name>clickable</name> 95 <name>clickable</name>
96 <bool>true</bool> 96 <bool>true</bool>
97 </property> 97 </property>
98 <property> 98 <property>
99 <name>resizeable</name> 99 <name>resizeable</name>
100 <bool>true</bool> 100 <bool>true</bool>
101 </property> 101 </property>
102 </column> 102 </column>
103 <property stdset="1"> 103 <property stdset="1">
104 <name>name</name> 104 <name>name</name>
105 <cstring>serviceList</cstring> 105 <cstring>serviceList</cstring>
106 </property> 106 </property>
107 <property stdset="1"> 107 <property stdset="1">
108 <name>allColumnsShowFocus</name> 108 <name>allColumnsShowFocus</name>
109 <bool>true</bool> 109 <bool>true</bool>
110 </property> 110 </property>
111 </widget> 111 </widget>
112 <widget> 112 <widget>
113 <class>QLayoutWidget</class> 113 <class>QLayoutWidget</class>
114 <property stdset="1"> 114 <property stdset="1">
115 <name>name</name> 115 <name>name</name>
116 <cstring>Layout2</cstring> 116 <cstring>Layout2</cstring>
117 </property> 117 </property>
118 <property> 118 <property>
119 <name>layoutMargin</name> 119 <name>layoutMargin</name>
120 </property> 120 </property>
121 <grid> 121 <grid>
122 <property stdset="1"> 122 <property stdset="1">
123 <name>margin</name> 123 <name>margin</name>
124 <number>5</number> 124 <number>5</number>
125 </property> 125 </property>
126 <property stdset="1"> 126 <property stdset="1">
127 <name>spacing</name> 127 <name>spacing</name>
128 <number>6</number> 128 <number>6</number>
129 </property> 129 </property>
130 <widget row="1" column="0" > 130 <widget row="1" column="0" >
131 <class>QPushButton</class> 131 <class>QPushButton</class>
132 <property stdset="1"> 132 <property stdset="1">
133 <name>name</name> 133 <name>name</name>
134 <cstring>addServiceButton</cstring> 134 <cstring>addServiceButton</cstring>
135 </property> 135 </property>
136 <property stdset="1"> 136 <property stdset="1">
137 <name>text</name> 137 <name>text</name>
138 <string>&amp;Add</string> 138 <string>&amp;Add</string>
139 </property> 139 </property>
140 </widget> 140 </widget>
141 <widget row="0" column="0" > 141 <widget row="0" column="0" >
142 <class>QPushButton</class> 142 <class>QPushButton</class>
143 <property stdset="1"> 143 <property stdset="1">
144 <name>name</name> 144 <name>name</name>
145 <cstring>informationServiceButton</cstring> 145 <cstring>informationServiceButton</cstring>
146 </property> 146 </property>
147 <property stdset="1"> 147 <property stdset="1">
148 <name>text</name> 148 <name>text</name>
149 <string>&amp;Information</string> 149 <string>&amp;Information</string>
150 </property> 150 </property>
151 </widget> 151 </widget>
152 <widget row="0" column="1" > 152 <widget row="0" column="1" >
153 <class>QPushButton</class> 153 <class>QPushButton</class>
154 <property stdset="1"> 154 <property stdset="1">
155 <name>name</name> 155 <name>name</name>
156 <cstring>configureServiceButton</cstring> 156 <cstring>configureServiceButton</cstring>
157 </property> 157 </property>
158 <property stdset="1"> 158 <property stdset="1">
159 <name>text</name> 159 <name>text</name>
160 <string>&amp;Configure</string> 160 <string>&amp;Configure</string>
161 </property> 161 </property>
162 </widget> 162 </widget>
163 <widget row="1" column="1" > 163 <widget row="1" column="1" >
164 <class>QPushButton</class> 164 <class>QPushButton</class>
165 <property stdset="1"> 165 <property stdset="1">
166 <name>name</name> 166 <name>name</name>
167 <cstring>removeServiceButton</cstring> 167 <cstring>removeServiceButton</cstring>
168 </property> 168 </property>
169 <property stdset="1"> 169 <property stdset="1">
170 <name>text</name> 170 <name>text</name>
171 <string>&amp;Remove</string> 171 <string>&amp;Remove</string>
172 </property> 172 </property>
173 </widget> 173 </widget>
174 </grid> 174 </grid>
175 </widget> 175 </widget>
176 </vbox> 176 </vbox>
177 </widget> 177 </widget>
178 <widget> 178 <widget>
179 <class>QWidget</class> 179 <class>QWidget</class>
180 <property stdset="1"> 180 <property stdset="1">
181 <name>name</name> 181 <name>name</name>
182 <cstring>tab</cstring> 182 <cstring>tab</cstring>
183 </property> 183 </property>
184 <attribute> 184 <attribute>
185 <name>title</name> 185 <name>title</name>
186 <string>Profiles</string> 186 <string>Profiles</string>
187 </attribute> 187 </attribute>
188 <grid> 188 <grid>
189 <property stdset="1"> 189 <property stdset="1">
190 <name>margin</name> 190 <name>margin</name>
191 <number>11</number> 191 <number>11</number>
192 </property> 192 </property>
193 <property stdset="1"> 193 <property stdset="1">
194 <name>spacing</name> 194 <name>spacing</name>
195 <number>6</number> 195 <number>6</number>
196 </property> 196 </property>
197 <widget row="1" column="0" rowspan="1" colspan="2" >
198 <class>QLabel</class>
199 <property stdset="1">
200 <name>name</name>
201 <cstring>TextLabel3</cstring>
202 </property>
203 <property stdset="1">
204 <name>text</name>
205 <string>Change Profile To</string>
206 </property>
207 </widget>
208 <widget row="0" column="0" rowspan="1" colspan="2" > 197 <widget row="0" column="0" rowspan="1" colspan="2" >
209 <class>QLabel</class> 198 <class>QLabel</class>
210 <property stdset="1"> 199 <property stdset="1">
211 <name>name</name> 200 <name>name</name>
212 <cstring>TextLabel1</cstring> 201 <cstring>TextLabel1</cstring>
213 </property> 202 </property>
214 <property stdset="1"> 203 <property stdset="1">
215 <name>text</name> 204 <name>text</name>
216 <string>Current Profile</string> 205 <string>Current Profile</string>
217 </property> 206 </property>
218 </widget> 207 </widget>
219 <widget row="0" column="2" > 208 <widget row="0" column="2" >
220 <class>QLabel</class> 209 <class>QLabel</class>
221 <property stdset="1"> 210 <property stdset="1">
222 <name>name</name> 211 <name>name</name>
223 <cstring>TextLabel2</cstring> 212 <cstring>currentProfileLabel</cstring>
224 </property> 213 </property>
225 <property stdset="1"> 214 <property stdset="1">
226 <name>frameShape</name> 215 <name>frameShape</name>
227 <enum>Panel</enum> 216 <enum>Panel</enum>
228 </property> 217 </property>
229 <property stdset="1"> 218 <property stdset="1">
230 <name>frameShadow</name> 219 <name>frameShadow</name>
231 <enum>Sunken</enum> 220 <enum>Sunken</enum>
232 </property> 221 </property>
233 <property stdset="1"> 222 <property stdset="1">
234 <name>text</name> 223 <name>text</name>
235 <string>All</string> 224 <string>All</string>
236 </property> 225 </property>
237 </widget> 226 </widget>
238 <widget row="1" column="2" > 227 <widget row="1" column="0" >
239 <class>QComboBox</class> 228 <class>QLabel</class>
240 <item>
241 <property>
242 <name>text</name>
243 <string>All</string>
244 </property>
245 </item>
246 <property stdset="1">
247 <name>name</name>
248 <cstring>ComboBox10</cstring>
249 </property>
250 </widget>
251 <widget row="2" column="1" rowspan="1" colspan="2" >
252 <class>QPushButton</class>
253 <property stdset="1">
254 <name>name</name>
255 <cstring>removeProfileButton</cstring>
256 </property>
257 <property stdset="1">
258 <name>text</name>
259 <string>&amp;Remove</string>
260 </property>
261 </widget>
262 <widget row="2" column="0" >
263 <class>QPushButton</class>
264 <property stdset="1"> 229 <property stdset="1">
265 <name>name</name> 230 <name>name</name>
266 <cstring>newProfileButton</cstring> 231 <cstring>TextLabel1_2</cstring>
267 </property> 232 </property>
268 <property stdset="1"> 233 <property stdset="1">
269 <name>text</name> 234 <name>text</name>
270 <string>&amp;New</string> 235 <string>Profiles</string>
271 </property> 236 </property>
272 </widget> 237 </widget>
273 <spacer row="3" column="2" > 238 <spacer row="5" column="2" >
274 <property> 239 <property>
275 <name>name</name> 240 <name>name</name>
276 <cstring>Spacer16</cstring> 241 <cstring>Spacer16</cstring>
277 </property> 242 </property>
278 <property stdset="1"> 243 <property stdset="1">
279 <name>orientation</name> 244 <name>orientation</name>
280 <enum>Vertical</enum> 245 <enum>Vertical</enum>
281 </property> 246 </property>
282 <property stdset="1"> 247 <property stdset="1">
283 <name>sizeType</name> 248 <name>sizeType</name>
284 <enum>Expanding</enum> 249 <enum>Expanding</enum>
285 </property> 250 </property>
286 <property> 251 <property>
287 <name>sizeHint</name> 252 <name>sizeHint</name>
288 <size> 253 <size>
289 <width>20</width> 254 <width>20</width>
290 <height>20</height> 255 <height>20</height>
291 </size> 256 </size>
292 </property> 257 </property>
293 </spacer> 258 </spacer>
259 <widget row="2" column="0" rowspan="3" colspan="1" >
260 <class>QListBox</class>
261 <property stdset="1">
262 <name>name</name>
263 <cstring>profilesList</cstring>
264 </property>
265 </widget>
266 <widget row="4" column="1" rowspan="1" colspan="2" >
267 <class>QPushButton</class>
268 <property stdset="1">
269 <name>name</name>
270 <cstring>PushButton7</cstring>
271 </property>
272 <property stdset="1">
273 <name>text</name>
274 <string>Set Current</string>
275 </property>
276 </widget>
277 <widget row="3" column="1" rowspan="1" colspan="2" >
278 <class>QPushButton</class>
279 <property stdset="1">
280 <name>name</name>
281 <cstring>removeProfileButton</cstring>
282 </property>
283 <property stdset="1">
284 <name>text</name>
285 <string>&amp;Remove</string>
286 </property>
287 </widget>
288 <widget row="2" column="1" rowspan="1" colspan="2" >
289 <class>QPushButton</class>
290 <property stdset="1">
291 <name>name</name>
292 <cstring>newProfileButton</cstring>
293 </property>
294 <property stdset="1">
295 <name>text</name>
296 <string>&amp;New</string>
297 </property>
298 </widget>
294 </grid> 299 </grid>
295 </widget> 300 </widget>
296 </widget> 301 </widget>
297 </vbox> 302 </vbox>
298</widget> 303</widget>
299<customwidgets> 304<customwidgets>
300 <customwidget> 305 <customwidget>
301 <class>QWidget</class> 306 <class>QWidget</class>
302 <header location="local">qwidget.h</header> 307 <header location="local">qwidget.h</header>
303 <sizehint> 308 <sizehint>
304 <width>100</width> 309 <width>100</width>
305 <height>100</height> 310 <height>100</height>
306 </sizehint> 311 </sizehint>
307 <container>0</container> 312 <container>0</container>
308 <sizepolicy> 313 <sizepolicy>
309 <hordata>7</hordata> 314 <hordata>7</hordata>
310 <verdata>7</verdata> 315 <verdata>7</verdata>
311 </sizepolicy> 316 </sizepolicy>
312 <pixmap>image0</pixmap> 317 <pixmap>image0</pixmap>
313 </customwidget> 318 </customwidget>
314</customwidgets> 319</customwidgets>
315<images> 320<images>
316 <image> 321 <image>
317 <name>image0</name> 322 <name>image0</name>
318 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> 323 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
319 </image> 324 </image>
320</images> 325</images>
321</UI> 326</UI>
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index ad9362f..2f821a9 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,319 +1,365 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addserviceimp.h" 2#include "addserviceimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interface.h" 5#include "interface.h"
6#include "kprocess.h" 6#include "kprocess.h"
7#include "module.h" 7#include "module.h"
8 8
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qdir.h>
11#include <qtabwidget.h> 10#include <qtabwidget.h>
11#include <qlistbox.h>
12#include <qlistview.h>
13#include <qheader.h>
14#include <qlabel.h>
15
12#include <qmainwindow.h> 16#include <qmainwindow.h>
13#include <qmessagebox.h> 17#include <qmessagebox.h>
14#include <qlistbox.h> 18
15#include <qpe/config.h> 19#include <qpe/config.h>
16#include <qpe/qlibrary.h> 20#include <qpe/qlibrary.h>
17#include <qpe/resource.h> 21#include <qpe/resource.h>
18#include <qlist.h>
19 22
23#include <qlist.h>
24#include <qdir.h>
20#include <qfile.h> 25#include <qfile.h>
21#include <qtextstream.h> 26#include <qtextstream.h>
22#include <qlistview.h> 27
23#include <qheader.h>
24// For library loading. 28// For library loading.
25#include <dlfcn.h> 29#include <dlfcn.h>
26 30
27#define TEMP_ALL "/tmp/ifconfig-a" 31#define TEMP_ALL "/tmp/ifconfig-a"
28#define TEMP_UP "/tmp/ifconfig" 32#define TEMP_UP "/tmp/ifconfig"
29 33
30#define NO_SELECT_ERROR_AND_RETURN { \ 34#define NO_SELECT_ERROR_AND_RETURN { \
31 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \ 35 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \
32 return; \ 36 return; \
33} 37}
34 38
35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) { 39MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) {
36 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked())); 40 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
37 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 41 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
38 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 42 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
39 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 43 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
44
45 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
46 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
47 connect(profilesList, SIGNAL(highlighted(const QString&)), this, SLOT(changeProfile(const QString&)));
48
40 // Make sure we have a plugin directory to scan. 49 // Make sure we have a plugin directory to scan.
41 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 50 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
42 QDir pluginDir( DirStr ); 51 QDir pluginDir( DirStr );
43 pluginDir.mkdir( DirStr ); 52 pluginDir.mkdir( DirStr );
44 pluginDir.mkdir( ( DirStr + "plugins/" ) ); 53 pluginDir.mkdir( ( DirStr + "plugins/" ) );
45 QString path = DirStr + "plugins"; 54 QString path = DirStr + "plugins";
46 pluginDir.setPath(path); 55 pluginDir.setPath(path);
47 if(!pluginDir.exists()){ 56 if(!pluginDir.exists()){
48 qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1()); 57 qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1());
49 return; 58 return;
50 } 59 }
51 60
52 // Load any saved services. 61 // Load any saved services.
53 loadModules(path); 62 loadModules(path);
54 getInterfaceList(); 63 getInterfaceList();
55 serviceList->header()->hide(); 64 serviceList->header()->hide();
56 65
57 66
58 Config cfg("NetworkSetup"); 67 Config cfg("NetworkSetup");
59 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 68 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
69 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
70 profilesList->insertItem((*it));
60} 71}
61 72
62/** 73/**
63 * Deconstructor. Unload libraries and save profile list. 74 * Deconstructor. Unload libraries and save profile list.
64 */ 75 */
65MainWindowImp::~MainWindowImp(){ 76MainWindowImp::~MainWindowImp(){
66 if(profiles.count() > 1){ 77 if(profiles.count() > 1){
67 Config cfg("NetworkSetup"); 78 Config cfg("NetworkSetup");
68 cfg.writeEntry("Profiles", profiles.join(" ")); 79 cfg.writeEntry("Profiles", profiles.join(" "));
69 } 80 }
70} 81}
71 82
72void MainWindowImp::loadModules(QString path){ 83void MainWindowImp::loadModules(QString path){
73} 84}
74 85
75/** 86/**
76 * Attempt to load a function and resolve a function. 87 * Attempt to load a function and resolve a function.
77 * @param pluginFileName - the name of the file in which to attempt to load 88 * @param pluginFileName - the name of the file in which to attempt to load
78 * @param resolveString - function pointer to resolve 89 * @param resolveString - function pointer to resolve
79 * @return pointer to the function with name resolveString or NULL 90 * @return pointer to the function with name resolveString or NULL
80 */ 91 */
81Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 92Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
82 //qDebug(pluginFileName.latin1()); 93 //qDebug(pluginFileName.latin1());
83 QLibrary *lib = new QLibrary(pluginFileName); 94 QLibrary *lib = new QLibrary(pluginFileName);
84 void *functionPointer = lib->resolve(resolveString); 95 void *functionPointer = lib->resolve(resolveString);
85 if( !functionPointer ){ 96 if( !functionPointer ){
86 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 97 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
87 delete lib; 98 delete lib;
88 return NULL; 99 return NULL;
89 } 100 }
90 101
91 // Try to get an object. 102 // Try to get an object.
92 Module *object = ((Module* (*)()) functionPointer)(); 103 Module *object = ((Module* (*)()) functionPointer)();
93 if(object == NULL){ 104 if(object == NULL){
94 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 105 qDebug("MainWindowImp: Couldn't create object, but did load library!");
95 delete lib; 106 delete lib;
96 return NULL; 107 return NULL;
97 } 108 }
98 109
99 // Store for reference 110 // Store for reference
100 libraries.insert(object, lib); 111 libraries.insert(object, lib);
101 return object; 112 return object;
102} 113}
103 114
104/* 115/*
105QList<QString> MainWindowImp::retrieveUnloadedPluginList(){ 116QList<QString> MainWindowImp::retrieveUnloadedPluginList(){
106 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 117 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
107 QString path = DirStr + "plugins"; 118 QString path = DirStr + "plugins";
108 QDir d(path); 119 QDir d(path);
109 d.setFilter( QDir::Files | QDir::Hidden ); 120 d.setFilter( QDir::Files | QDir::Hidden );
110 121
111 QMap<QObject*, QLibrary*>::Iterator libraryIt; 122 QMap<QObject*, QLibrary*>::Iterator libraryIt;
112 QList<QString> rlist; 123 QList<QString> rlist;
113 rlist.setAutoDelete(false); 124 rlist.setAutoDelete(false);
114 125
115 const QFileInfoList *list = d.entryInfoList(); 126 const QFileInfoList *list = d.entryInfoList();
116 QFileInfoListIterator it( *list ); 127 QFileInfoListIterator it( *list );
117 QFileInfo *fi; 128 QFileInfo *fi;
118 while ( (fi=it.current()) ) { 129 while ( (fi=it.current()) ) {
119 if(fi->fileName().contains(".so")){ 130 if(fi->fileName().contains(".so")){
120 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt ) 131 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt )
121 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){ 132 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){
122 QString *s = new QString(path + "/" + fi->fileName()); 133 QString *s = new QString(path + "/" + fi->fileName());
123 rlist.append(s); 134 rlist.append(s);
124 } 135 }
125 } 136 }
126 ++it; 137 ++it;
127 } 138 }
128 return rlist; 139 return rlist;
129} 140}
130*/ 141*/
131 142
132/** 143/**
133 * The Add button was clicked. Bring up the add dialog and if OK is hit 144 * The Add button was clicked. Bring up the add dialog and if OK is hit
134 * load the plugin and append it to the list 145 * load the plugin and append it to the list
135 */ 146 */
136void MainWindowImp::addClicked(){ 147void MainWindowImp::addClicked(){
137 // Now that we have a list of all of the protocals, list them. 148 // Now that we have a list of all of the protocals, list them.
138 { 149 {
139 QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok"); 150 QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok");
140 return; 151 return;
141 } 152 }
142 AddServiceImp service(this, "AddService", true); 153 AddServiceImp service(this, "AddService", true);
143 service.showMaximized(); 154 service.showMaximized();
144 service.exec(); 155 service.exec();
145} 156}
146 157
147/** 158/**
148 * Prompt the user to see if they really want to do this. 159 * Prompt the user to see if they really want to do this.
149 * If they do then remove from the list and unload. 160 * If they do then remove from the list and unload.
150 */ 161 */
151void MainWindowImp::removeClicked(){ 162void MainWindowImp::removeClicked(){
152 QListViewItem *item = serviceList->currentItem(); 163 QListViewItem *item = serviceList->currentItem();
153 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 164 if(item == NULL) NO_SELECT_ERROR_AND_RETURN
154 165
155 if(modules.find(interfaceItems[item]) == modules.end()){ 166 if(modules.find(interfaceItems[item]) == modules.end()){
156 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 167 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
157 } 168 }
158 else{ 169 else{
159 // Try to remove. 170 // Try to remove.
160 } 171 }
161 172
162} 173}
163 174
164/** 175/**
165 * See if there is a configuration for the selected protocal. 176 * See if there is a configuration for the selected protocal.
166 * Prompt with errors. 177 * Prompt with errors.
167 */ 178 */
168void MainWindowImp::configureClicked(){ 179void MainWindowImp::configureClicked(){
169 QListViewItem *item = serviceList->currentItem(); 180 QListViewItem *item = serviceList->currentItem();
170 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 181 if(item == NULL) NO_SELECT_ERROR_AND_RETURN
171 182
172 if(modules.find(interfaceItems[item]) == modules.end()){ 183 if(modules.find(interfaceItems[item]) == modules.end()){
173 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); 184 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
174 conf->showMaximized(); 185 conf->showMaximized();
175 conf->show(); 186 conf->show();
176 } 187 }
177 else{ 188 else{
178 InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration"); 189 InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration");
179 conf->show(); 190 conf->show();
180 } 191 }
181} 192}
182 193
183/** 194/**
184 * Pull up the information about the selected interface 195 * Pull up the information about the selected interface
185 * Report an error 196 * Report an error
186 */ 197 */
187void MainWindowImp::informationClicked(){ 198void MainWindowImp::informationClicked(){
188 QListViewItem *item = serviceList->currentItem(); 199 QListViewItem *item = serviceList->currentItem();
189 if(item == NULL)NO_SELECT_ERROR_AND_RETURN 200 if(item == NULL)NO_SELECT_ERROR_AND_RETURN
190 201
191 if(modules.find(interfaceItems[item]) == modules.end()){ 202 if(modules.find(interfaceItems[item]) == modules.end()){
192 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); 203 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
193 i->showMaximized(); 204 i->showMaximized();
194 i->show(); 205 i->show();
195 } 206 }
196 else{ 207 else{
197 QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB"); 208 QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB");
198 InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); 209 InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
199 t->insertTab(i, "TCP/IP"); 210 t->insertTab(i, "TCP/IP");
200 t->show(); 211 t->show();
201 } 212 }
202} 213}
203 214
204/** 215/**
205 * Aquire the list of active interfaces from ifconfig 216 * Aquire the list of active interfaces from ifconfig
206 * Call ifconfig and ifconfig -a 217 * Call ifconfig and ifconfig -a
207 */ 218 */
208void MainWindowImp::getInterfaceList(){ 219void MainWindowImp::getInterfaceList(){
209 KShellProcess *processAll = new KShellProcess(); 220 KShellProcess *processAll = new KShellProcess();
210 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 221 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
211 connect(processAll, SIGNAL(processExited(KProcess *)), 222 connect(processAll, SIGNAL(processExited(KProcess *)),
212 this, SLOT(jobDone(KProcess *))); 223 this, SLOT(jobDone(KProcess *)));
213 threads.insert(processAll, TEMP_ALL); 224 threads.insert(processAll, TEMP_ALL);
214 processAll->start(KShellProcess::NotifyOnExit); 225 processAll->start(KShellProcess::NotifyOnExit);
215 226
216 KShellProcess *process = new KShellProcess(); 227 KShellProcess *process = new KShellProcess();
217 *process << "/sbin/ifconfig" << " > " TEMP_UP; 228 *process << "/sbin/ifconfig" << " > " TEMP_UP;
218 connect(process, SIGNAL(processExited(KProcess *)), 229 connect(process, SIGNAL(processExited(KProcess *)),
219 this, SLOT(jobDone(KProcess *))); 230 this, SLOT(jobDone(KProcess *)));
220 threads.insert(process, TEMP_UP); 231 threads.insert(process, TEMP_UP);
221 process->start(KShellProcess::NotifyOnExit); 232 process->start(KShellProcess::NotifyOnExit);
222} 233}
223 234
224void MainWindowImp::jobDone(KProcess *process){ 235void MainWindowImp::jobDone(KProcess *process){
225 QString fileName = threads[process]; 236 QString fileName = threads[process];
226 threads.remove(process); 237 threads.remove(process);
227 delete process; 238 delete process;
228 239
229 QFile file(fileName); 240 QFile file(fileName);
230 if (!file.open(IO_ReadOnly)){ 241 if (!file.open(IO_ReadOnly)){
231 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 242 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
232 return; 243 return;
233 } 244 }
234 245
235 QTextStream stream( &file ); 246 QTextStream stream( &file );
236 QString line; 247 QString line;
237 while ( !stream.eof() ) { 248 while ( !stream.eof() ) {
238 line = stream.readLine(); 249 line = stream.readLine();
239 int space = line.find(" "); 250 int space = line.find(" ");
240 if(space > 1){ 251 if(space > 1){
241 // We have found an interface 252 // We have found an interface
242 QString interfaceName = line.mid(0, space); 253 QString interfaceName = line.mid(0, space);
243 Interface *i; 254 Interface *i;
244 // See if we already have it 255 // See if we already have it
245 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 256 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
246 if(fileName == TEMP_ALL) 257 if(fileName == TEMP_ALL)
247 i = new Interface(interfaceName, false); 258 i = new Interface(interfaceName, false);
248 else 259 else
249 i = new Interface(interfaceName, true); 260 i = new Interface(interfaceName, true);
250 } 261 }
251 else{ 262 else{
252 i = interfaceNames[interfaceName]; 263 i = interfaceNames[interfaceName];
253 if(fileName != TEMP_ALL) 264 if(fileName != TEMP_ALL)
254 i->setStatus(true); 265 i->setStatus(true);
255 } 266 }
256 267
257 i->setAttached(true); 268 i->setAttached(true);
258 i->setInterfaceName(interfaceName); 269 i->setInterfaceName(interfaceName);
259 270
260 QString hardName = "Ethernet"; 271 QString hardName = "Ethernet";
261 int hardwareName = line.find("Link encap:"); 272 int hardwareName = line.find("Link encap:");
262 int macAddress = line.find("HWaddr"); 273 int macAddress = line.find("HWaddr");
263 if(macAddress == -1) 274 if(macAddress == -1)
264 macAddress = line.length(); 275 macAddress = line.length();
265 if(hardwareName != -1) 276 if(hardwareName != -1)
266 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); 277 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
267 // We have found an interface 278 // We have found an interface
268 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 279 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
269 interfaceNames.insert(i->getInterfaceName(), i); 280 interfaceNames.insert(i->getInterfaceName(), i);
270 updateInterface(i); 281 updateInterface(i);
271 } 282 }
272 } 283 }
273 file.close(); 284 file.close();
274 QFile::remove(fileName); 285 QFile::remove(fileName);
275} 286}
276 287
277void MainWindowImp::updateInterface(Interface *i){ 288void MainWindowImp::updateInterface(Interface *i){
278 QListViewItem *item = NULL; 289 QListViewItem *item = NULL;
279 290
280 // See if we already have it 291 // See if we already have it
281 if(items.find(i) == items.end()){ 292 if(items.find(i) == items.end()){
282 item = new QListViewItem(serviceList, "", "", ""); 293 item = new QListViewItem(serviceList, "", "", "");
283 // See if you can't find a module owner for this interface 294 // See if you can't find a module owner for this interface
284 //EmployeeMap::Iterator it; 295 //EmployeeMap::Iterator it;
285 //for( it = map.begin(); it != map.end(); ++it ) 296 //for( it = map.begin(); it != map.end(); ++it )
286 // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() ); 297 // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() );
287 298
288 items.insert(i, item); 299 items.insert(i, item);
289 interfaceItems.insert(item, i); 300 interfaceItems.insert(item, i);
290 } 301 }
291 else 302 else
292 item = items[i]; 303 item = items[i];
293 304
294 QString statusImage = "down"; 305 QString statusImage = "down";
295 if(i->getStatus()) 306 if(i->getStatus())
296 statusImage = "up"; 307 statusImage = "up";
297 QPixmap status = (Resource::loadPixmap(statusImage)); 308 QPixmap status = (Resource::loadPixmap(statusImage));
298 item->setPixmap(0, status); 309 item->setPixmap(0, status);
299 310
300 QString typeName = "lan"; 311 QString typeName = "lan";
301 if(i->getHardwareName().contains("Local Loopback")) 312 if(i->getHardwareName().contains("Local Loopback"))
302 typeName = "lo"; 313 typeName = "lo";
303 QPixmap type = (Resource::loadPixmap(typeName)); 314 QPixmap type = (Resource::loadPixmap(typeName));
304 item->setPixmap(1, type); 315 item->setPixmap(1, type);
305 316
306 item->setText(2, i->getHardwareName()); 317 item->setText(2, i->getHardwareName());
307 318
308} 319}
309 320
321/**
322 * Adds a new profile to the list of profiles.
323 * Don't add profiles that already exists.
324 * Appends to the combo and QStringList
325 */
310void MainWindowImp::addProfile(){ 326void MainWindowImp::addProfile(){
327 QString newProfileName = "New";
328 if(profiles.grep(newProfileName).count() > 0){
329 QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
330 return;
331 }
332 profiles.append(newProfileName);
333 profilesList->insertItem(newProfileName);
311 334
312} 335}
313 336
337/**
338 * Removes the currently selected profile in the combo.
339 * Doesn't delete if there are less then 2 profiles.
340 */
314void MainWindowImp::removeProfile(){ 341void MainWindowImp::removeProfile(){
342 if(profilesList->count() <= 1){
343 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
344 return;
345 }
346 QString profileToRemove = profilesList->currentText();
347 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
348 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
349 profilesList->clear();
350 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
351 profilesList->insertItem((*it));
352 }
353
354}
315 355
356/**
357 * A new profile has been selected, change.
358 * @param newProfile the new profile.
359 */
360void MainWindowImp::changeProfile(const QString& newProfile){
361 currentProfileLabel->setText(newProfile);
316} 362}
317 363
318// mainwindowimp.cpp 364// mainwindowimp.cpp
319 365
diff --git a/noncore/net/networksetup/mainwindowimp.h b/noncore/net/networksetup/mainwindowimp.h
index 0618dd2..8e300bf 100644
--- a/noncore/net/networksetup/mainwindowimp.h
+++ b/noncore/net/networksetup/mainwindowimp.h
@@ -1,56 +1,57 @@
1#ifndef MAINWINOWIMP_H 1#ifndef MAINWINOWIMP_H
2#define MAINWINOWIMP_H 2#define MAINWINOWIMP_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8class Module; 8class Module;
9class Interface; 9class Interface;
10class QLibrary; 10class QLibrary;
11class KProcess; 11class KProcess;
12 12
13class MainWindowImp : public MainWindow { 13class MainWindowImp : public MainWindow {
14 Q_OBJECT 14 Q_OBJECT
15 15
16public: 16public:
17 MainWindowImp(QWidget *parent=0, const char *name=0); 17 MainWindowImp(QWidget *parent=0, const char *name=0);
18 ~MainWindowImp(); 18 ~MainWindowImp();
19 19
20private slots: 20private slots:
21 void addClicked(); 21 void addClicked();
22 void removeClicked(); 22 void removeClicked();
23 void configureClicked(); 23 void configureClicked();
24 void informationClicked(); 24 void informationClicked();
25 25
26 void jobDone(KProcess *process); 26 void jobDone(KProcess *process);
27 void getInterfaceList(); 27 void getInterfaceList();
28 28
29 void addProfile(); 29 void addProfile();
30 void removeProfile(); 30 void removeProfile();
31 void changeProfile(const QString&);
31 32
32 void updateInterface(Interface *i); 33 void updateInterface(Interface *i);
33 34
34private: 35private:
35 void loadModules(QString path); 36 void loadModules(QString path);
36 37
37 Module* loadPlugin(QString pluginFileName, 38 Module* loadPlugin(QString pluginFileName,
38 QString resolveString = "create_plugin"); 39 QString resolveString = "create_plugin");
39 40
40 // For our local list of names 41 // For our local list of names
41 QMap<QString, Interface*> interfaceNames; 42 QMap<QString, Interface*> interfaceNames;
42 43
43 QMap<Module*, QLibrary*> libraries; 44 QMap<Module*, QLibrary*> libraries;
44 QMap<Interface*, Module*> modules; 45 QMap<Interface*, Module*> modules;
45 QMap<Interface*, QListViewItem*> items; 46 QMap<Interface*, QListViewItem*> items;
46 QMap<QListViewItem*, Interface*> interfaceItems; 47 QMap<QListViewItem*, Interface*> interfaceItems;
47 48
48 QMap<KProcess*, QString> threads; 49 QMap<KProcess*, QString> threads;
49 QStringList profiles; 50 QStringList profiles;
50 51
51}; 52};
52 53
53#endif 54#endif
54 55
55// mainwindowimp.h 56// mainwindowimp.h
56 57
diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui
index b8c0675..f7efe99 100644
--- a/noncore/settings/networksettings/mainwindow.ui
+++ b/noncore/settings/networksettings/mainwindow.ui
@@ -1,321 +1,326 @@
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>222</width> 14 <width>218</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 Setup</string> 20 <string>Network Setup</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> 37 <property>
38 <name>layoutMargin</name> 38 <name>layoutMargin</name>
39 </property> 39 </property>
40 <widget> 40 <widget>
41 <class>QWidget</class> 41 <class>QWidget</class>
42 <property stdset="1"> 42 <property stdset="1">
43 <name>name</name> 43 <name>name</name>
44 <cstring>Widget3</cstring> 44 <cstring>Widget3</cstring>
45 </property> 45 </property>
46 <attribute> 46 <attribute>
47 <name>title</name> 47 <name>title</name>
48 <string>Interfaces</string> 48 <string>Interfaces</string>
49 </attribute> 49 </attribute>
50 <vbox> 50 <vbox>
51 <property stdset="1"> 51 <property stdset="1">
52 <name>margin</name> 52 <name>margin</name>
53 <number>0</number> 53 <number>0</number>
54 </property> 54 </property>
55 <property stdset="1"> 55 <property stdset="1">
56 <name>spacing</name> 56 <name>spacing</name>
57 <number>6</number> 57 <number>6</number>
58 </property> 58 </property>
59 <widget> 59 <widget>
60 <class>QListView</class> 60 <class>QListView</class>
61 <column> 61 <column>
62 <property> 62 <property>
63 <name>text</name> 63 <name>text</name>
64 <string>i</string> 64 <string>i</string>
65 </property> 65 </property>
66 <property> 66 <property>
67 <name>clickable</name> 67 <name>clickable</name>
68 <bool>true</bool> 68 <bool>true</bool>
69 </property> 69 </property>
70 <property> 70 <property>
71 <name>resizeable</name> 71 <name>resizeable</name>
72 <bool>true</bool> 72 <bool>true</bool>
73 </property> 73 </property>
74 </column> 74 </column>
75 <column> 75 <column>
76 <property> 76 <property>
77 <name>text</name> 77 <name>text</name>
78 <string>t</string> 78 <string>t</string>
79 </property> 79 </property>
80 <property> 80 <property>
81 <name>clickable</name> 81 <name>clickable</name>
82 <bool>true</bool> 82 <bool>true</bool>
83 </property> 83 </property>
84 <property> 84 <property>
85 <name>resizeable</name> 85 <name>resizeable</name>
86 <bool>true</bool> 86 <bool>true</bool>
87 </property> 87 </property>
88 </column> 88 </column>
89 <column> 89 <column>
90 <property> 90 <property>
91 <name>text</name> 91 <name>text</name>
92 <string>Name</string> 92 <string>Name</string>
93 </property> 93 </property>
94 <property> 94 <property>
95 <name>clickable</name> 95 <name>clickable</name>
96 <bool>true</bool> 96 <bool>true</bool>
97 </property> 97 </property>
98 <property> 98 <property>
99 <name>resizeable</name> 99 <name>resizeable</name>
100 <bool>true</bool> 100 <bool>true</bool>
101 </property> 101 </property>
102 </column> 102 </column>
103 <property stdset="1"> 103 <property stdset="1">
104 <name>name</name> 104 <name>name</name>
105 <cstring>serviceList</cstring> 105 <cstring>serviceList</cstring>
106 </property> 106 </property>
107 <property stdset="1"> 107 <property stdset="1">
108 <name>allColumnsShowFocus</name> 108 <name>allColumnsShowFocus</name>
109 <bool>true</bool> 109 <bool>true</bool>
110 </property> 110 </property>
111 </widget> 111 </widget>
112 <widget> 112 <widget>
113 <class>QLayoutWidget</class> 113 <class>QLayoutWidget</class>
114 <property stdset="1"> 114 <property stdset="1">
115 <name>name</name> 115 <name>name</name>
116 <cstring>Layout2</cstring> 116 <cstring>Layout2</cstring>
117 </property> 117 </property>
118 <property> 118 <property>
119 <name>layoutMargin</name> 119 <name>layoutMargin</name>
120 </property> 120 </property>
121 <grid> 121 <grid>
122 <property stdset="1"> 122 <property stdset="1">
123 <name>margin</name> 123 <name>margin</name>
124 <number>5</number> 124 <number>5</number>
125 </property> 125 </property>
126 <property stdset="1"> 126 <property stdset="1">
127 <name>spacing</name> 127 <name>spacing</name>
128 <number>6</number> 128 <number>6</number>
129 </property> 129 </property>
130 <widget row="1" column="0" > 130 <widget row="1" column="0" >
131 <class>QPushButton</class> 131 <class>QPushButton</class>
132 <property stdset="1"> 132 <property stdset="1">
133 <name>name</name> 133 <name>name</name>
134 <cstring>addServiceButton</cstring> 134 <cstring>addServiceButton</cstring>
135 </property> 135 </property>
136 <property stdset="1"> 136 <property stdset="1">
137 <name>text</name> 137 <name>text</name>
138 <string>&amp;Add</string> 138 <string>&amp;Add</string>
139 </property> 139 </property>
140 </widget> 140 </widget>
141 <widget row="0" column="0" > 141 <widget row="0" column="0" >
142 <class>QPushButton</class> 142 <class>QPushButton</class>
143 <property stdset="1"> 143 <property stdset="1">
144 <name>name</name> 144 <name>name</name>
145 <cstring>informationServiceButton</cstring> 145 <cstring>informationServiceButton</cstring>
146 </property> 146 </property>
147 <property stdset="1"> 147 <property stdset="1">
148 <name>text</name> 148 <name>text</name>
149 <string>&amp;Information</string> 149 <string>&amp;Information</string>
150 </property> 150 </property>
151 </widget> 151 </widget>
152 <widget row="0" column="1" > 152 <widget row="0" column="1" >
153 <class>QPushButton</class> 153 <class>QPushButton</class>
154 <property stdset="1"> 154 <property stdset="1">
155 <name>name</name> 155 <name>name</name>
156 <cstring>configureServiceButton</cstring> 156 <cstring>configureServiceButton</cstring>
157 </property> 157 </property>
158 <property stdset="1"> 158 <property stdset="1">
159 <name>text</name> 159 <name>text</name>
160 <string>&amp;Configure</string> 160 <string>&amp;Configure</string>
161 </property> 161 </property>
162 </widget> 162 </widget>
163 <widget row="1" column="1" > 163 <widget row="1" column="1" >
164 <class>QPushButton</class> 164 <class>QPushButton</class>
165 <property stdset="1"> 165 <property stdset="1">
166 <name>name</name> 166 <name>name</name>
167 <cstring>removeServiceButton</cstring> 167 <cstring>removeServiceButton</cstring>
168 </property> 168 </property>
169 <property stdset="1"> 169 <property stdset="1">
170 <name>text</name> 170 <name>text</name>
171 <string>&amp;Remove</string> 171 <string>&amp;Remove</string>
172 </property> 172 </property>
173 </widget> 173 </widget>
174 </grid> 174 </grid>
175 </widget> 175 </widget>
176 </vbox> 176 </vbox>
177 </widget> 177 </widget>
178 <widget> 178 <widget>
179 <class>QWidget</class> 179 <class>QWidget</class>
180 <property stdset="1"> 180 <property stdset="1">
181 <name>name</name> 181 <name>name</name>
182 <cstring>tab</cstring> 182 <cstring>tab</cstring>
183 </property> 183 </property>
184 <attribute> 184 <attribute>
185 <name>title</name> 185 <name>title</name>
186 <string>Profiles</string> 186 <string>Profiles</string>
187 </attribute> 187 </attribute>
188 <grid> 188 <grid>
189 <property stdset="1"> 189 <property stdset="1">
190 <name>margin</name> 190 <name>margin</name>
191 <number>11</number> 191 <number>11</number>
192 </property> 192 </property>
193 <property stdset="1"> 193 <property stdset="1">
194 <name>spacing</name> 194 <name>spacing</name>
195 <number>6</number> 195 <number>6</number>
196 </property> 196 </property>
197 <widget row="1" column="0" rowspan="1" colspan="2" >
198 <class>QLabel</class>
199 <property stdset="1">
200 <name>name</name>
201 <cstring>TextLabel3</cstring>
202 </property>
203 <property stdset="1">
204 <name>text</name>
205 <string>Change Profile To</string>
206 </property>
207 </widget>
208 <widget row="0" column="0" rowspan="1" colspan="2" > 197 <widget row="0" column="0" rowspan="1" colspan="2" >
209 <class>QLabel</class> 198 <class>QLabel</class>
210 <property stdset="1"> 199 <property stdset="1">
211 <name>name</name> 200 <name>name</name>
212 <cstring>TextLabel1</cstring> 201 <cstring>TextLabel1</cstring>
213 </property> 202 </property>
214 <property stdset="1"> 203 <property stdset="1">
215 <name>text</name> 204 <name>text</name>
216 <string>Current Profile</string> 205 <string>Current Profile</string>
217 </property> 206 </property>
218 </widget> 207 </widget>
219 <widget row="0" column="2" > 208 <widget row="0" column="2" >
220 <class>QLabel</class> 209 <class>QLabel</class>
221 <property stdset="1"> 210 <property stdset="1">
222 <name>name</name> 211 <name>name</name>
223 <cstring>TextLabel2</cstring> 212 <cstring>currentProfileLabel</cstring>
224 </property> 213 </property>
225 <property stdset="1"> 214 <property stdset="1">
226 <name>frameShape</name> 215 <name>frameShape</name>
227 <enum>Panel</enum> 216 <enum>Panel</enum>
228 </property> 217 </property>
229 <property stdset="1"> 218 <property stdset="1">
230 <name>frameShadow</name> 219 <name>frameShadow</name>
231 <enum>Sunken</enum> 220 <enum>Sunken</enum>
232 </property> 221 </property>
233 <property stdset="1"> 222 <property stdset="1">
234 <name>text</name> 223 <name>text</name>
235 <string>All</string> 224 <string>All</string>
236 </property> 225 </property>
237 </widget> 226 </widget>
238 <widget row="1" column="2" > 227 <widget row="1" column="0" >
239 <class>QComboBox</class> 228 <class>QLabel</class>
240 <item>
241 <property>
242 <name>text</name>
243 <string>All</string>
244 </property>
245 </item>
246 <property stdset="1">
247 <name>name</name>
248 <cstring>ComboBox10</cstring>
249 </property>
250 </widget>
251 <widget row="2" column="1" rowspan="1" colspan="2" >
252 <class>QPushButton</class>
253 <property stdset="1">
254 <name>name</name>
255 <cstring>removeProfileButton</cstring>
256 </property>
257 <property stdset="1">
258 <name>text</name>
259 <string>&amp;Remove</string>
260 </property>
261 </widget>
262 <widget row="2" column="0" >
263 <class>QPushButton</class>
264 <property stdset="1"> 229 <property stdset="1">
265 <name>name</name> 230 <name>name</name>
266 <cstring>newProfileButton</cstring> 231 <cstring>TextLabel1_2</cstring>
267 </property> 232 </property>
268 <property stdset="1"> 233 <property stdset="1">
269 <name>text</name> 234 <name>text</name>
270 <string>&amp;New</string> 235 <string>Profiles</string>
271 </property> 236 </property>
272 </widget> 237 </widget>
273 <spacer row="3" column="2" > 238 <spacer row="5" column="2" >
274 <property> 239 <property>
275 <name>name</name> 240 <name>name</name>
276 <cstring>Spacer16</cstring> 241 <cstring>Spacer16</cstring>
277 </property> 242 </property>
278 <property stdset="1"> 243 <property stdset="1">
279 <name>orientation</name> 244 <name>orientation</name>
280 <enum>Vertical</enum> 245 <enum>Vertical</enum>
281 </property> 246 </property>
282 <property stdset="1"> 247 <property stdset="1">
283 <name>sizeType</name> 248 <name>sizeType</name>
284 <enum>Expanding</enum> 249 <enum>Expanding</enum>
285 </property> 250 </property>
286 <property> 251 <property>
287 <name>sizeHint</name> 252 <name>sizeHint</name>
288 <size> 253 <size>
289 <width>20</width> 254 <width>20</width>
290 <height>20</height> 255 <height>20</height>
291 </size> 256 </size>
292 </property> 257 </property>
293 </spacer> 258 </spacer>
259 <widget row="2" column="0" rowspan="3" colspan="1" >
260 <class>QListBox</class>
261 <property stdset="1">
262 <name>name</name>
263 <cstring>profilesList</cstring>
264 </property>
265 </widget>
266 <widget row="4" column="1" rowspan="1" colspan="2" >
267 <class>QPushButton</class>
268 <property stdset="1">
269 <name>name</name>
270 <cstring>PushButton7</cstring>
271 </property>
272 <property stdset="1">
273 <name>text</name>
274 <string>Set Current</string>
275 </property>
276 </widget>
277 <widget row="3" column="1" rowspan="1" colspan="2" >
278 <class>QPushButton</class>
279 <property stdset="1">
280 <name>name</name>
281 <cstring>removeProfileButton</cstring>
282 </property>
283 <property stdset="1">
284 <name>text</name>
285 <string>&amp;Remove</string>
286 </property>
287 </widget>
288 <widget row="2" column="1" rowspan="1" colspan="2" >
289 <class>QPushButton</class>
290 <property stdset="1">
291 <name>name</name>
292 <cstring>newProfileButton</cstring>
293 </property>
294 <property stdset="1">
295 <name>text</name>
296 <string>&amp;New</string>
297 </property>
298 </widget>
294 </grid> 299 </grid>
295 </widget> 300 </widget>
296 </widget> 301 </widget>
297 </vbox> 302 </vbox>
298</widget> 303</widget>
299<customwidgets> 304<customwidgets>
300 <customwidget> 305 <customwidget>
301 <class>QWidget</class> 306 <class>QWidget</class>
302 <header location="local">qwidget.h</header> 307 <header location="local">qwidget.h</header>
303 <sizehint> 308 <sizehint>
304 <width>100</width> 309 <width>100</width>
305 <height>100</height> 310 <height>100</height>
306 </sizehint> 311 </sizehint>
307 <container>0</container> 312 <container>0</container>
308 <sizepolicy> 313 <sizepolicy>
309 <hordata>7</hordata> 314 <hordata>7</hordata>
310 <verdata>7</verdata> 315 <verdata>7</verdata>
311 </sizepolicy> 316 </sizepolicy>
312 <pixmap>image0</pixmap> 317 <pixmap>image0</pixmap>
313 </customwidget> 318 </customwidget>
314</customwidgets> 319</customwidgets>
315<images> 320<images>
316 <image> 321 <image>
317 <name>image0</name> 322 <name>image0</name>
318 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> 323 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
319 </image> 324 </image>
320</images> 325</images>
321</UI> 326</UI>
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index ad9362f..2f821a9 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,319 +1,365 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addserviceimp.h" 2#include "addserviceimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interface.h" 5#include "interface.h"
6#include "kprocess.h" 6#include "kprocess.h"
7#include "module.h" 7#include "module.h"
8 8
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qdir.h>
11#include <qtabwidget.h> 10#include <qtabwidget.h>
11#include <qlistbox.h>
12#include <qlistview.h>
13#include <qheader.h>
14#include <qlabel.h>
15
12#include <qmainwindow.h> 16#include <qmainwindow.h>
13#include <qmessagebox.h> 17#include <qmessagebox.h>
14#include <qlistbox.h> 18
15#include <qpe/config.h> 19#include <qpe/config.h>
16#include <qpe/qlibrary.h> 20#include <qpe/qlibrary.h>
17#include <qpe/resource.h> 21#include <qpe/resource.h>
18#include <qlist.h>
19 22
23#include <qlist.h>
24#include <qdir.h>
20#include <qfile.h> 25#include <qfile.h>
21#include <qtextstream.h> 26#include <qtextstream.h>
22#include <qlistview.h> 27
23#include <qheader.h>
24// For library loading. 28// For library loading.
25#include <dlfcn.h> 29#include <dlfcn.h>
26 30
27#define TEMP_ALL "/tmp/ifconfig-a" 31#define TEMP_ALL "/tmp/ifconfig-a"
28#define TEMP_UP "/tmp/ifconfig" 32#define TEMP_UP "/tmp/ifconfig"
29 33
30#define NO_SELECT_ERROR_AND_RETURN { \ 34#define NO_SELECT_ERROR_AND_RETURN { \
31 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \ 35 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \
32 return; \ 36 return; \
33} 37}
34 38
35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) { 39MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) {
36 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked())); 40 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
37 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 41 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
38 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 42 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
39 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 43 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
44
45 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
46 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
47 connect(profilesList, SIGNAL(highlighted(const QString&)), this, SLOT(changeProfile(const QString&)));
48
40 // Make sure we have a plugin directory to scan. 49 // Make sure we have a plugin directory to scan.
41 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 50 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
42 QDir pluginDir( DirStr ); 51 QDir pluginDir( DirStr );
43 pluginDir.mkdir( DirStr ); 52 pluginDir.mkdir( DirStr );
44 pluginDir.mkdir( ( DirStr + "plugins/" ) ); 53 pluginDir.mkdir( ( DirStr + "plugins/" ) );
45 QString path = DirStr + "plugins"; 54 QString path = DirStr + "plugins";
46 pluginDir.setPath(path); 55 pluginDir.setPath(path);
47 if(!pluginDir.exists()){ 56 if(!pluginDir.exists()){
48 qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1()); 57 qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1());
49 return; 58 return;
50 } 59 }
51 60
52 // Load any saved services. 61 // Load any saved services.
53 loadModules(path); 62 loadModules(path);
54 getInterfaceList(); 63 getInterfaceList();
55 serviceList->header()->hide(); 64 serviceList->header()->hide();
56 65
57 66
58 Config cfg("NetworkSetup"); 67 Config cfg("NetworkSetup");
59 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 68 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
69 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
70 profilesList->insertItem((*it));
60} 71}
61 72
62/** 73/**
63 * Deconstructor. Unload libraries and save profile list. 74 * Deconstructor. Unload libraries and save profile list.
64 */ 75 */
65MainWindowImp::~MainWindowImp(){ 76MainWindowImp::~MainWindowImp(){
66 if(profiles.count() > 1){ 77 if(profiles.count() > 1){
67 Config cfg("NetworkSetup"); 78 Config cfg("NetworkSetup");
68 cfg.writeEntry("Profiles", profiles.join(" ")); 79 cfg.writeEntry("Profiles", profiles.join(" "));
69 } 80 }
70} 81}
71 82
72void MainWindowImp::loadModules(QString path){ 83void MainWindowImp::loadModules(QString path){
73} 84}
74 85
75/** 86/**
76 * Attempt to load a function and resolve a function. 87 * Attempt to load a function and resolve a function.
77 * @param pluginFileName - the name of the file in which to attempt to load 88 * @param pluginFileName - the name of the file in which to attempt to load
78 * @param resolveString - function pointer to resolve 89 * @param resolveString - function pointer to resolve
79 * @return pointer to the function with name resolveString or NULL 90 * @return pointer to the function with name resolveString or NULL
80 */ 91 */
81Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 92Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
82 //qDebug(pluginFileName.latin1()); 93 //qDebug(pluginFileName.latin1());
83 QLibrary *lib = new QLibrary(pluginFileName); 94 QLibrary *lib = new QLibrary(pluginFileName);
84 void *functionPointer = lib->resolve(resolveString); 95 void *functionPointer = lib->resolve(resolveString);
85 if( !functionPointer ){ 96 if( !functionPointer ){
86 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 97 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
87 delete lib; 98 delete lib;
88 return NULL; 99 return NULL;
89 } 100 }
90 101
91 // Try to get an object. 102 // Try to get an object.
92 Module *object = ((Module* (*)()) functionPointer)(); 103 Module *object = ((Module* (*)()) functionPointer)();
93 if(object == NULL){ 104 if(object == NULL){
94 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 105 qDebug("MainWindowImp: Couldn't create object, but did load library!");
95 delete lib; 106 delete lib;
96 return NULL; 107 return NULL;
97 } 108 }
98 109
99 // Store for reference 110 // Store for reference
100 libraries.insert(object, lib); 111 libraries.insert(object, lib);
101 return object; 112 return object;
102} 113}
103 114
104/* 115/*
105QList<QString> MainWindowImp::retrieveUnloadedPluginList(){ 116QList<QString> MainWindowImp::retrieveUnloadedPluginList(){
106 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 117 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
107 QString path = DirStr + "plugins"; 118 QString path = DirStr + "plugins";
108 QDir d(path); 119 QDir d(path);
109 d.setFilter( QDir::Files | QDir::Hidden ); 120 d.setFilter( QDir::Files | QDir::Hidden );
110 121
111 QMap<QObject*, QLibrary*>::Iterator libraryIt; 122 QMap<QObject*, QLibrary*>::Iterator libraryIt;
112 QList<QString> rlist; 123 QList<QString> rlist;
113 rlist.setAutoDelete(false); 124 rlist.setAutoDelete(false);
114 125
115 const QFileInfoList *list = d.entryInfoList(); 126 const QFileInfoList *list = d.entryInfoList();
116 QFileInfoListIterator it( *list ); 127 QFileInfoListIterator it( *list );
117 QFileInfo *fi; 128 QFileInfo *fi;
118 while ( (fi=it.current()) ) { 129 while ( (fi=it.current()) ) {
119 if(fi->fileName().contains(".so")){ 130 if(fi->fileName().contains(".so")){
120 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt ) 131 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt )
121 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){ 132 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){
122 QString *s = new QString(path + "/" + fi->fileName()); 133 QString *s = new QString(path + "/" + fi->fileName());
123 rlist.append(s); 134 rlist.append(s);
124 } 135 }
125 } 136 }
126 ++it; 137 ++it;
127 } 138 }
128 return rlist; 139 return rlist;
129} 140}
130*/ 141*/
131 142
132/** 143/**
133 * The Add button was clicked. Bring up the add dialog and if OK is hit 144 * The Add button was clicked. Bring up the add dialog and if OK is hit
134 * load the plugin and append it to the list 145 * load the plugin and append it to the list
135 */ 146 */
136void MainWindowImp::addClicked(){ 147void MainWindowImp::addClicked(){
137 // Now that we have a list of all of the protocals, list them. 148 // Now that we have a list of all of the protocals, list them.
138 { 149 {
139 QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok"); 150 QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok");
140 return; 151 return;
141 } 152 }
142 AddServiceImp service(this, "AddService", true); 153 AddServiceImp service(this, "AddService", true);
143 service.showMaximized(); 154 service.showMaximized();
144 service.exec(); 155 service.exec();
145} 156}
146 157
147/** 158/**
148 * Prompt the user to see if they really want to do this. 159 * Prompt the user to see if they really want to do this.
149 * If they do then remove from the list and unload. 160 * If they do then remove from the list and unload.
150 */ 161 */
151void MainWindowImp::removeClicked(){ 162void MainWindowImp::removeClicked(){
152 QListViewItem *item = serviceList->currentItem(); 163 QListViewItem *item = serviceList->currentItem();
153 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 164 if(item == NULL) NO_SELECT_ERROR_AND_RETURN
154 165
155 if(modules.find(interfaceItems[item]) == modules.end()){ 166 if(modules.find(interfaceItems[item]) == modules.end()){
156 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 167 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
157 } 168 }
158 else{ 169 else{
159 // Try to remove. 170 // Try to remove.
160 } 171 }
161 172
162} 173}
163 174
164/** 175/**
165 * See if there is a configuration for the selected protocal. 176 * See if there is a configuration for the selected protocal.
166 * Prompt with errors. 177 * Prompt with errors.
167 */ 178 */
168void MainWindowImp::configureClicked(){ 179void MainWindowImp::configureClicked(){
169 QListViewItem *item = serviceList->currentItem(); 180 QListViewItem *item = serviceList->currentItem();
170 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 181 if(item == NULL) NO_SELECT_ERROR_AND_RETURN
171 182
172 if(modules.find(interfaceItems[item]) == modules.end()){ 183 if(modules.find(interfaceItems[item]) == modules.end()){
173 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); 184 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
174 conf->showMaximized(); 185 conf->showMaximized();
175 conf->show(); 186 conf->show();
176 } 187 }
177 else{ 188 else{
178 InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration"); 189 InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration");
179 conf->show(); 190 conf->show();
180 } 191 }
181} 192}
182 193
183/** 194/**
184 * Pull up the information about the selected interface 195 * Pull up the information about the selected interface
185 * Report an error 196 * Report an error
186 */ 197 */
187void MainWindowImp::informationClicked(){ 198void MainWindowImp::informationClicked(){
188 QListViewItem *item = serviceList->currentItem(); 199 QListViewItem *item = serviceList->currentItem();
189 if(item == NULL)NO_SELECT_ERROR_AND_RETURN 200 if(item == NULL)NO_SELECT_ERROR_AND_RETURN
190 201
191 if(modules.find(interfaceItems[item]) == modules.end()){ 202 if(modules.find(interfaceItems[item]) == modules.end()){
192 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); 203 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
193 i->showMaximized(); 204 i->showMaximized();
194 i->show(); 205 i->show();
195 } 206 }
196 else{ 207 else{
197 QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB"); 208 QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB");
198 InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); 209 InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
199 t->insertTab(i, "TCP/IP"); 210 t->insertTab(i, "TCP/IP");
200 t->show(); 211 t->show();
201 } 212 }
202} 213}
203 214
204/** 215/**
205 * Aquire the list of active interfaces from ifconfig 216 * Aquire the list of active interfaces from ifconfig
206 * Call ifconfig and ifconfig -a 217 * Call ifconfig and ifconfig -a
207 */ 218 */
208void MainWindowImp::getInterfaceList(){ 219void MainWindowImp::getInterfaceList(){
209 KShellProcess *processAll = new KShellProcess(); 220 KShellProcess *processAll = new KShellProcess();
210 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 221 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
211 connect(processAll, SIGNAL(processExited(KProcess *)), 222 connect(processAll, SIGNAL(processExited(KProcess *)),
212 this, SLOT(jobDone(KProcess *))); 223 this, SLOT(jobDone(KProcess *)));
213 threads.insert(processAll, TEMP_ALL); 224 threads.insert(processAll, TEMP_ALL);
214 processAll->start(KShellProcess::NotifyOnExit); 225 processAll->start(KShellProcess::NotifyOnExit);
215 226
216 KShellProcess *process = new KShellProcess(); 227 KShellProcess *process = new KShellProcess();
217 *process << "/sbin/ifconfig" << " > " TEMP_UP; 228 *process << "/sbin/ifconfig" << " > " TEMP_UP;
218 connect(process, SIGNAL(processExited(KProcess *)), 229 connect(process, SIGNAL(processExited(KProcess *)),
219 this, SLOT(jobDone(KProcess *))); 230 this, SLOT(jobDone(KProcess *)));
220 threads.insert(process, TEMP_UP); 231 threads.insert(process, TEMP_UP);
221 process->start(KShellProcess::NotifyOnExit); 232 process->start(KShellProcess::NotifyOnExit);
222} 233}
223 234
224void MainWindowImp::jobDone(KProcess *process){ 235void MainWindowImp::jobDone(KProcess *process){
225 QString fileName = threads[process]; 236 QString fileName = threads[process];
226 threads.remove(process); 237 threads.remove(process);
227 delete process; 238 delete process;
228 239
229 QFile file(fileName); 240 QFile file(fileName);
230 if (!file.open(IO_ReadOnly)){ 241 if (!file.open(IO_ReadOnly)){
231 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 242 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
232 return; 243 return;
233 } 244 }
234 245
235 QTextStream stream( &file ); 246 QTextStream stream( &file );
236 QString line; 247 QString line;
237 while ( !stream.eof() ) { 248 while ( !stream.eof() ) {
238 line = stream.readLine(); 249 line = stream.readLine();
239 int space = line.find(" "); 250 int space = line.find(" ");
240 if(space > 1){ 251 if(space > 1){
241 // We have found an interface 252 // We have found an interface
242 QString interfaceName = line.mid(0, space); 253 QString interfaceName = line.mid(0, space);
243 Interface *i; 254 Interface *i;
244 // See if we already have it 255 // See if we already have it
245 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 256 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
246 if(fileName == TEMP_ALL) 257 if(fileName == TEMP_ALL)
247 i = new Interface(interfaceName, false); 258 i = new Interface(interfaceName, false);
248 else 259 else
249 i = new Interface(interfaceName, true); 260 i = new Interface(interfaceName, true);
250 } 261 }
251 else{ 262 else{
252 i = interfaceNames[interfaceName]; 263 i = interfaceNames[interfaceName];
253 if(fileName != TEMP_ALL) 264 if(fileName != TEMP_ALL)
254 i->setStatus(true); 265 i->setStatus(true);
255 } 266 }
256 267
257 i->setAttached(true); 268 i->setAttached(true);
258 i->setInterfaceName(interfaceName); 269 i->setInterfaceName(interfaceName);
259 270
260 QString hardName = "Ethernet"; 271 QString hardName = "Ethernet";
261 int hardwareName = line.find("Link encap:"); 272 int hardwareName = line.find("Link encap:");
262 int macAddress = line.find("HWaddr"); 273 int macAddress = line.find("HWaddr");
263 if(macAddress == -1) 274 if(macAddress == -1)
264 macAddress = line.length(); 275 macAddress = line.length();
265 if(hardwareName != -1) 276 if(hardwareName != -1)
266 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); 277 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
267 // We have found an interface 278 // We have found an interface
268 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 279 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
269 interfaceNames.insert(i->getInterfaceName(), i); 280 interfaceNames.insert(i->getInterfaceName(), i);
270 updateInterface(i); 281 updateInterface(i);
271 } 282 }
272 } 283 }
273 file.close(); 284 file.close();
274 QFile::remove(fileName); 285 QFile::remove(fileName);
275} 286}
276 287
277void MainWindowImp::updateInterface(Interface *i){ 288void MainWindowImp::updateInterface(Interface *i){
278 QListViewItem *item = NULL; 289 QListViewItem *item = NULL;
279 290
280 // See if we already have it 291 // See if we already have it
281 if(items.find(i) == items.end()){ 292 if(items.find(i) == items.end()){
282 item = new QListViewItem(serviceList, "", "", ""); 293 item = new QListViewItem(serviceList, "", "", "");
283 // See if you can't find a module owner for this interface 294 // See if you can't find a module owner for this interface
284 //EmployeeMap::Iterator it; 295 //EmployeeMap::Iterator it;
285 //for( it = map.begin(); it != map.end(); ++it ) 296 //for( it = map.begin(); it != map.end(); ++it )
286 // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() ); 297 // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() );
287 298
288 items.insert(i, item); 299 items.insert(i, item);
289 interfaceItems.insert(item, i); 300 interfaceItems.insert(item, i);
290 } 301 }
291 else 302 else
292 item = items[i]; 303 item = items[i];
293 304
294 QString statusImage = "down"; 305 QString statusImage = "down";
295 if(i->getStatus()) 306 if(i->getStatus())
296 statusImage = "up"; 307 statusImage = "up";
297 QPixmap status = (Resource::loadPixmap(statusImage)); 308 QPixmap status = (Resource::loadPixmap(statusImage));
298 item->setPixmap(0, status); 309 item->setPixmap(0, status);
299 310
300 QString typeName = "lan"; 311 QString typeName = "lan";
301 if(i->getHardwareName().contains("Local Loopback")) 312 if(i->getHardwareName().contains("Local Loopback"))
302 typeName = "lo"; 313 typeName = "lo";
303 QPixmap type = (Resource::loadPixmap(typeName)); 314 QPixmap type = (Resource::loadPixmap(typeName));
304 item->setPixmap(1, type); 315 item->setPixmap(1, type);
305 316
306 item->setText(2, i->getHardwareName()); 317 item->setText(2, i->getHardwareName());
307 318
308} 319}
309 320
321/**
322 * Adds a new profile to the list of profiles.
323 * Don't add profiles that already exists.
324 * Appends to the combo and QStringList
325 */
310void MainWindowImp::addProfile(){ 326void MainWindowImp::addProfile(){
327 QString newProfileName = "New";
328 if(profiles.grep(newProfileName).count() > 0){
329 QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
330 return;
331 }
332 profiles.append(newProfileName);
333 profilesList->insertItem(newProfileName);
311 334
312} 335}
313 336
337/**
338 * Removes the currently selected profile in the combo.
339 * Doesn't delete if there are less then 2 profiles.
340 */
314void MainWindowImp::removeProfile(){ 341void MainWindowImp::removeProfile(){
342 if(profilesList->count() <= 1){
343 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
344 return;
345 }
346 QString profileToRemove = profilesList->currentText();
347 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
348 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
349 profilesList->clear();
350 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
351 profilesList->insertItem((*it));
352 }
353
354}
315 355
356/**
357 * A new profile has been selected, change.
358 * @param newProfile the new profile.
359 */
360void MainWindowImp::changeProfile(const QString& newProfile){
361 currentProfileLabel->setText(newProfile);
316} 362}
317 363
318// mainwindowimp.cpp 364// mainwindowimp.cpp
319 365
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 0618dd2..8e300bf 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -1,56 +1,57 @@
1#ifndef MAINWINOWIMP_H 1#ifndef MAINWINOWIMP_H
2#define MAINWINOWIMP_H 2#define MAINWINOWIMP_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8class Module; 8class Module;
9class Interface; 9class Interface;
10class QLibrary; 10class QLibrary;
11class KProcess; 11class KProcess;
12 12
13class MainWindowImp : public MainWindow { 13class MainWindowImp : public MainWindow {
14 Q_OBJECT 14 Q_OBJECT
15 15
16public: 16public:
17 MainWindowImp(QWidget *parent=0, const char *name=0); 17 MainWindowImp(QWidget *parent=0, const char *name=0);
18 ~MainWindowImp(); 18 ~MainWindowImp();
19 19
20private slots: 20private slots:
21 void addClicked(); 21 void addClicked();
22 void removeClicked(); 22 void removeClicked();
23 void configureClicked(); 23 void configureClicked();
24 void informationClicked(); 24 void informationClicked();
25 25
26 void jobDone(KProcess *process); 26 void jobDone(KProcess *process);
27 void getInterfaceList(); 27 void getInterfaceList();
28 28
29 void addProfile(); 29 void addProfile();
30 void removeProfile(); 30 void removeProfile();
31 void changeProfile(const QString&);
31 32
32 void updateInterface(Interface *i); 33 void updateInterface(Interface *i);
33 34
34private: 35private:
35 void loadModules(QString path); 36 void loadModules(QString path);
36 37
37 Module* loadPlugin(QString pluginFileName, 38 Module* loadPlugin(QString pluginFileName,
38 QString resolveString = "create_plugin"); 39 QString resolveString = "create_plugin");
39 40
40 // For our local list of names 41 // For our local list of names
41 QMap<QString, Interface*> interfaceNames; 42 QMap<QString, Interface*> interfaceNames;
42 43
43 QMap<Module*, QLibrary*> libraries; 44 QMap<Module*, QLibrary*> libraries;
44 QMap<Interface*, Module*> modules; 45 QMap<Interface*, Module*> modules;
45 QMap<Interface*, QListViewItem*> items; 46 QMap<Interface*, QListViewItem*> items;
46 QMap<QListViewItem*, Interface*> interfaceItems; 47 QMap<QListViewItem*, Interface*> interfaceItems;
47 48
48 QMap<KProcess*, QString> threads; 49 QMap<KProcess*, QString> threads;
49 QStringList profiles; 50 QStringList profiles;
50 51
51}; 52};
52 53
53#endif 54#endif
54 55
55// mainwindowimp.h 56// mainwindowimp.h
56 57