Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfacesetupimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 7c2f85c..ec3bad3 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -25,75 +25,75 @@ | |||
25 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
26 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
27 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ | 27 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ |
28 | if (j == 0) { | 28 | if (j == 0) { |
29 | delInterfaces = true; | 29 | delInterfaces = true; |
30 | interfaces = new Interfaces; | 30 | interfaces = new Interfaces; |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Destructor | 35 | * Destructor |
36 | */ | 36 | */ |
37 | InterfaceSetupImp::~InterfaceSetupImp(){ | 37 | InterfaceSetupImp::~InterfaceSetupImp(){ |
38 | if(delInterfaces) { | 38 | if(delInterfaces) { |
39 | delete interfaces; | 39 | delete interfaces; |
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Save the current settings, then write out the interfaces file and close. | 44 | * Save the current settings, then write out the interfaces file and close. |
45 | */ | 45 | */ |
46 | bool InterfaceSetupImp::saveChanges(){ | 46 | bool InterfaceSetupImp::saveChanges(){ |
47 | bool error; | 47 | bool error; |
48 | QString iface = interfaces->getInterfaceName(error); | 48 | QString iface = interfaces->getInterfaceName(error); |
49 | qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); | 49 | odebug << "InterfaceSetupImp::saveChanges saves interface " << iface.latin1() << "" << oendl; |
50 | if(!saveSettings()) | 50 | if(!saveSettings()) |
51 | return false; | 51 | return false; |
52 | 52 | ||
53 | interfaces->write(); | 53 | interfaces->write(); |
54 | 54 | ||
55 | if (interface->getStatus()) { | 55 | if (interface->getStatus()) { |
56 | QString ifup; | 56 | QString ifup; |
57 | ifup += "ifdown "; | 57 | ifup += "ifdown "; |
58 | ifup += iface; | 58 | ifup += iface; |
59 | ifup += "; ifup "; | 59 | ifup += "; ifup "; |
60 | ifup += iface; | 60 | ifup += iface; |
61 | ifup += ";"; | 61 | ifup += ";"; |
62 | 62 | ||
63 | OProcess restart; | 63 | OProcess restart; |
64 | restart << "sh"; | 64 | restart << "sh"; |
65 | restart << "-c"; | 65 | restart << "-c"; |
66 | restart << ifup; | 66 | restart << ifup; |
67 | 67 | ||
68 | OWait *owait = new OWait(); | 68 | OWait *owait = new OWait(); |
69 | Global::statusMessage( tr( "Restarting interface" ) ); | 69 | Global::statusMessage( tr( "Restarting interface" ) ); |
70 | 70 | ||
71 | owait->show(); | 71 | owait->show(); |
72 | qApp->processEvents(); | 72 | qApp->processEvents(); |
73 | 73 | ||
74 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { | 74 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { |
75 | qWarning("unstable to spawn ifdown/ifup"); | 75 | owarn << "unstable to spawn ifdown/ifup" << oendl; |
76 | } | 76 | } |
77 | 77 | ||
78 | owait->hide(); | 78 | owait->hide(); |
79 | delete owait; | 79 | delete owait; |
80 | 80 | ||
81 | interface->refresh(); | 81 | interface->refresh(); |
82 | } | 82 | } |
83 | return true; | 83 | return true; |
84 | } | 84 | } |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Save the settings for the current Interface. | 87 | * Save the settings for the current Interface. |
88 | * @return bool true if successful, false otherwise | 88 | * @return bool true if successful, false otherwise |
89 | */ | 89 | */ |
90 | bool InterfaceSetupImp::saveSettings(){ | 90 | bool InterfaceSetupImp::saveSettings(){ |
91 | // eh can't really do anything about it other then return. :-D | 91 | // eh can't really do anything about it other then return. :-D |
92 | if(!interfaces->isInterfaceSet()) | 92 | if(!interfaces->isInterfaceSet()) |
93 | return true; | 93 | return true; |
94 | 94 | ||
95 | bool error = false; | 95 | bool error = false; |
96 | // Loopback case | 96 | // Loopback case |
97 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 97 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
98 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 98 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
99 | return true; | 99 | return true; |
@@ -136,73 +136,73 @@ bool InterfaceSetupImp::saveSettings(){ | |||
136 | * @param QString profile the new profile. | 136 | * @param QString profile the new profile. |
137 | */ | 137 | */ |
138 | void InterfaceSetupImp::setProfile(const QString &profile){ | 138 | void InterfaceSetupImp::setProfile(const QString &profile){ |
139 | /* | 139 | /* |
140 | bool error = false; | 140 | bool error = false; |
141 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 141 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
142 | staticGroupBox->hide(); | 142 | staticGroupBox->hide(); |
143 | dhcpCheckBox->hide(); | 143 | dhcpCheckBox->hide(); |
144 | leaseTime->hide(); | 144 | leaseTime->hide(); |
145 | leaseHoursLabel->hide(); | 145 | leaseHoursLabel->hide(); |
146 | } | 146 | } |
147 | */ | 147 | */ |
148 | 148 | ||
149 | QString newInterfaceName = interface->getInterfaceName(); | 149 | QString newInterfaceName = interface->getInterfaceName(); |
150 | if(profile.length() > 0) | 150 | if(profile.length() > 0) |
151 | newInterfaceName += "_" + profile; | 151 | newInterfaceName += "_" + profile; |
152 | // See if we have to make a interface. | 152 | // See if we have to make a interface. |
153 | if(!interfaces->setInterface(newInterfaceName)){ | 153 | if(!interfaces->setInterface(newInterfaceName)){ |
154 | // Add making for this new interface if need too | 154 | // Add making for this new interface if need too |
155 | if(profile != ""){ | 155 | if(profile != ""){ |
156 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 156 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
157 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 157 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
158 | interfaces->addMapping(interface->getInterfaceName()); | 158 | interfaces->addMapping(interface->getInterfaceName()); |
159 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 159 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
160 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); | 160 | odebug << "InterfaceSetupImp: Added Mapping, but still can't setInterface." << oendl; |
161 | return; | 161 | return; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | interfaces->setMap("map", newInterfaceName); | 164 | interfaces->setMap("map", newInterfaceName); |
165 | interfaces->setScript("getprofile.sh"); | 165 | interfaces->setScript("getprofile.sh"); |
166 | } | 166 | } |
167 | else{ | 167 | else{ |
168 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 168 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
169 | if(!interfaces->setInterface(newInterfaceName)){ | 169 | if(!interfaces->setInterface(newInterfaceName)){ |
170 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); | 170 | odebug << "InterfaceSetupImp: Added interface, but still can't setInterface." << oendl; |
171 | return; | 171 | return; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | // We must have a valid interface to get this far so read some settings. | 176 | // We must have a valid interface to get this far so read some settings. |
177 | 177 | ||
178 | // DHCP | 178 | // DHCP |
179 | bool error = false; | 179 | bool error = false; |
180 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 180 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
181 | dhcpCheckBox->setChecked(true); | 181 | dhcpCheckBox->setChecked(true); |
182 | else | 182 | else |
183 | dhcpCheckBox->setChecked(false); | 183 | dhcpCheckBox->setChecked(false); |
184 | 184 | ||
185 | // IP Information | 185 | // IP Information |
186 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 186 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
187 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); | 187 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); |
188 | qDebug("dns >%s<",dns.latin1()); | 188 | odebug << "dns >" << dns.latin1() << "<" << oendl; |
189 | if(dns.contains(" ")){ | 189 | if(dns.contains(" ")){ |
190 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 190 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
191 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 191 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
192 | }else firstDNSLineEdit->setText(dns); | 192 | }else firstDNSLineEdit->setText(dns); |
193 | 193 | ||
194 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 194 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
195 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 195 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
196 | if (subnetMaskEdit->text().isEmpty()) | 196 | if (subnetMaskEdit->text().isEmpty()) |
197 | subnetMaskEdit->setText( "255.255.255.0" ); | 197 | subnetMaskEdit->setText( "255.255.255.0" ); |
198 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 198 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
199 | 199 | ||
200 | 200 | ||
201 | 201 | ||
202 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); | 202 | owarn << "InterfaceSetupImp::setProfile(" << profile.latin1() << ")\n" << oendl; |
203 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); | 203 | owarn << "InterfaceSetupImp::setProfile: iface is " << interfaces->getInterfaceName(error).latin1() << "\n" << oendl; |
204 | 204 | ||
205 | } | 205 | } |
206 | 206 | ||
207 | // interfacesetup.cpp | 207 | // interfacesetup.cpp |
208 | 208 | ||