Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfacesetupimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 8498759..62b1b7a 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -16,47 +16,47 @@ | |||
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | #include <qpe/global.h> | 17 | #include <qpe/global.h> |
18 | #include <qapplication.h> | 18 | #include <qapplication.h> |
19 | #endif | 19 | #endif |
20 | 20 | ||
21 | #define DNSSCRIPT "changedns" | 21 | #define DNSSCRIPT "changedns" |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Constuctor. Set up the connection. A profile must be set. | 24 | * Constuctor. Set up the connection. A profile must be set. |
25 | */ | 25 | */ |
26 | using namespace Opie::Ui; | 26 | using namespace Opie::Ui; |
27 | using namespace Opie::Core; | 27 | using namespace Opie::Core; |
28 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ | 28 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interfaces(j), interface(i), delInterfaces(false){ |
29 | if (j == 0) { | 29 | if (j == 0) { |
30 | delInterfaces = true; | 30 | delInterfaces = true; |
31 | interfaces = new Interfaces; | 31 | interfaces = new Interfaces; |
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Destructor | 36 | * Destructor |
37 | */ | 37 | */ |
38 | InterfaceSetupImp::~InterfaceSetupImp(){ | 38 | InterfaceSetupImp::~InterfaceSetupImp(){ |
39 | if(delInterfaces) { | 39 | if(delInterfaces) { |
40 | delete interfaces; | 40 | delete interfaces; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Save the current settings, then write out the interfaces file and close. | 45 | * Save the current settings, then write out the interfaces file and close. |
46 | */ | 46 | */ |
47 | bool InterfaceSetupImp::saveChanges(){ | 47 | bool InterfaceSetupImp::saveChanges(){ |
48 | bool error; | 48 | bool error; |
49 | QString iface = interfaces->getInterfaceName(error); | 49 | QString iface = interfaces->getInterfaceName(error); |
50 | odebug << "InterfaceSetupImp::saveChanges saves interface " << iface.latin1() << "" << oendl; | 50 | odebug << "InterfaceSetupImp::saveChanges saves interface " << iface.latin1() << "" << oendl; |
51 | if(!saveSettings()) | 51 | if(!saveSettings()) |
52 | return false; | 52 | return false; |
53 | 53 | ||
54 | interfaces->write(); | 54 | interfaces->write(); |
55 | 55 | ||
56 | if (interface->getStatus()) { | 56 | if (interface->getStatus()) { |
57 | QString ifup; | 57 | QString ifup; |
58 | ifup += "ifdown "; | 58 | ifup += "ifdown "; |
59 | ifup += iface; | 59 | ifup += iface; |
60 | ifup += "; ifup "; | 60 | ifup += "; ifup "; |
61 | ifup += iface; | 61 | ifup += iface; |
62 | ifup += ";"; | 62 | ifup += ";"; |
@@ -64,25 +64,25 @@ bool InterfaceSetupImp::saveChanges(){ | |||
64 | OProcess restart; | 64 | OProcess restart; |
65 | restart << "sh"; | 65 | restart << "sh"; |
66 | restart << "-c"; | 66 | restart << "-c"; |
67 | restart << ifup; | 67 | restart << ifup; |
68 | 68 | ||
69 | OWait *owait = new OWait(); | 69 | OWait *owait = new OWait(); |
70 | Global::statusMessage( tr( "Restarting interface" ) ); | 70 | Global::statusMessage( tr( "Restarting interface" ) ); |
71 | 71 | ||
72 | owait->show(); | 72 | owait->show(); |
73 | qApp->processEvents(); | 73 | qApp->processEvents(); |
74 | 74 | ||
75 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { | 75 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { |
76 | owarn << "unstable to spawn ifdown/ifup" << oendl; | 76 | owarn << "unstable to spawn ifdown/ifup" << oendl; |
77 | } | 77 | } |
78 | 78 | ||
79 | owait->hide(); | 79 | owait->hide(); |
80 | delete owait; | 80 | delete owait; |
81 | 81 | ||
82 | interface->refresh(); | 82 | interface->refresh(); |
83 | } | 83 | } |
84 | return true; | 84 | return true; |
85 | } | 85 | } |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * Save the settings for the current Interface. | 88 | * Save the settings for the current Interface. |
@@ -149,61 +149,61 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
149 | 149 | ||
150 | QString newInterfaceName = interface->getInterfaceName(); | 150 | QString newInterfaceName = interface->getInterfaceName(); |
151 | if(profile.length() > 0) | 151 | if(profile.length() > 0) |
152 | newInterfaceName += "_" + profile; | 152 | newInterfaceName += "_" + profile; |
153 | // See if we have to make a interface. | 153 | // See if we have to make a interface. |
154 | if(!interfaces->setInterface(newInterfaceName)){ | 154 | if(!interfaces->setInterface(newInterfaceName)){ |
155 | // Add making for this new interface if need too | 155 | // Add making for this new interface if need too |
156 | if(profile != ""){ | 156 | if(profile != ""){ |
157 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 157 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
158 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 158 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
159 | interfaces->addMapping(interface->getInterfaceName()); | 159 | interfaces->addMapping(interface->getInterfaceName()); |
160 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 160 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
161 | odebug << "InterfaceSetupImp: Added Mapping, but still can't setInterface." << oendl; | 161 | odebug << "InterfaceSetupImp: Added Mapping, but still can't setInterface." << oendl; |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | interfaces->setMap("map", newInterfaceName); | 165 | interfaces->setMap("map", newInterfaceName); |
166 | interfaces->setScript("getprofile.sh"); | 166 | interfaces->setScript("getprofile.sh"); |
167 | } | 167 | } |
168 | else{ | 168 | else{ |
169 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 169 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
170 | if(!interfaces->setInterface(newInterfaceName)){ | 170 | if(!interfaces->setInterface(newInterfaceName)){ |
171 | odebug << "InterfaceSetupImp: Added interface, but still can't setInterface." << oendl; | 171 | odebug << "InterfaceSetupImp: Added interface, but still can't setInterface." << oendl; |
172 | return; | 172 | return; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | // We must have a valid interface to get this far so read some settings. | 177 | // We must have a valid interface to get this far so read some settings. |
178 | 178 | ||
179 | // DHCP | 179 | // DHCP |
180 | bool error = false; | 180 | bool error = false; |
181 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 181 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
182 | dhcpCheckBox->setChecked(true); | 182 | dhcpCheckBox->setChecked(true); |
183 | else | 183 | else |
184 | dhcpCheckBox->setChecked(false); | 184 | dhcpCheckBox->setChecked(false); |
185 | 185 | ||
186 | // IP Information | 186 | // IP Information |
187 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 187 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
188 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); | 188 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); |
189 | odebug << "dns >" << dns.latin1() << "<" << oendl; | 189 | odebug << "dns >" << dns.latin1() << "<" << oendl; |
190 | if(dns.contains(" ")){ | 190 | if(dns.contains(" ")){ |
191 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 191 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
192 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 192 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
193 | }else firstDNSLineEdit->setText(dns); | 193 | }else firstDNSLineEdit->setText(dns); |
194 | 194 | ||
195 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 195 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
196 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 196 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
197 | if (subnetMaskEdit->text().isEmpty()) | 197 | if (subnetMaskEdit->text().isEmpty()) |
198 | subnetMaskEdit->setText( "255.255.255.0" ); | 198 | subnetMaskEdit->setText( "255.255.255.0" ); |
199 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 199 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
200 | 200 | ||
201 | 201 | ||
202 | 202 | ||
203 | owarn << "InterfaceSetupImp::setProfile(" << profile.latin1() << ")\n" << oendl; | 203 | owarn << "InterfaceSetupImp::setProfile(" << profile.latin1() << ")\n" << oendl; |
204 | owarn << "InterfaceSetupImp::setProfile: iface is " << interfaces->getInterfaceName(error).latin1() << "\n" << oendl; | 204 | owarn << "InterfaceSetupImp::setProfile: iface is " << interfaces->getInterfaceName(error).latin1() << "\n" << oendl; |
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | // interfacesetup.cpp | 208 | // interfacesetup.cpp |
209 | 209 | ||