summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp57
1 files changed, 52 insertions, 5 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index fc65c5f..8d78828 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -6,12 +6,20 @@
#include <qspinbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qmessagebox.h>
+#include <opie/oprocess.h>
+
+#ifdef QWS
+#include <opie/owait.h>
+#include <qpe/global.h>
+#include <qapplication.h>
+#endif
+
#define DNSSCRIPT "changedns"
/**
* Constuctor. Set up the connection. A profile must be set.
*/
InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){
@@ -31,15 +39,47 @@ InterfaceSetupImp::~InterfaceSetupImp(){
}
/**
* Save the current settings, then write out the interfaces file and close.
*/
bool InterfaceSetupImp::saveChanges(){
+ bool error;
+ QString iface = interfaces->getInterfaceName(error);
if(!saveSettings())
return false;
+
+ qWarning("restarting interface %s\n", iface.latin1());
interfaces->write();
+
+ QString ifup;
+ ifup += "ifdown ";
+ ifup += iface;
+ ifup += "; ifup ";
+ ifup += iface;
+ ifup += ";";
+
+ OProcess restart;
+ restart << "sh";
+ restart << "-c";
+ restart << ifup;
+
+ OWait *owait = new OWait();
+ Global::statusMessage( tr( "Restarting interface" ) );
+
+ owait->show();
+ qApp->processEvents();
+
+ if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) {
+ qWarning("unstable to spawn ifdown/ifup");
+ }
+
+ owait->hide();
+ delete owait;
+
+ interface->refresh();
+
return true;
}
/**
* Save the settings for the current Interface.
* @return bool true if successfull, false otherwise
@@ -57,18 +97,21 @@ bool InterfaceSetupImp::saveSettings(){
}
if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
return false;
}
- //interfaces.removeAllInterfaceOptions();
-
// DHCP
- if(dhcpCheckBox->isChecked())
+ if(dhcpCheckBox->isChecked()) {
interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
- else{
+ interfaces->removeInterfaceOption("address");
+ interfaces->removeInterfaceOption("netmask");
+ interfaces->removeInterfaceOption("gateway");
+ interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
+ interfaces->removeInterfaceOption("down "DNSSCRIPT" -r ");
+ } else{
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();
@@ -93,13 +136,13 @@ void InterfaceSetupImp::setProfile(const QString &profile){
staticGroupBox->hide();
dhcpCheckBox->hide();
leaseTime->hide();
leaseHoursLabel->hide();
}
*/
-
+
QString newInterfaceName = interface->getInterfaceName();
if(profile.length() > 0)
newInterfaceName += "_" + profile;
// See if we have to make a interface.
if(!interfaces->setInterface(newInterfaceName)){
// Add making for this new interface if need too
@@ -140,10 +183,14 @@ void InterfaceSetupImp::setProfile(const QString &profile){
firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
}
ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
+
+ qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1());
+ qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1());
+
}
// interfacesetup.cpp