-rw-r--r-- | noncore/net/networksetup/interfaces/interfacesetupimp.cpp | 12 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | 12 |
2 files changed, 14 insertions, 10 deletions
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp index d42b45d..6587d6f 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp | |||
@@ -1,149 +1,151 @@ | |||
1 | #include "interfacesetupimp.h" | 1 | #include "interfacesetupimp.h" |
2 | #include "interface.h" | 2 | #include "interface.h" |
3 | #include "interfaces.h" | 3 | #include "interfaces.h" |
4 | 4 | ||
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
7 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qspinbox.h> | 9 | #include <qspinbox.h> |
10 | #include <qgroupbox.h> | 10 | #include <qgroupbox.h> |
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | 12 | ||
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | 14 | ||
15 | #include <assert.h> | 15 | #include <assert.h> |
16 | 16 | ||
17 | #define DNSSCRIPT "changedns" | 17 | #define DNSSCRIPT "changedns" |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Constuctor. Set up the connection and load the first profile. | 20 | * Constuctor. Set up the connection and load the first profile. |
21 | */ | 21 | */ |
22 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ | 22 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ |
23 | assert(parent); | 23 | assert(parent); |
24 | assert(i); | 24 | assert(i); |
25 | interface = i; | 25 | interface = i; |
26 | interfaces = new Interfaces(); | 26 | interfaces = new Interfaces(); |
27 | bool error = false; | 27 | bool error = false; |
28 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 28 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
29 | staticGroupBox->hide(); | 29 | staticGroupBox->hide(); |
30 | dhcpCheckBox->hide(); | 30 | dhcpCheckBox->hide(); |
31 | leaseTime->hide(); | 31 | leaseTime->hide(); |
32 | leaseHoursLabel->hide(); | 32 | leaseHoursLabel->hide(); |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Save the current settings, then write out the interfaces file and close. | 37 | * Save the current settings, then write out the interfaces file and close. |
38 | */ | 38 | */ |
39 | void InterfaceSetupImp::saveChanges(){ | 39 | void InterfaceSetupImp::saveChanges(){ |
40 | if(!saveSettings()) | 40 | if(!saveSettings()) |
41 | return; | 41 | return; |
42 | interfaces->write(); | 42 | interfaces->write(); |
43 | } | 43 | } |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Save the settings for the current Interface. | 46 | * Save the settings for the current Interface. |
47 | * @return bool true if successfull, false otherwise | 47 | * @return bool true if successfull, false otherwise |
48 | */ | 48 | */ |
49 | bool InterfaceSetupImp::saveSettings(){ | 49 | bool InterfaceSetupImp::saveSettings(){ |
50 | // 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 |
51 | if(!interfaces->isInterfaceSet()) | 51 | if(!interfaces->isInterfaceSet()) |
52 | return true; | 52 | return true; |
53 | 53 | ||
54 | bool error = false; | 54 | bool error = false; |
55 | // Loopback case | 55 | // Loopback case |
56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
58 | return true; | 58 | return true; |
59 | } | 59 | } |
60 | 60 | ||
61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty() || firstDNSLineEdit->text().isEmpty())){ | 61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
62 | QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "Ok"); | 62 | QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n and gateway entries.", "Ok"); |
63 | return false; | 63 | return false; |
64 | } | 64 | } |
65 | interfaces->removeAllInterfaceOptions(); | 65 | interfaces->removeAllInterfaceOptions(); |
66 | 66 | ||
67 | // DHCP | 67 | // DHCP |
68 | if(dhcpCheckBox->isChecked()){ | 68 | if(dhcpCheckBox->isChecked()){ |
69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); | 70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); |
71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); | 71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); |
72 | } | 72 | } |
73 | else{ | 73 | else{ |
74 | interfaces->setInterfaceMethod("static"); | 74 | interfaces->setInterfaceMethod("static"); |
75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
78 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 78 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
79 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 79 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
80 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 80 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
81 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | ||
82 | } | ||
81 | } | 83 | } |
82 | 84 | ||
83 | // IP Information | 85 | // IP Information |
84 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 86 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
85 | return true; | 87 | return true; |
86 | } | 88 | } |
87 | 89 | ||
88 | /** | 90 | /** |
89 | * The Profile has changed. | 91 | * The Profile has changed. |
90 | * @profile the new profile. | 92 | * @profile the new profile. |
91 | */ | 93 | */ |
92 | void InterfaceSetupImp::setProfile(const QString &profile){ | 94 | void InterfaceSetupImp::setProfile(const QString &profile){ |
93 | QString newInterfaceName = interface->getInterfaceName(); | 95 | QString newInterfaceName = interface->getInterfaceName(); |
94 | if(profile.length() > 0) | 96 | if(profile.length() > 0) |
95 | newInterfaceName += "_" + profile; | 97 | newInterfaceName += "_" + profile; |
96 | qDebug("InterfaceSetupImp::setProfile"); | 98 | qDebug("InterfaceSetupImp::setProfile"); |
97 | // See if we have to make a interface. | 99 | // See if we have to make a interface. |
98 | if(!interfaces->setInterface(newInterfaceName)){ | 100 | if(!interfaces->setInterface(newInterfaceName)){ |
99 | // Add making for this new interface if need too | 101 | // Add making for this new interface if need too |
100 | if(profile != ""){ | 102 | if(profile != ""){ |
101 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 103 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
102 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 104 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
103 | interfaces->addMapping(interface->getInterfaceName()); | 105 | interfaces->addMapping(interface->getInterfaceName()); |
104 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 106 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
105 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); | 107 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); |
106 | return; | 108 | return; |
107 | } | 109 | } |
108 | } | 110 | } |
109 | interfaces->setMap("map", newInterfaceName); | 111 | interfaces->setMap("map", newInterfaceName); |
110 | interfaces->setScript("getprofile.sh"); | 112 | interfaces->setScript("getprofile.sh"); |
111 | } | 113 | } |
112 | else{ | 114 | else{ |
113 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 115 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
114 | if(!interfaces->setInterface(newInterfaceName)){ | 116 | if(!interfaces->setInterface(newInterfaceName)){ |
115 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); | 117 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); |
116 | return; | 118 | return; |
117 | } | 119 | } |
118 | } | 120 | } |
119 | } | 121 | } |
120 | 122 | ||
121 | // We must have a valid interface to get this far so read some settings. | 123 | // We must have a valid interface to get this far so read some settings. |
122 | 124 | ||
123 | // DHCP | 125 | // DHCP |
124 | bool error = false; | 126 | bool error = false; |
125 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 127 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
126 | dhcpCheckBox->setChecked(true); | 128 | dhcpCheckBox->setChecked(true); |
127 | else | 129 | else |
128 | dhcpCheckBox->setChecked(false); | 130 | dhcpCheckBox->setChecked(false); |
129 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); | 131 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); |
130 | if(error) | 132 | if(error) |
131 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); | 133 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); |
132 | if(error) | 134 | if(error) |
133 | leaseTime->setValue(24); | 135 | leaseTime->setValue(24); |
134 | 136 | ||
135 | // IP Information | 137 | // IP Information |
136 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 138 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
137 | QString dns = interfaces->getInterfaceOption("up interfacednsscript -a", error); | 139 | QString dns = interfaces->getInterfaceOption("up interfacednsscript -a", error); |
138 | if(dns.contains(" ")){ | 140 | if(dns.contains(" ")){ |
139 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 141 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
140 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 142 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
141 | } | 143 | } |
142 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 144 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
143 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 145 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
144 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 146 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
145 | } | 147 | } |
146 | 148 | ||
147 | 149 | ||
148 | // interfacesetup.cpp | 150 | // interfacesetup.cpp |
149 | 151 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index d42b45d..6587d6f 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -1,149 +1,151 @@ | |||
1 | #include "interfacesetupimp.h" | 1 | #include "interfacesetupimp.h" |
2 | #include "interface.h" | 2 | #include "interface.h" |
3 | #include "interfaces.h" | 3 | #include "interfaces.h" |
4 | 4 | ||
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
7 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qspinbox.h> | 9 | #include <qspinbox.h> |
10 | #include <qgroupbox.h> | 10 | #include <qgroupbox.h> |
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | 12 | ||
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | 14 | ||
15 | #include <assert.h> | 15 | #include <assert.h> |
16 | 16 | ||
17 | #define DNSSCRIPT "changedns" | 17 | #define DNSSCRIPT "changedns" |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Constuctor. Set up the connection and load the first profile. | 20 | * Constuctor. Set up the connection and load the first profile. |
21 | */ | 21 | */ |
22 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ | 22 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ |
23 | assert(parent); | 23 | assert(parent); |
24 | assert(i); | 24 | assert(i); |
25 | interface = i; | 25 | interface = i; |
26 | interfaces = new Interfaces(); | 26 | interfaces = new Interfaces(); |
27 | bool error = false; | 27 | bool error = false; |
28 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 28 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
29 | staticGroupBox->hide(); | 29 | staticGroupBox->hide(); |
30 | dhcpCheckBox->hide(); | 30 | dhcpCheckBox->hide(); |
31 | leaseTime->hide(); | 31 | leaseTime->hide(); |
32 | leaseHoursLabel->hide(); | 32 | leaseHoursLabel->hide(); |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Save the current settings, then write out the interfaces file and close. | 37 | * Save the current settings, then write out the interfaces file and close. |
38 | */ | 38 | */ |
39 | void InterfaceSetupImp::saveChanges(){ | 39 | void InterfaceSetupImp::saveChanges(){ |
40 | if(!saveSettings()) | 40 | if(!saveSettings()) |
41 | return; | 41 | return; |
42 | interfaces->write(); | 42 | interfaces->write(); |
43 | } | 43 | } |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Save the settings for the current Interface. | 46 | * Save the settings for the current Interface. |
47 | * @return bool true if successfull, false otherwise | 47 | * @return bool true if successfull, false otherwise |
48 | */ | 48 | */ |
49 | bool InterfaceSetupImp::saveSettings(){ | 49 | bool InterfaceSetupImp::saveSettings(){ |
50 | // 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 |
51 | if(!interfaces->isInterfaceSet()) | 51 | if(!interfaces->isInterfaceSet()) |
52 | return true; | 52 | return true; |
53 | 53 | ||
54 | bool error = false; | 54 | bool error = false; |
55 | // Loopback case | 55 | // Loopback case |
56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
58 | return true; | 58 | return true; |
59 | } | 59 | } |
60 | 60 | ||
61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty() || firstDNSLineEdit->text().isEmpty())){ | 61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
62 | QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "Ok"); | 62 | QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n and gateway entries.", "Ok"); |
63 | return false; | 63 | return false; |
64 | } | 64 | } |
65 | interfaces->removeAllInterfaceOptions(); | 65 | interfaces->removeAllInterfaceOptions(); |
66 | 66 | ||
67 | // DHCP | 67 | // DHCP |
68 | if(dhcpCheckBox->isChecked()){ | 68 | if(dhcpCheckBox->isChecked()){ |
69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); | 70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); |
71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); | 71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); |
72 | } | 72 | } |
73 | else{ | 73 | else{ |
74 | interfaces->setInterfaceMethod("static"); | 74 | interfaces->setInterfaceMethod("static"); |
75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
78 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 78 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
79 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 79 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
80 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 80 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
81 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | ||
82 | } | ||
81 | } | 83 | } |
82 | 84 | ||
83 | // IP Information | 85 | // IP Information |
84 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 86 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
85 | return true; | 87 | return true; |
86 | } | 88 | } |
87 | 89 | ||
88 | /** | 90 | /** |
89 | * The Profile has changed. | 91 | * The Profile has changed. |
90 | * @profile the new profile. | 92 | * @profile the new profile. |
91 | */ | 93 | */ |
92 | void InterfaceSetupImp::setProfile(const QString &profile){ | 94 | void InterfaceSetupImp::setProfile(const QString &profile){ |
93 | QString newInterfaceName = interface->getInterfaceName(); | 95 | QString newInterfaceName = interface->getInterfaceName(); |
94 | if(profile.length() > 0) | 96 | if(profile.length() > 0) |
95 | newInterfaceName += "_" + profile; | 97 | newInterfaceName += "_" + profile; |
96 | qDebug("InterfaceSetupImp::setProfile"); | 98 | qDebug("InterfaceSetupImp::setProfile"); |
97 | // See if we have to make a interface. | 99 | // See if we have to make a interface. |
98 | if(!interfaces->setInterface(newInterfaceName)){ | 100 | if(!interfaces->setInterface(newInterfaceName)){ |
99 | // Add making for this new interface if need too | 101 | // Add making for this new interface if need too |
100 | if(profile != ""){ | 102 | if(profile != ""){ |
101 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 103 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
102 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 104 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
103 | interfaces->addMapping(interface->getInterfaceName()); | 105 | interfaces->addMapping(interface->getInterfaceName()); |
104 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 106 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
105 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); | 107 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); |
106 | return; | 108 | return; |
107 | } | 109 | } |
108 | } | 110 | } |
109 | interfaces->setMap("map", newInterfaceName); | 111 | interfaces->setMap("map", newInterfaceName); |
110 | interfaces->setScript("getprofile.sh"); | 112 | interfaces->setScript("getprofile.sh"); |
111 | } | 113 | } |
112 | else{ | 114 | else{ |
113 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 115 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
114 | if(!interfaces->setInterface(newInterfaceName)){ | 116 | if(!interfaces->setInterface(newInterfaceName)){ |
115 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); | 117 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); |
116 | return; | 118 | return; |
117 | } | 119 | } |
118 | } | 120 | } |
119 | } | 121 | } |
120 | 122 | ||
121 | // We must have a valid interface to get this far so read some settings. | 123 | // We must have a valid interface to get this far so read some settings. |
122 | 124 | ||
123 | // DHCP | 125 | // DHCP |
124 | bool error = false; | 126 | bool error = false; |
125 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 127 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
126 | dhcpCheckBox->setChecked(true); | 128 | dhcpCheckBox->setChecked(true); |
127 | else | 129 | else |
128 | dhcpCheckBox->setChecked(false); | 130 | dhcpCheckBox->setChecked(false); |
129 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); | 131 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); |
130 | if(error) | 132 | if(error) |
131 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); | 133 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); |
132 | if(error) | 134 | if(error) |
133 | leaseTime->setValue(24); | 135 | leaseTime->setValue(24); |
134 | 136 | ||
135 | // IP Information | 137 | // IP Information |
136 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 138 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
137 | QString dns = interfaces->getInterfaceOption("up interfacednsscript -a", error); | 139 | QString dns = interfaces->getInterfaceOption("up interfacednsscript -a", error); |
138 | if(dns.contains(" ")){ | 140 | if(dns.contains(" ")){ |
139 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 141 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
140 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 142 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
141 | } | 143 | } |
142 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 144 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
143 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 145 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
144 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 146 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
145 | } | 147 | } |
146 | 148 | ||
147 | 149 | ||
148 | // interfacesetup.cpp | 150 | // interfacesetup.cpp |
149 | 151 | ||