Diffstat (limited to 'noncore/net/networksetup/interfaces') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/interfaces/interfacesetupimp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp index a19aaeb..3b1a4de 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp | |||
@@ -15,97 +15,97 @@ | |||
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 | bool InterfaceSetupImp::saveChanges(){ | 39 | bool InterfaceSetupImp::saveChanges(){ |
40 | if(!saveSettings()) | 40 | if(!saveSettings()) |
41 | return false; | 41 | return false; |
42 | interfaces->write(); | 42 | interfaces->write(); |
43 | return true; | 43 | return true; |
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Save the settings for the current Interface. | 47 | * Save the settings for the current Interface. |
48 | * @return bool true if successfull, false otherwise | 48 | * @return bool true if successfull, false otherwise |
49 | */ | 49 | */ |
50 | bool InterfaceSetupImp::saveSettings(){ | 50 | bool InterfaceSetupImp::saveSettings(){ |
51 | // eh can't really do anything about it other then return. :-D | 51 | // eh can't really do anything about it other then return. :-D |
52 | if(!interfaces->isInterfaceSet()) | 52 | if(!interfaces->isInterfaceSet()) |
53 | return true; | 53 | return true; |
54 | 54 | ||
55 | bool error = false; | 55 | bool error = false; |
56 | // Loopback case | 56 | // Loopback case |
57 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 57 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
58 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 58 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
59 | return true; | 59 | return true; |
60 | } | 60 | } |
61 | 61 | ||
62 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 62 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
63 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", "Ok"); | 63 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); |
64 | return false; | 64 | return false; |
65 | } | 65 | } |
66 | interfaces->removeAllInterfaceOptions(); | 66 | interfaces->removeAllInterfaceOptions(); |
67 | 67 | ||
68 | // DHCP | 68 | // DHCP |
69 | if(dhcpCheckBox->isChecked()){ | 69 | if(dhcpCheckBox->isChecked()){ |
70 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 70 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
71 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); | 71 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); |
72 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); | 72 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); |
73 | } | 73 | } |
74 | else{ | 74 | else{ |
75 | interfaces->setInterfaceMethod("static"); | 75 | interfaces->setInterfaceMethod("static"); |
76 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 76 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
77 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 77 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
78 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 78 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
79 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 79 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
80 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 80 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
81 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 81 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
82 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 82 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | // IP Information | 86 | // IP Information |
87 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 87 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * The Profile has changed. | 92 | * The Profile has changed. |
93 | * @profile the new profile. | 93 | * @profile the new profile. |
94 | */ | 94 | */ |
95 | void InterfaceSetupImp::setProfile(const QString &profile){ | 95 | void InterfaceSetupImp::setProfile(const QString &profile){ |
96 | QString newInterfaceName = interface->getInterfaceName(); | 96 | QString newInterfaceName = interface->getInterfaceName(); |
97 | if(profile.length() > 0) | 97 | if(profile.length() > 0) |
98 | newInterfaceName += "_" + profile; | 98 | newInterfaceName += "_" + profile; |
99 | qDebug("InterfaceSetupImp::setProfile"); | 99 | qDebug("InterfaceSetupImp::setProfile"); |
100 | // See if we have to make a interface. | 100 | // See if we have to make a interface. |
101 | if(!interfaces->setInterface(newInterfaceName)){ | 101 | if(!interfaces->setInterface(newInterfaceName)){ |
102 | // Add making for this new interface if need too | 102 | // Add making for this new interface if need too |
103 | if(profile != ""){ | 103 | if(profile != ""){ |
104 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 104 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
105 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 105 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
106 | interfaces->addMapping(interface->getInterfaceName()); | 106 | interfaces->addMapping(interface->getInterfaceName()); |
107 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 107 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
108 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); | 108 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); |
109 | return; | 109 | return; |
110 | } | 110 | } |
111 | } | 111 | } |