Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfacesetupimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index b40d101..e844d8a 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -23,48 +23,49 @@ | |||
23 | * Constuctor. Set up the connection. A profile must be set. | 23 | * Constuctor. Set up the connection. A profile must be set. |
24 | */ | 24 | */ |
25 | 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){ |
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 | */ |
35 | InterfaceSetupImp::~InterfaceSetupImp(){ | 35 | InterfaceSetupImp::~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 | */ |
44 | bool InterfaceSetupImp::saveChanges(){ | 44 | bool InterfaceSetupImp::saveChanges(){ |
45 | bool error; | 45 | bool error; |
46 | QString iface = interfaces->getInterfaceName(error); | 46 | QString iface = interfaces->getInterfaceName(error); |
47 | qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); | ||
47 | if(!saveSettings()) | 48 | if(!saveSettings()) |
48 | return false; | 49 | return false; |
49 | 50 | ||
50 | interfaces->write(); | 51 | interfaces->write(); |
51 | 52 | ||
52 | if (interface->getStatus()) { | 53 | if (interface->getStatus()) { |
53 | QString ifup; | 54 | QString ifup; |
54 | ifup += "ifdown "; | 55 | ifup += "ifdown "; |
55 | ifup += iface; | 56 | ifup += iface; |
56 | ifup += "; ifup "; | 57 | ifup += "; ifup "; |
57 | ifup += iface; | 58 | ifup += iface; |
58 | ifup += ";"; | 59 | ifup += ";"; |
59 | 60 | ||
60 | OProcess restart; | 61 | OProcess restart; |
61 | restart << "sh"; | 62 | restart << "sh"; |
62 | restart << "-c"; | 63 | restart << "-c"; |
63 | restart << ifup; | 64 | restart << ifup; |
64 | 65 | ||
65 | OWait *owait = new OWait(); | 66 | OWait *owait = new OWait(); |
66 | Global::statusMessage( tr( "Restarting interface" ) ); | 67 | Global::statusMessage( tr( "Restarting interface" ) ); |
67 | 68 | ||
68 | owait->show(); | 69 | owait->show(); |
69 | qApp->processEvents(); | 70 | qApp->processEvents(); |
70 | 71 | ||
@@ -96,48 +97,51 @@ bool InterfaceSetupImp::saveSettings(){ | |||
96 | return true; | 97 | return true; |
97 | } | 98 | } |
98 | 99 | ||
99 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 100 | 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); | 101 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); |
101 | return false; | 102 | return false; |
102 | } | 103 | } |
103 | // DHCP | 104 | // DHCP |
104 | if(dhcpCheckBox->isChecked()) { | 105 | if(dhcpCheckBox->isChecked()) { |
105 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 106 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
106 | interfaces->removeInterfaceOption("address"); | 107 | interfaces->removeInterfaceOption("address"); |
107 | interfaces->removeInterfaceOption("netmask"); | 108 | interfaces->removeInterfaceOption("netmask"); |
108 | interfaces->removeInterfaceOption("gateway"); | 109 | interfaces->removeInterfaceOption("gateway"); |
109 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | 110 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); |
110 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); | 111 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); |
111 | } else{ | 112 | } else{ |
112 | interfaces->setInterfaceMethod("static"); | 113 | interfaces->setInterfaceMethod("static"); |
113 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 114 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
114 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 115 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
115 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 116 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
116 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 117 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
117 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 118 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
118 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 119 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
119 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 120 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
121 | }else{ | ||
122 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | ||
123 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); | ||
120 | } | 124 | } |
121 | } | 125 | } |
122 | 126 | ||
123 | // IP Information | 127 | // IP Information |
124 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 128 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
125 | return true; | 129 | return true; |
126 | } | 130 | } |
127 | 131 | ||
128 | /** | 132 | /** |
129 | * The Profile has changed. | 133 | * The Profile has changed. |
130 | * @param QString profile the new profile. | 134 | * @param QString profile the new profile. |
131 | */ | 135 | */ |
132 | void InterfaceSetupImp::setProfile(const QString &profile){ | 136 | void InterfaceSetupImp::setProfile(const QString &profile){ |
133 | /* | 137 | /* |
134 | bool error = false; | 138 | bool error = false; |
135 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 139 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
136 | staticGroupBox->hide(); | 140 | staticGroupBox->hide(); |
137 | dhcpCheckBox->hide(); | 141 | dhcpCheckBox->hide(); |
138 | leaseTime->hide(); | 142 | leaseTime->hide(); |
139 | leaseHoursLabel->hide(); | 143 | leaseHoursLabel->hide(); |
140 | } | 144 | } |
141 | */ | 145 | */ |
142 | 146 | ||
143 | QString newInterfaceName = interface->getInterfaceName(); | 147 | QString newInterfaceName = interface->getInterfaceName(); |