summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
authordrw <drw>2004-02-22 17:06:57 (UTC)
committer drw <drw>2004-02-22 17:06:57 (UTC)
commit68bd0ee2c7806b8fb35caf796e1d623e3d1f6011 (patch) (unidiff)
treebaee9d67d1134d1af933dfc21867c2607103813e /noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
parenta607c211c7ad47f1083fa820da5632a1d2110e44 (diff)
downloadopie-68bd0ee2c7806b8fb35caf796e1d623e3d1f6011.zip
opie-68bd0ee2c7806b8fb35caf796e1d623e3d1f6011.tar.gz
opie-68bd0ee2c7806b8fb35caf796e1d623e3d1f6011.tar.bz2
Network Settings: libopie->libopie2
Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfacesetupimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index 78466d0..ab0e4cc 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -1,63 +1,63 @@
1#include "interfacesetupimp.h" 1#include "interfacesetupimp.h"
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 <opie2/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 qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); 47 qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() );
48 if(!saveSettings()) 48 if(!saveSettings())
49 return false; 49 return false;
50 50
51 interfaces->write(); 51 interfaces->write();
52 52
53 if (interface->getStatus()) { 53 if (interface->getStatus()) {
54 QString ifup; 54 QString ifup;
55 ifup += "ifdown "; 55 ifup += "ifdown ";
56 ifup += iface; 56 ifup += iface;
57 ifup += "; ifup "; 57 ifup += "; ifup ";
58 ifup += iface; 58 ifup += iface;
59 ifup += ";"; 59 ifup += ";";
60 60
61 OProcess restart; 61 OProcess restart;
62 restart << "sh"; 62 restart << "sh";
63 restart << "-c"; 63 restart << "-c";
@@ -110,97 +110,97 @@ bool InterfaceSetupImp::saveSettings(){
110 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); 110 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
111 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); 111 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r ");
112 } else{ 112 } else{
113 interfaces->setInterfaceMethod("static"); 113 interfaces->setInterfaceMethod("static");
114 interfaces->setInterfaceOption("address", ipAddressEdit->text()); 114 interfaces->setInterfaceOption("address", ipAddressEdit->text());
115 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); 115 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
116 interfaces->setInterfaceOption("gateway", gatewayEdit->text()); 116 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
117 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ 117 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
118 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); 118 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
119 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); 119 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
120 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); 120 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
121 }else{ 121 }else{
122 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); 122 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
123 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); 123 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r");
124 } 124 }
125 } 125 }
126 126
127 // IP Information 127 // IP Information
128 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 128 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
129 return true; 129 return true;
130} 130}
131 131
132/** 132/**
133 * The Profile has changed. 133 * The Profile has changed.
134 * @param QString profile the new profile. 134 * @param QString profile the new profile.
135 */ 135 */
136void InterfaceSetupImp::setProfile(const QString &profile){ 136void InterfaceSetupImp::setProfile(const QString &profile){
137 /* 137 /*
138 bool error = false; 138 bool error = false;
139 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 139 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
140 staticGroupBox->hide(); 140 staticGroupBox->hide();
141 dhcpCheckBox->hide(); 141 dhcpCheckBox->hide();
142 leaseTime->hide(); 142 leaseTime->hide();
143 leaseHoursLabel->hide(); 143 leaseHoursLabel->hide();
144 } 144 }
145 */ 145 */
146 146
147 QString newInterfaceName = interface->getInterfaceName(); 147 QString newInterfaceName = interface->getInterfaceName();
148 if(profile.length() > 0) 148 if(profile.length() > 0)
149 newInterfaceName += "_" + profile; 149 newInterfaceName += "_" + profile;
150 // See if we have to make a interface. 150 // See if we have to make a interface.
151 if(!interfaces->setInterface(newInterfaceName)){ 151 if(!interfaces->setInterface(newInterfaceName)){
152 // Add making for this new interface if need too 152 // Add making for this new interface if need too
153 if(profile != ""){ 153 if(profile != ""){
154 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); 154 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
155 if(!interfaces->setMapping(interface->getInterfaceName())){ 155 if(!interfaces->setMapping(interface->getInterfaceName())){
156 interfaces->addMapping(interface->getInterfaceName()); 156 interfaces->addMapping(interface->getInterfaceName());
157 if(!interfaces->setMapping(interface->getInterfaceName())){ 157 if(!interfaces->setMapping(interface->getInterfaceName())){
158 qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); 158 qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface.");
159 return; 159 return;
160 } 160 }
161 } 161 }
162 interfaces->setMap("map", newInterfaceName); 162 interfaces->setMap("map", newInterfaceName);
163 interfaces->setScript("getprofile.sh"); 163 interfaces->setScript("getprofile.sh");
164 } 164 }
165 else{ 165 else{
166 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); 166 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
167 if(!interfaces->setInterface(newInterfaceName)){ 167 if(!interfaces->setInterface(newInterfaceName)){
168 qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); 168 qDebug("InterfaceSetupImp: Added interface, but still can't setInterface.");
169 return; 169 return;
170 } 170 }
171 } 171 }
172 } 172 }
173 173
174 // We must have a valid interface to get this far so read some settings. 174 // We must have a valid interface to get this far so read some settings.
175 175
176 // DHCP 176 // DHCP
177 bool error = false; 177 bool error = false;
178 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 178 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
179 dhcpCheckBox->setChecked(true); 179 dhcpCheckBox->setChecked(true);
180 else 180 else
181 dhcpCheckBox->setChecked(false); 181 dhcpCheckBox->setChecked(false);
182 182
183 // IP Information 183 // IP Information
184 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); 184 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
185 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); 185 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error);
186 qDebug("dns >%s<",dns.latin1()); 186 qDebug("dns >%s<",dns.latin1());
187 if(dns.contains(" ")){ 187 if(dns.contains(" ")){
188 firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); 188 firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
189 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); 189 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
190 }else firstDNSLineEdit->setText(dns); 190 }else firstDNSLineEdit->setText(dns);
191 191
192 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); 192 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
193 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); 193 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
194 if (subnetMaskEdit->text().isEmpty()) 194 if (subnetMaskEdit->text().isEmpty())
195 subnetMaskEdit->setText( "255.255.255.0" ); 195 subnetMaskEdit->setText( "255.255.255.0" );
196 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); 196 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
197 197
198 198
199 199
200 qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); 200 qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1());
201 qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); 201 qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1());
202 202
203} 203}
204 204
205// interfacesetup.cpp 205// interfacesetup.cpp
206 206