summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO1
-rw-r--r--noncore/net/networksetup/interfaces.cpp26
-rw-r--r--noncore/net/networksetup/interfaces.h3
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp22
-rw-r--r--noncore/net/networksetup/networksetup.pro6
-rw-r--r--noncore/settings/networksettings/TODO1
-rw-r--r--noncore/settings/networksettings/interfaces.cpp26
-rw-r--r--noncore/settings/networksettings/interfaces.h3
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp22
-rw-r--r--noncore/settings/networksettings/networksetup.pro6
10 files changed, 106 insertions, 10 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index 70d6717..7386646 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,7 +1,8 @@
1[ ] Wlanmodule needs to check if an interface supports wireless 1[ ] Wlanmodule needs to check if an interface supports wireless
2 extensions. 2 extensions.
3[x] When you set options in wlanmodule, hit OK, it exits all of 3[x] When you set options in wlanmodule, hit OK, it exits all of
4 networksetup, doesnt bring you back to the main screen. 4 networksetup, doesnt bring you back to the main screen.
5[x] Wlanmodule isnt writing out wireless.opts 5[x] Wlanmodule isnt writing out wireless.opts
6[ ] Need a means of bringing an interface up and down (calling 6[ ] Need a means of bringing an interface up and down (calling
7 out ifup/ifdown) from the gui. 7 out ifup/ifdown) from the gui.
8 -Ben- Click information, then click up or down... :-D
diff --git a/noncore/net/networksetup/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp
index b8a3e7f..1287d90 100644
--- a/noncore/net/networksetup/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces.cpp
@@ -1,302 +1,326 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qregexp.h> 5#include <qregexp.h>
6 6
7#define AUTO "auto" 7#define AUTO "auto"
8#define IFACE "iface" 8#define IFACE "iface"
9#define MAPPING "mapping" 9#define MAPPING "mapping"
10 10
11/** 11/**
12 * Constructor. Reads in the interfaces file and then split the file up by 12 * Constructor. Reads in the interfaces file and then split the file up by
13 * the \n for interfaces variable. 13 * the \n for interfaces variable.
14 * @param useInterfacesFile if an interface file other then the default is 14 * @param useInterfacesFile if an interface file other then the default is
15 * desired to be used it should be passed in. 15 * desired to be used it should be passed in.
16 */ 16 */
17Interfaces::Interfaces(QString useInterfacesFile){ 17Interfaces::Interfaces(QString useInterfacesFile){
18 acceptedFamily.append(INTERFACES_FAMILY_INET); 18 acceptedFamily.append(INTERFACES_FAMILY_INET);
19 acceptedFamily.append(INTERFACES_FAMILY_IPX); 19 acceptedFamily.append(INTERFACES_FAMILY_IPX);
20 acceptedFamily.append(INTERFACES_FAMILY_INET6); 20 acceptedFamily.append(INTERFACES_FAMILY_INET6);
21 21
22 interfacesFile = useInterfacesFile; 22 interfacesFile = useInterfacesFile;
23 QFile file(interfacesFile); 23 QFile file(interfacesFile);
24 if (!file.open(IO_ReadOnly)){ 24 if (!file.open(IO_ReadOnly)){
25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); 25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
26 currentIface = interfaces.end(); 26 currentIface = interfaces.end();
27 currentMapping = interfaces.end(); 27 currentMapping = interfaces.end();
28 return; 28 return;
29 } 29 }
30 QTextStream stream( &file ); 30 QTextStream stream( &file );
31 QString line; 31 QString line;
32 while ( !stream.eof() ) { 32 while ( !stream.eof() ) {
33 line += stream.readLine(); 33 line += stream.readLine();
34 line += "\n"; 34 line += "\n";
35 } 35 }
36 file.close(); 36 file.close();
37 interfaces = QStringList::split("\n", line, true); 37 interfaces = QStringList::split("\n", line, true);
38 38
39 currentIface = interfaces.end(); 39 currentIface = interfaces.end();
40 currentMapping = interfaces.end(); 40 currentMapping = interfaces.end();
41} 41}
42 42
43
44/**
45 * Get a list of all interfaces in the interface file. Usefull for
46 * hardware that is not currently connected such as an 802.11b card
47 * not plugged in, but configured for when it is plugged in.
48 * @return Return string list of interfaces.
49 **/
50QStringList Interfaces::getInterfaceList(){
51 QStringList list;
52 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
53 QString line = (*it).simplifyWhiteSpace();
54 if(line.contains(IFACE)){
55 line = line.mid(QString(IFACE).length() +1, line.length());
56 line = line.simplifyWhiteSpace();
57 int findSpace = line.find(" ");
58 if( findSpace >= 0){
59 line = line.mid(0, findSpace);
60 list.append(line);
61 }
62 }
63 }
64 return list;
65}
66
43/** 67/**
44 * Find out if interface is in an "auto" group or not. 68 * Find out if interface is in an "auto" group or not.
45 * Report any duplicates such as eth0 being in two differnt auto's 69 * Report any duplicates such as eth0 being in two differnt auto's
46 * @param 70 * @param interface interface to check to see if it is on or not.
47 * @return true is interface is in auto 71 * @return true is interface is in auto
48 */ 72 */
49bool Interfaces::isAuto(QString interface){ 73bool Interfaces::isAuto(QString interface){
50 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 74 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
51 QStringList awi = autoLines.grep(QRegExp(interface)); 75 QStringList awi = autoLines.grep(QRegExp(interface));
52 if(awi.count() > 1) 76 if(awi.count() > 1)
53 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
54 if(awi.count() < 1) 78 if(awi.count() < 1)
55 return false; 79 return false;
56 return true; 80 return true;
57} 81}
58 82
59/** 83/**
60 * Attempt to set the auto option for interface to setAuto. 84 * Attempt to set the auto option for interface to setAuto.
61 * @param interface the interface to set 85 * @param interface the interface to set
62 * @param setAuto the value to set interface to. 86 * @param setAuto the value to set interface to.
63 * @return false if already set to setAuto. 87 * @return false if already set to setAuto.
64 * */ 88 * */
65bool Interfaces::setAuto(QString interface, bool setAuto){ 89bool Interfaces::setAuto(QString interface, bool setAuto){
66 // Don't need to set it if it is already set. 90 // Don't need to set it if it is already set.
67 if(isAuto(interface) == setAuto) 91 if(isAuto(interface) == setAuto)
68 return false; 92 return false;
69 93
70 bool changed = false; 94 bool changed = false;
71 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
72 if((*it).contains(AUTO)){ 96 if((*it).contains(AUTO)){
73 //We know that they are not in any group so let add to this auto. 97 //We know that they are not in any group so let add to this auto.
74 if(setAuto){ 98 if(setAuto){
75 (*it) = (*it) += " " + interface; 99 (*it) = (*it) += " " + interface;
76 // Don't care to have such thins as: auto eth0 lo usb0 100 // Don't care to have such thins as: auto eth0 lo usb0
77 (*it) = (*it).simplifyWhiteSpace(); 101 (*it) = (*it).simplifyWhiteSpace();
78 changed = true; 102 changed = true;
79 break; 103 break;
80 } 104 }
81 else{ 105 else{
82 if((*it).contains(interface)){ 106 if((*it).contains(interface)){
83 (*it) = (*it).replace(QRegExp(interface), ""); 107 (*it) = (*it).replace(QRegExp(interface), "");
84 // clean up 108 // clean up
85 QString line = (*it).simplifyWhiteSpace(); 109 QString line = (*it).simplifyWhiteSpace();
86 line = line.replace(QRegExp(" "),""); 110 line = line.replace(QRegExp(" "),"");
87 if(line == AUTO) 111 if(line == AUTO)
88 (*it) = ""; 112 (*it) = "";
89 changed = true; 113 changed = true;
90 // Don't break because we want to make sure we remove all cases. 114 // Don't break because we want to make sure we remove all cases.
91 } 115 }
92 } 116 }
93 } 117 }
94 } 118 }
95 if(changed == false){ 119 if(changed == false){
96 if(setAuto == true) 120 if(setAuto == true)
97 interfaces.append(QString(AUTO" %1").arg(interface)); 121 interfaces.append(QString(AUTO" %1").arg(interface));
98 else{ 122 else{
99 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1()); 123 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1());
100 } 124 }
101 } 125 }
102 return true; 126 return true;
103} 127}
104 128
105/** 129/**
106 * Set the current interface to interface. This needs to be done before you 130 * Set the current interface to interface. This needs to be done before you
107 * can call getFamily(), getMethod, and get/setOption(). 131 * can call getFamily(), getMethod, and get/setOption().
108 * @param interface the name of the interface to set. All whitespace is 132 * @param interface the name of the interface to set. All whitespace is
109 * removed from the interface name. 133 * removed from the interface name.
110 * @return bool true if it is successfull. 134 * @return bool true if it is successfull.
111 */ 135 */
112bool Interfaces::setInterface(QString interface){ 136bool Interfaces::setInterface(QString interface){
113 interface = interface.simplifyWhiteSpace(); 137 interface = interface.simplifyWhiteSpace();
114 interface = interface.replace(QRegExp(" "), ""); 138 interface = interface.replace(QRegExp(" "), "");
115 return setStanza(IFACE, interface, currentIface); 139 return setStanza(IFACE, interface, currentIface);
116} 140}
117 141
118/** 142/**
119 * A quick helper funtion to see if the current interface is set. 143 * A quick helper funtion to see if the current interface is set.
120 * @return bool true if set, false otherwise. 144 * @return bool true if set, false otherwise.
121 */ 145 */
122bool Interfaces::isInterfaceSet(){ 146bool Interfaces::isInterfaceSet(){
123 return (currentIface != interfaces.end()); 147 return (currentIface != interfaces.end());
124} 148}
125 149
126/** 150/**
127 * Add a new interface of with the settings - family and method 151 * Add a new interface of with the settings - family and method
128 * @param interface the name of the interface to set. All whitespace is 152 * @param interface the name of the interface to set. All whitespace is
129 * removed from the interface name. 153 * removed from the interface name.
130 * @param family the family of this interface inet or inet, ipx or inet6 154 * @param family the family of this interface inet or inet, ipx or inet6
131 * Must of one of the families defined in interfaces.h 155 * Must of one of the families defined in interfaces.h
132 * @param method for the family. see interfaces man page for family methods. 156 * @param method for the family. see interfaces man page for family methods.
133 * @return true if successfull. 157 * @return true if successfull.
134 */ 158 */
135bool Interfaces::addInterface(QString interface, QString family, QString method){ 159bool Interfaces::addInterface(QString interface, QString family, QString method){
136 if(acceptedFamily.contains(family)==0) 160 if(acceptedFamily.contains(family)==0)
137 return false; 161 return false;
138 interface = interface.simplifyWhiteSpace(); 162 interface = interface.simplifyWhiteSpace();
139 interface = interface.replace(QRegExp(" "), ""); 163 interface = interface.replace(QRegExp(" "), "");
140 interfaces.append(""); 164 interfaces.append("");
141 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); 165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method));
142 return true; 166 return true;
143} 167}
144 168
145/** 169/**
146 * Remove the currently selected interface and all of its options. 170 * Remove the currently selected interface and all of its options.
147 * @return bool if successfull or not. 171 * @return bool if successfull or not.
148 */ 172 */
149bool Interfaces::removeInterface(){ 173bool Interfaces::removeInterface(){
150 if(currentIface == interfaces.end()) 174 if(currentIface == interfaces.end())
151 return false; 175 return false;
152 (*currentIface) = ""; 176 (*currentIface) = "";
153 return removeAllInterfaceOptions(); 177 return removeAllInterfaceOptions();
154} 178}
155 179
156/** 180/**
157 * Gets the hardware name of the interface that is currently selected. 181 * Gets the hardware name of the interface that is currently selected.
158 * @return QString name of the hardware interface (eth0, usb2, wlan1...). 182 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
159 * @param error set to true if any error occurs, false otherwise. 183 * @param error set to true if any error occurs, false otherwise.
160 */ 184 */
161QString Interfaces::getInterfaceName(bool &error){ 185QString Interfaces::getInterfaceName(bool &error){
162 if(currentIface == interfaces.end()){ 186 if(currentIface == interfaces.end()){
163 error = true; 187 error = true;
164 return QString(); 188 return QString();
165 } 189 }
166 QString line = (*currentIface); 190 QString line = (*currentIface);
167 line = line.mid(QString(IFACE).length() +1, line.length()); 191 line = line.mid(QString(IFACE).length() +1, line.length());
168 line = line.simplifyWhiteSpace(); 192 line = line.simplifyWhiteSpace();
169 int findSpace = line.find(" "); 193 int findSpace = line.find(" ");
170 if( findSpace < 0){ 194 if( findSpace < 0){
171 error = true; 195 error = true;
172 return QString(); 196 return QString();
173 } 197 }
174 error = false; 198 error = false;
175 return line.mid(0, findSpace); 199 return line.mid(0, findSpace);
176} 200}
177 201
178/** 202/**
179 * Gets the family name of the interface that is currently selected. 203 * Gets the family name of the interface that is currently selected.
180 * @return QString name of the family (inet, inet6, ipx). 204 * @return QString name of the family (inet, inet6, ipx).
181 * @param error set to true if any error occurs, false otherwise. 205 * @param error set to true if any error occurs, false otherwise.
182 */ 206 */
183QString Interfaces::getInterfaceFamily(bool &error){ 207QString Interfaces::getInterfaceFamily(bool &error){
184 QString name = getInterfaceName(error); 208 QString name = getInterfaceName(error);
185 if(error){ 209 if(error){
186 error = true; 210 error = true;
187 return QString(); 211 return QString();
188 } 212 }
189 QString line = (*currentIface); 213 QString line = (*currentIface);
190 line = line.mid(QString(IFACE).length() +1, line.length()); 214 line = line.mid(QString(IFACE).length() +1, line.length());
191 line = line.mid(name.length()+1, line.length()); 215 line = line.mid(name.length()+1, line.length());
192 line = line.simplifyWhiteSpace(); 216 line = line.simplifyWhiteSpace();
193 int findSpace = line.find(" "); 217 int findSpace = line.find(" ");
194 if( findSpace < 0){ 218 if( findSpace < 0){
195 error = true; 219 error = true;
196 return QString(); 220 return QString();
197 } 221 }
198 error = false; 222 error = false;
199 return line.mid(0, findSpace); 223 return line.mid(0, findSpace);
200} 224}
201 225
202/** 226/**
203 * Gets the method of the interface that is currently selected. 227 * Gets the method of the interface that is currently selected.
204 * @return QString name of the method such as staic or dhcp. 228 * @return QString name of the method such as staic or dhcp.
205 * See the man page of interfaces for possible methods depending on the family. 229 * See the man page of interfaces for possible methods depending on the family.
206 * @param error set to true if any error occurs, false otherwise. 230 * @param error set to true if any error occurs, false otherwise.
207 */ 231 */
208QString Interfaces::getInterfaceMethod(bool &error){ 232QString Interfaces::getInterfaceMethod(bool &error){
209 QString name = getInterfaceName(error); 233 QString name = getInterfaceName(error);
210 if(error){ 234 if(error){
211 error = true; 235 error = true;
212 return QString(); 236 return QString();
213 } 237 }
214 QString family = getInterfaceFamily(error); 238 QString family = getInterfaceFamily(error);
215 if(error){ 239 if(error){
216 error = true; 240 error = true;
217 return QString(); 241 return QString();
218 } 242 }
219 QString line = (*currentIface); 243 QString line = (*currentIface);
220 line = line.mid(QString(IFACE).length()+1, line.length()); 244 line = line.mid(QString(IFACE).length()+1, line.length());
221 line = line.mid(name.length()+1, line.length()); 245 line = line.mid(name.length()+1, line.length());
222 line = line.mid(family.length()+1, line.length()); 246 line = line.mid(family.length()+1, line.length());
223 line = line.simplifyWhiteSpace(); 247 line = line.simplifyWhiteSpace();
224 error = false; 248 error = false;
225 return line; 249 return line;
226} 250}
227 251
228/** 252/**
229 * Sets the interface name to newName. 253 * Sets the interface name to newName.
230 * @param newName the new name of the interface. All whitespace is removed. 254 * @param newName the new name of the interface. All whitespace is removed.
231 * @return bool true if successfull. 255 * @return bool true if successfull.
232 */ 256 */
233bool Interfaces::setInterfaceName(QString newName){ 257bool Interfaces::setInterfaceName(QString newName){
234 if(currentIface == interfaces.end()) 258 if(currentIface == interfaces.end())
235 return false; 259 return false;
236 newName = newName.simplifyWhiteSpace(); 260 newName = newName.simplifyWhiteSpace();
237 newName = newName.replace(QRegExp(" "), ""); 261 newName = newName.replace(QRegExp(" "), "");
238 bool returnValue = false; 262 bool returnValue = false;
239 (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); 263 (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
240 return !returnValue; 264 return !returnValue;
241} 265}
242 266
243/** 267/**
244 * Sets the interface family to newName. 268 * Sets the interface family to newName.
245 * @param newName the new name of the interface. Must be one of the families 269 * @param newName the new name of the interface. Must be one of the families
246 * defined in the interfaces.h file. 270 * defined in the interfaces.h file.
247 * @return bool true if successfull. 271 * @return bool true if successfull.
248 */ 272 */
249bool Interfaces::setInterfaceFamily(QString newName){ 273bool Interfaces::setInterfaceFamily(QString newName){
250 if(currentIface == interfaces.end()) 274 if(currentIface == interfaces.end())
251 return false; 275 return false;
252 if(acceptedFamily.contains(newName)==0) 276 if(acceptedFamily.contains(newName)==0)
253 return false; 277 return false;
254 bool returnValue = false; 278 bool returnValue = false;
255 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); 279 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
256 return !returnValue; 280 return !returnValue;
257} 281}
258 282
259/** 283/**
260 * Sets the interface method to newName 284 * Sets the interface method to newName
261 * @param newName the new name of the interface 285 * @param newName the new name of the interface
262 * @return bool true if successfull. 286 * @return bool true if successfull.
263 */ 287 */
264bool Interfaces::setInterfaceMethod(QString newName){ 288bool Interfaces::setInterfaceMethod(QString newName){
265 if(currentIface == interfaces.end()) 289 if(currentIface == interfaces.end())
266 return false; 290 return false;
267 bool returnValue = false; 291 bool returnValue = false;
268 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); 292 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
269 return !returnValue; 293 return !returnValue;
270} 294}
271 295
272/** 296/**
273 * Get a value for an option in the currently selected interface. For example 297 * Get a value for an option in the currently selected interface. For example
274 * calling getInterfaceOption("address") on the following stanza would 298 * calling getInterfaceOption("address") on the following stanza would
275 * return 192.168.1.1. 299 * return 192.168.1.1.
276 * iface eth0 static 300 * iface eth0 static
277 * address 192.168.1.1 301 * address 192.168.1.1
278 * @param option the options to get the value. 302 * @param option the options to get the value.
279 * @param error set to true if any error occurs, false otherwise. 303 * @param error set to true if any error occurs, false otherwise.
280 * @return QString the options value. QString::null if error == true 304 * @return QString the options value. QString::null if error == true
281 */ 305 */
282QString Interfaces::getInterfaceOption(QString option, bool &error){ 306QString Interfaces::getInterfaceOption(QString option, bool &error){
283 return getOption(currentIface, option, error); 307 return getOption(currentIface, option, error);
284} 308}
285 309
286/** 310/**
287 * Set a value for an option in the currently selected interface. If option 311 * Set a value for an option in the currently selected interface. If option
288 * doesn't exist then it is added along with the value. If value is set to an 312 * doesn't exist then it is added along with the value. If value is set to an
289 * empty string then option is removed. 313 * empty string then option is removed.
290 * @param option the options to set the value. 314 * @param option the options to set the value.
291 * @param value the value that option should be set to. 315 * @param value the value that option should be set to.
292 * @param error set to true if any error occurs, false otherwise. 316 * @param error set to true if any error occurs, false otherwise.
293 * @return QString the options value. QString::null if error == true 317 * @return QString the options value. QString::null if error == true
294 */ 318 */
295bool Interfaces::setInterfaceOption(QString option, QString value){ 319bool Interfaces::setInterfaceOption(QString option, QString value){
296 return setOption(currentIface, option, value); 320 return setOption(currentIface, option, value);
297} 321}
298 322
299/** 323/**
300 * Removes all of the options from the currently selected interface. 324 * Removes all of the options from the currently selected interface.
301 * @return bool error if if successfull 325 * @return bool error if if successfull
302 */ 326 */
diff --git a/noncore/net/networksetup/interfaces.h b/noncore/net/networksetup/interfaces.h
index 2cc9689..8b4788c 100644
--- a/noncore/net/networksetup/interfaces.h
+++ b/noncore/net/networksetup/interfaces.h
@@ -1,70 +1,71 @@
1#ifndef INTERFACES_H 1#ifndef INTERFACES_H
2#define INTERFACES_H 2#define INTERFACES_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6 6
7#define INTERFACES_LOOPBACK "loopback" 7#define INTERFACES_LOOPBACK "loopback"
8 8
9#define INTERFACES_FAMILY_INET "inet" 9#define INTERFACES_FAMILY_INET "inet"
10#define INTERFACES_FAMILY_IPX "ipx" 10#define INTERFACES_FAMILY_IPX "ipx"
11#define INTERFACES_FAMILY_INET6 "inet6" 11#define INTERFACES_FAMILY_INET6 "inet6"
12 12
13#define INTERFACES_METHOD_DHCP "dhcp" 13#define INTERFACES_METHOD_DHCP "dhcp"
14#define INTERFACES_METHOD_STATIC "static" 14#define INTERFACES_METHOD_STATIC "static"
15#define INTERFACES_METHOD_PPP "ppp" 15#define INTERFACES_METHOD_PPP "ppp"
16 16
17/** 17/**
18 * This class provides a clean frontend for parsing the network interfaces file. 18 * This class provides a clean frontend for parsing the network interfaces file.
19 * It provides helper functions to minipulate the options within the file. 19 * It provides helper functions to minipulate the options within the file.
20 * See the interfaces man page for the syntax rules. 20 * See the interfaces man page for the syntax rules.
21 */ 21 */
22class Interfaces { 22class Interfaces {
23 23
24public: 24public:
25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); 25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
26 26 QStringList getInterfaceList();
27
27 bool isAuto(QString interface); 28 bool isAuto(QString interface);
28 bool setAuto(QString interface, bool setAuto); 29 bool setAuto(QString interface, bool setAuto);
29 30
30 bool removeInterface(); 31 bool removeInterface();
31 bool addInterface(QString interface, QString family, QString method); 32 bool addInterface(QString interface, QString family, QString method);
32 bool setInterface(QString interface); 33 bool setInterface(QString interface);
33 bool isInterfaceSet(); 34 bool isInterfaceSet();
34 QString getInterfaceName(bool &error); 35 QString getInterfaceName(bool &error);
35 bool setInterfaceName(QString newName); 36 bool setInterfaceName(QString newName);
36 QString getInterfaceFamily(bool &error); 37 QString getInterfaceFamily(bool &error);
37 bool setInterfaceFamily(QString newName); 38 bool setInterfaceFamily(QString newName);
38 QString getInterfaceMethod(bool &error); 39 QString getInterfaceMethod(bool &error);
39 bool setInterfaceMethod(QString newName); 40 bool setInterfaceMethod(QString newName);
40 QString getInterfaceOption(QString option, bool &error); 41 QString getInterfaceOption(QString option, bool &error);
41 bool setInterfaceOption(QString option, QString value); 42 bool setInterfaceOption(QString option, QString value);
42 bool removeAllInterfaceOptions(); 43 bool removeAllInterfaceOptions();
43 44
44 bool setMapping(QString interface); 45 bool setMapping(QString interface);
45 void addMapping(QString interfaces); 46 void addMapping(QString interfaces);
46 bool setMap(QString map, QString value); 47 bool setMap(QString map, QString value);
47 QString getMap(QString map, bool &error); 48 QString getMap(QString map, bool &error);
48 bool setScript(QString); 49 bool setScript(QString);
49 QString getScript(bool &error); 50 QString getScript(bool &error);
50 51
51 bool write(); 52 bool write();
52 53
53private: 54private:
54 bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); 55 bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator);
55 bool setOption(QStringList::Iterator start, QString option, QString value); 56 bool setOption(QStringList::Iterator start, QString option, QString value);
56 QString getOption(QStringList::Iterator start, QString option, bool &error); 57 QString getOption(QStringList::Iterator start, QString option, bool &error);
57 bool removeAllOptions(QStringList::Iterator start); 58 bool removeAllOptions(QStringList::Iterator start);
58 59
59 QString interfacesFile; 60 QString interfacesFile;
60 QStringList interfaces; 61 QStringList interfaces;
61 QStringList::Iterator currentIface; 62 QStringList::Iterator currentIface;
62 QStringList::Iterator currentMapping; 63 QStringList::Iterator currentMapping;
63 64
64 QStringList acceptedFamily; 65 QStringList acceptedFamily;
65}; 66};
66 67
67#endif 68#endif
68 69
69// interfaces 70// interfaces
70 71
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 36f12e0..24af1ec 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,428 +1,450 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interfaces.h"
6
5#include "module.h" 7#include "module.h"
6 8
7#include "kprocess.h" 9#include "kprocess.h"
8 10
9#include <qpushbutton.h> 11#include <qpushbutton.h>
10#include <qtabwidget.h> 12#include <qtabwidget.h>
11#include <qlistbox.h> 13#include <qlistbox.h>
12#include <qlineedit.h> 14#include <qlineedit.h>
13#include <qlistview.h> 15#include <qlistview.h>
14#include <qheader.h> 16#include <qheader.h>
15#include <qlabel.h> 17#include <qlabel.h>
16 18
17#include <qmainwindow.h> 19#include <qmainwindow.h>
18#include <qmessagebox.h> 20#include <qmessagebox.h>
19 21
20#include <qpe/config.h> 22#include <qpe/config.h>
21#include <qpe/qlibrary.h> 23#include <qpe/qlibrary.h>
22#include <qpe/resource.h> 24#include <qpe/resource.h>
23#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
24 26
25#include <qlist.h> 27#include <qlist.h>
26#include <qdir.h> 28#include <qdir.h>
27#include <qfile.h> 29#include <qfile.h>
28#include <qtextstream.h> 30#include <qtextstream.h>
29 31
30#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
31#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
32 34
33MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
34 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 36 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
35 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 37 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
36 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 38 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
37 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 39 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
38 40
39 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 41 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
40 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 42 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
41 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 43 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
42 44
43 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 45 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
44 // Load connections. 46 // Load connections.
45 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 47 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
46 getInterfaceList(); 48 getInterfaceList();
47 connectionList->header()->hide(); 49 connectionList->header()->hide();
48 50
49 51
50 Config cfg("NetworkSetup"); 52 Config cfg("NetworkSetup");
51 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 53 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
52 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 54 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
53 profilesList->insertItem((*it)); 55 profilesList->insertItem((*it));
54 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 56 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
55} 57}
56 58
57/** 59/**
58 * Deconstructor. Save profiles. Delete loaded libraries. 60 * Deconstructor. Save profiles. Delete loaded libraries.
59 */ 61 */
60MainWindowImp::~MainWindowImp(){ 62MainWindowImp::~MainWindowImp(){
61 // Save profiles. 63 // Save profiles.
62 if(profiles.count() > 1){ 64 if(profiles.count() > 1){
63 Config cfg("NetworkSetup"); 65 Config cfg("NetworkSetup");
64 cfg.setGroup("General"); 66 cfg.setGroup("General");
65 cfg.writeEntry("Profiles", profiles.join(" ")); 67 cfg.writeEntry("Profiles", profiles.join(" "));
66 } 68 }
67 // Delete Modules and Libraries 69 // Delete Modules and Libraries
68 QMap<Module*, QLibrary*>::Iterator it; 70 QMap<Module*, QLibrary*>::Iterator it;
69 for( it = libraries.begin(); it != libraries.end(); ++it ){ 71 for( it = libraries.begin(); it != libraries.end(); ++it ){
70 delete it.key(); 72 delete it.key();
71 delete it.data(); 73 delete it.data();
72 } 74 }
73} 75}
74 76
75/** 77/**
76 * Load all modules that are found in the path 78 * Load all modules that are found in the path
77 * @param path a directory that is scaned for any plugins that can be loaded 79 * @param path a directory that is scaned for any plugins that can be loaded
78 * and attempts to load them 80 * and attempts to load them
79 */ 81 */
80void MainWindowImp::loadModules(QString path){ 82void MainWindowImp::loadModules(QString path){
81 qDebug(path.latin1()); 83 qDebug(path.latin1());
82 QDir d(path); 84 QDir d(path);
83 if(!d.exists()) 85 if(!d.exists())
84 return; 86 return;
85 87
86 // Don't want sym links 88 // Don't want sym links
87 d.setFilter( QDir::Files | QDir::NoSymLinks ); 89 d.setFilter( QDir::Files | QDir::NoSymLinks );
88 const QFileInfoList *list = d.entryInfoList(); 90 const QFileInfoList *list = d.entryInfoList();
89 QFileInfoListIterator it( *list ); 91 QFileInfoListIterator it( *list );
90 QFileInfo *fi; 92 QFileInfo *fi;
91 while ( (fi=it.current()) ) { 93 while ( (fi=it.current()) ) {
92 if(fi->fileName().contains(".so")){ 94 if(fi->fileName().contains(".so")){
93 loadPlugin(path + "/" + fi->fileName()); 95 loadPlugin(path + "/" + fi->fileName());
94 } 96 }
95 ++it; 97 ++it;
96 } 98 }
97} 99}
98 100
99/** 101/**
100 * Attempt to load a function and resolve a function. 102 * Attempt to load a function and resolve a function.
101 * @param pluginFileName - the name of the file in which to attempt to load 103 * @param pluginFileName - the name of the file in which to attempt to load
102 * @param resolveString - function pointer to resolve 104 * @param resolveString - function pointer to resolve
103 * @return pointer to the function with name resolveString or NULL 105 * @return pointer to the function with name resolveString or NULL
104 */ 106 */
105Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 107Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
106 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 108 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
107 QLibrary *lib = new QLibrary(pluginFileName); 109 QLibrary *lib = new QLibrary(pluginFileName);
108 void *functionPointer = lib->resolve(resolveString); 110 void *functionPointer = lib->resolve(resolveString);
109 if( !functionPointer ){ 111 if( !functionPointer ){
110 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 112 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
111 delete lib; 113 delete lib;
112 return NULL; 114 return NULL;
113 } 115 }
114 116
115 // Try to get an object. 117 // Try to get an object.
116 Module *object = ((Module* (*)()) functionPointer)(); 118 Module *object = ((Module* (*)()) functionPointer)();
117 if(object == NULL){ 119 if(object == NULL){
118 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 120 qDebug("MainWindowImp: Couldn't create object, but did load library!");
119 delete lib; 121 delete lib;
120 return NULL; 122 return NULL;
121 } 123 }
122 124
123 // Store for deletion later 125 // Store for deletion later
124 libraries.insert(object, lib); 126 libraries.insert(object, lib);
125 return object; 127 return object;
126} 128}
127 129
128/** 130/**
129 * The Add button was clicked. Bring up the add dialog and if OK is hit 131 * The Add button was clicked. Bring up the add dialog and if OK is hit
130 * load the plugin and append it to the list 132 * load the plugin and append it to the list
131 */ 133 */
132void MainWindowImp::addClicked(){ 134void MainWindowImp::addClicked(){
133 QMap<Module*, QLibrary*>::Iterator it; 135 QMap<Module*, QLibrary*>::Iterator it;
134 QMap<QString, QString> list; 136 QMap<QString, QString> list;
135 QMap<QString, Module*> newInterfaceOwners; 137 QMap<QString, Module*> newInterfaceOwners;
136 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 138 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
137 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 139 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
138 for( it = libraries.begin(); it != libraries.end(); ++it ){ 140 for( it = libraries.begin(); it != libraries.end(); ++it ){
139 if(it.key()){ 141 if(it.key()){
140 (it.key())->possibleNewInterfaces(list); 142 (it.key())->possibleNewInterfaces(list);
141 } 143 }
142 } 144 }
143 // See if the list has anything that we can add. 145 // See if the list has anything that we can add.
144 if(list.count() == 0){ 146 if(list.count() == 0){
145 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 147 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
146 return; 148 return;
147 } 149 }
148 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 150 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
149 addNewConnection.addConnections(list); 151 addNewConnection.addConnections(list);
150 addNewConnection.showMaximized(); 152 addNewConnection.showMaximized();
151 if(QDialog::Accepted == addNewConnection.exec()){ 153 if(QDialog::Accepted == addNewConnection.exec()){
152 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 154 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
153 if(!item) 155 if(!item)
154 return; 156 return;
155 157
156 for( it = libraries.begin(); it != libraries.end(); ++it ){ 158 for( it = libraries.begin(); it != libraries.end(); ++it ){
157 if(it.key()){ 159 if(it.key()){
158 Interface *i = (it.key())->addNewInterface(item->text(0)); 160 Interface *i = (it.key())->addNewInterface(item->text(0));
159 if(i){ 161 if(i){
160 interfaceNames.insert(i->getInterfaceName(), i); 162 interfaceNames.insert(i->getInterfaceName(), i);
161 updateInterface(i); 163 updateInterface(i);
162 } 164 }
163 } 165 }
164 } 166 }
165 } 167 }
166} 168}
167 169
168/** 170/**
169 * Prompt the user to see if they really want to do this. 171 * Prompt the user to see if they really want to do this.
170 * If they do then remove from the list and unload. 172 * If they do then remove from the list and unload.
171 */ 173 */
172void MainWindowImp::removeClicked(){ 174void MainWindowImp::removeClicked(){
173 QListViewItem *item = connectionList->currentItem(); 175 QListViewItem *item = connectionList->currentItem();
174 if(!item) { 176 if(!item) {
175 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); 177 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
176 return; 178 return;
177 } 179 }
178 180
179 Interface *i = interfaceItems[item]; 181 Interface *i = interfaceItems[item];
180 if(i->getModuleOwner() == NULL){ 182 if(i->getModuleOwner() == NULL){
181 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 183 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
182 } 184 }
183 else{ 185 else{
184 if(!i->getModuleOwner()->remove(i)) 186 if(!i->getModuleOwner()->remove(i))
185 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 187 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
186 else{ 188 else{
187 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 189 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
188 // TODO memory managment.... 190 // TODO memory managment....
189 // who deletes the interface? 191 // who deletes the interface?
190 } 192 }
191 } 193 }
192} 194}
193 195
194/** 196/**
195 * Pull up the configure about the currently selected interface. 197 * Pull up the configure about the currently selected interface.
196 * Report an error if no interface is selected. 198 * Report an error if no interface is selected.
197 * If the interface has a module owner then request its configure with a empty 199 * If the interface has a module owner then request its configure with a empty
198 * tab. If tab is !NULL then append the interfaces setup widget to it. 200 * tab. If tab is !NULL then append the interfaces setup widget to it.
199 */ 201 */
200void MainWindowImp::configureClicked(){ 202void MainWindowImp::configureClicked(){
201 QListViewItem *item = connectionList->currentItem(); 203 QListViewItem *item = connectionList->currentItem();
202 if(!item){ 204 if(!item){
203 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 205 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
204 return; 206 return;
205 } 207 }
206 208
207 Interface *i = interfaceItems[item]; 209 Interface *i = interfaceItems[item];
208 if(i->getModuleOwner()){ 210 if(i->getModuleOwner()){
209 QTabWidget *tabWidget = NULL; 211 QTabWidget *tabWidget = NULL;
210 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 212 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
211 if(moduleConfigure != NULL){ 213 if(moduleConfigure != NULL){
212 if(tabWidget != NULL){ 214 if(tabWidget != NULL){
213 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 215 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
214 tabWidget->insertTab(configure, "TCP/IP"); 216 tabWidget->insertTab(configure, "TCP/IP");
215 } 217 }
216 moduleConfigure->showMaximized(); 218 moduleConfigure->showMaximized();
217 moduleConfigure->show(); 219 moduleConfigure->show();
218 return; 220 return;
219 } 221 }
220 } 222 }
221 223
222 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 224 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
223 configure->showMaximized(); 225 configure->showMaximized();
224 configure->show(); 226 configure->show();
225} 227}
226 228
227/** 229/**
228 * Pull up the information about the currently selected interface. 230 * Pull up the information about the currently selected interface.
229 * Report an error if no interface is selected. 231 * Report an error if no interface is selected.
230 * If the interface has a module owner then request its configure with a empty 232 * If the interface has a module owner then request its configure with a empty
231 * tab. If tab is !NULL then append the interfaces setup widget to it. 233 * tab. If tab is !NULL then append the interfaces setup widget to it.
232 */ 234 */
233void MainWindowImp::informationClicked(){ 235void MainWindowImp::informationClicked(){
234 QListViewItem *item = connectionList->currentItem(); 236 QListViewItem *item = connectionList->currentItem();
235 if(!item){ 237 if(!item){
236 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
237 return; 239 return;
238 } 240 }
239 241
240 Interface *i = interfaceItems[item]; 242 Interface *i = interfaceItems[item];
241 if(i->getModuleOwner()){ 243 if(i->getModuleOwner()){
242 QTabWidget *tabWidget = NULL; 244 QTabWidget *tabWidget = NULL;
243 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 245 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
244 if(moduleInformation != NULL){ 246 if(moduleInformation != NULL){
245 if(tabWidget != NULL){ 247 if(tabWidget != NULL){
246 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 248 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
247 tabWidget->insertTab(information, "TCP/IP"); 249 tabWidget->insertTab(information, "TCP/IP");
248 } 250 }
249 moduleInformation->showMaximized(); 251 moduleInformation->showMaximized();
250 moduleInformation->show(); 252 moduleInformation->show();
251 return; 253 return;
252 } 254 }
253 } 255 }
254 256
255 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 257 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
256 information->showMaximized(); 258 information->showMaximized();
257 information->show(); 259 information->show();
258} 260}
259 261
260/** 262/**
261 * Aquire the list of active interfaces from ifconfig 263 * Aquire the list of active interfaces from ifconfig
262 * Call ifconfig and ifconfig -a 264 * Call ifconfig and ifconfig -a
263 */ 265 */
264void MainWindowImp::getInterfaceList(){ 266void MainWindowImp::getInterfaceList(){
265 KShellProcess *processAll = new KShellProcess(); 267 KShellProcess *processAll = new KShellProcess();
266 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 268 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
267 connect(processAll, SIGNAL(processExited(KProcess *)), 269 connect(processAll, SIGNAL(processExited(KProcess *)),
268 this, SLOT(jobDone(KProcess *))); 270 this, SLOT(jobDone(KProcess *)));
269 threads.insert(processAll, TEMP_ALL); 271 threads.insert(processAll, TEMP_ALL);
270 processAll->start(KShellProcess::NotifyOnExit); 272 processAll->start(KShellProcess::NotifyOnExit);
271 273
272 KShellProcess *process = new KShellProcess(); 274 KShellProcess *process = new KShellProcess();
273 *process << "/sbin/ifconfig" << " > " TEMP_UP; 275 *process << "/sbin/ifconfig" << " > " TEMP_UP;
274 connect(process, SIGNAL(processExited(KProcess *)), 276 connect(process, SIGNAL(processExited(KProcess *)),
275 this, SLOT(jobDone(KProcess *))); 277 this, SLOT(jobDone(KProcess *)));
276 threads.insert(process, TEMP_UP); 278 threads.insert(process, TEMP_UP);
277 process->start(KShellProcess::NotifyOnExit); 279 process->start(KShellProcess::NotifyOnExit);
278} 280}
279 281
280void MainWindowImp::jobDone(KProcess *process){ 282void MainWindowImp::jobDone(KProcess *process){
281 QString fileName = threads[process]; 283 QString fileName = threads[process];
282 threads.remove(process); 284 threads.remove(process);
283 delete process; 285 delete process;
284 286
285 QFile file(fileName); 287 QFile file(fileName);
286 if (!file.open(IO_ReadOnly)){ 288 if (!file.open(IO_ReadOnly)){
287 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 289 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
288 return; 290 return;
289 } 291 }
290 292
291 QTextStream stream( &file ); 293 QTextStream stream( &file );
292 QString line; 294 QString line;
293 while ( !stream.eof() ) { 295 while ( !stream.eof() ) {
294 line = stream.readLine(); 296 line = stream.readLine();
295 int space = line.find(" "); 297 int space = line.find(" ");
296 if(space > 1){ 298 if(space > 1){
297 // We have found an interface 299 // We have found an interface
298 QString interfaceName = line.mid(0, space); 300 QString interfaceName = line.mid(0, space);
299 if(!advancedUserMode){ 301 if(!advancedUserMode){
300 if(interfaceName == "lo") 302 if(interfaceName == "lo")
301 break; 303 break;
302 } 304 }
303 Interface *i; 305 Interface *i;
304 // See if we already have it 306 // See if we already have it
305 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 307 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
306 if(fileName == TEMP_ALL) 308 if(fileName == TEMP_ALL)
307 i = new Interface(interfaceName, false); 309 i = new Interface(interfaceName, false);
308 else 310 else
309 i = new Interface(interfaceName, true); 311 i = new Interface(interfaceName, true);
310 } 312 }
311 else{ 313 else{
312 i = interfaceNames[interfaceName]; 314 i = interfaceNames[interfaceName];
313 if(fileName != TEMP_ALL) 315 if(fileName != TEMP_ALL)
314 i->setStatus(true); 316 i->setStatus(true);
315 } 317 }
316 318
317 i->setAttached(true); 319 i->setAttached(true);
318 i->setInterfaceName(interfaceName); 320 i->setInterfaceName(interfaceName);
319 321
320 QString hardName = "Ethernet"; 322 QString hardName = "Ethernet";
321 int hardwareName = line.find("Link encap:"); 323 int hardwareName = line.find("Link encap:");
322 int macAddress = line.find("HWaddr"); 324 int macAddress = line.find("HWaddr");
323 if(macAddress == -1) 325 if(macAddress == -1)
324 macAddress = line.length(); 326 macAddress = line.length();
325 if(hardwareName != -1) 327 if(hardwareName != -1)
326 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); 328 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
327 // We have found an interface 329 // We have found an interface
328 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 330 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
329 interfaceNames.insert(i->getInterfaceName(), i); 331 interfaceNames.insert(i->getInterfaceName(), i);
330 updateInterface(i); 332 updateInterface(i);
331 } 333 }
332 } 334 }
333 file.close(); 335 file.close();
334 QFile::remove(fileName); 336 QFile::remove(fileName);
337 if(threads.count() == 0){
338 Interfaces i;
339 QStringList list = i.getInterfaceList();
340 QMap<QString, Interface*>::Iterator it;
341 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
342 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
343 if(it.key() == (*ni)){
344 Interface *i = new Interface(*ni, false);
345 i->setAttached(false);
346 i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
347 i->setInterfaceName(*ni);
348 interfaceNames.insert(i->getInterfaceName(), i);
349 updateInterface(i);
350 }
351 }
352 }
353 }
335} 354}
336 355
337/** 356/**
338 * Update this interface. If no QListViewItem exists create one. 357 * Update this interface. If no QListViewItem exists create one.
339 * @param Interface* pointer to the interface that needs to be updated. 358 * @param Interface* pointer to the interface that needs to be updated.
340 */ 359 */
341void MainWindowImp::updateInterface(Interface *i){ 360void MainWindowImp::updateInterface(Interface *i){
342 QListViewItem *item = NULL; 361 QListViewItem *item = NULL;
343 362
344 // Find the interface, making it if needed. 363 // Find the interface, making it if needed.
345 if(items.find(i) == items.end()){ 364 if(items.find(i) == items.end()){
346 item = new QListViewItem(connectionList, "", "", ""); 365 item = new QListViewItem(connectionList, "", "", "");
347 // See if you can't find a module owner for this interface 366 // See if you can't find a module owner for this interface
348 QMap<Module*, QLibrary*>::Iterator it; 367 QMap<Module*, QLibrary*>::Iterator it;
349 for( it = libraries.begin(); it != libraries.end(); ++it ){ 368 for( it = libraries.begin(); it != libraries.end(); ++it ){
350 if(it.key()->isOwner(i)) 369 if(it.key()->isOwner(i))
351 i->setModuleOwner(it.key()); 370 i->setModuleOwner(it.key());
352 } 371 }
353 items.insert(i, item); 372 items.insert(i, item);
354 interfaceItems.insert(item, i); 373 interfaceItems.insert(item, i);
355 } 374 }
356 else 375 else
357 item = items[i]; 376 item = items[i];
358 377
359 // Update the icons and information 378 // Update the icons and information
360 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 379 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
361 380
362 QString typeName = "lan"; 381 QString typeName = "lan";
363 if(i->getHardwareName().contains("Local Loopback")) 382 if(i->getHardwareName().contains("Local Loopback"))
364 typeName = "lo"; 383 typeName = "lo";
365 if(i->getInterfaceName().contains("irda")) 384 if(i->getInterfaceName().contains("irda"))
366 typeName = "irda"; 385 typeName = "irda";
367 if(i->getInterfaceName().contains("wlan")) 386 if(i->getInterfaceName().contains("wlan"))
368 typeName = "wlan"; 387 typeName = "wlan";
388
389 if(!i->isAttached())
390 typeName = "connect_no";
369 // Actually try to use the Module 391 // Actually try to use the Module
370 if(i->getModuleOwner() != NULL) 392 if(i->getModuleOwner() != NULL)
371 typeName = i->getModuleOwner()->getPixmapName(i); 393 typeName = i->getModuleOwner()->getPixmapName(i);
372 394
373 item->setPixmap(1, (Resource::loadPixmap(typeName))); 395 item->setPixmap(1, (Resource::loadPixmap(typeName)));
374 item->setText(2, i->getHardwareName()); 396 item->setText(2, i->getHardwareName());
375 item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); 397 item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
376} 398}
377 399
378void MainWindowImp::newProfileChanged(const QString& newText){ 400void MainWindowImp::newProfileChanged(const QString& newText){
379 if(newText.length() > 0) 401 if(newText.length() > 0)
380 newProfileButton->setEnabled(true); 402 newProfileButton->setEnabled(true);
381 else 403 else
382 newProfileButton->setEnabled(false); 404 newProfileButton->setEnabled(false);
383} 405}
384 406
385/** 407/**
386 * Adds a new profile to the list of profiles. 408 * Adds a new profile to the list of profiles.
387 * Don't add profiles that already exists. 409 * Don't add profiles that already exists.
388 * Appends to the list and QStringList 410 * Appends to the list and QStringList
389 */ 411 */
390void MainWindowImp::addProfile(){ 412void MainWindowImp::addProfile(){
391 QString newProfileName = newProfile->text(); 413 QString newProfileName = newProfile->text();
392 if(profiles.grep(newProfileName).count() > 0){ 414 if(profiles.grep(newProfileName).count() > 0){
393 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 415 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
394 return; 416 return;
395 } 417 }
396 profiles.append(newProfileName); 418 profiles.append(newProfileName);
397 profilesList->insertItem(newProfileName); 419 profilesList->insertItem(newProfileName);
398} 420}
399 421
400/** 422/**
401 * Removes the currently selected profile in the combo. 423 * Removes the currently selected profile in the combo.
402 * Doesn't delete if there are less then 2 profiles. 424 * Doesn't delete if there are less then 2 profiles.
403 */ 425 */
404void MainWindowImp::removeProfile(){ 426void MainWindowImp::removeProfile(){
405 if(profilesList->count() <= 1){ 427 if(profilesList->count() <= 1){
406 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok"); 428 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
407 return; 429 return;
408 } 430 }
409 QString profileToRemove = profilesList->currentText(); 431 QString profileToRemove = profilesList->currentText();
410 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 432 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
411 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 433 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
412 profilesList->clear(); 434 profilesList->clear();
413 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 435 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
414 profilesList->insertItem((*it)); 436 profilesList->insertItem((*it));
415 } 437 }
416 438
417} 439}
418 440
419/** 441/**
420 * A new profile has been selected, change. 442 * A new profile has been selected, change.
421 * @param newProfile the new profile. 443 * @param newProfile the new profile.
422 */ 444 */
423void MainWindowImp::changeProfile(){ 445void MainWindowImp::changeProfile(){
424 currentProfileLabel->setText(profilesList->text(profilesList->currentItem())); 446 currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
425} 447}
426 448
427// mainwindowimp.cpp 449// mainwindowimp.cpp
428 450
diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro
index f09db93..441bbaa 100644
--- a/noncore/net/networksetup/networksetup.pro
+++ b/noncore/net/networksetup/networksetup.pro
@@ -1,11 +1,11 @@
1 DESTDIR = $(OPIEDIR)/bin 1 #DESTDIR = $(OPIEDIR)/bin
2 TEMPLATE= app 2 TEMPLATE= app
3 #CONFIG = qt warn_on debug 3 #CONFIG = qt warn_on debug
4 CONFIG = qt warn_on release 4 CONFIG = qt warn_on release
5 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h 5 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h
6 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp 6 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include 7 #INCLUDEPATH+= $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 8 #DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
10 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui 10 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui
11 TARGET = networksetup 11 TARGET = networksetup
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index 70d6717..7386646 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,7 +1,8 @@
1[ ] Wlanmodule needs to check if an interface supports wireless 1[ ] Wlanmodule needs to check if an interface supports wireless
2 extensions. 2 extensions.
3[x] When you set options in wlanmodule, hit OK, it exits all of 3[x] When you set options in wlanmodule, hit OK, it exits all of
4 networksetup, doesnt bring you back to the main screen. 4 networksetup, doesnt bring you back to the main screen.
5[x] Wlanmodule isnt writing out wireless.opts 5[x] Wlanmodule isnt writing out wireless.opts
6[ ] Need a means of bringing an interface up and down (calling 6[ ] Need a means of bringing an interface up and down (calling
7 out ifup/ifdown) from the gui. 7 out ifup/ifdown) from the gui.
8 -Ben- Click information, then click up or down... :-D
diff --git a/noncore/settings/networksettings/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp
index b8a3e7f..1287d90 100644
--- a/noncore/settings/networksettings/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces.cpp
@@ -1,302 +1,326 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qregexp.h> 5#include <qregexp.h>
6 6
7#define AUTO "auto" 7#define AUTO "auto"
8#define IFACE "iface" 8#define IFACE "iface"
9#define MAPPING "mapping" 9#define MAPPING "mapping"
10 10
11/** 11/**
12 * Constructor. Reads in the interfaces file and then split the file up by 12 * Constructor. Reads in the interfaces file and then split the file up by
13 * the \n for interfaces variable. 13 * the \n for interfaces variable.
14 * @param useInterfacesFile if an interface file other then the default is 14 * @param useInterfacesFile if an interface file other then the default is
15 * desired to be used it should be passed in. 15 * desired to be used it should be passed in.
16 */ 16 */
17Interfaces::Interfaces(QString useInterfacesFile){ 17Interfaces::Interfaces(QString useInterfacesFile){
18 acceptedFamily.append(INTERFACES_FAMILY_INET); 18 acceptedFamily.append(INTERFACES_FAMILY_INET);
19 acceptedFamily.append(INTERFACES_FAMILY_IPX); 19 acceptedFamily.append(INTERFACES_FAMILY_IPX);
20 acceptedFamily.append(INTERFACES_FAMILY_INET6); 20 acceptedFamily.append(INTERFACES_FAMILY_INET6);
21 21
22 interfacesFile = useInterfacesFile; 22 interfacesFile = useInterfacesFile;
23 QFile file(interfacesFile); 23 QFile file(interfacesFile);
24 if (!file.open(IO_ReadOnly)){ 24 if (!file.open(IO_ReadOnly)){
25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); 25 qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
26 currentIface = interfaces.end(); 26 currentIface = interfaces.end();
27 currentMapping = interfaces.end(); 27 currentMapping = interfaces.end();
28 return; 28 return;
29 } 29 }
30 QTextStream stream( &file ); 30 QTextStream stream( &file );
31 QString line; 31 QString line;
32 while ( !stream.eof() ) { 32 while ( !stream.eof() ) {
33 line += stream.readLine(); 33 line += stream.readLine();
34 line += "\n"; 34 line += "\n";
35 } 35 }
36 file.close(); 36 file.close();
37 interfaces = QStringList::split("\n", line, true); 37 interfaces = QStringList::split("\n", line, true);
38 38
39 currentIface = interfaces.end(); 39 currentIface = interfaces.end();
40 currentMapping = interfaces.end(); 40 currentMapping = interfaces.end();
41} 41}
42 42
43
44/**
45 * Get a list of all interfaces in the interface file. Usefull for
46 * hardware that is not currently connected such as an 802.11b card
47 * not plugged in, but configured for when it is plugged in.
48 * @return Return string list of interfaces.
49 **/
50QStringList Interfaces::getInterfaceList(){
51 QStringList list;
52 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
53 QString line = (*it).simplifyWhiteSpace();
54 if(line.contains(IFACE)){
55 line = line.mid(QString(IFACE).length() +1, line.length());
56 line = line.simplifyWhiteSpace();
57 int findSpace = line.find(" ");
58 if( findSpace >= 0){
59 line = line.mid(0, findSpace);
60 list.append(line);
61 }
62 }
63 }
64 return list;
65}
66
43/** 67/**
44 * Find out if interface is in an "auto" group or not. 68 * Find out if interface is in an "auto" group or not.
45 * Report any duplicates such as eth0 being in two differnt auto's 69 * Report any duplicates such as eth0 being in two differnt auto's
46 * @param 70 * @param interface interface to check to see if it is on or not.
47 * @return true is interface is in auto 71 * @return true is interface is in auto
48 */ 72 */
49bool Interfaces::isAuto(QString interface){ 73bool Interfaces::isAuto(QString interface){
50 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 74 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
51 QStringList awi = autoLines.grep(QRegExp(interface)); 75 QStringList awi = autoLines.grep(QRegExp(interface));
52 if(awi.count() > 1) 76 if(awi.count() > 1)
53 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
54 if(awi.count() < 1) 78 if(awi.count() < 1)
55 return false; 79 return false;
56 return true; 80 return true;
57} 81}
58 82
59/** 83/**
60 * Attempt to set the auto option for interface to setAuto. 84 * Attempt to set the auto option for interface to setAuto.
61 * @param interface the interface to set 85 * @param interface the interface to set
62 * @param setAuto the value to set interface to. 86 * @param setAuto the value to set interface to.
63 * @return false if already set to setAuto. 87 * @return false if already set to setAuto.
64 * */ 88 * */
65bool Interfaces::setAuto(QString interface, bool setAuto){ 89bool Interfaces::setAuto(QString interface, bool setAuto){
66 // Don't need to set it if it is already set. 90 // Don't need to set it if it is already set.
67 if(isAuto(interface) == setAuto) 91 if(isAuto(interface) == setAuto)
68 return false; 92 return false;
69 93
70 bool changed = false; 94 bool changed = false;
71 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
72 if((*it).contains(AUTO)){ 96 if((*it).contains(AUTO)){
73 //We know that they are not in any group so let add to this auto. 97 //We know that they are not in any group so let add to this auto.
74 if(setAuto){ 98 if(setAuto){
75 (*it) = (*it) += " " + interface; 99 (*it) = (*it) += " " + interface;
76 // Don't care to have such thins as: auto eth0 lo usb0 100 // Don't care to have such thins as: auto eth0 lo usb0
77 (*it) = (*it).simplifyWhiteSpace(); 101 (*it) = (*it).simplifyWhiteSpace();
78 changed = true; 102 changed = true;
79 break; 103 break;
80 } 104 }
81 else{ 105 else{
82 if((*it).contains(interface)){ 106 if((*it).contains(interface)){
83 (*it) = (*it).replace(QRegExp(interface), ""); 107 (*it) = (*it).replace(QRegExp(interface), "");
84 // clean up 108 // clean up
85 QString line = (*it).simplifyWhiteSpace(); 109 QString line = (*it).simplifyWhiteSpace();
86 line = line.replace(QRegExp(" "),""); 110 line = line.replace(QRegExp(" "),"");
87 if(line == AUTO) 111 if(line == AUTO)
88 (*it) = ""; 112 (*it) = "";
89 changed = true; 113 changed = true;
90 // Don't break because we want to make sure we remove all cases. 114 // Don't break because we want to make sure we remove all cases.
91 } 115 }
92 } 116 }
93 } 117 }
94 } 118 }
95 if(changed == false){ 119 if(changed == false){
96 if(setAuto == true) 120 if(setAuto == true)
97 interfaces.append(QString(AUTO" %1").arg(interface)); 121 interfaces.append(QString(AUTO" %1").arg(interface));
98 else{ 122 else{
99 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1()); 123 qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1());
100 } 124 }
101 } 125 }
102 return true; 126 return true;
103} 127}
104 128
105/** 129/**
106 * Set the current interface to interface. This needs to be done before you 130 * Set the current interface to interface. This needs to be done before you
107 * can call getFamily(), getMethod, and get/setOption(). 131 * can call getFamily(), getMethod, and get/setOption().
108 * @param interface the name of the interface to set. All whitespace is 132 * @param interface the name of the interface to set. All whitespace is
109 * removed from the interface name. 133 * removed from the interface name.
110 * @return bool true if it is successfull. 134 * @return bool true if it is successfull.
111 */ 135 */
112bool Interfaces::setInterface(QString interface){ 136bool Interfaces::setInterface(QString interface){
113 interface = interface.simplifyWhiteSpace(); 137 interface = interface.simplifyWhiteSpace();
114 interface = interface.replace(QRegExp(" "), ""); 138 interface = interface.replace(QRegExp(" "), "");
115 return setStanza(IFACE, interface, currentIface); 139 return setStanza(IFACE, interface, currentIface);
116} 140}
117 141
118/** 142/**
119 * A quick helper funtion to see if the current interface is set. 143 * A quick helper funtion to see if the current interface is set.
120 * @return bool true if set, false otherwise. 144 * @return bool true if set, false otherwise.
121 */ 145 */
122bool Interfaces::isInterfaceSet(){ 146bool Interfaces::isInterfaceSet(){
123 return (currentIface != interfaces.end()); 147 return (currentIface != interfaces.end());
124} 148}
125 149
126/** 150/**
127 * Add a new interface of with the settings - family and method 151 * Add a new interface of with the settings - family and method
128 * @param interface the name of the interface to set. All whitespace is 152 * @param interface the name of the interface to set. All whitespace is
129 * removed from the interface name. 153 * removed from the interface name.
130 * @param family the family of this interface inet or inet, ipx or inet6 154 * @param family the family of this interface inet or inet, ipx or inet6
131 * Must of one of the families defined in interfaces.h 155 * Must of one of the families defined in interfaces.h
132 * @param method for the family. see interfaces man page for family methods. 156 * @param method for the family. see interfaces man page for family methods.
133 * @return true if successfull. 157 * @return true if successfull.
134 */ 158 */
135bool Interfaces::addInterface(QString interface, QString family, QString method){ 159bool Interfaces::addInterface(QString interface, QString family, QString method){
136 if(acceptedFamily.contains(family)==0) 160 if(acceptedFamily.contains(family)==0)
137 return false; 161 return false;
138 interface = interface.simplifyWhiteSpace(); 162 interface = interface.simplifyWhiteSpace();
139 interface = interface.replace(QRegExp(" "), ""); 163 interface = interface.replace(QRegExp(" "), "");
140 interfaces.append(""); 164 interfaces.append("");
141 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); 165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method));
142 return true; 166 return true;
143} 167}
144 168
145/** 169/**
146 * Remove the currently selected interface and all of its options. 170 * Remove the currently selected interface and all of its options.
147 * @return bool if successfull or not. 171 * @return bool if successfull or not.
148 */ 172 */
149bool Interfaces::removeInterface(){ 173bool Interfaces::removeInterface(){
150 if(currentIface == interfaces.end()) 174 if(currentIface == interfaces.end())
151 return false; 175 return false;
152 (*currentIface) = ""; 176 (*currentIface) = "";
153 return removeAllInterfaceOptions(); 177 return removeAllInterfaceOptions();
154} 178}
155 179
156/** 180/**
157 * Gets the hardware name of the interface that is currently selected. 181 * Gets the hardware name of the interface that is currently selected.
158 * @return QString name of the hardware interface (eth0, usb2, wlan1...). 182 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
159 * @param error set to true if any error occurs, false otherwise. 183 * @param error set to true if any error occurs, false otherwise.
160 */ 184 */
161QString Interfaces::getInterfaceName(bool &error){ 185QString Interfaces::getInterfaceName(bool &error){
162 if(currentIface == interfaces.end()){ 186 if(currentIface == interfaces.end()){
163 error = true; 187 error = true;
164 return QString(); 188 return QString();
165 } 189 }
166 QString line = (*currentIface); 190 QString line = (*currentIface);
167 line = line.mid(QString(IFACE).length() +1, line.length()); 191 line = line.mid(QString(IFACE).length() +1, line.length());
168 line = line.simplifyWhiteSpace(); 192 line = line.simplifyWhiteSpace();
169 int findSpace = line.find(" "); 193 int findSpace = line.find(" ");
170 if( findSpace < 0){ 194 if( findSpace < 0){
171 error = true; 195 error = true;
172 return QString(); 196 return QString();
173 } 197 }
174 error = false; 198 error = false;
175 return line.mid(0, findSpace); 199 return line.mid(0, findSpace);
176} 200}
177 201
178/** 202/**
179 * Gets the family name of the interface that is currently selected. 203 * Gets the family name of the interface that is currently selected.
180 * @return QString name of the family (inet, inet6, ipx). 204 * @return QString name of the family (inet, inet6, ipx).
181 * @param error set to true if any error occurs, false otherwise. 205 * @param error set to true if any error occurs, false otherwise.
182 */ 206 */
183QString Interfaces::getInterfaceFamily(bool &error){ 207QString Interfaces::getInterfaceFamily(bool &error){
184 QString name = getInterfaceName(error); 208 QString name = getInterfaceName(error);
185 if(error){ 209 if(error){
186 error = true; 210 error = true;
187 return QString(); 211 return QString();
188 } 212 }
189 QString line = (*currentIface); 213 QString line = (*currentIface);
190 line = line.mid(QString(IFACE).length() +1, line.length()); 214 line = line.mid(QString(IFACE).length() +1, line.length());
191 line = line.mid(name.length()+1, line.length()); 215 line = line.mid(name.length()+1, line.length());
192 line = line.simplifyWhiteSpace(); 216 line = line.simplifyWhiteSpace();
193 int findSpace = line.find(" "); 217 int findSpace = line.find(" ");
194 if( findSpace < 0){ 218 if( findSpace < 0){
195 error = true; 219 error = true;
196 return QString(); 220 return QString();
197 } 221 }
198 error = false; 222 error = false;
199 return line.mid(0, findSpace); 223 return line.mid(0, findSpace);
200} 224}
201 225
202/** 226/**
203 * Gets the method of the interface that is currently selected. 227 * Gets the method of the interface that is currently selected.
204 * @return QString name of the method such as staic or dhcp. 228 * @return QString name of the method such as staic or dhcp.
205 * See the man page of interfaces for possible methods depending on the family. 229 * See the man page of interfaces for possible methods depending on the family.
206 * @param error set to true if any error occurs, false otherwise. 230 * @param error set to true if any error occurs, false otherwise.
207 */ 231 */
208QString Interfaces::getInterfaceMethod(bool &error){ 232QString Interfaces::getInterfaceMethod(bool &error){
209 QString name = getInterfaceName(error); 233 QString name = getInterfaceName(error);
210 if(error){ 234 if(error){
211 error = true; 235 error = true;
212 return QString(); 236 return QString();
213 } 237 }
214 QString family = getInterfaceFamily(error); 238 QString family = getInterfaceFamily(error);
215 if(error){ 239 if(error){
216 error = true; 240 error = true;
217 return QString(); 241 return QString();
218 } 242 }
219 QString line = (*currentIface); 243 QString line = (*currentIface);
220 line = line.mid(QString(IFACE).length()+1, line.length()); 244 line = line.mid(QString(IFACE).length()+1, line.length());
221 line = line.mid(name.length()+1, line.length()); 245 line = line.mid(name.length()+1, line.length());
222 line = line.mid(family.length()+1, line.length()); 246 line = line.mid(family.length()+1, line.length());
223 line = line.simplifyWhiteSpace(); 247 line = line.simplifyWhiteSpace();
224 error = false; 248 error = false;
225 return line; 249 return line;
226} 250}
227 251
228/** 252/**
229 * Sets the interface name to newName. 253 * Sets the interface name to newName.
230 * @param newName the new name of the interface. All whitespace is removed. 254 * @param newName the new name of the interface. All whitespace is removed.
231 * @return bool true if successfull. 255 * @return bool true if successfull.
232 */ 256 */
233bool Interfaces::setInterfaceName(QString newName){ 257bool Interfaces::setInterfaceName(QString newName){
234 if(currentIface == interfaces.end()) 258 if(currentIface == interfaces.end())
235 return false; 259 return false;
236 newName = newName.simplifyWhiteSpace(); 260 newName = newName.simplifyWhiteSpace();
237 newName = newName.replace(QRegExp(" "), ""); 261 newName = newName.replace(QRegExp(" "), "");
238 bool returnValue = false; 262 bool returnValue = false;
239 (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); 263 (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
240 return !returnValue; 264 return !returnValue;
241} 265}
242 266
243/** 267/**
244 * Sets the interface family to newName. 268 * Sets the interface family to newName.
245 * @param newName the new name of the interface. Must be one of the families 269 * @param newName the new name of the interface. Must be one of the families
246 * defined in the interfaces.h file. 270 * defined in the interfaces.h file.
247 * @return bool true if successfull. 271 * @return bool true if successfull.
248 */ 272 */
249bool Interfaces::setInterfaceFamily(QString newName){ 273bool Interfaces::setInterfaceFamily(QString newName){
250 if(currentIface == interfaces.end()) 274 if(currentIface == interfaces.end())
251 return false; 275 return false;
252 if(acceptedFamily.contains(newName)==0) 276 if(acceptedFamily.contains(newName)==0)
253 return false; 277 return false;
254 bool returnValue = false; 278 bool returnValue = false;
255 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); 279 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
256 return !returnValue; 280 return !returnValue;
257} 281}
258 282
259/** 283/**
260 * Sets the interface method to newName 284 * Sets the interface method to newName
261 * @param newName the new name of the interface 285 * @param newName the new name of the interface
262 * @return bool true if successfull. 286 * @return bool true if successfull.
263 */ 287 */
264bool Interfaces::setInterfaceMethod(QString newName){ 288bool Interfaces::setInterfaceMethod(QString newName){
265 if(currentIface == interfaces.end()) 289 if(currentIface == interfaces.end())
266 return false; 290 return false;
267 bool returnValue = false; 291 bool returnValue = false;
268 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); 292 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
269 return !returnValue; 293 return !returnValue;
270} 294}
271 295
272/** 296/**
273 * Get a value for an option in the currently selected interface. For example 297 * Get a value for an option in the currently selected interface. For example
274 * calling getInterfaceOption("address") on the following stanza would 298 * calling getInterfaceOption("address") on the following stanza would
275 * return 192.168.1.1. 299 * return 192.168.1.1.
276 * iface eth0 static 300 * iface eth0 static
277 * address 192.168.1.1 301 * address 192.168.1.1
278 * @param option the options to get the value. 302 * @param option the options to get the value.
279 * @param error set to true if any error occurs, false otherwise. 303 * @param error set to true if any error occurs, false otherwise.
280 * @return QString the options value. QString::null if error == true 304 * @return QString the options value. QString::null if error == true
281 */ 305 */
282QString Interfaces::getInterfaceOption(QString option, bool &error){ 306QString Interfaces::getInterfaceOption(QString option, bool &error){
283 return getOption(currentIface, option, error); 307 return getOption(currentIface, option, error);
284} 308}
285 309
286/** 310/**
287 * Set a value for an option in the currently selected interface. If option 311 * Set a value for an option in the currently selected interface. If option
288 * doesn't exist then it is added along with the value. If value is set to an 312 * doesn't exist then it is added along with the value. If value is set to an
289 * empty string then option is removed. 313 * empty string then option is removed.
290 * @param option the options to set the value. 314 * @param option the options to set the value.
291 * @param value the value that option should be set to. 315 * @param value the value that option should be set to.
292 * @param error set to true if any error occurs, false otherwise. 316 * @param error set to true if any error occurs, false otherwise.
293 * @return QString the options value. QString::null if error == true 317 * @return QString the options value. QString::null if error == true
294 */ 318 */
295bool Interfaces::setInterfaceOption(QString option, QString value){ 319bool Interfaces::setInterfaceOption(QString option, QString value){
296 return setOption(currentIface, option, value); 320 return setOption(currentIface, option, value);
297} 321}
298 322
299/** 323/**
300 * Removes all of the options from the currently selected interface. 324 * Removes all of the options from the currently selected interface.
301 * @return bool error if if successfull 325 * @return bool error if if successfull
302 */ 326 */
diff --git a/noncore/settings/networksettings/interfaces.h b/noncore/settings/networksettings/interfaces.h
index 2cc9689..8b4788c 100644
--- a/noncore/settings/networksettings/interfaces.h
+++ b/noncore/settings/networksettings/interfaces.h
@@ -1,70 +1,71 @@
1#ifndef INTERFACES_H 1#ifndef INTERFACES_H
2#define INTERFACES_H 2#define INTERFACES_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6 6
7#define INTERFACES_LOOPBACK "loopback" 7#define INTERFACES_LOOPBACK "loopback"
8 8
9#define INTERFACES_FAMILY_INET "inet" 9#define INTERFACES_FAMILY_INET "inet"
10#define INTERFACES_FAMILY_IPX "ipx" 10#define INTERFACES_FAMILY_IPX "ipx"
11#define INTERFACES_FAMILY_INET6 "inet6" 11#define INTERFACES_FAMILY_INET6 "inet6"
12 12
13#define INTERFACES_METHOD_DHCP "dhcp" 13#define INTERFACES_METHOD_DHCP "dhcp"
14#define INTERFACES_METHOD_STATIC "static" 14#define INTERFACES_METHOD_STATIC "static"
15#define INTERFACES_METHOD_PPP "ppp" 15#define INTERFACES_METHOD_PPP "ppp"
16 16
17/** 17/**
18 * This class provides a clean frontend for parsing the network interfaces file. 18 * This class provides a clean frontend for parsing the network interfaces file.
19 * It provides helper functions to minipulate the options within the file. 19 * It provides helper functions to minipulate the options within the file.
20 * See the interfaces man page for the syntax rules. 20 * See the interfaces man page for the syntax rules.
21 */ 21 */
22class Interfaces { 22class Interfaces {
23 23
24public: 24public:
25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); 25 Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
26 26 QStringList getInterfaceList();
27
27 bool isAuto(QString interface); 28 bool isAuto(QString interface);
28 bool setAuto(QString interface, bool setAuto); 29 bool setAuto(QString interface, bool setAuto);
29 30
30 bool removeInterface(); 31 bool removeInterface();
31 bool addInterface(QString interface, QString family, QString method); 32 bool addInterface(QString interface, QString family, QString method);
32 bool setInterface(QString interface); 33 bool setInterface(QString interface);
33 bool isInterfaceSet(); 34 bool isInterfaceSet();
34 QString getInterfaceName(bool &error); 35 QString getInterfaceName(bool &error);
35 bool setInterfaceName(QString newName); 36 bool setInterfaceName(QString newName);
36 QString getInterfaceFamily(bool &error); 37 QString getInterfaceFamily(bool &error);
37 bool setInterfaceFamily(QString newName); 38 bool setInterfaceFamily(QString newName);
38 QString getInterfaceMethod(bool &error); 39 QString getInterfaceMethod(bool &error);
39 bool setInterfaceMethod(QString newName); 40 bool setInterfaceMethod(QString newName);
40 QString getInterfaceOption(QString option, bool &error); 41 QString getInterfaceOption(QString option, bool &error);
41 bool setInterfaceOption(QString option, QString value); 42 bool setInterfaceOption(QString option, QString value);
42 bool removeAllInterfaceOptions(); 43 bool removeAllInterfaceOptions();
43 44
44 bool setMapping(QString interface); 45 bool setMapping(QString interface);
45 void addMapping(QString interfaces); 46 void addMapping(QString interfaces);
46 bool setMap(QString map, QString value); 47 bool setMap(QString map, QString value);
47 QString getMap(QString map, bool &error); 48 QString getMap(QString map, bool &error);
48 bool setScript(QString); 49 bool setScript(QString);
49 QString getScript(bool &error); 50 QString getScript(bool &error);
50 51
51 bool write(); 52 bool write();
52 53
53private: 54private:
54 bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); 55 bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator);
55 bool setOption(QStringList::Iterator start, QString option, QString value); 56 bool setOption(QStringList::Iterator start, QString option, QString value);
56 QString getOption(QStringList::Iterator start, QString option, bool &error); 57 QString getOption(QStringList::Iterator start, QString option, bool &error);
57 bool removeAllOptions(QStringList::Iterator start); 58 bool removeAllOptions(QStringList::Iterator start);
58 59
59 QString interfacesFile; 60 QString interfacesFile;
60 QStringList interfaces; 61 QStringList interfaces;
61 QStringList::Iterator currentIface; 62 QStringList::Iterator currentIface;
62 QStringList::Iterator currentMapping; 63 QStringList::Iterator currentMapping;
63 64
64 QStringList acceptedFamily; 65 QStringList acceptedFamily;
65}; 66};
66 67
67#endif 68#endif
68 69
69// interfaces 70// interfaces
70 71
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 36f12e0..24af1ec 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,428 +1,450 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interfaces.h"
6
5#include "module.h" 7#include "module.h"
6 8
7#include "kprocess.h" 9#include "kprocess.h"
8 10
9#include <qpushbutton.h> 11#include <qpushbutton.h>
10#include <qtabwidget.h> 12#include <qtabwidget.h>
11#include <qlistbox.h> 13#include <qlistbox.h>
12#include <qlineedit.h> 14#include <qlineedit.h>
13#include <qlistview.h> 15#include <qlistview.h>
14#include <qheader.h> 16#include <qheader.h>
15#include <qlabel.h> 17#include <qlabel.h>
16 18
17#include <qmainwindow.h> 19#include <qmainwindow.h>
18#include <qmessagebox.h> 20#include <qmessagebox.h>
19 21
20#include <qpe/config.h> 22#include <qpe/config.h>
21#include <qpe/qlibrary.h> 23#include <qpe/qlibrary.h>
22#include <qpe/resource.h> 24#include <qpe/resource.h>
23#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
24 26
25#include <qlist.h> 27#include <qlist.h>
26#include <qdir.h> 28#include <qdir.h>
27#include <qfile.h> 29#include <qfile.h>
28#include <qtextstream.h> 30#include <qtextstream.h>
29 31
30#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
31#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
32 34
33MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
34 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 36 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
35 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 37 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
36 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 38 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
37 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 39 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
38 40
39 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 41 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
40 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 42 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
41 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 43 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
42 44
43 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 45 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
44 // Load connections. 46 // Load connections.
45 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 47 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
46 getInterfaceList(); 48 getInterfaceList();
47 connectionList->header()->hide(); 49 connectionList->header()->hide();
48 50
49 51
50 Config cfg("NetworkSetup"); 52 Config cfg("NetworkSetup");
51 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 53 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
52 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 54 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
53 profilesList->insertItem((*it)); 55 profilesList->insertItem((*it));
54 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 56 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
55} 57}
56 58
57/** 59/**
58 * Deconstructor. Save profiles. Delete loaded libraries. 60 * Deconstructor. Save profiles. Delete loaded libraries.
59 */ 61 */
60MainWindowImp::~MainWindowImp(){ 62MainWindowImp::~MainWindowImp(){
61 // Save profiles. 63 // Save profiles.
62 if(profiles.count() > 1){ 64 if(profiles.count() > 1){
63 Config cfg("NetworkSetup"); 65 Config cfg("NetworkSetup");
64 cfg.setGroup("General"); 66 cfg.setGroup("General");
65 cfg.writeEntry("Profiles", profiles.join(" ")); 67 cfg.writeEntry("Profiles", profiles.join(" "));
66 } 68 }
67 // Delete Modules and Libraries 69 // Delete Modules and Libraries
68 QMap<Module*, QLibrary*>::Iterator it; 70 QMap<Module*, QLibrary*>::Iterator it;
69 for( it = libraries.begin(); it != libraries.end(); ++it ){ 71 for( it = libraries.begin(); it != libraries.end(); ++it ){
70 delete it.key(); 72 delete it.key();
71 delete it.data(); 73 delete it.data();
72 } 74 }
73} 75}
74 76
75/** 77/**
76 * Load all modules that are found in the path 78 * Load all modules that are found in the path
77 * @param path a directory that is scaned for any plugins that can be loaded 79 * @param path a directory that is scaned for any plugins that can be loaded
78 * and attempts to load them 80 * and attempts to load them
79 */ 81 */
80void MainWindowImp::loadModules(QString path){ 82void MainWindowImp::loadModules(QString path){
81 qDebug(path.latin1()); 83 qDebug(path.latin1());
82 QDir d(path); 84 QDir d(path);
83 if(!d.exists()) 85 if(!d.exists())
84 return; 86 return;
85 87
86 // Don't want sym links 88 // Don't want sym links
87 d.setFilter( QDir::Files | QDir::NoSymLinks ); 89 d.setFilter( QDir::Files | QDir::NoSymLinks );
88 const QFileInfoList *list = d.entryInfoList(); 90 const QFileInfoList *list = d.entryInfoList();
89 QFileInfoListIterator it( *list ); 91 QFileInfoListIterator it( *list );
90 QFileInfo *fi; 92 QFileInfo *fi;
91 while ( (fi=it.current()) ) { 93 while ( (fi=it.current()) ) {
92 if(fi->fileName().contains(".so")){ 94 if(fi->fileName().contains(".so")){
93 loadPlugin(path + "/" + fi->fileName()); 95 loadPlugin(path + "/" + fi->fileName());
94 } 96 }
95 ++it; 97 ++it;
96 } 98 }
97} 99}
98 100
99/** 101/**
100 * Attempt to load a function and resolve a function. 102 * Attempt to load a function and resolve a function.
101 * @param pluginFileName - the name of the file in which to attempt to load 103 * @param pluginFileName - the name of the file in which to attempt to load
102 * @param resolveString - function pointer to resolve 104 * @param resolveString - function pointer to resolve
103 * @return pointer to the function with name resolveString or NULL 105 * @return pointer to the function with name resolveString or NULL
104 */ 106 */
105Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 107Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
106 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 108 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
107 QLibrary *lib = new QLibrary(pluginFileName); 109 QLibrary *lib = new QLibrary(pluginFileName);
108 void *functionPointer = lib->resolve(resolveString); 110 void *functionPointer = lib->resolve(resolveString);
109 if( !functionPointer ){ 111 if( !functionPointer ){
110 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 112 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
111 delete lib; 113 delete lib;
112 return NULL; 114 return NULL;
113 } 115 }
114 116
115 // Try to get an object. 117 // Try to get an object.
116 Module *object = ((Module* (*)()) functionPointer)(); 118 Module *object = ((Module* (*)()) functionPointer)();
117 if(object == NULL){ 119 if(object == NULL){
118 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 120 qDebug("MainWindowImp: Couldn't create object, but did load library!");
119 delete lib; 121 delete lib;
120 return NULL; 122 return NULL;
121 } 123 }
122 124
123 // Store for deletion later 125 // Store for deletion later
124 libraries.insert(object, lib); 126 libraries.insert(object, lib);
125 return object; 127 return object;
126} 128}
127 129
128/** 130/**
129 * The Add button was clicked. Bring up the add dialog and if OK is hit 131 * The Add button was clicked. Bring up the add dialog and if OK is hit
130 * load the plugin and append it to the list 132 * load the plugin and append it to the list
131 */ 133 */
132void MainWindowImp::addClicked(){ 134void MainWindowImp::addClicked(){
133 QMap<Module*, QLibrary*>::Iterator it; 135 QMap<Module*, QLibrary*>::Iterator it;
134 QMap<QString, QString> list; 136 QMap<QString, QString> list;
135 QMap<QString, Module*> newInterfaceOwners; 137 QMap<QString, Module*> newInterfaceOwners;
136 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 138 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
137 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 139 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
138 for( it = libraries.begin(); it != libraries.end(); ++it ){ 140 for( it = libraries.begin(); it != libraries.end(); ++it ){
139 if(it.key()){ 141 if(it.key()){
140 (it.key())->possibleNewInterfaces(list); 142 (it.key())->possibleNewInterfaces(list);
141 } 143 }
142 } 144 }
143 // See if the list has anything that we can add. 145 // See if the list has anything that we can add.
144 if(list.count() == 0){ 146 if(list.count() == 0){
145 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 147 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
146 return; 148 return;
147 } 149 }
148 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 150 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
149 addNewConnection.addConnections(list); 151 addNewConnection.addConnections(list);
150 addNewConnection.showMaximized(); 152 addNewConnection.showMaximized();
151 if(QDialog::Accepted == addNewConnection.exec()){ 153 if(QDialog::Accepted == addNewConnection.exec()){
152 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 154 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
153 if(!item) 155 if(!item)
154 return; 156 return;
155 157
156 for( it = libraries.begin(); it != libraries.end(); ++it ){ 158 for( it = libraries.begin(); it != libraries.end(); ++it ){
157 if(it.key()){ 159 if(it.key()){
158 Interface *i = (it.key())->addNewInterface(item->text(0)); 160 Interface *i = (it.key())->addNewInterface(item->text(0));
159 if(i){ 161 if(i){
160 interfaceNames.insert(i->getInterfaceName(), i); 162 interfaceNames.insert(i->getInterfaceName(), i);
161 updateInterface(i); 163 updateInterface(i);
162 } 164 }
163 } 165 }
164 } 166 }
165 } 167 }
166} 168}
167 169
168/** 170/**
169 * Prompt the user to see if they really want to do this. 171 * Prompt the user to see if they really want to do this.
170 * If they do then remove from the list and unload. 172 * If they do then remove from the list and unload.
171 */ 173 */
172void MainWindowImp::removeClicked(){ 174void MainWindowImp::removeClicked(){
173 QListViewItem *item = connectionList->currentItem(); 175 QListViewItem *item = connectionList->currentItem();
174 if(!item) { 176 if(!item) {
175 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); 177 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
176 return; 178 return;
177 } 179 }
178 180
179 Interface *i = interfaceItems[item]; 181 Interface *i = interfaceItems[item];
180 if(i->getModuleOwner() == NULL){ 182 if(i->getModuleOwner() == NULL){
181 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 183 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
182 } 184 }
183 else{ 185 else{
184 if(!i->getModuleOwner()->remove(i)) 186 if(!i->getModuleOwner()->remove(i))
185 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 187 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
186 else{ 188 else{
187 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 189 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
188 // TODO memory managment.... 190 // TODO memory managment....
189 // who deletes the interface? 191 // who deletes the interface?
190 } 192 }
191 } 193 }
192} 194}
193 195
194/** 196/**
195 * Pull up the configure about the currently selected interface. 197 * Pull up the configure about the currently selected interface.
196 * Report an error if no interface is selected. 198 * Report an error if no interface is selected.
197 * If the interface has a module owner then request its configure with a empty 199 * If the interface has a module owner then request its configure with a empty
198 * tab. If tab is !NULL then append the interfaces setup widget to it. 200 * tab. If tab is !NULL then append the interfaces setup widget to it.
199 */ 201 */
200void MainWindowImp::configureClicked(){ 202void MainWindowImp::configureClicked(){
201 QListViewItem *item = connectionList->currentItem(); 203 QListViewItem *item = connectionList->currentItem();
202 if(!item){ 204 if(!item){
203 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 205 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
204 return; 206 return;
205 } 207 }
206 208
207 Interface *i = interfaceItems[item]; 209 Interface *i = interfaceItems[item];
208 if(i->getModuleOwner()){ 210 if(i->getModuleOwner()){
209 QTabWidget *tabWidget = NULL; 211 QTabWidget *tabWidget = NULL;
210 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); 212 QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
211 if(moduleConfigure != NULL){ 213 if(moduleConfigure != NULL){
212 if(tabWidget != NULL){ 214 if(tabWidget != NULL){
213 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); 215 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
214 tabWidget->insertTab(configure, "TCP/IP"); 216 tabWidget->insertTab(configure, "TCP/IP");
215 } 217 }
216 moduleConfigure->showMaximized(); 218 moduleConfigure->showMaximized();
217 moduleConfigure->show(); 219 moduleConfigure->show();
218 return; 220 return;
219 } 221 }
220 } 222 }
221 223
222 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); 224 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
223 configure->showMaximized(); 225 configure->showMaximized();
224 configure->show(); 226 configure->show();
225} 227}
226 228
227/** 229/**
228 * Pull up the information about the currently selected interface. 230 * Pull up the information about the currently selected interface.
229 * Report an error if no interface is selected. 231 * Report an error if no interface is selected.
230 * If the interface has a module owner then request its configure with a empty 232 * If the interface has a module owner then request its configure with a empty
231 * tab. If tab is !NULL then append the interfaces setup widget to it. 233 * tab. If tab is !NULL then append the interfaces setup widget to it.
232 */ 234 */
233void MainWindowImp::informationClicked(){ 235void MainWindowImp::informationClicked(){
234 QListViewItem *item = connectionList->currentItem(); 236 QListViewItem *item = connectionList->currentItem();
235 if(!item){ 237 if(!item){
236 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
237 return; 239 return;
238 } 240 }
239 241
240 Interface *i = interfaceItems[item]; 242 Interface *i = interfaceItems[item];
241 if(i->getModuleOwner()){ 243 if(i->getModuleOwner()){
242 QTabWidget *tabWidget = NULL; 244 QTabWidget *tabWidget = NULL;
243 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 245 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
244 if(moduleInformation != NULL){ 246 if(moduleInformation != NULL){
245 if(tabWidget != NULL){ 247 if(tabWidget != NULL){
246 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 248 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
247 tabWidget->insertTab(information, "TCP/IP"); 249 tabWidget->insertTab(information, "TCP/IP");
248 } 250 }
249 moduleInformation->showMaximized(); 251 moduleInformation->showMaximized();
250 moduleInformation->show(); 252 moduleInformation->show();
251 return; 253 return;
252 } 254 }
253 } 255 }
254 256
255 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 257 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
256 information->showMaximized(); 258 information->showMaximized();
257 information->show(); 259 information->show();
258} 260}
259 261
260/** 262/**
261 * Aquire the list of active interfaces from ifconfig 263 * Aquire the list of active interfaces from ifconfig
262 * Call ifconfig and ifconfig -a 264 * Call ifconfig and ifconfig -a
263 */ 265 */
264void MainWindowImp::getInterfaceList(){ 266void MainWindowImp::getInterfaceList(){
265 KShellProcess *processAll = new KShellProcess(); 267 KShellProcess *processAll = new KShellProcess();
266 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 268 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
267 connect(processAll, SIGNAL(processExited(KProcess *)), 269 connect(processAll, SIGNAL(processExited(KProcess *)),
268 this, SLOT(jobDone(KProcess *))); 270 this, SLOT(jobDone(KProcess *)));
269 threads.insert(processAll, TEMP_ALL); 271 threads.insert(processAll, TEMP_ALL);
270 processAll->start(KShellProcess::NotifyOnExit); 272 processAll->start(KShellProcess::NotifyOnExit);
271 273
272 KShellProcess *process = new KShellProcess(); 274 KShellProcess *process = new KShellProcess();
273 *process << "/sbin/ifconfig" << " > " TEMP_UP; 275 *process << "/sbin/ifconfig" << " > " TEMP_UP;
274 connect(process, SIGNAL(processExited(KProcess *)), 276 connect(process, SIGNAL(processExited(KProcess *)),
275 this, SLOT(jobDone(KProcess *))); 277 this, SLOT(jobDone(KProcess *)));
276 threads.insert(process, TEMP_UP); 278 threads.insert(process, TEMP_UP);
277 process->start(KShellProcess::NotifyOnExit); 279 process->start(KShellProcess::NotifyOnExit);
278} 280}
279 281
280void MainWindowImp::jobDone(KProcess *process){ 282void MainWindowImp::jobDone(KProcess *process){
281 QString fileName = threads[process]; 283 QString fileName = threads[process];
282 threads.remove(process); 284 threads.remove(process);
283 delete process; 285 delete process;
284 286
285 QFile file(fileName); 287 QFile file(fileName);
286 if (!file.open(IO_ReadOnly)){ 288 if (!file.open(IO_ReadOnly)){
287 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 289 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
288 return; 290 return;
289 } 291 }
290 292
291 QTextStream stream( &file ); 293 QTextStream stream( &file );
292 QString line; 294 QString line;
293 while ( !stream.eof() ) { 295 while ( !stream.eof() ) {
294 line = stream.readLine(); 296 line = stream.readLine();
295 int space = line.find(" "); 297 int space = line.find(" ");
296 if(space > 1){ 298 if(space > 1){
297 // We have found an interface 299 // We have found an interface
298 QString interfaceName = line.mid(0, space); 300 QString interfaceName = line.mid(0, space);
299 if(!advancedUserMode){ 301 if(!advancedUserMode){
300 if(interfaceName == "lo") 302 if(interfaceName == "lo")
301 break; 303 break;
302 } 304 }
303 Interface *i; 305 Interface *i;
304 // See if we already have it 306 // See if we already have it
305 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 307 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
306 if(fileName == TEMP_ALL) 308 if(fileName == TEMP_ALL)
307 i = new Interface(interfaceName, false); 309 i = new Interface(interfaceName, false);
308 else 310 else
309 i = new Interface(interfaceName, true); 311 i = new Interface(interfaceName, true);
310 } 312 }
311 else{ 313 else{
312 i = interfaceNames[interfaceName]; 314 i = interfaceNames[interfaceName];
313 if(fileName != TEMP_ALL) 315 if(fileName != TEMP_ALL)
314 i->setStatus(true); 316 i->setStatus(true);
315 } 317 }
316 318
317 i->setAttached(true); 319 i->setAttached(true);
318 i->setInterfaceName(interfaceName); 320 i->setInterfaceName(interfaceName);
319 321
320 QString hardName = "Ethernet"; 322 QString hardName = "Ethernet";
321 int hardwareName = line.find("Link encap:"); 323 int hardwareName = line.find("Link encap:");
322 int macAddress = line.find("HWaddr"); 324 int macAddress = line.find("HWaddr");
323 if(macAddress == -1) 325 if(macAddress == -1)
324 macAddress = line.length(); 326 macAddress = line.length();
325 if(hardwareName != -1) 327 if(hardwareName != -1)
326 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); 328 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
327 // We have found an interface 329 // We have found an interface
328 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 330 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
329 interfaceNames.insert(i->getInterfaceName(), i); 331 interfaceNames.insert(i->getInterfaceName(), i);
330 updateInterface(i); 332 updateInterface(i);
331 } 333 }
332 } 334 }
333 file.close(); 335 file.close();
334 QFile::remove(fileName); 336 QFile::remove(fileName);
337 if(threads.count() == 0){
338 Interfaces i;
339 QStringList list = i.getInterfaceList();
340 QMap<QString, Interface*>::Iterator it;
341 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
342 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
343 if(it.key() == (*ni)){
344 Interface *i = new Interface(*ni, false);
345 i->setAttached(false);
346 i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
347 i->setInterfaceName(*ni);
348 interfaceNames.insert(i->getInterfaceName(), i);
349 updateInterface(i);
350 }
351 }
352 }
353 }
335} 354}
336 355
337/** 356/**
338 * Update this interface. If no QListViewItem exists create one. 357 * Update this interface. If no QListViewItem exists create one.
339 * @param Interface* pointer to the interface that needs to be updated. 358 * @param Interface* pointer to the interface that needs to be updated.
340 */ 359 */
341void MainWindowImp::updateInterface(Interface *i){ 360void MainWindowImp::updateInterface(Interface *i){
342 QListViewItem *item = NULL; 361 QListViewItem *item = NULL;
343 362
344 // Find the interface, making it if needed. 363 // Find the interface, making it if needed.
345 if(items.find(i) == items.end()){ 364 if(items.find(i) == items.end()){
346 item = new QListViewItem(connectionList, "", "", ""); 365 item = new QListViewItem(connectionList, "", "", "");
347 // See if you can't find a module owner for this interface 366 // See if you can't find a module owner for this interface
348 QMap<Module*, QLibrary*>::Iterator it; 367 QMap<Module*, QLibrary*>::Iterator it;
349 for( it = libraries.begin(); it != libraries.end(); ++it ){ 368 for( it = libraries.begin(); it != libraries.end(); ++it ){
350 if(it.key()->isOwner(i)) 369 if(it.key()->isOwner(i))
351 i->setModuleOwner(it.key()); 370 i->setModuleOwner(it.key());
352 } 371 }
353 items.insert(i, item); 372 items.insert(i, item);
354 interfaceItems.insert(item, i); 373 interfaceItems.insert(item, i);
355 } 374 }
356 else 375 else
357 item = items[i]; 376 item = items[i];
358 377
359 // Update the icons and information 378 // Update the icons and information
360 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 379 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
361 380
362 QString typeName = "lan"; 381 QString typeName = "lan";
363 if(i->getHardwareName().contains("Local Loopback")) 382 if(i->getHardwareName().contains("Local Loopback"))
364 typeName = "lo"; 383 typeName = "lo";
365 if(i->getInterfaceName().contains("irda")) 384 if(i->getInterfaceName().contains("irda"))
366 typeName = "irda"; 385 typeName = "irda";
367 if(i->getInterfaceName().contains("wlan")) 386 if(i->getInterfaceName().contains("wlan"))
368 typeName = "wlan"; 387 typeName = "wlan";
388
389 if(!i->isAttached())
390 typeName = "connect_no";
369 // Actually try to use the Module 391 // Actually try to use the Module
370 if(i->getModuleOwner() != NULL) 392 if(i->getModuleOwner() != NULL)
371 typeName = i->getModuleOwner()->getPixmapName(i); 393 typeName = i->getModuleOwner()->getPixmapName(i);
372 394
373 item->setPixmap(1, (Resource::loadPixmap(typeName))); 395 item->setPixmap(1, (Resource::loadPixmap(typeName)));
374 item->setText(2, i->getHardwareName()); 396 item->setText(2, i->getHardwareName());
375 item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); 397 item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
376} 398}
377 399
378void MainWindowImp::newProfileChanged(const QString& newText){ 400void MainWindowImp::newProfileChanged(const QString& newText){
379 if(newText.length() > 0) 401 if(newText.length() > 0)
380 newProfileButton->setEnabled(true); 402 newProfileButton->setEnabled(true);
381 else 403 else
382 newProfileButton->setEnabled(false); 404 newProfileButton->setEnabled(false);
383} 405}
384 406
385/** 407/**
386 * Adds a new profile to the list of profiles. 408 * Adds a new profile to the list of profiles.
387 * Don't add profiles that already exists. 409 * Don't add profiles that already exists.
388 * Appends to the list and QStringList 410 * Appends to the list and QStringList
389 */ 411 */
390void MainWindowImp::addProfile(){ 412void MainWindowImp::addProfile(){
391 QString newProfileName = newProfile->text(); 413 QString newProfileName = newProfile->text();
392 if(profiles.grep(newProfileName).count() > 0){ 414 if(profiles.grep(newProfileName).count() > 0){
393 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 415 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
394 return; 416 return;
395 } 417 }
396 profiles.append(newProfileName); 418 profiles.append(newProfileName);
397 profilesList->insertItem(newProfileName); 419 profilesList->insertItem(newProfileName);
398} 420}
399 421
400/** 422/**
401 * Removes the currently selected profile in the combo. 423 * Removes the currently selected profile in the combo.
402 * Doesn't delete if there are less then 2 profiles. 424 * Doesn't delete if there are less then 2 profiles.
403 */ 425 */
404void MainWindowImp::removeProfile(){ 426void MainWindowImp::removeProfile(){
405 if(profilesList->count() <= 1){ 427 if(profilesList->count() <= 1){
406 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok"); 428 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
407 return; 429 return;
408 } 430 }
409 QString profileToRemove = profilesList->currentText(); 431 QString profileToRemove = profilesList->currentText();
410 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 432 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
411 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 433 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
412 profilesList->clear(); 434 profilesList->clear();
413 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 435 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
414 profilesList->insertItem((*it)); 436 profilesList->insertItem((*it));
415 } 437 }
416 438
417} 439}
418 440
419/** 441/**
420 * A new profile has been selected, change. 442 * A new profile has been selected, change.
421 * @param newProfile the new profile. 443 * @param newProfile the new profile.
422 */ 444 */
423void MainWindowImp::changeProfile(){ 445void MainWindowImp::changeProfile(){
424 currentProfileLabel->setText(profilesList->text(profilesList->currentItem())); 446 currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
425} 447}
426 448
427// mainwindowimp.cpp 449// mainwindowimp.cpp
428 450
diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro
index f09db93..441bbaa 100644
--- a/noncore/settings/networksettings/networksetup.pro
+++ b/noncore/settings/networksettings/networksetup.pro
@@ -1,11 +1,11 @@
1 DESTDIR = $(OPIEDIR)/bin 1 #DESTDIR = $(OPIEDIR)/bin
2 TEMPLATE= app 2 TEMPLATE= app
3 #CONFIG = qt warn_on debug 3 #CONFIG = qt warn_on debug
4 CONFIG = qt warn_on release 4 CONFIG = qt warn_on release
5 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h 5 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h
6 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp 6 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp
7 INCLUDEPATH+= $(OPIEDIR)/include 7 #INCLUDEPATH+= $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 8 #DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
10 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui 10 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui
11 TARGET = networksetup 11 TARGET = networksetup