summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/info.ui22
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp14
2 files changed, 8 insertions, 28 deletions
diff --git a/noncore/settings/networksettings/wlan/info.ui b/noncore/settings/networksettings/wlan/info.ui
index 7a5bf0b..50ee540 100644
--- a/noncore/settings/networksettings/wlan/info.ui
+++ b/noncore/settings/networksettings/wlan/info.ui
@@ -235,87 +235,65 @@
235 <name>sizePolicy</name> 235 <name>sizePolicy</name>
236 <sizepolicy> 236 <sizepolicy>
237 <hsizetype>7</hsizetype> 237 <hsizetype>7</hsizetype>
238 <vsizetype>1</vsizetype> 238 <vsizetype>1</vsizetype>
239 </sizepolicy> 239 </sizepolicy>
240 </property> 240 </property>
241 <property stdset="1"> 241 <property stdset="1">
242 <name>frameShape</name> 242 <name>frameShape</name>
243 <enum>Panel</enum> 243 <enum>Panel</enum>
244 </property> 244 </property>
245 <property stdset="1"> 245 <property stdset="1">
246 <name>frameShadow</name> 246 <name>frameShadow</name>
247 <enum>Sunken</enum> 247 <enum>Sunken</enum>
248 </property> 248 </property>
249 </widget> 249 </widget>
250 <widget row="8" column="0" > 250 <widget row="8" column="0" >
251 <class>QLabel</class> 251 <class>QLabel</class>
252 <property stdset="1"> 252 <property stdset="1">
253 <name>name</name> 253 <name>name</name>
254 <cstring>TextLabel4_2</cstring> 254 <cstring>TextLabel4_2</cstring>
255 </property> 255 </property>
256 <property stdset="1"> 256 <property stdset="1">
257 <name>text</name> 257 <name>text</name>
258 <string>Rate</string> 258 <string>Rate</string>
259 </property> 259 </property>
260 </widget> 260 </widget>
261 <widget row="7" column="0" > 261 <widget row="7" column="0" >
262 <class>QLabel</class> 262 <class>QLabel</class>
263 <property stdset="1"> 263 <property stdset="1">
264 <name>name</name> 264 <name>name</name>
265 <cstring>TextLabel3_2</cstring> 265 <cstring>TextLabel3_2</cstring>
266 </property> 266 </property>
267 <property stdset="1"> 267 <property stdset="1">
268 <name>text</name> 268 <name>text</name>
269 <string>Quality</string> 269 <string>Quality</string>
270 </property> 270 </property>
271 </widget> 271 </widget>
272 <widget row="6" column="0" > 272 <widget row="6" column="0" >
273 <class>QLabel</class> 273 <class>QLabel</class>
274 <property stdset="1"> 274 <property stdset="1">
275 <name>name</name> 275 <name>name</name>
276 <cstring>TextLabel2_2</cstring> 276 <cstring>TextLabel2_2</cstring>
277 </property> 277 </property>
278 <property stdset="1"> 278 <property stdset="1">
279 <name>text</name> 279 <name>text</name>
280 <string>Noise</string> 280 <string>Noise</string>
281 </property> 281 </property>
282 </widget> 282 </widget>
283 <widget row="5" column="0" > 283 <widget row="5" column="0" >
284 <class>QLabel</class> 284 <class>QLabel</class>
285 <property stdset="1"> 285 <property stdset="1">
286 <name>name</name> 286 <name>name</name>
287 <cstring>TextLabel1_2</cstring> 287 <cstring>TextLabel1_2</cstring>
288 </property> 288 </property>
289 <property stdset="1"> 289 <property stdset="1">
290 <name>text</name> 290 <name>text</name>
291 <string>Signal</string> 291 <string>Signal</string>
292 </property> 292 </property>
293 </widget> 293 </widget>
294 </grid> 294 </grid>
295 </widget> 295 </widget>
296 </widget> 296 </widget>
297 </vbox> 297 </vbox>
298</widget> 298</widget>
299<customwidgets>
300 <customwidget>
301 <class>QWidget</class>
302 <header location="local">qwidget.h</header>
303 <sizehint>
304 <width>100</width>
305 <height>100</height>
306 </sizehint>
307 <container>0</container>
308 <sizepolicy>
309 <hordata>7</hordata>
310 <verdata>7</verdata>
311 </sizepolicy>
312 <pixmap>image0</pixmap>
313 </customwidget>
314</customwidgets>
315<images>
316 <image>
317 <name>image0</name>
318 <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
319 </image>
320</images>
321</UI> 299</UI>
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 3797e22..57266bb 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -1,82 +1,85 @@
1#include "wlanimp.h" 1#include "wlanimp.h"
2#include "interfacesetupimp.h" 2#include "interfacesetupimp.h"
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 <qlabel.h>
10#include <qspinbox.h> 10#include <qspinbox.h>
11#include <qradiobutton.h> 11#include <qradiobutton.h>
12#include <qcheckbox.h> 12#include <qcheckbox.h>
13#include <qtabwidget.h> 13#include <qtabwidget.h>
14#include <qcombobox.h> 14#include <qcombobox.h>
15 15
16/* system() */ 16#ifdef QTE_VERSION
17//#include <stdlib.h> 17 #include <opie/oprocess.h>
18#include <opie/oprocess.h> 18#else
19 #define OProcess KProcess
20 #include <kprocess.h>
21#endif
19 22
20#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 23#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
21 24
22/** 25/**
23 * Constructor, read in the wireless.opts file for parsing later. 26 * Constructor, read in the wireless.opts file for parsing later.
24 */ 27 */
25WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { 28WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") {
26 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); 29 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);
27 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 30 tabWidget->insertTab(interfaceSetup, "TCP/IP");
28 31
29 // Read in the config file. 32 // Read in the config file.
30 QString wlanFile = WIRELESS_OPTS; 33 QString wlanFile = WIRELESS_OPTS;
31 QFile file(wlanFile); 34 QFile file(wlanFile);
32 if (file.open(IO_ReadOnly)){ 35 if (file.open(IO_ReadOnly)){
33 QTextStream stream( &file ); 36 QTextStream stream( &file );
34 QString line = ""; 37 QString line = "";
35 while ( !stream.eof() ) { 38 while ( !stream.eof() ) {
36 line += stream.readLine(); 39 line += stream.readLine();
37 line += "\n"; 40 line += "\n";
38 } 41 }
39 file.close(); 42 file.close();
40 settingsFileText = QStringList::split("\n", line, true); 43 settingsFileText = QStringList::split("\n", line, true);
41 parseSettingFile(); 44 parseSettingFile();
42 } 45 }
43 else 46 else
44 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); 47 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1());
45 connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); 48 connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
46} 49}
47 50
48void WLANImp::typeChanged(int mod){ 51void WLANImp::typeChanged(int mod){
49 networkChannel->setEnabled(mod); 52 networkChannel->setEnabled(mod);
50 channelLabel->setEnabled(mod); 53 channelLabel->setEnabled(mod);
51} 54}
52 55
53/** 56/**
54 * Change the profile for both wireless settings and network settings. 57 * Change the profile for both wireless settings and network settings.
55 */ 58 */
56void WLANImp::setProfile(const QString &profile){ 59void WLANImp::setProfile(const QString &profile){
57 interfaceSetup->setProfile(profile); 60 interfaceSetup->setProfile(profile);
58 parseSettingFile(); 61 parseSettingFile();
59} 62}
60 63
61/** 64/**
62 * Parses the settings file that was read in and gets any setting from it. 65 * Parses the settings file that was read in and gets any setting from it.
63 */ 66 */
64void WLANImp::parseSettingFile(){ 67void WLANImp::parseSettingFile(){
65 bool foundCase = false; 68 bool foundCase = false;
66 bool found = false; 69 bool found = false;
67 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 70 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
68 QString line = (*it).simplifyWhiteSpace(); 71 QString line = (*it).simplifyWhiteSpace();
69 if(line.contains("case")) 72 if(line.contains("case"))
70 foundCase = true; 73 foundCase = true;
71 // See if we found our scheme to write or the sceme couldn't be found 74 // See if we found our scheme to write or the sceme couldn't be found
72 if((foundCase && line.contains("esac")) || 75 if((foundCase && line.contains("esac")) ||
73 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) 76 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#'))
74 found = true; 77 found = true;
75 78
76 if(line.contains(";;")) 79 if(line.contains(";;"))
77 found = false; 80 found = false;
78 if(found){ 81 if(found){
79 // write out scheme 82 // write out scheme
80 if(line.contains("ESSID=")){ 83 if(line.contains("ESSID=")){
81 QString id = line.mid(line.find("ESSID=")+6, line.length()); 84 QString id = line.mid(line.find("ESSID=")+6, line.length());
82 if(id == "any"){ 85 if(id == "any"){
@@ -165,78 +168,77 @@ void WLANImp::changeAndSaveSettingFile(){
165 stream << line << "\n"; 168 stream << line << "\n";
166 if(!essAny->isChecked() == true){ 169 if(!essAny->isChecked() == true){
167 stream << "\tESSID=any\n"; 170 stream << "\tESSID=any\n";
168 stream << "\tMODE=Managed\n"; 171 stream << "\tMODE=Managed\n";
169 } 172 }
170 else{ 173 else{
171 stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; 174 stream << "\tESSID=" << essSpecificLineEdit->text() << '\n';
172 stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; 175 stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n';
173 stream << "\tCHANNEL=" << networkChannel->value() << "\n"; 176 stream << "\tCHANNEL=" << networkChannel->value() << "\n";
174 } 177 }
175 178
176 stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; 179 stream << "\t#KEY0=" << keyLineEdit0->text() << "\n";
177 stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; 180 stream << "\t#KEY1=" << keyLineEdit1->text() << "\n";
178 stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; 181 stream << "\t#KEY2=" << keyLineEdit2->text() << "\n";
179 stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; 182 stream << "\t#KEY3=" << keyLineEdit3->text() << "\n";
180 183
181 if(wepEnabled->isChecked()){ 184 if(wepEnabled->isChecked()){
182 stream << "\tKEY=\""; 185 stream << "\tKEY=\"";
183 if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); 186 if(keyRadio0->isChecked()) stream << keyLineEdit0->text();
184 if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); 187 if(keyRadio1->isChecked()) stream << keyLineEdit1->text();
185 if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); 188 if(keyRadio2->isChecked()) stream << keyLineEdit2->text();
186 if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); 189 if(keyRadio3->isChecked()) stream << keyLineEdit3->text();
187 if(authOpen->isChecked()) 190 if(authOpen->isChecked())
188 stream << " open"; 191 stream << " open";
189 else 192 else
190 stream << " restricted"; 193 stream << " restricted";
191 stream << "\"\n"; 194 stream << "\"\n";
192 } 195 }
193 stream << "\tRATE=auto\n"; 196 stream << "\tRATE=auto\n";
194 if(line.contains("esac")) 197 if(line.contains("esac"))
195 stream << line << "\n"; 198 stream << line << "\n";
196 } 199 }
197 if(line.contains(";;")) 200 if(line.contains(";;"))
198 output = true; 201 output = true;
199 if(output && (*it).length() ) 202 if(output && (*it).length() )
200 stream << (*it) << '\n'; 203 stream << (*it) << '\n';
201 } 204 }
202 file.close(); 205 file.close();
203} 206}
204 207
205/** 208/**
206 * Check to see if the current config is valid 209 * Check to see if the current config is valid
207 * Save wireless.opts, save interfaces 210 * Save wireless.opts, save interfaces
208 */ 211 */
209void WLANImp::accept(){ 212void WLANImp::accept(){
210 if(wepEnabled->isChecked()){ 213 if(wepEnabled->isChecked()){
211 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ 214 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){
212 QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); 215 QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok);
213 return; 216 return;
214 } 217 }
215 } 218 }
216 219
217 if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){ 220 if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){
218 QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); 221 QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok);
219 return; 222 return;
220 } 223 }
221 224
222 // Ok settings are good here, save 225 // Ok settings are good here, save
223 changeAndSaveSettingFile(); 226 changeAndSaveSettingFile();
224 227
225 // Try to save the interfaces settings. 228 // Try to save the interfaces settings.
226 if(!interfaceSetup->saveChanges()) 229 if(!interfaceSetup->saveChanges())
227 return; 230 return;
228 231
229 OProcess insert(QString("sh")); 232 OProcess insert;
233 insert << "sh";
230 insert << "-c"; 234 insert << "-c";
231 insert << "cardctl eject && cardctl insert"; 235 insert << "cardctl eject && cardctl insert";
232 236
233 if (!insert.start(OProcess::DontCare, OProcess::NoCommunication) ) { 237 if (!insert.start(OProcess::DontCare, OProcess::NoCommunication) ) {
234 qWarning("could not start cardctl"); 238 qWarning("could not start cardctl");
235 } 239 }
236 240
237 // Close out the dialog 241 // Close out the dialog
238 QDialog::accept(); 242 QDialog::accept();
239} 243}
240 244
241// wlanimp.cpp
242