summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-14 02:11:00 (UTC)
committer kergoth <kergoth>2003-04-14 02:11:00 (UTC)
commitffbdd4fe71b0b8cfee3cef57b24ebae4bb075621 (patch) (side-by-side diff)
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
@@ -15,5 +15,20 @@
* Constuctor. Set up the connection. A profile must be set.
*/
-InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i){
+InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interfaces(j), interface(i), delInterfaces(false){
+}
+
+/**
+ * Constuctor. Set up the connection. A profile must be set.
+ */
+InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), delInterfaces(true){
+ interfaces = new Interfaces;
+}
+
+/**
+ * Destructor
+ */
+InterfaceSetupImp::~InterfaceSetupImp(){
+ if(delInterfaces)
+ delete interfaces;
}
@@ -24,5 +39,5 @@ bool InterfaceSetupImp::saveChanges(){
if(!saveSettings())
return false;
- interfaces.write();
+ interfaces->write();
return true;
}
@@ -34,11 +49,11 @@ bool InterfaceSetupImp::saveChanges(){
bool InterfaceSetupImp::saveSettings(){
// eh can't really do anything about it other then return. :-D
- if(!interfaces.isInterfaceSet())
+ if(!interfaces->isInterfaceSet())
return true;
bool error = false;
// Loopback case
- if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){
- interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked());
+ if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
+ interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
return true;
}
@@ -48,23 +63,23 @@ bool InterfaceSetupImp::saveSettings(){
return false;
}
- interfaces.removeAllInterfaceOptions();
+ interfaces->removeAllInterfaceOptions();
// DHCP
if(dhcpCheckBox->isChecked())
- interfaces.setInterfaceMethod(INTERFACES_METHOD_DHCP);
+ interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
else{
- interfaces.setInterfaceMethod("static");
- interfaces.setInterfaceOption("address", ipAddressEdit->text());
- interfaces.setInterfaceOption("netmask", subnetMaskEdit->text());
- interfaces.setInterfaceOption("gateway", gatewayEdit->text());
+ interfaces->setInterfaceMethod("static");
+ interfaces->setInterfaceOption("address", ipAddressEdit->text());
+ interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
+ interfaces->setInterfaceOption("gateway", gatewayEdit->text());
if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
- interfaces.setInterfaceOption("up "DNSSCRIPT" -a ", dns);
- interfaces.setInterfaceOption("down "DNSSCRIPT" -r ", dns);
+ interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
+ interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
}
}
// IP Information
- interfaces.setAuto(interface->getInterfaceName(), autoStart->isChecked());
+ interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
return true;
}
@@ -77,5 +92,5 @@ void InterfaceSetupImp::setProfile(const QString &profile){
/*
bool error = false;
- if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){
+ if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
staticGroupBox->hide();
dhcpCheckBox->hide();
@@ -89,21 +104,21 @@ void InterfaceSetupImp::setProfile(const QString &profile){
newInterfaceName += "_" + profile;
// See if we have to make a interface.
- if(!interfaces.setInterface(newInterfaceName)){
+ if(!interfaces->setInterface(newInterfaceName)){
// Add making for this new interface if need too
if(profile != ""){
- interfaces.copyInterface(interface->getInterfaceName(), newInterfaceName);
- if(!interfaces.setMapping(interface->getInterfaceName())){
- interfaces.addMapping(interface->getInterfaceName());
- if(!interfaces.setMapping(interface->getInterfaceName())){
+ interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
+ if(!interfaces->setMapping(interface->getInterfaceName())){
+ interfaces->addMapping(interface->getInterfaceName());
+ if(!interfaces->setMapping(interface->getInterfaceName())){
qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface.");
return;
}
}
- interfaces.setMap("map", newInterfaceName);
- interfaces.setScript("getprofile.sh");
+ interfaces->setMap("map", newInterfaceName);
+ interfaces->setScript("getprofile.sh");
}
else{
- interfaces.addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
- if(!interfaces.setInterface(newInterfaceName)){
+ interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
+ if(!interfaces->setInterface(newInterfaceName)){
qDebug("InterfaceSetupImp: Added interface, but still can't setInterface.");
return;
@@ -116,5 +131,5 @@ void InterfaceSetupImp::setProfile(const QString &profile){
// DHCP
bool error = false;
- if(interfaces.getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
+ if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
dhcpCheckBox->setChecked(true);
else
@@ -122,13 +137,13 @@ void InterfaceSetupImp::setProfile(const QString &profile){
// IP Information
- autoStart->setChecked(interfaces.isAuto(interface->getInterfaceName()));
- QString dns = interfaces.getInterfaceOption("up "DNSSCRIPT" -a", error);
+ autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
+ QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error);
if(dns.contains(" ")){
firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
}
- ipAddressEdit->setText(interfaces.getInterfaceOption("address", error));
- subnetMaskEdit->setText(interfaces.getInterfaceOption("netmask", error));
- gatewayEdit->setText(interfaces.getInterfaceOption("gateway", error));
+ ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
+ subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
+ gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
}
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
@@ -12,5 +12,7 @@ class InterfaceSetupImp : public InterfaceSetup {
public:
- InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0);
+ InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i = 0, WFlags fl = 0);
+ InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i = 0, Interfaces *j = 0, WFlags fl = 0);
+ ~InterfaceSetupImp();
bool saveChanges();
@@ -20,6 +22,8 @@ public slots:
private:
- Interfaces interfaces;
- Interface *interface;
+ Interfaces *interfaces;
+ Interface *interface;
+
+ bool delInterfaces;
};