author | kergoth <kergoth> | 2003-04-15 00:40:18 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-15 00:40:18 (UTC) |
commit | 414e71d6189ffdeb07dcca8225ecf69331d0023c (patch) (unidiff) | |
tree | 7f24b2508735537171aa308c20d499b696c0151a | |
parent | 54c3c91b776f277fdcf2e78621a28e98cc55ab5b (diff) | |
download | opie-414e71d6189ffdeb07dcca8225ecf69331d0023c.zip opie-414e71d6189ffdeb07dcca8225ecf69331d0023c.tar.gz opie-414e71d6189ffdeb07dcca8225ecf69331d0023c.tar.bz2 |
1) When selecting dhcp, remove the static options, since we're no longer
removing all options.
2) Restart the network interface when saveChanges() is called.
3) Use OWait and a status message to give feedback to the user during
the interface restart.
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 55 |
1 files changed, 51 insertions, 4 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 | |||
@@ -9,6 +9,14 @@ | |||
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 | /** |
@@ -34,9 +42,41 @@ InterfaceSetupImp::~InterfaceSetupImp(){ | |||
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 | ||
@@ -60,12 +100,15 @@ bool InterfaceSetupImp::saveSettings(){ | |||
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()); |
@@ -143,6 +186,10 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
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 |