author | kergoth <kergoth> | 2003-04-14 02:11:00 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-14 02:11:00 (UTC) |
commit | ffbdd4fe71b0b8cfee3cef57b24ebae4bb075621 (patch) (unidiff) | |
tree | 8f1c25faf57cc741ddaaa4b5cbf20cfff843f134 /noncore | |
parent | ef69f1d1ca947a0b972e3f8d635883ae7ef0ae23 (diff) | |
download | opie-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.
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 75 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.h | 10 |
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 | |||
@@ -16,3 +16,18 @@ | |||
16 | */ | 16 | */ |
17 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i){ | 17 | InterfaceSetupImp::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 | */ | ||
23 | InterfaceSetupImp::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 | */ | ||
30 | InterfaceSetupImp::~InterfaceSetupImp(){ | ||
31 | if(delInterfaces) | ||
32 | delete interfaces; | ||
18 | } | 33 | } |
@@ -25,3 +40,3 @@ bool InterfaceSetupImp::saveChanges(){ | |||
25 | return false; | 40 | return false; |
26 | interfaces.write(); | 41 | interfaces->write(); |
27 | return true; | 42 | return true; |
@@ -35,3 +50,3 @@ bool 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; |
@@ -40,4 +55,4 @@ bool InterfaceSetupImp::saveSettings(){ | |||
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; |
@@ -49,3 +64,3 @@ bool InterfaceSetupImp::saveSettings(){ | |||
49 | } | 64 | } |
50 | interfaces.removeAllInterfaceOptions(); | 65 | interfaces->removeAllInterfaceOptions(); |
51 | 66 | ||
@@ -53,12 +68,12 @@ bool InterfaceSetupImp::saveSettings(){ | |||
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 | } |
@@ -67,3 +82,3 @@ bool InterfaceSetupImp::saveSettings(){ | |||
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; |
@@ -78,3 +93,3 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
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(); |
@@ -90,9 +105,9 @@ void InterfaceSetupImp::setProfile(const QString &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."); |
@@ -101,8 +116,8 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
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."); |
@@ -117,3 +132,3 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
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); |
@@ -123,4 +138,4 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
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(" ")){ |
@@ -129,5 +144,5 @@ void InterfaceSetupImp::setProfile(const QString &profile){ | |||
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 | } |
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 | |||
@@ -13,3 +13,5 @@ class InterfaceSetupImp : public InterfaceSetup { | |||
13 | public: | 13 | public: |
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(); |
@@ -21,4 +23,6 @@ public slots: | |||
21 | private: | 23 | private: |
22 | Interfaces interfaces; | 24 | Interfaces *interfaces; |
23 | Interface *interface; | 25 | Interface *interface; |
26 | |||
27 | bool delInterfaces; | ||
24 | }; | 28 | }; |