summaryrefslogtreecommitdiff
Side-by-side diff
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 @@
CLEAN UP
-Write a class that parses /proc and not ifconfig
-
udchcp needs to output the dhcp information so interfaces can read it
interfacesetupimp really doesn't need a interface* pointer
Possible other modules to write: ppp, ipsec, bluetooth, ipchains
PPP module needs to scan pppd.tdb to see what is currently active
WLAN - add possiblity to input text or hex without knowing "s:"
+Interface 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
@@ -1,38 +1,37 @@
#include "addconnectionimp.h"
#include <qlistview.h>
#include <qlist.h>
#include <qlabel.h>
#include <qheader.h>
/**
* Constructor
*/
AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){
connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed()));
registeredServicesList->header()->hide();
};
/**
* The current item changed, update the discription.
*/
void AddConnectionImp::changed(){
QListViewItem *item = registeredServicesList->currentItem();
- if(item){
+ if(item)
help->setText(list[item->text(0)]);
- }
}
/**
* Save a copy of newList for the discriptions and append them all to the view
* @param newList the new list of possible interfaces
*/
-void AddConnectionImp::addConnections(QMap<QString, QString> newList){
+void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){
list = newList;
QMap<QString, QString>::Iterator it;
for( it = list.begin(); it != list.end(); ++it )
QListViewItem *item = new QListViewItem(registeredServicesList, it.key());
registeredServicesList->setCurrentItem(registeredServicesList->firstChild());
}
// addserviceimp.cpp
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 @@
#ifndef ADDCONNECTIONIMP_H
#define ADDCONNECTIONIMP_H
#include "addconnection.h"
#include <qmap.h>
#include <qlist.h>
class QListViewItem;
class AddConnectionImp : public AddConnection {
Q_OBJECT
public:
AddConnectionImp(QWidget *parent=0, const char *name=0, WFlags f=0);
- void addConnections(QMap<QString, QString> newList);
+ void addConnections(const QMap<QString, QString> &newList);
private slots:
void changed();
private:
QMap<QString, QString> list;
};
#endif
// addconectionimp.h
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
@@ -1,93 +1,93 @@
#include "interface.h"
#include <qdatetime.h>
#include <qfile.h>
#include <qdir.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#define IFCONFIG "/sbin/ifconfig"
#define DHCP_INFO_DIR "/etc/dhcpc"
#include <stdio.h>
#include <stdlib.h>
Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
refresh();
}
/**
* Set status
* @param newStatus - the new status
* emit updateInterface
*/
void Interface::setStatus(bool newStatus){
if(status != newStatus){
status = newStatus;
refresh();
}
};
/**
* Set if attached or not (802.11 card pulled out for example)
* @param isAttached - if attached
* emit updateInterface
*/
void Interface::setAttached(bool isAttached){
attached = isAttached;
emit(updateInterface(this));
};
/**
* Set Hardware name
* @param name - the new name
* emit updateInterface
*/
-void Interface::setHardwareName(QString name){
+void Interface::setHardwareName(const QString &name){
hardwareName = name;
emit(updateInterface(this));
};
/**
* Set Module owner
* @param owner - the new owner
* emit updateInterface
*/
void Interface::setModuleOwner(Module *owner){
moduleOwner = owner;
emit(updateInterface(this));
};
/**
* Try to start the interface.
*/
void Interface::start(){
// check to see if we are already running.
if(true == status){
emit (updateMessage("Unable to start interface,\n already started"));
return;
}
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
// See if it was successfull...
if(ret != 0){
emit (updateMessage("Starting interface failed."));
return;
}
status = true;
refresh();
emit (updateMessage("Start successfull"));
}
/**
* Try to stop the interface.
*/
void Interface::stop(){
// check to see if we are already stopped.
if(false == status){
emit (updateMessage("Unable to stop interface,\n already stopped"));
return;
}
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
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
@@ -1,72 +1,71 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <qstring.h>
#include <qobject.h>
class Module;
class Interface : public QObject{
Q_OBJECT
signals:
void updateInterface(Interface *i);
void updateMessage(const QString &message);
public:
Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
- virtual ~Interface(){};
- virtual QString getInterfaceName(){ QString n(this->name()); return n; };
+ QString getInterfaceName(){ QString n(this->name()); return n; };
- virtual bool getStatus(){ return status; };
- virtual void setStatus(bool newStatus);
+ bool getStatus(){ return status; };
+ void setStatus(bool newStatus);
- virtual bool isAttached(){ return attached; };
- virtual void setAttached(bool isAttached=false);
+ bool isAttached(){ return attached; };
+ void setAttached(bool isAttached=false);
- virtual QString getHardwareName(){ return hardwareName; };
- virtual void setHardwareName(QString name="Unknown");
+ QString getHardwareName(){ return hardwareName; };
+ void setHardwareName(const QString &name="Unknown");
- virtual Module* getModuleOwner(){ return moduleOwner; };
- virtual void setModuleOwner(Module *owner=NULL);
+ Module* getModuleOwner(){ return moduleOwner; };
+ void setModuleOwner(Module *owner=NULL);
// inet information.
QString getMacAddress(){ return macAddress; };
QString getIp(){ return ip; };
QString getSubnetMask(){ return subnetMask; };
QString getBroadcast(){ return broadcast; };
bool isDhcp(){ return dhcp; };
QString getDhcpServerIp(){ return dhcpServerIp; };
QString getLeaseObtained(){ return leaseObtained; };
QString getLeaseExpires(){ return leaseExpires; };
public slots:
bool refresh();
void start();
void stop();
void restart();
private:
// Interface information
bool status;
bool attached;
QString hardwareName;
Module *moduleOwner;
// Network information
QString macAddress;
QString ip;
QString broadcast;
QString subnetMask;
bool dhcp;
QString dhcpServerIp;
QString leaseObtained;
QString leaseExpires;
};
#endif
// interface.h
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
@@ -25,198 +25,198 @@ Interfaces::Interfaces(QString useInterfacesFile){
qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
currentIface = interfaces.end();
currentMapping = interfaces.end();
return;
}
QTextStream stream( &file );
QString line;
while ( !stream.eof() ) {
line += stream.readLine();
line += "\n";
}
file.close();
interfaces = QStringList::split("\n", line, true);
currentIface = interfaces.end();
currentMapping = interfaces.end();
}
/**
* Get a list of all interfaces in the interface file. Usefull for
* hardware that is not currently connected such as an 802.11b card
* not plugged in, but configured for when it is plugged in.
* @return Return string list of interfaces.
**/
QStringList Interfaces::getInterfaceList(){
QStringList list;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains(IFACE) && line.at(0) != '#'){
line = line.mid(QString(IFACE).length() +1, line.length());
line = line.simplifyWhiteSpace();
int findSpace = line.find(" ");
if( findSpace >= 0){
line = line.mid(0, findSpace);
list.append(line);
}
}
}
return list;
}
/**
* Find out if interface is in an "auto" group or not.
* Report any duplicates such as eth0 being in two differnt auto's
* @param interface interface to check to see if it is on or not.
* @return true is interface is in auto
*/
-bool Interfaces::isAuto(QString interface){
+bool Interfaces::isAuto(const QString &interface){
QStringList autoLines = interfaces.grep(QRegExp(AUTO));
QStringList awi = autoLines.grep(QRegExp(interface));
if(awi.count() > 1)
qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
if(awi.count() < 1)
return false;
return true;
}
/**
* Attempt to set the auto option for interface to setAuto.
* @param interface the interface to set
* @param setAuto the value to set interface to.
* @return false if already set to setAuto.
* */
-bool Interfaces::setAuto(QString interface, bool setAuto){
+bool Interfaces::setAuto(const QString &interface, bool setAuto){
// Don't need to set it if it is already set.
if(isAuto(interface) == setAuto)
return false;
bool changed = false;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
if((*it).contains(AUTO)){
//We know that they are not in any group so let add to this auto.
if(setAuto){
(*it) = (*it) += " " + interface;
// Don't care to have such thins as: auto eth0 lo usb0
(*it) = (*it).simplifyWhiteSpace();
changed = true;
break;
}
else{
if((*it).contains(interface)){
(*it) = (*it).replace(QRegExp(interface), "");
// clean up
QString line = (*it).simplifyWhiteSpace();
line = line.replace(QRegExp(" "),"");
if(line == AUTO)
(*it) = "";
changed = true;
// Don't break because we want to make sure we remove all cases.
}
}
}
}
if(changed == false){
if(setAuto == true)
interfaces.append(QString(AUTO" %1").arg(interface));
else{
qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1());
}
}
return true;
}
/**
* Set the current interface to interface. This needs to be done before you
* can call getFamily(), getMethod, and get/setOption().
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @return bool true if it is successfull.
*/
bool Interfaces::setInterface(QString interface){
interface = interface.simplifyWhiteSpace();
interface = interface.replace(QRegExp(" "), "");
return setStanza(IFACE, interface, currentIface);
}
/**
* A quick helper funtion to see if the current interface is set.
* @return bool true if set, false otherwise.
*/
bool Interfaces::isInterfaceSet(){
return (currentIface != interfaces.end());
}
/**
* Add a new interface of with the settings - family and method
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @param family the family of this interface inet or inet, ipx or inet6
* Must of one of the families defined in interfaces.h
* @param method for the family. see interfaces man page for family methods.
* @return true if successfull.
*/
-bool Interfaces::addInterface(QString interface, QString family, QString method){
+bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
if(acceptedFamily.contains(family)==0)
return false;
- interface = interface.simplifyWhiteSpace();
- interface = interface.replace(QRegExp(" "), "");
+ QString newInterface = interface.simplifyWhiteSpace();
+ newInterface = newInterface.replace(QRegExp(" "), "");
interfaces.append("");
- interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method));
+ interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
return true;
}
/**
* Copies interface with name interface to name newInterface
* @param newInterface name of the new interface.
* @return bool true if successfull
*/
-bool Interfaces::copyInterface(QString interface, QString newInterface){
+bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
if(!setInterface(interface)) return false;
QStringList::Iterator it = currentIface;
it++;
bool error;
addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
if(!setInterface(newInterface)) return false;
QStringList::Iterator newIface = currentIface;
newIface++;
for ( ; it != interfaces.end(); ++it ){
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
break;
newIface = interfaces.insert(newIface, *it);
}
return true;
}
/**
* Remove the currently selected interface and all of its options.
* @return bool if successfull or not.
*/
bool Interfaces::removeInterface(){
if(currentIface == interfaces.end())
return false;
(*currentIface) = "";
return removeAllInterfaceOptions();
}
/**
* Gets the hardware name of the interface that is currently selected.
* @return QString name of the hardware interface (eth0, usb2, wlan1...).
* @param error set to true if any error occurs, false otherwise.
*/
QString Interfaces::getInterfaceName(bool &error){
if(currentIface == interfaces.end()){
error = true;
return QString();
}
QString line = (*currentIface);
line = line.mid(QString(IFACE).length() +1, line.length());
line = line.simplifyWhiteSpace();
int findSpace = line.find(" ");
if( findSpace < 0){
error = true;
return QString();
@@ -235,392 +235,394 @@ QString Interfaces::getInterfaceFamily(bool &error){
if(error){
error = true;
return QString();
}
QString line = (*currentIface);
line = line.mid(QString(IFACE).length() +1, line.length());
line = line.mid(name.length()+1, line.length());
line = line.simplifyWhiteSpace();
int findSpace = line.find(" ");
if( findSpace < 0){
error = true;
return QString();
}
error = false;
return line.mid(0, findSpace);
}
/**
* Gets the method of the interface that is currently selected.
* @return QString name of the method such as staic or dhcp.
* See the man page of interfaces for possible methods depending on the family.
* @param error set to true if any error occurs, false otherwise.
*/
QString Interfaces::getInterfaceMethod(bool &error){
QString name = getInterfaceName(error);
if(error){
error = true;
return QString();
}
QString family = getInterfaceFamily(error);
if(error){
error = true;
return QString();
}
QString line = (*currentIface);
line = line.mid(QString(IFACE).length()+1, line.length());
line = line.mid(name.length()+1, line.length());
line = line.mid(family.length()+1, line.length());
line = line.simplifyWhiteSpace();
error = false;
return line;
}
/**
* Sets the interface name to newName.
* @param newName the new name of the interface. All whitespace is removed.
* @return bool true if successfull.
*/
-bool Interfaces::setInterfaceName(QString newName){
+bool Interfaces::setInterfaceName(const QString &newName){
if(currentIface == interfaces.end())
return false;
- newName = newName.simplifyWhiteSpace();
- newName = newName.replace(QRegExp(" "), "");
+ QString name = newName.simplifyWhiteSpace();
+ name = name.replace(QRegExp(" "), "");
bool returnValue = false;
- (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
+ (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
return !returnValue;
}
/**
* Sets the interface family to newName.
* @param newName the new name of the interface. Must be one of the families
* defined in the interfaces.h file.
* @return bool true if successfull.
*/
-bool Interfaces::setInterfaceFamily(QString newName){
+bool Interfaces::setInterfaceFamily(const QString &newName){
if(currentIface == interfaces.end())
return false;
if(acceptedFamily.contains(newName)==0)
return false;
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
return !returnValue;
}
/**
* Sets the interface method to newName
* @param newName the new name of the interface
* @return bool true if successfull.
*/
-bool Interfaces::setInterfaceMethod(QString newName){
+bool Interfaces::setInterfaceMethod(const QString &newName){
if(currentIface == interfaces.end())
return false;
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
return !returnValue;
}
/**
* Get a value for an option in the currently selected interface. For example
* calling getInterfaceOption("address") on the following stanza would
* return 192.168.1.1.
* iface eth0 static
* address 192.168.1.1
* @param option the options to get the value.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
-QString Interfaces::getInterfaceOption(QString option, bool &error){
+QString Interfaces::getInterfaceOption(const QString &option, bool &error){
return getOption(currentIface, option, error);
}
/**
* Set a value for an option in the currently selected interface. If option
* doesn't exist then it is added along with the value.
* @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
-bool Interfaces::setInterfaceOption(QString option, QString value){
+bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
return setOption(currentIface, option, value);
}
/**
* Removes a value for an option in the currently selected interface.
* @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
-bool Interfaces::removeInterfaceOption(QString option, QString value){
+bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
return removeOption(currentIface, option, value);
}
/**
* Removes all of the options from the currently selected interface.
* @return bool error if if successfull
*/
bool Interfaces::removeAllInterfaceOptions(){
return removeAllOptions(currentIface);
}
/**
* Set the current map to interface's map. This needs to be done before you
* can call addMapping(), set/getMap(), and get/setScript().
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @return bool true if it is successfull.
*/
-bool Interfaces::setMapping(QString interface){
- interface = interface.simplifyWhiteSpace();
- interface = interface.replace(QRegExp(" "), "");
- return setStanza(MAPPING, interface, currentMapping);
+bool Interfaces::setMapping(const QString &interface){
+ QString interfaceName = interface.simplifyWhiteSpace();
+ interfaceName = interfaceName.replace(QRegExp(" "), "");
+ return setStanza(MAPPING, interfaceName, currentMapping);
}
/**
* Adds a new Mapping to the interfaces file with interfaces.
* @param interface the name(s) of the interfaces to set to this mapping
*/
-void Interfaces::addMapping(QString option){
+void Interfaces::addMapping(const QString &option){
interfaces.append("");
interfaces.append(QString(MAPPING " %1").arg(option));
}
/**
* Remove the currently selected map and all of its options.
* @return bool if successfull or not.
*/
bool Interfaces::removeMapping(){
if(currentMapping == interfaces.end())
return false;
(*currentMapping) = "";
return removeAllOptions(currentMapping);
}
/**
* Set a map option within a mapping.
* @param map map to use
* @param value value to go with map
* @return bool true if it is successfull.
*/
-bool Interfaces::setMap(QString map, QString value){
+bool Interfaces::setMap(const QString &map, const QString &value){
return setOption(currentMapping, map, value);
}
/**
* Removes a map option within a mapping.
* @param map map to use
* @param value value to go with map
* @return bool true if it is successfull.
*/
-bool Interfaces::removeMap(QString map, QString value){
+bool Interfaces::removeMap(const QString &map, const QString &value){
return removeOption(currentMapping, map, value);
}
/**
* Get a map value within a mapping.
* @param map map to get value of
* @param bool true if it is successfull.
* @return value that goes to the map
*/
-QString Interfaces::getMap(QString map, bool &error){
+QString Interfaces::getMap(const QString &map, bool &error){
return getOption(currentMapping, map, error);
}
/**
* Sets a script value of the current mapping to argument.
* @param argument the script name.
* @return true if successfull.
*/
-bool Interfaces::setScript(QString argument){
+bool Interfaces::setScript(const QString &argument){
return setOption(currentMapping, "script", argument);
}
/**
* @param error true if could not retrieve the current script argument.
* @return QString the argument of the script for the current mapping.
*/
QString Interfaces::getScript(bool &error){
return getOption(currentMapping, "script", error);
}
+
+
/**
* Helper function used to parse through the QStringList and put pointers in
* the correct place.
* @param stanza The stanza (auto, iface, mapping) to look for.
* @param option string that must be in the stanza's main line.
* @param interator interator to place at location of stanza if successfull.
* @return bool true if the stanza is found.
*/
-bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){
+bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
bool found = false;
iterator = interfaces.end();
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
uint point = line.find(option);
bool valid = true;
if(point > 0){
// There are more chars in the line. check +1
if(line.at(point-1) != ' ')
valid = false;
}
point += option.length();
if(point < line.length()-1){
// There are more chars in the line. check -1
if(line.at(point) != ' ')
valid = false;
}
if(valid){
if(found == true){
qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
}
found = true;
iterator = it;
}
}
}
return found;
}
/**
* Sets a value of an option in a stanza
* @param start the start of the stanza
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
-bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){
+bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
if(!found && value != ""){
// Got to the end of the stanza without finding it, so append it.
interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
}
found = true;
break;
}
if((*it).contains(option) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
if(found)
qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
found = true;
(*it) = QString("\t%1 %2").arg(option).arg(value);
}
}
if(!found){
QStringList::Iterator p = start;
interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
found = true;
}
return found;
}
/**
* Removes a option in a stanza
* @param start the start of the stanza
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
-bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){
+bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
// got to the end without finding it
break;
}
if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
if(found)
qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
found = true;
(*it) = "";
}
}
return found;
}
/**
* Removes all options in a stanza
* @param start the start of the stanza
* @return bool true if successfull, false otherwise.
*/
-bool Interfaces::removeAllOptions(QStringList::Iterator start){
+bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
if(start == interfaces.end())
return false;
QStringList::Iterator it = start;
it = ++it;
for (; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
it = interfaces.remove(it);
it = --it;
}
// Leave a space between this interface and the next.
interfaces.insert(it, QString(""));
return true;
}
/**
* Gets a value of an option in a stanza
* @param start the start of the stanza
* @param option the option to use when getting the value.
* @param bool true if errors false otherwise.
* @return QString the value of option QString::null() if error == true.
*/
-QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){
+QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){
if(start == interfaces.end()){
error = false;
return QString();
}
QString value;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
if((*it).contains(option) && (*it).at(0) != '#'){
if(found)
qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
found = true;
QString line = (*it).simplifyWhiteSpace();
int space = line.find(" ", option.length());
if(space != -1)
value = line.mid(space+1, line.length());
else
qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1());
}
}
error = !found;
return value;
}
/**
* Write out the interfaces file to the file passed into the constructor.
* Removes any excess blank lines over 1 line long.
* @return bool true if successfull, false if not.
*/
bool Interfaces::write(){
QFile::remove(interfacesFile);
QFile file(interfacesFile);
if (!file.open(IO_ReadWrite)){
qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
return false;
}
QTextStream stream( &file );
int whiteSpaceCount = 0;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
line = line.replace(QRegExp(" "),"");
if(line.length() == 0)
whiteSpaceCount++;
else
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
@@ -1,76 +1,76 @@
#ifndef INTERFACES_H
#define INTERFACES_H
#include <qstring.h>
#include <qstringlist.h>
#define INTERFACES_LOOPBACK "loopback"
#define INTERFACES_FAMILY_INET "inet"
#define INTERFACES_FAMILY_IPX "ipx"
#define INTERFACES_FAMILY_INET6 "inet6"
#define INTERFACES_METHOD_DHCP "dhcp"
#define INTERFACES_METHOD_STATIC "static"
#define INTERFACES_METHOD_PPP "ppp"
/**
* This class provides a clean frontend for parsing the network interfaces file.
* It provides helper functions to minipulate the options within the file.
* See the interfaces man page for the syntax rules.
*/
class Interfaces {
public:
Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
QStringList getInterfaceList();
- bool isAuto(QString interface);
- bool setAuto(QString interface, bool setAuto);
+ bool isAuto(const QString &interface);
+ bool setAuto(const QString &interface, bool setAuto);
bool removeInterface();
- bool addInterface(QString interface, QString family, QString method);
- bool copyInterface(QString oldInterface, QString newInterface);
+ bool addInterface(const QString &interface, const QString &family, const QString &method);
+ bool copyInterface(const QString &oldInterface, const QString &newInterface);
bool setInterface(QString interface);
- bool isInterfaceSet();
+ inline bool isInterfaceSet();
QString getInterfaceName(bool &error);
- bool setInterfaceName(QString newName);
+ bool setInterfaceName(const QString &newName);
QString getInterfaceFamily(bool &error);
- bool setInterfaceFamily(QString newName);
+ bool setInterfaceFamily(const QString &newName);
QString getInterfaceMethod(bool &error);
- bool setInterfaceMethod(QString newName);
- QString getInterfaceOption(QString option, bool &error);
- bool setInterfaceOption(QString option, QString value);
- bool removeInterfaceOption(QString option, QString value);
- bool removeAllInterfaceOptions();
+ bool setInterfaceMethod(const QString &newName);
+ inline QString getInterfaceOption(const QString &option, bool &error);
+ inline bool setInterfaceOption(const QString &option, const QString &value);
+ inline bool removeInterfaceOption(const QString &option, const QString &value);
+ inline bool removeAllInterfaceOptions();
- bool setMapping(QString interface);
+ bool setMapping(const QString &interface);
bool removeMapping();
- void addMapping(QString options);
- bool setMap(QString map, QString value);
- bool removeMap(QString map, QString value);
- QString getMap(QString map, bool &error);
- bool setScript(QString);
- QString getScript(bool &error);
+ inline void addMapping(const QString &options);
+ inline bool setMap(const QString &map, const QString &value);
+ inline bool removeMap(const QString &map, const QString &value);
+ inline QString getMap(const QString &map, bool &error);
+ inline bool setScript(const QString &argument);
+ inline QString getScript(bool &error);
bool write();
private:
- bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator);
- bool setOption(QStringList::Iterator start, QString option, QString value);
- bool removeOption(QStringList::Iterator start, QString option, QString value);
- QString getOption(QStringList::Iterator start, QString option, bool &error);
- bool removeAllOptions(QStringList::Iterator start);
+ bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
+ bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
+ bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
+ QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
+ bool removeAllOptions(const QStringList::Iterator &start);
QString interfacesFile;
QStringList interfaces;
QStringList::Iterator currentIface;
QStringList::Iterator currentMapping;
QStringList acceptedFamily;
};
#endif
// interfaces
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
@@ -54,96 +54,100 @@
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>dhcpCheckBox</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>DHCP</string>
</property>
<property stdset="1">
<name>checked</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>leaseHoursLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Requested Lease</string>
</property>
</widget>
<widget>
<class>QSpinBox</class>
<property stdset="1">
<name>name</name>
<cstring>leaseTime</cstring>
</property>
<property stdset="1">
<name>suffix</name>
<string> hours</string>
</property>
<property stdset="1">
<name>maxValue</name>
<number>87600</number>
</property>
<property stdset="1">
<name>minValue</name>
<number>1</number>
</property>
<property stdset="1">
+ <name>lineStep</name>
+ <number>24</number>
+ </property>
+ <property stdset="1">
<name>value</name>
<number>168</number>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QGroupBox</class>
<property stdset="1">
<name>name</name>
<cstring>staticGroupBox</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Box</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>title</name>
<string>Static Ip Configuration</string>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="1" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel5</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Subnet Mask</string>
</property>
</widget>
@@ -206,79 +210,101 @@
<property stdset="1">
<name>name</name>
<cstring>TextLabel3</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Second DNS</string>
</property>
</widget>
<widget row="3" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>firstDNSLineEdit</cstring>
</property>
</widget>
<widget row="4" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>secondDNSLineEdit</cstring>
</property>
</widget>
</grid>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer9</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
+<customwidgets>
+ <customwidget>
+ <class>QWidget</class>
+ <header location="local">qwidget.h</header>
+ <sizehint>
+ <width>100</width>
+ <height>100</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>7</verdata>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image>
+ <name>image0</name>
+ <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
+ </image>
+</images>
<connections>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>leaseHoursLabel</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>leaseTime</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>staticGroupBox</receiver>
<slot>setDisabled(bool)</slot>
</connection>
</connections>
<tabstops>
<tabstop>autoStart</tabstop>
<tabstop>dhcpCheckBox</tabstop>
<tabstop>leaseTime</tabstop>
<tabstop>ipAddressEdit</tabstop>
<tabstop>subnetMaskEdit</tabstop>
<tabstop>gatewayEdit</tabstop>
<tabstop>firstDNSLineEdit</tabstop>
<tabstop>secondDNSLineEdit</tabstop>
</tabstops>
</UI>
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
@@ -1,56 +1,55 @@
#ifndef INTERFACESETUPIMP_H
#define INTERFACESETUPIMP_H
#include "interfacesetup.h"
#include <qdialog.h>
class Interface;
class Interfaces;
class InterfaceSetupImp : public InterfaceSetup {
Q_OBJECT
public:
InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0);
bool saveChanges();
public slots:
void setProfile(const QString &profile);
bool saveSettings();
private:
Interfaces *interfaces;
Interface *interface;
-
};
#include <qlayout.h>
class InterfaceSetupImpDialog : public QDialog {
Q_OBJECT
public:
InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){
QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this );
setCaption("Interface Setup");
interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl);
InterfaceSetupLayout->addWidget( interfaceSetup );
};
void setProfile(QString &profile){ interfaceSetup->setProfile(profile);};
private:
InterfaceSetupImp *interfaceSetup;
protected slots:
void accept(){
if(interfaceSetup->saveChanges())
QDialog::accept();
};
};
#endif
// interfacesetupimp.h
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
@@ -1,81 +1,81 @@
#include "mainwindowimp.h"
#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
#include "interfaces.h"
#include "module.h"
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qlist.h>
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#include <net/if.h>
#include <sys/ioctl.h>
#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
-MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
+MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false), scheme(DEFAULT_SCHEME){
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
// Load connections.
loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
getAllInterfaces();
Interfaces i;
QStringList list = i.getInterfaceList();
QMap<QString, Interface*>::Iterator it;
for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
bool found = false;
for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
if(it.key() == (*ni))
found = true;
}
if(!found){
if(!(*ni).contains("_")){
Interface *i = new Interface(this, *ni, false);
i->setAttached(false);
i->setHardwareName("Disconnected");
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
}
}
//getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
QFile file(scheme);
if ( file.open(IO_ReadOnly) ) { // file opened successfully
@@ -144,122 +144,122 @@ void MainWindowImp::getAllInterfaces(){
int flags;
struct sockaddr_in *sinptr;
Interface *i = NULL;
switch (ifr->ifr_addr.sa_family){
case AF_INET:
sinptr = (struct sockaddr_in *) &ifr->ifr_addr;
flags=0;
struct ifreq ifcopy;
ifcopy=*ifr;
result=ioctl(sockfd,SIOCGIFFLAGS,&ifcopy);
flags=ifcopy.ifr_flags;
i = new Interface(this, ifr->ifr_name, false);
i->setAttached(true);
if ((flags & IFF_UP) == IFF_UP)
i->setStatus(true);
else
i->setStatus(false);
if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
i->setHardwareName("Ethernet");
else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
i->setHardwareName("Point to Point");
else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
i->setHardwareName("Multicast");
else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
i->setHardwareName("Loopback");
else
i->setHardwareName("Unknown");
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
break;
default:
qDebug(ifr->ifr_name);
qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1());
break;
}
}
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
*/
-void MainWindowImp::loadModules(QString path){
+void MainWindowImp::loadModules(const QString &path){
//qDebug(path.latin1());
QDir d(path);
if(!d.exists())
return;
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
if(fi->fileName().contains(".so")){
loadPlugin(path + "/" + fi->fileName());
}
++it;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
-Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
+Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
//qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
delete lib;
return NULL;
}
// Try to get an object.
Module *object = ((Module* (*)()) functionPointer)();
if(object == NULL){
qDebug("MainWindowImp: Couldn't create object, but did load library!");
delete lib;
return NULL;
}
// Store for deletion later
libraries.insert(object, lib);
return object;
}
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked(){
QMap<Module*, QLibrary*>::Iterator it;
QMap<QString, QString> list;
QMap<QString, Module*> newInterfaceOwners;
//list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
//list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()){
(it.key())->possibleNewInterfaces(list);
}
}
// See if the list has anything that we can add.
if(list.count() == 0){
QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
return;
}
AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
addNewConnection.addConnections(list);
addNewConnection.showMaximized();
if(QDialog::Accepted == addNewConnection.exec()){
QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
if(!item)
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
@@ -1,58 +1,58 @@
#ifndef MAINWINOWIMP_H
#define MAINWINOWIMP_H
#include "mainwindow.h"
#include <qmap.h>
#include <qstringlist.h>
class Module;
class Interface;
class QLibrary;
class KProcess;
class MainWindowImp : public MainWindow {
Q_OBJECT
public:
MainWindowImp(QWidget *parent=0, const char *name=0);
~MainWindowImp();
private slots:
void getAllInterfaces();
void addClicked();
void removeClicked();
void configureClicked();
void informationClicked();
void addProfile();
void removeProfile();
void changeProfile();
void updateInterface(Interface *i);
void newProfileChanged(const QString& newText);
private:
- void loadModules(QString path);
+ void loadModules(const QString &path);
- Module* loadPlugin(QString pluginFileName,
- QString resolveString = "create_plugin");
+ Module* loadPlugin(const QString &pluginFileName,
+ const QString &resolveString = "create_plugin");
// For our local list of names
QMap<QString, Interface*> interfaceNames;
QMap<Module*, QLibrary*> libraries;
QMap<Interface*, QListViewItem*> items;
QMap<QListViewItem*, Interface*> interfaceItems;
QMap<KProcess*, QString> threads;
QStringList profiles;
bool advancedUserMode;
QString scheme;
};
#endif
// mainwindowimp.h
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
@@ -1,86 +1,86 @@
#ifndef NETCONF_MODULE_H
#define NETCONF_MODULE_H
#include <qobject.h>
#include <qlist.h>
#include <qmap.h>
#include "interface.h"
class QWidget;
class QTabWidget;
class Module : QObject{
signals:
void updateInterface(Interface *i);
public:
Module(){};
/**
* The current profile has been changed and the module should do any
* neccesary changes also.
* @param newProfile what the profile should be changed to.
*/
- virtual void setProfile(QString newProfile) = 0;
+ virtual void setProfile(const QString &newProfile) = 0;
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
virtual QString getPixmapName(Interface *) = 0;
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
virtual bool isOwner(Interface *){ return false; };
/**
* Create and return the WLANConfigure Module
* @param Interface *i the interface to configure.
* @return QWidget* pointer to this modules configure.
*/
virtual QWidget *configure(Interface *){ return NULL; } ;
/**
* Create, and return the Information Module
* @param Interface *i the interface to get info on.
* @return QWidget* pointer to this modules info.
*/
virtual QWidget *information(Interface *){ return NULL; };
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
virtual QList<Interface> getInterfaces() = 0;
/**
* Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
* modem ppp)
*/
virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
/**
* Attempts to create a new interface from name
* @return Interface* NULL if it was unable to be created.
* @param name the type of interface to create
*/
- virtual Interface *addNewInterface(QString name) = 0;
+ virtual Interface *addNewInterface(const QString &name) = 0;
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
virtual bool remove(Interface* i) = 0;
};
#endif
// module.h
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,27 +1,27 @@
#ifndef INFOIMP_H
#define INFOIMP_H
#include "info.h"
class QTimer;
-class WExtensions;
+//class WExtensions;
class WlanInfoImp : public WlanInfo {
Q_OBJECT
public:
WlanInfoImp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
private slots:
void update();
private:
//WExtensions *wExtensions;
QTimer *timer;
};
#endif
// infoimp.h
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
@@ -1,68 +1,67 @@
#include "wextensions.h"
#include <qfile.h>
#include <qtextstream.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <math.h>
#define PROCNETWIRELESS "/proc/net/wireless"
#define IW_LOWER 0
#define IW_UPPER 256
/**
* Constructor. Sets hasWirelessExtensions
*/
-WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){
- interface = interfaceName;
+WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) {
fd = socket( AF_INET, SOCK_DGRAM, 0 );
if(fd == -1)
return;
const char* buffer[200];
memset( &iwr, 0, sizeof( iwr ) );
iwr.u.essid.pointer = (caddr_t) buffer;
iwr.u.essid.length = IW_ESSID_MAX_SIZE;
iwr.u.essid.flags = 0;
// check if it is an IEEE 802.11 standard conform
// wireless device by sending SIOCGIWESSID
// which also gives back the Extended Service Set ID
// (see IEEE 802.11 for more information)
const char* iname = interface.latin1();
strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) )
hasWirelessExtensions = true;
}
/**
* @return QString the station name of the access point.
*/
QString WExtensions::station(){
if(!hasWirelessExtensions)
return QString();
const char* buffer[200];
iwr.u.data.pointer = (caddr_t) buffer;
iwr.u.data.length = IW_ESSID_MAX_SIZE;
iwr.u.data.flags = 0;
if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){
iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0';
return QString(iwr.u.data.pointer);
}
return QString();
}
/**
* @return QString the essid of the host 802.11 access point.
*/
QString WExtensions::essid(){
if(!hasWirelessExtensions)
return QString();
if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){
iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0';
return QString(iwr.u.essid.pointer);
}
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
@@ -1,95 +1,95 @@
#include "wlanimp.h"
#include "interfacesetupimp.h"
#include <qfile.h>
#include <qdir.h>
#include <qtextstream.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qtabwidget.h>
/* system() */
#include <stdlib.h>
#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
/**
* Constructor, read in the wireless.opts file for parsing later.
*/
WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") {
interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);
tabWidget->insertTab(interfaceSetup, "TCP/IP");
// Read in the config file.
QString wlanFile = WIRELESS_OPTS;
QFile file(wlanFile);
if (file.open(IO_ReadOnly)){
QTextStream stream( &file );
QString line = "";
while ( !stream.eof() ) {
line += stream.readLine();
line += "\n";
}
file.close();
settingsFileText = QStringList::split("\n", line, true);
parseSettingFile();
}
else
qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1());
}
/**
* Change the profile for both wireless settings and network settings.
*/
-void WLANImp::setProfile(QString &profile){
+void WLANImp::setProfile(const QString &profile){
interfaceSetup->setProfile(profile);
parseSettingFile();
}
/**
* Parses the settings file that was read in and gets any setting from it.
*/
void WLANImp::parseSettingFile(){
bool foundCase = false;
bool found = false;
for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains("case"))
foundCase = true;
// See if we found our scheme to write or the sceme couldn't be found
if((foundCase && line.contains("esac")) ||
(foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#'))
found = true;
if(line.contains(";;"))
found = false;
if(found){
// write out scheme
if(line.contains("ESSID=")){
QString id = line.mid(line.find("ESSID=")+6, line.length());
if(id == "any"){
essNon->setChecked(true);
essSpecific->setChecked(false);
}else{
essSpecific->setChecked(true);
essSpecificLineEdit->setText(id);
essNon->setChecked(false);
}
}
if(line.contains("MODE=")){
QString mode = line.mid(line.find("MODE=")+5, line.length());
if(mode == "Managed"){
network802->setChecked( false );
networkInfrastructure->setChecked( true );
}
else{
network802->setChecked( true );
networkInfrastructure->setChecked( false );
}
}
if(line.contains("KEY=")){
line.at(0) != '#' ? wepEnabled->setChecked(true) : wepEnabled->setChecked(false);
int s = line.find("KEY=");
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 @@
#ifndef WLANIMP_H
#define WLANIMP_H
#include "wlan.h"
#include <qstringlist.h>
class InterfaceSetupImp;
class Interface;
class Config;
class WLANImp : public WLAN {
Q_OBJECT
public:
WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
- void setProfile(QString &profile);
+ void setProfile(const QString &profile);
protected:
void accept();
private:
void parseSettingFile();
void changeAndSaveSettingFile();
InterfaceSetupImp *interfaceSetup;
QStringList settingsFileText;
QString currentProfile;
};
#endif
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
@@ -1,113 +1,113 @@
#include "wlanmodule.h"
#include "wlanimp.h"
#include "infoimp.h"
#include "wextensions.h"
#include "interfaceinformationimp.h"
#include <qlabel.h>
#include <qprogressbar.h>
#include <qtabwidget.h>
/**
* Constructor, find all of the possible interfaces
*/
WLANModule::WLANModule() : Module() {
}
/**
* Delete any interfaces that we own.
*/
WLANModule::~WLANModule(){
Interface *i;
for ( i=list.first(); i != 0; i=list.next() )
delete i;
}
/**
* Change the current profile
*/
-void WLANModule::setProfile(QString newProfile){
+void WLANModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
QString WLANModule::getPixmapName(Interface* ){
return "wlan";
}
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
bool WLANModule::isOwner(Interface *i){
WExtensions we(i->getInterfaceName());
if(!we.doesHaveWirelessExtensions())
return false;
i->setHardwareName("802.11b");
list.append(i);
return true;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *WLANModule::configure(Interface *i){
WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose);
wlanconfig->setProfile(profile);
return wlanconfig;
}
/**
* Create, and return the Information Module
* @return QWidget* pointer to this modules info.
*/
QWidget *WLANModule::information(Interface *i){
WExtensions we(i->getInterfaceName());
if(!we.doesHaveWirelessExtensions())
return NULL;
WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
info->tabWidget->insertTab(information, "TCP/IP");
return info;
}
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
QList<Interface> WLANModule::getInterfaces(){
return list;
}
/**
* Attempt to add a new interface as defined by name
* @param name the name of the type of interface that should be created given
* by possibleNewInterfaces();
* @return Interface* NULL if it was unable to be created.
*/
-Interface *WLANModule::addNewInterface(QString ){
+Interface *WLANModule::addNewInterface(const QString &){
// We can't add a 802.11 interface, either the hardware will be there
// or it wont.
return NULL;
}
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
bool WLANModule::remove(Interface*){
// Can't remove a hardware device, you can stop it though.
return false;
}
// wlanmodule.cpp
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,41 +1,41 @@
#ifndef WLAN_MODULE_H
#define WLAN_MODULE_H
#include "module.h"
class WLANModule : Module{
signals:
void updateInterface(Interface *i);
public:
WLANModule();
~WLANModule();
- virtual void setProfile(QString newProfile);
- virtual bool isOwner(Interface *);
- virtual QWidget *configure(Interface *i);
- virtual QWidget *information(Interface *i);
- virtual QList<Interface> getInterfaces();
- virtual void possibleNewInterfaces(QMap<QString, QString> &){};
- virtual Interface *addNewInterface(QString name);
- virtual bool remove(Interface* i);
- virtual QString getPixmapName(Interface* i);
+ void setProfile(const QString &newProfile);
+ bool isOwner(Interface *);
+ QWidget *configure(Interface *i);
+ QWidget *information(Interface *i);
+ QList<Interface> getInterfaces();
+ void possibleNewInterfaces(QMap<QString, QString> &){};
+ Interface *addNewInterface(const QString &name);
+ bool remove(Interface* i);
+ QString getPixmapName(Interface* i);
private:
QList<Interface> list;
QString profile;
};
extern "C"
{
void* create_plugin() {
return new WLANModule();
}
};
#endif
// wlanmodule.h
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 @@
CLEAN UP
-Write a class that parses /proc and not ifconfig
-
udchcp needs to output the dhcp information so interfaces can read it
interfacesetupimp really doesn't need a interface* pointer
Possible other modules to write: ppp, ipsec, bluetooth, ipchains
PPP module needs to scan pppd.tdb to see what is currently active
WLAN - add possiblity to input text or hex without knowing "s:"
+Interface 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
@@ -1,38 +1,37 @@
#include "addconnectionimp.h"
#include <qlistview.h>
#include <qlist.h>
#include <qlabel.h>
#include <qheader.h>
/**
* Constructor
*/
AddConnectionImp::AddConnectionImp(QWidget *parent, const char *name, WFlags f):AddConnection(parent, name, f){
connect(registeredServicesList, SIGNAL(selectionChanged()), this, SLOT(changed()));
registeredServicesList->header()->hide();
};
/**
* The current item changed, update the discription.
*/
void AddConnectionImp::changed(){
QListViewItem *item = registeredServicesList->currentItem();
- if(item){
+ if(item)
help->setText(list[item->text(0)]);
- }
}
/**
* Save a copy of newList for the discriptions and append them all to the view
* @param newList the new list of possible interfaces
*/
-void AddConnectionImp::addConnections(QMap<QString, QString> newList){
+void AddConnectionImp::addConnections(const QMap<QString, QString> &newList){
list = newList;
QMap<QString, QString>::Iterator it;
for( it = list.begin(); it != list.end(); ++it )
QListViewItem *item = new QListViewItem(registeredServicesList, it.key());
registeredServicesList->setCurrentItem(registeredServicesList->firstChild());
}
// addserviceimp.cpp
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 @@
#ifndef ADDCONNECTIONIMP_H
#define ADDCONNECTIONIMP_H
#include "addconnection.h"
#include <qmap.h>
#include <qlist.h>
class QListViewItem;
class AddConnectionImp : public AddConnection {
Q_OBJECT
public:
AddConnectionImp(QWidget *parent=0, const char *name=0, WFlags f=0);
- void addConnections(QMap<QString, QString> newList);
+ void addConnections(const QMap<QString, QString> &newList);
private slots:
void changed();
private:
QMap<QString, QString> list;
};
#endif
// addconectionimp.h
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
@@ -1,93 +1,93 @@
#include "interface.h"
#include <qdatetime.h>
#include <qfile.h>
#include <qdir.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#define IFCONFIG "/sbin/ifconfig"
#define DHCP_INFO_DIR "/etc/dhcpc"
#include <stdio.h>
#include <stdlib.h>
Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
refresh();
}
/**
* Set status
* @param newStatus - the new status
* emit updateInterface
*/
void Interface::setStatus(bool newStatus){
if(status != newStatus){
status = newStatus;
refresh();
}
};
/**
* Set if attached or not (802.11 card pulled out for example)
* @param isAttached - if attached
* emit updateInterface
*/
void Interface::setAttached(bool isAttached){
attached = isAttached;
emit(updateInterface(this));
};
/**
* Set Hardware name
* @param name - the new name
* emit updateInterface
*/
-void Interface::setHardwareName(QString name){
+void Interface::setHardwareName(const QString &name){
hardwareName = name;
emit(updateInterface(this));
};
/**
* Set Module owner
* @param owner - the new owner
* emit updateInterface
*/
void Interface::setModuleOwner(Module *owner){
moduleOwner = owner;
emit(updateInterface(this));
};
/**
* Try to start the interface.
*/
void Interface::start(){
// check to see if we are already running.
if(true == status){
emit (updateMessage("Unable to start interface,\n already started"));
return;
}
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
// See if it was successfull...
if(ret != 0){
emit (updateMessage("Starting interface failed."));
return;
}
status = true;
refresh();
emit (updateMessage("Start successfull"));
}
/**
* Try to stop the interface.
*/
void Interface::stop(){
// check to see if we are already stopped.
if(false == status){
emit (updateMessage("Unable to stop interface,\n already stopped"));
return;
}
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
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
@@ -1,72 +1,71 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <qstring.h>
#include <qobject.h>
class Module;
class Interface : public QObject{
Q_OBJECT
signals:
void updateInterface(Interface *i);
void updateMessage(const QString &message);
public:
Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
- virtual ~Interface(){};
- virtual QString getInterfaceName(){ QString n(this->name()); return n; };
+ QString getInterfaceName(){ QString n(this->name()); return n; };
- virtual bool getStatus(){ return status; };
- virtual void setStatus(bool newStatus);
+ bool getStatus(){ return status; };
+ void setStatus(bool newStatus);
- virtual bool isAttached(){ return attached; };
- virtual void setAttached(bool isAttached=false);
+ bool isAttached(){ return attached; };
+ void setAttached(bool isAttached=false);
- virtual QString getHardwareName(){ return hardwareName; };
- virtual void setHardwareName(QString name="Unknown");
+ QString getHardwareName(){ return hardwareName; };
+ void setHardwareName(const QString &name="Unknown");
- virtual Module* getModuleOwner(){ return moduleOwner; };
- virtual void setModuleOwner(Module *owner=NULL);
+ Module* getModuleOwner(){ return moduleOwner; };
+ void setModuleOwner(Module *owner=NULL);
// inet information.
QString getMacAddress(){ return macAddress; };
QString getIp(){ return ip; };
QString getSubnetMask(){ return subnetMask; };
QString getBroadcast(){ return broadcast; };
bool isDhcp(){ return dhcp; };
QString getDhcpServerIp(){ return dhcpServerIp; };
QString getLeaseObtained(){ return leaseObtained; };
QString getLeaseExpires(){ return leaseExpires; };
public slots:
bool refresh();
void start();
void stop();
void restart();
private:
// Interface information
bool status;
bool attached;
QString hardwareName;
Module *moduleOwner;
// Network information
QString macAddress;
QString ip;
QString broadcast;
QString subnetMask;
bool dhcp;
QString dhcpServerIp;
QString leaseObtained;
QString leaseExpires;
};
#endif
// interface.h
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
@@ -25,198 +25,198 @@ Interfaces::Interfaces(QString useInterfacesFile){
qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1());
currentIface = interfaces.end();
currentMapping = interfaces.end();
return;
}
QTextStream stream( &file );
QString line;
while ( !stream.eof() ) {
line += stream.readLine();
line += "\n";
}
file.close();
interfaces = QStringList::split("\n", line, true);
currentIface = interfaces.end();
currentMapping = interfaces.end();
}
/**
* Get a list of all interfaces in the interface file. Usefull for
* hardware that is not currently connected such as an 802.11b card
* not plugged in, but configured for when it is plugged in.
* @return Return string list of interfaces.
**/
QStringList Interfaces::getInterfaceList(){
QStringList list;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains(IFACE) && line.at(0) != '#'){
line = line.mid(QString(IFACE).length() +1, line.length());
line = line.simplifyWhiteSpace();
int findSpace = line.find(" ");
if( findSpace >= 0){
line = line.mid(0, findSpace);
list.append(line);
}
}
}
return list;
}
/**
* Find out if interface is in an "auto" group or not.
* Report any duplicates such as eth0 being in two differnt auto's
* @param interface interface to check to see if it is on or not.
* @return true is interface is in auto
*/
-bool Interfaces::isAuto(QString interface){
+bool Interfaces::isAuto(const QString &interface){
QStringList autoLines = interfaces.grep(QRegExp(AUTO));
QStringList awi = autoLines.grep(QRegExp(interface));
if(awi.count() > 1)
qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
if(awi.count() < 1)
return false;
return true;
}
/**
* Attempt to set the auto option for interface to setAuto.
* @param interface the interface to set
* @param setAuto the value to set interface to.
* @return false if already set to setAuto.
* */
-bool Interfaces::setAuto(QString interface, bool setAuto){
+bool Interfaces::setAuto(const QString &interface, bool setAuto){
// Don't need to set it if it is already set.
if(isAuto(interface) == setAuto)
return false;
bool changed = false;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
if((*it).contains(AUTO)){
//We know that they are not in any group so let add to this auto.
if(setAuto){
(*it) = (*it) += " " + interface;
// Don't care to have such thins as: auto eth0 lo usb0
(*it) = (*it).simplifyWhiteSpace();
changed = true;
break;
}
else{
if((*it).contains(interface)){
(*it) = (*it).replace(QRegExp(interface), "");
// clean up
QString line = (*it).simplifyWhiteSpace();
line = line.replace(QRegExp(" "),"");
if(line == AUTO)
(*it) = "";
changed = true;
// Don't break because we want to make sure we remove all cases.
}
}
}
}
if(changed == false){
if(setAuto == true)
interfaces.append(QString(AUTO" %1").arg(interface));
else{
qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1());
}
}
return true;
}
/**
* Set the current interface to interface. This needs to be done before you
* can call getFamily(), getMethod, and get/setOption().
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @return bool true if it is successfull.
*/
bool Interfaces::setInterface(QString interface){
interface = interface.simplifyWhiteSpace();
interface = interface.replace(QRegExp(" "), "");
return setStanza(IFACE, interface, currentIface);
}
/**
* A quick helper funtion to see if the current interface is set.
* @return bool true if set, false otherwise.
*/
bool Interfaces::isInterfaceSet(){
return (currentIface != interfaces.end());
}
/**
* Add a new interface of with the settings - family and method
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @param family the family of this interface inet or inet, ipx or inet6
* Must of one of the families defined in interfaces.h
* @param method for the family. see interfaces man page for family methods.
* @return true if successfull.
*/
-bool Interfaces::addInterface(QString interface, QString family, QString method){
+bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
if(acceptedFamily.contains(family)==0)
return false;
- interface = interface.simplifyWhiteSpace();
- interface = interface.replace(QRegExp(" "), "");
+ QString newInterface = interface.simplifyWhiteSpace();
+ newInterface = newInterface.replace(QRegExp(" "), "");
interfaces.append("");
- interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method));
+ interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
return true;
}
/**
* Copies interface with name interface to name newInterface
* @param newInterface name of the new interface.
* @return bool true if successfull
*/
-bool Interfaces::copyInterface(QString interface, QString newInterface){
+bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
if(!setInterface(interface)) return false;
QStringList::Iterator it = currentIface;
it++;
bool error;
addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
if(!setInterface(newInterface)) return false;
QStringList::Iterator newIface = currentIface;
newIface++;
for ( ; it != interfaces.end(); ++it ){
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
break;
newIface = interfaces.insert(newIface, *it);
}
return true;
}
/**
* Remove the currently selected interface and all of its options.
* @return bool if successfull or not.
*/
bool Interfaces::removeInterface(){
if(currentIface == interfaces.end())
return false;
(*currentIface) = "";
return removeAllInterfaceOptions();
}
/**
* Gets the hardware name of the interface that is currently selected.
* @return QString name of the hardware interface (eth0, usb2, wlan1...).
* @param error set to true if any error occurs, false otherwise.
*/
QString Interfaces::getInterfaceName(bool &error){
if(currentIface == interfaces.end()){
error = true;
return QString();
}
QString line = (*currentIface);
line = line.mid(QString(IFACE).length() +1, line.length());
line = line.simplifyWhiteSpace();
int findSpace = line.find(" ");
if( findSpace < 0){
error = true;
return QString();
@@ -235,392 +235,394 @@ QString Interfaces::getInterfaceFamily(bool &error){
if(error){
error = true;
return QString();
}
QString line = (*currentIface);
line = line.mid(QString(IFACE).length() +1, line.length());
line = line.mid(name.length()+1, line.length());
line = line.simplifyWhiteSpace();
int findSpace = line.find(" ");
if( findSpace < 0){
error = true;
return QString();
}
error = false;
return line.mid(0, findSpace);
}
/**
* Gets the method of the interface that is currently selected.
* @return QString name of the method such as staic or dhcp.
* See the man page of interfaces for possible methods depending on the family.
* @param error set to true if any error occurs, false otherwise.
*/
QString Interfaces::getInterfaceMethod(bool &error){
QString name = getInterfaceName(error);
if(error){
error = true;
return QString();
}
QString family = getInterfaceFamily(error);
if(error){
error = true;
return QString();
}
QString line = (*currentIface);
line = line.mid(QString(IFACE).length()+1, line.length());
line = line.mid(name.length()+1, line.length());
line = line.mid(family.length()+1, line.length());
line = line.simplifyWhiteSpace();
error = false;
return line;
}
/**
* Sets the interface name to newName.
* @param newName the new name of the interface. All whitespace is removed.
* @return bool true if successfull.
*/
-bool Interfaces::setInterfaceName(QString newName){
+bool Interfaces::setInterfaceName(const QString &newName){
if(currentIface == interfaces.end())
return false;
- newName = newName.simplifyWhiteSpace();
- newName = newName.replace(QRegExp(" "), "");
+ QString name = newName.simplifyWhiteSpace();
+ name = name.replace(QRegExp(" "), "");
bool returnValue = false;
- (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
+ (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
return !returnValue;
}
/**
* Sets the interface family to newName.
* @param newName the new name of the interface. Must be one of the families
* defined in the interfaces.h file.
* @return bool true if successfull.
*/
-bool Interfaces::setInterfaceFamily(QString newName){
+bool Interfaces::setInterfaceFamily(const QString &newName){
if(currentIface == interfaces.end())
return false;
if(acceptedFamily.contains(newName)==0)
return false;
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
return !returnValue;
}
/**
* Sets the interface method to newName
* @param newName the new name of the interface
* @return bool true if successfull.
*/
-bool Interfaces::setInterfaceMethod(QString newName){
+bool Interfaces::setInterfaceMethod(const QString &newName){
if(currentIface == interfaces.end())
return false;
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
return !returnValue;
}
/**
* Get a value for an option in the currently selected interface. For example
* calling getInterfaceOption("address") on the following stanza would
* return 192.168.1.1.
* iface eth0 static
* address 192.168.1.1
* @param option the options to get the value.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
-QString Interfaces::getInterfaceOption(QString option, bool &error){
+QString Interfaces::getInterfaceOption(const QString &option, bool &error){
return getOption(currentIface, option, error);
}
/**
* Set a value for an option in the currently selected interface. If option
* doesn't exist then it is added along with the value.
* @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
-bool Interfaces::setInterfaceOption(QString option, QString value){
+bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
return setOption(currentIface, option, value);
}
/**
* Removes a value for an option in the currently selected interface.
* @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
-bool Interfaces::removeInterfaceOption(QString option, QString value){
+bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
return removeOption(currentIface, option, value);
}
/**
* Removes all of the options from the currently selected interface.
* @return bool error if if successfull
*/
bool Interfaces::removeAllInterfaceOptions(){
return removeAllOptions(currentIface);
}
/**
* Set the current map to interface's map. This needs to be done before you
* can call addMapping(), set/getMap(), and get/setScript().
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @return bool true if it is successfull.
*/
-bool Interfaces::setMapping(QString interface){
- interface = interface.simplifyWhiteSpace();
- interface = interface.replace(QRegExp(" "), "");
- return setStanza(MAPPING, interface, currentMapping);
+bool Interfaces::setMapping(const QString &interface){
+ QString interfaceName = interface.simplifyWhiteSpace();
+ interfaceName = interfaceName.replace(QRegExp(" "), "");
+ return setStanza(MAPPING, interfaceName, currentMapping);
}
/**
* Adds a new Mapping to the interfaces file with interfaces.
* @param interface the name(s) of the interfaces to set to this mapping
*/
-void Interfaces::addMapping(QString option){
+void Interfaces::addMapping(const QString &option){
interfaces.append("");
interfaces.append(QString(MAPPING " %1").arg(option));
}
/**
* Remove the currently selected map and all of its options.
* @return bool if successfull or not.
*/
bool Interfaces::removeMapping(){
if(currentMapping == interfaces.end())
return false;
(*currentMapping) = "";
return removeAllOptions(currentMapping);
}
/**
* Set a map option within a mapping.
* @param map map to use
* @param value value to go with map
* @return bool true if it is successfull.
*/
-bool Interfaces::setMap(QString map, QString value){
+bool Interfaces::setMap(const QString &map, const QString &value){
return setOption(currentMapping, map, value);
}
/**
* Removes a map option within a mapping.
* @param map map to use
* @param value value to go with map
* @return bool true if it is successfull.
*/
-bool Interfaces::removeMap(QString map, QString value){
+bool Interfaces::removeMap(const QString &map, const QString &value){
return removeOption(currentMapping, map, value);
}
/**
* Get a map value within a mapping.
* @param map map to get value of
* @param bool true if it is successfull.
* @return value that goes to the map
*/
-QString Interfaces::getMap(QString map, bool &error){
+QString Interfaces::getMap(const QString &map, bool &error){
return getOption(currentMapping, map, error);
}
/**
* Sets a script value of the current mapping to argument.
* @param argument the script name.
* @return true if successfull.
*/
-bool Interfaces::setScript(QString argument){
+bool Interfaces::setScript(const QString &argument){
return setOption(currentMapping, "script", argument);
}
/**
* @param error true if could not retrieve the current script argument.
* @return QString the argument of the script for the current mapping.
*/
QString Interfaces::getScript(bool &error){
return getOption(currentMapping, "script", error);
}
+
+
/**
* Helper function used to parse through the QStringList and put pointers in
* the correct place.
* @param stanza The stanza (auto, iface, mapping) to look for.
* @param option string that must be in the stanza's main line.
* @param interator interator to place at location of stanza if successfull.
* @return bool true if the stanza is found.
*/
-bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){
+bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
bool found = false;
iterator = interfaces.end();
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
uint point = line.find(option);
bool valid = true;
if(point > 0){
// There are more chars in the line. check +1
if(line.at(point-1) != ' ')
valid = false;
}
point += option.length();
if(point < line.length()-1){
// There are more chars in the line. check -1
if(line.at(point) != ' ')
valid = false;
}
if(valid){
if(found == true){
qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
}
found = true;
iterator = it;
}
}
}
return found;
}
/**
* Sets a value of an option in a stanza
* @param start the start of the stanza
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
-bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){
+bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
if(!found && value != ""){
// Got to the end of the stanza without finding it, so append it.
interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
}
found = true;
break;
}
if((*it).contains(option) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
if(found)
qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
found = true;
(*it) = QString("\t%1 %2").arg(option).arg(value);
}
}
if(!found){
QStringList::Iterator p = start;
interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
found = true;
}
return found;
}
/**
* Removes a option in a stanza
* @param start the start of the stanza
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
-bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){
+bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
// got to the end without finding it
break;
}
if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
// Found it in stanza so replace it.
if(found)
qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
found = true;
(*it) = "";
}
}
return found;
}
/**
* Removes all options in a stanza
* @param start the start of the stanza
* @return bool true if successfull, false otherwise.
*/
-bool Interfaces::removeAllOptions(QStringList::Iterator start){
+bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
if(start == interfaces.end())
return false;
QStringList::Iterator it = start;
it = ++it;
for (; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
it = interfaces.remove(it);
it = --it;
}
// Leave a space between this interface and the next.
interfaces.insert(it, QString(""));
return true;
}
/**
* Gets a value of an option in a stanza
* @param start the start of the stanza
* @param option the option to use when getting the value.
* @param bool true if errors false otherwise.
* @return QString the value of option QString::null() if error == true.
*/
-QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){
+QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){
if(start == interfaces.end()){
error = false;
return QString();
}
QString value;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
if((*it).contains(option) && (*it).at(0) != '#'){
if(found)
qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
found = true;
QString line = (*it).simplifyWhiteSpace();
int space = line.find(" ", option.length());
if(space != -1)
value = line.mid(space+1, line.length());
else
qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1());
}
}
error = !found;
return value;
}
/**
* Write out the interfaces file to the file passed into the constructor.
* Removes any excess blank lines over 1 line long.
* @return bool true if successfull, false if not.
*/
bool Interfaces::write(){
QFile::remove(interfacesFile);
QFile file(interfacesFile);
if (!file.open(IO_ReadWrite)){
qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
return false;
}
QTextStream stream( &file );
int whiteSpaceCount = 0;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
line = line.replace(QRegExp(" "),"");
if(line.length() == 0)
whiteSpaceCount++;
else
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
@@ -1,76 +1,76 @@
#ifndef INTERFACES_H
#define INTERFACES_H
#include <qstring.h>
#include <qstringlist.h>
#define INTERFACES_LOOPBACK "loopback"
#define INTERFACES_FAMILY_INET "inet"
#define INTERFACES_FAMILY_IPX "ipx"
#define INTERFACES_FAMILY_INET6 "inet6"
#define INTERFACES_METHOD_DHCP "dhcp"
#define INTERFACES_METHOD_STATIC "static"
#define INTERFACES_METHOD_PPP "ppp"
/**
* This class provides a clean frontend for parsing the network interfaces file.
* It provides helper functions to minipulate the options within the file.
* See the interfaces man page for the syntax rules.
*/
class Interfaces {
public:
Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
QStringList getInterfaceList();
- bool isAuto(QString interface);
- bool setAuto(QString interface, bool setAuto);
+ bool isAuto(const QString &interface);
+ bool setAuto(const QString &interface, bool setAuto);
bool removeInterface();
- bool addInterface(QString interface, QString family, QString method);
- bool copyInterface(QString oldInterface, QString newInterface);
+ bool addInterface(const QString &interface, const QString &family, const QString &method);
+ bool copyInterface(const QString &oldInterface, const QString &newInterface);
bool setInterface(QString interface);
- bool isInterfaceSet();
+ inline bool isInterfaceSet();
QString getInterfaceName(bool &error);
- bool setInterfaceName(QString newName);
+ bool setInterfaceName(const QString &newName);
QString getInterfaceFamily(bool &error);
- bool setInterfaceFamily(QString newName);
+ bool setInterfaceFamily(const QString &newName);
QString getInterfaceMethod(bool &error);
- bool setInterfaceMethod(QString newName);
- QString getInterfaceOption(QString option, bool &error);
- bool setInterfaceOption(QString option, QString value);
- bool removeInterfaceOption(QString option, QString value);
- bool removeAllInterfaceOptions();
+ bool setInterfaceMethod(const QString &newName);
+ inline QString getInterfaceOption(const QString &option, bool &error);
+ inline bool setInterfaceOption(const QString &option, const QString &value);
+ inline bool removeInterfaceOption(const QString &option, const QString &value);
+ inline bool removeAllInterfaceOptions();
- bool setMapping(QString interface);
+ bool setMapping(const QString &interface);
bool removeMapping();
- void addMapping(QString options);
- bool setMap(QString map, QString value);
- bool removeMap(QString map, QString value);
- QString getMap(QString map, bool &error);
- bool setScript(QString);
- QString getScript(bool &error);
+ inline void addMapping(const QString &options);
+ inline bool setMap(const QString &map, const QString &value);
+ inline bool removeMap(const QString &map, const QString &value);
+ inline QString getMap(const QString &map, bool &error);
+ inline bool setScript(const QString &argument);
+ inline QString getScript(bool &error);
bool write();
private:
- bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator);
- bool setOption(QStringList::Iterator start, QString option, QString value);
- bool removeOption(QStringList::Iterator start, QString option, QString value);
- QString getOption(QStringList::Iterator start, QString option, bool &error);
- bool removeAllOptions(QStringList::Iterator start);
+ bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
+ bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
+ bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
+ QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
+ bool removeAllOptions(const QStringList::Iterator &start);
QString interfacesFile;
QStringList interfaces;
QStringList::Iterator currentIface;
QStringList::Iterator currentMapping;
QStringList acceptedFamily;
};
#endif
// interfaces
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
@@ -54,96 +54,100 @@
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>dhcpCheckBox</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>DHCP</string>
</property>
<property stdset="1">
<name>checked</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>leaseHoursLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Requested Lease</string>
</property>
</widget>
<widget>
<class>QSpinBox</class>
<property stdset="1">
<name>name</name>
<cstring>leaseTime</cstring>
</property>
<property stdset="1">
<name>suffix</name>
<string> hours</string>
</property>
<property stdset="1">
<name>maxValue</name>
<number>87600</number>
</property>
<property stdset="1">
<name>minValue</name>
<number>1</number>
</property>
<property stdset="1">
+ <name>lineStep</name>
+ <number>24</number>
+ </property>
+ <property stdset="1">
<name>value</name>
<number>168</number>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QGroupBox</class>
<property stdset="1">
<name>name</name>
<cstring>staticGroupBox</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Box</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>title</name>
<string>Static Ip Configuration</string>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="1" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel5</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Subnet Mask</string>
</property>
</widget>
@@ -206,79 +210,101 @@
<property stdset="1">
<name>name</name>
<cstring>TextLabel3</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Second DNS</string>
</property>
</widget>
<widget row="3" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>firstDNSLineEdit</cstring>
</property>
</widget>
<widget row="4" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>secondDNSLineEdit</cstring>
</property>
</widget>
</grid>
</widget>
<spacer>
<property>
<name>name</name>
<cstring>Spacer9</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</vbox>
</widget>
+<customwidgets>
+ <customwidget>
+ <class>QWidget</class>
+ <header location="local">qwidget.h</header>
+ <sizehint>
+ <width>100</width>
+ <height>100</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>7</hordata>
+ <verdata>7</verdata>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image>
+ <name>image0</name>
+ <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
+ </image>
+</images>
<connections>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>leaseHoursLabel</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>leaseTime</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>staticGroupBox</receiver>
<slot>setDisabled(bool)</slot>
</connection>
</connections>
<tabstops>
<tabstop>autoStart</tabstop>
<tabstop>dhcpCheckBox</tabstop>
<tabstop>leaseTime</tabstop>
<tabstop>ipAddressEdit</tabstop>
<tabstop>subnetMaskEdit</tabstop>
<tabstop>gatewayEdit</tabstop>
<tabstop>firstDNSLineEdit</tabstop>
<tabstop>secondDNSLineEdit</tabstop>
</tabstops>
</UI>
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
@@ -1,56 +1,55 @@
#ifndef INTERFACESETUPIMP_H
#define INTERFACESETUPIMP_H
#include "interfacesetup.h"
#include <qdialog.h>
class Interface;
class Interfaces;
class InterfaceSetupImp : public InterfaceSetup {
Q_OBJECT
public:
InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0);
bool saveChanges();
public slots:
void setProfile(const QString &profile);
bool saveSettings();
private:
Interfaces *interfaces;
Interface *interface;
-
};
#include <qlayout.h>
class InterfaceSetupImpDialog : public QDialog {
Q_OBJECT
public:
InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){
QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this );
setCaption("Interface Setup");
interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl);
InterfaceSetupLayout->addWidget( interfaceSetup );
};
void setProfile(QString &profile){ interfaceSetup->setProfile(profile);};
private:
InterfaceSetupImp *interfaceSetup;
protected slots:
void accept(){
if(interfaceSetup->saveChanges())
QDialog::accept();
};
};
#endif
// interfacesetupimp.h
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
@@ -1,81 +1,81 @@
#include "mainwindowimp.h"
#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
#include "interfaces.h"
#include "module.h"
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qlist.h>
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#include <net/if.h>
#include <sys/ioctl.h>
#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
-MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
+MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false), scheme(DEFAULT_SCHEME){
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
// Load connections.
loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
getAllInterfaces();
Interfaces i;
QStringList list = i.getInterfaceList();
QMap<QString, Interface*>::Iterator it;
for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
bool found = false;
for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
if(it.key() == (*ni))
found = true;
}
if(!found){
if(!(*ni).contains("_")){
Interface *i = new Interface(this, *ni, false);
i->setAttached(false);
i->setHardwareName("Disconnected");
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
}
}
//getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
QFile file(scheme);
if ( file.open(IO_ReadOnly) ) { // file opened successfully
@@ -144,122 +144,122 @@ void MainWindowImp::getAllInterfaces(){
int flags;
struct sockaddr_in *sinptr;
Interface *i = NULL;
switch (ifr->ifr_addr.sa_family){
case AF_INET:
sinptr = (struct sockaddr_in *) &ifr->ifr_addr;
flags=0;
struct ifreq ifcopy;
ifcopy=*ifr;
result=ioctl(sockfd,SIOCGIFFLAGS,&ifcopy);
flags=ifcopy.ifr_flags;
i = new Interface(this, ifr->ifr_name, false);
i->setAttached(true);
if ((flags & IFF_UP) == IFF_UP)
i->setStatus(true);
else
i->setStatus(false);
if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
i->setHardwareName("Ethernet");
else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
i->setHardwareName("Point to Point");
else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
i->setHardwareName("Multicast");
else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
i->setHardwareName("Loopback");
else
i->setHardwareName("Unknown");
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
break;
default:
qDebug(ifr->ifr_name);
qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1());
break;
}
}
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
*/
-void MainWindowImp::loadModules(QString path){
+void MainWindowImp::loadModules(const QString &path){
//qDebug(path.latin1());
QDir d(path);
if(!d.exists())
return;
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
if(fi->fileName().contains(".so")){
loadPlugin(path + "/" + fi->fileName());
}
++it;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
-Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
+Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
//qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
delete lib;
return NULL;
}
// Try to get an object.
Module *object = ((Module* (*)()) functionPointer)();
if(object == NULL){
qDebug("MainWindowImp: Couldn't create object, but did load library!");
delete lib;
return NULL;
}
// Store for deletion later
libraries.insert(object, lib);
return object;
}
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked(){
QMap<Module*, QLibrary*>::Iterator it;
QMap<QString, QString> list;
QMap<QString, Module*> newInterfaceOwners;
//list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
//list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()){
(it.key())->possibleNewInterfaces(list);
}
}
// See if the list has anything that we can add.
if(list.count() == 0){
QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
return;
}
AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
addNewConnection.addConnections(list);
addNewConnection.showMaximized();
if(QDialog::Accepted == addNewConnection.exec()){
QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
if(!item)
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
@@ -1,58 +1,58 @@
#ifndef MAINWINOWIMP_H
#define MAINWINOWIMP_H
#include "mainwindow.h"
#include <qmap.h>
#include <qstringlist.h>
class Module;
class Interface;
class QLibrary;
class KProcess;
class MainWindowImp : public MainWindow {
Q_OBJECT
public:
MainWindowImp(QWidget *parent=0, const char *name=0);
~MainWindowImp();
private slots:
void getAllInterfaces();
void addClicked();
void removeClicked();
void configureClicked();
void informationClicked();
void addProfile();
void removeProfile();
void changeProfile();
void updateInterface(Interface *i);
void newProfileChanged(const QString& newText);
private:
- void loadModules(QString path);
+ void loadModules(const QString &path);
- Module* loadPlugin(QString pluginFileName,
- QString resolveString = "create_plugin");
+ Module* loadPlugin(const QString &pluginFileName,
+ const QString &resolveString = "create_plugin");
// For our local list of names
QMap<QString, Interface*> interfaceNames;
QMap<Module*, QLibrary*> libraries;
QMap<Interface*, QListViewItem*> items;
QMap<QListViewItem*, Interface*> interfaceItems;
QMap<KProcess*, QString> threads;
QStringList profiles;
bool advancedUserMode;
QString scheme;
};
#endif
// mainwindowimp.h
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
@@ -1,86 +1,86 @@
#ifndef NETCONF_MODULE_H
#define NETCONF_MODULE_H
#include <qobject.h>
#include <qlist.h>
#include <qmap.h>
#include "interface.h"
class QWidget;
class QTabWidget;
class Module : QObject{
signals:
void updateInterface(Interface *i);
public:
Module(){};
/**
* The current profile has been changed and the module should do any
* neccesary changes also.
* @param newProfile what the profile should be changed to.
*/
- virtual void setProfile(QString newProfile) = 0;
+ virtual void setProfile(const QString &newProfile) = 0;
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
virtual QString getPixmapName(Interface *) = 0;
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
virtual bool isOwner(Interface *){ return false; };
/**
* Create and return the WLANConfigure Module
* @param Interface *i the interface to configure.
* @return QWidget* pointer to this modules configure.
*/
virtual QWidget *configure(Interface *){ return NULL; } ;
/**
* Create, and return the Information Module
* @param Interface *i the interface to get info on.
* @return QWidget* pointer to this modules info.
*/
virtual QWidget *information(Interface *){ return NULL; };
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
virtual QList<Interface> getInterfaces() = 0;
/**
* Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
* modem ppp)
*/
virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
/**
* Attempts to create a new interface from name
* @return Interface* NULL if it was unable to be created.
* @param name the type of interface to create
*/
- virtual Interface *addNewInterface(QString name) = 0;
+ virtual Interface *addNewInterface(const QString &name) = 0;
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
virtual bool remove(Interface* i) = 0;
};
#endif
// module.h
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,27 +1,27 @@
#ifndef INFOIMP_H
#define INFOIMP_H
#include "info.h"
class QTimer;
-class WExtensions;
+//class WExtensions;
class WlanInfoImp : public WlanInfo {
Q_OBJECT
public:
WlanInfoImp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
private slots:
void update();
private:
//WExtensions *wExtensions;
QTimer *timer;
};
#endif
// infoimp.h
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
@@ -1,68 +1,67 @@
#include "wextensions.h"
#include <qfile.h>
#include <qtextstream.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <math.h>
#define PROCNETWIRELESS "/proc/net/wireless"
#define IW_LOWER 0
#define IW_UPPER 256
/**
* Constructor. Sets hasWirelessExtensions
*/
-WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){
- interface = interfaceName;
+WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) {
fd = socket( AF_INET, SOCK_DGRAM, 0 );
if(fd == -1)
return;
const char* buffer[200];
memset( &iwr, 0, sizeof( iwr ) );
iwr.u.essid.pointer = (caddr_t) buffer;
iwr.u.essid.length = IW_ESSID_MAX_SIZE;
iwr.u.essid.flags = 0;
// check if it is an IEEE 802.11 standard conform
// wireless device by sending SIOCGIWESSID
// which also gives back the Extended Service Set ID
// (see IEEE 802.11 for more information)
const char* iname = interface.latin1();
strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) )
hasWirelessExtensions = true;
}
/**
* @return QString the station name of the access point.
*/
QString WExtensions::station(){
if(!hasWirelessExtensions)
return QString();
const char* buffer[200];
iwr.u.data.pointer = (caddr_t) buffer;
iwr.u.data.length = IW_ESSID_MAX_SIZE;
iwr.u.data.flags = 0;
if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){
iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0';
return QString(iwr.u.data.pointer);
}
return QString();
}
/**
* @return QString the essid of the host 802.11 access point.
*/
QString WExtensions::essid(){
if(!hasWirelessExtensions)
return QString();
if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){
iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0';
return QString(iwr.u.essid.pointer);
}
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
@@ -1,95 +1,95 @@
#include "wlanimp.h"
#include "interfacesetupimp.h"
#include <qfile.h>
#include <qdir.h>
#include <qtextstream.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qtabwidget.h>
/* system() */
#include <stdlib.h>
#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
/**
* Constructor, read in the wireless.opts file for parsing later.
*/
WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") {
interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);
tabWidget->insertTab(interfaceSetup, "TCP/IP");
// Read in the config file.
QString wlanFile = WIRELESS_OPTS;
QFile file(wlanFile);
if (file.open(IO_ReadOnly)){
QTextStream stream( &file );
QString line = "";
while ( !stream.eof() ) {
line += stream.readLine();
line += "\n";
}
file.close();
settingsFileText = QStringList::split("\n", line, true);
parseSettingFile();
}
else
qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1());
}
/**
* Change the profile for both wireless settings and network settings.
*/
-void WLANImp::setProfile(QString &profile){
+void WLANImp::setProfile(const QString &profile){
interfaceSetup->setProfile(profile);
parseSettingFile();
}
/**
* Parses the settings file that was read in and gets any setting from it.
*/
void WLANImp::parseSettingFile(){
bool foundCase = false;
bool found = false;
for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains("case"))
foundCase = true;
// See if we found our scheme to write or the sceme couldn't be found
if((foundCase && line.contains("esac")) ||
(foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#'))
found = true;
if(line.contains(";;"))
found = false;
if(found){
// write out scheme
if(line.contains("ESSID=")){
QString id = line.mid(line.find("ESSID=")+6, line.length());
if(id == "any"){
essNon->setChecked(true);
essSpecific->setChecked(false);
}else{
essSpecific->setChecked(true);
essSpecificLineEdit->setText(id);
essNon->setChecked(false);
}
}
if(line.contains("MODE=")){
QString mode = line.mid(line.find("MODE=")+5, line.length());
if(mode == "Managed"){
network802->setChecked( false );
networkInfrastructure->setChecked( true );
}
else{
network802->setChecked( true );
networkInfrastructure->setChecked( false );
}
}
if(line.contains("KEY=")){
line.at(0) != '#' ? wepEnabled->setChecked(true) : wepEnabled->setChecked(false);
int s = line.find("KEY=");
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 @@
#ifndef WLANIMP_H
#define WLANIMP_H
#include "wlan.h"
#include <qstringlist.h>
class InterfaceSetupImp;
class Interface;
class Config;
class WLANImp : public WLAN {
Q_OBJECT
public:
WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
- void setProfile(QString &profile);
+ void setProfile(const QString &profile);
protected:
void accept();
private:
void parseSettingFile();
void changeAndSaveSettingFile();
InterfaceSetupImp *interfaceSetup;
QStringList settingsFileText;
QString currentProfile;
};
#endif
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
@@ -1,113 +1,113 @@
#include "wlanmodule.h"
#include "wlanimp.h"
#include "infoimp.h"
#include "wextensions.h"
#include "interfaceinformationimp.h"
#include <qlabel.h>
#include <qprogressbar.h>
#include <qtabwidget.h>
/**
* Constructor, find all of the possible interfaces
*/
WLANModule::WLANModule() : Module() {
}
/**
* Delete any interfaces that we own.
*/
WLANModule::~WLANModule(){
Interface *i;
for ( i=list.first(); i != 0; i=list.next() )
delete i;
}
/**
* Change the current profile
*/
-void WLANModule::setProfile(QString newProfile){
+void WLANModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
QString WLANModule::getPixmapName(Interface* ){
return "wlan";
}
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
bool WLANModule::isOwner(Interface *i){
WExtensions we(i->getInterfaceName());
if(!we.doesHaveWirelessExtensions())
return false;
i->setHardwareName("802.11b");
list.append(i);
return true;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *WLANModule::configure(Interface *i){
WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose);
wlanconfig->setProfile(profile);
return wlanconfig;
}
/**
* Create, and return the Information Module
* @return QWidget* pointer to this modules info.
*/
QWidget *WLANModule::information(Interface *i){
WExtensions we(i->getInterfaceName());
if(!we.doesHaveWirelessExtensions())
return NULL;
WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
info->tabWidget->insertTab(information, "TCP/IP");
return info;
}
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
QList<Interface> WLANModule::getInterfaces(){
return list;
}
/**
* Attempt to add a new interface as defined by name
* @param name the name of the type of interface that should be created given
* by possibleNewInterfaces();
* @return Interface* NULL if it was unable to be created.
*/
-Interface *WLANModule::addNewInterface(QString ){
+Interface *WLANModule::addNewInterface(const QString &){
// We can't add a 802.11 interface, either the hardware will be there
// or it wont.
return NULL;
}
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
bool WLANModule::remove(Interface*){
// Can't remove a hardware device, you can stop it though.
return false;
}
// wlanmodule.cpp
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,41 +1,41 @@
#ifndef WLAN_MODULE_H
#define WLAN_MODULE_H
#include "module.h"
class WLANModule : Module{
signals:
void updateInterface(Interface *i);
public:
WLANModule();
~WLANModule();
- virtual void setProfile(QString newProfile);
- virtual bool isOwner(Interface *);
- virtual QWidget *configure(Interface *i);
- virtual QWidget *information(Interface *i);
- virtual QList<Interface> getInterfaces();
- virtual void possibleNewInterfaces(QMap<QString, QString> &){};
- virtual Interface *addNewInterface(QString name);
- virtual bool remove(Interface* i);
- virtual QString getPixmapName(Interface* i);
+ void setProfile(const QString &newProfile);
+ bool isOwner(Interface *);
+ QWidget *configure(Interface *i);
+ QWidget *information(Interface *i);
+ QList<Interface> getInterfaces();
+ void possibleNewInterfaces(QMap<QString, QString> &){};
+ Interface *addNewInterface(const QString &name);
+ bool remove(Interface* i);
+ QString getPixmapName(Interface* i);
private:
QList<Interface> list;
QString profile;
};
extern "C"
{
void* create_plugin() {
return new WLANModule();
}
};
#endif
// wlanmodule.h