Diffstat (limited to 'noncore/net/networksetup/interfacesetupimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/interfacesetupimp.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/noncore/net/networksetup/interfacesetupimp.cpp b/noncore/net/networksetup/interfacesetupimp.cpp index 951aeee..c16d821 100644 --- a/noncore/net/networksetup/interfacesetupimp.cpp +++ b/noncore/net/networksetup/interfacesetupimp.cpp @@ -21,17 +21,15 @@ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){ assert(i); interface = i; interfaces = new Interfaces(); - changeProfile(profileCombo->currentText()); bool error = false; if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ staticGroupBox->hide(); dhcpCheckBox->hide(); leaseTime->hide(); leaseHoursLabel->hide(); } - connect(profileCombo, SIGNAL(highlighted(const QString &)), this, SLOT(changeProfile(const QString &))); } /** * Save the current settings, then write out the interfaces file and close. @@ -89,37 +87,36 @@ bool InterfaceSetupImp::saveSettings(){ /** * The Profile has changed. * @profile the new profile. */ -void InterfaceSetupImp::changeProfile(const QString &profile){ - QString newInterfaceName; - if(profile.lower() == "all") - newInterfaceName = interface->getInterfaceName(); - else - newInterfaceName = interface->getInterfaceName() + "_" + profile; - if(newInterfaceName == currentInterfaceName) - return; - else{ - saveSettings(); - currentInterfaceName = newInterfaceName; - } - bool error = interfaces->setInterface(currentInterfaceName); +void InterfaceSetupImp::setProfile(const QString &profile){ + QString newInterfaceName = interface->getInterfaceName() + profile; // See if we have to make a interface. - if(error){ - qDebug("InterfaceSetupImp: Adding a new interface from profile change."); - interfaces->addInterface(currentInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); - error = interfaces->setInterface(currentInterfaceName); - if(error){ + if(!interfaces->setInterface(newInterfaceName)){ + interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); + if(!interfaces->setInterface(newInterfaceName)){ qDebug("InterfaceSetupImp: Added interface, but still can't set."); return; } + // Add making for this new interface if need too + if(profile != ""){ + if(!interfaces->setMapping(interface->getInterfaceName())){ + interfaces->addMapping(interface->getInterfaceName()); + if(!interfaces->setMapping(interface->getInterfaceName())){ + qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); + return; + } + } + interfaces->setScript("getprofile.sh"); + interfaces->setMap("map", newInterfaceName); + } } - //qDebug( currentInterfaceName.latin1() ); // We must have a valid interface to get this far so read some settings. // DHCP + bool error = false; if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) dhcpCheckBox->setChecked(true); else dhcpCheckBox->setChecked(false); |