6 files changed, 20 insertions, 16 deletions
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp index 550e909..a19aaeb 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp | |||
@@ -1,151 +1,152 @@ | |||
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 | bool InterfaceSetupImp::saveChanges(){ |
40 | if(!saveSettings()) | 40 | if(!saveSettings()) |
41 | return; | 41 | return false; |
42 | interfaces->write(); | 42 | interfaces->write(); |
43 | return true; | ||
43 | } | 44 | } |
44 | 45 | ||
45 | /** | 46 | /** |
46 | * Save the settings for the current Interface. | 47 | * Save the settings for the current Interface. |
47 | * @return bool true if successfull, false otherwise | 48 | * @return bool true if successfull, false otherwise |
48 | */ | 49 | */ |
49 | bool InterfaceSetupImp::saveSettings(){ | 50 | bool InterfaceSetupImp::saveSettings(){ |
50 | // 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 |
51 | if(!interfaces->isInterfaceSet()) | 52 | if(!interfaces->isInterfaceSet()) |
52 | return true; | 53 | return true; |
53 | 54 | ||
54 | bool error = false; | 55 | bool error = false; |
55 | // Loopback case | 56 | // Loopback case |
56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 57 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 58 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
58 | return true; | 59 | return true; |
59 | } | 60 | } |
60 | 61 | ||
61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 62 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
62 | QMessageBox::information(this, "Not Saved.", "Please fill in address, subnet,\n and gateway entries.", "Ok"); | 63 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", "Ok"); |
63 | return false; | 64 | return false; |
64 | } | 65 | } |
65 | interfaces->removeAllInterfaceOptions(); | 66 | interfaces->removeAllInterfaceOptions(); |
66 | 67 | ||
67 | // DHCP | 68 | // DHCP |
68 | if(dhcpCheckBox->isChecked()){ | 69 | if(dhcpCheckBox->isChecked()){ |
69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 70 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); | 71 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); |
71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); | 72 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); |
72 | } | 73 | } |
73 | else{ | 74 | else{ |
74 | interfaces->setInterfaceMethod("static"); | 75 | interfaces->setInterfaceMethod("static"); |
75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 76 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 77 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 78 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
78 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 79 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
79 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 80 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
80 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 81 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
81 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 82 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
82 | } | 83 | } |
83 | } | 84 | } |
84 | 85 | ||
85 | // IP Information | 86 | // IP Information |
86 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 87 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
87 | return true; | 88 | return true; |
88 | } | 89 | } |
89 | 90 | ||
90 | /** | 91 | /** |
91 | * The Profile has changed. | 92 | * The Profile has changed. |
92 | * @profile the new profile. | 93 | * @profile the new profile. |
93 | */ | 94 | */ |
94 | void InterfaceSetupImp::setProfile(const QString &profile){ | 95 | void InterfaceSetupImp::setProfile(const QString &profile){ |
95 | QString newInterfaceName = interface->getInterfaceName(); | 96 | QString newInterfaceName = interface->getInterfaceName(); |
96 | if(profile.length() > 0) | 97 | if(profile.length() > 0) |
97 | newInterfaceName += "_" + profile; | 98 | newInterfaceName += "_" + profile; |
98 | qDebug("InterfaceSetupImp::setProfile"); | 99 | qDebug("InterfaceSetupImp::setProfile"); |
99 | // See if we have to make a interface. | 100 | // See if we have to make a interface. |
100 | if(!interfaces->setInterface(newInterfaceName)){ | 101 | if(!interfaces->setInterface(newInterfaceName)){ |
101 | // Add making for this new interface if need too | 102 | // Add making for this new interface if need too |
102 | if(profile != ""){ | 103 | if(profile != ""){ |
103 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 104 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
104 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 105 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
105 | interfaces->addMapping(interface->getInterfaceName()); | 106 | interfaces->addMapping(interface->getInterfaceName()); |
106 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 107 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
107 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); | 108 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); |
108 | return; | 109 | return; |
109 | } | 110 | } |
110 | } | 111 | } |
111 | interfaces->setMap("map", newInterfaceName); | 112 | interfaces->setMap("map", newInterfaceName); |
112 | interfaces->setScript("getprofile.sh"); | 113 | interfaces->setScript("getprofile.sh"); |
113 | } | 114 | } |
114 | else{ | 115 | else{ |
115 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 116 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
116 | if(!interfaces->setInterface(newInterfaceName)){ | 117 | if(!interfaces->setInterface(newInterfaceName)){ |
117 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); | 118 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); |
118 | return; | 119 | return; |
119 | } | 120 | } |
120 | } | 121 | } |
121 | } | 122 | } |
122 | 123 | ||
123 | // We must have a valid interface to get this far so read some settings. | 124 | // We must have a valid interface to get this far so read some settings. |
124 | 125 | ||
125 | // DHCP | 126 | // DHCP |
126 | bool error = false; | 127 | bool error = false; |
127 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 128 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
128 | dhcpCheckBox->setChecked(true); | 129 | dhcpCheckBox->setChecked(true); |
129 | else | 130 | else |
130 | dhcpCheckBox->setChecked(false); | 131 | dhcpCheckBox->setChecked(false); |
131 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); | 132 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); |
132 | if(error) | 133 | if(error) |
133 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); | 134 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); |
134 | if(error) | 135 | if(error) |
135 | leaseTime->setValue(24); | 136 | leaseTime->setValue(24); |
136 | 137 | ||
137 | // IP Information | 138 | // IP Information |
138 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 139 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
139 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); | 140 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); |
140 | if(dns.contains(" ")){ | 141 | if(dns.contains(" ")){ |
141 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 142 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
142 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 143 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
143 | } | 144 | } |
144 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 145 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
145 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 146 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
146 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 147 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
147 | } | 148 | } |
148 | 149 | ||
149 | 150 | ||
150 | // interfacesetup.cpp | 151 | // interfacesetup.cpp |
151 | 152 | ||
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.h b/noncore/net/networksetup/interfaces/interfacesetupimp.h index 3bbf34e..a88e190 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.h +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.h | |||
@@ -1,55 +1,56 @@ | |||
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 <qdialog.h> | 5 | #include <qdialog.h> |
6 | 6 | ||
7 | class Interface; | 7 | class Interface; |
8 | class Interfaces; | 8 | class Interfaces; |
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); | 14 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); |
15 | void saveChanges(); | 15 | bool saveChanges(); |
16 | 16 | ||
17 | public slots: | 17 | public slots: |
18 | void setProfile(const QString &profile); | 18 | void setProfile(const QString &profile); |
19 | bool saveSettings(); | 19 | bool saveSettings(); |
20 | |||
20 | private: | 21 | private: |
21 | Interfaces *interfaces; | 22 | Interfaces *interfaces; |
22 | Interface *interface; | 23 | Interface *interface; |
23 | 24 | ||
24 | }; | 25 | }; |
25 | 26 | ||
26 | 27 | ||
27 | #include <qlayout.h> | 28 | #include <qlayout.h> |
28 | 29 | ||
29 | class InterfaceSetupImpDialog : public QDialog { | 30 | class InterfaceSetupImpDialog : public QDialog { |
30 | Q_OBJECT | 31 | Q_OBJECT |
31 | 32 | ||
32 | public: | 33 | public: |
33 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ | 34 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ |
34 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); | 35 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); |
35 | setCaption("Interface Setup"); | 36 | setCaption("Interface Setup"); |
36 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); | 37 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); |
37 | InterfaceSetupLayout->addWidget( interfaceSetup ); | 38 | InterfaceSetupLayout->addWidget( interfaceSetup ); |
38 | }; | 39 | }; |
39 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; | 40 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; |
40 | 41 | ||
41 | private: | 42 | private: |
42 | InterfaceSetupImp *interfaceSetup; | 43 | InterfaceSetupImp *interfaceSetup; |
43 | 44 | ||
44 | protected slots: | 45 | protected slots: |
45 | void accept(){ | 46 | void accept(){ |
46 | interfaceSetup->saveChanges(); | 47 | if(interfaceSetup->saveChanges()) |
47 | QDialog::accept(); | 48 | QDialog::accept(); |
48 | }; | 49 | }; |
49 | 50 | ||
50 | }; | 51 | }; |
51 | 52 | ||
52 | #endif | 53 | #endif |
53 | 54 | ||
54 | // interfacesetupimp.h | 55 | // interfacesetupimp.h |
55 | 56 | ||
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 74bf390..01d7e36 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -28,194 +28,194 @@ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, W | |||
28 | readConfig(); | 28 | readConfig(); |
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | WLANImp::~WLANImp( ){ | 32 | WLANImp::~WLANImp( ){ |
33 | delete config; | 33 | delete config; |
34 | } | 34 | } |
35 | 35 | ||
36 | void WLANImp::setProfile(QString &profile){ | 36 | void WLANImp::setProfile(QString &profile){ |
37 | interfaceSetup->setProfile(profile); | 37 | interfaceSetup->setProfile(profile); |
38 | } | 38 | } |
39 | 39 | ||
40 | void WLANImp::readConfig() | 40 | void WLANImp::readConfig() |
41 | { | 41 | { |
42 | qWarning( "WLANImp::readConfig() called." ); | 42 | qWarning( "WLANImp::readConfig() called." ); |
43 | config->setGroup( "Properties" ); | 43 | config->setGroup( "Properties" ); |
44 | QString ssid = config->readEntry( "SSID", "any" ); | 44 | QString ssid = config->readEntry( "SSID", "any" ); |
45 | if( ssid == "any" || ssid == "ANY" ){ | 45 | if( ssid == "any" || ssid == "ANY" ){ |
46 | essNon->setChecked( true ); | 46 | essNon->setChecked( true ); |
47 | } else { | 47 | } else { |
48 | essSpecific->setChecked( true ); | 48 | essSpecific->setChecked( true ); |
49 | essSpecificLineEdit->setText( ssid ); | 49 | essSpecificLineEdit->setText( ssid ); |
50 | } | 50 | } |
51 | QString mode = config->readEntry( "Mode", "Managed" ); | 51 | QString mode = config->readEntry( "Mode", "Managed" ); |
52 | if( mode == "adhoc" ) { | 52 | if( mode == "adhoc" ) { |
53 | network802->setChecked( true ); | 53 | network802->setChecked( true ); |
54 | } else { | 54 | } else { |
55 | networkInfrastructure->setChecked( true ); | 55 | networkInfrastructure->setChecked( true ); |
56 | } | 56 | } |
57 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); | 57 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
58 | // config->readEntry( "RATE", "auto" ); | 58 | // config->readEntry( "RATE", "auto" ); |
59 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 59 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
60 | config->readEntry( "AuthType", "opensystem" ); | 60 | config->readEntry( "AuthType", "opensystem" ); |
61 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 61 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
62 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 62 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
63 | switch( defaultkey ){ | 63 | switch( defaultkey ){ |
64 | case 0: | 64 | case 0: |
65 | keyRadio0->setChecked( true ); | 65 | keyRadio0->setChecked( true ); |
66 | break; | 66 | break; |
67 | case 1: | 67 | case 1: |
68 | keyRadio1->setChecked( true ); | 68 | keyRadio1->setChecked( true ); |
69 | break; | 69 | break; |
70 | case 2: | 70 | case 2: |
71 | keyRadio2->setChecked( true ); | 71 | keyRadio2->setChecked( true ); |
72 | break; | 72 | break; |
73 | case 3: | 73 | case 3: |
74 | keyRadio3->setChecked( true ); | 74 | keyRadio3->setChecked( true ); |
75 | break; | 75 | break; |
76 | } | 76 | } |
77 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); | 77 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
78 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); | 78 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
79 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); | 79 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
80 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); | 80 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
81 | return; | 81 | return; |
82 | } | 82 | } |
83 | 83 | ||
84 | bool WLANImp::writeConfig() | 84 | bool WLANImp::writeConfig() |
85 | { | 85 | { |
86 | qWarning( "WLANImp::writeConfig() called." ); | 86 | qWarning( "WLANImp::writeConfig() called." ); |
87 | config->setGroup( "Properties" ); | 87 | config->setGroup( "Properties" ); |
88 | if( essNon->isChecked() ) { | 88 | if( essNon->isChecked() ) { |
89 | config->writeEntry( "SSID", "any" ); | 89 | config->writeEntry( "SSID", "any" ); |
90 | } else { | 90 | } else { |
91 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); | 91 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
92 | } | 92 | } |
93 | if( networkInfrastructure->isChecked() ){ | 93 | if( networkInfrastructure->isChecked() ){ |
94 | config->writeEntry( "Mode", "Managed" ); | 94 | config->writeEntry( "Mode", "Managed" ); |
95 | } else if( network802->isChecked() ){ | 95 | } else if( network802->isChecked() ){ |
96 | config->writeEntry( "Mode", "adhoc" ); | 96 | config->writeEntry( "Mode", "adhoc" ); |
97 | } | 97 | } |
98 | config->writeEntry( "CHANNEL", networkChannel->value() ); | 98 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
99 | // config->readEntry( "RATE", "auto" ); | 99 | // config->readEntry( "RATE", "auto" ); |
100 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); | 100 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
101 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); | 101 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
102 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); | 102 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
103 | if( keyRadio0->isChecked() ){ | 103 | if( keyRadio0->isChecked() ){ |
104 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); | 104 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
105 | } else if( keyRadio1->isChecked() ){ | 105 | } else if( keyRadio1->isChecked() ){ |
106 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); | 106 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
107 | } else if( keyRadio2->isChecked() ){ | 107 | } else if( keyRadio2->isChecked() ){ |
108 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); | 108 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
109 | } else if( keyRadio3->isChecked() ){ | 109 | } else if( keyRadio3->isChecked() ){ |
110 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); | 110 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
111 | } | 111 | } |
112 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 112 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
113 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 113 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
114 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 114 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
115 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 115 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
116 | return writeWirelessOpts( ); | 116 | return writeWirelessOpts( ); |
117 | } | 117 | } |
118 | 118 | ||
119 | /** | 119 | /** |
120 | */ | 120 | */ |
121 | void WLANImp::accept() | 121 | void WLANImp::accept() |
122 | { | 122 | { |
123 | if ( writeConfig() ){ | 123 | if ( writeConfig() ){ |
124 | interfaceSetup->saveChanges(); | 124 | if(interfaceSetup->saveChanges()) |
125 | QDialog::accept(); | 125 | QDialog::accept(); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | bool WLANImp::writeWirelessOpts( QString scheme ) | 129 | bool WLANImp::writeWirelessOpts( QString scheme ) |
130 | { | 130 | { |
131 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 131 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
132 | QString prev = "/etc/pcmcia/wireless.opts"; | 132 | QString prev = "/etc/pcmcia/wireless.opts"; |
133 | QFile prevFile(prev); | 133 | QFile prevFile(prev); |
134 | if ( !prevFile.open( IO_ReadOnly ) ) | 134 | if ( !prevFile.open( IO_ReadOnly ) ) |
135 | return false; | 135 | return false; |
136 | 136 | ||
137 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 137 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
138 | QFile tmpFile(tmp); | 138 | QFile tmpFile(tmp); |
139 | if ( !tmpFile.open( IO_WriteOnly ) ) | 139 | if ( !tmpFile.open( IO_WriteOnly ) ) |
140 | return false; | 140 | return false; |
141 | 141 | ||
142 | bool retval = true; | 142 | bool retval = true; |
143 | 143 | ||
144 | QTextStream in( &prevFile ); | 144 | QTextStream in( &prevFile ); |
145 | QTextStream out( &tmpFile ); | 145 | QTextStream out( &tmpFile ); |
146 | 146 | ||
147 | config->setGroup("Properties"); | 147 | config->setGroup("Properties"); |
148 | 148 | ||
149 | QString line; | 149 | QString line; |
150 | bool found=false; | 150 | bool found=false; |
151 | bool done=false; | 151 | bool done=false; |
152 | while ( !in.atEnd() ) { | 152 | while ( !in.atEnd() ) { |
153 | QString line = in.readLine(); | 153 | QString line = in.readLine(); |
154 | QString wline = line.simplifyWhiteSpace(); | 154 | QString wline = line.simplifyWhiteSpace(); |
155 | if ( !done ) { | 155 | if ( !done ) { |
156 | if ( found ) { | 156 | if ( found ) { |
157 | // skip existing entry for this scheme, and write our own. | 157 | // skip existing entry for this scheme, and write our own. |
158 | if ( wline == ";;" ) { | 158 | if ( wline == ";;" ) { |
159 | found = false; | 159 | found = false; |
160 | continue; | 160 | continue; |
161 | } else { | 161 | } else { |
162 | continue; | 162 | continue; |
163 | } | 163 | } |
164 | } else { | 164 | } else { |
165 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 165 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
166 | found=true; | 166 | found=true; |
167 | continue; // skip this line | 167 | continue; // skip this line |
168 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 168 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
169 | // end - add new entry | 169 | // end - add new entry |
170 | // Not all fields have a GUI, but all are supported | 170 | // Not all fields have a GUI, but all are supported |
171 | // in the letwork configuration files. | 171 | // in the letwork configuration files. |
172 | static const char* txtfields[] = { | 172 | static const char* txtfields[] = { |
173 | 0 | 173 | 0 |
174 | }; | 174 | }; |
175 | QString readmode = config->readEntry( "Mode", "Managed" ); | 175 | QString readmode = config->readEntry( "Mode", "Managed" ); |
176 | QString mode; | 176 | QString mode; |
177 | if( readmode == "Managed" ){ | 177 | if( readmode == "Managed" ){ |
178 | mode = readmode; | 178 | mode = readmode; |
179 | } else if( readmode == "adhoc" ){ | 179 | } else if( readmode == "adhoc" ){ |
180 | mode = "Ad-Hoc"; | 180 | mode = "Ad-Hoc"; |
181 | } | 181 | } |
182 | QString key; | 182 | QString key; |
183 | if( wepEnabled->isChecked() ){ | 183 | if( wepEnabled->isChecked() ){ |
184 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 184 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
185 | switch( defaultkey ){ | 185 | switch( defaultkey ){ |
186 | case 0: | 186 | case 0: |
187 | key += keyLineEdit0->text(); | 187 | key += keyLineEdit0->text(); |
188 | break; | 188 | break; |
189 | case 1: | 189 | case 1: |
190 | key += keyLineEdit1->text(); | 190 | key += keyLineEdit1->text(); |
191 | break; | 191 | break; |
192 | case 2: | 192 | case 2: |
193 | key += keyLineEdit2->text(); | 193 | key += keyLineEdit2->text(); |
194 | break; | 194 | break; |
195 | case 3: | 195 | case 3: |
196 | key += keyLineEdit3->text(); | 196 | key += keyLineEdit3->text(); |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") | 199 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
200 | key += " open"; | 200 | key += " open"; |
201 | } | 201 | } |
202 | out << scheme << ",*,*,*)" << "\n" | 202 | out << scheme << ",*,*,*)" << "\n" |
203 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" | 203 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
204 | << " MODE=" << mode << "\n" | 204 | << " MODE=" << mode << "\n" |
205 | << " KEY=" << Global::shellQuote( key ) << "\n" | 205 | << " KEY=" << Global::shellQuote( key ) << "\n" |
206 | << " RATE=" << "auto" << "\n" | 206 | << " RATE=" << "auto" << "\n" |
207 | ; | 207 | ; |
208 | if( mode != "Managed" ) | 208 | if( mode != "Managed" ) |
209 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; | 209 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
210 | const char** f = txtfields; | 210 | const char** f = txtfields; |
211 | while (*f) { | 211 | while (*f) { |
212 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; | 212 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
213 | ++f; | 213 | ++f; |
214 | } | 214 | } |
215 | out << " ;;\n"; | 215 | out << " ;;\n"; |
216 | done = true; | 216 | done = true; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | out << line << "\n"; | 220 | out << line << "\n"; |
221 | } | 221 | } |
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 550e909..a19aaeb 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -1,151 +1,152 @@ | |||
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 | bool InterfaceSetupImp::saveChanges(){ |
40 | if(!saveSettings()) | 40 | if(!saveSettings()) |
41 | return; | 41 | return false; |
42 | interfaces->write(); | 42 | interfaces->write(); |
43 | return true; | ||
43 | } | 44 | } |
44 | 45 | ||
45 | /** | 46 | /** |
46 | * Save the settings for the current Interface. | 47 | * Save the settings for the current Interface. |
47 | * @return bool true if successfull, false otherwise | 48 | * @return bool true if successfull, false otherwise |
48 | */ | 49 | */ |
49 | bool InterfaceSetupImp::saveSettings(){ | 50 | bool InterfaceSetupImp::saveSettings(){ |
50 | // 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 |
51 | if(!interfaces->isInterfaceSet()) | 52 | if(!interfaces->isInterfaceSet()) |
52 | return true; | 53 | return true; |
53 | 54 | ||
54 | bool error = false; | 55 | bool error = false; |
55 | // Loopback case | 56 | // Loopback case |
56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 57 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 58 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
58 | return true; | 59 | return true; |
59 | } | 60 | } |
60 | 61 | ||
61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 62 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
62 | QMessageBox::information(this, "Not Saved.", "Please fill in address, subnet,\n and gateway entries.", "Ok"); | 63 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", "Ok"); |
63 | return false; | 64 | return false; |
64 | } | 65 | } |
65 | interfaces->removeAllInterfaceOptions(); | 66 | interfaces->removeAllInterfaceOptions(); |
66 | 67 | ||
67 | // DHCP | 68 | // DHCP |
68 | if(dhcpCheckBox->isChecked()){ | 69 | if(dhcpCheckBox->isChecked()){ |
69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 70 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); | 71 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); |
71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); | 72 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); |
72 | } | 73 | } |
73 | else{ | 74 | else{ |
74 | interfaces->setInterfaceMethod("static"); | 75 | interfaces->setInterfaceMethod("static"); |
75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 76 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 77 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 78 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
78 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 79 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
79 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 80 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
80 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 81 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
81 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 82 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
82 | } | 83 | } |
83 | } | 84 | } |
84 | 85 | ||
85 | // IP Information | 86 | // IP Information |
86 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 87 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
87 | return true; | 88 | return true; |
88 | } | 89 | } |
89 | 90 | ||
90 | /** | 91 | /** |
91 | * The Profile has changed. | 92 | * The Profile has changed. |
92 | * @profile the new profile. | 93 | * @profile the new profile. |
93 | */ | 94 | */ |
94 | void InterfaceSetupImp::setProfile(const QString &profile){ | 95 | void InterfaceSetupImp::setProfile(const QString &profile){ |
95 | QString newInterfaceName = interface->getInterfaceName(); | 96 | QString newInterfaceName = interface->getInterfaceName(); |
96 | if(profile.length() > 0) | 97 | if(profile.length() > 0) |
97 | newInterfaceName += "_" + profile; | 98 | newInterfaceName += "_" + profile; |
98 | qDebug("InterfaceSetupImp::setProfile"); | 99 | qDebug("InterfaceSetupImp::setProfile"); |
99 | // See if we have to make a interface. | 100 | // See if we have to make a interface. |
100 | if(!interfaces->setInterface(newInterfaceName)){ | 101 | if(!interfaces->setInterface(newInterfaceName)){ |
101 | // Add making for this new interface if need too | 102 | // Add making for this new interface if need too |
102 | if(profile != ""){ | 103 | if(profile != ""){ |
103 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 104 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
104 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 105 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
105 | interfaces->addMapping(interface->getInterfaceName()); | 106 | interfaces->addMapping(interface->getInterfaceName()); |
106 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 107 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
107 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); | 108 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); |
108 | return; | 109 | return; |
109 | } | 110 | } |
110 | } | 111 | } |
111 | interfaces->setMap("map", newInterfaceName); | 112 | interfaces->setMap("map", newInterfaceName); |
112 | interfaces->setScript("getprofile.sh"); | 113 | interfaces->setScript("getprofile.sh"); |
113 | } | 114 | } |
114 | else{ | 115 | else{ |
115 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 116 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
116 | if(!interfaces->setInterface(newInterfaceName)){ | 117 | if(!interfaces->setInterface(newInterfaceName)){ |
117 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); | 118 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); |
118 | return; | 119 | return; |
119 | } | 120 | } |
120 | } | 121 | } |
121 | } | 122 | } |
122 | 123 | ||
123 | // We must have a valid interface to get this far so read some settings. | 124 | // We must have a valid interface to get this far so read some settings. |
124 | 125 | ||
125 | // DHCP | 126 | // DHCP |
126 | bool error = false; | 127 | bool error = false; |
127 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 128 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
128 | dhcpCheckBox->setChecked(true); | 129 | dhcpCheckBox->setChecked(true); |
129 | else | 130 | else |
130 | dhcpCheckBox->setChecked(false); | 131 | dhcpCheckBox->setChecked(false); |
131 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); | 132 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); |
132 | if(error) | 133 | if(error) |
133 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); | 134 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); |
134 | if(error) | 135 | if(error) |
135 | leaseTime->setValue(24); | 136 | leaseTime->setValue(24); |
136 | 137 | ||
137 | // IP Information | 138 | // IP Information |
138 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 139 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
139 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); | 140 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); |
140 | if(dns.contains(" ")){ | 141 | if(dns.contains(" ")){ |
141 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 142 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
142 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 143 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
143 | } | 144 | } |
144 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 145 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
145 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 146 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
146 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 147 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
147 | } | 148 | } |
148 | 149 | ||
149 | 150 | ||
150 | // interfacesetup.cpp | 151 | // interfacesetup.cpp |
151 | 152 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.h b/noncore/settings/networksettings/interfaces/interfacesetupimp.h index 3bbf34e..a88e190 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.h +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.h | |||
@@ -1,55 +1,56 @@ | |||
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 <qdialog.h> | 5 | #include <qdialog.h> |
6 | 6 | ||
7 | class Interface; | 7 | class Interface; |
8 | class Interfaces; | 8 | class Interfaces; |
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); | 14 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); |
15 | void saveChanges(); | 15 | bool saveChanges(); |
16 | 16 | ||
17 | public slots: | 17 | public slots: |
18 | void setProfile(const QString &profile); | 18 | void setProfile(const QString &profile); |
19 | bool saveSettings(); | 19 | bool saveSettings(); |
20 | |||
20 | private: | 21 | private: |
21 | Interfaces *interfaces; | 22 | Interfaces *interfaces; |
22 | Interface *interface; | 23 | Interface *interface; |
23 | 24 | ||
24 | }; | 25 | }; |
25 | 26 | ||
26 | 27 | ||
27 | #include <qlayout.h> | 28 | #include <qlayout.h> |
28 | 29 | ||
29 | class InterfaceSetupImpDialog : public QDialog { | 30 | class InterfaceSetupImpDialog : public QDialog { |
30 | Q_OBJECT | 31 | Q_OBJECT |
31 | 32 | ||
32 | public: | 33 | public: |
33 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ | 34 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ |
34 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); | 35 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); |
35 | setCaption("Interface Setup"); | 36 | setCaption("Interface Setup"); |
36 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); | 37 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); |
37 | InterfaceSetupLayout->addWidget( interfaceSetup ); | 38 | InterfaceSetupLayout->addWidget( interfaceSetup ); |
38 | }; | 39 | }; |
39 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; | 40 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; |
40 | 41 | ||
41 | private: | 42 | private: |
42 | InterfaceSetupImp *interfaceSetup; | 43 | InterfaceSetupImp *interfaceSetup; |
43 | 44 | ||
44 | protected slots: | 45 | protected slots: |
45 | void accept(){ | 46 | void accept(){ |
46 | interfaceSetup->saveChanges(); | 47 | if(interfaceSetup->saveChanges()) |
47 | QDialog::accept(); | 48 | QDialog::accept(); |
48 | }; | 49 | }; |
49 | 50 | ||
50 | }; | 51 | }; |
51 | 52 | ||
52 | #endif | 53 | #endif |
53 | 54 | ||
54 | // interfacesetupimp.h | 55 | // interfacesetupimp.h |
55 | 56 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 74bf390..01d7e36 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -28,194 +28,194 @@ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, W | |||
28 | readConfig(); | 28 | readConfig(); |
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | WLANImp::~WLANImp( ){ | 32 | WLANImp::~WLANImp( ){ |
33 | delete config; | 33 | delete config; |
34 | } | 34 | } |
35 | 35 | ||
36 | void WLANImp::setProfile(QString &profile){ | 36 | void WLANImp::setProfile(QString &profile){ |
37 | interfaceSetup->setProfile(profile); | 37 | interfaceSetup->setProfile(profile); |
38 | } | 38 | } |
39 | 39 | ||
40 | void WLANImp::readConfig() | 40 | void WLANImp::readConfig() |
41 | { | 41 | { |
42 | qWarning( "WLANImp::readConfig() called." ); | 42 | qWarning( "WLANImp::readConfig() called." ); |
43 | config->setGroup( "Properties" ); | 43 | config->setGroup( "Properties" ); |
44 | QString ssid = config->readEntry( "SSID", "any" ); | 44 | QString ssid = config->readEntry( "SSID", "any" ); |
45 | if( ssid == "any" || ssid == "ANY" ){ | 45 | if( ssid == "any" || ssid == "ANY" ){ |
46 | essNon->setChecked( true ); | 46 | essNon->setChecked( true ); |
47 | } else { | 47 | } else { |
48 | essSpecific->setChecked( true ); | 48 | essSpecific->setChecked( true ); |
49 | essSpecificLineEdit->setText( ssid ); | 49 | essSpecificLineEdit->setText( ssid ); |
50 | } | 50 | } |
51 | QString mode = config->readEntry( "Mode", "Managed" ); | 51 | QString mode = config->readEntry( "Mode", "Managed" ); |
52 | if( mode == "adhoc" ) { | 52 | if( mode == "adhoc" ) { |
53 | network802->setChecked( true ); | 53 | network802->setChecked( true ); |
54 | } else { | 54 | } else { |
55 | networkInfrastructure->setChecked( true ); | 55 | networkInfrastructure->setChecked( true ); |
56 | } | 56 | } |
57 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); | 57 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
58 | // config->readEntry( "RATE", "auto" ); | 58 | // config->readEntry( "RATE", "auto" ); |
59 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 59 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
60 | config->readEntry( "AuthType", "opensystem" ); | 60 | config->readEntry( "AuthType", "opensystem" ); |
61 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 61 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
62 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 62 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
63 | switch( defaultkey ){ | 63 | switch( defaultkey ){ |
64 | case 0: | 64 | case 0: |
65 | keyRadio0->setChecked( true ); | 65 | keyRadio0->setChecked( true ); |
66 | break; | 66 | break; |
67 | case 1: | 67 | case 1: |
68 | keyRadio1->setChecked( true ); | 68 | keyRadio1->setChecked( true ); |
69 | break; | 69 | break; |
70 | case 2: | 70 | case 2: |
71 | keyRadio2->setChecked( true ); | 71 | keyRadio2->setChecked( true ); |
72 | break; | 72 | break; |
73 | case 3: | 73 | case 3: |
74 | keyRadio3->setChecked( true ); | 74 | keyRadio3->setChecked( true ); |
75 | break; | 75 | break; |
76 | } | 76 | } |
77 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); | 77 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
78 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); | 78 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
79 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); | 79 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
80 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); | 80 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
81 | return; | 81 | return; |
82 | } | 82 | } |
83 | 83 | ||
84 | bool WLANImp::writeConfig() | 84 | bool WLANImp::writeConfig() |
85 | { | 85 | { |
86 | qWarning( "WLANImp::writeConfig() called." ); | 86 | qWarning( "WLANImp::writeConfig() called." ); |
87 | config->setGroup( "Properties" ); | 87 | config->setGroup( "Properties" ); |
88 | if( essNon->isChecked() ) { | 88 | if( essNon->isChecked() ) { |
89 | config->writeEntry( "SSID", "any" ); | 89 | config->writeEntry( "SSID", "any" ); |
90 | } else { | 90 | } else { |
91 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); | 91 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
92 | } | 92 | } |
93 | if( networkInfrastructure->isChecked() ){ | 93 | if( networkInfrastructure->isChecked() ){ |
94 | config->writeEntry( "Mode", "Managed" ); | 94 | config->writeEntry( "Mode", "Managed" ); |
95 | } else if( network802->isChecked() ){ | 95 | } else if( network802->isChecked() ){ |
96 | config->writeEntry( "Mode", "adhoc" ); | 96 | config->writeEntry( "Mode", "adhoc" ); |
97 | } | 97 | } |
98 | config->writeEntry( "CHANNEL", networkChannel->value() ); | 98 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
99 | // config->readEntry( "RATE", "auto" ); | 99 | // config->readEntry( "RATE", "auto" ); |
100 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); | 100 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
101 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); | 101 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
102 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); | 102 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
103 | if( keyRadio0->isChecked() ){ | 103 | if( keyRadio0->isChecked() ){ |
104 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); | 104 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
105 | } else if( keyRadio1->isChecked() ){ | 105 | } else if( keyRadio1->isChecked() ){ |
106 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); | 106 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
107 | } else if( keyRadio2->isChecked() ){ | 107 | } else if( keyRadio2->isChecked() ){ |
108 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); | 108 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
109 | } else if( keyRadio3->isChecked() ){ | 109 | } else if( keyRadio3->isChecked() ){ |
110 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); | 110 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
111 | } | 111 | } |
112 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 112 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
113 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 113 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
114 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 114 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
115 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 115 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
116 | return writeWirelessOpts( ); | 116 | return writeWirelessOpts( ); |
117 | } | 117 | } |
118 | 118 | ||
119 | /** | 119 | /** |
120 | */ | 120 | */ |
121 | void WLANImp::accept() | 121 | void WLANImp::accept() |
122 | { | 122 | { |
123 | if ( writeConfig() ){ | 123 | if ( writeConfig() ){ |
124 | interfaceSetup->saveChanges(); | 124 | if(interfaceSetup->saveChanges()) |
125 | QDialog::accept(); | 125 | QDialog::accept(); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | bool WLANImp::writeWirelessOpts( QString scheme ) | 129 | bool WLANImp::writeWirelessOpts( QString scheme ) |
130 | { | 130 | { |
131 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 131 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
132 | QString prev = "/etc/pcmcia/wireless.opts"; | 132 | QString prev = "/etc/pcmcia/wireless.opts"; |
133 | QFile prevFile(prev); | 133 | QFile prevFile(prev); |
134 | if ( !prevFile.open( IO_ReadOnly ) ) | 134 | if ( !prevFile.open( IO_ReadOnly ) ) |
135 | return false; | 135 | return false; |
136 | 136 | ||
137 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 137 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
138 | QFile tmpFile(tmp); | 138 | QFile tmpFile(tmp); |
139 | if ( !tmpFile.open( IO_WriteOnly ) ) | 139 | if ( !tmpFile.open( IO_WriteOnly ) ) |
140 | return false; | 140 | return false; |
141 | 141 | ||
142 | bool retval = true; | 142 | bool retval = true; |
143 | 143 | ||
144 | QTextStream in( &prevFile ); | 144 | QTextStream in( &prevFile ); |
145 | QTextStream out( &tmpFile ); | 145 | QTextStream out( &tmpFile ); |
146 | 146 | ||
147 | config->setGroup("Properties"); | 147 | config->setGroup("Properties"); |
148 | 148 | ||
149 | QString line; | 149 | QString line; |
150 | bool found=false; | 150 | bool found=false; |
151 | bool done=false; | 151 | bool done=false; |
152 | while ( !in.atEnd() ) { | 152 | while ( !in.atEnd() ) { |
153 | QString line = in.readLine(); | 153 | QString line = in.readLine(); |
154 | QString wline = line.simplifyWhiteSpace(); | 154 | QString wline = line.simplifyWhiteSpace(); |
155 | if ( !done ) { | 155 | if ( !done ) { |
156 | if ( found ) { | 156 | if ( found ) { |
157 | // skip existing entry for this scheme, and write our own. | 157 | // skip existing entry for this scheme, and write our own. |
158 | if ( wline == ";;" ) { | 158 | if ( wline == ";;" ) { |
159 | found = false; | 159 | found = false; |
160 | continue; | 160 | continue; |
161 | } else { | 161 | } else { |
162 | continue; | 162 | continue; |
163 | } | 163 | } |
164 | } else { | 164 | } else { |
165 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 165 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
166 | found=true; | 166 | found=true; |
167 | continue; // skip this line | 167 | continue; // skip this line |
168 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 168 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
169 | // end - add new entry | 169 | // end - add new entry |
170 | // Not all fields have a GUI, but all are supported | 170 | // Not all fields have a GUI, but all are supported |
171 | // in the letwork configuration files. | 171 | // in the letwork configuration files. |
172 | static const char* txtfields[] = { | 172 | static const char* txtfields[] = { |
173 | 0 | 173 | 0 |
174 | }; | 174 | }; |
175 | QString readmode = config->readEntry( "Mode", "Managed" ); | 175 | QString readmode = config->readEntry( "Mode", "Managed" ); |
176 | QString mode; | 176 | QString mode; |
177 | if( readmode == "Managed" ){ | 177 | if( readmode == "Managed" ){ |
178 | mode = readmode; | 178 | mode = readmode; |
179 | } else if( readmode == "adhoc" ){ | 179 | } else if( readmode == "adhoc" ){ |
180 | mode = "Ad-Hoc"; | 180 | mode = "Ad-Hoc"; |
181 | } | 181 | } |
182 | QString key; | 182 | QString key; |
183 | if( wepEnabled->isChecked() ){ | 183 | if( wepEnabled->isChecked() ){ |
184 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 184 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
185 | switch( defaultkey ){ | 185 | switch( defaultkey ){ |
186 | case 0: | 186 | case 0: |
187 | key += keyLineEdit0->text(); | 187 | key += keyLineEdit0->text(); |
188 | break; | 188 | break; |
189 | case 1: | 189 | case 1: |
190 | key += keyLineEdit1->text(); | 190 | key += keyLineEdit1->text(); |
191 | break; | 191 | break; |
192 | case 2: | 192 | case 2: |
193 | key += keyLineEdit2->text(); | 193 | key += keyLineEdit2->text(); |
194 | break; | 194 | break; |
195 | case 3: | 195 | case 3: |
196 | key += keyLineEdit3->text(); | 196 | key += keyLineEdit3->text(); |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") | 199 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
200 | key += " open"; | 200 | key += " open"; |
201 | } | 201 | } |
202 | out << scheme << ",*,*,*)" << "\n" | 202 | out << scheme << ",*,*,*)" << "\n" |
203 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" | 203 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
204 | << " MODE=" << mode << "\n" | 204 | << " MODE=" << mode << "\n" |
205 | << " KEY=" << Global::shellQuote( key ) << "\n" | 205 | << " KEY=" << Global::shellQuote( key ) << "\n" |
206 | << " RATE=" << "auto" << "\n" | 206 | << " RATE=" << "auto" << "\n" |
207 | ; | 207 | ; |
208 | if( mode != "Managed" ) | 208 | if( mode != "Managed" ) |
209 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; | 209 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
210 | const char** f = txtfields; | 210 | const char** f = txtfields; |
211 | while (*f) { | 211 | while (*f) { |
212 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; | 212 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
213 | ++f; | 213 | ++f; |
214 | } | 214 | } |
215 | out << " ;;\n"; | 215 | out << " ;;\n"; |
216 | done = true; | 216 | done = true; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | out << line << "\n"; | 220 | out << line << "\n"; |
221 | } | 221 | } |