summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-14 02:11:00 (UTC)
committer kergoth <kergoth>2003-04-14 02:11:00 (UTC)
commitffbdd4fe71b0b8cfee3cef57b24ebae4bb075621 (patch) (unidiff)
tree8f1c25faf57cc741ddaaa4b5cbf20cfff843f134
parentef69f1d1ca947a0b972e3f8d635883ae7ef0ae23 (diff)
downloadopie-ffbdd4fe71b0b8cfee3cef57b24ebae4bb075621.zip
opie-ffbdd4fe71b0b8cfee3cef57b24ebae4bb075621.tar.gz
opie-ffbdd4fe71b0b8cfee3cef57b24ebae4bb075621.tar.bz2
Add a constructor to InterfaceSetupImp which lets me pass in a pointer to
an already existing Interfaces object, so that it will play nice with a wireless module that also uses Interfaces.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp75
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.h10
2 files changed, 52 insertions, 33 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index 56bbe93..2a5520d 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -13,18 +13,33 @@
13 13
14/** 14/**
15 * Constuctor. Set up the connection. A profile must be set. 15 * Constuctor. Set up the connection. A profile must be set.
16 */ 16 */
17InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i){ 17InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interfaces(j), interface(i), delInterfaces(false){
18}
19
20/**
21 * Constuctor. Set up the connection. A profile must be set.
22 */
23InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), delInterfaces(true){
24 interfaces = new Interfaces;
25}
26
27/**
28 * Destructor
29 */
30InterfaceSetupImp::~InterfaceSetupImp(){
31 if(delInterfaces)
32 delete interfaces;
18} 33}
19 34
20/** 35/**
21 * Save the current settings, then write out the interfaces file and close. 36 * Save the current settings, then write out the interfaces file and close.
22 */ 37 */
23bool InterfaceSetupImp::saveChanges(){ 38bool InterfaceSetupImp::saveChanges(){
24 if(!saveSettings()) 39 if(!saveSettings())
25 return false; 40 return false;
26 interfaces.write(); 41 interfaces->write();
27 return true; 42 return true;
28} 43}
29 44
30/** 45/**
@@ -32,41 +47,41 @@ bool InterfaceSetupImp::saveChanges(){
32 * @return bool true if successfull, false otherwise 47 * @return bool true if successfull, false otherwise
33 */ 48 */
34bool InterfaceSetupImp::saveSettings(){ 49bool InterfaceSetupImp::saveSettings(){
35 // eh can't really do anything about it other then return. :-D 50 // eh can't really do anything about it other then return. :-D
36 if(!interfaces.isInterfaceSet()) 51 if(!interfaces->isInterfaceSet())
37 return true; 52 return true;
38 53
39 bool error = false; 54 bool error = false;
40 // Loopback case 55 // Loopback case
41 if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 56 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
42 interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked()); 57 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
43 return true; 58 return true;
44 } 59 }
45 60
46 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ 61 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
47 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); 62 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
48 return false; 63 return false;
49 } 64 }
50 interfaces.removeAllInterfaceOptions(); 65 interfaces->removeAllInterfaceOptions();
51 66
52 // DHCP 67 // DHCP
53 if(dhcpCheckBox->isChecked()) 68 if(dhcpCheckBox->isChecked())
54 interfaces.setInterfaceMethod(INTERFACES_METHOD_DHCP); 69 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
55 else{ 70 else{
56 interfaces.setInterfaceMethod("static"); 71 interfaces->setInterfaceMethod("static");
57 interfaces.setInterfaceOption("address", ipAddressEdit->text()); 72 interfaces->setInterfaceOption("address", ipAddressEdit->text());
58 interfaces.setInterfaceOption("netmask", subnetMaskEdit->text()); 73 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
59 interfaces.setInterfaceOption("gateway", gatewayEdit->text()); 74 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
60 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ 75 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
61 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); 76 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
62 interfaces.setInterfaceOption("up "DNSSCRIPT" -a ", dns); 77 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
63 interfaces.setInterfaceOption("down "DNSSCRIPT" -r ", dns); 78 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
64 } 79 }
65 } 80 }
66 81
67 // IP Information 82 // IP Information
68 interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked()); 83 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
69 return true; 84 return true;
70} 85}
71 86
72/** 87/**
@@ -75,9 +90,9 @@ bool InterfaceSetupImp::saveSettings(){
75 */ 90 */
76void InterfaceSetupImp::setProfile(const QString &profile){ 91void InterfaceSetupImp::setProfile(const QString &profile){
77 /* 92 /*
78 bool error = false; 93 bool error = false;
79 if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 94 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
80 staticGroupBox->hide(); 95 staticGroupBox->hide();
81 dhcpCheckBox->hide(); 96 dhcpCheckBox->hide();
82 leaseTime->hide(); 97 leaseTime->hide();
83 leaseHoursLabel->hide(); 98 leaseHoursLabel->hide();
@@ -87,25 +102,25 @@ void InterfaceSetupImp::setProfile(const QString &profile){
87 QString newInterfaceName = interface->getInterfaceName(); 102 QString newInterfaceName = interface->getInterfaceName();
88 if(profile.length() > 0) 103 if(profile.length() > 0)
89 newInterfaceName += "_" + profile; 104 newInterfaceName += "_" + profile;
90 // See if we have to make a interface. 105 // See if we have to make a interface.
91 if(!interfaces.setInterface(newInterfaceName)){ 106 if(!interfaces->setInterface(newInterfaceName)){
92 // Add making for this new interface if need too 107 // Add making for this new interface if need too
93 if(profile != ""){ 108 if(profile != ""){
94 interfaces.copyInterface(interface->getInterfaceName(), newInterfaceName); 109 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
95 if(!interfaces.setMapping(interface->getInterfaceName())){ 110 if(!interfaces->setMapping(interface->getInterfaceName())){
96 interfaces.addMapping(interface->getInterfaceName()); 111 interfaces->addMapping(interface->getInterfaceName());
97 if(!interfaces.setMapping(interface->getInterfaceName())){ 112 if(!interfaces->setMapping(interface->getInterfaceName())){
98 qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); 113 qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface.");
99 return; 114 return;
100 } 115 }
101 } 116 }
102 interfaces.setMap("map", newInterfaceName); 117 interfaces->setMap("map", newInterfaceName);
103 interfaces.setScript("getprofile.sh"); 118 interfaces->setScript("getprofile.sh");
104 } 119 }
105 else{ 120 else{
106 interfaces.addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); 121 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
107 if(!interfaces.setInterface(newInterfaceName)){ 122 if(!interfaces->setInterface(newInterfaceName)){
108 qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); 123 qDebug("InterfaceSetupImp: Added interface, but still can't setInterface.");
109 return; 124 return;
110 } 125 }
111 } 126 }
@@ -114,23 +129,23 @@ void InterfaceSetupImp::setProfile(const QString &profile){
114 // We must have a valid interface to get this far so read some settings. 129 // We must have a valid interface to get this far so read some settings.
115 130
116 // DHCP 131 // DHCP
117 bool error = false; 132 bool error = false;
118 if(interfaces.getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 133 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
119 dhcpCheckBox->setChecked(true); 134 dhcpCheckBox->setChecked(true);
120 else 135 else
121 dhcpCheckBox->setChecked(false); 136 dhcpCheckBox->setChecked(false);
122 137
123 // IP Information 138 // IP Information
124 autoStart->setChecked(interfaces.isAuto(interface->getInterfaceName())); 139 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
125 QString dns = interfaces.getInterfaceOption("up "DNSSCRIPT" -a", error); 140 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error);
126 if(dns.contains(" ")){ 141 if(dns.contains(" ")){
127 firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); 142 firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
128 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); 143 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
129 } 144 }
130 ipAddressEdit->setText(interfaces.getInterfaceOption("address", error)); 145 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
131 subnetMaskEdit->setText(interfaces.getInterfaceOption("netmask", error)); 146 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
132 gatewayEdit->setText(interfaces.getInterfaceOption("gateway", error)); 147 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
133} 148}
134 149
135// interfacesetup.cpp 150// interfacesetup.cpp
136 151
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.h b/noncore/settings/networksettings/interfaces/interfacesetupimp.h
index 9ec526c..c4ace77 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.h
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.h
@@ -10,18 +10,22 @@ class Interface;
10class InterfaceSetupImp : public InterfaceSetup { 10class InterfaceSetupImp : public InterfaceSetup {
11 Q_OBJECT 11 Q_OBJECT
12 12
13public: 13public:
14 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); 14 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i = 0, WFlags fl = 0);
15 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i = 0, Interfaces *j = 0, WFlags fl = 0);
16 ~InterfaceSetupImp();
15 bool saveChanges(); 17 bool saveChanges();
16 18
17public slots: 19public slots:
18 void setProfile(const QString &profile); 20 void setProfile(const QString &profile);
19 bool saveSettings(); 21 bool saveSettings();
20 22
21private: 23private:
22 Interfaces interfaces; 24 Interfaces *interfaces;
23 Interface *interface; 25 Interface *interface;
26
27 bool delInterfaces;
24}; 28};
25 29
26 30
27#include <qlayout.h> 31#include <qlayout.h>