Diffstat (limited to 'noncore/net/networksetup/wlan/wlanimp.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 6a56358..ef7329e 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -6,10 +6,12 @@ | |||
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qlabel.h> | ||
9 | #include <qspinbox.h> | 10 | #include <qspinbox.h> |
10 | #include <qradiobutton.h> | 11 | #include <qradiobutton.h> |
11 | #include <qcheckbox.h> | 12 | #include <qcheckbox.h> |
12 | #include <qtabwidget.h> | 13 | #include <qtabwidget.h> |
14 | #include <qcombobox.h> | ||
13 | 15 | ||
14 | /* system() */ | 16 | /* system() */ |
15 | #include <stdlib.h> | 17 | #include <stdlib.h> |
@@ -39,6 +41,13 @@ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, W | |||
39 | } | 41 | } |
40 | else | 42 | else |
41 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); | 43 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); |
44 | connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); | ||
45 | |||
46 | } | ||
47 | |||
48 | void WLANImp::typeChanged(int mod){ | ||
49 | networkChannel->setEnabled(mod); | ||
50 | channelLabel->setEnabled(mod); | ||
42 | } | 51 | } |
43 | 52 | ||
44 | /** | 53 | /** |
@@ -71,23 +80,19 @@ void WLANImp::parseSettingFile(){ | |||
71 | if(line.contains("ESSID=")){ | 80 | if(line.contains("ESSID=")){ |
72 | QString id = line.mid(line.find("ESSID=")+6, line.length()); | 81 | QString id = line.mid(line.find("ESSID=")+6, line.length()); |
73 | if(id == "any"){ | 82 | if(id == "any"){ |
74 | essNon->setChecked(true); | 83 | essAny->setChecked(false); |
75 | essSpecific->setChecked(false); | ||
76 | }else{ | 84 | }else{ |
77 | essSpecific->setChecked(true); | 85 | essAny->setChecked(true); |
78 | essSpecificLineEdit->setText(id); | 86 | essSpecificLineEdit->setText(id); |
79 | essNon->setChecked(false); | ||
80 | } | 87 | } |
81 | } | 88 | } |
82 | if(line.contains("MODE=")){ | 89 | if(line.contains("MODE=")){ |
83 | QString mode = line.mid(line.find("MODE=")+5, line.length()); | 90 | QString mode = line.mid(line.find("MODE=")+5, line.length()); |
84 | if(mode == "Managed"){ | 91 | if(mode == "Managed"){ |
85 | network802->setChecked( false ); | 92 | networkType->setCurrentItem(0); |
86 | networkInfrastructure->setChecked( true ); | ||
87 | } | 93 | } |
88 | else{ | 94 | else{ |
89 | network802->setChecked( true ); | 95 | networkType->setCurrentItem(0); |
90 | networkInfrastructure->setChecked( false ); | ||
91 | } | 96 | } |
92 | } | 97 | } |
93 | if(line.contains("KEY0=")) | 98 | if(line.contains("KEY0=")) |
@@ -154,9 +159,16 @@ void WLANImp::changeAndSaveSettingFile(){ | |||
154 | 159 | ||
155 | if(!line.contains("esac")) | 160 | if(!line.contains("esac")) |
156 | stream << line << "\n"; | 161 | stream << line << "\n"; |
157 | 162 | if(!essAny->isChecked() == true){ | |
158 | stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; | 163 | stream << "\tESSID=any\n"; |
159 | stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "ad-hoc") << '\n'; | 164 | stream << "\tMODE=Managed\n"; |
165 | stream << "\tCHANNEL=6\n"; | ||
166 | } | ||
167 | else{ | ||
168 | stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; | ||
169 | stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; | ||
170 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | ||
171 | } | ||
160 | 172 | ||
161 | stream << "\tKEY0=" << keyLineEdit0->text() << "\n"; | 173 | stream << "\tKEY0=" << keyLineEdit0->text() << "\n"; |
162 | stream << "\tKEY1=" << keyLineEdit1->text() << "\n"; | 174 | stream << "\tKEY1=" << keyLineEdit1->text() << "\n"; |
@@ -175,7 +187,6 @@ void WLANImp::changeAndSaveSettingFile(){ | |||
175 | stream << " restricted"; | 187 | stream << " restricted"; |
176 | stream << "\"\n"; | 188 | stream << "\"\n"; |
177 | } | 189 | } |
178 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | ||
179 | stream << "\tRATE=auto\n"; | 190 | stream << "\tRATE=auto\n"; |
180 | if(line.contains("esac")) | 191 | if(line.contains("esac")) |
181 | stream << line << "\n"; | 192 | stream << line << "\n"; |
@@ -196,11 +207,16 @@ void WLANImp::accept(){ | |||
196 | if(wepEnabled->isChecked()){ | 207 | if(wepEnabled->isChecked()){ |
197 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) | 208 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) |
198 | { | 209 | { |
199 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); | 210 | QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); |
200 | return; | 211 | return; |
201 | } | 212 | } |
202 | } | 213 | } |
203 | 214 | ||
215 | if(essSpecificLineEdit->text().isEmpty()){ | ||
216 | QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); | ||
217 | return; | ||
218 | } | ||
219 | |||
204 | // Ok settings are good here, save | 220 | // Ok settings are good here, save |
205 | changeAndSaveSettingFile(); | 221 | changeAndSaveSettingFile(); |
206 | 222 | ||
@@ -208,6 +224,7 @@ void WLANImp::accept(){ | |||
208 | if(!interfaceSetup->saveChanges()) | 224 | if(!interfaceSetup->saveChanges()) |
209 | return; | 225 | return; |
210 | 226 | ||
227 | return; | ||
211 | // Restart the device now that the settings have changed | 228 | // Restart the device now that the settings have changed |
212 | QString initpath; | 229 | QString initpath; |
213 | if( QDir("/etc/rc.d/init.d").exists() ) | 230 | if( QDir("/etc/rc.d/init.d").exists() ) |