summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index 8d78828..49a47ae 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -2,126 +2,126 @@
2#include "interface.h" 2#include "interface.h"
3 3
4#include <qcheckbox.h> 4#include <qcheckbox.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
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> 12#include <opie/oprocess.h>
13 13
14#ifdef QWS 14#ifdef QWS
15#include <opie/owait.h> 15#include <opie/owait.h>
16#include <qpe/global.h> 16#include <qpe/global.h>
17#include <qapplication.h> 17#include <qapplication.h>
18#endif 18#endif
19 19
20#define DNSSCRIPT "changedns" 20#define DNSSCRIPT "changedns"
21 21
22/** 22/**
23 * Constuctor. Set up the connection. A profile must be set. 23 * Constuctor. Set up the connection. A profile must be set.
24 */ 24 */
25InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ 25InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){
26 if (j == 0) { 26 if (j == 0) {
27 delInterfaces = true; 27 delInterfaces = true;
28 interfaces = new Interfaces; 28 interfaces = new Interfaces;
29 } 29 }
30} 30}
31 31
32/** 32/**
33 * Destructor 33 * Destructor
34 */ 34 */
35InterfaceSetupImp::~InterfaceSetupImp(){ 35InterfaceSetupImp::~InterfaceSetupImp(){
36 if(delInterfaces) { 36 if(delInterfaces) {
37 delete interfaces; 37 delete interfaces;
38 } 38 }
39} 39}
40 40
41/** 41/**
42 * 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.
43 */ 43 */
44bool InterfaceSetupImp::saveChanges(){ 44bool InterfaceSetupImp::saveChanges(){
45 bool error; 45 bool error;
46 QString iface = interfaces->getInterfaceName(error); 46 QString iface = interfaces->getInterfaceName(error);
47 if(!saveSettings()) 47 if(!saveSettings())
48 return false; 48 return false;
49 49
50 qWarning("restarting interface %s\n", iface.latin1());
51 interfaces->write(); 50 interfaces->write();
52 51
53 QString ifup; 52 if (interface->getStatus()) {
54 ifup += "ifdown "; 53 QString ifup;
55 ifup += iface; 54 ifup += "ifdown ";
56 ifup += "; ifup "; 55 ifup += iface;
57 ifup += iface; 56 ifup += "; ifup ";
58 ifup += ";"; 57 ifup += iface;
59 58 ifup += ";";
60 OProcess restart; 59
61 restart << "sh"; 60 OProcess restart;
62 restart << "-c"; 61 restart << "sh";
63 restart << ifup; 62 restart << "-c";
64 63 restart << ifup;
65 OWait *owait = new OWait(); 64
66 Global::statusMessage( tr( "Restarting interface" ) ); 65 OWait *owait = new OWait();
67 66 Global::statusMessage( tr( "Restarting interface" ) );
68 owait->show(); 67
69 qApp->processEvents(); 68 owait->show();
70 69 qApp->processEvents();
71 if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { 70
72 qWarning("unstable to spawn ifdown/ifup"); 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();
73 } 79 }
74
75 owait->hide();
76 delete owait;
77
78 interface->refresh();
79
80 return true; 80 return true;
81} 81}
82 82
83/** 83/**
84 * Save the settings for the current Interface. 84 * Save the settings for the current Interface.
85 * @return bool true if successfull, false otherwise 85 * @return bool true if successfull, false otherwise
86 */ 86 */
87bool InterfaceSetupImp::saveSettings(){ 87bool InterfaceSetupImp::saveSettings(){
88 // eh can't really do anything about it other then return. :-D 88 // eh can't really do anything about it other then return. :-D
89 if(!interfaces->isInterfaceSet()) 89 if(!interfaces->isInterfaceSet())
90 return true; 90 return true;
91 91
92 bool error = false; 92 bool error = false;
93 // Loopback case 93 // Loopback case
94 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 94 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
95 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 95 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
96 return true; 96 return true;
97 } 97 }
98 98
99 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ 99 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
100 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);
101 return false; 101 return false;
102 } 102 }
103 // DHCP 103 // DHCP
104 if(dhcpCheckBox->isChecked()) { 104 if(dhcpCheckBox->isChecked()) {
105 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); 105 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
106 interfaces->removeInterfaceOption("address"); 106 interfaces->removeInterfaceOption("address");
107 interfaces->removeInterfaceOption("netmask"); 107 interfaces->removeInterfaceOption("netmask");
108 interfaces->removeInterfaceOption("gateway"); 108 interfaces->removeInterfaceOption("gateway");
109 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); 109 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
110 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); 110 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r ");
111 } else{ 111 } else{
112 interfaces->setInterfaceMethod("static"); 112 interfaces->setInterfaceMethod("static");
113 interfaces->setInterfaceOption("address", ipAddressEdit->text()); 113 interfaces->setInterfaceOption("address", ipAddressEdit->text());
114 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); 114 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
115 interfaces->setInterfaceOption("gateway", gatewayEdit->text()); 115 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
116 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ 116 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
117 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); 117 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
118 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); 118 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
119 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); 119 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
120 } 120 }
121 } 121 }
122 122
123 // IP Information 123 // IP Information
124 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 124 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
125 return true; 125 return true;
126} 126}
127 127