-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 8de30de..f19cbdd 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -90,110 +90,111 @@ bool InterfaceSetupImp::saveSettings(){ | |||
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 | ||
128 | /** | 128 | /** |
129 | * The Profile has changed. | 129 | * The Profile has changed. |
130 | * @param QString profile the new profile. | 130 | * @param QString profile the new profile. |
131 | */ | 131 | */ |
132 | void InterfaceSetupImp::setProfile(const QString &profile){ | 132 | void InterfaceSetupImp::setProfile(const QString &profile){ |
133 | /* | 133 | /* |
134 | bool error = false; | 134 | bool error = false; |
135 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 135 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
136 | staticGroupBox->hide(); | 136 | staticGroupBox->hide(); |
137 | dhcpCheckBox->hide(); | 137 | dhcpCheckBox->hide(); |
138 | leaseTime->hide(); | 138 | leaseTime->hide(); |
139 | leaseHoursLabel->hide(); | 139 | leaseHoursLabel->hide(); |
140 | } | 140 | } |
141 | */ | 141 | */ |
142 | 142 | ||
143 | QString newInterfaceName = interface->getInterfaceName(); | 143 | QString newInterfaceName = interface->getInterfaceName(); |
144 | if(profile.length() > 0) | 144 | if(profile.length() > 0) |
145 | newInterfaceName += "_" + profile; | 145 | newInterfaceName += "_" + profile; |
146 | // See if we have to make a interface. | 146 | // See if we have to make a interface. |
147 | if(!interfaces->setInterface(newInterfaceName)){ | 147 | if(!interfaces->setInterface(newInterfaceName)){ |
148 | // Add making for this new interface if need too | 148 | // Add making for this new interface if need too |
149 | if(profile != ""){ | 149 | if(profile != ""){ |
150 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 150 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
151 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 151 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
152 | interfaces->addMapping(interface->getInterfaceName()); | 152 | interfaces->addMapping(interface->getInterfaceName()); |
153 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 153 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
154 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); | 154 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | interfaces->setMap("map", newInterfaceName); | 158 | interfaces->setMap("map", newInterfaceName); |
159 | interfaces->setScript("getprofile.sh"); | 159 | interfaces->setScript("getprofile.sh"); |
160 | } | 160 | } |
161 | else{ | 161 | else{ |
162 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 162 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
163 | if(!interfaces->setInterface(newInterfaceName)){ | 163 | if(!interfaces->setInterface(newInterfaceName)){ |
164 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); | 164 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | // We must have a valid interface to get this far so read some settings. | 170 | // We must have a valid interface to get this far so read some settings. |
171 | 171 | ||
172 | // DHCP | 172 | // DHCP |
173 | bool error = false; | 173 | bool error = false; |
174 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 174 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
175 | dhcpCheckBox->setChecked(true); | 175 | dhcpCheckBox->setChecked(true); |
176 | else | 176 | else |
177 | dhcpCheckBox->setChecked(false); | 177 | dhcpCheckBox->setChecked(false); |
178 | 178 | ||
179 | // IP Information | 179 | // IP Information |
180 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 180 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
181 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); | 181 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); |
182 | qDebug("dns >%s<",dns.latin1()); | 182 | qDebug("dns >%s<",dns.latin1()); |
183 | if(dns.contains(" ")){ | 183 | if(dns.contains(" ")){ |
184 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 184 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
185 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 185 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
186 | } | 186 | }else firstDNSLineEdit->setText(dns); |
187 | |||
187 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 188 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
188 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 189 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
189 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 190 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
190 | 191 | ||
191 | 192 | ||
192 | 193 | ||
193 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); | 194 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); |
194 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); | 195 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); |
195 | 196 | ||
196 | } | 197 | } |
197 | 198 | ||
198 | // interfacesetup.cpp | 199 | // interfacesetup.cpp |
199 | 200 | ||