8 files changed, 186 insertions, 192 deletions
diff --git a/noncore/net/networksetup/interfaces/interfaces.cpp b/noncore/net/networksetup/interfaces/interfaces.cpp index 708f399..e49998e 100644 --- a/noncore/net/networksetup/interfaces/interfaces.cpp +++ b/noncore/net/networksetup/interfaces/interfaces.cpp @@ -6,2 +6,3 @@ +// The three stanza's #define AUTO "auto" @@ -104,2 +105,3 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ } + // else see if we need to remove from this one else{ @@ -107,6 +109,4 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ (*it) = (*it).replace(QRegExp(interface), ""); - // clean up - QString line = (*it).simplifyWhiteSpace(); - line = line.replace(QRegExp(" "),""); - if(line == AUTO) + // if AUTO is the only thing left clear the line + if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) (*it) = ""; @@ -118,9 +118,5 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ } - 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()); - } - } + // In the case where there is no AUTO field add one. + if(!changed && setAuto) + interfaces.append(QString(AUTO" %1").arg(interface)); return true; @@ -159,3 +155,3 @@ bool Interfaces::isInterfaceSet(){ bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ - if(acceptedFamily.contains(family)==0) + if(0 == acceptedFamily.contains(family)) return false; @@ -174,4 +170,6 @@ bool Interfaces::addInterface(const QString &interface, const QString &family, c bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ - if(!setInterface(interface)) return false; - + if(!setInterface(interface)) + return false; + + // Store the old interface and bump past the stanza line. QStringList::Iterator it = currentIface; @@ -179,8 +177,12 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter + // Add the new interface bool error; addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); - if(!setInterface(newInterface)) return false; + if(!setInterface(newInterface)) + return false; + QStringList::Iterator newIface = currentIface; newIface++; - + + // Copy all of the lines for ( ; it != interfaces.end(); ++it ){ @@ -199,6 +201,3 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter bool Interfaces::removeInterface(){ - if(currentIface == interfaces.end()) - return false; - (*currentIface) = ""; - return removeAllInterfaceOptions(); + return removeStanza(currentIface); } @@ -234,6 +233,4 @@ QString Interfaces::getInterfaceFamily(bool &error){ QString name = getInterfaceName(error); - if(error){ - error = true; + if(error) return QString(); - } QString line = (*currentIface); @@ -259,11 +256,7 @@ QString Interfaces::getInterfaceMethod(bool &error){ QString name = getInterfaceName(error); - if(error){ - error = true; + if(error) return QString(); - } QString family = getInterfaceFamily(error); - if(error){ - error = true; + if(error) return QString(); - } QString line = (*currentIface); @@ -393,6 +386,3 @@ void Interfaces::addMapping(const QString &option){ bool Interfaces::removeMapping(){ - if(currentMapping == interfaces.end()) - return false; - (*currentMapping) = ""; - return removeAllOptions(currentMapping); + return removeStanza(currentMapping); } @@ -522,2 +512,15 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op } + +/** + * Removes a stanza and all of its options + * @param stanza the stanza to remove + * @return bool true if successfull. + */ +bool Interfaces::removeStanza(QStringList::Iterator &stanza){ + if(stanza == interfaces.end()) + return false; + (*stanza) = ""; + return removeAllOptions(stanza); +} + /** @@ -593,3 +596,3 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString 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()); + qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); found = true; @@ -597,6 +600,6 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString int space = line.find(" ", option.length()); - if(space != -1) + if(space != -1){ value = line.mid(space+1, line.length()); - else - qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); + break; + } } diff --git a/noncore/net/networksetup/interfaces/interfaces.h b/noncore/net/networksetup/interfaces/interfaces.h index 26abb73..5a8feb6 100644 --- a/noncore/net/networksetup/interfaces/interfaces.h +++ b/noncore/net/networksetup/interfaces/interfaces.h @@ -30,3 +30,3 @@ public: - bool removeInterface(); + inline bool removeInterface(); bool addInterface(const QString &interface, const QString &family, const QString &method); @@ -47,3 +47,3 @@ public: bool setMapping(const QString &interface); - bool removeMapping(); + inline bool removeMapping(); inline void addMapping(const QString &options); @@ -62,2 +62,3 @@ private: QString getOption(const QStringList::Iterator &start, const QString &option, bool &error); + bool removeStanza(QStringList::Iterator &stanza); bool removeAllOptions(const QStringList::Iterator &start); diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp index 3b1a4de..4818e37 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp @@ -2,6 +2,3 @@ #include "interface.h" -#include "interfaces.h" -#include <qdialog.h> -#include <qcombobox.h> #include <qcheckbox.h> @@ -14,4 +11,2 @@ -#include <assert.h> - #define DNSSCRIPT "changedns" @@ -19,16 +14,5 @@ /** - * Constuctor. Set up the connection and load the first profile. + * Constuctor. Set up the connection. A profile must be set. */ -InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ - assert(parent); - assert(i); - interface = i; - interfaces = new Interfaces(); - bool error = false; - if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ - staticGroupBox->hide(); - dhcpCheckBox->hide(); - leaseTime->hide(); - leaseHoursLabel->hide(); - } +InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i){ } @@ -41,3 +25,3 @@ bool InterfaceSetupImp::saveChanges(){ return false; - interfaces->write(); + interfaces.write(); return true; @@ -51,3 +35,3 @@ bool InterfaceSetupImp::saveSettings(){ // eh can't really do anything about it other then return. :-D - if(!interfaces->isInterfaceSet()) + if(!interfaces.isInterfaceSet()) return true; @@ -56,4 +40,4 @@ bool InterfaceSetupImp::saveSettings(){ // Loopback case - if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ - interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); + if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ + interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked()); return true; @@ -65,3 +49,3 @@ bool InterfaceSetupImp::saveSettings(){ } - interfaces->removeAllInterfaceOptions(); + interfaces.removeAllInterfaceOptions(); @@ -69,15 +53,15 @@ bool InterfaceSetupImp::saveSettings(){ if(dhcpCheckBox->isChecked()){ - interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); - interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); - interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); + interfaces.setInterfaceMethod(INTERFACES_METHOD_DHCP); + interfaces.setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); + interfaces.setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); } else{ - interfaces->setInterfaceMethod("static"); - interfaces->setInterfaceOption("address", ipAddressEdit->text()); - interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); - interfaces->setInterfaceOption("gateway", gatewayEdit->text()); + interfaces.setInterfaceMethod("static"); + interfaces.setInterfaceOption("address", ipAddressEdit->text()); + interfaces.setInterfaceOption("netmask", subnetMaskEdit->text()); + interfaces.setInterfaceOption("gateway", gatewayEdit->text()); if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); - interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); - interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); + interfaces.setInterfaceOption("up "DNSSCRIPT" -a ", dns); + interfaces.setInterfaceOption("down "DNSSCRIPT" -r ", dns); } @@ -86,3 +70,3 @@ bool InterfaceSetupImp::saveSettings(){ // IP Information - interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); + interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked()); return true; @@ -92,5 +76,15 @@ bool InterfaceSetupImp::saveSettings(){ * The Profile has changed. - * @profile the new profile. + * @param QString profile the new profile. */ void InterfaceSetupImp::setProfile(const QString &profile){ + /* + bool error = false; + if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ + staticGroupBox->hide(); + dhcpCheckBox->hide(); + leaseTime->hide(); + leaseHoursLabel->hide(); + } + */ + QString newInterfaceName = interface->getInterfaceName(); @@ -98,12 +92,11 @@ void InterfaceSetupImp::setProfile(const QString &profile){ newInterfaceName += "_" + profile; - qDebug("InterfaceSetupImp::setProfile"); // See if we have to make a interface. - if(!interfaces->setInterface(newInterfaceName)){ + if(!interfaces.setInterface(newInterfaceName)){ // Add making for this new interface if need too if(profile != ""){ - interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); - if(!interfaces->setMapping(interface->getInterfaceName())){ - interfaces->addMapping(interface->getInterfaceName()); - if(!interfaces->setMapping(interface->getInterfaceName())){ - qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); + interfaces.copyInterface(interface->getInterfaceName(), newInterfaceName); + if(!interfaces.setMapping(interface->getInterfaceName())){ + interfaces.addMapping(interface->getInterfaceName()); + if(!interfaces.setMapping(interface->getInterfaceName())){ + qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); return; @@ -111,9 +104,9 @@ void InterfaceSetupImp::setProfile(const QString &profile){ } - interfaces->setMap("map", newInterfaceName); - interfaces->setScript("getprofile.sh"); + interfaces.setMap("map", newInterfaceName); + interfaces.setScript("getprofile.sh"); } else{ - interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); - if(!interfaces->setInterface(newInterfaceName)){ - qDebug("InterfaceSetupImp: Added interface, but still can't set."); + interfaces.addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); + if(!interfaces.setInterface(newInterfaceName)){ + qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); return; @@ -127,3 +120,3 @@ void InterfaceSetupImp::setProfile(const QString &profile){ bool error = false; - if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) + if(interfaces.getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) dhcpCheckBox->setChecked(true); @@ -131,5 +124,5 @@ void InterfaceSetupImp::setProfile(const QString &profile){ dhcpCheckBox->setChecked(false); - leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); + leaseTime->setValue(interfaces.getInterfaceOption("leasehours", error).toInt()); if(error) - leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); + leaseTime->setValue(interfaces.getInterfaceOption("leasetime", error).toInt()/60/60); if(error) @@ -138,4 +131,4 @@ void InterfaceSetupImp::setProfile(const QString &profile){ // IP Information - autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); - QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); + autoStart->setChecked(interfaces.isAuto(interface->getInterfaceName())); + QString dns = interfaces.getInterfaceOption("up "DNSSCRIPT" -a", error); if(dns.contains(" ")){ @@ -144,7 +137,7 @@ void InterfaceSetupImp::setProfile(const QString &profile){ } - ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); - subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); - gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); -} + ipAddressEdit->setText(interfaces.getInterfaceOption("address", error)); + subnetMaskEdit->setText(interfaces.getInterfaceOption("netmask", error)); + gatewayEdit->setText(interfaces.getInterfaceOption("gateway", error)); +} diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.h b/noncore/net/networksetup/interfaces/interfacesetupimp.h index 60933aa..9ec526c 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.h +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.h @@ -4,2 +4,3 @@ #include "interfacesetup.h" +#include "interfaces.h" #include <qdialog.h> @@ -7,3 +8,2 @@ class Interface; -class Interfaces; @@ -21,3 +21,3 @@ public slots: private: - Interfaces *interfaces; + Interfaces interfaces; Interface *interface; diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index 708f399..e49998e 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp @@ -6,2 +6,3 @@ +// The three stanza's #define AUTO "auto" @@ -104,2 +105,3 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ } + // else see if we need to remove from this one else{ @@ -107,6 +109,4 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ (*it) = (*it).replace(QRegExp(interface), ""); - // clean up - QString line = (*it).simplifyWhiteSpace(); - line = line.replace(QRegExp(" "),""); - if(line == AUTO) + // if AUTO is the only thing left clear the line + if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) (*it) = ""; @@ -118,9 +118,5 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ } - 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()); - } - } + // In the case where there is no AUTO field add one. + if(!changed && setAuto) + interfaces.append(QString(AUTO" %1").arg(interface)); return true; @@ -159,3 +155,3 @@ bool Interfaces::isInterfaceSet(){ bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ - if(acceptedFamily.contains(family)==0) + if(0 == acceptedFamily.contains(family)) return false; @@ -174,4 +170,6 @@ bool Interfaces::addInterface(const QString &interface, const QString &family, c bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ - if(!setInterface(interface)) return false; - + if(!setInterface(interface)) + return false; + + // Store the old interface and bump past the stanza line. QStringList::Iterator it = currentIface; @@ -179,8 +177,12 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter + // Add the new interface bool error; addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); - if(!setInterface(newInterface)) return false; + if(!setInterface(newInterface)) + return false; + QStringList::Iterator newIface = currentIface; newIface++; - + + // Copy all of the lines for ( ; it != interfaces.end(); ++it ){ @@ -199,6 +201,3 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter bool Interfaces::removeInterface(){ - if(currentIface == interfaces.end()) - return false; - (*currentIface) = ""; - return removeAllInterfaceOptions(); + return removeStanza(currentIface); } @@ -234,6 +233,4 @@ QString Interfaces::getInterfaceFamily(bool &error){ QString name = getInterfaceName(error); - if(error){ - error = true; + if(error) return QString(); - } QString line = (*currentIface); @@ -259,11 +256,7 @@ QString Interfaces::getInterfaceMethod(bool &error){ QString name = getInterfaceName(error); - if(error){ - error = true; + if(error) return QString(); - } QString family = getInterfaceFamily(error); - if(error){ - error = true; + if(error) return QString(); - } QString line = (*currentIface); @@ -393,6 +386,3 @@ void Interfaces::addMapping(const QString &option){ bool Interfaces::removeMapping(){ - if(currentMapping == interfaces.end()) - return false; - (*currentMapping) = ""; - return removeAllOptions(currentMapping); + return removeStanza(currentMapping); } @@ -522,2 +512,15 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op } + +/** + * Removes a stanza and all of its options + * @param stanza the stanza to remove + * @return bool true if successfull. + */ +bool Interfaces::removeStanza(QStringList::Iterator &stanza){ + if(stanza == interfaces.end()) + return false; + (*stanza) = ""; + return removeAllOptions(stanza); +} + /** @@ -593,3 +596,3 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString 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()); + qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); found = true; @@ -597,6 +600,6 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString int space = line.find(" ", option.length()); - if(space != -1) + if(space != -1){ value = line.mid(space+1, line.length()); - else - qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); + break; + } } diff --git a/noncore/settings/networksettings/interfaces/interfaces.h b/noncore/settings/networksettings/interfaces/interfaces.h index 26abb73..5a8feb6 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.h +++ b/noncore/settings/networksettings/interfaces/interfaces.h @@ -30,3 +30,3 @@ public: - bool removeInterface(); + inline bool removeInterface(); bool addInterface(const QString &interface, const QString &family, const QString &method); @@ -47,3 +47,3 @@ public: bool setMapping(const QString &interface); - bool removeMapping(); + inline bool removeMapping(); inline void addMapping(const QString &options); @@ -62,2 +62,3 @@ private: QString getOption(const QStringList::Iterator &start, const QString &option, bool &error); + bool removeStanza(QStringList::Iterator &stanza); bool removeAllOptions(const QStringList::Iterator &start); diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 3b1a4de..4818e37 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp @@ -2,6 +2,3 @@ #include "interface.h" -#include "interfaces.h" -#include <qdialog.h> -#include <qcombobox.h> #include <qcheckbox.h> @@ -14,4 +11,2 @@ -#include <assert.h> - #define DNSSCRIPT "changedns" @@ -19,16 +14,5 @@ /** - * Constuctor. Set up the connection and load the first profile. + * Constuctor. Set up the connection. A profile must be set. */ -InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ - assert(parent); - assert(i); - interface = i; - interfaces = new Interfaces(); - bool error = false; - if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ - staticGroupBox->hide(); - dhcpCheckBox->hide(); - leaseTime->hide(); - leaseHoursLabel->hide(); - } +InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i){ } @@ -41,3 +25,3 @@ bool InterfaceSetupImp::saveChanges(){ return false; - interfaces->write(); + interfaces.write(); return true; @@ -51,3 +35,3 @@ bool InterfaceSetupImp::saveSettings(){ // eh can't really do anything about it other then return. :-D - if(!interfaces->isInterfaceSet()) + if(!interfaces.isInterfaceSet()) return true; @@ -56,4 +40,4 @@ bool InterfaceSetupImp::saveSettings(){ // Loopback case - if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ - interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); + if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ + interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked()); return true; @@ -65,3 +49,3 @@ bool InterfaceSetupImp::saveSettings(){ } - interfaces->removeAllInterfaceOptions(); + interfaces.removeAllInterfaceOptions(); @@ -69,15 +53,15 @@ bool InterfaceSetupImp::saveSettings(){ if(dhcpCheckBox->isChecked()){ - interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); - interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); - interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); + interfaces.setInterfaceMethod(INTERFACES_METHOD_DHCP); + interfaces.setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); + interfaces.setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); } else{ - interfaces->setInterfaceMethod("static"); - interfaces->setInterfaceOption("address", ipAddressEdit->text()); - interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); - interfaces->setInterfaceOption("gateway", gatewayEdit->text()); + interfaces.setInterfaceMethod("static"); + interfaces.setInterfaceOption("address", ipAddressEdit->text()); + interfaces.setInterfaceOption("netmask", subnetMaskEdit->text()); + interfaces.setInterfaceOption("gateway", gatewayEdit->text()); if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); - interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); - interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); + interfaces.setInterfaceOption("up "DNSSCRIPT" -a ", dns); + interfaces.setInterfaceOption("down "DNSSCRIPT" -r ", dns); } @@ -86,3 +70,3 @@ bool InterfaceSetupImp::saveSettings(){ // IP Information - interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); + interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked()); return true; @@ -92,5 +76,15 @@ bool InterfaceSetupImp::saveSettings(){ * The Profile has changed. - * @profile the new profile. + * @param QString profile the new profile. */ void InterfaceSetupImp::setProfile(const QString &profile){ + /* + bool error = false; + if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ + staticGroupBox->hide(); + dhcpCheckBox->hide(); + leaseTime->hide(); + leaseHoursLabel->hide(); + } + */ + QString newInterfaceName = interface->getInterfaceName(); @@ -98,12 +92,11 @@ void InterfaceSetupImp::setProfile(const QString &profile){ newInterfaceName += "_" + profile; - qDebug("InterfaceSetupImp::setProfile"); // See if we have to make a interface. - if(!interfaces->setInterface(newInterfaceName)){ + if(!interfaces.setInterface(newInterfaceName)){ // Add making for this new interface if need too if(profile != ""){ - interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); - if(!interfaces->setMapping(interface->getInterfaceName())){ - interfaces->addMapping(interface->getInterfaceName()); - if(!interfaces->setMapping(interface->getInterfaceName())){ - qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); + interfaces.copyInterface(interface->getInterfaceName(), newInterfaceName); + if(!interfaces.setMapping(interface->getInterfaceName())){ + interfaces.addMapping(interface->getInterfaceName()); + if(!interfaces.setMapping(interface->getInterfaceName())){ + qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); return; @@ -111,9 +104,9 @@ void InterfaceSetupImp::setProfile(const QString &profile){ } - interfaces->setMap("map", newInterfaceName); - interfaces->setScript("getprofile.sh"); + interfaces.setMap("map", newInterfaceName); + interfaces.setScript("getprofile.sh"); } else{ - interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); - if(!interfaces->setInterface(newInterfaceName)){ - qDebug("InterfaceSetupImp: Added interface, but still can't set."); + interfaces.addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); + if(!interfaces.setInterface(newInterfaceName)){ + qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); return; @@ -127,3 +120,3 @@ void InterfaceSetupImp::setProfile(const QString &profile){ bool error = false; - if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) + if(interfaces.getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) dhcpCheckBox->setChecked(true); @@ -131,5 +124,5 @@ void InterfaceSetupImp::setProfile(const QString &profile){ dhcpCheckBox->setChecked(false); - leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); + leaseTime->setValue(interfaces.getInterfaceOption("leasehours", error).toInt()); if(error) - leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); + leaseTime->setValue(interfaces.getInterfaceOption("leasetime", error).toInt()/60/60); if(error) @@ -138,4 +131,4 @@ void InterfaceSetupImp::setProfile(const QString &profile){ // IP Information - autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); - QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); + autoStart->setChecked(interfaces.isAuto(interface->getInterfaceName())); + QString dns = interfaces.getInterfaceOption("up "DNSSCRIPT" -a", error); if(dns.contains(" ")){ @@ -144,7 +137,7 @@ void InterfaceSetupImp::setProfile(const QString &profile){ } - ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); - subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); - gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); -} + ipAddressEdit->setText(interfaces.getInterfaceOption("address", error)); + subnetMaskEdit->setText(interfaces.getInterfaceOption("netmask", error)); + gatewayEdit->setText(interfaces.getInterfaceOption("gateway", error)); +} diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.h b/noncore/settings/networksettings/interfaces/interfacesetupimp.h index 60933aa..9ec526c 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.h +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.h @@ -4,2 +4,3 @@ #include "interfacesetup.h" +#include "interfaces.h" #include <qdialog.h> @@ -7,3 +8,2 @@ class Interface; -class Interfaces; @@ -21,3 +21,3 @@ public slots: private: - Interfaces *interfaces; + Interfaces interfaces; Interface *interface; |