summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/wlan/wlanimp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/wlan/wlanimp.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 80a9927..fe7941d 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -24,49 +24,49 @@
24 24
25/** 25/**
26 * Constructor, read in the wireless.opts file for parsing later. 26 * Constructor, read in the wireless.opts file for parsing later.
27 */ 27 */
28using namespace Opie::Core; 28using namespace Opie::Core;
29WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { 29WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") {
30 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); 30 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);
31 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 31 tabWidget->insertTab(interfaceSetup, "TCP/IP");
32 32
33 // Read in the config file. 33 // Read in the config file.
34 QString wlanFile = WIRELESS_OPTS; 34 QString wlanFile = WIRELESS_OPTS;
35 QFile file(wlanFile); 35 QFile file(wlanFile);
36 if (file.open(IO_ReadOnly)){ 36 if (file.open(IO_ReadOnly)){
37 QTextStream stream( &file ); 37 QTextStream stream( &file );
38 QString line = ""; 38 QString line = "";
39 while ( !stream.eof() ) { 39 while ( !stream.eof() ) {
40 line += stream.readLine(); 40 line += stream.readLine();
41 line += "\n"; 41 line += "\n";
42 } 42 }
43 file.close(); 43 file.close();
44 settingsFileText = QStringList::split("\n", line, true); 44 settingsFileText = QStringList::split("\n", line, true);
45 parseSettingFile(); 45 parseSettingFile();
46 } 46 }
47 else 47 else
48 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); 48 odebug << QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1() << oendl;
49 connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); 49 connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
50} 50}
51 51
52void WLANImp::typeChanged(int mod){ 52void WLANImp::typeChanged(int mod){
53 networkChannel->setEnabled(mod); 53 networkChannel->setEnabled(mod);
54 channelLabel->setEnabled(mod); 54 channelLabel->setEnabled(mod);
55} 55}
56 56
57/** 57/**
58 * Change the profile for both wireless settings and network settings. 58 * Change the profile for both wireless settings and network settings.
59 */ 59 */
60void WLANImp::setProfile(const QString &profile){ 60void WLANImp::setProfile(const QString &profile){
61 interfaceSetup->setProfile(profile); 61 interfaceSetup->setProfile(profile);
62 parseSettingFile(); 62 parseSettingFile();
63} 63}
64 64
65/** 65/**
66 * Parses the settings file that was read in and gets any setting from it. 66 * Parses the settings file that was read in and gets any setting from it.
67 */ 67 */
68void WLANImp::parseSettingFile(){ 68void WLANImp::parseSettingFile(){
69 bool foundCase = false; 69 bool foundCase = false;
70 bool found = false; 70 bool found = false;
71 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 71 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
72 QString line = (*it).simplifyWhiteSpace(); 72 QString line = (*it).simplifyWhiteSpace();
@@ -125,49 +125,49 @@ void WLANImp::parseSettingFile(){
125 authShared->setChecked(true); 125 authShared->setChecked(true);
126 key = line.mid(4, line.length()); 126 key = line.mid(4, line.length());
127 } 127 }
128 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); 128 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true);
129 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); 129 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true);
130 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); 130 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true);
131 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); 131 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true);
132 } 132 }
133 if(line.contains("CHANNEL=")){ 133 if(line.contains("CHANNEL=")){
134 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); 134 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt());
135 } 135 }
136 } 136 }
137 } 137 }
138} 138}
139 139
140/** 140/**
141 * Saves settings to the wireless.opts file using the current profile 141 * Saves settings to the wireless.opts file using the current profile
142 */ 142 */
143void WLANImp::changeAndSaveSettingFile(){ 143void WLANImp::changeAndSaveSettingFile(){
144 QString wlanFile = WIRELESS_OPTS; 144 QString wlanFile = WIRELESS_OPTS;
145 QFile::remove(wlanFile); 145 QFile::remove(wlanFile);
146 QFile file(wlanFile); 146 QFile file(wlanFile);
147 147
148 if (!file.open(IO_ReadWrite)){ 148 if (!file.open(IO_ReadWrite)){
149 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 149 odebug << QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1() << oendl;
150 return; 150 return;
151 } 151 }
152 152
153 QTextStream stream( &file ); 153 QTextStream stream( &file );
154 bool foundCase = false; 154 bool foundCase = false;
155 bool found = false; 155 bool found = false;
156 bool output = true; 156 bool output = true;
157 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 157 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
158 QString line = (*it).simplifyWhiteSpace(); 158 QString line = (*it).simplifyWhiteSpace();
159 if(line.contains("case")) 159 if(line.contains("case"))
160 foundCase = true; 160 foundCase = true;
161 // See if we found our scheme to write or the sceme couldn't be found 161 // See if we found our scheme to write or the sceme couldn't be found
162 if((foundCase && line.contains("esac") && !found) || 162 if((foundCase && line.contains("esac") && !found) ||
163 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ 163 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){
164 // write out scheme 164 // write out scheme
165 found = true; 165 found = true;
166 output = false; 166 output = false;
167 167
168 if(!line.contains("esac")) 168 if(!line.contains("esac"))
169 stream << line << "\n"; 169 stream << line << "\n";
170 if(!essAny->isChecked() == true){ 170 if(!essAny->isChecked() == true){
171 stream << "\tESSID=any\n"; 171 stream << "\tESSID=any\n";
172 stream << "\tMODE=Managed\n"; 172 stream << "\tMODE=Managed\n";
173 } 173 }
@@ -215,31 +215,31 @@ void WLANImp::accept(){
215 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ 215 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){
216 QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); 216 QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok);
217 return; 217 return;
218 } 218 }
219 } 219 }
220 220
221 if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){ 221 if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){
222 QMessageBox::information(this, "Error", "Please enter a SSID.", QMessageBox::Ok); 222 QMessageBox::information(this, "Error", "Please enter a SSID.", QMessageBox::Ok);
223 return; 223 return;
224 } 224 }
225 225
226 // Ok settings are good here, save 226 // Ok settings are good here, save
227 changeAndSaveSettingFile(); 227 changeAndSaveSettingFile();
228 228
229 // Try to save the interfaces settings. 229 // Try to save the interfaces settings.
230 if(!interfaceSetup->saveChanges()) 230 if(!interfaceSetup->saveChanges())
231 return; 231 return;
232 232
233 OProcess insert; 233 OProcess insert;
234 insert << "sh"; 234 insert << "sh";
235 insert << "-c"; 235 insert << "-c";
236 insert << "cardctl eject && cardctl insert"; 236 insert << "cardctl eject && cardctl insert";
237 237
238 if (!insert.start(OProcess::DontCare, OProcess::NoCommunication) ) { 238 if (!insert.start(OProcess::DontCare, OProcess::NoCommunication) ) {
239 qWarning("could not start cardctl"); 239 owarn << "could not start cardctl" << oendl;
240 } 240 }
241 241
242 // Close out the dialog 242 // Close out the dialog
243 QDialog::accept(); 243 QDialog::accept();
244} 244}
245 245