author | kergoth <kergoth> | 2003-04-14 23:26:44 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-14 23:26:44 (UTC) |
commit | 9c0ba9922e12081ba87cce6583fe413ab5794cf6 (patch) (unidiff) | |
tree | 274472a08b80971045ad54a49b126f7b19454483 | |
parent | 4c0ff8a1bdc4750ee36c713392d0842e9eb9eeb3 (diff) | |
download | opie-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.
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 18 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.h | 3 |
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,113 +1,111 @@ | |||
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 | #define DNSSCRIPT "changedns" | 12 | #define DNSSCRIPT "changedns" |
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 | */ |
17 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interfaces(j), interface(i), delInterfaces(false){ | 17 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ |
18 | } | 18 | if (j == 0) { |
19 | 19 | delInterfaces = true; | |
20 | /** | 20 | interfaces = new Interfaces; |
21 | * Constuctor. Set up the connection. A profile must be set. | 21 | } |
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 | } | 22 | } |
26 | 23 | ||
27 | /** | 24 | /** |
28 | * Destructor | 25 | * Destructor |
29 | */ | 26 | */ |
30 | InterfaceSetupImp::~InterfaceSetupImp(){ | 27 | InterfaceSetupImp::~InterfaceSetupImp(){ |
31 | if(delInterfaces) | 28 | if(delInterfaces) { |
32 | delete interfaces; | 29 | delete interfaces; |
30 | } | ||
33 | } | 31 | } |
34 | 32 | ||
35 | /** | 33 | /** |
36 | * Save the current settings, then write out the interfaces file and close. | 34 | * Save the current settings, then write out the interfaces file and close. |
37 | */ | 35 | */ |
38 | bool InterfaceSetupImp::saveChanges(){ | 36 | bool InterfaceSetupImp::saveChanges(){ |
39 | if(!saveSettings()) | 37 | if(!saveSettings()) |
40 | return false; | 38 | return false; |
41 | interfaces->write(); | 39 | interfaces->write(); |
42 | return true; | 40 | return true; |
43 | } | 41 | } |
44 | 42 | ||
45 | /** | 43 | /** |
46 | * Save the settings for the current Interface. | 44 | * Save the settings for the current Interface. |
47 | * @return bool true if successfull, false otherwise | 45 | * @return bool true if successfull, false otherwise |
48 | */ | 46 | */ |
49 | bool InterfaceSetupImp::saveSettings(){ | 47 | bool InterfaceSetupImp::saveSettings(){ |
50 | // eh can't really do anything about it other then return. :-D | 48 | // eh can't really do anything about it other then return. :-D |
51 | if(!interfaces->isInterfaceSet()) | 49 | if(!interfaces->isInterfaceSet()) |
52 | return true; | 50 | return true; |
53 | 51 | ||
54 | bool error = false; | 52 | bool error = false; |
55 | // Loopback case | 53 | // Loopback case |
56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 54 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 55 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
58 | return true; | 56 | return true; |
59 | } | 57 | } |
60 | 58 | ||
61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 59 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
62 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); | 60 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); |
63 | return false; | 61 | return false; |
64 | } | 62 | } |
65 | interfaces->removeAllInterfaceOptions(); | 63 | //interfaces.removeAllInterfaceOptions(); |
66 | 64 | ||
67 | // DHCP | 65 | // DHCP |
68 | if(dhcpCheckBox->isChecked()) | 66 | if(dhcpCheckBox->isChecked()) |
69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 67 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
70 | else{ | 68 | else{ |
71 | interfaces->setInterfaceMethod("static"); | 69 | interfaces->setInterfaceMethod("static"); |
72 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 70 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
73 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 71 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
74 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 72 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
75 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 73 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
76 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 74 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
77 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 75 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
78 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 76 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
79 | } | 77 | } |
80 | } | 78 | } |
81 | 79 | ||
82 | // IP Information | 80 | // IP Information |
83 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 81 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
84 | return true; | 82 | return true; |
85 | } | 83 | } |
86 | 84 | ||
87 | /** | 85 | /** |
88 | * The Profile has changed. | 86 | * The Profile has changed. |
89 | * @param QString profile the new profile. | 87 | * @param QString profile the new profile. |
90 | */ | 88 | */ |
91 | void InterfaceSetupImp::setProfile(const QString &profile){ | 89 | void InterfaceSetupImp::setProfile(const QString &profile){ |
92 | /* | 90 | /* |
93 | bool error = false; | 91 | bool error = false; |
94 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 92 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
95 | staticGroupBox->hide(); | 93 | staticGroupBox->hide(); |
96 | dhcpCheckBox->hide(); | 94 | dhcpCheckBox->hide(); |
97 | leaseTime->hide(); | 95 | leaseTime->hide(); |
98 | leaseHoursLabel->hide(); | 96 | leaseHoursLabel->hide(); |
99 | } | 97 | } |
100 | */ | 98 | */ |
101 | 99 | ||
102 | QString newInterfaceName = interface->getInterfaceName(); | 100 | QString newInterfaceName = interface->getInterfaceName(); |
103 | if(profile.length() > 0) | 101 | if(profile.length() > 0) |
104 | newInterfaceName += "_" + profile; | 102 | newInterfaceName += "_" + profile; |
105 | // See if we have to make a interface. | 103 | // See if we have to make a interface. |
106 | if(!interfaces->setInterface(newInterfaceName)){ | 104 | if(!interfaces->setInterface(newInterfaceName)){ |
107 | // Add making for this new interface if need too | 105 | // Add making for this new interface if need too |
108 | if(profile != ""){ | 106 | if(profile != ""){ |
109 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 107 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
110 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 108 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
111 | interfaces->addMapping(interface->getInterfaceName()); | 109 | interfaces->addMapping(interface->getInterfaceName()); |
112 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 110 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
113 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); | 111 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); |
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 @@ | |||
1 | #ifndef INTERFACESETUPIMP_H | 1 | #ifndef INTERFACESETUPIMP_H |
2 | #define INTERFACESETUPIMP_H | 2 | #define INTERFACESETUPIMP_H |
3 | 3 | ||
4 | #include "interfacesetup.h" | 4 | #include "interfacesetup.h" |
5 | #include "interfaces.h" | 5 | #include "interfaces.h" |
6 | #include <qdialog.h> | 6 | #include <qdialog.h> |
7 | 7 | ||
8 | class Interface; | 8 | class Interface; |
9 | 9 | ||
10 | class InterfaceSetupImp : public InterfaceSetup { | 10 | class InterfaceSetupImp : public InterfaceSetup { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
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); | 14 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i = 0, Interfaces *j = 0, WFlags fl = 0); |
16 | ~InterfaceSetupImp(); | 15 | ~InterfaceSetupImp(); |
17 | bool saveChanges(); | 16 | bool saveChanges(); |
18 | 17 | ||
19 | public slots: | 18 | public slots: |
20 | void setProfile(const QString &profile); | 19 | void setProfile(const QString &profile); |
21 | bool saveSettings(); | 20 | bool saveSettings(); |
22 | 21 | ||
23 | private: | 22 | private: |
24 | Interfaces *interfaces; | 23 | Interfaces *interfaces; |
25 | Interface *interface; | 24 | Interface *interface; |
26 | 25 | ||
27 | bool delInterfaces; | 26 | bool delInterfaces; |
28 | }; | 27 | }; |
29 | 28 | ||
30 | 29 | ||
31 | #include <qlayout.h> | 30 | #include <qlayout.h> |
32 | 31 | ||
33 | class InterfaceSetupImpDialog : public QDialog { | 32 | class InterfaceSetupImpDialog : public QDialog { |
34 | Q_OBJECT | 33 | Q_OBJECT |
35 | 34 | ||
36 | public: | 35 | public: |
37 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ | 36 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ |
38 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); | 37 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); |
39 | setCaption("Interface Setup"); | 38 | setCaption("Interface Setup"); |
40 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); | 39 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i); |
41 | InterfaceSetupLayout->addWidget( interfaceSetup ); | 40 | InterfaceSetupLayout->addWidget( interfaceSetup ); |
42 | }; | 41 | }; |
43 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; | 42 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; |
44 | 43 | ||
45 | private: | 44 | private: |
46 | InterfaceSetupImp *interfaceSetup; | 45 | InterfaceSetupImp *interfaceSetup; |
47 | 46 | ||
48 | protected slots: | 47 | protected slots: |
49 | void accept(){ | 48 | void accept(){ |
50 | if(interfaceSetup->saveChanges()) | 49 | if(interfaceSetup->saveChanges()) |
51 | QDialog::accept(); | 50 | QDialog::accept(); |
52 | }; | 51 | }; |
53 | 52 | ||
54 | }; | 53 | }; |
55 | 54 | ||
56 | #endif | 55 | #endif |
57 | 56 | ||
58 | // interfacesetupimp.h | 57 | // interfacesetupimp.h |
59 | 58 | ||