-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 57 |
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 @@ | |||
6 | #include <qspinbox.h> | 6 | #include <qspinbox.h> |
7 | #include <qgroupbox.h> | 7 | #include <qgroupbox.h> |
8 | #include <qlabel.h> | 8 | #include <qlabel.h> |
9 | 9 | ||
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | 11 | ||
12 | #include <opie/oprocess.h> | ||
13 | |||
14 | #ifdef QWS | ||
15 | #include <opie/owait.h> | ||
16 | #include <qpe/global.h> | ||
17 | #include <qapplication.h> | ||
18 | #endif | ||
19 | |||
12 | #define DNSSCRIPT "changedns" | 20 | #define DNSSCRIPT "changedns" |
13 | 21 | ||
14 | /** | 22 | /** |
15 | * Constuctor. Set up the connection. A profile must be set. | 23 | * Constuctor. Set up the connection. A profile must be set. |
16 | */ | 24 | */ |
17 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ | 25 | 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(){ | |||
31 | } | 39 | } |
32 | 40 | ||
33 | /** | 41 | /** |
34 | * Save the current settings, then write out the interfaces file and close. | 42 | * Save the current settings, then write out the interfaces file and close. |
35 | */ | 43 | */ |
36 | bool InterfaceSetupImp::saveChanges(){ | 44 | bool InterfaceSetupImp::saveChanges(){ |
45 | bool error; | ||
46 | QString iface = interfaces->getInterfaceName(error); | ||
37 | if(!saveSettings()) | 47 | if(!saveSettings()) |
38 | return false; | 48 | return false; |
49 | |||
50 | qWarning("restarting interface %s\n", iface.latin1()); | ||
39 | interfaces->write(); | 51 | interfaces->write(); |
52 | |||
53 | QString ifup; | ||
54 | ifup += "ifdown "; | ||
55 | ifup += iface; | ||
56 | ifup += "; ifup "; | ||
57 | ifup += iface; | ||
58 | ifup += ";"; | ||
59 | |||
60 | OProcess restart; | ||
61 | restart << "sh"; | ||
62 | restart << "-c"; | ||
63 | restart << ifup; | ||
64 | |||
65 | OWait *owait = new OWait(); | ||
66 | Global::statusMessage( tr( "Restarting interface" ) ); | ||
67 | |||
68 | owait->show(); | ||
69 | qApp->processEvents(); | ||
70 | |||
71 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { | ||
72 | qWarning("unstable to spawn ifdown/ifup"); | ||
73 | } | ||
74 | |||
75 | owait->hide(); | ||
76 | delete owait; | ||
77 | |||
78 | interface->refresh(); | ||
79 | |||
40 | return true; | 80 | return true; |
41 | } | 81 | } |
42 | 82 | ||
43 | /** | 83 | /** |
44 | * Save the settings for the current Interface. | 84 | * Save the settings for the current Interface. |
45 | * @return bool true if successfull, false otherwise | 85 | * @return bool true if successfull, false otherwise |
@@ -57,18 +97,21 @@ bool InterfaceSetupImp::saveSettings(){ | |||
57 | } | 97 | } |
58 | 98 | ||
59 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 99 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
60 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); | 100 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); |
61 | return false; | 101 | return false; |
62 | } | 102 | } |
63 | //interfaces.removeAllInterfaceOptions(); | ||
64 | |||
65 | // DHCP | 103 | // DHCP |
66 | if(dhcpCheckBox->isChecked()) | 104 | if(dhcpCheckBox->isChecked()) { |
67 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 105 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
68 | else{ | 106 | interfaces->removeInterfaceOption("address"); |
107 | interfaces->removeInterfaceOption("netmask"); | ||
108 | interfaces->removeInterfaceOption("gateway"); | ||
109 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | ||
110 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); | ||
111 | } else{ | ||
69 | interfaces->setInterfaceMethod("static"); | 112 | interfaces->setInterfaceMethod("static"); |
70 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 113 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
71 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 114 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
72 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 115 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
73 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 116 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
74 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 117 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
@@ -93,13 +136,13 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
93 | staticGroupBox->hide(); | 136 | staticGroupBox->hide(); |
94 | dhcpCheckBox->hide(); | 137 | dhcpCheckBox->hide(); |
95 | leaseTime->hide(); | 138 | leaseTime->hide(); |
96 | leaseHoursLabel->hide(); | 139 | leaseHoursLabel->hide(); |
97 | } | 140 | } |
98 | */ | 141 | */ |
99 | 142 | ||
100 | QString newInterfaceName = interface->getInterfaceName(); | 143 | QString newInterfaceName = interface->getInterfaceName(); |
101 | if(profile.length() > 0) | 144 | if(profile.length() > 0) |
102 | newInterfaceName += "_" + profile; | 145 | newInterfaceName += "_" + profile; |
103 | // See if we have to make a interface. | 146 | // See if we have to make a interface. |
104 | if(!interfaces->setInterface(newInterfaceName)){ | 147 | if(!interfaces->setInterface(newInterfaceName)){ |
105 | // Add making for this new interface if need too | 148 | // Add making for this new interface if need too |
@@ -140,10 +183,14 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
140 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 183 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
141 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 184 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
142 | } | 185 | } |
143 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 186 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
144 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 187 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
145 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 188 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
189 | |||
190 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); | ||
191 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); | ||
192 | |||
146 | } | 193 | } |
147 | 194 | ||
148 | // interfacesetup.cpp | 195 | // interfacesetup.cpp |
149 | 196 | ||