summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO3
-rw-r--r--noncore/net/networksetup/addconnectionimp.cpp5
-rw-r--r--noncore/net/networksetup/addconnectionimp.h2
-rw-r--r--noncore/net/networksetup/interfaces/interface.cpp2
-rw-r--r--noncore/net/networksetup/interfaces/interface.h19
-rw-r--r--noncore/net/networksetup/interfaces/interfaces.cpp62
-rw-r--r--noncore/net/networksetup/interfaces/interfaces.h48
-rw-r--r--noncore/net/networksetup/interfaces/interfacesetup.ui26
-rw-r--r--noncore/net/networksetup/interfaces/interfacesetupimp.h1
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp6
-rw-r--r--noncore/net/networksetup/mainwindowimp.h6
-rw-r--r--noncore/net/networksetup/module.h4
-rw-r--r--noncore/net/networksetup/wlan/infoimp.h2
-rw-r--r--noncore/net/networksetup/wlan/wextensions.cpp3
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.cpp2
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.h2
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp4
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.h18
-rw-r--r--noncore/settings/networksettings/TODO3
-rw-r--r--noncore/settings/networksettings/addconnectionimp.cpp5
-rw-r--r--noncore/settings/networksettings/addconnectionimp.h2
-rw-r--r--noncore/settings/networksettings/interfaces/interface.cpp2
-rw-r--r--noncore/settings/networksettings/interfaces/interface.h19
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp62
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.h48
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetup.ui26
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.h1
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp6
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h6
-rw-r--r--noncore/settings/networksettings/module.h4
-rw-r--r--noncore/settings/networksettings/wlan/infoimp.h2
-rw-r--r--noncore/settings/networksettings/wlan/wextensions.cpp3
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.h2
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp4
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.h18
36 files changed, 238 insertions, 192 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index 8e57405..7185dbe 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,14 +1,13 @@
1CLEAN UP 1CLEAN UP
2 2
3Write a class that parses /proc and not ifconfig
4
5udchcp needs to output the dhcp information so interfaces can read it 3udchcp needs to output the dhcp information so interfaces can read it
6 4
7interfacesetupimp really doesn't need a interface* pointer 5interfacesetupimp really doesn't need a interface* pointer
8 6
9Possible other modules to write: ppp, ipsec, bluetooth, ipchains 7Possible other modules to write: ppp, ipsec, bluetooth, ipchains
10 8
11PPP module needs to scan pppd.tdb to see what is currently active 9PPP module needs to scan pppd.tdb to see what is currently active
12 10
13WLAN - add possiblity to input text or hex without knowing "s:" 11WLAN - add possiblity to input text or hex without knowing "s:"
14 12
13Interface setupimp needs to use kernel calls.
diff --git a/noncore/net/networksetup/addconnectionimp.cpp b/noncore/net/networksetup/addconnectionimp.cpp
index 53db0fc..07545f7 100644
--- a/noncore/net/networksetup/addconnectionimp.cpp
+++ b/noncore/net/networksetup/addconnectionimp.cpp
@@ -4,35 +4,34 @@
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qheader.h> 5#include <qheader.h>
6 6
7/** 7/**
8 * Constructor 8 * Constructor
9 */ 9 */
10AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){ 10AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){
11 connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed())); 11 connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed()));
12 registeredServicesList->header()->hide(); 12 registeredServicesList->header()->hide();
13}; 13};
14 14
15/** 15/**
16 * The current item changed, update the discription. 16 * The current item changed, update the discription.
17 */ 17 */
18void AddConnectionImp::changed(){ 18void AddConnectionImp::changed(){
19 QListViewItem *item = registeredServicesList->currentItem(); 19 QListViewItem *item = registeredServicesList->currentItem();
20 if(item){ 20 if(item)
21 help->setText(list[item->text(0)]); 21 help->setText(list[item->text(0)]);
22 }
23} 22}
24 23
25/** 24/**
26 * Save a copy of newList for the discriptions and append them all to the view 25 * Save a copy of newList for the discriptions and append them all to the view
27 * @param newList the new list of possible interfaces 26 * @param newList the new list of possible interfaces
28 */ 27 */
29void AddConnectionImp::addConnections(QMap<QString, QString> newList){ 28void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){
30 list = newList; 29 list = newList;
31 QMap<QString, QString>::Iterator it; 30 QMap<QString, QString>::Iterator it;
32 for( it = list.begin(); it != list.end(); ++it ) 31 for( it = list.begin(); it != list.end(); ++it )
33 QListViewItem *item = new QListViewItem(registeredServicesList, it.key()); 32 QListViewItem *item = new QListViewItem(registeredServicesList, it.key());
34 registeredServicesList->setCurrentItem(registeredServicesList->firstChild()); 33 registeredServicesList->setCurrentItem(registeredServicesList->firstChild());
35} 34}
36 35
37// addserviceimp.cpp 36// addserviceimp.cpp
38 37
diff --git a/noncore/net/networksetup/addconnectionimp.h b/noncore/net/networksetup/addconnectionimp.h
index 643cd9a..680a502 100644
--- a/noncore/net/networksetup/addconnectionimp.h
+++ b/noncore/net/networksetup/addconnectionimp.h
@@ -1,29 +1,29 @@
1#ifndef ADDCONNECTIONIMP_H 1#ifndef ADDCONNECTIONIMP_H
2#define ADDCONNECTIONIMP_H 2#define ADDCONNECTIONIMP_H
3 3
4#include "addconnection.h" 4#include "addconnection.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qlist.h> 6#include <qlist.h>
7 7
8class QListViewItem; 8class QListViewItem;
9 9
10class AddConnectionImp : public AddConnection { 10class AddConnectionImp : public AddConnection {
11 11
12Q_OBJECT 12Q_OBJECT
13 13
14public: 14public:
15 AddConnectionImp(QWidget *parent=0, const char *name=0, WFlags f=0); 15 AddConnectionImp(QWidget *parent=0, const char *name=0, WFlags f=0);
16 void addConnections(QMap<QString, QString> newList); 16 void addConnections(const QMap<QString, QString> &newList);
17 17
18private slots: 18private slots:
19 void changed(); 19 void changed();
20 20
21private: 21private:
22 QMap<QString, QString> list; 22 QMap<QString, QString> list;
23 23
24}; 24};
25 25
26#endif 26#endif
27 27
28// addconectionimp.h 28// addconectionimp.h
29 29
diff --git a/noncore/net/networksetup/interfaces/interface.cpp b/noncore/net/networksetup/interfaces/interface.cpp
index e4f405e..4129b3d 100644
--- a/noncore/net/networksetup/interfaces/interface.cpp
+++ b/noncore/net/networksetup/interfaces/interface.cpp
@@ -29,33 +29,33 @@ void Interface::setStatus(bool newStatus){
29 29
30/** 30/**
31 * Set if attached or not (802.11 card pulled out for example) 31 * Set if attached or not (802.11 card pulled out for example)
32 * @param isAttached - if attached 32 * @param isAttached - if attached
33 * emit updateInterface 33 * emit updateInterface
34 */ 34 */
35void Interface::setAttached(bool isAttached){ 35void Interface::setAttached(bool isAttached){
36 attached = isAttached; 36 attached = isAttached;
37 emit(updateInterface(this)); 37 emit(updateInterface(this));
38}; 38};
39 39
40/** 40/**
41 * Set Hardware name 41 * Set Hardware name
42 * @param name - the new name 42 * @param name - the new name
43 * emit updateInterface 43 * emit updateInterface
44 */ 44 */
45void Interface::setHardwareName(QString name){ 45void Interface::setHardwareName(const QString &name){
46 hardwareName = name; 46 hardwareName = name;
47 emit(updateInterface(this)); 47 emit(updateInterface(this));
48}; 48};
49 49
50/** 50/**
51 * Set Module owner 51 * Set Module owner
52 * @param owner - the new owner 52 * @param owner - the new owner
53 * emit updateInterface 53 * emit updateInterface
54 */ 54 */
55void Interface::setModuleOwner(Module *owner){ 55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner; 56 moduleOwner = owner;
57 emit(updateInterface(this)); 57 emit(updateInterface(this));
58}; 58};
59 59
60 60
61/** 61/**
diff --git a/noncore/net/networksetup/interfaces/interface.h b/noncore/net/networksetup/interfaces/interface.h
index fc064fe..989d6d8 100644
--- a/noncore/net/networksetup/interfaces/interface.h
+++ b/noncore/net/networksetup/interfaces/interface.h
@@ -2,47 +2,46 @@
2#define INTERFACE_H 2#define INTERFACE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7class Module; 7class Module;
8 8
9class Interface : public QObject{ 9class Interface : public QObject{
10 Q_OBJECT 10 Q_OBJECT
11 11
12signals: 12signals:
13 void updateInterface(Interface *i); 13 void updateInterface(Interface *i);
14 void updateMessage(const QString &message); 14 void updateMessage(const QString &message);
15 15
16public: 16public:
17 Interface(QObject * parent=0, const char * name= "unknown", bool status = false); 17 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
18 virtual ~Interface(){};
19 18
20 virtual QString getInterfaceName(){ QString n(this->name()); return n; }; 19 QString getInterfaceName(){ QString n(this->name()); return n; };
21 20
22 virtual bool getStatus(){ return status; }; 21 bool getStatus(){ return status; };
23 virtual void setStatus(bool newStatus); 22 void setStatus(bool newStatus);
24 23
25 virtual bool isAttached(){ return attached; }; 24 bool isAttached(){ return attached; };
26 virtual void setAttached(bool isAttached=false); 25 void setAttached(bool isAttached=false);
27 26
28 virtual QString getHardwareName(){ return hardwareName; }; 27 QString getHardwareName(){ return hardwareName; };
29 virtual void setHardwareName(QString name="Unknown"); 28 void setHardwareName(const QString &name="Unknown");
30 29
31 virtual Module* getModuleOwner(){ return moduleOwner; }; 30 Module* getModuleOwner(){ return moduleOwner; };
32 virtual void setModuleOwner(Module *owner=NULL); 31 void setModuleOwner(Module *owner=NULL);
33 32
34 // inet information. 33 // inet information.
35 QString getMacAddress(){ return macAddress; }; 34 QString getMacAddress(){ return macAddress; };
36 QString getIp(){ return ip; }; 35 QString getIp(){ return ip; };
37 QString getSubnetMask(){ return subnetMask; }; 36 QString getSubnetMask(){ return subnetMask; };
38 QString getBroadcast(){ return broadcast; }; 37 QString getBroadcast(){ return broadcast; };
39 bool isDhcp(){ return dhcp; }; 38 bool isDhcp(){ return dhcp; };
40 QString getDhcpServerIp(){ return dhcpServerIp; }; 39 QString getDhcpServerIp(){ return dhcpServerIp; };
41 QString getLeaseObtained(){ return leaseObtained; }; 40 QString getLeaseObtained(){ return leaseObtained; };
42 QString getLeaseExpires(){ return leaseExpires; }; 41 QString getLeaseExpires(){ return leaseExpires; };
43 42
44public slots: 43public slots:
45 bool refresh(); 44 bool refresh();
46 void start(); 45 void start();
47 void stop(); 46 void stop();
48 void restart(); 47 void restart();
diff --git a/noncore/net/networksetup/interfaces/interfaces.cpp b/noncore/net/networksetup/interfaces/interfaces.cpp
index f1b8067..708f399 100644
--- a/noncore/net/networksetup/interfaces/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces/interfaces.cpp
@@ -57,49 +57,49 @@ QStringList Interfaces::getInterfaceList(){
57 int findSpace = line.find(" "); 57 int findSpace = line.find(" ");
58 if( findSpace >= 0){ 58 if( findSpace >= 0){
59 line = line.mid(0, findSpace); 59 line = line.mid(0, findSpace);
60 list.append(line); 60 list.append(line);
61 } 61 }
62 } 62 }
63 } 63 }
64 return list; 64 return list;
65} 65}
66 66
67/** 67/**
68 * Find out if interface is in an "auto" group or not. 68 * Find out if interface is in an "auto" group or not.
69 * Report any duplicates such as eth0 being in two differnt auto's 69 * Report any duplicates such as eth0 being in two differnt auto's
70 * @param interface interface to check to see if it is on or not. 70 * @param interface interface to check to see if it is on or not.
71 * @return true is interface is in auto 71 * @return true is interface is in auto
72 */ 72 */
73bool Interfaces::isAuto(QString interface){ 73bool Interfaces::isAuto(const QString &interface){
74 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 74 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
75 QStringList awi = autoLines.grep(QRegExp(interface)); 75 QStringList awi = autoLines.grep(QRegExp(interface));
76 if(awi.count() > 1) 76 if(awi.count() > 1)
77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
78 if(awi.count() < 1) 78 if(awi.count() < 1)
79 return false; 79 return false;
80 return true; 80 return true;
81} 81}
82 82
83/** 83/**
84 * Attempt to set the auto option for interface to setAuto. 84 * Attempt to set the auto option for interface to setAuto.
85 * @param interface the interface to set 85 * @param interface the interface to set
86 * @param setAuto the value to set interface to. 86 * @param setAuto the value to set interface to.
87 * @return false if already set to setAuto. 87 * @return false if already set to setAuto.
88 * */ 88 * */
89bool Interfaces::setAuto(QString interface, bool setAuto){ 89bool Interfaces::setAuto(const QString &interface, bool setAuto){
90 // Don't need to set it if it is already set. 90 // Don't need to set it if it is already set.
91 if(isAuto(interface) == setAuto) 91 if(isAuto(interface) == setAuto)
92 return false; 92 return false;
93 93
94 bool changed = false; 94 bool changed = false;
95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
96 if((*it).contains(AUTO)){ 96 if((*it).contains(AUTO)){
97 //We know that they are not in any group so let add to this auto. 97 //We know that they are not in any group so let add to this auto.
98 if(setAuto){ 98 if(setAuto){
99 (*it) = (*it) += " " + interface; 99 (*it) = (*it) += " " + interface;
100 // Don't care to have such thins as: auto eth0 lo usb0 100 // Don't care to have such thins as: auto eth0 lo usb0
101 (*it) = (*it).simplifyWhiteSpace(); 101 (*it) = (*it).simplifyWhiteSpace();
102 changed = true; 102 changed = true;
103 break; 103 break;
104 } 104 }
105 else{ 105 else{
@@ -143,48 +143,48 @@ bool Interfaces::setInterface(QString interface){
143 * A quick helper funtion to see if the current interface is set. 143 * A quick helper funtion to see if the current interface is set.
144 * @return bool true if set, false otherwise. 144 * @return bool true if set, false otherwise.
145 */ 145 */
146bool Interfaces::isInterfaceSet(){ 146bool Interfaces::isInterfaceSet(){
147 return (currentIface != interfaces.end()); 147 return (currentIface != interfaces.end());
148} 148}
149 149
150/** 150/**
151 * Add a new interface of with the settings - family and method 151 * Add a new interface of with the settings - family and method
152 * @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
153 * removed from the interface name. 153 * removed from the interface name.
154 * @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
155 * Must of one of the families defined in interfaces.h 155 * Must of one of the families defined in interfaces.h
156 * @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.
157 * @return true if successfull. 157 * @return true if successfull.
158 */ 158 */
159bool Interfaces::addInterface(QString interface, QString family, QString method){ 159bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
160 if(acceptedFamily.contains(family)==0) 160 if(acceptedFamily.contains(family)==0)
161 return false; 161 return false;
162 interface = interface.simplifyWhiteSpace(); 162 QString newInterface = interface.simplifyWhiteSpace();
163 interface = interface.replace(QRegExp(" "), ""); 163 newInterface = newInterface.replace(QRegExp(" "), "");
164 interfaces.append(""); 164 interfaces.append("");
165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); 165 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
166 return true; 166 return true;
167} 167}
168 168
169/** 169/**
170 * Copies interface with name interface to name newInterface 170 * Copies interface with name interface to name newInterface
171 * @param newInterface name of the new interface. 171 * @param newInterface name of the new interface.
172 * @return bool true if successfull 172 * @return bool true if successfull
173 */ 173 */
174bool Interfaces::copyInterface(QString interface, QString newInterface){ 174bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
175 if(!setInterface(interface)) return false; 175 if(!setInterface(interface)) return false;
176 176
177 QStringList::Iterator it = currentIface; 177 QStringList::Iterator it = currentIface;
178 it++; 178 it++;
179 179
180 bool error; 180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); 181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) return false; 182 if(!setInterface(newInterface)) return false;
183 QStringList::Iterator newIface = currentIface; 183 QStringList::Iterator newIface = currentIface;
184 newIface++; 184 newIface++;
185 185
186 for ( ; it != interfaces.end(); ++it ){ 186 for ( ; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) 187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break; 188 break;
189 newIface = interfaces.insert(newIface, *it); 189 newIface = interfaces.insert(newIface, *it);
190 } 190 }
@@ -267,205 +267,207 @@ QString Interfaces::getInterfaceMethod(bool &error){
267 return QString(); 267 return QString();
268 } 268 }
269 QString line = (*currentIface); 269 QString line = (*currentIface);
270 line = line.mid(QString(IFACE).length()+1, line.length()); 270 line = line.mid(QString(IFACE).length()+1, line.length());
271 line = line.mid(name.length()+1, line.length()); 271 line = line.mid(name.length()+1, line.length());
272 line = line.mid(family.length()+1, line.length()); 272 line = line.mid(family.length()+1, line.length());
273 line = line.simplifyWhiteSpace(); 273 line = line.simplifyWhiteSpace();
274 error = false; 274 error = false;
275 return line; 275 return line;
276} 276}
277 277
278/** 278/**
279 * Sets the interface name to newName. 279 * Sets the interface name to newName.
280 * @param newName the new name of the interface. All whitespace is removed. 280 * @param newName the new name of the interface. All whitespace is removed.
281 * @return bool true if successfull. 281 * @return bool true if successfull.
282 */ 282 */
283bool Interfaces::setInterfaceName(QString newName){ 283bool Interfaces::setInterfaceName(const QString &newName){
284 if(currentIface == interfaces.end()) 284 if(currentIface == interfaces.end())
285 return false; 285 return false;
286 newName = newName.simplifyWhiteSpace(); 286 QString name = newName.simplifyWhiteSpace();
287 newName = newName.replace(QRegExp(" "), ""); 287 name = name.replace(QRegExp(" "), "");
288 bool returnValue = false; 288 bool returnValue = false;
289 (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); 289 (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
290 return !returnValue; 290 return !returnValue;
291} 291}
292 292
293/** 293/**
294 * Sets the interface family to newName. 294 * Sets the interface family to newName.
295 * @param newName the new name of the interface. Must be one of the families 295 * @param newName the new name of the interface. Must be one of the families
296 * defined in the interfaces.h file. 296 * defined in the interfaces.h file.
297 * @return bool true if successfull. 297 * @return bool true if successfull.
298 */ 298 */
299bool Interfaces::setInterfaceFamily(QString newName){ 299bool Interfaces::setInterfaceFamily(const QString &newName){
300 if(currentIface == interfaces.end()) 300 if(currentIface == interfaces.end())
301 return false; 301 return false;
302 if(acceptedFamily.contains(newName)==0) 302 if(acceptedFamily.contains(newName)==0)
303 return false; 303 return false;
304 bool returnValue = false; 304 bool returnValue = false;
305 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); 305 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
306 return !returnValue; 306 return !returnValue;
307} 307}
308 308
309/** 309/**
310 * Sets the interface method to newName 310 * Sets the interface method to newName
311 * @param newName the new name of the interface 311 * @param newName the new name of the interface
312 * @return bool true if successfull. 312 * @return bool true if successfull.
313 */ 313 */
314bool Interfaces::setInterfaceMethod(QString newName){ 314bool Interfaces::setInterfaceMethod(const QString &newName){
315 if(currentIface == interfaces.end()) 315 if(currentIface == interfaces.end())
316 return false; 316 return false;
317 bool returnValue = false; 317 bool returnValue = false;
318 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); 318 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
319 return !returnValue; 319 return !returnValue;
320} 320}
321 321
322/** 322/**
323 * Get a value for an option in the currently selected interface. For example 323 * Get a value for an option in the currently selected interface. For example
324 * calling getInterfaceOption("address") on the following stanza would 324 * calling getInterfaceOption("address") on the following stanza would
325 * return 192.168.1.1. 325 * return 192.168.1.1.
326 * iface eth0 static 326 * iface eth0 static
327 * address 192.168.1.1 327 * address 192.168.1.1
328 * @param option the options to get the value. 328 * @param option the options to get the value.
329 * @param error set to true if any error occurs, false otherwise. 329 * @param error set to true if any error occurs, false otherwise.
330 * @return QString the options value. QString::null if error == true 330 * @return QString the options value. QString::null if error == true
331 */ 331 */
332QString Interfaces::getInterfaceOption(QString option, bool &error){ 332QString Interfaces::getInterfaceOption(const QString &option, bool &error){
333 return getOption(currentIface, option, error); 333 return getOption(currentIface, option, error);
334} 334}
335 335
336/** 336/**
337 * Set a value for an option in the currently selected interface. If option 337 * Set a value for an option in the currently selected interface. If option
338 * doesn't exist then it is added along with the value. 338 * doesn't exist then it is added along with the value.
339 * @param option the options to set the value. 339 * @param option the options to set the value.
340 * @param value the value that option should be set to. 340 * @param value the value that option should be set to.
341 * @param error set to true if any error occurs, false otherwise. 341 * @param error set to true if any error occurs, false otherwise.
342 * @return QString the options value. QString::null if error == true 342 * @return QString the options value. QString::null if error == true
343 */ 343 */
344bool Interfaces::setInterfaceOption(QString option, QString value){ 344bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
345 return setOption(currentIface, option, value); 345 return setOption(currentIface, option, value);
346} 346}
347 347
348/** 348/**
349 * Removes a value for an option in the currently selected interface. 349 * Removes a value for an option in the currently selected interface.
350 * @param option the options to set the value. 350 * @param option the options to set the value.
351 * @param value the value that option should be set to. 351 * @param value the value that option should be set to.
352 * @param error set to true if any error occurs, false otherwise. 352 * @param error set to true if any error occurs, false otherwise.
353 * @return QString the options value. QString::null if error == true 353 * @return QString the options value. QString::null if error == true
354 */ 354 */
355bool Interfaces::removeInterfaceOption(QString option, QString value){ 355bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
356 return removeOption(currentIface, option, value); 356 return removeOption(currentIface, option, value);
357} 357}
358 358
359/** 359/**
360 * Removes all of the options from the currently selected interface. 360 * Removes all of the options from the currently selected interface.
361 * @return bool error if if successfull 361 * @return bool error if if successfull
362 */ 362 */
363bool Interfaces::removeAllInterfaceOptions(){ 363bool Interfaces::removeAllInterfaceOptions(){
364 return removeAllOptions(currentIface); 364 return removeAllOptions(currentIface);
365} 365}
366 366
367/** 367/**
368 * Set the current map to interface's map. This needs to be done before you 368 * Set the current map to interface's map. This needs to be done before you
369 * can call addMapping(), set/getMap(), and get/setScript(). 369 * can call addMapping(), set/getMap(), and get/setScript().
370 * @param interface the name of the interface to set. All whitespace is 370 * @param interface the name of the interface to set. All whitespace is
371 * removed from the interface name. 371 * removed from the interface name.
372 * @return bool true if it is successfull. 372 * @return bool true if it is successfull.
373 */ 373 */
374bool Interfaces::setMapping(QString interface){ 374bool Interfaces::setMapping(const QString &interface){
375 interface = interface.simplifyWhiteSpace(); 375 QString interfaceName = interface.simplifyWhiteSpace();
376 interface = interface.replace(QRegExp(" "), ""); 376 interfaceName = interfaceName.replace(QRegExp(" "), "");
377 return setStanza(MAPPING, interface, currentMapping); 377 return setStanza(MAPPING, interfaceName, currentMapping);
378} 378}
379 379
380/** 380/**
381 * Adds a new Mapping to the interfaces file with interfaces. 381 * Adds a new Mapping to the interfaces file with interfaces.
382 * @param interface the name(s) of the interfaces to set to this mapping 382 * @param interface the name(s) of the interfaces to set to this mapping
383 */ 383 */
384void Interfaces::addMapping(QString option){ 384void Interfaces::addMapping(const QString &option){
385 interfaces.append(""); 385 interfaces.append("");
386 interfaces.append(QString(MAPPING " %1").arg(option)); 386 interfaces.append(QString(MAPPING " %1").arg(option));
387} 387}
388 388
389/** 389/**
390 * Remove the currently selected map and all of its options. 390 * Remove the currently selected map and all of its options.
391 * @return bool if successfull or not. 391 * @return bool if successfull or not.
392 */ 392 */
393bool Interfaces::removeMapping(){ 393bool Interfaces::removeMapping(){
394 if(currentMapping == interfaces.end()) 394 if(currentMapping == interfaces.end())
395 return false; 395 return false;
396 (*currentMapping) = ""; 396 (*currentMapping) = "";
397 return removeAllOptions(currentMapping); 397 return removeAllOptions(currentMapping);
398} 398}
399 399
400/** 400/**
401 * Set a map option within a mapping. 401 * Set a map option within a mapping.
402 * @param map map to use 402 * @param map map to use
403 * @param value value to go with map 403 * @param value value to go with map
404 * @return bool true if it is successfull. 404 * @return bool true if it is successfull.
405 */ 405 */
406bool Interfaces::setMap(QString map, QString value){ 406bool Interfaces::setMap(const QString &map, const QString &value){
407 return setOption(currentMapping, map, value); 407 return setOption(currentMapping, map, value);
408} 408}
409 409
410/** 410/**
411 * Removes a map option within a mapping. 411 * Removes a map option within a mapping.
412 * @param map map to use 412 * @param map map to use
413 * @param value value to go with map 413 * @param value value to go with map
414 * @return bool true if it is successfull. 414 * @return bool true if it is successfull.
415 */ 415 */
416bool Interfaces::removeMap(QString map, QString value){ 416bool Interfaces::removeMap(const QString &map, const QString &value){
417 return removeOption(currentMapping, map, value); 417 return removeOption(currentMapping, map, value);
418} 418}
419 419
420/** 420/**
421 * Get a map value within a mapping. 421 * Get a map value within a mapping.
422 * @param map map to get value of 422 * @param map map to get value of
423 * @param bool true if it is successfull. 423 * @param bool true if it is successfull.
424 * @return value that goes to the map 424 * @return value that goes to the map
425 */ 425 */
426QString Interfaces::getMap(QString map, bool &error){ 426QString Interfaces::getMap(const QString &map, bool &error){
427 return getOption(currentMapping, map, error); 427 return getOption(currentMapping, map, error);
428} 428}
429 429
430/** 430/**
431 * Sets a script value of the current mapping to argument. 431 * Sets a script value of the current mapping to argument.
432 * @param argument the script name. 432 * @param argument the script name.
433 * @return true if successfull. 433 * @return true if successfull.
434 */ 434 */
435bool Interfaces::setScript(QString argument){ 435bool Interfaces::setScript(const QString &argument){
436 return setOption(currentMapping, "script", argument); 436 return setOption(currentMapping, "script", argument);
437} 437}
438 438
439/** 439/**
440 * @param error true if could not retrieve the current script argument. 440 * @param error true if could not retrieve the current script argument.
441 * @return QString the argument of the script for the current mapping. 441 * @return QString the argument of the script for the current mapping.
442 */ 442 */
443QString Interfaces::getScript(bool &error){ 443QString Interfaces::getScript(bool &error){
444 return getOption(currentMapping, "script", error); 444 return getOption(currentMapping, "script", error);
445} 445}
446 446
447
448
447/** 449/**
448 * Helper function used to parse through the QStringList and put pointers in 450 * Helper function used to parse through the QStringList and put pointers in
449 * the correct place. 451 * the correct place.
450 * @param stanza The stanza (auto, iface, mapping) to look for. 452 * @param stanza The stanza (auto, iface, mapping) to look for.
451 * @param option string that must be in the stanza's main line. 453 * @param option string that must be in the stanza's main line.
452 * @param interator interator to place at location of stanza if successfull. 454 * @param interator interator to place at location of stanza if successfull.
453 * @return bool true if the stanza is found. 455 * @return bool true if the stanza is found.
454 */ 456 */
455bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ 457bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
456 bool found = false; 458 bool found = false;
457 iterator = interfaces.end(); 459 iterator = interfaces.end();
458 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 460 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
459 QString line = (*it).simplifyWhiteSpace(); 461 QString line = (*it).simplifyWhiteSpace();
460 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ 462 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
461 uint point = line.find(option); 463 uint point = line.find(option);
462 bool valid = true; 464 bool valid = true;
463 if(point > 0){ 465 if(point > 0){
464 // There are more chars in the line. check +1 466 // There are more chars in the line. check +1
465 if(line.at(point-1) != ' ') 467 if(line.at(point-1) != ' ')
466 valid = false; 468 valid = false;
467 } 469 }
468 point += option.length(); 470 point += option.length();
469 if(point < line.length()-1){ 471 if(point < line.length()-1){
470 // There are more chars in the line. check -1 472 // There are more chars in the line. check -1
471 if(line.at(point) != ' ') 473 if(line.at(point) != ' ')
@@ -476,33 +478,33 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator
476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 478 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
477 } 479 }
478 found = true; 480 found = true;
479 iterator = it; 481 iterator = it;
480 } 482 }
481 } 483 }
482 } 484 }
483 return found; 485 return found;
484} 486}
485 487
486/** 488/**
487 * Sets a value of an option in a stanza 489 * Sets a value of an option in a stanza
488 * @param start the start of the stanza 490 * @param start the start of the stanza
489 * @param option the option to use when setting value. 491 * @param option the option to use when setting value.
490 * @return bool true if successfull, false otherwise. 492 * @return bool true if successfull, false otherwise.
491 */ 493 */
492bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ 494bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
493 if(start == interfaces.end()) 495 if(start == interfaces.end())
494 return false; 496 return false;
495 497
496 bool found = false; 498 bool found = false;
497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 499 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 500 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
499 if(!found && value != ""){ 501 if(!found && value != ""){
500 // Got to the end of the stanza without finding it, so append it. 502 // Got to the end of the stanza without finding it, so append it.
501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 503 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
502 } 504 }
503 found = true; 505 found = true;
504 break; 506 break;
505 } 507 }
506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 508 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
507 // Found it in stanza so replace it. 509 // Found it in stanza so replace it.
508 if(found) 510 if(found)
@@ -511,84 +513,84 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString
511 (*it) = QString("\t%1 %2").arg(option).arg(value); 513 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 } 514 }
513 } 515 }
514 if(!found){ 516 if(!found){
515 QStringList::Iterator p = start; 517 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 518 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true; 519 found = true;
518 } 520 }
519 return found; 521 return found;
520} 522}
521/** 523/**
522 * Removes a option in a stanza 524 * Removes a option in a stanza
523 * @param start the start of the stanza 525 * @param start the start of the stanza
524 * @param option the option to use when setting value. 526 * @param option the option to use when setting value.
525 * @return bool true if successfull, false otherwise. 527 * @return bool true if successfull, false otherwise.
526 */ 528 */
527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ 529bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
528 if(start == interfaces.end()) 530 if(start == interfaces.end())
529 return false; 531 return false;
530 532
531 bool found = false; 533 bool found = false;
532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 534 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 535 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
534 // got to the end without finding it 536 // got to the end without finding it
535 break; 537 break;
536 } 538 }
537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ 539 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
538 // Found it in stanza so replace it. 540 // Found it in stanza so replace it.
539 if(found) 541 if(found)
540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 542 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
541 found = true; 543 found = true;
542 (*it) = ""; 544 (*it) = "";
543 } 545 }
544 } 546 }
545 return found; 547 return found;
546} 548}
547 549
548/** 550/**
549 * Removes all options in a stanza 551 * Removes all options in a stanza
550 * @param start the start of the stanza 552 * @param start the start of the stanza
551 * @return bool true if successfull, false otherwise. 553 * @return bool true if successfull, false otherwise.
552 */ 554 */
553bool Interfaces::removeAllOptions(QStringList::Iterator start){ 555bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
554 if(start == interfaces.end()) 556 if(start == interfaces.end())
555 return false; 557 return false;
556 558
557 QStringList::Iterator it = start; 559 QStringList::Iterator it = start;
558 it = ++it; 560 it = ++it;
559 for (; it != interfaces.end(); ++it ) { 561 for (; it != interfaces.end(); ++it ) {
560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 562 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
561 break; 563 break;
562 } 564 }
563 it = interfaces.remove(it); 565 it = interfaces.remove(it);
564 it = --it; 566 it = --it;
565 } 567 }
566 // Leave a space between this interface and the next. 568 // Leave a space between this interface and the next.
567 interfaces.insert(it, QString("")); 569 interfaces.insert(it, QString(""));
568 return true; 570 return true;
569} 571}
570 572
571/** 573/**
572 * Gets a value of an option in a stanza 574 * Gets a value of an option in a stanza
573 * @param start the start of the stanza 575 * @param start the start of the stanza
574 * @param option the option to use when getting the value. 576 * @param option the option to use when getting the value.
575 * @param bool true if errors false otherwise. 577 * @param bool true if errors false otherwise.
576 * @return QString the value of option QString::null() if error == true. 578 * @return QString the value of option QString::null() if error == true.
577 */ 579 */
578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ 580QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){
579 if(start == interfaces.end()){ 581 if(start == interfaces.end()){
580 error = false; 582 error = false;
581 return QString(); 583 return QString();
582 } 584 }
583 585
584 QString value; 586 QString value;
585 bool found = false; 587 bool found = false;
586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 588 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 589 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
588 break; 590 break;
589 } 591 }
590 if((*it).contains(option) && (*it).at(0) != '#'){ 592 if((*it).contains(option) && (*it).at(0) != '#'){
591 if(found) 593 if(found)
592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); 594 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
593 found = true; 595 found = true;
594 QString line = (*it).simplifyWhiteSpace(); 596 QString line = (*it).simplifyWhiteSpace();
diff --git a/noncore/net/networksetup/interfaces/interfaces.h b/noncore/net/networksetup/interfaces/interfaces.h
index e09ea71..26abb73 100644
--- a/noncore/net/networksetup/interfaces/interfaces.h
+++ b/noncore/net/networksetup/interfaces/interfaces.h
@@ -12,65 +12,65 @@
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 QStringList getInterfaceList(); 26 QStringList getInterfaceList();
27 27
28 bool isAuto(QString interface); 28 bool isAuto(const QString &interface);
29 bool setAuto(QString interface, bool setAuto); 29 bool setAuto(const QString &interface, bool setAuto);
30 30
31 bool removeInterface(); 31 bool removeInterface();
32 bool addInterface(QString interface, QString family, QString method); 32 bool addInterface(const QString &interface, const QString &family, const QString &method);
33 bool copyInterface(QString oldInterface, QString newInterface); 33 bool copyInterface(const QString &oldInterface, const QString &newInterface);
34 bool setInterface(QString interface); 34 bool setInterface(QString interface);
35 bool isInterfaceSet(); 35 inline bool isInterfaceSet();
36 QString getInterfaceName(bool &error); 36 QString getInterfaceName(bool &error);
37 bool setInterfaceName(QString newName); 37 bool setInterfaceName(const QString &newName);
38 QString getInterfaceFamily(bool &error); 38 QString getInterfaceFamily(bool &error);
39 bool setInterfaceFamily(QString newName); 39 bool setInterfaceFamily(const QString &newName);
40 QString getInterfaceMethod(bool &error); 40 QString getInterfaceMethod(bool &error);
41 bool setInterfaceMethod(QString newName); 41 bool setInterfaceMethod(const QString &newName);
42 QString getInterfaceOption(QString option, bool &error); 42 inline QString getInterfaceOption(const QString &option, bool &error);
43 bool setInterfaceOption(QString option, QString value); 43 inline bool setInterfaceOption(const QString &option, const QString &value);
44 bool removeInterfaceOption(QString option, QString value); 44 inline bool removeInterfaceOption(const QString &option, const QString &value);
45 bool removeAllInterfaceOptions(); 45 inline bool removeAllInterfaceOptions();
46 46
47 bool setMapping(QString interface); 47 bool setMapping(const QString &interface);
48 bool removeMapping(); 48 bool removeMapping();
49 void addMapping(QString options); 49 inline void addMapping(const QString &options);
50 bool setMap(QString map, QString value); 50 inline bool setMap(const QString &map, const QString &value);
51 bool removeMap(QString map, QString value); 51 inline bool removeMap(const QString &map, const QString &value);
52 QString getMap(QString map, bool &error); 52 inline QString getMap(const QString &map, bool &error);
53 bool setScript(QString); 53 inline bool setScript(const QString &argument);
54 QString getScript(bool &error); 54 inline QString getScript(bool &error);
55 55
56 bool write(); 56 bool write();
57 57
58private: 58private:
59 bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); 59 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
60 bool setOption(QStringList::Iterator start, QString option, QString value); 60 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
61 bool removeOption(QStringList::Iterator start, QString option, QString value); 61 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
62 QString getOption(QStringList::Iterator start, QString option, bool &error); 62 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
63 bool removeAllOptions(QStringList::Iterator start); 63 bool removeAllOptions(const QStringList::Iterator &start);
64 64
65 QString interfacesFile; 65 QString interfacesFile;
66 QStringList interfaces; 66 QStringList interfaces;
67 QStringList::Iterator currentIface; 67 QStringList::Iterator currentIface;
68 QStringList::Iterator currentMapping; 68 QStringList::Iterator currentMapping;
69 69
70 QStringList acceptedFamily; 70 QStringList acceptedFamily;
71}; 71};
72 72
73#endif 73#endif
74 74
75// interfaces 75// interfaces
76 76
diff --git a/noncore/net/networksetup/interfaces/interfacesetup.ui b/noncore/net/networksetup/interfaces/interfacesetup.ui
index ab8e413..df55d25 100644
--- a/noncore/net/networksetup/interfaces/interfacesetup.ui
+++ b/noncore/net/networksetup/interfaces/interfacesetup.ui
@@ -86,32 +86,36 @@
86 <name>name</name> 86 <name>name</name>
87 <cstring>leaseTime</cstring> 87 <cstring>leaseTime</cstring>
88 </property> 88 </property>
89 <property stdset="1"> 89 <property stdset="1">
90 <name>suffix</name> 90 <name>suffix</name>
91 <string> hours</string> 91 <string> hours</string>
92 </property> 92 </property>
93 <property stdset="1"> 93 <property stdset="1">
94 <name>maxValue</name> 94 <name>maxValue</name>
95 <number>87600</number> 95 <number>87600</number>
96 </property> 96 </property>
97 <property stdset="1"> 97 <property stdset="1">
98 <name>minValue</name> 98 <name>minValue</name>
99 <number>1</number> 99 <number>1</number>
100 </property> 100 </property>
101 <property stdset="1"> 101 <property stdset="1">
102 <name>lineStep</name>
103 <number>24</number>
104 </property>
105 <property stdset="1">
102 <name>value</name> 106 <name>value</name>
103 <number>168</number> 107 <number>168</number>
104 </property> 108 </property>
105 </widget> 109 </widget>
106 </hbox> 110 </hbox>
107 </widget> 111 </widget>
108 <widget> 112 <widget>
109 <class>QGroupBox</class> 113 <class>QGroupBox</class>
110 <property stdset="1"> 114 <property stdset="1">
111 <name>name</name> 115 <name>name</name>
112 <cstring>staticGroupBox</cstring> 116 <cstring>staticGroupBox</cstring>
113 </property> 117 </property>
114 <property stdset="1"> 118 <property stdset="1">
115 <name>enabled</name> 119 <name>enabled</name>
116 <bool>false</bool> 120 <bool>false</bool>
117 </property> 121 </property>
@@ -238,32 +242,54 @@
238 <enum>Vertical</enum> 242 <enum>Vertical</enum>
239 </property> 243 </property>
240 <property stdset="1"> 244 <property stdset="1">
241 <name>sizeType</name> 245 <name>sizeType</name>
242 <enum>Expanding</enum> 246 <enum>Expanding</enum>
243 </property> 247 </property>
244 <property> 248 <property>
245 <name>sizeHint</name> 249 <name>sizeHint</name>
246 <size> 250 <size>
247 <width>20</width> 251 <width>20</width>
248 <height>20</height> 252 <height>20</height>
249 </size> 253 </size>
250 </property> 254 </property>
251 </spacer> 255 </spacer>
252 </vbox> 256 </vbox>
253</widget> 257</widget>
258<customwidgets>
259 <customwidget>
260 <class>QWidget</class>
261 <header location="local">qwidget.h</header>
262 <sizehint>
263 <width>100</width>
264 <height>100</height>
265 </sizehint>
266 <container>0</container>
267 <sizepolicy>
268 <hordata>7</hordata>
269 <verdata>7</verdata>
270 </sizepolicy>
271 <pixmap>image0</pixmap>
272 </customwidget>
273</customwidgets>
274<images>
275 <image>
276 <name>image0</name>
277 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
278 </image>
279</images>
254<connections> 280<connections>
255 <connection> 281 <connection>
256 <sender>dhcpCheckBox</sender> 282 <sender>dhcpCheckBox</sender>
257 <signal>toggled(bool)</signal> 283 <signal>toggled(bool)</signal>
258 <receiver>leaseHoursLabel</receiver> 284 <receiver>leaseHoursLabel</receiver>
259 <slot>setEnabled(bool)</slot> 285 <slot>setEnabled(bool)</slot>
260 </connection> 286 </connection>
261 <connection> 287 <connection>
262 <sender>dhcpCheckBox</sender> 288 <sender>dhcpCheckBox</sender>
263 <signal>toggled(bool)</signal> 289 <signal>toggled(bool)</signal>
264 <receiver>leaseTime</receiver> 290 <receiver>leaseTime</receiver>
265 <slot>setEnabled(bool)</slot> 291 <slot>setEnabled(bool)</slot>
266 </connection> 292 </connection>
267 <connection> 293 <connection>
268 <sender>dhcpCheckBox</sender> 294 <sender>dhcpCheckBox</sender>
269 <signal>toggled(bool)</signal> 295 <signal>toggled(bool)</signal>
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.h b/noncore/net/networksetup/interfaces/interfacesetupimp.h
index a88e190..60933aa 100644
--- a/noncore/net/networksetup/interfaces/interfacesetupimp.h
+++ b/noncore/net/networksetup/interfaces/interfacesetupimp.h
@@ -8,33 +8,32 @@ class Interface;
8class Interfaces; 8class Interfaces;
9 9
10class InterfaceSetupImp : public InterfaceSetup { 10class InterfaceSetupImp : public InterfaceSetup {
11 Q_OBJECT 11 Q_OBJECT
12 12
13public: 13public:
14 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); 14 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0);
15 bool saveChanges(); 15 bool saveChanges();
16 16
17public slots: 17public slots:
18 void setProfile(const QString &profile); 18 void setProfile(const QString &profile);
19 bool saveSettings(); 19 bool saveSettings();
20 20
21private: 21private:
22 Interfaces *interfaces; 22 Interfaces *interfaces;
23 Interface *interface; 23 Interface *interface;
24
25}; 24};
26 25
27 26
28#include <qlayout.h> 27#include <qlayout.h>
29 28
30class InterfaceSetupImpDialog : public QDialog { 29class InterfaceSetupImpDialog : public QDialog {
31Q_OBJECT 30Q_OBJECT
32 31
33public: 32public:
34 InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ 33 InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){
35 QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); 34 QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this );
36 setCaption("Interface Setup"); 35 setCaption("Interface Setup");
37 interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); 36 interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl);
38 InterfaceSetupLayout->addWidget( interfaceSetup ); 37 InterfaceSetupLayout->addWidget( interfaceSetup );
39 }; 38 };
40 void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; 39 void setProfile(QString &profile){ interfaceSetup->setProfile(profile);};
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 48ef9b3..7b93554 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -17,33 +17,33 @@
17 17
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/qlibrary.h> 19#include <qpe/qlibrary.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22 22
23#include <qlist.h> 23#include <qlist.h>
24#include <qdir.h> 24#include <qdir.h>
25#include <qfile.h> 25#include <qfile.h>
26#include <qtextstream.h> 26#include <qtextstream.h>
27 27
28#include <net/if.h> 28#include <net/if.h>
29#include <sys/ioctl.h> 29#include <sys/ioctl.h>
30 30
31#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 31#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
32 32
33MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 33MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false), scheme(DEFAULT_SCHEME){
34 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 34 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
35 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 35 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
36 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 36 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
37 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 37 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
38 38
39 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 39 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
40 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 40 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
41 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 41 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
42 42
43 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 43 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
44 // Load connections. 44 // Load connections.
45 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 45 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
46 getAllInterfaces(); 46 getAllInterfaces();
47 47
48 Interfaces i; 48 Interfaces i;
49 QStringList list = i.getInterfaceList(); 49 QStringList list = i.getInterfaceList();
@@ -176,58 +176,58 @@ void MainWindowImp::getAllInterfaces(){
176 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 176 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
177 break; 177 break;
178 178
179 default: 179 default:
180 qDebug(ifr->ifr_name); 180 qDebug(ifr->ifr_name);
181 qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1()); 181 qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1());
182 break; 182 break;
183 } 183 }
184 } 184 }
185} 185}
186 186
187/** 187/**
188 * Load all modules that are found in the path 188 * Load all modules that are found in the path
189 * @param path a directory that is scaned for any plugins that can be loaded 189 * @param path a directory that is scaned for any plugins that can be loaded
190 * and attempts to load them 190 * and attempts to load them
191 */ 191 */
192void MainWindowImp::loadModules(QString path){ 192void MainWindowImp::loadModules(const QString &path){
193 //qDebug(path.latin1()); 193 //qDebug(path.latin1());
194 QDir d(path); 194 QDir d(path);
195 if(!d.exists()) 195 if(!d.exists())
196 return; 196 return;
197 197
198 // Don't want sym links 198 // Don't want sym links
199 d.setFilter( QDir::Files | QDir::NoSymLinks ); 199 d.setFilter( QDir::Files | QDir::NoSymLinks );
200 const QFileInfoList *list = d.entryInfoList(); 200 const QFileInfoList *list = d.entryInfoList();
201 QFileInfoListIterator it( *list ); 201 QFileInfoListIterator it( *list );
202 QFileInfo *fi; 202 QFileInfo *fi;
203 while ( (fi=it.current()) ) { 203 while ( (fi=it.current()) ) {
204 if(fi->fileName().contains(".so")){ 204 if(fi->fileName().contains(".so")){
205 loadPlugin(path + "/" + fi->fileName()); 205 loadPlugin(path + "/" + fi->fileName());
206 } 206 }
207 ++it; 207 ++it;
208 } 208 }
209} 209}
210 210
211/** 211/**
212 * Attempt to load a function and resolve a function. 212 * Attempt to load a function and resolve a function.
213 * @param pluginFileName - the name of the file in which to attempt to load 213 * @param pluginFileName - the name of the file in which to attempt to load
214 * @param resolveString - function pointer to resolve 214 * @param resolveString - function pointer to resolve
215 * @return pointer to the function with name resolveString or NULL 215 * @return pointer to the function with name resolveString or NULL
216 */ 216 */
217Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 217Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
218 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 218 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
219 QLibrary *lib = new QLibrary(pluginFileName); 219 QLibrary *lib = new QLibrary(pluginFileName);
220 void *functionPointer = lib->resolve(resolveString); 220 void *functionPointer = lib->resolve(resolveString);
221 if( !functionPointer ){ 221 if( !functionPointer ){
222 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 222 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
223 delete lib; 223 delete lib;
224 return NULL; 224 return NULL;
225 } 225 }
226 226
227 // Try to get an object. 227 // Try to get an object.
228 Module *object = ((Module* (*)()) functionPointer)(); 228 Module *object = ((Module* (*)()) functionPointer)();
229 if(object == NULL){ 229 if(object == NULL){
230 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 230 qDebug("MainWindowImp: Couldn't create object, but did load library!");
231 delete lib; 231 delete lib;
232 return NULL; 232 return NULL;
233 } 233 }
diff --git a/noncore/net/networksetup/mainwindowimp.h b/noncore/net/networksetup/mainwindowimp.h
index 382428c..4f09d6c 100644
--- a/noncore/net/networksetup/mainwindowimp.h
+++ b/noncore/net/networksetup/mainwindowimp.h
@@ -20,36 +20,36 @@ public:
20private slots: 20private slots:
21 void getAllInterfaces(); 21 void getAllInterfaces();
22 22
23 void addClicked(); 23 void addClicked();
24 void removeClicked(); 24 void removeClicked();
25 void configureClicked(); 25 void configureClicked();
26 void informationClicked(); 26 void informationClicked();
27 27
28 void addProfile(); 28 void addProfile();
29 void removeProfile(); 29 void removeProfile();
30 void changeProfile(); 30 void changeProfile();
31 31
32 void updateInterface(Interface *i); 32 void updateInterface(Interface *i);
33 void newProfileChanged(const QString& newText); 33 void newProfileChanged(const QString& newText);
34 34
35private: 35private:
36 void loadModules(QString path); 36 void loadModules(const QString &path);
37 37
38 Module* loadPlugin(QString pluginFileName, 38 Module* loadPlugin(const QString &pluginFileName,
39 QString resolveString = "create_plugin"); 39 const QString &resolveString = "create_plugin");
40 40
41 // For our local list of names 41 // For our local list of names
42 QMap<QString, Interface*> interfaceNames; 42 QMap<QString, Interface*> interfaceNames;
43 43
44 QMap<Module*, QLibrary*> libraries; 44 QMap<Module*, QLibrary*> libraries;
45 QMap<Interface*, QListViewItem*> items; 45 QMap<Interface*, QListViewItem*> items;
46 QMap<QListViewItem*, Interface*> interfaceItems; 46 QMap<QListViewItem*, Interface*> interfaceItems;
47 47
48 QMap<KProcess*, QString> threads; 48 QMap<KProcess*, QString> threads;
49 QStringList profiles; 49 QStringList profiles;
50 50
51 bool advancedUserMode; 51 bool advancedUserMode;
52 QString scheme; 52 QString scheme;
53}; 53};
54 54
55#endif 55#endif
diff --git a/noncore/net/networksetup/module.h b/noncore/net/networksetup/module.h
index 92b125a..2e6272b 100644
--- a/noncore/net/networksetup/module.h
+++ b/noncore/net/networksetup/module.h
@@ -9,33 +9,33 @@
9class QWidget; 9class QWidget;
10class QTabWidget; 10class QTabWidget;
11 11
12class Module : QObject{ 12class Module : QObject{
13 13
14signals: 14signals:
15 void updateInterface(Interface *i); 15 void updateInterface(Interface *i);
16 16
17public: 17public:
18 Module(){}; 18 Module(){};
19 19
20 /** 20 /**
21 * The current profile has been changed and the module should do any 21 * The current profile has been changed and the module should do any
22 * neccesary changes also. 22 * neccesary changes also.
23 * @param newProfile what the profile should be changed to. 23 * @param newProfile what the profile should be changed to.
24 */ 24 */
25 virtual void setProfile(QString newProfile) = 0; 25 virtual void setProfile(const QString &newProfile) = 0;
26 26
27 /** 27 /**
28 * get the icon name for this device. 28 * get the icon name for this device.
29 * @param Interface* can be used in determining the icon. 29 * @param Interface* can be used in determining the icon.
30 * @return QString the icon name (minus .png, .gif etc) 30 * @return QString the icon name (minus .png, .gif etc)
31 */ 31 */
32 virtual QString getPixmapName(Interface *) = 0; 32 virtual QString getPixmapName(Interface *) = 0;
33 33
34 /** 34 /**
35 * Check to see if the interface i is owned by this module. 35 * Check to see if the interface i is owned by this module.
36 * @param Interface* interface to check against 36 * @param Interface* interface to check against
37 * @return bool true if i is owned by this module, false otherwise. 37 * @return bool true if i is owned by this module, false otherwise.
38 */ 38 */
39 virtual bool isOwner(Interface *){ return false; }; 39 virtual bool isOwner(Interface *){ return false; };
40 40
41 /** 41 /**
@@ -57,30 +57,30 @@ public:
57 * @return QList<Interface> A list of interfaces that exsist that havn't 57 * @return QList<Interface> A list of interfaces that exsist that havn't
58 * been called by isOwner() 58 * been called by isOwner()
59 */ 59 */
60 virtual QList<Interface> getInterfaces() = 0; 60 virtual QList<Interface> getInterfaces() = 0;
61 61
62 /** 62 /**
63 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), 63 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
64 * modem ppp) 64 * modem ppp)
65 */ 65 */
66 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; 66 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
67 67
68 /** 68 /**
69 * Attempts to create a new interface from name 69 * Attempts to create a new interface from name
70 * @return Interface* NULL if it was unable to be created. 70 * @return Interface* NULL if it was unable to be created.
71 * @param name the type of interface to create 71 * @param name the type of interface to create
72 */ 72 */
73 virtual Interface *addNewInterface(QString name) = 0; 73 virtual Interface *addNewInterface(const QString &name) = 0;
74 74
75 /** 75 /**
76 * Attempts to remove the interface, doesn't delete i 76 * Attempts to remove the interface, doesn't delete i
77 * @return bool true if successfull, false otherwise. 77 * @return bool true if successfull, false otherwise.
78 */ 78 */
79 virtual bool remove(Interface* i) = 0; 79 virtual bool remove(Interface* i) = 0;
80 80
81}; 81};
82 82
83#endif 83#endif
84 84
85// module.h 85// module.h
86 86
diff --git a/noncore/net/networksetup/wlan/infoimp.h b/noncore/net/networksetup/wlan/infoimp.h
index 5311bea..8f7f0d6 100644
--- a/noncore/net/networksetup/wlan/infoimp.h
+++ b/noncore/net/networksetup/wlan/infoimp.h
@@ -1,23 +1,23 @@
1#ifndef INFOIMP_H 1#ifndef INFOIMP_H
2#define INFOIMP_H 2#define INFOIMP_H
3 3
4#include "info.h" 4#include "info.h"
5 5
6class QTimer; 6class QTimer;
7class WExtensions; 7//class WExtensions;
8 8
9class WlanInfoImp : public WlanInfo { 9class WlanInfoImp : public WlanInfo {
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 WlanInfoImp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 13 WlanInfoImp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
14 14
15private slots: 15private slots:
16 void update(); 16 void update();
17 17
18private: 18private:
19 //WExtensions *wExtensions; 19 //WExtensions *wExtensions;
20 QTimer *timer; 20 QTimer *timer;
21 21
22}; 22};
23 23
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp
index eb6fc42..6335ebc 100644
--- a/noncore/net/networksetup/wlan/wextensions.cpp
+++ b/noncore/net/networksetup/wlan/wextensions.cpp
@@ -3,34 +3,33 @@
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5 5
6#include <arpa/inet.h> 6#include <arpa/inet.h>
7#include <sys/socket.h> 7#include <sys/socket.h>
8#include <sys/ioctl.h> 8#include <sys/ioctl.h>
9 9
10#include <math.h> 10#include <math.h>
11 11
12#define PROCNETWIRELESS "/proc/net/wireless" 12#define PROCNETWIRELESS "/proc/net/wireless"
13#define IW_LOWER 0 13#define IW_LOWER 0
14#define IW_UPPER 256 14#define IW_UPPER 256
15 15
16/** 16/**
17 * Constructor. Sets hasWirelessExtensions 17 * Constructor. Sets hasWirelessExtensions
18 */ 18 */
19WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){ 19WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) {
20 interface = interfaceName;
21 fd = socket( AF_INET, SOCK_DGRAM, 0 ); 20 fd = socket( AF_INET, SOCK_DGRAM, 0 );
22 if(fd == -1) 21 if(fd == -1)
23 return; 22 return;
24 23
25 const char* buffer[200]; 24 const char* buffer[200];
26 memset( &iwr, 0, sizeof( iwr ) ); 25 memset( &iwr, 0, sizeof( iwr ) );
27 iwr.u.essid.pointer = (caddr_t) buffer; 26 iwr.u.essid.pointer = (caddr_t) buffer;
28 iwr.u.essid.length = IW_ESSID_MAX_SIZE; 27 iwr.u.essid.length = IW_ESSID_MAX_SIZE;
29 iwr.u.essid.flags = 0; 28 iwr.u.essid.flags = 0;
30 29
31 // check if it is an IEEE 802.11 standard conform 30 // check if it is an IEEE 802.11 standard conform
32 // wireless device by sending SIOCGIWESSID 31 // wireless device by sending SIOCGIWESSID
33 // which also gives back the Extended Service Set ID 32 // which also gives back the Extended Service Set ID
34 // (see IEEE 802.11 for more information) 33 // (see IEEE 802.11 for more information)
35 34
36 const char* iname = interface.latin1(); 35 const char* iname = interface.latin1();
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp
index 689eae2..d4b4af9 100644
--- a/noncore/net/networksetup/wlan/wlanimp.cpp
+++ b/noncore/net/networksetup/wlan/wlanimp.cpp
@@ -31,33 +31,33 @@ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, W
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 settingsFileText = QStringList::split("\n", line, true); 37 settingsFileText = QStringList::split("\n", line, true);
38 parseSettingFile(); 38 parseSettingFile();
39 } 39 }
40 else 40 else
41 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); 41 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1());
42} 42}
43 43
44/** 44/**
45 * Change the profile for both wireless settings and network settings. 45 * Change the profile for both wireless settings and network settings.
46 */ 46 */
47void WLANImp::setProfile(QString &profile){ 47void WLANImp::setProfile(const QString &profile){
48 interfaceSetup->setProfile(profile); 48 interfaceSetup->setProfile(profile);
49 parseSettingFile(); 49 parseSettingFile();
50} 50}
51 51
52/** 52/**
53 * Parses the settings file that was read in and gets any setting from it. 53 * Parses the settings file that was read in and gets any setting from it.
54 */ 54 */
55void WLANImp::parseSettingFile(){ 55void WLANImp::parseSettingFile(){
56 bool foundCase = false; 56 bool foundCase = false;
57 bool found = false; 57 bool found = false;
58 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 58 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
59 QString line = (*it).simplifyWhiteSpace(); 59 QString line = (*it).simplifyWhiteSpace();
60 if(line.contains("case")) 60 if(line.contains("case"))
61 foundCase = true; 61 foundCase = true;
62 // See if we found our scheme to write or the sceme couldn't be found 62 // See if we found our scheme to write or the sceme couldn't be found
63 if((foundCase && line.contains("esac")) || 63 if((foundCase && line.contains("esac")) ||
diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h
index f88e550..df599af 100644
--- a/noncore/net/networksetup/wlan/wlanimp.h
+++ b/noncore/net/networksetup/wlan/wlanimp.h
@@ -1,31 +1,31 @@
1#ifndef WLANIMP_H 1#ifndef WLANIMP_H
2#define WLANIMP_H 2#define WLANIMP_H
3 3
4#include "wlan.h" 4#include "wlan.h"
5#include <qstringlist.h> 5#include <qstringlist.h>
6 6
7class InterfaceSetupImp; 7class InterfaceSetupImp;
8class Interface; 8class Interface;
9class Config; 9class Config;
10 10
11class WLANImp : public WLAN { 11class WLANImp : public WLAN {
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); 15 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
16 void setProfile(QString &profile); 16 void setProfile(const QString &profile);
17 17
18protected: 18protected:
19 void accept(); 19 void accept();
20 20
21private: 21private:
22 void parseSettingFile(); 22 void parseSettingFile();
23 void changeAndSaveSettingFile(); 23 void changeAndSaveSettingFile();
24 24
25 InterfaceSetupImp *interfaceSetup; 25 InterfaceSetupImp *interfaceSetup;
26 QStringList settingsFileText; 26 QStringList settingsFileText;
27 QString currentProfile; 27 QString currentProfile;
28}; 28};
29 29
30#endif 30#endif
31 31
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index b14fc0a..3979e60 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -13,33 +13,33 @@
13 */ 13 */
14WLANModule::WLANModule() : Module() { 14WLANModule::WLANModule() : Module() {
15} 15}
16 16
17/** 17/**
18 * Delete any interfaces that we own. 18 * Delete any interfaces that we own.
19 */ 19 */
20WLANModule::~WLANModule(){ 20WLANModule::~WLANModule(){
21 Interface *i; 21 Interface *i;
22 for ( i=list.first(); i != 0; i=list.next() ) 22 for ( i=list.first(); i != 0; i=list.next() )
23 delete i; 23 delete i;
24} 24}
25 25
26/** 26/**
27 * Change the current profile 27 * Change the current profile
28 */ 28 */
29void WLANModule::setProfile(QString newProfile){ 29void WLANModule::setProfile(const QString &newProfile){
30 profile = newProfile; 30 profile = newProfile;
31} 31}
32 32
33/** 33/**
34 * get the icon name for this device. 34 * get the icon name for this device.
35 * @param Interface* can be used in determining the icon. 35 * @param Interface* can be used in determining the icon.
36 * @return QString the icon name (minus .png, .gif etc) 36 * @return QString the icon name (minus .png, .gif etc)
37 */ 37 */
38QString WLANModule::getPixmapName(Interface* ){ 38QString WLANModule::getPixmapName(Interface* ){
39 return "wlan"; 39 return "wlan";
40} 40}
41 41
42/** 42/**
43 * Check to see if the interface i is owned by this module. 43 * Check to see if the interface i is owned by this module.
44 * @param Interface* interface to check against 44 * @param Interface* interface to check against
45 * @return bool true if i is owned by this module, false otherwise. 45 * @return bool true if i is owned by this module, false otherwise.
@@ -81,33 +81,33 @@ QWidget *WLANModule::information(Interface *i){
81 81
82/** 82/**
83 * Get all active (up or down) interfaces 83 * Get all active (up or down) interfaces
84 * @return QList<Interface> A list of interfaces that exsist that havn't 84 * @return QList<Interface> A list of interfaces that exsist that havn't
85 * been called by isOwner() 85 * been called by isOwner()
86 */ 86 */
87QList<Interface> WLANModule::getInterfaces(){ 87QList<Interface> WLANModule::getInterfaces(){
88 return list; 88 return list;
89} 89}
90 90
91/** 91/**
92 * Attempt to add a new interface as defined by name 92 * Attempt to add a new interface as defined by name
93 * @param name the name of the type of interface that should be created given 93 * @param name the name of the type of interface that should be created given
94 * by possibleNewInterfaces(); 94 * by possibleNewInterfaces();
95 * @return Interface* NULL if it was unable to be created. 95 * @return Interface* NULL if it was unable to be created.
96 */ 96 */
97Interface *WLANModule::addNewInterface(QString ){ 97Interface *WLANModule::addNewInterface(const QString &){
98 // We can't add a 802.11 interface, either the hardware will be there 98 // We can't add a 802.11 interface, either the hardware will be there
99 // or it wont. 99 // or it wont.
100 return NULL; 100 return NULL;
101} 101}
102 102
103/** 103/**
104 * Attempts to remove the interface, doesn't delete i 104 * Attempts to remove the interface, doesn't delete i
105 * @return bool true if successfull, false otherwise. 105 * @return bool true if successfull, false otherwise.
106 */ 106 */
107bool WLANModule::remove(Interface*){ 107bool WLANModule::remove(Interface*){
108 // Can't remove a hardware device, you can stop it though. 108 // Can't remove a hardware device, you can stop it though.
109 return false; 109 return false;
110} 110}
111 111
112// wlanmodule.cpp 112// wlanmodule.cpp
113 113
diff --git a/noncore/net/networksetup/wlan/wlanmodule.h b/noncore/net/networksetup/wlan/wlanmodule.h
index a81ccff..3a54de6 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.h
+++ b/noncore/net/networksetup/wlan/wlanmodule.h
@@ -1,39 +1,39 @@
1#ifndef WLAN_MODULE_H 1#ifndef WLAN_MODULE_H
2#define WLAN_MODULE_H 2#define WLAN_MODULE_H
3 3
4#include "module.h" 4#include "module.h"
5 5
6class WLANModule : Module{ 6class WLANModule : Module{
7 7
8signals: 8signals:
9 void updateInterface(Interface *i); 9 void updateInterface(Interface *i);
10 10
11public: 11public:
12 WLANModule(); 12 WLANModule();
13 ~WLANModule(); 13 ~WLANModule();
14 14
15 virtual void setProfile(QString newProfile); 15 void setProfile(const QString &newProfile);
16 virtual bool isOwner(Interface *); 16 bool isOwner(Interface *);
17 virtual QWidget *configure(Interface *i); 17 QWidget *configure(Interface *i);
18 virtual QWidget *information(Interface *i); 18 QWidget *information(Interface *i);
19 virtual QList<Interface> getInterfaces(); 19 QList<Interface> getInterfaces();
20 virtual void possibleNewInterfaces(QMap<QString, QString> &){}; 20 void possibleNewInterfaces(QMap<QString, QString> &){};
21 virtual Interface *addNewInterface(QString name); 21 Interface *addNewInterface(const QString &name);
22 virtual bool remove(Interface* i); 22 bool remove(Interface* i);
23 virtual QString getPixmapName(Interface* i); 23 QString getPixmapName(Interface* i);
24 24
25private: 25private:
26 QList<Interface> list; 26 QList<Interface> list;
27 QString profile; 27 QString profile;
28 28
29}; 29};
30 30
31extern "C" 31extern "C"
32{ 32{
33 void* create_plugin() { 33 void* create_plugin() {
34 return new WLANModule(); 34 return new WLANModule();
35 } 35 }
36}; 36};
37 37
38#endif 38#endif
39 39
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index 8e57405..7185dbe 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,14 +1,13 @@
1CLEAN UP 1CLEAN UP
2 2
3Write a class that parses /proc and not ifconfig
4
5udchcp needs to output the dhcp information so interfaces can read it 3udchcp needs to output the dhcp information so interfaces can read it
6 4
7interfacesetupimp really doesn't need a interface* pointer 5interfacesetupimp really doesn't need a interface* pointer
8 6
9Possible other modules to write: ppp, ipsec, bluetooth, ipchains 7Possible other modules to write: ppp, ipsec, bluetooth, ipchains
10 8
11PPP module needs to scan pppd.tdb to see what is currently active 9PPP module needs to scan pppd.tdb to see what is currently active
12 10
13WLAN - add possiblity to input text or hex without knowing "s:" 11WLAN - add possiblity to input text or hex without knowing "s:"
14 12
13Interface setupimp needs to use kernel calls.
diff --git a/noncore/settings/networksettings/addconnectionimp.cpp b/noncore/settings/networksettings/addconnectionimp.cpp
index 53db0fc..07545f7 100644
--- a/noncore/settings/networksettings/addconnectionimp.cpp
+++ b/noncore/settings/networksettings/addconnectionimp.cpp
@@ -4,35 +4,34 @@
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qheader.h> 5#include <qheader.h>
6 6
7/** 7/**
8 * Constructor 8 * Constructor
9 */ 9 */
10AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){ 10AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){
11 connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed())); 11 connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed()));
12 registeredServicesList->header()->hide(); 12 registeredServicesList->header()->hide();
13}; 13};
14 14
15/** 15/**
16 * The current item changed, update the discription. 16 * The current item changed, update the discription.
17 */ 17 */
18void AddConnectionImp::changed(){ 18void AddConnectionImp::changed(){
19 QListViewItem *item = registeredServicesList->currentItem(); 19 QListViewItem *item = registeredServicesList->currentItem();
20 if(item){ 20 if(item)
21 help->setText(list[item->text(0)]); 21 help->setText(list[item->text(0)]);
22 }
23} 22}
24 23
25/** 24/**
26 * Save a copy of newList for the discriptions and append them all to the view 25 * Save a copy of newList for the discriptions and append them all to the view
27 * @param newList the new list of possible interfaces 26 * @param newList the new list of possible interfaces
28 */ 27 */
29void AddConnectionImp::addConnections(QMap<QString, QString> newList){ 28void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){
30 list = newList; 29 list = newList;
31 QMap<QString, QString>::Iterator it; 30 QMap<QString, QString>::Iterator it;
32 for( it = list.begin(); it != list.end(); ++it ) 31 for( it = list.begin(); it != list.end(); ++it )
33 QListViewItem *item = new QListViewItem(registeredServicesList, it.key()); 32 QListViewItem *item = new QListViewItem(registeredServicesList, it.key());
34 registeredServicesList->setCurrentItem(registeredServicesList->firstChild()); 33 registeredServicesList->setCurrentItem(registeredServicesList->firstChild());
35} 34}
36 35
37// addserviceimp.cpp 36// addserviceimp.cpp
38 37
diff --git a/noncore/settings/networksettings/addconnectionimp.h b/noncore/settings/networksettings/addconnectionimp.h
index 643cd9a..680a502 100644
--- a/noncore/settings/networksettings/addconnectionimp.h
+++ b/noncore/settings/networksettings/addconnectionimp.h
@@ -1,29 +1,29 @@
1#ifndef ADDCONNECTIONIMP_H 1#ifndef ADDCONNECTIONIMP_H
2#define ADDCONNECTIONIMP_H 2#define ADDCONNECTIONIMP_H
3 3
4#include "addconnection.h" 4#include "addconnection.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qlist.h> 6#include <qlist.h>
7 7
8class QListViewItem; 8class QListViewItem;
9 9
10class AddConnectionImp : public AddConnection { 10class AddConnectionImp : public AddConnection {
11 11
12Q_OBJECT 12Q_OBJECT
13 13
14public: 14public:
15 AddConnectionImp(QWidget *parent=0, const char *name=0, WFlags f=0); 15 AddConnectionImp(QWidget *parent=0, const char *name=0, WFlags f=0);
16 void addConnections(QMap<QString, QString> newList); 16 void addConnections(const QMap<QString, QString> &newList);
17 17
18private slots: 18private slots:
19 void changed(); 19 void changed();
20 20
21private: 21private:
22 QMap<QString, QString> list; 22 QMap<QString, QString> list;
23 23
24}; 24};
25 25
26#endif 26#endif
27 27
28// addconectionimp.h 28// addconectionimp.h
29 29
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp
index e4f405e..4129b3d 100644
--- a/noncore/settings/networksettings/interfaces/interface.cpp
+++ b/noncore/settings/networksettings/interfaces/interface.cpp
@@ -29,33 +29,33 @@ void Interface::setStatus(bool newStatus){
29 29
30/** 30/**
31 * Set if attached or not (802.11 card pulled out for example) 31 * Set if attached or not (802.11 card pulled out for example)
32 * @param isAttached - if attached 32 * @param isAttached - if attached
33 * emit updateInterface 33 * emit updateInterface
34 */ 34 */
35void Interface::setAttached(bool isAttached){ 35void Interface::setAttached(bool isAttached){
36 attached = isAttached; 36 attached = isAttached;
37 emit(updateInterface(this)); 37 emit(updateInterface(this));
38}; 38};
39 39
40/** 40/**
41 * Set Hardware name 41 * Set Hardware name
42 * @param name - the new name 42 * @param name - the new name
43 * emit updateInterface 43 * emit updateInterface
44 */ 44 */
45void Interface::setHardwareName(QString name){ 45void Interface::setHardwareName(const QString &name){
46 hardwareName = name; 46 hardwareName = name;
47 emit(updateInterface(this)); 47 emit(updateInterface(this));
48}; 48};
49 49
50/** 50/**
51 * Set Module owner 51 * Set Module owner
52 * @param owner - the new owner 52 * @param owner - the new owner
53 * emit updateInterface 53 * emit updateInterface
54 */ 54 */
55void Interface::setModuleOwner(Module *owner){ 55void Interface::setModuleOwner(Module *owner){
56 moduleOwner = owner; 56 moduleOwner = owner;
57 emit(updateInterface(this)); 57 emit(updateInterface(this));
58}; 58};
59 59
60 60
61/** 61/**
diff --git a/noncore/settings/networksettings/interfaces/interface.h b/noncore/settings/networksettings/interfaces/interface.h
index fc064fe..989d6d8 100644
--- a/noncore/settings/networksettings/interfaces/interface.h
+++ b/noncore/settings/networksettings/interfaces/interface.h
@@ -2,47 +2,46 @@
2#define INTERFACE_H 2#define INTERFACE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7class Module; 7class Module;
8 8
9class Interface : public QObject{ 9class Interface : public QObject{
10 Q_OBJECT 10 Q_OBJECT
11 11
12signals: 12signals:
13 void updateInterface(Interface *i); 13 void updateInterface(Interface *i);
14 void updateMessage(const QString &message); 14 void updateMessage(const QString &message);
15 15
16public: 16public:
17 Interface(QObject * parent=0, const char * name= "unknown", bool status = false); 17 Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
18 virtual ~Interface(){};
19 18
20 virtual QString getInterfaceName(){ QString n(this->name()); return n; }; 19 QString getInterfaceName(){ QString n(this->name()); return n; };
21 20
22 virtual bool getStatus(){ return status; }; 21 bool getStatus(){ return status; };
23 virtual void setStatus(bool newStatus); 22 void setStatus(bool newStatus);
24 23
25 virtual bool isAttached(){ return attached; }; 24 bool isAttached(){ return attached; };
26 virtual void setAttached(bool isAttached=false); 25 void setAttached(bool isAttached=false);
27 26
28 virtual QString getHardwareName(){ return hardwareName; }; 27 QString getHardwareName(){ return hardwareName; };
29 virtual void setHardwareName(QString name="Unknown"); 28 void setHardwareName(const QString &name="Unknown");
30 29
31 virtual Module* getModuleOwner(){ return moduleOwner; }; 30 Module* getModuleOwner(){ return moduleOwner; };
32 virtual void setModuleOwner(Module *owner=NULL); 31 void setModuleOwner(Module *owner=NULL);
33 32
34 // inet information. 33 // inet information.
35 QString getMacAddress(){ return macAddress; }; 34 QString getMacAddress(){ return macAddress; };
36 QString getIp(){ return ip; }; 35 QString getIp(){ return ip; };
37 QString getSubnetMask(){ return subnetMask; }; 36 QString getSubnetMask(){ return subnetMask; };
38 QString getBroadcast(){ return broadcast; }; 37 QString getBroadcast(){ return broadcast; };
39 bool isDhcp(){ return dhcp; }; 38 bool isDhcp(){ return dhcp; };
40 QString getDhcpServerIp(){ return dhcpServerIp; }; 39 QString getDhcpServerIp(){ return dhcpServerIp; };
41 QString getLeaseObtained(){ return leaseObtained; }; 40 QString getLeaseObtained(){ return leaseObtained; };
42 QString getLeaseExpires(){ return leaseExpires; }; 41 QString getLeaseExpires(){ return leaseExpires; };
43 42
44public slots: 43public slots:
45 bool refresh(); 44 bool refresh();
46 void start(); 45 void start();
47 void stop(); 46 void stop();
48 void restart(); 47 void restart();
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index f1b8067..708f399 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -57,49 +57,49 @@ QStringList Interfaces::getInterfaceList(){
57 int findSpace = line.find(" "); 57 int findSpace = line.find(" ");
58 if( findSpace >= 0){ 58 if( findSpace >= 0){
59 line = line.mid(0, findSpace); 59 line = line.mid(0, findSpace);
60 list.append(line); 60 list.append(line);
61 } 61 }
62 } 62 }
63 } 63 }
64 return list; 64 return list;
65} 65}
66 66
67/** 67/**
68 * Find out if interface is in an "auto" group or not. 68 * Find out if interface is in an "auto" group or not.
69 * Report any duplicates such as eth0 being in two differnt auto's 69 * Report any duplicates such as eth0 being in two differnt auto's
70 * @param interface interface to check to see if it is on or not. 70 * @param interface interface to check to see if it is on or not.
71 * @return true is interface is in auto 71 * @return true is interface is in auto
72 */ 72 */
73bool Interfaces::isAuto(QString interface){ 73bool Interfaces::isAuto(const QString &interface){
74 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 74 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
75 QStringList awi = autoLines.grep(QRegExp(interface)); 75 QStringList awi = autoLines.grep(QRegExp(interface));
76 if(awi.count() > 1) 76 if(awi.count() > 1)
77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 77 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
78 if(awi.count() < 1) 78 if(awi.count() < 1)
79 return false; 79 return false;
80 return true; 80 return true;
81} 81}
82 82
83/** 83/**
84 * Attempt to set the auto option for interface to setAuto. 84 * Attempt to set the auto option for interface to setAuto.
85 * @param interface the interface to set 85 * @param interface the interface to set
86 * @param setAuto the value to set interface to. 86 * @param setAuto the value to set interface to.
87 * @return false if already set to setAuto. 87 * @return false if already set to setAuto.
88 * */ 88 * */
89bool Interfaces::setAuto(QString interface, bool setAuto){ 89bool Interfaces::setAuto(const QString &interface, bool setAuto){
90 // Don't need to set it if it is already set. 90 // Don't need to set it if it is already set.
91 if(isAuto(interface) == setAuto) 91 if(isAuto(interface) == setAuto)
92 return false; 92 return false;
93 93
94 bool changed = false; 94 bool changed = false;
95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
96 if((*it).contains(AUTO)){ 96 if((*it).contains(AUTO)){
97 //We know that they are not in any group so let add to this auto. 97 //We know that they are not in any group so let add to this auto.
98 if(setAuto){ 98 if(setAuto){
99 (*it) = (*it) += " " + interface; 99 (*it) = (*it) += " " + interface;
100 // Don't care to have such thins as: auto eth0 lo usb0 100 // Don't care to have such thins as: auto eth0 lo usb0
101 (*it) = (*it).simplifyWhiteSpace(); 101 (*it) = (*it).simplifyWhiteSpace();
102 changed = true; 102 changed = true;
103 break; 103 break;
104 } 104 }
105 else{ 105 else{
@@ -143,48 +143,48 @@ bool Interfaces::setInterface(QString interface){
143 * A quick helper funtion to see if the current interface is set. 143 * A quick helper funtion to see if the current interface is set.
144 * @return bool true if set, false otherwise. 144 * @return bool true if set, false otherwise.
145 */ 145 */
146bool Interfaces::isInterfaceSet(){ 146bool Interfaces::isInterfaceSet(){
147 return (currentIface != interfaces.end()); 147 return (currentIface != interfaces.end());
148} 148}
149 149
150/** 150/**
151 * Add a new interface of with the settings - family and method 151 * Add a new interface of with the settings - family and method
152 * @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
153 * removed from the interface name. 153 * removed from the interface name.
154 * @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
155 * Must of one of the families defined in interfaces.h 155 * Must of one of the families defined in interfaces.h
156 * @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.
157 * @return true if successfull. 157 * @return true if successfull.
158 */ 158 */
159bool Interfaces::addInterface(QString interface, QString family, QString method){ 159bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
160 if(acceptedFamily.contains(family)==0) 160 if(acceptedFamily.contains(family)==0)
161 return false; 161 return false;
162 interface = interface.simplifyWhiteSpace(); 162 QString newInterface = interface.simplifyWhiteSpace();
163 interface = interface.replace(QRegExp(" "), ""); 163 newInterface = newInterface.replace(QRegExp(" "), "");
164 interfaces.append(""); 164 interfaces.append("");
165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); 165 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
166 return true; 166 return true;
167} 167}
168 168
169/** 169/**
170 * Copies interface with name interface to name newInterface 170 * Copies interface with name interface to name newInterface
171 * @param newInterface name of the new interface. 171 * @param newInterface name of the new interface.
172 * @return bool true if successfull 172 * @return bool true if successfull
173 */ 173 */
174bool Interfaces::copyInterface(QString interface, QString newInterface){ 174bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
175 if(!setInterface(interface)) return false; 175 if(!setInterface(interface)) return false;
176 176
177 QStringList::Iterator it = currentIface; 177 QStringList::Iterator it = currentIface;
178 it++; 178 it++;
179 179
180 bool error; 180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); 181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) return false; 182 if(!setInterface(newInterface)) return false;
183 QStringList::Iterator newIface = currentIface; 183 QStringList::Iterator newIface = currentIface;
184 newIface++; 184 newIface++;
185 185
186 for ( ; it != interfaces.end(); ++it ){ 186 for ( ; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) 187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break; 188 break;
189 newIface = interfaces.insert(newIface, *it); 189 newIface = interfaces.insert(newIface, *it);
190 } 190 }
@@ -267,205 +267,207 @@ QString Interfaces::getInterfaceMethod(bool &error){
267 return QString(); 267 return QString();
268 } 268 }
269 QString line = (*currentIface); 269 QString line = (*currentIface);
270 line = line.mid(QString(IFACE).length()+1, line.length()); 270 line = line.mid(QString(IFACE).length()+1, line.length());
271 line = line.mid(name.length()+1, line.length()); 271 line = line.mid(name.length()+1, line.length());
272 line = line.mid(family.length()+1, line.length()); 272 line = line.mid(family.length()+1, line.length());
273 line = line.simplifyWhiteSpace(); 273 line = line.simplifyWhiteSpace();
274 error = false; 274 error = false;
275 return line; 275 return line;
276} 276}
277 277
278/** 278/**
279 * Sets the interface name to newName. 279 * Sets the interface name to newName.
280 * @param newName the new name of the interface. All whitespace is removed. 280 * @param newName the new name of the interface. All whitespace is removed.
281 * @return bool true if successfull. 281 * @return bool true if successfull.
282 */ 282 */
283bool Interfaces::setInterfaceName(QString newName){ 283bool Interfaces::setInterfaceName(const QString &newName){
284 if(currentIface == interfaces.end()) 284 if(currentIface == interfaces.end())
285 return false; 285 return false;
286 newName = newName.simplifyWhiteSpace(); 286 QString name = newName.simplifyWhiteSpace();
287 newName = newName.replace(QRegExp(" "), ""); 287 name = name.replace(QRegExp(" "), "");
288 bool returnValue = false; 288 bool returnValue = false;
289 (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); 289 (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
290 return !returnValue; 290 return !returnValue;
291} 291}
292 292
293/** 293/**
294 * Sets the interface family to newName. 294 * Sets the interface family to newName.
295 * @param newName the new name of the interface. Must be one of the families 295 * @param newName the new name of the interface. Must be one of the families
296 * defined in the interfaces.h file. 296 * defined in the interfaces.h file.
297 * @return bool true if successfull. 297 * @return bool true if successfull.
298 */ 298 */
299bool Interfaces::setInterfaceFamily(QString newName){ 299bool Interfaces::setInterfaceFamily(const QString &newName){
300 if(currentIface == interfaces.end()) 300 if(currentIface == interfaces.end())
301 return false; 301 return false;
302 if(acceptedFamily.contains(newName)==0) 302 if(acceptedFamily.contains(newName)==0)
303 return false; 303 return false;
304 bool returnValue = false; 304 bool returnValue = false;
305 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); 305 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
306 return !returnValue; 306 return !returnValue;
307} 307}
308 308
309/** 309/**
310 * Sets the interface method to newName 310 * Sets the interface method to newName
311 * @param newName the new name of the interface 311 * @param newName the new name of the interface
312 * @return bool true if successfull. 312 * @return bool true if successfull.
313 */ 313 */
314bool Interfaces::setInterfaceMethod(QString newName){ 314bool Interfaces::setInterfaceMethod(const QString &newName){
315 if(currentIface == interfaces.end()) 315 if(currentIface == interfaces.end())
316 return false; 316 return false;
317 bool returnValue = false; 317 bool returnValue = false;
318 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); 318 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
319 return !returnValue; 319 return !returnValue;
320} 320}
321 321
322/** 322/**
323 * Get a value for an option in the currently selected interface. For example 323 * Get a value for an option in the currently selected interface. For example
324 * calling getInterfaceOption("address") on the following stanza would 324 * calling getInterfaceOption("address") on the following stanza would
325 * return 192.168.1.1. 325 * return 192.168.1.1.
326 * iface eth0 static 326 * iface eth0 static
327 * address 192.168.1.1 327 * address 192.168.1.1
328 * @param option the options to get the value. 328 * @param option the options to get the value.
329 * @param error set to true if any error occurs, false otherwise. 329 * @param error set to true if any error occurs, false otherwise.
330 * @return QString the options value. QString::null if error == true 330 * @return QString the options value. QString::null if error == true
331 */ 331 */
332QString Interfaces::getInterfaceOption(QString option, bool &error){ 332QString Interfaces::getInterfaceOption(const QString &option, bool &error){
333 return getOption(currentIface, option, error); 333 return getOption(currentIface, option, error);
334} 334}
335 335
336/** 336/**
337 * Set a value for an option in the currently selected interface. If option 337 * Set a value for an option in the currently selected interface. If option
338 * doesn't exist then it is added along with the value. 338 * doesn't exist then it is added along with the value.
339 * @param option the options to set the value. 339 * @param option the options to set the value.
340 * @param value the value that option should be set to. 340 * @param value the value that option should be set to.
341 * @param error set to true if any error occurs, false otherwise. 341 * @param error set to true if any error occurs, false otherwise.
342 * @return QString the options value. QString::null if error == true 342 * @return QString the options value. QString::null if error == true
343 */ 343 */
344bool Interfaces::setInterfaceOption(QString option, QString value){ 344bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
345 return setOption(currentIface, option, value); 345 return setOption(currentIface, option, value);
346} 346}
347 347
348/** 348/**
349 * Removes a value for an option in the currently selected interface. 349 * Removes a value for an option in the currently selected interface.
350 * @param option the options to set the value. 350 * @param option the options to set the value.
351 * @param value the value that option should be set to. 351 * @param value the value that option should be set to.
352 * @param error set to true if any error occurs, false otherwise. 352 * @param error set to true if any error occurs, false otherwise.
353 * @return QString the options value. QString::null if error == true 353 * @return QString the options value. QString::null if error == true
354 */ 354 */
355bool Interfaces::removeInterfaceOption(QString option, QString value){ 355bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
356 return removeOption(currentIface, option, value); 356 return removeOption(currentIface, option, value);
357} 357}
358 358
359/** 359/**
360 * Removes all of the options from the currently selected interface. 360 * Removes all of the options from the currently selected interface.
361 * @return bool error if if successfull 361 * @return bool error if if successfull
362 */ 362 */
363bool Interfaces::removeAllInterfaceOptions(){ 363bool Interfaces::removeAllInterfaceOptions(){
364 return removeAllOptions(currentIface); 364 return removeAllOptions(currentIface);
365} 365}
366 366
367/** 367/**
368 * Set the current map to interface's map. This needs to be done before you 368 * Set the current map to interface's map. This needs to be done before you
369 * can call addMapping(), set/getMap(), and get/setScript(). 369 * can call addMapping(), set/getMap(), and get/setScript().
370 * @param interface the name of the interface to set. All whitespace is 370 * @param interface the name of the interface to set. All whitespace is
371 * removed from the interface name. 371 * removed from the interface name.
372 * @return bool true if it is successfull. 372 * @return bool true if it is successfull.
373 */ 373 */
374bool Interfaces::setMapping(QString interface){ 374bool Interfaces::setMapping(const QString &interface){
375 interface = interface.simplifyWhiteSpace(); 375 QString interfaceName = interface.simplifyWhiteSpace();
376 interface = interface.replace(QRegExp(" "), ""); 376 interfaceName = interfaceName.replace(QRegExp(" "), "");
377 return setStanza(MAPPING, interface, currentMapping); 377 return setStanza(MAPPING, interfaceName, currentMapping);
378} 378}
379 379
380/** 380/**
381 * Adds a new Mapping to the interfaces file with interfaces. 381 * Adds a new Mapping to the interfaces file with interfaces.
382 * @param interface the name(s) of the interfaces to set to this mapping 382 * @param interface the name(s) of the interfaces to set to this mapping
383 */ 383 */
384void Interfaces::addMapping(QString option){ 384void Interfaces::addMapping(const QString &option){
385 interfaces.append(""); 385 interfaces.append("");
386 interfaces.append(QString(MAPPING " %1").arg(option)); 386 interfaces.append(QString(MAPPING " %1").arg(option));
387} 387}
388 388
389/** 389/**
390 * Remove the currently selected map and all of its options. 390 * Remove the currently selected map and all of its options.
391 * @return bool if successfull or not. 391 * @return bool if successfull or not.
392 */ 392 */
393bool Interfaces::removeMapping(){ 393bool Interfaces::removeMapping(){
394 if(currentMapping == interfaces.end()) 394 if(currentMapping == interfaces.end())
395 return false; 395 return false;
396 (*currentMapping) = ""; 396 (*currentMapping) = "";
397 return removeAllOptions(currentMapping); 397 return removeAllOptions(currentMapping);
398} 398}
399 399
400/** 400/**
401 * Set a map option within a mapping. 401 * Set a map option within a mapping.
402 * @param map map to use 402 * @param map map to use
403 * @param value value to go with map 403 * @param value value to go with map
404 * @return bool true if it is successfull. 404 * @return bool true if it is successfull.
405 */ 405 */
406bool Interfaces::setMap(QString map, QString value){ 406bool Interfaces::setMap(const QString &map, const QString &value){
407 return setOption(currentMapping, map, value); 407 return setOption(currentMapping, map, value);
408} 408}
409 409
410/** 410/**
411 * Removes a map option within a mapping. 411 * Removes a map option within a mapping.
412 * @param map map to use 412 * @param map map to use
413 * @param value value to go with map 413 * @param value value to go with map
414 * @return bool true if it is successfull. 414 * @return bool true if it is successfull.
415 */ 415 */
416bool Interfaces::removeMap(QString map, QString value){ 416bool Interfaces::removeMap(const QString &map, const QString &value){
417 return removeOption(currentMapping, map, value); 417 return removeOption(currentMapping, map, value);
418} 418}
419 419
420/** 420/**
421 * Get a map value within a mapping. 421 * Get a map value within a mapping.
422 * @param map map to get value of 422 * @param map map to get value of
423 * @param bool true if it is successfull. 423 * @param bool true if it is successfull.
424 * @return value that goes to the map 424 * @return value that goes to the map
425 */ 425 */
426QString Interfaces::getMap(QString map, bool &error){ 426QString Interfaces::getMap(const QString &map, bool &error){
427 return getOption(currentMapping, map, error); 427 return getOption(currentMapping, map, error);
428} 428}
429 429
430/** 430/**
431 * Sets a script value of the current mapping to argument. 431 * Sets a script value of the current mapping to argument.
432 * @param argument the script name. 432 * @param argument the script name.
433 * @return true if successfull. 433 * @return true if successfull.
434 */ 434 */
435bool Interfaces::setScript(QString argument){ 435bool Interfaces::setScript(const QString &argument){
436 return setOption(currentMapping, "script", argument); 436 return setOption(currentMapping, "script", argument);
437} 437}
438 438
439/** 439/**
440 * @param error true if could not retrieve the current script argument. 440 * @param error true if could not retrieve the current script argument.
441 * @return QString the argument of the script for the current mapping. 441 * @return QString the argument of the script for the current mapping.
442 */ 442 */
443QString Interfaces::getScript(bool &error){ 443QString Interfaces::getScript(bool &error){
444 return getOption(currentMapping, "script", error); 444 return getOption(currentMapping, "script", error);
445} 445}
446 446
447
448
447/** 449/**
448 * Helper function used to parse through the QStringList and put pointers in 450 * Helper function used to parse through the QStringList and put pointers in
449 * the correct place. 451 * the correct place.
450 * @param stanza The stanza (auto, iface, mapping) to look for. 452 * @param stanza The stanza (auto, iface, mapping) to look for.
451 * @param option string that must be in the stanza's main line. 453 * @param option string that must be in the stanza's main line.
452 * @param interator interator to place at location of stanza if successfull. 454 * @param interator interator to place at location of stanza if successfull.
453 * @return bool true if the stanza is found. 455 * @return bool true if the stanza is found.
454 */ 456 */
455bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ 457bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
456 bool found = false; 458 bool found = false;
457 iterator = interfaces.end(); 459 iterator = interfaces.end();
458 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 460 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
459 QString line = (*it).simplifyWhiteSpace(); 461 QString line = (*it).simplifyWhiteSpace();
460 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ 462 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
461 uint point = line.find(option); 463 uint point = line.find(option);
462 bool valid = true; 464 bool valid = true;
463 if(point > 0){ 465 if(point > 0){
464 // There are more chars in the line. check +1 466 // There are more chars in the line. check +1
465 if(line.at(point-1) != ' ') 467 if(line.at(point-1) != ' ')
466 valid = false; 468 valid = false;
467 } 469 }
468 point += option.length(); 470 point += option.length();
469 if(point < line.length()-1){ 471 if(point < line.length()-1){
470 // There are more chars in the line. check -1 472 // There are more chars in the line. check -1
471 if(line.at(point) != ' ') 473 if(line.at(point) != ' ')
@@ -476,33 +478,33 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator
476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 478 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
477 } 479 }
478 found = true; 480 found = true;
479 iterator = it; 481 iterator = it;
480 } 482 }
481 } 483 }
482 } 484 }
483 return found; 485 return found;
484} 486}
485 487
486/** 488/**
487 * Sets a value of an option in a stanza 489 * Sets a value of an option in a stanza
488 * @param start the start of the stanza 490 * @param start the start of the stanza
489 * @param option the option to use when setting value. 491 * @param option the option to use when setting value.
490 * @return bool true if successfull, false otherwise. 492 * @return bool true if successfull, false otherwise.
491 */ 493 */
492bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ 494bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
493 if(start == interfaces.end()) 495 if(start == interfaces.end())
494 return false; 496 return false;
495 497
496 bool found = false; 498 bool found = false;
497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 499 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 500 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
499 if(!found && value != ""){ 501 if(!found && value != ""){
500 // Got to the end of the stanza without finding it, so append it. 502 // Got to the end of the stanza without finding it, so append it.
501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 503 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
502 } 504 }
503 found = true; 505 found = true;
504 break; 506 break;
505 } 507 }
506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 508 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
507 // Found it in stanza so replace it. 509 // Found it in stanza so replace it.
508 if(found) 510 if(found)
@@ -511,84 +513,84 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString
511 (*it) = QString("\t%1 %2").arg(option).arg(value); 513 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 } 514 }
513 } 515 }
514 if(!found){ 516 if(!found){
515 QStringList::Iterator p = start; 517 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 518 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true; 519 found = true;
518 } 520 }
519 return found; 521 return found;
520} 522}
521/** 523/**
522 * Removes a option in a stanza 524 * Removes a option in a stanza
523 * @param start the start of the stanza 525 * @param start the start of the stanza
524 * @param option the option to use when setting value. 526 * @param option the option to use when setting value.
525 * @return bool true if successfull, false otherwise. 527 * @return bool true if successfull, false otherwise.
526 */ 528 */
527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ 529bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
528 if(start == interfaces.end()) 530 if(start == interfaces.end())
529 return false; 531 return false;
530 532
531 bool found = false; 533 bool found = false;
532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 534 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 535 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
534 // got to the end without finding it 536 // got to the end without finding it
535 break; 537 break;
536 } 538 }
537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ 539 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
538 // Found it in stanza so replace it. 540 // Found it in stanza so replace it.
539 if(found) 541 if(found)
540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 542 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
541 found = true; 543 found = true;
542 (*it) = ""; 544 (*it) = "";
543 } 545 }
544 } 546 }
545 return found; 547 return found;
546} 548}
547 549
548/** 550/**
549 * Removes all options in a stanza 551 * Removes all options in a stanza
550 * @param start the start of the stanza 552 * @param start the start of the stanza
551 * @return bool true if successfull, false otherwise. 553 * @return bool true if successfull, false otherwise.
552 */ 554 */
553bool Interfaces::removeAllOptions(QStringList::Iterator start){ 555bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
554 if(start == interfaces.end()) 556 if(start == interfaces.end())
555 return false; 557 return false;
556 558
557 QStringList::Iterator it = start; 559 QStringList::Iterator it = start;
558 it = ++it; 560 it = ++it;
559 for (; it != interfaces.end(); ++it ) { 561 for (; it != interfaces.end(); ++it ) {
560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 562 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
561 break; 563 break;
562 } 564 }
563 it = interfaces.remove(it); 565 it = interfaces.remove(it);
564 it = --it; 566 it = --it;
565 } 567 }
566 // Leave a space between this interface and the next. 568 // Leave a space between this interface and the next.
567 interfaces.insert(it, QString("")); 569 interfaces.insert(it, QString(""));
568 return true; 570 return true;
569} 571}
570 572
571/** 573/**
572 * Gets a value of an option in a stanza 574 * Gets a value of an option in a stanza
573 * @param start the start of the stanza 575 * @param start the start of the stanza
574 * @param option the option to use when getting the value. 576 * @param option the option to use when getting the value.
575 * @param bool true if errors false otherwise. 577 * @param bool true if errors false otherwise.
576 * @return QString the value of option QString::null() if error == true. 578 * @return QString the value of option QString::null() if error == true.
577 */ 579 */
578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ 580QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){
579 if(start == interfaces.end()){ 581 if(start == interfaces.end()){
580 error = false; 582 error = false;
581 return QString(); 583 return QString();
582 } 584 }
583 585
584 QString value; 586 QString value;
585 bool found = false; 587 bool found = false;
586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 588 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 589 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
588 break; 590 break;
589 } 591 }
590 if((*it).contains(option) && (*it).at(0) != '#'){ 592 if((*it).contains(option) && (*it).at(0) != '#'){
591 if(found) 593 if(found)
592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); 594 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
593 found = true; 595 found = true;
594 QString line = (*it).simplifyWhiteSpace(); 596 QString line = (*it).simplifyWhiteSpace();
diff --git a/noncore/settings/networksettings/interfaces/interfaces.h b/noncore/settings/networksettings/interfaces/interfaces.h
index e09ea71..26abb73 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.h
+++ b/noncore/settings/networksettings/interfaces/interfaces.h
@@ -12,65 +12,65 @@
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 QStringList getInterfaceList(); 26 QStringList getInterfaceList();
27 27
28 bool isAuto(QString interface); 28 bool isAuto(const QString &interface);
29 bool setAuto(QString interface, bool setAuto); 29 bool setAuto(const QString &interface, bool setAuto);
30 30
31 bool removeInterface(); 31 bool removeInterface();
32 bool addInterface(QString interface, QString family, QString method); 32 bool addInterface(const QString &interface, const QString &family, const QString &method);
33 bool copyInterface(QString oldInterface, QString newInterface); 33 bool copyInterface(const QString &oldInterface, const QString &newInterface);
34 bool setInterface(QString interface); 34 bool setInterface(QString interface);
35 bool isInterfaceSet(); 35 inline bool isInterfaceSet();
36 QString getInterfaceName(bool &error); 36 QString getInterfaceName(bool &error);
37 bool setInterfaceName(QString newName); 37 bool setInterfaceName(const QString &newName);
38 QString getInterfaceFamily(bool &error); 38 QString getInterfaceFamily(bool &error);
39 bool setInterfaceFamily(QString newName); 39 bool setInterfaceFamily(const QString &newName);
40 QString getInterfaceMethod(bool &error); 40 QString getInterfaceMethod(bool &error);
41 bool setInterfaceMethod(QString newName); 41 bool setInterfaceMethod(const QString &newName);
42 QString getInterfaceOption(QString option, bool &error); 42 inline QString getInterfaceOption(const QString &option, bool &error);
43 bool setInterfaceOption(QString option, QString value); 43 inline bool setInterfaceOption(const QString &option, const QString &value);
44 bool removeInterfaceOption(QString option, QString value); 44 inline bool removeInterfaceOption(const QString &option, const QString &value);
45 bool removeAllInterfaceOptions(); 45 inline bool removeAllInterfaceOptions();
46 46
47 bool setMapping(QString interface); 47 bool setMapping(const QString &interface);
48 bool removeMapping(); 48 bool removeMapping();
49 void addMapping(QString options); 49 inline void addMapping(const QString &options);
50 bool setMap(QString map, QString value); 50 inline bool setMap(const QString &map, const QString &value);
51 bool removeMap(QString map, QString value); 51 inline bool removeMap(const QString &map, const QString &value);
52 QString getMap(QString map, bool &error); 52 inline QString getMap(const QString &map, bool &error);
53 bool setScript(QString); 53 inline bool setScript(const QString &argument);
54 QString getScript(bool &error); 54 inline QString getScript(bool &error);
55 55
56 bool write(); 56 bool write();
57 57
58private: 58private:
59 bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); 59 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
60 bool setOption(QStringList::Iterator start, QString option, QString value); 60 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
61 bool removeOption(QStringList::Iterator start, QString option, QString value); 61 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
62 QString getOption(QStringList::Iterator start, QString option, bool &error); 62 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
63 bool removeAllOptions(QStringList::Iterator start); 63 bool removeAllOptions(const QStringList::Iterator &start);
64 64
65 QString interfacesFile; 65 QString interfacesFile;
66 QStringList interfaces; 66 QStringList interfaces;
67 QStringList::Iterator currentIface; 67 QStringList::Iterator currentIface;
68 QStringList::Iterator currentMapping; 68 QStringList::Iterator currentMapping;
69 69
70 QStringList acceptedFamily; 70 QStringList acceptedFamily;
71}; 71};
72 72
73#endif 73#endif
74 74
75// interfaces 75// interfaces
76 76
diff --git a/noncore/settings/networksettings/interfaces/interfacesetup.ui b/noncore/settings/networksettings/interfaces/interfacesetup.ui
index ab8e413..df55d25 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetup.ui
+++ b/noncore/settings/networksettings/interfaces/interfacesetup.ui
@@ -86,32 +86,36 @@
86 <name>name</name> 86 <name>name</name>
87 <cstring>leaseTime</cstring> 87 <cstring>leaseTime</cstring>
88 </property> 88 </property>
89 <property stdset="1"> 89 <property stdset="1">
90 <name>suffix</name> 90 <name>suffix</name>
91 <string> hours</string> 91 <string> hours</string>
92 </property> 92 </property>
93 <property stdset="1"> 93 <property stdset="1">
94 <name>maxValue</name> 94 <name>maxValue</name>
95 <number>87600</number> 95 <number>87600</number>
96 </property> 96 </property>
97 <property stdset="1"> 97 <property stdset="1">
98 <name>minValue</name> 98 <name>minValue</name>
99 <number>1</number> 99 <number>1</number>
100 </property> 100 </property>
101 <property stdset="1"> 101 <property stdset="1">
102 <name>lineStep</name>
103 <number>24</number>
104 </property>
105 <property stdset="1">
102 <name>value</name> 106 <name>value</name>
103 <number>168</number> 107 <number>168</number>
104 </property> 108 </property>
105 </widget> 109 </widget>
106 </hbox> 110 </hbox>
107 </widget> 111 </widget>
108 <widget> 112 <widget>
109 <class>QGroupBox</class> 113 <class>QGroupBox</class>
110 <property stdset="1"> 114 <property stdset="1">
111 <name>name</name> 115 <name>name</name>
112 <cstring>staticGroupBox</cstring> 116 <cstring>staticGroupBox</cstring>
113 </property> 117 </property>
114 <property stdset="1"> 118 <property stdset="1">
115 <name>enabled</name> 119 <name>enabled</name>
116 <bool>false</bool> 120 <bool>false</bool>
117 </property> 121 </property>
@@ -238,32 +242,54 @@
238 <enum>Vertical</enum> 242 <enum>Vertical</enum>
239 </property> 243 </property>
240 <property stdset="1"> 244 <property stdset="1">
241 <name>sizeType</name> 245 <name>sizeType</name>
242 <enum>Expanding</enum> 246 <enum>Expanding</enum>
243 </property> 247 </property>
244 <property> 248 <property>
245 <name>sizeHint</name> 249 <name>sizeHint</name>
246 <size> 250 <size>
247 <width>20</width> 251 <width>20</width>
248 <height>20</height> 252 <height>20</height>
249 </size> 253 </size>
250 </property> 254 </property>
251 </spacer> 255 </spacer>
252 </vbox> 256 </vbox>
253</widget> 257</widget>
258<customwidgets>
259 <customwidget>
260 <class>QWidget</class>
261 <header location="local">qwidget.h</header>
262 <sizehint>
263 <width>100</width>
264 <height>100</height>
265 </sizehint>
266 <container>0</container>
267 <sizepolicy>
268 <hordata>7</hordata>
269 <verdata>7</verdata>
270 </sizepolicy>
271 <pixmap>image0</pixmap>
272 </customwidget>
273</customwidgets>
274<images>
275 <image>
276 <name>image0</name>
277 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
278 </image>
279</images>
254<connections> 280<connections>
255 <connection> 281 <connection>
256 <sender>dhcpCheckBox</sender> 282 <sender>dhcpCheckBox</sender>
257 <signal>toggled(bool)</signal> 283 <signal>toggled(bool)</signal>
258 <receiver>leaseHoursLabel</receiver> 284 <receiver>leaseHoursLabel</receiver>
259 <slot>setEnabled(bool)</slot> 285 <slot>setEnabled(bool)</slot>
260 </connection> 286 </connection>
261 <connection> 287 <connection>
262 <sender>dhcpCheckBox</sender> 288 <sender>dhcpCheckBox</sender>
263 <signal>toggled(bool)</signal> 289 <signal>toggled(bool)</signal>
264 <receiver>leaseTime</receiver> 290 <receiver>leaseTime</receiver>
265 <slot>setEnabled(bool)</slot> 291 <slot>setEnabled(bool)</slot>
266 </connection> 292 </connection>
267 <connection> 293 <connection>
268 <sender>dhcpCheckBox</sender> 294 <sender>dhcpCheckBox</sender>
269 <signal>toggled(bool)</signal> 295 <signal>toggled(bool)</signal>
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.h b/noncore/settings/networksettings/interfaces/interfacesetupimp.h
index a88e190..60933aa 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.h
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.h
@@ -8,33 +8,32 @@ class Interface;
8class Interfaces; 8class Interfaces;
9 9
10class InterfaceSetupImp : public InterfaceSetup { 10class InterfaceSetupImp : public InterfaceSetup {
11 Q_OBJECT 11 Q_OBJECT
12 12
13public: 13public:
14 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); 14 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0);
15 bool saveChanges(); 15 bool saveChanges();
16 16
17public slots: 17public slots:
18 void setProfile(const QString &profile); 18 void setProfile(const QString &profile);
19 bool saveSettings(); 19 bool saveSettings();
20 20
21private: 21private:
22 Interfaces *interfaces; 22 Interfaces *interfaces;
23 Interface *interface; 23 Interface *interface;
24
25}; 24};
26 25
27 26
28#include <qlayout.h> 27#include <qlayout.h>
29 28
30class InterfaceSetupImpDialog : public QDialog { 29class InterfaceSetupImpDialog : public QDialog {
31Q_OBJECT 30Q_OBJECT
32 31
33public: 32public:
34 InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ 33 InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){
35 QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); 34 QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this );
36 setCaption("Interface Setup"); 35 setCaption("Interface Setup");
37 interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); 36 interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl);
38 InterfaceSetupLayout->addWidget( interfaceSetup ); 37 InterfaceSetupLayout->addWidget( interfaceSetup );
39 }; 38 };
40 void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; 39 void setProfile(QString &profile){ interfaceSetup->setProfile(profile);};
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 48ef9b3..7b93554 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -17,33 +17,33 @@
17 17
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/qlibrary.h> 19#include <qpe/qlibrary.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22 22
23#include <qlist.h> 23#include <qlist.h>
24#include <qdir.h> 24#include <qdir.h>
25#include <qfile.h> 25#include <qfile.h>
26#include <qtextstream.h> 26#include <qtextstream.h>
27 27
28#include <net/if.h> 28#include <net/if.h>
29#include <sys/ioctl.h> 29#include <sys/ioctl.h>
30 30
31#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 31#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
32 32
33MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 33MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false), scheme(DEFAULT_SCHEME){
34 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 34 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
35 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 35 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
36 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 36 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
37 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 37 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
38 38
39 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 39 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
40 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 40 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
41 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 41 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
42 42
43 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 43 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
44 // Load connections. 44 // Load connections.
45 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); 45 loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
46 getAllInterfaces(); 46 getAllInterfaces();
47 47
48 Interfaces i; 48 Interfaces i;
49 QStringList list = i.getInterfaceList(); 49 QStringList list = i.getInterfaceList();
@@ -176,58 +176,58 @@ void MainWindowImp::getAllInterfaces(){
176 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 176 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
177 break; 177 break;
178 178
179 default: 179 default:
180 qDebug(ifr->ifr_name); 180 qDebug(ifr->ifr_name);
181 qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1()); 181 qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1());
182 break; 182 break;
183 } 183 }
184 } 184 }
185} 185}
186 186
187/** 187/**
188 * Load all modules that are found in the path 188 * Load all modules that are found in the path
189 * @param path a directory that is scaned for any plugins that can be loaded 189 * @param path a directory that is scaned for any plugins that can be loaded
190 * and attempts to load them 190 * and attempts to load them
191 */ 191 */
192void MainWindowImp::loadModules(QString path){ 192void MainWindowImp::loadModules(const QString &path){
193 //qDebug(path.latin1()); 193 //qDebug(path.latin1());
194 QDir d(path); 194 QDir d(path);
195 if(!d.exists()) 195 if(!d.exists())
196 return; 196 return;
197 197
198 // Don't want sym links 198 // Don't want sym links
199 d.setFilter( QDir::Files | QDir::NoSymLinks ); 199 d.setFilter( QDir::Files | QDir::NoSymLinks );
200 const QFileInfoList *list = d.entryInfoList(); 200 const QFileInfoList *list = d.entryInfoList();
201 QFileInfoListIterator it( *list ); 201 QFileInfoListIterator it( *list );
202 QFileInfo *fi; 202 QFileInfo *fi;
203 while ( (fi=it.current()) ) { 203 while ( (fi=it.current()) ) {
204 if(fi->fileName().contains(".so")){ 204 if(fi->fileName().contains(".so")){
205 loadPlugin(path + "/" + fi->fileName()); 205 loadPlugin(path + "/" + fi->fileName());
206 } 206 }
207 ++it; 207 ++it;
208 } 208 }
209} 209}
210 210
211/** 211/**
212 * Attempt to load a function and resolve a function. 212 * Attempt to load a function and resolve a function.
213 * @param pluginFileName - the name of the file in which to attempt to load 213 * @param pluginFileName - the name of the file in which to attempt to load
214 * @param resolveString - function pointer to resolve 214 * @param resolveString - function pointer to resolve
215 * @return pointer to the function with name resolveString or NULL 215 * @return pointer to the function with name resolveString or NULL
216 */ 216 */
217Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 217Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
218 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 218 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
219 QLibrary *lib = new QLibrary(pluginFileName); 219 QLibrary *lib = new QLibrary(pluginFileName);
220 void *functionPointer = lib->resolve(resolveString); 220 void *functionPointer = lib->resolve(resolveString);
221 if( !functionPointer ){ 221 if( !functionPointer ){
222 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 222 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
223 delete lib; 223 delete lib;
224 return NULL; 224 return NULL;
225 } 225 }
226 226
227 // Try to get an object. 227 // Try to get an object.
228 Module *object = ((Module* (*)()) functionPointer)(); 228 Module *object = ((Module* (*)()) functionPointer)();
229 if(object == NULL){ 229 if(object == NULL){
230 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 230 qDebug("MainWindowImp: Couldn't create object, but did load library!");
231 delete lib; 231 delete lib;
232 return NULL; 232 return NULL;
233 } 233 }
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 382428c..4f09d6c 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -20,36 +20,36 @@ public:
20private slots: 20private slots:
21 void getAllInterfaces(); 21 void getAllInterfaces();
22 22
23 void addClicked(); 23 void addClicked();
24 void removeClicked(); 24 void removeClicked();
25 void configureClicked(); 25 void configureClicked();
26 void informationClicked(); 26 void informationClicked();
27 27
28 void addProfile(); 28 void addProfile();
29 void removeProfile(); 29 void removeProfile();
30 void changeProfile(); 30 void changeProfile();
31 31
32 void updateInterface(Interface *i); 32 void updateInterface(Interface *i);
33 void newProfileChanged(const QString& newText); 33 void newProfileChanged(const QString& newText);
34 34
35private: 35private:
36 void loadModules(QString path); 36 void loadModules(const QString &path);
37 37
38 Module* loadPlugin(QString pluginFileName, 38 Module* loadPlugin(const QString &pluginFileName,
39 QString resolveString = "create_plugin"); 39 const QString &resolveString = "create_plugin");
40 40
41 // For our local list of names 41 // For our local list of names
42 QMap<QString, Interface*> interfaceNames; 42 QMap<QString, Interface*> interfaceNames;
43 43
44 QMap<Module*, QLibrary*> libraries; 44 QMap<Module*, QLibrary*> libraries;
45 QMap<Interface*, QListViewItem*> items; 45 QMap<Interface*, QListViewItem*> items;
46 QMap<QListViewItem*, Interface*> interfaceItems; 46 QMap<QListViewItem*, Interface*> interfaceItems;
47 47
48 QMap<KProcess*, QString> threads; 48 QMap<KProcess*, QString> threads;
49 QStringList profiles; 49 QStringList profiles;
50 50
51 bool advancedUserMode; 51 bool advancedUserMode;
52 QString scheme; 52 QString scheme;
53}; 53};
54 54
55#endif 55#endif
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h
index 92b125a..2e6272b 100644
--- a/noncore/settings/networksettings/module.h
+++ b/noncore/settings/networksettings/module.h
@@ -9,33 +9,33 @@
9class QWidget; 9class QWidget;
10class QTabWidget; 10class QTabWidget;
11 11
12class Module : QObject{ 12class Module : QObject{
13 13
14signals: 14signals:
15 void updateInterface(Interface *i); 15 void updateInterface(Interface *i);
16 16
17public: 17public:
18 Module(){}; 18 Module(){};
19 19
20 /** 20 /**
21 * The current profile has been changed and the module should do any 21 * The current profile has been changed and the module should do any
22 * neccesary changes also. 22 * neccesary changes also.
23 * @param newProfile what the profile should be changed to. 23 * @param newProfile what the profile should be changed to.
24 */ 24 */
25 virtual void setProfile(QString newProfile) = 0; 25 virtual void setProfile(const QString &newProfile) = 0;
26 26
27 /** 27 /**
28 * get the icon name for this device. 28 * get the icon name for this device.
29 * @param Interface* can be used in determining the icon. 29 * @param Interface* can be used in determining the icon.
30 * @return QString the icon name (minus .png, .gif etc) 30 * @return QString the icon name (minus .png, .gif etc)
31 */ 31 */
32 virtual QString getPixmapName(Interface *) = 0; 32 virtual QString getPixmapName(Interface *) = 0;
33 33
34 /** 34 /**
35 * Check to see if the interface i is owned by this module. 35 * Check to see if the interface i is owned by this module.
36 * @param Interface* interface to check against 36 * @param Interface* interface to check against
37 * @return bool true if i is owned by this module, false otherwise. 37 * @return bool true if i is owned by this module, false otherwise.
38 */ 38 */
39 virtual bool isOwner(Interface *){ return false; }; 39 virtual bool isOwner(Interface *){ return false; };
40 40
41 /** 41 /**
@@ -57,30 +57,30 @@ public:
57 * @return QList<Interface> A list of interfaces that exsist that havn't 57 * @return QList<Interface> A list of interfaces that exsist that havn't
58 * been called by isOwner() 58 * been called by isOwner()
59 */ 59 */
60 virtual QList<Interface> getInterfaces() = 0; 60 virtual QList<Interface> getInterfaces() = 0;
61 61
62 /** 62 /**
63 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), 63 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
64 * modem ppp) 64 * modem ppp)
65 */ 65 */
66 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; 66 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
67 67
68 /** 68 /**
69 * Attempts to create a new interface from name 69 * Attempts to create a new interface from name
70 * @return Interface* NULL if it was unable to be created. 70 * @return Interface* NULL if it was unable to be created.
71 * @param name the type of interface to create 71 * @param name the type of interface to create
72 */ 72 */
73 virtual Interface *addNewInterface(QString name) = 0; 73 virtual Interface *addNewInterface(const QString &name) = 0;
74 74
75 /** 75 /**
76 * Attempts to remove the interface, doesn't delete i 76 * Attempts to remove the interface, doesn't delete i
77 * @return bool true if successfull, false otherwise. 77 * @return bool true if successfull, false otherwise.
78 */ 78 */
79 virtual bool remove(Interface* i) = 0; 79 virtual bool remove(Interface* i) = 0;
80 80
81}; 81};
82 82
83#endif 83#endif
84 84
85// module.h 85// module.h
86 86
diff --git a/noncore/settings/networksettings/wlan/infoimp.h b/noncore/settings/networksettings/wlan/infoimp.h
index 5311bea..8f7f0d6 100644
--- a/noncore/settings/networksettings/wlan/infoimp.h
+++ b/noncore/settings/networksettings/wlan/infoimp.h
@@ -1,23 +1,23 @@
1#ifndef INFOIMP_H 1#ifndef INFOIMP_H
2#define INFOIMP_H 2#define INFOIMP_H
3 3
4#include "info.h" 4#include "info.h"
5 5
6class QTimer; 6class QTimer;
7class WExtensions; 7//class WExtensions;
8 8
9class WlanInfoImp : public WlanInfo { 9class WlanInfoImp : public WlanInfo {
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 WlanInfoImp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 13 WlanInfoImp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
14 14
15private slots: 15private slots:
16 void update(); 16 void update();
17 17
18private: 18private:
19 //WExtensions *wExtensions; 19 //WExtensions *wExtensions;
20 QTimer *timer; 20 QTimer *timer;
21 21
22}; 22};
23 23
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp
index eb6fc42..6335ebc 100644
--- a/noncore/settings/networksettings/wlan/wextensions.cpp
+++ b/noncore/settings/networksettings/wlan/wextensions.cpp
@@ -3,34 +3,33 @@
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5 5
6#include <arpa/inet.h> 6#include <arpa/inet.h>
7#include <sys/socket.h> 7#include <sys/socket.h>
8#include <sys/ioctl.h> 8#include <sys/ioctl.h>
9 9
10#include <math.h> 10#include <math.h>
11 11
12#define PROCNETWIRELESS "/proc/net/wireless" 12#define PROCNETWIRELESS "/proc/net/wireless"
13#define IW_LOWER 0 13#define IW_LOWER 0
14#define IW_UPPER 256 14#define IW_UPPER 256
15 15
16/** 16/**
17 * Constructor. Sets hasWirelessExtensions 17 * Constructor. Sets hasWirelessExtensions
18 */ 18 */
19WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){ 19WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) {
20 interface = interfaceName;
21 fd = socket( AF_INET, SOCK_DGRAM, 0 ); 20 fd = socket( AF_INET, SOCK_DGRAM, 0 );
22 if(fd == -1) 21 if(fd == -1)
23 return; 22 return;
24 23
25 const char* buffer[200]; 24 const char* buffer[200];
26 memset( &iwr, 0, sizeof( iwr ) ); 25 memset( &iwr, 0, sizeof( iwr ) );
27 iwr.u.essid.pointer = (caddr_t) buffer; 26 iwr.u.essid.pointer = (caddr_t) buffer;
28 iwr.u.essid.length = IW_ESSID_MAX_SIZE; 27 iwr.u.essid.length = IW_ESSID_MAX_SIZE;
29 iwr.u.essid.flags = 0; 28 iwr.u.essid.flags = 0;
30 29
31 // check if it is an IEEE 802.11 standard conform 30 // check if it is an IEEE 802.11 standard conform
32 // wireless device by sending SIOCGIWESSID 31 // wireless device by sending SIOCGIWESSID
33 // which also gives back the Extended Service Set ID 32 // which also gives back the Extended Service Set ID
34 // (see IEEE 802.11 for more information) 33 // (see IEEE 802.11 for more information)
35 34
36 const char* iname = interface.latin1(); 35 const char* iname = interface.latin1();
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 689eae2..d4b4af9 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -31,33 +31,33 @@ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, W
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 settingsFileText = QStringList::split("\n", line, true); 37 settingsFileText = QStringList::split("\n", line, true);
38 parseSettingFile(); 38 parseSettingFile();
39 } 39 }
40 else 40 else
41 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); 41 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1());
42} 42}
43 43
44/** 44/**
45 * Change the profile for both wireless settings and network settings. 45 * Change the profile for both wireless settings and network settings.
46 */ 46 */
47void WLANImp::setProfile(QString &profile){ 47void WLANImp::setProfile(const QString &profile){
48 interfaceSetup->setProfile(profile); 48 interfaceSetup->setProfile(profile);
49 parseSettingFile(); 49 parseSettingFile();
50} 50}
51 51
52/** 52/**
53 * Parses the settings file that was read in and gets any setting from it. 53 * Parses the settings file that was read in and gets any setting from it.
54 */ 54 */
55void WLANImp::parseSettingFile(){ 55void WLANImp::parseSettingFile(){
56 bool foundCase = false; 56 bool foundCase = false;
57 bool found = false; 57 bool found = false;
58 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 58 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
59 QString line = (*it).simplifyWhiteSpace(); 59 QString line = (*it).simplifyWhiteSpace();
60 if(line.contains("case")) 60 if(line.contains("case"))
61 foundCase = true; 61 foundCase = true;
62 // See if we found our scheme to write or the sceme couldn't be found 62 // See if we found our scheme to write or the sceme couldn't be found
63 if((foundCase && line.contains("esac")) || 63 if((foundCase && line.contains("esac")) ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp.h b/noncore/settings/networksettings/wlan/wlanimp.h
index f88e550..df599af 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.h
+++ b/noncore/settings/networksettings/wlan/wlanimp.h
@@ -1,31 +1,31 @@
1#ifndef WLANIMP_H 1#ifndef WLANIMP_H
2#define WLANIMP_H 2#define WLANIMP_H
3 3
4#include "wlan.h" 4#include "wlan.h"
5#include <qstringlist.h> 5#include <qstringlist.h>
6 6
7class InterfaceSetupImp; 7class InterfaceSetupImp;
8class Interface; 8class Interface;
9class Config; 9class Config;
10 10
11class WLANImp : public WLAN { 11class WLANImp : public WLAN {
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); 15 WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
16 void setProfile(QString &profile); 16 void setProfile(const QString &profile);
17 17
18protected: 18protected:
19 void accept(); 19 void accept();
20 20
21private: 21private:
22 void parseSettingFile(); 22 void parseSettingFile();
23 void changeAndSaveSettingFile(); 23 void changeAndSaveSettingFile();
24 24
25 InterfaceSetupImp *interfaceSetup; 25 InterfaceSetupImp *interfaceSetup;
26 QStringList settingsFileText; 26 QStringList settingsFileText;
27 QString currentProfile; 27 QString currentProfile;
28}; 28};
29 29
30#endif 30#endif
31 31
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index b14fc0a..3979e60 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -13,33 +13,33 @@
13 */ 13 */
14WLANModule::WLANModule() : Module() { 14WLANModule::WLANModule() : Module() {
15} 15}
16 16
17/** 17/**
18 * Delete any interfaces that we own. 18 * Delete any interfaces that we own.
19 */ 19 */
20WLANModule::~WLANModule(){ 20WLANModule::~WLANModule(){
21 Interface *i; 21 Interface *i;
22 for ( i=list.first(); i != 0; i=list.next() ) 22 for ( i=list.first(); i != 0; i=list.next() )
23 delete i; 23 delete i;
24} 24}
25 25
26/** 26/**
27 * Change the current profile 27 * Change the current profile
28 */ 28 */
29void WLANModule::setProfile(QString newProfile){ 29void WLANModule::setProfile(const QString &newProfile){
30 profile = newProfile; 30 profile = newProfile;
31} 31}
32 32
33/** 33/**
34 * get the icon name for this device. 34 * get the icon name for this device.
35 * @param Interface* can be used in determining the icon. 35 * @param Interface* can be used in determining the icon.
36 * @return QString the icon name (minus .png, .gif etc) 36 * @return QString the icon name (minus .png, .gif etc)
37 */ 37 */
38QString WLANModule::getPixmapName(Interface* ){ 38QString WLANModule::getPixmapName(Interface* ){
39 return "wlan"; 39 return "wlan";
40} 40}
41 41
42/** 42/**
43 * Check to see if the interface i is owned by this module. 43 * Check to see if the interface i is owned by this module.
44 * @param Interface* interface to check against 44 * @param Interface* interface to check against
45 * @return bool true if i is owned by this module, false otherwise. 45 * @return bool true if i is owned by this module, false otherwise.
@@ -81,33 +81,33 @@ QWidget *WLANModule::information(Interface *i){
81 81
82/** 82/**
83 * Get all active (up or down) interfaces 83 * Get all active (up or down) interfaces
84 * @return QList<Interface> A list of interfaces that exsist that havn't 84 * @return QList<Interface> A list of interfaces that exsist that havn't
85 * been called by isOwner() 85 * been called by isOwner()
86 */ 86 */
87QList<Interface> WLANModule::getInterfaces(){ 87QList<Interface> WLANModule::getInterfaces(){
88 return list; 88 return list;
89} 89}
90 90
91/** 91/**
92 * Attempt to add a new interface as defined by name 92 * Attempt to add a new interface as defined by name
93 * @param name the name of the type of interface that should be created given 93 * @param name the name of the type of interface that should be created given
94 * by possibleNewInterfaces(); 94 * by possibleNewInterfaces();
95 * @return Interface* NULL if it was unable to be created. 95 * @return Interface* NULL if it was unable to be created.
96 */ 96 */
97Interface *WLANModule::addNewInterface(QString ){ 97Interface *WLANModule::addNewInterface(const QString &){
98 // We can't add a 802.11 interface, either the hardware will be there 98 // We can't add a 802.11 interface, either the hardware will be there
99 // or it wont. 99 // or it wont.
100 return NULL; 100 return NULL;
101} 101}
102 102
103/** 103/**
104 * Attempts to remove the interface, doesn't delete i 104 * Attempts to remove the interface, doesn't delete i
105 * @return bool true if successfull, false otherwise. 105 * @return bool true if successfull, false otherwise.
106 */ 106 */
107bool WLANModule::remove(Interface*){ 107bool WLANModule::remove(Interface*){
108 // Can't remove a hardware device, you can stop it though. 108 // Can't remove a hardware device, you can stop it though.
109 return false; 109 return false;
110} 110}
111 111
112// wlanmodule.cpp 112// wlanmodule.cpp
113 113
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.h b/noncore/settings/networksettings/wlan/wlanmodule.h
index a81ccff..3a54de6 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.h
+++ b/noncore/settings/networksettings/wlan/wlanmodule.h
@@ -1,39 +1,39 @@
1#ifndef WLAN_MODULE_H 1#ifndef WLAN_MODULE_H
2#define WLAN_MODULE_H 2#define WLAN_MODULE_H
3 3
4#include "module.h" 4#include "module.h"
5 5
6class WLANModule : Module{ 6class WLANModule : Module{
7 7
8signals: 8signals:
9 void updateInterface(Interface *i); 9 void updateInterface(Interface *i);
10 10
11public: 11public:
12 WLANModule(); 12 WLANModule();
13 ~WLANModule(); 13 ~WLANModule();
14 14
15 virtual void setProfile(QString newProfile); 15 void setProfile(const QString &newProfile);
16 virtual bool isOwner(Interface *); 16 bool isOwner(Interface *);
17 virtual QWidget *configure(Interface *i); 17 QWidget *configure(Interface *i);
18 virtual QWidget *information(Interface *i); 18 QWidget *information(Interface *i);
19 virtual QList<Interface> getInterfaces(); 19 QList<Interface> getInterfaces();
20 virtual void possibleNewInterfaces(QMap<QString, QString> &){}; 20 void possibleNewInterfaces(QMap<QString, QString> &){};
21 virtual Interface *addNewInterface(QString name); 21 Interface *addNewInterface(const QString &name);
22 virtual bool remove(Interface* i); 22 bool remove(Interface* i);
23 virtual QString getPixmapName(Interface* i); 23 QString getPixmapName(Interface* i);
24 24
25private: 25private:
26 QList<Interface> list; 26 QList<Interface> list;
27 QString profile; 27 QString profile;
28 28
29}; 29};
30 30
31extern "C" 31extern "C"
32{ 32{
33 void* create_plugin() { 33 void* create_plugin() {
34 return new WLANModule(); 34 return new WLANModule();
35 } 35 }
36}; 36};
37 37
38#endif 38#endif
39 39