author | andyq <andyq> | 2002-11-10 15:34:59 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-10 15:34:59 (UTC) |
commit | 6d3fd69b7f14971d837e4fd13084bb978592a752 (patch) (unidiff) | |
tree | 9c11d7be738bc147215af59654c9ab1f51ddcf10 | |
parent | 804e08f4642353af836bab921d8f732709051de0 (diff) | |
download | opie-6d3fd69b7f14971d837e4fd13084bb978592a752.zip opie-6d3fd69b7f14971d837e4fd13084bb978592a752.tar.gz opie-6d3fd69b7f14971d837e4fd13084bb978592a752.tar.bz2 |
Added braces round key checking if statement to fix bug that WEP settings
were never saved if WEP was enabled
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 7 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index d4b4af9..e64a633 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -11,222 +11,225 @@ | |||
11 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
12 | #include <qtabwidget.h> | 12 | #include <qtabwidget.h> |
13 | 13 | ||
14 | /* system() */ | 14 | /* system() */ |
15 | #include <stdlib.h> | 15 | #include <stdlib.h> |
16 | 16 | ||
17 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 17 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Constructor, read in the wireless.opts file for parsing later. | 20 | * Constructor, read in the wireless.opts file for parsing later. |
21 | */ | 21 | */ |
22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { | 22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { |
23 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); | 23 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); |
24 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 24 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
25 | 25 | ||
26 | // Read in the config file. | 26 | // Read in the config file. |
27 | QString wlanFile = WIRELESS_OPTS; | 27 | QString wlanFile = WIRELESS_OPTS; |
28 | QFile file(wlanFile); | 28 | QFile file(wlanFile); |
29 | if (file.open(IO_ReadOnly)){ | 29 | if (file.open(IO_ReadOnly)){ |
30 | QTextStream stream( &file ); | 30 | QTextStream stream( &file ); |
31 | QString line = ""; | 31 | QString line = ""; |
32 | while ( !stream.eof() ) { | 32 | while ( !stream.eof() ) { |
33 | line += stream.readLine(); | 33 | line += stream.readLine(); |
34 | line += "\n"; | 34 | line += "\n"; |
35 | } | 35 | } |
36 | file.close(); | 36 | file.close(); |
37 | settingsFileText = QStringList::split("\n", line, true); | 37 | settingsFileText = QStringList::split("\n", line, true); |
38 | parseSettingFile(); | 38 | parseSettingFile(); |
39 | } | 39 | } |
40 | else | 40 | else |
41 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); | 41 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); |
42 | } | 42 | } |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Change the profile for both wireless settings and network settings. | 45 | * Change the profile for both wireless settings and network settings. |
46 | */ | 46 | */ |
47 | void WLANImp::setProfile(const QString &profile){ | 47 | void WLANImp::setProfile(const QString &profile){ |
48 | interfaceSetup->setProfile(profile); | 48 | interfaceSetup->setProfile(profile); |
49 | parseSettingFile(); | 49 | parseSettingFile(); |
50 | } | 50 | } |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Parses the settings file that was read in and gets any setting from it. | 53 | * Parses the settings file that was read in and gets any setting from it. |
54 | */ | 54 | */ |
55 | void WLANImp::parseSettingFile(){ | 55 | void WLANImp::parseSettingFile(){ |
56 | bool foundCase = false; | 56 | bool foundCase = false; |
57 | bool found = false; | 57 | bool found = false; |
58 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | 58 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { |
59 | QString line = (*it).simplifyWhiteSpace(); | 59 | QString line = (*it).simplifyWhiteSpace(); |
60 | if(line.contains("case")) | 60 | if(line.contains("case")) |
61 | foundCase = true; | 61 | foundCase = true; |
62 | // See if we found our scheme to write or the sceme couldn't be found | 62 | // See if we found our scheme to write or the sceme couldn't be found |
63 | if((foundCase && line.contains("esac")) || | 63 | if((foundCase && line.contains("esac")) || |
64 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) | 64 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) |
65 | found = true; | 65 | found = true; |
66 | 66 | ||
67 | if(line.contains(";;")) | 67 | if(line.contains(";;")) |
68 | found = false; | 68 | found = false; |
69 | if(found){ | 69 | if(found){ |
70 | // write out scheme | 70 | // write out scheme |
71 | if(line.contains("ESSID=")){ | 71 | if(line.contains("ESSID=")){ |
72 | QString id = line.mid(line.find("ESSID=")+6, line.length()); | 72 | QString id = line.mid(line.find("ESSID=")+6, line.length()); |
73 | if(id == "any"){ | 73 | if(id == "any"){ |
74 | essNon->setChecked(true); | 74 | essNon->setChecked(true); |
75 | essSpecific->setChecked(false); | 75 | essSpecific->setChecked(false); |
76 | }else{ | 76 | }else{ |
77 | essSpecific->setChecked(true); | 77 | essSpecific->setChecked(true); |
78 | essSpecificLineEdit->setText(id); | 78 | essSpecificLineEdit->setText(id); |
79 | essNon->setChecked(false); | 79 | essNon->setChecked(false); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | if(line.contains("MODE=")){ | 82 | if(line.contains("MODE=")){ |
83 | QString mode = line.mid(line.find("MODE=")+5, line.length()); | 83 | QString mode = line.mid(line.find("MODE=")+5, line.length()); |
84 | if(mode == "Managed"){ | 84 | if(mode == "Managed"){ |
85 | network802->setChecked( false ); | 85 | network802->setChecked( false ); |
86 | networkInfrastructure->setChecked( true ); | 86 | networkInfrastructure->setChecked( true ); |
87 | } | 87 | } |
88 | else{ | 88 | else{ |
89 | network802->setChecked( true ); | 89 | network802->setChecked( true ); |
90 | networkInfrastructure->setChecked( false ); | 90 | networkInfrastructure->setChecked( false ); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | if(line.contains("KEY=")){ | 93 | if(line.contains("KEY=")){ |
94 | line.at(0) != '#' ? wepEnabled->setChecked(true) : wepEnabled->setChecked(false); | 94 | line.at(0) != '#' ? wepEnabled->setChecked(true) : wepEnabled->setChecked(false); |
95 | int s = line.find("KEY="); | 95 | int s = line.find("KEY="); |
96 | line = line.mid(s+4, line.length()); | 96 | line = line.mid(s+4, line.length()); |
97 | // Find first Key | 97 | // Find first Key |
98 | s = line.find("[1]"); | 98 | s = line.find("[1]"); |
99 | if(s != -1){ | 99 | if(s != -1){ |
100 | keyLineEdit0->setText(line.mid(0, s)); | 100 | keyLineEdit0->setText(line.mid(0, s)); |
101 | line = line.mid(s+3, line.length()); | 101 | line = line.mid(s+3, line.length()); |
102 | } | 102 | } |
103 | s = line.find("[2]"); | 103 | s = line.find("[2]"); |
104 | if(s != -1){ | 104 | if(s != -1){ |
105 | keyLineEdit1->setText(line.mid(0, s)); | 105 | keyLineEdit1->setText(line.mid(0, s)); |
106 | line = line.mid(s+3, line.length()); | 106 | line = line.mid(s+3, line.length()); |
107 | } | 107 | } |
108 | s = line.find("[3]"); | 108 | s = line.find("[3]"); |
109 | if(s != -1){ | 109 | if(s != -1){ |
110 | keyLineEdit2->setText(line.mid(0, s)); | 110 | keyLineEdit2->setText(line.mid(0, s)); |
111 | line = line.mid(s+3, line.length()); | 111 | line = line.mid(s+3, line.length()); |
112 | } | 112 | } |
113 | s = line.find("[4]"); | 113 | s = line.find("[4]"); |
114 | if(s != -1){ | 114 | if(s != -1){ |
115 | keyLineEdit3->setText(line.mid(0, s)); | 115 | keyLineEdit3->setText(line.mid(0, s)); |
116 | line = line.mid(s+3, line.length()); | 116 | line = line.mid(s+3, line.length()); |
117 | } | 117 | } |
118 | if(line.contains("key [1]")) keyRadio0->setChecked(true); | 118 | if(line.contains("key [1]")) keyRadio0->setChecked(true); |
119 | if(line.contains("key [2]")) keyRadio1->setChecked(true); | 119 | if(line.contains("key [2]")) keyRadio1->setChecked(true); |
120 | if(line.contains("key [3]")) keyRadio2->setChecked(true); | 120 | if(line.contains("key [3]")) keyRadio2->setChecked(true); |
121 | if(line.contains("key [4]")) keyRadio3->setChecked(true); | 121 | if(line.contains("key [4]")) keyRadio3->setChecked(true); |
122 | if(line.contains("open")){ | 122 | if(line.contains("open")){ |
123 | authOpen->setChecked(true); | 123 | authOpen->setChecked(true); |
124 | authShared->setChecked(false); | 124 | authShared->setChecked(false); |
125 | } | 125 | } |
126 | else{ | 126 | else{ |
127 | authOpen->setChecked(false); | 127 | authOpen->setChecked(false); |
128 | authShared->setChecked(true); | 128 | authShared->setChecked(true); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | if(line.contains("CHANNEL=")){ | 131 | if(line.contains("CHANNEL=")){ |
132 | networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); | 132 | networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * Saves settings to the wireless.opts file using the current profile | 139 | * Saves settings to the wireless.opts file using the current profile |
140 | */ | 140 | */ |
141 | void WLANImp::changeAndSaveSettingFile(){ | 141 | void WLANImp::changeAndSaveSettingFile(){ |
142 | QString wlanFile = WIRELESS_OPTS; | 142 | QString wlanFile = WIRELESS_OPTS; |
143 | QFile::remove(wlanFile); | 143 | QFile::remove(wlanFile); |
144 | QFile file(wlanFile); | 144 | QFile file(wlanFile); |
145 | 145 | ||
146 | if (!file.open(IO_ReadWrite)){ | 146 | if (!file.open(IO_ReadWrite)){ |
147 | qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); | 147 | qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | 150 | ||
151 | QTextStream stream( &file ); | 151 | QTextStream stream( &file ); |
152 | bool foundCase = false; | 152 | bool foundCase = false; |
153 | bool found = false; | 153 | bool found = false; |
154 | bool output = true; | 154 | bool output = true; |
155 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | 155 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { |
156 | QString line = (*it).simplifyWhiteSpace(); | 156 | QString line = (*it).simplifyWhiteSpace(); |
157 | if(line.contains("case")) | 157 | if(line.contains("case")) |
158 | foundCase = true; | 158 | foundCase = true; |
159 | // See if we found our scheme to write or the sceme couldn't be found | 159 | // See if we found our scheme to write or the sceme couldn't be found |
160 | if((foundCase && line.contains("esac") && !found) || | 160 | if((foundCase && line.contains("esac") && !found) || |
161 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ | 161 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ |
162 | // write out scheme | 162 | // write out scheme |
163 | found = true; | 163 | found = true; |
164 | output = false; | 164 | output = false; |
165 | 165 | ||
166 | if(!line.contains("esac")) | 166 | if(!line.contains("esac")) |
167 | stream << line << "\n"; | 167 | stream << line << "\n"; |
168 | 168 | ||
169 | stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; | 169 | stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; |
170 | stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "AdHoc") << '\n'; | 170 | stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "AdHoc") << '\n'; |
171 | if(!wepEnabled->isChecked()) | 171 | if(!wepEnabled->isChecked()) |
172 | stream << "#"; | 172 | stream << "#"; |
173 | stream << "\tKEY="; | 173 | stream << "\tKEY="; |
174 | stream << keyLineEdit0->text() << " [1]"; | 174 | stream << keyLineEdit0->text() << " [1]"; |
175 | stream << keyLineEdit1->text() << " [2]"; | 175 | stream << keyLineEdit1->text() << " [2]"; |
176 | stream << keyLineEdit2->text() << " [3]"; | 176 | stream << keyLineEdit2->text() << " [3]"; |
177 | stream << keyLineEdit3->text() << " [4]"; | 177 | stream << keyLineEdit3->text() << " [4]"; |
178 | stream << " key ["; | 178 | stream << " key ["; |
179 | if(keyRadio0->isChecked()) stream << "1]"; | 179 | if(keyRadio0->isChecked()) stream << "1]"; |
180 | if(keyRadio1->isChecked()) stream << "2]"; | 180 | if(keyRadio1->isChecked()) stream << "2]"; |
181 | if(keyRadio2->isChecked()) stream << "3]"; | 181 | if(keyRadio2->isChecked()) stream << "3]"; |
182 | if(keyRadio3->isChecked()) stream << "4]"; | 182 | if(keyRadio3->isChecked()) stream << "4]"; |
183 | if(authOpen->isChecked()) stream << " open"; | 183 | if(authOpen->isChecked()) stream << " open"; |
184 | stream << "\n"; | 184 | stream << "\n"; |
185 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | 185 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; |
186 | stream << "\tRATE=auto\n"; | 186 | stream << "\tRATE=auto\n"; |
187 | if(line.contains("esac")) | 187 | if(line.contains("esac")) |
188 | stream << line << "\n"; | 188 | stream << line << "\n"; |
189 | } | 189 | } |
190 | if(line.contains(";;")) | 190 | if(line.contains(";;")) |
191 | output = true; | 191 | output = true; |
192 | if(output) | 192 | if(output) |
193 | stream << (*it) << '\n'; | 193 | stream << (*it) << '\n'; |
194 | } | 194 | } |
195 | file.close(); | 195 | file.close(); |
196 | } | 196 | } |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Check to see if the current config is valid | 199 | * Check to see if the current config is valid |
200 | * Save wireless.opts, save interfaces | 200 | * Save wireless.opts, save interfaces |
201 | */ | 201 | */ |
202 | void WLANImp::accept(){ | 202 | void WLANImp::accept(){ |
203 | printf( "Accept pressed\n" ); | ||
203 | if(wepEnabled->isChecked()){ | 204 | if(wepEnabled->isChecked()){ |
204 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) | 205 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) |
205 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); | 206 | { |
206 | return; | 207 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); |
208 | return; | ||
209 | } | ||
207 | } | 210 | } |
208 | 211 | ||
209 | // Ok settings are good here, save | 212 | // Ok settings are good here, save |
210 | changeAndSaveSettingFile(); | 213 | changeAndSaveSettingFile(); |
211 | 214 | ||
212 | // Try to save the interfaces settings. | 215 | // Try to save the interfaces settings. |
213 | if(!interfaceSetup->saveChanges()) | 216 | if(!interfaceSetup->saveChanges()) |
214 | return; | 217 | return; |
215 | 218 | ||
216 | // Restart the device now that the settings have changed | 219 | // Restart the device now that the settings have changed |
217 | QString initpath; | 220 | QString initpath; |
218 | if( QDir("/etc/rc.d/init.d").exists() ) | 221 | if( QDir("/etc/rc.d/init.d").exists() ) |
219 | initpath = "/etc/rc.d/init.d"; | 222 | initpath = "/etc/rc.d/init.d"; |
220 | else if( QDir("/etc/init.d").exists() ) | 223 | else if( QDir("/etc/init.d").exists() ) |
221 | initpath = "/etc/init.d"; | 224 | initpath = "/etc/init.d"; |
222 | if( initpath ) | 225 | if( initpath ) |
223 | system(QString("%1/pcmcia stop").arg(initpath)); | 226 | system(QString("%1/pcmcia stop").arg(initpath)); |
224 | if( initpath ) | 227 | if( initpath ) |
225 | system(QString("%1/pcmcia start").arg(initpath)); | 228 | system(QString("%1/pcmcia start").arg(initpath)); |
226 | 229 | ||
227 | // Close out the dialog | 230 | // Close out the dialog |
228 | QDialog::accept(); | 231 | QDialog::accept(); |
229 | } | 232 | } |
230 | 233 | ||
231 | // wlanimp.cpp | 234 | // wlanimp.cpp |
232 | 235 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index d4b4af9..e64a633 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -11,222 +11,225 @@ | |||
11 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
12 | #include <qtabwidget.h> | 12 | #include <qtabwidget.h> |
13 | 13 | ||
14 | /* system() */ | 14 | /* system() */ |
15 | #include <stdlib.h> | 15 | #include <stdlib.h> |
16 | 16 | ||
17 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 17 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Constructor, read in the wireless.opts file for parsing later. | 20 | * Constructor, read in the wireless.opts file for parsing later. |
21 | */ | 21 | */ |
22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { | 22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { |
23 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); | 23 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); |
24 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 24 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
25 | 25 | ||
26 | // Read in the config file. | 26 | // Read in the config file. |
27 | QString wlanFile = WIRELESS_OPTS; | 27 | QString wlanFile = WIRELESS_OPTS; |
28 | QFile file(wlanFile); | 28 | QFile file(wlanFile); |
29 | if (file.open(IO_ReadOnly)){ | 29 | if (file.open(IO_ReadOnly)){ |
30 | QTextStream stream( &file ); | 30 | QTextStream stream( &file ); |
31 | QString line = ""; | 31 | QString line = ""; |
32 | while ( !stream.eof() ) { | 32 | while ( !stream.eof() ) { |
33 | line += stream.readLine(); | 33 | line += stream.readLine(); |
34 | line += "\n"; | 34 | line += "\n"; |
35 | } | 35 | } |
36 | file.close(); | 36 | file.close(); |
37 | settingsFileText = QStringList::split("\n", line, true); | 37 | settingsFileText = QStringList::split("\n", line, true); |
38 | parseSettingFile(); | 38 | parseSettingFile(); |
39 | } | 39 | } |
40 | else | 40 | else |
41 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); | 41 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); |
42 | } | 42 | } |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Change the profile for both wireless settings and network settings. | 45 | * Change the profile for both wireless settings and network settings. |
46 | */ | 46 | */ |
47 | void WLANImp::setProfile(const QString &profile){ | 47 | void WLANImp::setProfile(const QString &profile){ |
48 | interfaceSetup->setProfile(profile); | 48 | interfaceSetup->setProfile(profile); |
49 | parseSettingFile(); | 49 | parseSettingFile(); |
50 | } | 50 | } |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Parses the settings file that was read in and gets any setting from it. | 53 | * Parses the settings file that was read in and gets any setting from it. |
54 | */ | 54 | */ |
55 | void WLANImp::parseSettingFile(){ | 55 | void WLANImp::parseSettingFile(){ |
56 | bool foundCase = false; | 56 | bool foundCase = false; |
57 | bool found = false; | 57 | bool found = false; |
58 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | 58 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { |
59 | QString line = (*it).simplifyWhiteSpace(); | 59 | QString line = (*it).simplifyWhiteSpace(); |
60 | if(line.contains("case")) | 60 | if(line.contains("case")) |
61 | foundCase = true; | 61 | foundCase = true; |
62 | // See if we found our scheme to write or the sceme couldn't be found | 62 | // See if we found our scheme to write or the sceme couldn't be found |
63 | if((foundCase && line.contains("esac")) || | 63 | if((foundCase && line.contains("esac")) || |
64 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) | 64 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) |
65 | found = true; | 65 | found = true; |
66 | 66 | ||
67 | if(line.contains(";;")) | 67 | if(line.contains(";;")) |
68 | found = false; | 68 | found = false; |
69 | if(found){ | 69 | if(found){ |
70 | // write out scheme | 70 | // write out scheme |
71 | if(line.contains("ESSID=")){ | 71 | if(line.contains("ESSID=")){ |
72 | QString id = line.mid(line.find("ESSID=")+6, line.length()); | 72 | QString id = line.mid(line.find("ESSID=")+6, line.length()); |
73 | if(id == "any"){ | 73 | if(id == "any"){ |
74 | essNon->setChecked(true); | 74 | essNon->setChecked(true); |
75 | essSpecific->setChecked(false); | 75 | essSpecific->setChecked(false); |
76 | }else{ | 76 | }else{ |
77 | essSpecific->setChecked(true); | 77 | essSpecific->setChecked(true); |
78 | essSpecificLineEdit->setText(id); | 78 | essSpecificLineEdit->setText(id); |
79 | essNon->setChecked(false); | 79 | essNon->setChecked(false); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | if(line.contains("MODE=")){ | 82 | if(line.contains("MODE=")){ |
83 | QString mode = line.mid(line.find("MODE=")+5, line.length()); | 83 | QString mode = line.mid(line.find("MODE=")+5, line.length()); |
84 | if(mode == "Managed"){ | 84 | if(mode == "Managed"){ |
85 | network802->setChecked( false ); | 85 | network802->setChecked( false ); |
86 | networkInfrastructure->setChecked( true ); | 86 | networkInfrastructure->setChecked( true ); |
87 | } | 87 | } |
88 | else{ | 88 | else{ |
89 | network802->setChecked( true ); | 89 | network802->setChecked( true ); |
90 | networkInfrastructure->setChecked( false ); | 90 | networkInfrastructure->setChecked( false ); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | if(line.contains("KEY=")){ | 93 | if(line.contains("KEY=")){ |
94 | line.at(0) != '#' ? wepEnabled->setChecked(true) : wepEnabled->setChecked(false); | 94 | line.at(0) != '#' ? wepEnabled->setChecked(true) : wepEnabled->setChecked(false); |
95 | int s = line.find("KEY="); | 95 | int s = line.find("KEY="); |
96 | line = line.mid(s+4, line.length()); | 96 | line = line.mid(s+4, line.length()); |
97 | // Find first Key | 97 | // Find first Key |
98 | s = line.find("[1]"); | 98 | s = line.find("[1]"); |
99 | if(s != -1){ | 99 | if(s != -1){ |
100 | keyLineEdit0->setText(line.mid(0, s)); | 100 | keyLineEdit0->setText(line.mid(0, s)); |
101 | line = line.mid(s+3, line.length()); | 101 | line = line.mid(s+3, line.length()); |
102 | } | 102 | } |
103 | s = line.find("[2]"); | 103 | s = line.find("[2]"); |
104 | if(s != -1){ | 104 | if(s != -1){ |
105 | keyLineEdit1->setText(line.mid(0, s)); | 105 | keyLineEdit1->setText(line.mid(0, s)); |
106 | line = line.mid(s+3, line.length()); | 106 | line = line.mid(s+3, line.length()); |
107 | } | 107 | } |
108 | s = line.find("[3]"); | 108 | s = line.find("[3]"); |
109 | if(s != -1){ | 109 | if(s != -1){ |
110 | keyLineEdit2->setText(line.mid(0, s)); | 110 | keyLineEdit2->setText(line.mid(0, s)); |
111 | line = line.mid(s+3, line.length()); | 111 | line = line.mid(s+3, line.length()); |
112 | } | 112 | } |
113 | s = line.find("[4]"); | 113 | s = line.find("[4]"); |
114 | if(s != -1){ | 114 | if(s != -1){ |
115 | keyLineEdit3->setText(line.mid(0, s)); | 115 | keyLineEdit3->setText(line.mid(0, s)); |
116 | line = line.mid(s+3, line.length()); | 116 | line = line.mid(s+3, line.length()); |
117 | } | 117 | } |
118 | if(line.contains("key [1]")) keyRadio0->setChecked(true); | 118 | if(line.contains("key [1]")) keyRadio0->setChecked(true); |
119 | if(line.contains("key [2]")) keyRadio1->setChecked(true); | 119 | if(line.contains("key [2]")) keyRadio1->setChecked(true); |
120 | if(line.contains("key [3]")) keyRadio2->setChecked(true); | 120 | if(line.contains("key [3]")) keyRadio2->setChecked(true); |
121 | if(line.contains("key [4]")) keyRadio3->setChecked(true); | 121 | if(line.contains("key [4]")) keyRadio3->setChecked(true); |
122 | if(line.contains("open")){ | 122 | if(line.contains("open")){ |
123 | authOpen->setChecked(true); | 123 | authOpen->setChecked(true); |
124 | authShared->setChecked(false); | 124 | authShared->setChecked(false); |
125 | } | 125 | } |
126 | else{ | 126 | else{ |
127 | authOpen->setChecked(false); | 127 | authOpen->setChecked(false); |
128 | authShared->setChecked(true); | 128 | authShared->setChecked(true); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | if(line.contains("CHANNEL=")){ | 131 | if(line.contains("CHANNEL=")){ |
132 | networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); | 132 | networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * Saves settings to the wireless.opts file using the current profile | 139 | * Saves settings to the wireless.opts file using the current profile |
140 | */ | 140 | */ |
141 | void WLANImp::changeAndSaveSettingFile(){ | 141 | void WLANImp::changeAndSaveSettingFile(){ |
142 | QString wlanFile = WIRELESS_OPTS; | 142 | QString wlanFile = WIRELESS_OPTS; |
143 | QFile::remove(wlanFile); | 143 | QFile::remove(wlanFile); |
144 | QFile file(wlanFile); | 144 | QFile file(wlanFile); |
145 | 145 | ||
146 | if (!file.open(IO_ReadWrite)){ | 146 | if (!file.open(IO_ReadWrite)){ |
147 | qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); | 147 | qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | 150 | ||
151 | QTextStream stream( &file ); | 151 | QTextStream stream( &file ); |
152 | bool foundCase = false; | 152 | bool foundCase = false; |
153 | bool found = false; | 153 | bool found = false; |
154 | bool output = true; | 154 | bool output = true; |
155 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | 155 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { |
156 | QString line = (*it).simplifyWhiteSpace(); | 156 | QString line = (*it).simplifyWhiteSpace(); |
157 | if(line.contains("case")) | 157 | if(line.contains("case")) |
158 | foundCase = true; | 158 | foundCase = true; |
159 | // See if we found our scheme to write or the sceme couldn't be found | 159 | // See if we found our scheme to write or the sceme couldn't be found |
160 | if((foundCase && line.contains("esac") && !found) || | 160 | if((foundCase && line.contains("esac") && !found) || |
161 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ | 161 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ |
162 | // write out scheme | 162 | // write out scheme |
163 | found = true; | 163 | found = true; |
164 | output = false; | 164 | output = false; |
165 | 165 | ||
166 | if(!line.contains("esac")) | 166 | if(!line.contains("esac")) |
167 | stream << line << "\n"; | 167 | stream << line << "\n"; |
168 | 168 | ||
169 | stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; | 169 | stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; |
170 | stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "AdHoc") << '\n'; | 170 | stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "AdHoc") << '\n'; |
171 | if(!wepEnabled->isChecked()) | 171 | if(!wepEnabled->isChecked()) |
172 | stream << "#"; | 172 | stream << "#"; |
173 | stream << "\tKEY="; | 173 | stream << "\tKEY="; |
174 | stream << keyLineEdit0->text() << " [1]"; | 174 | stream << keyLineEdit0->text() << " [1]"; |
175 | stream << keyLineEdit1->text() << " [2]"; | 175 | stream << keyLineEdit1->text() << " [2]"; |
176 | stream << keyLineEdit2->text() << " [3]"; | 176 | stream << keyLineEdit2->text() << " [3]"; |
177 | stream << keyLineEdit3->text() << " [4]"; | 177 | stream << keyLineEdit3->text() << " [4]"; |
178 | stream << " key ["; | 178 | stream << " key ["; |
179 | if(keyRadio0->isChecked()) stream << "1]"; | 179 | if(keyRadio0->isChecked()) stream << "1]"; |
180 | if(keyRadio1->isChecked()) stream << "2]"; | 180 | if(keyRadio1->isChecked()) stream << "2]"; |
181 | if(keyRadio2->isChecked()) stream << "3]"; | 181 | if(keyRadio2->isChecked()) stream << "3]"; |
182 | if(keyRadio3->isChecked()) stream << "4]"; | 182 | if(keyRadio3->isChecked()) stream << "4]"; |
183 | if(authOpen->isChecked()) stream << " open"; | 183 | if(authOpen->isChecked()) stream << " open"; |
184 | stream << "\n"; | 184 | stream << "\n"; |
185 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | 185 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; |
186 | stream << "\tRATE=auto\n"; | 186 | stream << "\tRATE=auto\n"; |
187 | if(line.contains("esac")) | 187 | if(line.contains("esac")) |
188 | stream << line << "\n"; | 188 | stream << line << "\n"; |
189 | } | 189 | } |
190 | if(line.contains(";;")) | 190 | if(line.contains(";;")) |
191 | output = true; | 191 | output = true; |
192 | if(output) | 192 | if(output) |
193 | stream << (*it) << '\n'; | 193 | stream << (*it) << '\n'; |
194 | } | 194 | } |
195 | file.close(); | 195 | file.close(); |
196 | } | 196 | } |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Check to see if the current config is valid | 199 | * Check to see if the current config is valid |
200 | * Save wireless.opts, save interfaces | 200 | * Save wireless.opts, save interfaces |
201 | */ | 201 | */ |
202 | void WLANImp::accept(){ | 202 | void WLANImp::accept(){ |
203 | printf( "Accept pressed\n" ); | ||
203 | if(wepEnabled->isChecked()){ | 204 | if(wepEnabled->isChecked()){ |
204 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) | 205 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) |
205 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); | 206 | { |
206 | return; | 207 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); |
208 | return; | ||
209 | } | ||
207 | } | 210 | } |
208 | 211 | ||
209 | // Ok settings are good here, save | 212 | // Ok settings are good here, save |
210 | changeAndSaveSettingFile(); | 213 | changeAndSaveSettingFile(); |
211 | 214 | ||
212 | // Try to save the interfaces settings. | 215 | // Try to save the interfaces settings. |
213 | if(!interfaceSetup->saveChanges()) | 216 | if(!interfaceSetup->saveChanges()) |
214 | return; | 217 | return; |
215 | 218 | ||
216 | // Restart the device now that the settings have changed | 219 | // Restart the device now that the settings have changed |
217 | QString initpath; | 220 | QString initpath; |
218 | if( QDir("/etc/rc.d/init.d").exists() ) | 221 | if( QDir("/etc/rc.d/init.d").exists() ) |
219 | initpath = "/etc/rc.d/init.d"; | 222 | initpath = "/etc/rc.d/init.d"; |
220 | else if( QDir("/etc/init.d").exists() ) | 223 | else if( QDir("/etc/init.d").exists() ) |
221 | initpath = "/etc/init.d"; | 224 | initpath = "/etc/init.d"; |
222 | if( initpath ) | 225 | if( initpath ) |
223 | system(QString("%1/pcmcia stop").arg(initpath)); | 226 | system(QString("%1/pcmcia stop").arg(initpath)); |
224 | if( initpath ) | 227 | if( initpath ) |
225 | system(QString("%1/pcmcia start").arg(initpath)); | 228 | system(QString("%1/pcmcia start").arg(initpath)); |
226 | 229 | ||
227 | // Close out the dialog | 230 | // Close out the dialog |
228 | QDialog::accept(); | 231 | QDialog::accept(); |
229 | } | 232 | } |
230 | 233 | ||
231 | // wlanimp.cpp | 234 | // wlanimp.cpp |
232 | 235 | ||