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
@@ -203,119 +203,97 @@
203 <height>20</height> 203 <height>20</height>
204 </size> 204 </size>
205 </property> 205 </property>
206 </spacer> 206 </spacer>
207 <widget row="5" column="1" > 207 <widget row="5" column="1" >
208 <class>QProgressBar</class> 208 <class>QProgressBar</class>
209 <property stdset="1"> 209 <property stdset="1">
210 <name>name</name> 210 <name>name</name>
211 <cstring>signalProgressBar</cstring> 211 <cstring>signalProgressBar</cstring>
212 </property> 212 </property>
213 </widget> 213 </widget>
214 <widget row="6" column="1" > 214 <widget row="6" column="1" >
215 <class>QProgressBar</class> 215 <class>QProgressBar</class>
216 <property stdset="1"> 216 <property stdset="1">
217 <name>name</name> 217 <name>name</name>
218 <cstring>noiseProgressBar</cstring> 218 <cstring>noiseProgressBar</cstring>
219 </property> 219 </property>
220 </widget> 220 </widget>
221 <widget row="7" column="1" > 221 <widget row="7" column="1" >
222 <class>QProgressBar</class> 222 <class>QProgressBar</class>
223 <property stdset="1"> 223 <property stdset="1">
224 <name>name</name> 224 <name>name</name>
225 <cstring>qualityProgressBar</cstring> 225 <cstring>qualityProgressBar</cstring>
226 </property> 226 </property>
227 </widget> 227 </widget>
228 <widget row="8" column="1" > 228 <widget row="8" column="1" >
229 <class>QLabel</class> 229 <class>QLabel</class>
230 <property stdset="1"> 230 <property stdset="1">
231 <name>name</name> 231 <name>name</name>
232 <cstring>rateLabel</cstring> 232 <cstring>rateLabel</cstring>
233 </property> 233 </property>
234 <property stdset="1"> 234 <property stdset="1">
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,114 +1,117 @@
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"){
83 essAny->setChecked(false); 86 essAny->setChecked(false);
84 }else{ 87 }else{
85 essAny->setChecked(true); 88 essAny->setChecked(true);
86 essSpecificLineEdit->setText(id); 89 essSpecificLineEdit->setText(id);
87 } 90 }
88 } 91 }
89 if(line.contains("MODE=")){ 92 if(line.contains("MODE=")){
90 QString mode = line.mid(line.find("MODE=")+5, line.length()); 93 QString mode = line.mid(line.find("MODE=")+5, line.length());
91 if(mode == "Managed"){ 94 if(mode == "Managed"){
92 networkType->setCurrentItem(0); 95 networkType->setCurrentItem(0);
93 channelLabel->setEnabled(false); 96 channelLabel->setEnabled(false);
94 networkChannel->setEnabled(false); 97 networkChannel->setEnabled(false);
95 } 98 }
96 else{ 99 else{
97 networkType->setCurrentItem(1); 100 networkType->setCurrentItem(1);
98 networkChannel->setEnabled(true); 101 networkChannel->setEnabled(true);
99 channelLabel->setEnabled(true); 102 channelLabel->setEnabled(true);
100 } 103 }
101 } 104 }
102 if(line.contains("#KEY0=")) 105 if(line.contains("#KEY0="))
103 keyLineEdit0->setText(line.mid(6, line.length())); 106 keyLineEdit0->setText(line.mid(6, line.length()));
104 if(line.contains("#KEY1=")) 107 if(line.contains("#KEY1="))
105 keyLineEdit1->setText(line.mid(6, line.length())); 108 keyLineEdit1->setText(line.mid(6, line.length()));
106 if(line.contains("#KEY2=")) 109 if(line.contains("#KEY2="))
107 keyLineEdit2->setText(line.mid(6, line.length())); 110 keyLineEdit2->setText(line.mid(6, line.length()));
108 if(line.contains("#KEY3=")) 111 if(line.contains("#KEY3="))
109 keyLineEdit3->setText(line.mid(6, line.length())); 112 keyLineEdit3->setText(line.mid(6, line.length()));
110 113
111 if(line.contains("KEY=")){ 114 if(line.contains("KEY=")){
112 wepEnabled->setChecked(true); 115 wepEnabled->setChecked(true);
113 QString key; 116 QString key;
114 if(line.right(5) == (" open")){ 117 if(line.right(5) == (" open")){
@@ -133,110 +136,109 @@ void WLANImp::parseSettingFile(){
133 } 136 }
134} 137}
135 138
136/** 139/**
137 * Saves settings to the wireless.opts file using the current profile 140 * Saves settings to the wireless.opts file using the current profile
138 */ 141 */
139void WLANImp::changeAndSaveSettingFile(){ 142void WLANImp::changeAndSaveSettingFile(){
140 QString wlanFile = WIRELESS_OPTS; 143 QString wlanFile = WIRELESS_OPTS;
141 QFile::remove(wlanFile); 144 QFile::remove(wlanFile);
142 QFile file(wlanFile); 145 QFile file(wlanFile);
143 146
144 if (!file.open(IO_ReadWrite)){ 147 if (!file.open(IO_ReadWrite)){
145 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 148 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1());
146 return; 149 return;
147 } 150 }
148 151
149 QTextStream stream( &file ); 152 QTextStream stream( &file );
150 bool foundCase = false; 153 bool foundCase = false;
151 bool found = false; 154 bool found = false;
152 bool output = true; 155 bool output = true;
153 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 156 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
154 QString line = (*it).simplifyWhiteSpace(); 157 QString line = (*it).simplifyWhiteSpace();
155 if(line.contains("case")) 158 if(line.contains("case"))
156 foundCase = true; 159 foundCase = true;
157 // See if we found our scheme to write or the sceme couldn't be found 160 // See if we found our scheme to write or the sceme couldn't be found
158 if((foundCase && line.contains("esac") && !found) || 161 if((foundCase && line.contains("esac") && !found) ||
159 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ 162 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){
160 // write out scheme 163 // write out scheme
161 found = true; 164 found = true;
162 output = false; 165 output = false;
163 166
164 if(!line.contains("esac")) 167 if(!line.contains("esac"))
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