summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.cpp9
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp9
2 files changed, 12 insertions, 6 deletions
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp
index 488911b..44c721a 100644
--- a/noncore/net/networksetup/wlan/wlanimp.cpp
+++ b/noncore/net/networksetup/wlan/wlanimp.cpp
@@ -103,124 +103,127 @@ void WLANImp::parseSettingFile(){
103 wepEnabled->setChecked(true); 103 wepEnabled->setChecked(true);
104 QString key; 104 QString key;
105 if(line.right(5) == (" open")){ 105 if(line.right(5) == (" open")){
106 key = line.mid(4, line.length()-5); 106 key = line.mid(4, line.length()-5);
107 authOpen->setChecked(true); 107 authOpen->setChecked(true);
108 authShared->setChecked(false); 108 authShared->setChecked(false);
109 } 109 }
110 else{ 110 else{
111 authOpen->setChecked(false); 111 authOpen->setChecked(false);
112 authShared->setChecked(true); 112 authShared->setChecked(true);
113 key = line.mid(4, line.length()); 113 key = line.mid(4, line.length());
114 } 114 }
115 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); 115 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true);
116 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); 116 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true);
117 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); 117 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true);
118 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); 118 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true);
119 } 119 }
120 if(line.contains("CHANNEL=")){ 120 if(line.contains("CHANNEL=")){
121 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); 121 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt());
122 } 122 }
123 } 123 }
124 } 124 }
125} 125}
126 126
127/** 127/**
128 * Saves settings to the wireless.opts file using the current profile 128 * Saves settings to the wireless.opts file using the current profile
129 */ 129 */
130void WLANImp::changeAndSaveSettingFile(){ 130void WLANImp::changeAndSaveSettingFile(){
131 QString wlanFile = WIRELESS_OPTS; 131 QString wlanFile = WIRELESS_OPTS;
132 QFile::remove(wlanFile); 132 QFile::remove(wlanFile);
133 QFile file(wlanFile); 133 QFile file(wlanFile);
134 134
135 if (!file.open(IO_ReadWrite)){ 135 if (!file.open(IO_ReadWrite)){
136 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 136 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1());
137 return; 137 return;
138 } 138 }
139 139
140 QTextStream stream( &file ); 140 QTextStream stream( &file );
141 bool foundCase = false; 141 bool foundCase = false;
142 bool found = false; 142 bool found = false;
143 bool output = true; 143 bool output = true;
144 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 144 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
145 QString line = (*it).simplifyWhiteSpace(); 145 QString line = (*it).simplifyWhiteSpace();
146 if(line.contains("case")) 146 if(line.contains("case"))
147 foundCase = true; 147 foundCase = true;
148 // See if we found our scheme to write or the sceme couldn't be found 148 // See if we found our scheme to write or the sceme couldn't be found
149 if((foundCase && line.contains("esac") && !found) || 149 if((foundCase && line.contains("esac") && !found) ||
150 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ 150 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){
151 // write out scheme 151 // write out scheme
152 found = true; 152 found = true;
153 output = false; 153 output = false;
154 154
155 if(!line.contains("esac")) 155 if(!line.contains("esac"))
156 stream << line << "\n"; 156 stream << line << "\n";
157 157
158 stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; 158 stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n';
159 stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "ad-hoc") << '\n'; 159 stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "ad-hoc") << '\n';
160 160
161 stream << "\tKEY0=" << keyLineEdit0->text() << "\n"; 161 stream << "\tKEY0=" << keyLineEdit0->text() << "\n";
162 stream << "\tKEY1=" << keyLineEdit1->text() << "\n"; 162 stream << "\tKEY1=" << keyLineEdit1->text() << "\n";
163 stream << "\tKEY2=" << keyLineEdit2->text() << "\n"; 163 stream << "\tKEY2=" << keyLineEdit2->text() << "\n";
164 stream << "\tKEY3=" << keyLineEdit3->text() << "\n"; 164 stream << "\tKEY3=" << keyLineEdit3->text() << "\n";
165 165
166 if(wepEnabled->isChecked()){ 166 if(wepEnabled->isChecked()){
167 stream << "\tKEY="; 167 stream << "\tKEY=\"";
168 if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); 168 if(keyRadio0->isChecked()) stream << keyLineEdit0->text();
169 if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); 169 if(keyRadio1->isChecked()) stream << keyLineEdit1->text();
170 if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); 170 if(keyRadio2->isChecked()) stream << keyLineEdit2->text();
171 if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); 171 if(keyRadio3->isChecked()) stream << keyLineEdit3->text();
172 if(authOpen->isChecked()) stream << " open"; 172 if(authOpen->isChecked())
173 stream << "\n"; 173 stream << " open";
174 else
175 stream << " restricted";
176 stream << "\n\"";
174 } 177 }
175 stream << "\tCHANNEL=" << networkChannel->value() << "\n"; 178 stream << "\tCHANNEL=" << networkChannel->value() << "\n";
176 stream << "\tRATE=auto\n"; 179 stream << "\tRATE=auto\n";
177 if(line.contains("esac")) 180 if(line.contains("esac"))
178 stream << line << "\n"; 181 stream << line << "\n";
179 } 182 }
180 if(line.contains(";;")) 183 if(line.contains(";;"))
181 output = true; 184 output = true;
182 if(output) 185 if(output)
183 stream << (*it) << '\n'; 186 stream << (*it) << '\n';
184 } 187 }
185 file.close(); 188 file.close();
186} 189}
187 190
188/** 191/**
189 * Check to see if the current config is valid 192 * Check to see if the current config is valid
190 * Save wireless.opts, save interfaces 193 * Save wireless.opts, save interfaces
191 */ 194 */
192void WLANImp::accept(){ 195void WLANImp::accept(){
193 if(wepEnabled->isChecked()){ 196 if(wepEnabled->isChecked()){
194 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) 197 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() )
195 { 198 {
196 QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); 199 QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok);
197 return; 200 return;
198 } 201 }
199 } 202 }
200 203
201 // Ok settings are good here, save 204 // Ok settings are good here, save
202 changeAndSaveSettingFile(); 205 changeAndSaveSettingFile();
203 206
204 // Try to save the interfaces settings. 207 // Try to save the interfaces settings.
205 if(!interfaceSetup->saveChanges()) 208 if(!interfaceSetup->saveChanges())
206 return; 209 return;
207 210
208 QDialog::accept(); 211 QDialog::accept();
209 return; 212 return;
210 // Restart the device now that the settings have changed 213 // Restart the device now that the settings have changed
211 QString initpath; 214 QString initpath;
212 if( QDir("/etc/rc.d/init.d").exists() ) 215 if( QDir("/etc/rc.d/init.d").exists() )
213 initpath = "/etc/rc.d/init.d"; 216 initpath = "/etc/rc.d/init.d";
214 else if( QDir("/etc/init.d").exists() ) 217 else if( QDir("/etc/init.d").exists() )
215 initpath = "/etc/init.d"; 218 initpath = "/etc/init.d";
216 if( initpath ) 219 if( initpath )
217 system(QString("%1/pcmcia stop").arg(initpath)); 220 system(QString("%1/pcmcia stop").arg(initpath));
218 if( initpath ) 221 if( initpath )
219 system(QString("%1/pcmcia start").arg(initpath)); 222 system(QString("%1/pcmcia start").arg(initpath));
220 223
221 // Close out the dialog 224 // Close out the dialog
222 QDialog::accept(); 225 QDialog::accept();
223} 226}
224 227
225// wlanimp.cpp 228// wlanimp.cpp
226 229
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 488911b..44c721a 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -103,124 +103,127 @@ void WLANImp::parseSettingFile(){
103 wepEnabled->setChecked(true); 103 wepEnabled->setChecked(true);
104 QString key; 104 QString key;
105 if(line.right(5) == (" open")){ 105 if(line.right(5) == (" open")){
106 key = line.mid(4, line.length()-5); 106 key = line.mid(4, line.length()-5);
107 authOpen->setChecked(true); 107 authOpen->setChecked(true);
108 authShared->setChecked(false); 108 authShared->setChecked(false);
109 } 109 }
110 else{ 110 else{
111 authOpen->setChecked(false); 111 authOpen->setChecked(false);
112 authShared->setChecked(true); 112 authShared->setChecked(true);
113 key = line.mid(4, line.length()); 113 key = line.mid(4, line.length());
114 } 114 }
115 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); 115 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true);
116 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); 116 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true);
117 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); 117 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true);
118 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); 118 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true);
119 } 119 }
120 if(line.contains("CHANNEL=")){ 120 if(line.contains("CHANNEL=")){
121 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); 121 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt());
122 } 122 }
123 } 123 }
124 } 124 }
125} 125}
126 126
127/** 127/**
128 * Saves settings to the wireless.opts file using the current profile 128 * Saves settings to the wireless.opts file using the current profile
129 */ 129 */
130void WLANImp::changeAndSaveSettingFile(){ 130void WLANImp::changeAndSaveSettingFile(){
131 QString wlanFile = WIRELESS_OPTS; 131 QString wlanFile = WIRELESS_OPTS;
132 QFile::remove(wlanFile); 132 QFile::remove(wlanFile);
133 QFile file(wlanFile); 133 QFile file(wlanFile);
134 134
135 if (!file.open(IO_ReadWrite)){ 135 if (!file.open(IO_ReadWrite)){
136 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 136 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1());
137 return; 137 return;
138 } 138 }
139 139
140 QTextStream stream( &file ); 140 QTextStream stream( &file );
141 bool foundCase = false; 141 bool foundCase = false;
142 bool found = false; 142 bool found = false;
143 bool output = true; 143 bool output = true;
144 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 144 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
145 QString line = (*it).simplifyWhiteSpace(); 145 QString line = (*it).simplifyWhiteSpace();
146 if(line.contains("case")) 146 if(line.contains("case"))
147 foundCase = true; 147 foundCase = true;
148 // See if we found our scheme to write or the sceme couldn't be found 148 // See if we found our scheme to write or the sceme couldn't be found
149 if((foundCase && line.contains("esac") && !found) || 149 if((foundCase && line.contains("esac") && !found) ||
150 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ 150 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){
151 // write out scheme 151 // write out scheme
152 found = true; 152 found = true;
153 output = false; 153 output = false;
154 154
155 if(!line.contains("esac")) 155 if(!line.contains("esac"))
156 stream << line << "\n"; 156 stream << line << "\n";
157 157
158 stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; 158 stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n';
159 stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "ad-hoc") << '\n'; 159 stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "ad-hoc") << '\n';
160 160
161 stream << "\tKEY0=" << keyLineEdit0->text() << "\n"; 161 stream << "\tKEY0=" << keyLineEdit0->text() << "\n";
162 stream << "\tKEY1=" << keyLineEdit1->text() << "\n"; 162 stream << "\tKEY1=" << keyLineEdit1->text() << "\n";
163 stream << "\tKEY2=" << keyLineEdit2->text() << "\n"; 163 stream << "\tKEY2=" << keyLineEdit2->text() << "\n";
164 stream << "\tKEY3=" << keyLineEdit3->text() << "\n"; 164 stream << "\tKEY3=" << keyLineEdit3->text() << "\n";
165 165
166 if(wepEnabled->isChecked()){ 166 if(wepEnabled->isChecked()){
167 stream << "\tKEY="; 167 stream << "\tKEY=\"";
168 if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); 168 if(keyRadio0->isChecked()) stream << keyLineEdit0->text();
169 if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); 169 if(keyRadio1->isChecked()) stream << keyLineEdit1->text();
170 if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); 170 if(keyRadio2->isChecked()) stream << keyLineEdit2->text();
171 if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); 171 if(keyRadio3->isChecked()) stream << keyLineEdit3->text();
172 if(authOpen->isChecked()) stream << " open"; 172 if(authOpen->isChecked())
173 stream << "\n"; 173 stream << " open";
174 else
175 stream << " restricted";
176 stream << "\n\"";
174 } 177 }
175 stream << "\tCHANNEL=" << networkChannel->value() << "\n"; 178 stream << "\tCHANNEL=" << networkChannel->value() << "\n";
176 stream << "\tRATE=auto\n"; 179 stream << "\tRATE=auto\n";
177 if(line.contains("esac")) 180 if(line.contains("esac"))
178 stream << line << "\n"; 181 stream << line << "\n";
179 } 182 }
180 if(line.contains(";;")) 183 if(line.contains(";;"))
181 output = true; 184 output = true;
182 if(output) 185 if(output)
183 stream << (*it) << '\n'; 186 stream << (*it) << '\n';
184 } 187 }
185 file.close(); 188 file.close();
186} 189}
187 190
188/** 191/**
189 * Check to see if the current config is valid 192 * Check to see if the current config is valid
190 * Save wireless.opts, save interfaces 193 * Save wireless.opts, save interfaces
191 */ 194 */
192void WLANImp::accept(){ 195void WLANImp::accept(){
193 if(wepEnabled->isChecked()){ 196 if(wepEnabled->isChecked()){
194 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) 197 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() )
195 { 198 {
196 QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); 199 QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok);
197 return; 200 return;
198 } 201 }
199 } 202 }
200 203
201 // Ok settings are good here, save 204 // Ok settings are good here, save
202 changeAndSaveSettingFile(); 205 changeAndSaveSettingFile();
203 206
204 // Try to save the interfaces settings. 207 // Try to save the interfaces settings.
205 if(!interfaceSetup->saveChanges()) 208 if(!interfaceSetup->saveChanges())
206 return; 209 return;
207 210
208 QDialog::accept(); 211 QDialog::accept();
209 return; 212 return;
210 // Restart the device now that the settings have changed 213 // Restart the device now that the settings have changed
211 QString initpath; 214 QString initpath;
212 if( QDir("/etc/rc.d/init.d").exists() ) 215 if( QDir("/etc/rc.d/init.d").exists() )
213 initpath = "/etc/rc.d/init.d"; 216 initpath = "/etc/rc.d/init.d";
214 else if( QDir("/etc/init.d").exists() ) 217 else if( QDir("/etc/init.d").exists() )
215 initpath = "/etc/init.d"; 218 initpath = "/etc/init.d";
216 if( initpath ) 219 if( initpath )
217 system(QString("%1/pcmcia stop").arg(initpath)); 220 system(QString("%1/pcmcia stop").arg(initpath));
218 if( initpath ) 221 if( initpath )
219 system(QString("%1/pcmcia start").arg(initpath)); 222 system(QString("%1/pcmcia start").arg(initpath));
220 223
221 // Close out the dialog 224 // Close out the dialog
222 QDialog::accept(); 225 QDialog::accept();
223} 226}
224 227
225// wlanimp.cpp 228// wlanimp.cpp
226 229