summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-14 23:26:44 (UTC)
committer kergoth <kergoth>2003-04-14 23:26:44 (UTC)
commit9c0ba9922e12081ba87cce6583fe413ab5794cf6 (patch) (side-by-side diff)
tree274472a08b80971045ad54a49b126f7b19454483
parent4c0ff8a1bdc4750ee36c713392d0842e9eb9eeb3 (diff)
downloadopie-9c0ba9922e12081ba87cce6583fe413ab5794cf6.zip
opie-9c0ba9922e12081ba87cce6583fe413ab5794cf6.tar.gz
opie-9c0ba9922e12081ba87cce6583fe413ab5794cf6.tar.bz2
Correct the constructor, and ensure it does not remove all interface options, as that interferes with the new wireless module.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp18
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.h3
2 files changed, 9 insertions, 12 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index 2a5520d..fc65c5f 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -1,89 +1,87 @@
#include "interfacesetupimp.h"
#include "interface.h"
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qmessagebox.h>
#define DNSSCRIPT "changedns"
/**
* Constuctor. Set up the connection. A profile must be set.
*/
-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;
+InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){
+ if (j == 0) {
+ delInterfaces = true;
+ interfaces = new Interfaces;
+ }
}
/**
* Destructor
*/
InterfaceSetupImp::~InterfaceSetupImp(){
- if(delInterfaces)
+ if(delInterfaces) {
delete interfaces;
+ }
}
/**
* Save the current settings, then write out the interfaces file and close.
*/
bool InterfaceSetupImp::saveChanges(){
if(!saveSettings())
return false;
interfaces->write();
return true;
}
/**
* Save the settings for the current Interface.
* @return bool true if successfull, false otherwise
*/
bool InterfaceSetupImp::saveSettings(){
// eh can't really do anything about it other then return. :-D
if(!interfaces->isInterfaceSet())
return true;
bool error = false;
// Loopback case
if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
return true;
}
if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
return false;
}
- interfaces->removeAllInterfaceOptions();
+ //interfaces.removeAllInterfaceOptions();
// DHCP
if(dhcpCheckBox->isChecked())
interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
else{
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);
}
}
// IP Information
interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
return true;
}
/**
* The Profile has changed.
* @param QString profile the new profile.
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.h b/noncore/settings/networksettings/interfaces/interfacesetupimp.h
index c4ace77..172da6a 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.h
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.h
@@ -1,59 +1,58 @@
#ifndef INTERFACESETUPIMP_H
#define INTERFACESETUPIMP_H
#include "interfacesetup.h"
#include "interfaces.h"
#include <qdialog.h>
class Interface;
class InterfaceSetupImp : public InterfaceSetup {
Q_OBJECT
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, Interfaces *j = 0, WFlags fl = 0);
~InterfaceSetupImp();
bool saveChanges();
public slots:
void setProfile(const QString &profile);
bool saveSettings();
private:
Interfaces *interfaces;
Interface *interface;
bool delInterfaces;
};
#include <qlayout.h>
class InterfaceSetupImpDialog : public QDialog {
Q_OBJECT
public:
InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){
QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this );
setCaption("Interface Setup");
- interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl);
+ interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i);
InterfaceSetupLayout->addWidget( interfaceSetup );
};
void setProfile(QString &profile){ interfaceSetup->setProfile(profile);};
private:
InterfaceSetupImp *interfaceSetup;
protected slots:
void accept(){
if(interfaceSetup->saveChanges())
QDialog::accept();
};
};
#endif
// interfacesetupimp.h