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