author | benmeyer <benmeyer> | 2002-11-22 20:57:18 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-11-22 20:57:18 (UTC) |
commit | 575f126fe474ba1d1603de73088c342c2a3eaa8f (patch) (unidiff) | |
tree | 382d804a7c29d664fa6f864663201b736270feaa | |
parent | 6632eb593cc9ac17a4b01efb7a5145c4e7efaaa4 (diff) | |
download | opie-575f126fe474ba1d1603de73088c342c2a3eaa8f.zip opie-575f126fe474ba1d1603de73088c342c2a3eaa8f.tar.gz opie-575f126fe474ba1d1603de73088c342c2a3eaa8f.tar.bz2 |
Remove return
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 44c721a..6a56358 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -1,229 +1,227 @@ | |||
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 <qspinbox.h> | 9 | #include <qspinbox.h> |
10 | #include <qradiobutton.h> | 10 | #include <qradiobutton.h> |
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("KEY0=")) | 93 | if(line.contains("KEY0=")) |
94 | keyLineEdit0->setText(line.mid(5, line.length())); | 94 | keyLineEdit0->setText(line.mid(5, line.length())); |
95 | if(line.contains("KEY1=")) | 95 | if(line.contains("KEY1=")) |
96 | keyLineEdit1->setText(line.mid(5, line.length())); | 96 | keyLineEdit1->setText(line.mid(5, line.length())); |
97 | if(line.contains("KEY2=")) | 97 | if(line.contains("KEY2=")) |
98 | keyLineEdit2->setText(line.mid(5, line.length())); | 98 | keyLineEdit2->setText(line.mid(5, line.length())); |
99 | if(line.contains("KEY3=")) | 99 | if(line.contains("KEY3=")) |
100 | keyLineEdit3->setText(line.mid(5, line.length())); | 100 | keyLineEdit3->setText(line.mid(5, line.length())); |
101 | 101 | ||
102 | if(line.contains("KEY=")){ | 102 | if(line.contains("KEY=")){ |
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 | */ |
130 | void WLANImp::changeAndSaveSettingFile(){ | 130 | void 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()) | 172 | if(authOpen->isChecked()) |
173 | stream << " open"; | 173 | stream << " open"; |
174 | else | 174 | else |
175 | stream << " restricted"; | 175 | stream << " restricted"; |
176 | stream << "\n\""; | 176 | stream << "\"\n"; |
177 | } | 177 | } |
178 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | 178 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; |
179 | stream << "\tRATE=auto\n"; | 179 | stream << "\tRATE=auto\n"; |
180 | if(line.contains("esac")) | 180 | if(line.contains("esac")) |
181 | stream << line << "\n"; | 181 | stream << line << "\n"; |
182 | } | 182 | } |
183 | if(line.contains(";;")) | 183 | if(line.contains(";;")) |
184 | output = true; | 184 | output = true; |
185 | if(output) | 185 | if(output && (*it).length() ) |
186 | stream << (*it) << '\n'; | 186 | stream << (*it) << '\n'; |
187 | } | 187 | } |
188 | file.close(); | 188 | file.close(); |
189 | } | 189 | } |
190 | 190 | ||
191 | /** | 191 | /** |
192 | * Check to see if the current config is valid | 192 | * Check to see if the current config is valid |
193 | * Save wireless.opts, save interfaces | 193 | * Save wireless.opts, save interfaces |
194 | */ | 194 | */ |
195 | void WLANImp::accept(){ | 195 | void WLANImp::accept(){ |
196 | if(wepEnabled->isChecked()){ | 196 | if(wepEnabled->isChecked()){ |
197 | 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() ) |
198 | { | 198 | { |
199 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); | 199 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); |
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | // Ok settings are good here, save | 204 | // Ok settings are good here, save |
205 | changeAndSaveSettingFile(); | 205 | changeAndSaveSettingFile(); |
206 | 206 | ||
207 | // Try to save the interfaces settings. | 207 | // Try to save the interfaces settings. |
208 | if(!interfaceSetup->saveChanges()) | 208 | if(!interfaceSetup->saveChanges()) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | QDialog::accept(); | ||
212 | return; | ||
213 | // Restart the device now that the settings have changed | 211 | // Restart the device now that the settings have changed |
214 | QString initpath; | 212 | QString initpath; |
215 | if( QDir("/etc/rc.d/init.d").exists() ) | 213 | if( QDir("/etc/rc.d/init.d").exists() ) |
216 | initpath = "/etc/rc.d/init.d"; | 214 | initpath = "/etc/rc.d/init.d"; |
217 | else if( QDir("/etc/init.d").exists() ) | 215 | else if( QDir("/etc/init.d").exists() ) |
218 | initpath = "/etc/init.d"; | 216 | initpath = "/etc/init.d"; |
219 | if( initpath ) | 217 | if( initpath ) |
220 | system(QString("%1/pcmcia stop").arg(initpath)); | 218 | system(QString("%1/pcmcia stop").arg(initpath)); |
221 | if( initpath ) | 219 | if( initpath ) |
222 | system(QString("%1/pcmcia start").arg(initpath)); | 220 | system(QString("%1/pcmcia start").arg(initpath)); |
223 | 221 | ||
224 | // Close out the dialog | 222 | // Close out the dialog |
225 | QDialog::accept(); | 223 | QDialog::accept(); |
226 | } | 224 | } |
227 | 225 | ||
228 | // wlanimp.cpp | 226 | // wlanimp.cpp |
229 | 227 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 44c721a..6a56358 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -1,229 +1,227 @@ | |||
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 <qspinbox.h> | 9 | #include <qspinbox.h> |
10 | #include <qradiobutton.h> | 10 | #include <qradiobutton.h> |
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("KEY0=")) | 93 | if(line.contains("KEY0=")) |
94 | keyLineEdit0->setText(line.mid(5, line.length())); | 94 | keyLineEdit0->setText(line.mid(5, line.length())); |
95 | if(line.contains("KEY1=")) | 95 | if(line.contains("KEY1=")) |
96 | keyLineEdit1->setText(line.mid(5, line.length())); | 96 | keyLineEdit1->setText(line.mid(5, line.length())); |
97 | if(line.contains("KEY2=")) | 97 | if(line.contains("KEY2=")) |
98 | keyLineEdit2->setText(line.mid(5, line.length())); | 98 | keyLineEdit2->setText(line.mid(5, line.length())); |
99 | if(line.contains("KEY3=")) | 99 | if(line.contains("KEY3=")) |
100 | keyLineEdit3->setText(line.mid(5, line.length())); | 100 | keyLineEdit3->setText(line.mid(5, line.length())); |
101 | 101 | ||
102 | if(line.contains("KEY=")){ | 102 | if(line.contains("KEY=")){ |
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 | */ |
130 | void WLANImp::changeAndSaveSettingFile(){ | 130 | void 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()) | 172 | if(authOpen->isChecked()) |
173 | stream << " open"; | 173 | stream << " open"; |
174 | else | 174 | else |
175 | stream << " restricted"; | 175 | stream << " restricted"; |
176 | stream << "\n\""; | 176 | stream << "\"\n"; |
177 | } | 177 | } |
178 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | 178 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; |
179 | stream << "\tRATE=auto\n"; | 179 | stream << "\tRATE=auto\n"; |
180 | if(line.contains("esac")) | 180 | if(line.contains("esac")) |
181 | stream << line << "\n"; | 181 | stream << line << "\n"; |
182 | } | 182 | } |
183 | if(line.contains(";;")) | 183 | if(line.contains(";;")) |
184 | output = true; | 184 | output = true; |
185 | if(output) | 185 | if(output && (*it).length() ) |
186 | stream << (*it) << '\n'; | 186 | stream << (*it) << '\n'; |
187 | } | 187 | } |
188 | file.close(); | 188 | file.close(); |
189 | } | 189 | } |
190 | 190 | ||
191 | /** | 191 | /** |
192 | * Check to see if the current config is valid | 192 | * Check to see if the current config is valid |
193 | * Save wireless.opts, save interfaces | 193 | * Save wireless.opts, save interfaces |
194 | */ | 194 | */ |
195 | void WLANImp::accept(){ | 195 | void WLANImp::accept(){ |
196 | if(wepEnabled->isChecked()){ | 196 | if(wepEnabled->isChecked()){ |
197 | 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() ) |
198 | { | 198 | { |
199 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); | 199 | QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); |
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | // Ok settings are good here, save | 204 | // Ok settings are good here, save |
205 | changeAndSaveSettingFile(); | 205 | changeAndSaveSettingFile(); |
206 | 206 | ||
207 | // Try to save the interfaces settings. | 207 | // Try to save the interfaces settings. |
208 | if(!interfaceSetup->saveChanges()) | 208 | if(!interfaceSetup->saveChanges()) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | QDialog::accept(); | ||
212 | return; | ||
213 | // Restart the device now that the settings have changed | 211 | // Restart the device now that the settings have changed |
214 | QString initpath; | 212 | QString initpath; |
215 | if( QDir("/etc/rc.d/init.d").exists() ) | 213 | if( QDir("/etc/rc.d/init.d").exists() ) |
216 | initpath = "/etc/rc.d/init.d"; | 214 | initpath = "/etc/rc.d/init.d"; |
217 | else if( QDir("/etc/init.d").exists() ) | 215 | else if( QDir("/etc/init.d").exists() ) |
218 | initpath = "/etc/init.d"; | 216 | initpath = "/etc/init.d"; |
219 | if( initpath ) | 217 | if( initpath ) |
220 | system(QString("%1/pcmcia stop").arg(initpath)); | 218 | system(QString("%1/pcmcia stop").arg(initpath)); |
221 | if( initpath ) | 219 | if( initpath ) |
222 | system(QString("%1/pcmcia start").arg(initpath)); | 220 | system(QString("%1/pcmcia start").arg(initpath)); |
223 | 221 | ||
224 | // Close out the dialog | 222 | // Close out the dialog |
225 | QDialog::accept(); | 223 | QDialog::accept(); |
226 | } | 224 | } |
227 | 225 | ||
228 | // wlanimp.cpp | 226 | // wlanimp.cpp |
229 | 227 | ||