author | benmeyer <benmeyer> | 2002-12-11 22:08:02 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-12-11 22:08:02 (UTC) |
commit | 6523ee46d49203d11f34a3dbbf966a318cef7def (patch) (unidiff) | |
tree | 2a51a44e1fb114c3f4d8f3965d5106c8930fba16 /noncore/net/networksetup/wlan/wlanimp.cpp | |
parent | c5737bbbe357ea7481a9f6a406ef81bbeba0d541 (diff) | |
download | opie-6523ee46d49203d11f34a3dbbf966a318cef7def.zip opie-6523ee46d49203d11f34a3dbbf966a318cef7def.tar.gz opie-6523ee46d49203d11f34a3dbbf966a318cef7def.tar.bz2 |
New cleaner layout
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 | |||
@@ -3,16 +3,18 @@ | |||
3 | 3 | ||
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
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> |
16 | 18 | ||
17 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 19 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
18 | 20 | ||
@@ -36,12 +38,19 @@ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, W | |||
36 | file.close(); | 38 | file.close(); |
37 | settingsFileText = QStringList::split("\n", line, true); | 39 | settingsFileText = QStringList::split("\n", line, true); |
38 | parseSettingFile(); | 40 | parseSettingFile(); |
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 | /** |
45 | * Change the profile for both wireless settings and network settings. | 54 | * Change the profile for both wireless settings and network settings. |
46 | */ | 55 | */ |
47 | void WLANImp::setProfile(const QString &profile){ | 56 | void WLANImp::setProfile(const QString &profile){ |
@@ -68,29 +77,25 @@ void WLANImp::parseSettingFile(){ | |||
68 | found = false; | 77 | found = false; |
69 | if(found){ | 78 | if(found){ |
70 | // write out scheme | 79 | // write out scheme |
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=")) |
94 | keyLineEdit0->setText(line.mid(5, line.length())); | 99 | keyLineEdit0->setText(line.mid(5, line.length())); |
95 | if(line.contains("KEY1=")) | 100 | if(line.contains("KEY1=")) |
96 | keyLineEdit1->setText(line.mid(5, line.length())); | 101 | keyLineEdit1->setText(line.mid(5, line.length())); |
@@ -151,15 +156,22 @@ void WLANImp::changeAndSaveSettingFile(){ | |||
151 | // write out scheme | 156 | // write out scheme |
152 | found = true; | 157 | found = true; |
153 | output = false; | 158 | output = false; |
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"; |
163 | stream << "\tKEY2=" << keyLineEdit2->text() << "\n"; | 175 | stream << "\tKEY2=" << keyLineEdit2->text() << "\n"; |
164 | stream << "\tKEY3=" << keyLineEdit3->text() << "\n"; | 176 | stream << "\tKEY3=" << keyLineEdit3->text() << "\n"; |
165 | 177 | ||
@@ -172,13 +184,12 @@ void WLANImp::changeAndSaveSettingFile(){ | |||
172 | if(authOpen->isChecked()) | 184 | if(authOpen->isChecked()) |
173 | stream << " open"; | 185 | stream << " open"; |
174 | else | 186 | else |
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"; |
182 | } | 193 | } |
183 | if(line.contains(";;")) | 194 | if(line.contains(";;")) |
184 | output = true; | 195 | output = true; |
@@ -193,24 +204,30 @@ void WLANImp::changeAndSaveSettingFile(){ | |||
193 | * Save wireless.opts, save interfaces | 204 | * Save wireless.opts, save interfaces |
194 | */ | 205 | */ |
195 | void WLANImp::accept(){ | 206 | 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 | ||
207 | // Try to save the interfaces settings. | 223 | // Try to save the interfaces settings. |
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() ) |
214 | initpath = "/etc/rc.d/init.d"; | 231 | initpath = "/etc/rc.d/init.d"; |
215 | else if( QDir("/etc/init.d").exists() ) | 232 | else if( QDir("/etc/init.d").exists() ) |
216 | initpath = "/etc/init.d"; | 233 | initpath = "/etc/init.d"; |