summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.cpp28
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp28
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
@@ -53,194 +53,192 @@ void WLANImp::typeChanged(int mod){
53 * Change the profile for both wireless settings and network settings. 53 * Change the profile for both wireless settings and network settings.
54 */ 54 */
55void WLANImp::setProfile(const QString &profile){ 55void WLANImp::setProfile(const QString &profile){
56 interfaceSetup->setProfile(profile); 56 interfaceSetup->setProfile(profile);
57 parseSettingFile(); 57 parseSettingFile();
58} 58}
59 59
60/** 60/**
61 * Parses the settings file that was read in and gets any setting from it. 61 * Parses the settings file that was read in and gets any setting from it.
62 */ 62 */
63void WLANImp::parseSettingFile(){ 63void WLANImp::parseSettingFile(){
64 bool foundCase = false; 64 bool foundCase = false;
65 bool found = false; 65 bool found = false;
66 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 66 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
67 QString line = (*it).simplifyWhiteSpace(); 67 QString line = (*it).simplifyWhiteSpace();
68 if(line.contains("case")) 68 if(line.contains("case"))
69 foundCase = true; 69 foundCase = true;
70 // See if we found our scheme to write or the sceme couldn't be found 70 // See if we found our scheme to write or the sceme couldn't be found
71 if((foundCase && line.contains("esac")) || 71 if((foundCase && line.contains("esac")) ||
72 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) 72 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#'))
73 found = true; 73 found = true;
74 74
75 if(line.contains(";;")) 75 if(line.contains(";;"))
76 found = false; 76 found = false;
77 if(found){ 77 if(found){
78 // write out scheme 78 // write out scheme
79 if(line.contains("ESSID=")){ 79 if(line.contains("ESSID=")){
80 QString id = line.mid(line.find("ESSID=")+6, line.length()); 80 QString id = line.mid(line.find("ESSID=")+6, line.length());
81 if(id == "any"){ 81 if(id == "any"){
82 essAny->setChecked(false); 82 essAny->setChecked(false);
83 }else{ 83 }else{
84 essAny->setChecked(true); 84 essAny->setChecked(true);
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);
124 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); 124 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true);
125 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); 125 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true);
126 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); 126 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true);
127 } 127 }
128 if(line.contains("CHANNEL=")){ 128 if(line.contains("CHANNEL=")){
129 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); 129 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt());
130 } 130 }
131 } 131 }
132 } 132 }
133} 133}
134 134
135/** 135/**
136 * Saves settings to the wireless.opts file using the current profile 136 * Saves settings to the wireless.opts file using the current profile
137 */ 137 */
138void WLANImp::changeAndSaveSettingFile(){ 138void WLANImp::changeAndSaveSettingFile(){
139 QString wlanFile = WIRELESS_OPTS; 139 QString wlanFile = WIRELESS_OPTS;
140 QFile::remove(wlanFile); 140 QFile::remove(wlanFile);
141 QFile file(wlanFile); 141 QFile file(wlanFile);
142 142
143 if (!file.open(IO_ReadWrite)){ 143 if (!file.open(IO_ReadWrite)){
144 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 144 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1());
145 return; 145 return;
146 } 146 }
147 147
148 QTextStream stream( &file ); 148 QTextStream stream( &file );
149 bool foundCase = false; 149 bool foundCase = false;
150 bool found = false; 150 bool found = false;
151 bool output = true; 151 bool output = true;
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 */
209void WLANImp::accept(){ 208void 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() )
235 initpath = "/etc/init.d"; 233 initpath = "/etc/init.d";
236 if( initpath ) 234 if( initpath )
237 system(QString("%1/pcmcia stop").arg(initpath)); 235 system(QString("%1/pcmcia stop").arg(initpath));
238 if( initpath ) 236 if( initpath )
239 system(QString("%1/pcmcia start").arg(initpath)); 237 system(QString("%1/pcmcia start").arg(initpath));
240 238
241 // Close out the dialog 239 // Close out the dialog
242 QDialog::accept(); 240 QDialog::accept();
243} 241}
244 242
245// wlanimp.cpp 243// wlanimp.cpp
246 244
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
@@ -53,194 +53,192 @@ void WLANImp::typeChanged(int mod){
53 * Change the profile for both wireless settings and network settings. 53 * Change the profile for both wireless settings and network settings.
54 */ 54 */
55void WLANImp::setProfile(const QString &profile){ 55void WLANImp::setProfile(const QString &profile){
56 interfaceSetup->setProfile(profile); 56 interfaceSetup->setProfile(profile);
57 parseSettingFile(); 57 parseSettingFile();
58} 58}
59 59
60/** 60/**
61 * Parses the settings file that was read in and gets any setting from it. 61 * Parses the settings file that was read in and gets any setting from it.
62 */ 62 */
63void WLANImp::parseSettingFile(){ 63void WLANImp::parseSettingFile(){
64 bool foundCase = false; 64 bool foundCase = false;
65 bool found = false; 65 bool found = false;
66 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 66 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
67 QString line = (*it).simplifyWhiteSpace(); 67 QString line = (*it).simplifyWhiteSpace();
68 if(line.contains("case")) 68 if(line.contains("case"))
69 foundCase = true; 69 foundCase = true;
70 // See if we found our scheme to write or the sceme couldn't be found 70 // See if we found our scheme to write or the sceme couldn't be found
71 if((foundCase && line.contains("esac")) || 71 if((foundCase && line.contains("esac")) ||
72 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) 72 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#'))
73 found = true; 73 found = true;
74 74
75 if(line.contains(";;")) 75 if(line.contains(";;"))
76 found = false; 76 found = false;
77 if(found){ 77 if(found){
78 // write out scheme 78 // write out scheme
79 if(line.contains("ESSID=")){ 79 if(line.contains("ESSID=")){
80 QString id = line.mid(line.find("ESSID=")+6, line.length()); 80 QString id = line.mid(line.find("ESSID=")+6, line.length());
81 if(id == "any"){ 81 if(id == "any"){
82 essAny->setChecked(false); 82 essAny->setChecked(false);
83 }else{ 83 }else{
84 essAny->setChecked(true); 84 essAny->setChecked(true);
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);
124 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); 124 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true);
125 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); 125 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true);
126 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); 126 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true);
127 } 127 }
128 if(line.contains("CHANNEL=")){ 128 if(line.contains("CHANNEL=")){
129 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); 129 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt());
130 } 130 }
131 } 131 }
132 } 132 }
133} 133}
134 134
135/** 135/**
136 * Saves settings to the wireless.opts file using the current profile 136 * Saves settings to the wireless.opts file using the current profile
137 */ 137 */
138void WLANImp::changeAndSaveSettingFile(){ 138void WLANImp::changeAndSaveSettingFile(){
139 QString wlanFile = WIRELESS_OPTS; 139 QString wlanFile = WIRELESS_OPTS;
140 QFile::remove(wlanFile); 140 QFile::remove(wlanFile);
141 QFile file(wlanFile); 141 QFile file(wlanFile);
142 142
143 if (!file.open(IO_ReadWrite)){ 143 if (!file.open(IO_ReadWrite)){
144 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 144 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1());
145 return; 145 return;
146 } 146 }
147 147
148 QTextStream stream( &file ); 148 QTextStream stream( &file );
149 bool foundCase = false; 149 bool foundCase = false;
150 bool found = false; 150 bool found = false;
151 bool output = true; 151 bool output = true;
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 */
209void WLANImp::accept(){ 208void 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() )
235 initpath = "/etc/init.d"; 233 initpath = "/etc/init.d";
236 if( initpath ) 234 if( initpath )
237 system(QString("%1/pcmcia stop").arg(initpath)); 235 system(QString("%1/pcmcia stop").arg(initpath));
238 if( initpath ) 236 if( initpath )
239 system(QString("%1/pcmcia start").arg(initpath)); 237 system(QString("%1/pcmcia start").arg(initpath));
240 238
241 // Close out the dialog 239 // Close out the dialog
242 QDialog::accept(); 240 QDialog::accept();
243} 241}
244 242
245// wlanimp.cpp 243// wlanimp.cpp
246 244