summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindow
authormickeyl <mickeyl>2004-07-06 18:34:54 (UTC)
committer mickeyl <mickeyl>2004-07-06 18:34:54 (UTC)
commitda843f0c0571fd3d67d797c8fa80e2672056af4b (patch) (unidiff)
tree441b591b9e59ece79275bf83157cd023c24c6005 /noncore/settings/networksettings/mainwindow
parent7cb107b4be2d07ac8849d2ea1e41ea0318017048 (diff)
downloadopie-da843f0c0571fd3d67d797c8fa80e2672056af4b.zip
opie-da843f0c0571fd3d67d797c8fa80e2672056af4b.tar.gz
opie-da843f0c0571fd3d67d797c8fa80e2672056af4b.tar.bz2
CLEANUP: make networksettings directory structure packaging-friendly
Diffstat (limited to 'noncore/settings/networksettings/mainwindow') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindow/.cvsignore29
-rw-r--r--noncore/settings/networksettings/mainwindow/addconnection.ui158
-rw-r--r--noncore/settings/networksettings/mainwindow/addconnectionimp.cpp41
-rw-r--r--noncore/settings/networksettings/mainwindow/addconnectionimp.h28
-rw-r--r--noncore/settings/networksettings/mainwindow/defaultmodule.h26
-rw-r--r--noncore/settings/networksettings/mainwindow/main.cpp7
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindow.pro11
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindow.ui451
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.cpp749
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.h75
-rw-r--r--noncore/settings/networksettings/mainwindow/module.h188
11 files changed, 1763 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/mainwindow/.cvsignore b/noncore/settings/networksettings/mainwindow/.cvsignore
new file mode 100644
index 0000000..e000724
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/.cvsignore
@@ -0,0 +1,29 @@
1*.moc
2*.moc.o
3*.o
4.deps
5.libs
6.moc.cpp
7.moc.o
8.o
9Makefile*
10addconnection.cpp
11addconnection.h
12interfaceadvanced.cpp
13interfaceadvanced.h
14interfaceinformation.cpp
15interfaceinformation.h
16interfacesetup.cpp
17interfacesetup.h
18mainwindow.cpp
19mainwindow.h
20moc_*.cpp
21networksetup
22systemadvanced.cpp
23systemadvanced.h
24hosts.h
25hosts.cpp
26vpn.h
27vpn.cpp
28dns.h
29dns.cpp
diff --git a/noncore/settings/networksettings/mainwindow/addconnection.ui b/noncore/settings/networksettings/mainwindow/addconnection.ui
new file mode 100644
index 0000000..da6cf06
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/addconnection.ui
@@ -0,0 +1,158 @@
1<!DOCTYPE UI><UI>
2<class>AddConnection</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>AddConnection</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>229</width>
15 <height>268</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Add Network Connection</string>
21 </property>
22 <grid>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget row="3" column="1" >
32 <class>QPushButton</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>cancelButton</cstring>
36 </property>
37 <property stdset="1">
38 <name>text</name>
39 <string>&amp;Cancel</string>
40 </property>
41 </widget>
42 <widget row="3" column="0" >
43 <class>QPushButton</class>
44 <property stdset="1">
45 <name>name</name>
46 <cstring>addButton</cstring>
47 </property>
48 <property stdset="1">
49 <name>text</name>
50 <string>&amp;Add</string>
51 </property>
52 </widget>
53 <widget row="0" column="0" rowspan="1" colspan="2" >
54 <class>QListView</class>
55 <column>
56 <property>
57 <name>text</name>
58 <string>Services</string>
59 </property>
60 <property>
61 <name>clickable</name>
62 <bool>true</bool>
63 </property>
64 <property>
65 <name>resizeable</name>
66 <bool>true</bool>
67 </property>
68 </column>
69 <property stdset="1">
70 <name>name</name>
71 <cstring>registeredServicesList</cstring>
72 </property>
73 <property stdset="1">
74 <name>sizePolicy</name>
75 <sizepolicy>
76 <hsizetype>7</hsizetype>
77 <vsizetype>3</vsizetype>
78 </sizepolicy>
79 </property>
80 <property stdset="1">
81 <name>minimumSize</name>
82 <size>
83 <width>0</width>
84 <height>75</height>
85 </size>
86 </property>
87 </widget>
88 <spacer row="2" column="1" >
89 <property>
90 <name>name</name>
91 <cstring>Spacer12</cstring>
92 </property>
93 <property stdset="1">
94 <name>orientation</name>
95 <enum>Vertical</enum>
96 </property>
97 <property stdset="1">
98 <name>sizeType</name>
99 <enum>Expanding</enum>
100 </property>
101 <property>
102 <name>sizeHint</name>
103 <size>
104 <width>20</width>
105 <height>20</height>
106 </size>
107 </property>
108 </spacer>
109 <widget row="1" column="0" rowspan="1" colspan="2" >
110 <class>QLabel</class>
111 <property stdset="1">
112 <name>name</name>
113 <cstring>help</cstring>
114 </property>
115 <property stdset="1">
116 <name>sizePolicy</name>
117 <sizepolicy>
118 <hsizetype>5</hsizetype>
119 <vsizetype>4</vsizetype>
120 </sizepolicy>
121 </property>
122 <property stdset="1">
123 <name>text</name>
124 <string></string>
125 </property>
126 <property stdset="1">
127 <name>alignment</name>
128 <set>WordBreak|AlignTop|AlignLeft</set>
129 </property>
130 <property>
131 <name>vAlign</name>
132 </property>
133 <property>
134 <name>wordwrap</name>
135 </property>
136 </widget>
137 </grid>
138</widget>
139<connections>
140 <connection>
141 <sender>cancelButton</sender>
142 <signal>clicked()</signal>
143 <receiver>AddConnection</receiver>
144 <slot>reject()</slot>
145 </connection>
146 <connection>
147 <sender>addButton</sender>
148 <signal>clicked()</signal>
149 <receiver>AddConnection</receiver>
150 <slot>accept()</slot>
151 </connection>
152</connections>
153<tabstops>
154 <tabstop>registeredServicesList</tabstop>
155 <tabstop>addButton</tabstop>
156 <tabstop>cancelButton</tabstop>
157</tabstops>
158</UI>
diff --git a/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp b/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp
new file mode 100644
index 0000000..f18d8d1
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/addconnectionimp.cpp
@@ -0,0 +1,41 @@
1#include "addconnectionimp.h"
2#include <qlistview.h>
3#if QT_VERSION < 300
4#include <qlist.h>
5#else
6#include <qptrlist.h>
7#endif
8#include <qlabel.h>
9#include <qheader.h>
10
11/**
12 * Constructor
13 */
14AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){
15 connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed()));
16 registeredServicesList->header()->hide();
17};
18
19/**
20 * The current item changed, update the discription.
21 */
22void AddConnectionImp::changed(){
23 QListViewItem *item = registeredServicesList->currentItem();
24 if(item)
25 help->setText(list[item->text(0)]);
26}
27
28/**
29 * Save a copy of newList for the discriptions and append them all to the view
30 * @param newList the new list of possible interfaces
31 */
32void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){
33 list = newList;
34 QMap<QString, QString>::Iterator it;
35 for( it = list.begin(); it != list.end(); ++it )
36 QListViewItem *item = new QListViewItem(registeredServicesList, it.key());
37 registeredServicesList->setCurrentItem(registeredServicesList->firstChild());
38}
39
40// addserviceimp.cpp
41
diff --git a/noncore/settings/networksettings/mainwindow/addconnectionimp.h b/noncore/settings/networksettings/mainwindow/addconnectionimp.h
new file mode 100644
index 0000000..57e6b20
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/addconnectionimp.h
@@ -0,0 +1,28 @@
1#ifndef ADDCONNECTIONIMP_H
2#define ADDCONNECTIONIMP_H
3
4#include "addconnection.h"
5#include <qmap.h>
6
7class QListViewItem;
8
9class AddConnectionImp : public AddConnection {
10
11Q_OBJECT
12
13public:
14 AddConnectionImp(QWidget *parent=0, const char *name=0, WFlags f=0);
15 void addConnections(const QMap<QString, QString> &newList);
16
17private slots:
18 void changed();
19
20private:
21 QMap<QString, QString> list;
22
23};
24
25#endif
26
27// addconectionimp.h
28
diff --git a/noncore/settings/networksettings/mainwindow/defaultmodule.h b/noncore/settings/networksettings/mainwindow/defaultmodule.h
new file mode 100644
index 0000000..c7791d5
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/defaultmodule.h
@@ -0,0 +1,26 @@
1#ifndef MODULE_H
2#define MODULE_H
3
4#include "module.h"
5
6class QWidget;
7
8class DefaultModule : Module{
9
10public:
11 DefaultModule(){};
12
13 virtual bool isOwner(Interface *i);
14 virtual QWidget *configure();
15 virtual QWidget *information()};
16 virtual QList<Interface> getInterfaces();
17 virtual QMap<QString, QString> possibleNewInterfaces();
18 virtual Interface *addNewInterface(QString name);
19 virtual bool remove(Interface* i);
20
21};
22
23#endif
24
25// module.h
26
diff --git a/noncore/settings/networksettings/mainwindow/main.cpp b/noncore/settings/networksettings/mainwindow/main.cpp
new file mode 100644
index 0000000..e4153c3
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/main.cpp
@@ -0,0 +1,7 @@
1#include "mainwindowimp.h"
2#include <opie2/oapplicationfactory.h>
3
4using namespace Opie::Core;
5OPIE_EXPORT_APP( OApplicationFactory<MainWindowImp> )
6
7
diff --git a/noncore/settings/networksettings/mainwindow/mainwindow.pro b/noncore/settings/networksettings/mainwindow/mainwindow.pro
new file mode 100644
index 0000000..460d4d7
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/mainwindow.pro
@@ -0,0 +1,11 @@
1CONFIG = qt warn_on quick-app
2HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h
3SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp
4INCLUDEPATH += $(OPIEDIR)/include ../interfaces/ .
5DEPENDPATH += $(OPIEDIR)/include ../interfaces/ ../wlan/ ../ppp/
6LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -L../interfaces -linterfaces -lopiecore2 -lopieui2
7INTERFACES = mainwindow.ui addconnection.ui
8TARGET = networksettings
9
10
11include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/mainwindow/mainwindow.ui b/noncore/settings/networksettings/mainwindow/mainwindow.ui
new file mode 100644
index 0000000..a730dd5
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/mainwindow.ui
@@ -0,0 +1,451 @@
1<!DOCTYPE UI><UI>
2<class>MainWindow</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>MainWindow</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>240</width>
15 <height>289</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Network Settings</string>
21 </property>
22 <vbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>0</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QTabWidget</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>tabWidget</cstring>
36 </property>
37 <property stdset="1">
38 <name>enabled</name>
39 <bool>true</bool>
40 </property>
41 <property>
42 <name>layoutMargin</name>
43 </property>
44 <widget>
45 <class>QWidget</class>
46 <property stdset="1">
47 <name>name</name>
48 <cstring>Widget3</cstring>
49 </property>
50 <attribute>
51 <name>title</name>
52 <string>Connections</string>
53 </attribute>
54 <vbox>
55 <property stdset="1">
56 <name>margin</name>
57 <number>0</number>
58 </property>
59 <property stdset="1">
60 <name>spacing</name>
61 <number>6</number>
62 </property>
63 <widget>
64 <class>QListView</class>
65 <column>
66 <property>
67 <name>text</name>
68 <string>s</string>
69 </property>
70 <property>
71 <name>clickable</name>
72 <bool>true</bool>
73 </property>
74 <property>
75 <name>resizeable</name>
76 <bool>true</bool>
77 </property>
78 </column>
79 <column>
80 <property>
81 <name>text</name>
82 <string>t</string>
83 </property>
84 <property>
85 <name>clickable</name>
86 <bool>true</bool>
87 </property>
88 <property>
89 <name>resizeable</name>
90 <bool>true</bool>
91 </property>
92 </column>
93 <column>
94 <property>
95 <name>text</name>
96 <string>Name</string>
97 </property>
98 <property>
99 <name>clickable</name>
100 <bool>true</bool>
101 </property>
102 <property>
103 <name>resizeable</name>
104 <bool>true</bool>
105 </property>
106 </column>
107 <column>
108 <property>
109 <name>text</name>
110 <string>in</string>
111 </property>
112 <property>
113 <name>clickable</name>
114 <bool>true</bool>
115 </property>
116 <property>
117 <name>resizeable</name>
118 <bool>true</bool>
119 </property>
120 </column>
121 <column>
122 <property>
123 <name>text</name>
124 <string>IP</string>
125 </property>
126 <property>
127 <name>clickable</name>
128 <bool>true</bool>
129 </property>
130 <property>
131 <name>resizeable</name>
132 <bool>true</bool>
133 </property>
134 </column>
135 <property stdset="1">
136 <name>name</name>
137 <cstring>connectionList</cstring>
138 </property>
139 <property stdset="1">
140 <name>allColumnsShowFocus</name>
141 <bool>true</bool>
142 </property>
143 <property>
144 <name>whatsThis</name>
145 <string>A list of network settings to be choosen from</string>
146 </property>
147 </widget>
148 <widget>
149 <class>QLayoutWidget</class>
150 <property stdset="1">
151 <name>name</name>
152 <cstring>Layout2</cstring>
153 </property>
154 <property>
155 <name>layoutMargin</name>
156 </property>
157 <grid>
158 <property stdset="1">
159 <name>margin</name>
160 <number>5</number>
161 </property>
162 <property stdset="1">
163 <name>spacing</name>
164 <number>6</number>
165 </property>
166 <widget row="1" column="0" >
167 <class>QPushButton</class>
168 <property stdset="1">
169 <name>name</name>
170 <cstring>addConnectionButton</cstring>
171 </property>
172 <property stdset="1">
173 <name>text</name>
174 <string>&amp;Add</string>
175 </property>
176 <property>
177 <name>whatsThis</name>
178 <string>Add a new interface to the list.</string>
179 </property>
180 </widget>
181 <widget row="0" column="0" >
182 <class>QPushButton</class>
183 <property stdset="1">
184 <name>name</name>
185 <cstring>informationConnectionButton</cstring>
186 </property>
187 <property stdset="1">
188 <name>text</name>
189 <string>&amp;Start/Stop</string>
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>
195 </widget>
196 <widget row="0" column="1" >
197 <class>QPushButton</class>
198 <property stdset="1">
199 <name>name</name>
200 <cstring>configureConnectionButton</cstring>
201 </property>
202 <property stdset="1">
203 <name>text</name>
204 <string>&amp;Configure</string>
205 </property>
206 <property>
207 <name>whatsThis</name>
208 <string>Configure the current interface</string>
209 </property>
210 </widget>
211 <widget row="1" column="1" >
212 <class>QPushButton</class>
213 <property stdset="1">
214 <name>name</name>
215 <cstring>removeConnectionButton</cstring>
216 </property>
217 <property stdset="1">
218 <name>text</name>
219 <string>&amp;Remove</string>
220 </property>
221 <property>
222 <name>whatsThis</name>
223 <string>Remove the current interface from the list.</string>
224 </property>
225 </widget>
226 </grid>
227 </widget>
228 </vbox>
229 </widget>
230 <widget>
231 <class>QWidget</class>
232 <property stdset="1">
233 <name>name</name>
234 <cstring>tab</cstring>
235 </property>
236 <attribute>
237 <name>title</name>
238 <string>Profiles</string>
239 </attribute>
240 <grid>
241 <property stdset="1">
242 <name>margin</name>
243 <number>11</number>
244 </property>
245 <property stdset="1">
246 <name>spacing</name>
247 <number>6</number>
248 </property>
249 <spacer row="7" column="2" >
250 <property>
251 <name>name</name>
252 <cstring>Spacer16</cstring>
253 </property>
254 <property stdset="1">
255 <name>orientation</name>
256 <enum>Vertical</enum>
257 </property>
258 <property stdset="1">
259 <name>sizeType</name>
260 <enum>Expanding</enum>
261 </property>
262 <property>
263 <name>sizeHint</name>
264 <size>
265 <width>20</width>
266 <height>20</height>
267 </size>
268 </property>
269 </spacer>
270 <widget row="0" column="1" >
271 <class>QLabel</class>
272 <property stdset="1">
273 <name>name</name>
274 <cstring>currentProfileLabel</cstring>
275 </property>
276 <property stdset="1">
277 <name>frameShape</name>
278 <enum>Panel</enum>
279 </property>
280 <property stdset="1">
281 <name>frameShadow</name>
282 <enum>Sunken</enum>
283 </property>
284 <property stdset="1">
285 <name>text</name>
286 <string>All</string>
287 </property>
288 </widget>
289 <widget row="3" column="2" >
290 <class>QPushButton</class>
291 <property stdset="1">
292 <name>name</name>
293 <cstring>setCurrentProfileButton</cstring>
294 </property>
295 <property stdset="1">
296 <name>text</name>
297 <string>&amp;Set Current</string>
298 </property>
299 </widget>
300 <widget row="5" column="0" rowspan="1" colspan="3" >
301 <class>Line</class>
302 <property stdset="1">
303 <name>name</name>
304 <cstring>Line6</cstring>
305 </property>
306 <property stdset="1">
307 <name>orientation</name>
308 <enum>Horizontal</enum>
309 </property>
310 </widget>
311 <widget row="1" column="0" rowspan="1" colspan="3" >
312 <class>Line</class>
313 <property stdset="1">
314 <name>name</name>
315 <cstring>Line1</cstring>
316 </property>
317 <property stdset="1">
318 <name>orientation</name>
319 <enum>Horizontal</enum>
320 </property>
321 </widget>
322 <widget row="0" column="0" >
323 <class>QLabel</class>
324 <property stdset="1">
325 <name>name</name>
326 <cstring>TextLabel1</cstring>
327 </property>
328 <property stdset="1">
329 <name>text</name>
330 <string>Current Profile</string>
331 </property>
332 </widget>
333 <widget row="4" column="2" >
334 <class>QPushButton</class>
335 <property stdset="1">
336 <name>name</name>
337 <cstring>removeProfileButton</cstring>
338 </property>
339 <property stdset="1">
340 <name>text</name>
341 <string>&amp;Remove</string>
342 </property>
343 </widget>
344 <widget row="3" column="0" rowspan="2" colspan="2" >
345 <class>QListBox</class>
346 <property stdset="1">
347 <name>name</name>
348 <cstring>profilesList</cstring>
349 </property>
350 </widget>
351 <spacer row="0" column="2" >
352 <property>
353 <name>name</name>
354 <cstring>Spacer2</cstring>
355 </property>
356 <property stdset="1">
357 <name>orientation</name>
358 <enum>Horizontal</enum>
359 </property>
360 <property stdset="1">
361 <name>sizeType</name>
362 <enum>Expanding</enum>
363 </property>
364 <property>
365 <name>sizeHint</name>
366 <size>
367 <width>20</width>
368 <height>20</height>
369 </size>
370 </property>
371 </spacer>
372 <widget row="2" column="0" >
373 <class>QLabel</class>
374 <property stdset="1">
375 <name>name</name>
376 <cstring>TextLabel1_2</cstring>
377 </property>
378 <property stdset="1">
379 <name>text</name>
380 <string>Profiles</string>
381 </property>
382 </widget>
383 <widget row="6" column="0" rowspan="1" colspan="3" >
384 <class>QLayoutWidget</class>
385 <property stdset="1">
386 <name>name</name>
387 <cstring>Layout6</cstring>
388 </property>
389 <hbox>
390 <property stdset="1">
391 <name>margin</name>
392 <number>0</number>
393 </property>
394 <property stdset="1">
395 <name>spacing</name>
396 <number>6</number>
397 </property>
398 <widget>
399 <class>QLabel</class>
400 <property stdset="1">
401 <name>name</name>
402 <cstring>TextLabel1_3</cstring>
403 </property>
404 <property stdset="1">
405 <name>text</name>
406 <string>New Profile</string>
407 </property>
408 </widget>
409 <widget>
410 <class>QLineEdit</class>
411 <property stdset="1">
412 <name>name</name>
413 <cstring>newProfile</cstring>
414 </property>
415 </widget>
416 <widget>
417 <class>QPushButton</class>
418 <property stdset="1">
419 <name>name</name>
420 <cstring>newProfileButton</cstring>
421 </property>
422 <property stdset="1">
423 <name>enabled</name>
424 <bool>false</bool>
425 </property>
426 <property stdset="1">
427 <name>text</name>
428 <string>&amp;Add</string>
429 </property>
430 </widget>
431 </hbox>
432 </widget>
433 </grid>
434 </widget>
435 </widget>
436 </vbox>
437</widget>
438<tabstops>
439 <tabstop>tabWidget</tabstop>
440 <tabstop>connectionList</tabstop>
441 <tabstop>informationConnectionButton</tabstop>
442 <tabstop>configureConnectionButton</tabstop>
443 <tabstop>addConnectionButton</tabstop>
444 <tabstop>removeConnectionButton</tabstop>
445 <tabstop>profilesList</tabstop>
446 <tabstop>setCurrentProfileButton</tabstop>
447 <tabstop>removeProfileButton</tabstop>
448 <tabstop>newProfile</tabstop>
449 <tabstop>newProfileButton</tabstop>
450</tabstops>
451</UI>
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
new file mode 100644
index 0000000..5184630
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
@@ -0,0 +1,749 @@
1
2#include "mainwindowimp.h"
3#include "addconnectionimp.h"
4#include "interfaceinformationimp.h"
5#include "interfacesetupimp.h"
6#include "interfaces.h"
7#include "module.h"
8
9/* OPIE */
10#include <opie2/odebug.h>
11#include <qpe/qcopenvelope_qws.h>
12#include <qpe/qpeapplication.h>
13#include <qpe/config.h>
14#include <qpe/qlibrary.h>
15#include <qpe/resource.h>
16
17/* QT */
18#include <qpushbutton.h>
19#include <qlistbox.h>
20#include <qlineedit.h>
21#include <qlistview.h>
22#include <qheader.h>
23#include <qlabel.h>
24#include <qtabwidget.h> // in order to disable the profiles tab
25#include <qmessagebox.h>
26
27
28#if QT_VERSION < 300
29#include <qlist.h>
30#else
31#include <qptrlist.h>
32#endif
33#include <qdir.h>
34#include <qfile.h>
35#include <qtextstream.h>
36#include <qregexp.h>
37
38/* STD */
39#include <net/if.h>
40#include <sys/ioctl.h>
41#include <sys/socket.h>
42
43#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
44#define _PROCNETDEV "/proc/net/dev"
45
46MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME)
47{
48 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
49 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
50 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
51 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
52
53 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
54 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
55 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
56
57 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
58
59 //FIXME: disable profiles for the moment:
60 tabWidget->setTabEnabled( tab, false );
61
62 // Load connections.
63 // /usr/local/kde/lib/libinterfaces.la
64#ifdef QWS
65 loadModules(QPEApplication::qpeDir() + "plugins/networksettings");
66#else
67 loader = KLibLoader::self();
68 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
69#endif
70 getAllInterfaces();
71
72 Interfaces i;
73 QStringList list = i.getInterfaceList();
74 QMap<QString, Interface*>::Iterator it;
75 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni )
76 {
77 /*
78 * we skipped it in getAllInterfaces now
79 * we need to ignore it as well
80 */
81 if (m_handledIfaces.contains( *ni) )
82 {
83 odebug << "Not up iface handled by module" << oendl;
84 continue;
85 }
86 bool found = false;
87 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it )
88 {
89 if(it.key() == (*ni))
90 found = true;
91 }
92 if(!found)
93 {
94 if(!(*ni).contains("_"))
95 {
96 Interface *i = new Interface(this, *ni, false);
97 i->setAttached(false);
98 i->setHardwareName(tr("Disconnected"));
99 interfaceNames.insert(i->getInterfaceName(), i);
100 updateInterface(i);
101 connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*)));
102 }
103 }
104 }
105
106 //getInterfaceList();
107 connectionList->header()->hide();
108
109 Config cfg("NetworkSetup");
110 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
111 for ( QStringList::Iterator it = profiles.begin();
112 it != profiles.end(); ++it)
113 profilesList->insertItem((*it));
114 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
115 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
116 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
117
118 QFile file(scheme);
119 if ( file.open(IO_ReadOnly) )
120 { // file opened successfully
121 QTextStream stream( &file ); // use a text stream
122 while ( !stream.eof() )
123 { // until end of file...
124 QString line = stream.readLine(); // line of text excluding '\n'
125 if(line.contains("SCHEME"))
126 {
127 line = line.mid(7, line.length());
128 currentProfileLabel->setText(line);
129 break;
130 }
131 }
132 file.close();
133 }
134 makeChannel();
135}
136
137/**
138 * Deconstructor. Save profiles. Delete loaded libraries.
139 */
140MainWindowImp::~MainWindowImp()
141{
142 // Save profiles.
143 Config cfg("NetworkSetup");
144 cfg.setGroup("General");
145 cfg.writeEntry("Profiles", profiles.join(" "));
146
147 // Delete all interfaces that don't have owners.
148 QMap<Interface*, QListViewItem*>::Iterator iIt;
149 for( iIt = items.begin(); iIt != items.end(); ++iIt )
150 {
151 if(iIt.key()->getModuleOwner() == NULL)
152 delete iIt.key();
153 }
154
155#ifdef QWS
156 // Delete Modules and Libraries
157 QMap<Module*, QLibrary*>::Iterator it;
158 for( it = libraries.begin(); it != libraries.end(); ++it )
159 {
160 delete it.key();
161 // I wonder why I can't delete the libraries
162 // What fucking shit this is.
163 //delete it.data();
164 }
165#else
166 // klibloader automaticly deletes the libraries for us...
167#endif
168}
169
170/**
171 * Query the kernel for all of the interfaces.
172 */
173void MainWindowImp::getAllInterfaces()
174{
175 int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
176 if(sockfd == -1)
177 return;
178
179 struct ifreq ifr;
180 QStringList ifaces;
181 QFile procFile(QString(_PROCNETDEV));
182 int result;
183 Interface *i;
184
185 if (! procFile.exists())
186 {
187 struct ifreq ifrs[100];
188 struct ifconf ifc;
189 ifc.ifc_len = sizeof(ifrs);
190 ifc.ifc_req = ifrs;
191 result = ioctl(sockfd, SIOCGIFCONF, &ifc);
192
193 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++)
194 {
195 struct ifreq *pifr = &ifrs[i];
196
197 ifaces += pifr->ifr_name;
198 }
199 }
200 else
201 {
202 procFile.open(IO_ReadOnly);
203 QString line;
204 QTextStream procTs(&procFile);
205 int loc = -1;
206
207 procTs.readLine(); // eat a line
208 procTs.readLine(); // eat a line
209 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null)
210 {
211 if((loc = line.find(":")) != -1)
212 {
213 ifaces += line.left(loc);
214 }
215 }
216 }
217
218 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it)
219 {
220 int flags = 0;
221 if ( m_handledIfaces.contains( (*it) ) )
222 {
223 odebug << " " << (*it).latin1() << " is handled by a module" << oendl;
224 continue;
225 }
226 // int family;
227 i = NULL;
228
229 strcpy(ifr.ifr_name, (*it).latin1());
230
231 struct ifreq ifcopy;
232 ifcopy = ifr;
233 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
234 flags = ifcopy.ifr_flags;
235 i = new Interface(this, ifr.ifr_name, false);
236 i->setAttached(true);
237 if ((flags & IFF_UP) == IFF_UP)
238 i->setStatus(true);
239 else
240 i->setStatus(false);
241
242 if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
243 i->setHardwareName("Ethernet");
244 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
245 i->setHardwareName("Point to Point");
246 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
247 i->setHardwareName("Multicast");
248 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
249 i->setHardwareName("Loopback");
250 else
251 i->setHardwareName("Unknown");
252
253 owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl;
254 interfaceNames.insert(i->getInterfaceName(), i);
255 updateInterface(i);
256 connect(i, SIGNAL(updateInterface(Interface*)),
257 this, SLOT(updateInterface(Interface*)));
258 }
259 // now lets ask the plugins too ;)
260 QMap<Module*, QLibrary*>::Iterator it;
261 QList<Interface> ilist;
262 for( it = libraries.begin(); it != libraries.end(); ++it )
263 {
264 if(it.key())
265 {
266 ilist = it.key()->getInterfaces();
267 for( i = ilist.first(); i != 0; i = ilist.next() )
268 {
269 owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl;
270 interfaceNames.insert(i->getInterfaceName(), i);
271 updateInterface(i);
272 connect(i, SIGNAL(updateInterface(Interface*)),
273 this, SLOT(updateInterface(Interface*)));
274 }
275 }
276 }
277}
278
279/**
280 * Load all modules that are found in the path
281 * @param path a directory that is scaned for any plugins that can be loaded
282 * and attempts to load them
283 */
284void MainWindowImp::loadModules(const QString &path)
285{
286#ifdef DEBUG
287 odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl;
288#endif
289 QDir d(path);
290 if(!d.exists())
291 return;
292
293 // Don't want sym links
294 d.setFilter( QDir::Files | QDir::NoSymLinks );
295 const QFileInfoList *list = d.entryInfoList();
296 QFileInfoListIterator it( *list );
297 QFileInfo *fi;
298 while ( (fi=it.current()) )
299 {
300#ifdef QWS
301 if(fi->fileName().contains(".so"))
302 {
303#else
304 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_"))
305 {
306#endif
307 loadPlugin(path + "/" + fi->fileName());
308 odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl;
309 }
310 ++it;
311 }
312}
313
314/**
315 * Attempt to load a function and resolve a function.
316 * @param pluginFileName - the name of the file in which to attempt to load
317 * @param resolveString - function pointer to resolve
318 * @return pointer to the function with name resolveString or NULL
319 */
320Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString)
321{
322#ifdef DEBUG
323 odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl;
324#endif
325#ifdef QWS
326 QLibrary *lib = new QLibrary(pluginFileName);
327 void *functionPointer = lib->resolve(resolveString);
328 if( !functionPointer )
329 {
330#ifdef DEBUG
331 odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl;
332#endif
333 delete lib;
334 return NULL;
335 }
336 // Try to get an object.
337 Module *object = ((Module* (*)()) functionPointer)();
338 if(object == NULL)
339 {
340#ifdef DEBUG
341 odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl;
342#endif
343 delete lib;
344 return NULL;
345 }
346
347 m_handledIfaces += object->handledInterfaceNames();
348 // Store for deletion later
349 libraries.insert(object, lib);
350 return object;
351
352#else
353 QLibrary *lib = loader->library(pluginFileName);
354 if( !lib || !lib->hasSymbol(resolveString) )
355 {
356 odebug << QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1() << oendl;
357 return NULL;
358 }
359 // Try to get an object.
360 Module *object = ((Module* (*)()) lib->symbol(resolveString))();
361 if(object == NULL)
362 {
363#ifdef DEBUG
364 odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl;
365#endif
366 return NULL;
367 }
368#ifdef DEBUG
369 odebug << "MainWindowImp::loadPlugin:: Found object, storing." << oendl;
370#endif
371 // Store for deletion later
372 libraries.insert(object, lib);
373 return object;
374#endif
375}
376
377/**
378 * The Add button was clicked. Bring up the add dialog and if OK is hit
379 * load the plugin and append it to the list
380 */
381void MainWindowImp::addClicked()
382{
383 QMap<Module*, QLibrary*>::Iterator it;
384 QMap<QString, QString> list;
385 QMap<QString, Module*> newInterfaceOwners;
386
387 for( it = libraries.begin(); it != libraries.end(); ++it )
388 {
389 if(it.key())
390 {
391 (it.key())->possibleNewInterfaces(list);
392 }
393 }
394 // See if the list has anything that we can add.
395 if(list.count() == 0)
396 {
397 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
398 return;
399 }
400 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
401 addNewConnection.addConnections(list);
402 if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) )
403 {
404 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
405 if(!item)
406 return;
407
408 for( it = libraries.begin(); it != libraries.end(); ++it )
409 {
410 if(it.key())
411 {
412 Interface *i = (it.key())->addNewInterface(item->text(0));
413 if(i)
414 {
415 odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl;
416 interfaceNames.insert(i->getInterfaceName(), i);
417 updateInterface(i);
418 }
419 }
420 }
421 }
422}
423
424/**
425 * Prompt the user to see if they really want to do this.
426 * If they do then remove from the list and unload.
427 */
428void MainWindowImp::removeClicked()
429{
430 QListViewItem *item = connectionList->currentItem();
431 if(!item)
432 {
433 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
434 return;
435 }
436
437 Interface *i = interfaceItems[item];
438 if(i->getModuleOwner() == NULL)
439 {
440 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
441 }
442 else
443 {
444 if(!i->getModuleOwner()->remove(i))
445 QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok);
446 else
447 {
448 delete item;
449 // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
450 }
451 }
452}
453
454/**
455 * Pull up the configure about the currently selected interface.
456 * Report an error if no interface is selected.
457 * If the interface has a module owner then request its configure.
458 */
459void MainWindowImp::configureClicked()
460{
461 QListViewItem *item = connectionList->currentItem();
462 if(!item)
463 {
464 QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok);
465 return;
466 }
467
468 QString currentProfileText = currentProfileLabel->text();
469 if(currentProfileText.upper() == "ALL");
470 currentProfileText = "";
471
472 Interface *i = interfaceItems[item];
473
474 if(i->getModuleOwner())
475 {
476 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
477 if(moduleConfigure != NULL)
478 {
479 i->getModuleOwner()->setProfile(currentProfileText);
480 QPEApplication::showWidget( moduleConfigure );
481 return;
482 }
483 }
484
485 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp );
486 configure->setProfile(currentProfileText);
487 QPEApplication::showDialog( configure );
488}
489
490/**
491 * Pull up the information about the currently selected interface.
492 * Report an error if no interface is selected.
493 * If the interface has a module owner then request its configure.
494 */
495void MainWindowImp::informationClicked()
496{
497 QListViewItem *item = connectionList->currentItem();
498 if(!item)
499 {
500 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
501 return;
502 }
503
504 Interface *i = interfaceItems[item];
505 // if(!i->isAttached()){
506 // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
507 // return;
508 // }
509
510 if(i->getModuleOwner())
511 {
512 QWidget *moduleInformation = i->getModuleOwner()->information(i);
513 if(moduleInformation != NULL)
514 {
515 QPEApplication::showWidget( moduleInformation );
516#ifdef DEBUG
517 odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl;
518#endif
519 return;
520 }
521 }
522 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp);
523 QPEApplication::showWidget( information );
524}
525
526/**
527 * Update this interface. If no QListViewItem exists create one.
528 * @param Interface* pointer to the interface that needs to be updated.
529 */
530void MainWindowImp::updateInterface(Interface *i)
531{
532 if(!advancedUserMode)
533 {
534 if(i->getInterfaceName() == "lo")
535 return;
536 }
537
538 QListViewItem *item = NULL;
539
540 // Find the interface, making it if needed.
541 if(items.find(i) == items.end())
542 {
543 item = new QListViewItem(connectionList, "", "", "");
544 // See if you can't find a module owner for this interface
545 QMap<Module*, QLibrary*>::Iterator it;
546 for( it = libraries.begin(); it != libraries.end(); ++it )
547 {
548 if(it.key()->isOwner(i))
549 i->setModuleOwner(it.key());
550 }
551 items.insert(i, item);
552 interfaceItems.insert(item, i);
553 }
554 else
555 item = items[i];
556
557 // Update the icons and information
558#ifdef QWS
559 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
560#else
561 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
562#endif
563
564 QString typeName = "lan";
565 if(i->getInterfaceName() == "lo")
566 typeName = "lo";
567 if(i->getInterfaceName().contains("irda"))
568 typeName = "irda";
569 if(i->getInterfaceName().contains("wlan"))
570 typeName = "wlan";
571 if(i->getInterfaceName().contains("usb"))
572 typeName = "usb";
573
574 if(!i->isAttached())
575 typeName = "connect_no";
576 // Actually try to use the Module
577 if(i->getModuleOwner() != NULL)
578 typeName = i->getModuleOwner()->getPixmapName(i);
579
580#ifdef QWS
581 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName)));
582#else
583 item->setPixmap(1, (SmallIcon(typeName)));
584#endif
585 item->setText(2, i->getHardwareName());
586 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
587 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
588}
589
590void MainWindowImp::newProfileChanged(const QString& newText)
591{
592 if(newText.length() > 0)
593 newProfileButton->setEnabled(true);
594 else
595 newProfileButton->setEnabled(false);
596}
597
598/**
599 * Adds a new profile to the list of profiles.
600 * Don't add profiles that already exists.
601 * Appends to the list and QStringList
602 */
603void MainWindowImp::addProfile()
604{
605 QString newProfileName = newProfile->text();
606 if(profiles.grep(newProfileName).count() > 0)
607 {
608 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
609 return;
610 }
611 profiles.append(newProfileName);
612 profilesList->insertItem(newProfileName);
613}
614
615/**
616 * Removes the currently selected profile in the combo.
617 * Doesn't delete if there are less then 2 profiles.
618 */
619void MainWindowImp::removeProfile()
620{
621 if(profilesList->count() <= 1)
622 {
623 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
624 return;
625 }
626 QString profileToRemove = profilesList->currentText();
627 if(profileToRemove == "All")
628 {
629 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
630 return;
631 }
632 // Can't remove the curent profile
633 if(profileToRemove == currentProfileLabel->text())
634 {
635 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
636 return;
637
638 }
639
640 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
641 {
642 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
643 profilesList->clear();
644 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
645 profilesList->insertItem((*it));
646
647 // Remove any interface settings and mappings.
648 Interfaces interfaces;
649 // Go through them one by one
650 QMap<Interface*, QListViewItem*>::Iterator it;
651 for( it = items.begin(); it != items.end(); ++it )
652 {
653 QString interfaceName = it.key()->getInterfaceName();
654 odebug << interfaceName.latin1() << oendl;
655 if(interfaces.setInterface(interfaceName + "_" + profileToRemove))
656 {
657 interfaces.removeInterface();
658 if(interfaces.setMapping(interfaceName))
659 {
660 if(profilesList->count() == 1)
661 interfaces.removeMapping();
662 else
663 {
664 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
665 }
666 }
667 interfaces.write();
668 break;
669 }
670 }
671 }
672}
673
674/**
675 * A new profile has been selected, change.
676 * @param newProfile the new profile.
677 */
678void MainWindowImp::changeProfile()
679{
680 if(profilesList->currentItem() == -1)
681 {
682 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
683 return;
684 }
685 QString newProfile = profilesList->text(profilesList->currentItem());
686 if(newProfile != currentProfileLabel->text())
687 {
688 currentProfileLabel->setText(newProfile);
689 QFile::remove(scheme);
690 QFile file(scheme);
691 if ( file.open(IO_ReadWrite) )
692 {
693 QTextStream stream( &file );
694 stream << QString("SCHEME=%1").arg(newProfile);
695 file.close();
696 }
697 // restart all up devices?
698 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok)
699 {
700 // Go through them one by one
701 QMap<Interface*, QListViewItem*>::Iterator it;
702 for( it = items.begin(); it != items.end(); ++it )
703 {
704 if(it.key()->getStatus() == true)
705 it.key()->restart();
706 }
707 }
708 }
709 // TODO change the profile in the modules
710}
711
712
713void MainWindowImp::makeChannel()
714{
715 channel = new QCopChannel( "QPE/Application/networksettings", this );
716 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
717 this, SLOT(receive(const QCString&,const QByteArray&)) );
718}
719
720void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
721{
722 bool found = false;
723 odebug << "MainWindowImp::receive QCop msg >"+msg+"<" << oendl;
724 if (msg == "raise")
725 {
726 raise();
727 return;
728 }
729
730 QString dest = msg.left(msg.find("("));
731 QCString param = msg.right(msg.length() - msg.find("(") - 1);
732 param = param.left( param.length() - 1 );
733 odebug << "dest >" << dest.latin1() << "< param >"+param+"<" << oendl;
734
735 QMap<Module*, QLibrary*>::Iterator it;
736 for( it = libraries.begin(); it != libraries.end(); ++it )
737 {
738 odebug << "plugin >" << it.key()->type().latin1() << "<" << oendl;
739 if(it.key()->type() == dest)
740 {
741 it.key()->receive( param, arg );
742 found = true;
743 }
744 }
745
746
747 if (found) QPEApplication::setKeepRunning();
748 else odebug << "Huh what do ya want" << oendl;
749}
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.h b/noncore/settings/networksettings/mainwindow/mainwindowimp.h
new file mode 100644
index 0000000..f211d6e
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.h
@@ -0,0 +1,75 @@
1#ifndef MAINWINOWIMP_H
2#define MAINWINOWIMP_H
3
4#include "mainwindow.h"
5#include <qmap.h>
6#include <qstringlist.h>
7
8class Module;
9class Interface;
10class QLibrary;
11class KProcess;
12class QCopChannel;
13#ifdef QWS
14class QLibrary;
15#else
16class KLibrary;
17class KLibLoader;
18#define QLibrary KLibrary
19#endif
20
21
22class MainWindowImp : public MainWindow {
23 Q_OBJECT
24
25public:
26 static QString appName() { return QString::fromLatin1("networksettings"); }
27 MainWindowImp(QWidget *parent=0, const char *name=0, WFlags fl = 0);
28 ~MainWindowImp();
29
30 QCopChannel *channel;
31
32private slots:
33 void getAllInterfaces();
34
35 void addClicked();
36 void removeClicked();
37 void configureClicked();
38 void informationClicked();
39
40 void addProfile();
41 void removeProfile();
42 void changeProfile();
43
44 void updateInterface(Interface *i);
45 void newProfileChanged(const QString& newText);
46
47 void receive (const QCString &, const QByteArray &);
48
49private:
50 void makeChannel();
51 void loadModules(const QString &path);
52
53 Module* loadPlugin(const QString &pluginFileName,
54 const QString &resolveString = "create_plugin");
55
56 // For our local list of names
57 QMap<QString, Interface*> interfaceNames;
58
59 QMap<Module*, QLibrary*> libraries;
60 QMap<Interface*, QListViewItem*> items;
61 QMap<QListViewItem*, Interface*> interfaceItems;
62 QStringList m_handledIfaces;
63
64 QMap<KProcess*, QString> threads;
65 QStringList profiles;
66
67 bool advancedUserMode;
68 QString scheme;
69#ifndef QWS
70 KLibLoader *loader;
71#endif
72};
73
74#endif // MAINWINOWIMP_H
75
diff --git a/noncore/settings/networksettings/mainwindow/module.h b/noncore/settings/networksettings/mainwindow/module.h
new file mode 100644
index 0000000..9dc913e
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/module.h
@@ -0,0 +1,188 @@
1#ifndef NETCONF_MODULE_H
2#define NETCONF_MODULE_H
3
4#include <qobject.h>
5#if QT_VERSION < 300
6#include <qlist.h>
7#else
8#include <qptrlist.h>
9#endif
10#include <qmap.h>
11#include "interface.h"
12
13class QWidget;
14class QTabWidget;
15
16
17/**
18 * \brief The basis of all plugins
19 *
20 * This is the way to extend networksettings with
21 * extra functionality.
22 *
23 *
24 * Networksettings in the 1.0 release does not use QCOM
25 * for activation. You need to provide the following function yourself.
26 *
27 * A module needs to provide Name, Images, and methods for
28 * claiming interfaces. For example you can claim physicla
29 * interfaces like wlan0, ppp0 or virtual like a VPN
30 * connection and hide the real ppp device or ethernet device
31 * behind your VPN plugin.
32 *
33 * During start up. The main application searches for network devices
34 * and then looks for an owner under the plugins for them.
35 * For example the WLAN Plugin looks if there is a WLAN Extension
36 * on that interface and then claims it by returning true from isOwner()
37 *
38 * \code
39 * extern "C"
40 * {
41 * void* create_plugin() {
42 * return new WLANModule();
43 * }
44 * };
45 * \endcode
46 * @see isOwner(Interface*)
47 */
48class Module : private QObject{
49
50signals:
51/**
52 * Emit this Signal once you change the Interface
53 * you're operating on
54 *
55 * @param i The Interface
56 */
57 void updateInterface(Interface *i);
58
59
60public:
61 Module(){};
62
63 /**
64 * The type of the plugin
65 * and the name of the qcop call
66 */
67 virtual const QString type() = 0;
68
69 /**
70 * The current profile has been changed and the module should do any
71 * neccesary changes also.
72 * As of Opie1.0 profiles are disabled.
73 *
74 * @param newProfile what the profile should be changed to.
75 */
76 virtual void setProfile(const QString &newProfile) = 0;
77
78 /**
79 * get the icon name for this device.
80 * @param Interface* can be used in determining the icon.
81 * @return QString the icon name (minus .png, .gif etc)
82 */
83 virtual QString getPixmapName(Interface *) = 0;
84
85 /**
86 * Check to see if the interface i is owned by this module.
87 * See if you can handle it. And if you can claim ownership
88 * by returning true.
89 * For physical devices you will be asked if you want to own the
90 * device. But you can also create new \sa Interface Implementations.
91 *
92 * If you want to own the Interface add it to your internal interface
93 * list
94 *
95 * @param Interface* interface to check against
96 * @return bool true if i is owned by this module, false otherwise.
97 *
98 * @see getInterfaces
99 */
100 virtual bool isOwner(Interface *){ return false; };
101
102 /**
103 * Create and return the Configure Module
104 * @param Interface *i the interface to configure.
105 * @return QWidget* pointer to this modules configure.
106 *
107 * @see InterfaceSetupImp
108 */
109 virtual QWidget *configure(Interface *){ return NULL; } ;
110
111 /**
112 * Create, and return the Information Module.
113 *
114 * An default Implementation is InterfaceInformationImp
115 *
116 * @param Interface *i the interface to get info on.
117 * @return QWidget* pointer to this modules info.
118 *
119 * @see InterfaceInformationImp
120 *
121 */
122 virtual QWidget *information(Interface *){ return NULL; };
123
124 /**
125 * Get all active (up or down) interfaces managed by this
126 * module.
127 * At the end of initialisation you will be asked to return your interfaces
128 * Return all of your interfaces even the ones you claimed by isOnwer.
129 * Here you can also return your 'virtual' Interface Objects
130 *
131 * @return QList<Interface> A list of interfaces that exsist that havn't
132 * been called by isOwner()
133 */
134 virtual QList<Interface> getInterfaces() = 0;
135
136 /**
137 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
138 * modem ppp)
139 * Both strings need to be translated. The first string is a Shortcut
140 * like PPP and the second argument is a description.
141 *
142 * <code>
143 * list.insert(
144 *
145 * </code>
146 *
147 * @param list A reference to the list of supported additionns.
148 */
149 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
150
151 /**
152 * Attempts to create a new interface from name you gave
153 * possibleNewInterfaces()
154 * @return Interface* NULL if it was unable to be created.
155 * @param name the type of interface to create
156 *
157 * @see possibleNewInterfaces
158 */
159 virtual Interface *addNewInterface(const QString &name) = 0;
160
161 /**
162 * Attempts to remove the interface, doesn't delete i
163 * @return bool true if successful, false otherwise.
164 */
165 virtual bool remove(Interface* i) = 0;
166
167 /**
168 * get dcop calls
169 */
170 virtual void receive(const QCString &msg, const QByteArray &arg) = 0;
171
172 QStringList handledInterfaceNames()const { return m_inter; }
173protected:
174 /**
175 * set which interfaceNames should not be shown cause they're handled
176 * internally of this module.. An already running ppp link or
177 * a tunnel... VPN an such
178 */
179 void setHandledInterfaceNames( const QStringList& in) { m_inter = in; }
180
181private:
182 QStringList m_inter;
183};
184
185#endif
186
187// module.h
188