-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 28 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 28 |
2 files changed, 26 insertions, 30 deletions
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 84e0bae..cc18fba 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -85,39 +85,39 @@ void WLANImp::parseSettingFile(){ | |||
85 | essSpecificLineEdit->setText(id); | 85 | essSpecificLineEdit->setText(id); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | if(line.contains("MODE=")){ | 88 | if(line.contains("MODE=")){ |
89 | QString mode = line.mid(line.find("MODE=")+5, line.length()); | 89 | QString mode = line.mid(line.find("MODE=")+5, line.length()); |
90 | if(mode == "Managed"){ | 90 | if(mode == "Managed"){ |
91 | networkType->setCurrentItem(0); | 91 | networkType->setCurrentItem(0); |
92 | channelLabel->setEnabled(false); | 92 | channelLabel->setEnabled(false); |
93 | networkChannel->setEnabled(false); | 93 | networkChannel->setEnabled(false); |
94 | } | 94 | } |
95 | else{ | 95 | else{ |
96 | networkType->setCurrentItem(1); | 96 | networkType->setCurrentItem(1); |
97 | networkChannel->setEnabled(true); | 97 | networkChannel->setEnabled(true); |
98 | channelLabel->setEnabled(true); | 98 | channelLabel->setEnabled(true); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | if(line.contains("KEY0=")) | 101 | if(line.contains("#KEY0=")) |
102 | keyLineEdit0->setText(line.mid(5, line.length())); | 102 | keyLineEdit0->setText(line.mid(5, line.length())); |
103 | if(line.contains("KEY1=")) | 103 | if(line.contains("#KEY1=")) |
104 | keyLineEdit1->setText(line.mid(5, line.length())); | 104 | keyLineEdit1->setText(line.mid(5, line.length())); |
105 | if(line.contains("KEY2=")) | 105 | if(line.contains("#KEY2=")) |
106 | keyLineEdit2->setText(line.mid(5, line.length())); | 106 | keyLineEdit2->setText(line.mid(5, line.length())); |
107 | if(line.contains("KEY3=")) | 107 | if(line.contains("#KEY3=")) |
108 | keyLineEdit3->setText(line.mid(5, line.length())); | 108 | keyLineEdit3->setText(line.mid(5, line.length())); |
109 | 109 | ||
110 | if(line.contains("KEY=")){ | 110 | if(line.contains("KEY=")){ |
111 | wepEnabled->setChecked(true); | 111 | wepEnabled->setChecked(true); |
112 | QString key; | 112 | QString key; |
113 | if(line.right(5) == (" open")){ | 113 | if(line.right(5) == (" open")){ |
114 | key = line.mid(4, line.length()-5); | 114 | key = line.mid(4, line.length()-5); |
115 | authOpen->setChecked(true); | 115 | authOpen->setChecked(true); |
116 | authShared->setChecked(false); | 116 | authShared->setChecked(false); |
117 | } | 117 | } |
118 | else{ | 118 | else{ |
119 | authOpen->setChecked(false); | 119 | authOpen->setChecked(false); |
120 | authShared->setChecked(true); | 120 | authShared->setChecked(true); |
121 | key = line.mid(4, line.length()); | 121 | key = line.mid(4, line.length()); |
122 | } | 122 | } |
123 | if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); | 123 | if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); |
@@ -152,83 +152,81 @@ void WLANImp::changeAndSaveSettingFile(){ | |||
152 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | 152 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { |
153 | QString line = (*it).simplifyWhiteSpace(); | 153 | QString line = (*it).simplifyWhiteSpace(); |
154 | if(line.contains("case")) | 154 | if(line.contains("case")) |
155 | foundCase = true; | 155 | foundCase = true; |
156 | // See if we found our scheme to write or the sceme couldn't be found | 156 | // See if we found our scheme to write or the sceme couldn't be found |
157 | if((foundCase && line.contains("esac") && !found) || | 157 | if((foundCase && line.contains("esac") && !found) || |
158 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ | 158 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ |
159 | // write out scheme | 159 | // write out scheme |
160 | found = true; | 160 | found = true; |
161 | output = false; | 161 | output = false; |
162 | 162 | ||
163 | if(!line.contains("esac")) | 163 | if(!line.contains("esac")) |
164 | stream << line << "\n"; | 164 | stream << line << "\n"; |
165 | if(!essAny->isChecked() == true){ | 165 | if(!essAny->isChecked() == true){ |
166 | stream << "\tESSID=any\n"; | 166 | stream << "\tESSID=any\n"; |
167 | stream << "\tMODE=Managed\n"; | 167 | stream << "\tMODE=Managed\n"; |
168 | stream << "\tCHANNEL=6\n"; | ||
169 | } | 168 | } |
170 | else{ | 169 | else{ |
171 | stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; | 170 | stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; |
172 | stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; | 171 | stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; |
173 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | 172 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; |
174 | } | 173 | } |
175 | 174 | ||
176 | stream << "\tKEY0=" << keyLineEdit0->text() << "\n"; | 175 | stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; |
177 | stream << "\tKEY1=" << keyLineEdit1->text() << "\n"; | 176 | stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; |
178 | stream << "\tKEY2=" << keyLineEdit2->text() << "\n"; | 177 | stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; |
179 | stream << "\tKEY3=" << keyLineEdit3->text() << "\n"; | 178 | stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; |
180 | 179 | ||
181 | if(wepEnabled->isChecked()){ | 180 | if(wepEnabled->isChecked()){ |
182 | stream << "\tKEY=\""; | 181 | stream << "\tKEY=\""; |
183 | if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); | 182 | if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); |
184 | if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); | 183 | if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); |
185 | if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); | 184 | if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); |
186 | if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); | 185 | if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); |
187 | if(authOpen->isChecked()) | 186 | if(authOpen->isChecked()) |
188 | stream << " open"; | 187 | stream << " open"; |
189 | else | 188 | else |
190 | stream << " restricted"; | 189 | stream << " restricted"; |
191 | stream << "\"\n"; | 190 | stream << "\"\n"; |
192 | } | 191 | } |
193 | stream << "\tRATE=auto\n"; | 192 | stream << "\tRATE=auto\n"; |
194 | if(line.contains("esac")) | 193 | if(line.contains("esac")) |
195 | stream << line << "\n"; | 194 | stream << line << "\n"; |
196 | } | 195 | } |
197 | if(line.contains(";;")) | 196 | if(line.contains(";;")) |
198 | output = true; | 197 | output = true; |
199 | if(output && (*it).length() ) | 198 | if(output && (*it).length() ) |
200 | stream << (*it) << '\n'; | 199 | stream << (*it) << '\n'; |
201 | } | 200 | } |
202 | file.close(); | 201 | file.close(); |
203 | } | 202 | } |
204 | 203 | ||
205 | /** | 204 | /** |
206 | * Check to see if the current config is valid | 205 | * Check to see if the current config is valid |
207 | * Save wireless.opts, save interfaces | 206 | * Save wireless.opts, save interfaces |
208 | */ | 207 | */ |
209 | void WLANImp::accept(){ | 208 | void WLANImp::accept(){ |
210 | if(wepEnabled->isChecked()){ | 209 | if(wepEnabled->isChecked()){ |
211 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) | 210 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ |
212 | { | 211 | QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); |
213 | QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); | 212 | return; |
214 | return; | 213 | } |
215 | } | ||
216 | } | 214 | } |
217 | 215 | ||
218 | if(essSpecificLineEdit->text().isEmpty()){ | 216 | if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){ |
219 | QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); | 217 | QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); |
220 | return; | 218 | return; |
221 | } | 219 | } |
222 | 220 | ||
223 | // Ok settings are good here, save | 221 | // Ok settings are good here, save |
224 | changeAndSaveSettingFile(); | 222 | changeAndSaveSettingFile(); |
225 | 223 | ||
226 | // Try to save the interfaces settings. | 224 | // Try to save the interfaces settings. |
227 | if(!interfaceSetup->saveChanges()) | 225 | if(!interfaceSetup->saveChanges()) |
228 | return; | 226 | return; |
229 | 227 | ||
230 | // Restart the device now that the settings have changed | 228 | // Restart the device now that the settings have changed |
231 | QString initpath; | 229 | QString initpath; |
232 | if( QDir("/etc/rc.d/init.d").exists() ) | 230 | if( QDir("/etc/rc.d/init.d").exists() ) |
233 | initpath = "/etc/rc.d/init.d"; | 231 | initpath = "/etc/rc.d/init.d"; |
234 | else if( QDir("/etc/init.d").exists() ) | 232 | else if( QDir("/etc/init.d").exists() ) |
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 84e0bae..cc18fba 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -85,39 +85,39 @@ void WLANImp::parseSettingFile(){ | |||
85 | essSpecificLineEdit->setText(id); | 85 | essSpecificLineEdit->setText(id); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | if(line.contains("MODE=")){ | 88 | if(line.contains("MODE=")){ |
89 | QString mode = line.mid(line.find("MODE=")+5, line.length()); | 89 | QString mode = line.mid(line.find("MODE=")+5, line.length()); |
90 | if(mode == "Managed"){ | 90 | if(mode == "Managed"){ |
91 | networkType->setCurrentItem(0); | 91 | networkType->setCurrentItem(0); |
92 | channelLabel->setEnabled(false); | 92 | channelLabel->setEnabled(false); |
93 | networkChannel->setEnabled(false); | 93 | networkChannel->setEnabled(false); |
94 | } | 94 | } |
95 | else{ | 95 | else{ |
96 | networkType->setCurrentItem(1); | 96 | networkType->setCurrentItem(1); |
97 | networkChannel->setEnabled(true); | 97 | networkChannel->setEnabled(true); |
98 | channelLabel->setEnabled(true); | 98 | channelLabel->setEnabled(true); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | if(line.contains("KEY0=")) | 101 | if(line.contains("#KEY0=")) |
102 | keyLineEdit0->setText(line.mid(5, line.length())); | 102 | keyLineEdit0->setText(line.mid(5, line.length())); |
103 | if(line.contains("KEY1=")) | 103 | if(line.contains("#KEY1=")) |
104 | keyLineEdit1->setText(line.mid(5, line.length())); | 104 | keyLineEdit1->setText(line.mid(5, line.length())); |
105 | if(line.contains("KEY2=")) | 105 | if(line.contains("#KEY2=")) |
106 | keyLineEdit2->setText(line.mid(5, line.length())); | 106 | keyLineEdit2->setText(line.mid(5, line.length())); |
107 | if(line.contains("KEY3=")) | 107 | if(line.contains("#KEY3=")) |
108 | keyLineEdit3->setText(line.mid(5, line.length())); | 108 | keyLineEdit3->setText(line.mid(5, line.length())); |
109 | 109 | ||
110 | if(line.contains("KEY=")){ | 110 | if(line.contains("KEY=")){ |
111 | wepEnabled->setChecked(true); | 111 | wepEnabled->setChecked(true); |
112 | QString key; | 112 | QString key; |
113 | if(line.right(5) == (" open")){ | 113 | if(line.right(5) == (" open")){ |
114 | key = line.mid(4, line.length()-5); | 114 | key = line.mid(4, line.length()-5); |
115 | authOpen->setChecked(true); | 115 | authOpen->setChecked(true); |
116 | authShared->setChecked(false); | 116 | authShared->setChecked(false); |
117 | } | 117 | } |
118 | else{ | 118 | else{ |
119 | authOpen->setChecked(false); | 119 | authOpen->setChecked(false); |
120 | authShared->setChecked(true); | 120 | authShared->setChecked(true); |
121 | key = line.mid(4, line.length()); | 121 | key = line.mid(4, line.length()); |
122 | } | 122 | } |
123 | if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); | 123 | if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); |
@@ -152,83 +152,81 @@ void WLANImp::changeAndSaveSettingFile(){ | |||
152 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | 152 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { |
153 | QString line = (*it).simplifyWhiteSpace(); | 153 | QString line = (*it).simplifyWhiteSpace(); |
154 | if(line.contains("case")) | 154 | if(line.contains("case")) |
155 | foundCase = true; | 155 | foundCase = true; |
156 | // See if we found our scheme to write or the sceme couldn't be found | 156 | // See if we found our scheme to write or the sceme couldn't be found |
157 | if((foundCase && line.contains("esac") && !found) || | 157 | if((foundCase && line.contains("esac") && !found) || |
158 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ | 158 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ |
159 | // write out scheme | 159 | // write out scheme |
160 | found = true; | 160 | found = true; |
161 | output = false; | 161 | output = false; |
162 | 162 | ||
163 | if(!line.contains("esac")) | 163 | if(!line.contains("esac")) |
164 | stream << line << "\n"; | 164 | stream << line << "\n"; |
165 | if(!essAny->isChecked() == true){ | 165 | if(!essAny->isChecked() == true){ |
166 | stream << "\tESSID=any\n"; | 166 | stream << "\tESSID=any\n"; |
167 | stream << "\tMODE=Managed\n"; | 167 | stream << "\tMODE=Managed\n"; |
168 | stream << "\tCHANNEL=6\n"; | ||
169 | } | 168 | } |
170 | else{ | 169 | else{ |
171 | stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; | 170 | stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; |
172 | stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; | 171 | stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; |
173 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | 172 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; |
174 | } | 173 | } |
175 | 174 | ||
176 | stream << "\tKEY0=" << keyLineEdit0->text() << "\n"; | 175 | stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; |
177 | stream << "\tKEY1=" << keyLineEdit1->text() << "\n"; | 176 | stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; |
178 | stream << "\tKEY2=" << keyLineEdit2->text() << "\n"; | 177 | stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; |
179 | stream << "\tKEY3=" << keyLineEdit3->text() << "\n"; | 178 | stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; |
180 | 179 | ||
181 | if(wepEnabled->isChecked()){ | 180 | if(wepEnabled->isChecked()){ |
182 | stream << "\tKEY=\""; | 181 | stream << "\tKEY=\""; |
183 | if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); | 182 | if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); |
184 | if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); | 183 | if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); |
185 | if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); | 184 | if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); |
186 | if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); | 185 | if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); |
187 | if(authOpen->isChecked()) | 186 | if(authOpen->isChecked()) |
188 | stream << " open"; | 187 | stream << " open"; |
189 | else | 188 | else |
190 | stream << " restricted"; | 189 | stream << " restricted"; |
191 | stream << "\"\n"; | 190 | stream << "\"\n"; |
192 | } | 191 | } |
193 | stream << "\tRATE=auto\n"; | 192 | stream << "\tRATE=auto\n"; |
194 | if(line.contains("esac")) | 193 | if(line.contains("esac")) |
195 | stream << line << "\n"; | 194 | stream << line << "\n"; |
196 | } | 195 | } |
197 | if(line.contains(";;")) | 196 | if(line.contains(";;")) |
198 | output = true; | 197 | output = true; |
199 | if(output && (*it).length() ) | 198 | if(output && (*it).length() ) |
200 | stream << (*it) << '\n'; | 199 | stream << (*it) << '\n'; |
201 | } | 200 | } |
202 | file.close(); | 201 | file.close(); |
203 | } | 202 | } |
204 | 203 | ||
205 | /** | 204 | /** |
206 | * Check to see if the current config is valid | 205 | * Check to see if the current config is valid |
207 | * Save wireless.opts, save interfaces | 206 | * Save wireless.opts, save interfaces |
208 | */ | 207 | */ |
209 | void WLANImp::accept(){ | 208 | void WLANImp::accept(){ |
210 | if(wepEnabled->isChecked()){ | 209 | if(wepEnabled->isChecked()){ |
211 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) | 210 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ |
212 | { | 211 | QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); |
213 | QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); | 212 | return; |
214 | return; | 213 | } |
215 | } | ||
216 | } | 214 | } |
217 | 215 | ||
218 | if(essSpecificLineEdit->text().isEmpty()){ | 216 | if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){ |
219 | QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); | 217 | QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); |
220 | return; | 218 | return; |
221 | } | 219 | } |
222 | 220 | ||
223 | // Ok settings are good here, save | 221 | // Ok settings are good here, save |
224 | changeAndSaveSettingFile(); | 222 | changeAndSaveSettingFile(); |
225 | 223 | ||
226 | // Try to save the interfaces settings. | 224 | // Try to save the interfaces settings. |
227 | if(!interfaceSetup->saveChanges()) | 225 | if(!interfaceSetup->saveChanges()) |
228 | return; | 226 | return; |
229 | 227 | ||
230 | // Restart the device now that the settings have changed | 228 | // Restart the device now that the settings have changed |
231 | QString initpath; | 229 | QString initpath; |
232 | if( QDir("/etc/rc.d/init.d").exists() ) | 230 | if( QDir("/etc/rc.d/init.d").exists() ) |
233 | initpath = "/etc/rc.d/init.d"; | 231 | initpath = "/etc/rc.d/init.d"; |
234 | else if( QDir("/etc/init.d").exists() ) | 232 | else if( QDir("/etc/init.d").exists() ) |