author | benmeyer <benmeyer> | 2002-10-28 19:54:38 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-28 19:54:38 (UTC) |
commit | e9d8023028b7c996d8ff2a68b87dfde19fcfa892 (patch) (unidiff) | |
tree | 08468bce6771710d32534291ad6e9333f8879490 | |
parent | 0abe89f1b470f94f25f3ab5bb3a9fbc7a0ec9d2f (diff) | |
download | opie-e9d8023028b7c996d8ff2a68b87dfde19fcfa892.zip opie-e9d8023028b7c996d8ff2a68b87dfde19fcfa892.tar.gz opie-e9d8023028b7c996d8ff2a68b87dfde19fcfa892.tar.bz2 |
removed return statment that shouldn't be there
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 1 |
2 files changed, 0 insertions, 2 deletions
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 7c902e0..a466020 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -1,244 +1,243 @@ | |||
1 | #include "wlanimp.h" | 1 | #include "wlanimp.h" |
2 | 2 | ||
3 | /* Config class */ | 3 | /* Config class */ |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | /* Global namespace */ | 5 | /* Global namespace */ |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | /* system() */ | 7 | /* system() */ |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qradiobutton.h> | 15 | #include <qradiobutton.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qregexp.h> | 17 | #include <qregexp.h> |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qtabwidget.h> | 19 | #include <qtabwidget.h> |
20 | #include "interfacesetupimp.h" | 20 | #include "interfacesetupimp.h" |
21 | 21 | ||
22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ | 22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ |
23 | config = new Config("wireless"); | 23 | config = new Config("wireless"); |
24 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); | 24 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); |
25 | //configure->setProfile(currentProfile); | 25 | //configure->setProfile(currentProfile); |
26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
27 | 27 | ||
28 | readConfig(); | 28 | readConfig(); |
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | WLANImp::~WLANImp( ){ | 32 | WLANImp::~WLANImp( ){ |
33 | delete config; | 33 | delete config; |
34 | } | 34 | } |
35 | 35 | ||
36 | void WLANImp::readConfig() | 36 | void WLANImp::readConfig() |
37 | { | 37 | { |
38 | qWarning( "WLANImp::readConfig() called." ); | 38 | qWarning( "WLANImp::readConfig() called." ); |
39 | config->setGroup( "Properties" ); | 39 | config->setGroup( "Properties" ); |
40 | QString ssid = config->readEntry( "SSID", "any" ); | 40 | QString ssid = config->readEntry( "SSID", "any" ); |
41 | if( ssid == "any" || ssid == "ANY" ){ | 41 | if( ssid == "any" || ssid == "ANY" ){ |
42 | essNon->setChecked( true ); | 42 | essNon->setChecked( true ); |
43 | } else { | 43 | } else { |
44 | essSpecific->setChecked( true ); | 44 | essSpecific->setChecked( true ); |
45 | essSpecificLineEdit->setText( ssid ); | 45 | essSpecificLineEdit->setText( ssid ); |
46 | } | 46 | } |
47 | QString mode = config->readEntry( "Mode", "Managed" ); | 47 | QString mode = config->readEntry( "Mode", "Managed" ); |
48 | if( mode == "adhoc" ) { | 48 | if( mode == "adhoc" ) { |
49 | network802->setChecked( true ); | 49 | network802->setChecked( true ); |
50 | } else { | 50 | } else { |
51 | networkInfrastructure->setChecked( true ); | 51 | networkInfrastructure->setChecked( true ); |
52 | } | 52 | } |
53 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); | 53 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
54 | // config->readEntry( "RATE", "auto" ); | 54 | // config->readEntry( "RATE", "auto" ); |
55 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 55 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
56 | config->readEntry( "AuthType", "opensystem" ); | 56 | config->readEntry( "AuthType", "opensystem" ); |
57 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 57 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
58 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 58 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
59 | switch( defaultkey ){ | 59 | switch( defaultkey ){ |
60 | case 0: | 60 | case 0: |
61 | keyRadio0->setChecked( true ); | 61 | keyRadio0->setChecked( true ); |
62 | break; | 62 | break; |
63 | case 1: | 63 | case 1: |
64 | keyRadio1->setChecked( true ); | 64 | keyRadio1->setChecked( true ); |
65 | break; | 65 | break; |
66 | case 2: | 66 | case 2: |
67 | keyRadio2->setChecked( true ); | 67 | keyRadio2->setChecked( true ); |
68 | break; | 68 | break; |
69 | case 3: | 69 | case 3: |
70 | keyRadio3->setChecked( true ); | 70 | keyRadio3->setChecked( true ); |
71 | break; | 71 | break; |
72 | } | 72 | } |
73 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); | 73 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
74 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); | 74 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
75 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); | 75 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
76 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); | 76 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
77 | return; | 77 | return; |
78 | } | 78 | } |
79 | 79 | ||
80 | bool WLANImp::writeConfig() | 80 | bool WLANImp::writeConfig() |
81 | { | 81 | { |
82 | qWarning( "WLANImp::writeConfig() called." ); | 82 | qWarning( "WLANImp::writeConfig() called." ); |
83 | config->setGroup( "Properties" ); | 83 | config->setGroup( "Properties" ); |
84 | if( essNon->isChecked() ) { | 84 | if( essNon->isChecked() ) { |
85 | config->writeEntry( "SSID", "any" ); | 85 | config->writeEntry( "SSID", "any" ); |
86 | } else { | 86 | } else { |
87 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); | 87 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
88 | } | 88 | } |
89 | if( networkInfrastructure->isChecked() ){ | 89 | if( networkInfrastructure->isChecked() ){ |
90 | config->writeEntry( "Mode", "Managed" ); | 90 | config->writeEntry( "Mode", "Managed" ); |
91 | } else if( network802->isChecked() ){ | 91 | } else if( network802->isChecked() ){ |
92 | config->writeEntry( "Mode", "adhoc" ); | 92 | config->writeEntry( "Mode", "adhoc" ); |
93 | } | 93 | } |
94 | config->writeEntry( "CHANNEL", networkChannel->value() ); | 94 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
95 | // config->readEntry( "RATE", "auto" ); | 95 | // config->readEntry( "RATE", "auto" ); |
96 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); | 96 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
97 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); | 97 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
98 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); | 98 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
99 | if( keyRadio0->isChecked() ){ | 99 | if( keyRadio0->isChecked() ){ |
100 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); | 100 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
101 | } else if( keyRadio1->isChecked() ){ | 101 | } else if( keyRadio1->isChecked() ){ |
102 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); | 102 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
103 | } else if( keyRadio2->isChecked() ){ | 103 | } else if( keyRadio2->isChecked() ){ |
104 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); | 104 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
105 | } else if( keyRadio3->isChecked() ){ | 105 | } else if( keyRadio3->isChecked() ){ |
106 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); | 106 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
107 | } | 107 | } |
108 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 108 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
109 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 109 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
110 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 110 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
111 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 111 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
112 | return true; | ||
113 | return writeWirelessOpts( ); | 112 | return writeWirelessOpts( ); |
114 | } | 113 | } |
115 | 114 | ||
116 | /** | 115 | /** |
117 | */ | 116 | */ |
118 | void WLANImp::accept() | 117 | void WLANImp::accept() |
119 | { | 118 | { |
120 | if ( writeConfig() ){ | 119 | if ( writeConfig() ){ |
121 | interfaceSetup->saveChanges(); | 120 | interfaceSetup->saveChanges(); |
122 | QDialog::accept(); | 121 | QDialog::accept(); |
123 | } | 122 | } |
124 | } | 123 | } |
125 | 124 | ||
126 | bool WLANImp::writeWirelessOpts( QString scheme ) | 125 | bool WLANImp::writeWirelessOpts( QString scheme ) |
127 | { | 126 | { |
128 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 127 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
129 | QString prev = "/etc/pcmcia/wireless.opts"; | 128 | QString prev = "/etc/pcmcia/wireless.opts"; |
130 | QFile prevFile(prev); | 129 | QFile prevFile(prev); |
131 | if ( !prevFile.open( IO_ReadOnly ) ) | 130 | if ( !prevFile.open( IO_ReadOnly ) ) |
132 | return false; | 131 | return false; |
133 | 132 | ||
134 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 133 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
135 | QFile tmpFile(tmp); | 134 | QFile tmpFile(tmp); |
136 | if ( !tmpFile.open( IO_WriteOnly ) ) | 135 | if ( !tmpFile.open( IO_WriteOnly ) ) |
137 | return false; | 136 | return false; |
138 | 137 | ||
139 | bool retval = true; | 138 | bool retval = true; |
140 | 139 | ||
141 | QTextStream in( &prevFile ); | 140 | QTextStream in( &prevFile ); |
142 | QTextStream out( &tmpFile ); | 141 | QTextStream out( &tmpFile ); |
143 | 142 | ||
144 | config->setGroup("Properties"); | 143 | config->setGroup("Properties"); |
145 | 144 | ||
146 | QString line; | 145 | QString line; |
147 | bool found=false; | 146 | bool found=false; |
148 | bool done=false; | 147 | bool done=false; |
149 | while ( !in.atEnd() ) { | 148 | while ( !in.atEnd() ) { |
150 | QString line = in.readLine(); | 149 | QString line = in.readLine(); |
151 | QString wline = line.simplifyWhiteSpace(); | 150 | QString wline = line.simplifyWhiteSpace(); |
152 | if ( !done ) { | 151 | if ( !done ) { |
153 | if ( found ) { | 152 | if ( found ) { |
154 | // skip existing entry for this scheme, and write our own. | 153 | // skip existing entry for this scheme, and write our own. |
155 | if ( wline == ";;" ) { | 154 | if ( wline == ";;" ) { |
156 | found = false; | 155 | found = false; |
157 | continue; | 156 | continue; |
158 | } else { | 157 | } else { |
159 | continue; | 158 | continue; |
160 | } | 159 | } |
161 | } else { | 160 | } else { |
162 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 161 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
163 | found=true; | 162 | found=true; |
164 | continue; // skip this line | 163 | continue; // skip this line |
165 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 164 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
166 | // end - add new entry | 165 | // end - add new entry |
167 | // Not all fields have a GUI, but all are supported | 166 | // Not all fields have a GUI, but all are supported |
168 | // in the letwork configuration files. | 167 | // in the letwork configuration files. |
169 | static const char* txtfields[] = { | 168 | static const char* txtfields[] = { |
170 | 0 | 169 | 0 |
171 | }; | 170 | }; |
172 | QString readmode = config->readEntry( "Mode", "Managed" ); | 171 | QString readmode = config->readEntry( "Mode", "Managed" ); |
173 | QString mode; | 172 | QString mode; |
174 | if( readmode == "Managed" ){ | 173 | if( readmode == "Managed" ){ |
175 | mode = readmode; | 174 | mode = readmode; |
176 | } else if( readmode == "adhoc" ){ | 175 | } else if( readmode == "adhoc" ){ |
177 | mode = "Ad-Hoc"; | 176 | mode = "Ad-Hoc"; |
178 | } | 177 | } |
179 | QString key; | 178 | QString key; |
180 | if( wepEnabled->isChecked() ){ | 179 | if( wepEnabled->isChecked() ){ |
181 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 180 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
182 | switch( defaultkey ){ | 181 | switch( defaultkey ){ |
183 | case 0: | 182 | case 0: |
184 | key += keyLineEdit0->text(); | 183 | key += keyLineEdit0->text(); |
185 | break; | 184 | break; |
186 | case 1: | 185 | case 1: |
187 | key += keyLineEdit1->text(); | 186 | key += keyLineEdit1->text(); |
188 | break; | 187 | break; |
189 | case 2: | 188 | case 2: |
190 | key += keyLineEdit2->text(); | 189 | key += keyLineEdit2->text(); |
191 | break; | 190 | break; |
192 | case 3: | 191 | case 3: |
193 | key += keyLineEdit3->text(); | 192 | key += keyLineEdit3->text(); |
194 | break; | 193 | break; |
195 | } | 194 | } |
196 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") | 195 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
197 | key += " open"; | 196 | key += " open"; |
198 | } | 197 | } |
199 | out << scheme << ",*,*,*)" << "\n" | 198 | out << scheme << ",*,*,*)" << "\n" |
200 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" | 199 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
201 | << " MODE=" << mode << "\n" | 200 | << " MODE=" << mode << "\n" |
202 | << " KEY=" << Global::shellQuote( key ) << "\n" | 201 | << " KEY=" << Global::shellQuote( key ) << "\n" |
203 | << " RATE=" << "auto" << "\n" | 202 | << " RATE=" << "auto" << "\n" |
204 | ; | 203 | ; |
205 | if( mode != "Managed" ) | 204 | if( mode != "Managed" ) |
206 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; | 205 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
207 | const char** f = txtfields; | 206 | const char** f = txtfields; |
208 | while (*f) { | 207 | while (*f) { |
209 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; | 208 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
210 | ++f; | 209 | ++f; |
211 | } | 210 | } |
212 | out << " ;;\n"; | 211 | out << " ;;\n"; |
213 | done = true; | 212 | done = true; |
214 | } | 213 | } |
215 | } | 214 | } |
216 | } | 215 | } |
217 | out << line << "\n"; | 216 | out << line << "\n"; |
218 | } | 217 | } |
219 | 218 | ||
220 | prevFile.close(); | 219 | prevFile.close(); |
221 | tmpFile.close(); | 220 | tmpFile.close(); |
222 | QString initpath; | 221 | QString initpath; |
223 | //system("cardctl suspend"); | 222 | //system("cardctl suspend"); |
224 | if( QDir("/etc/rc.d/init.d").exists() ){ | 223 | if( QDir("/etc/rc.d/init.d").exists() ){ |
225 | initpath = "/etc/rc.d/init.d"; | 224 | initpath = "/etc/rc.d/init.d"; |
226 | } else if( QDir("/etc/init.d").exists() ){ | 225 | } else if( QDir("/etc/init.d").exists() ){ |
227 | initpath = "/etc/init.d"; | 226 | initpath = "/etc/init.d"; |
228 | } | 227 | } |
229 | if( initpath ) | 228 | if( initpath ) |
230 | system(QString("%1/pcmcia stop").arg(initpath)); | 229 | system(QString("%1/pcmcia stop").arg(initpath)); |
231 | 230 | ||
232 | if( system( "mv " + tmp + " " + prev ) ) | 231 | if( system( "mv " + tmp + " " + prev ) ) |
233 | retval = false; | 232 | retval = false; |
234 | //#ifdef USE_SCHEMES | 233 | //#ifdef USE_SCHEMES |
235 | // if ( retval ) | 234 | // if ( retval ) |
236 | //SchemeChanger::changeScheme(scheme); | 235 | //SchemeChanger::changeScheme(scheme); |
237 | //#endif | 236 | //#endif |
238 | 237 | ||
239 | //system("cardctl resume"); | 238 | //system("cardctl resume"); |
240 | if( initpath ) | 239 | if( initpath ) |
241 | system(QString("%1/pcmcia start").arg(initpath)); | 240 | system(QString("%1/pcmcia start").arg(initpath)); |
242 | 241 | ||
243 | return retval; | 242 | return retval; |
244 | } | 243 | } |
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 7c902e0..a466020 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -1,244 +1,243 @@ | |||
1 | #include "wlanimp.h" | 1 | #include "wlanimp.h" |
2 | 2 | ||
3 | /* Config class */ | 3 | /* Config class */ |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | /* Global namespace */ | 5 | /* Global namespace */ |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | /* system() */ | 7 | /* system() */ |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qradiobutton.h> | 15 | #include <qradiobutton.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qregexp.h> | 17 | #include <qregexp.h> |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qtabwidget.h> | 19 | #include <qtabwidget.h> |
20 | #include "interfacesetupimp.h" | 20 | #include "interfacesetupimp.h" |
21 | 21 | ||
22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ | 22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ |
23 | config = new Config("wireless"); | 23 | config = new Config("wireless"); |
24 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); | 24 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); |
25 | //configure->setProfile(currentProfile); | 25 | //configure->setProfile(currentProfile); |
26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
27 | 27 | ||
28 | readConfig(); | 28 | readConfig(); |
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | WLANImp::~WLANImp( ){ | 32 | WLANImp::~WLANImp( ){ |
33 | delete config; | 33 | delete config; |
34 | } | 34 | } |
35 | 35 | ||
36 | void WLANImp::readConfig() | 36 | void WLANImp::readConfig() |
37 | { | 37 | { |
38 | qWarning( "WLANImp::readConfig() called." ); | 38 | qWarning( "WLANImp::readConfig() called." ); |
39 | config->setGroup( "Properties" ); | 39 | config->setGroup( "Properties" ); |
40 | QString ssid = config->readEntry( "SSID", "any" ); | 40 | QString ssid = config->readEntry( "SSID", "any" ); |
41 | if( ssid == "any" || ssid == "ANY" ){ | 41 | if( ssid == "any" || ssid == "ANY" ){ |
42 | essNon->setChecked( true ); | 42 | essNon->setChecked( true ); |
43 | } else { | 43 | } else { |
44 | essSpecific->setChecked( true ); | 44 | essSpecific->setChecked( true ); |
45 | essSpecificLineEdit->setText( ssid ); | 45 | essSpecificLineEdit->setText( ssid ); |
46 | } | 46 | } |
47 | QString mode = config->readEntry( "Mode", "Managed" ); | 47 | QString mode = config->readEntry( "Mode", "Managed" ); |
48 | if( mode == "adhoc" ) { | 48 | if( mode == "adhoc" ) { |
49 | network802->setChecked( true ); | 49 | network802->setChecked( true ); |
50 | } else { | 50 | } else { |
51 | networkInfrastructure->setChecked( true ); | 51 | networkInfrastructure->setChecked( true ); |
52 | } | 52 | } |
53 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); | 53 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
54 | // config->readEntry( "RATE", "auto" ); | 54 | // config->readEntry( "RATE", "auto" ); |
55 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 55 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
56 | config->readEntry( "AuthType", "opensystem" ); | 56 | config->readEntry( "AuthType", "opensystem" ); |
57 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 57 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
58 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 58 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
59 | switch( defaultkey ){ | 59 | switch( defaultkey ){ |
60 | case 0: | 60 | case 0: |
61 | keyRadio0->setChecked( true ); | 61 | keyRadio0->setChecked( true ); |
62 | break; | 62 | break; |
63 | case 1: | 63 | case 1: |
64 | keyRadio1->setChecked( true ); | 64 | keyRadio1->setChecked( true ); |
65 | break; | 65 | break; |
66 | case 2: | 66 | case 2: |
67 | keyRadio2->setChecked( true ); | 67 | keyRadio2->setChecked( true ); |
68 | break; | 68 | break; |
69 | case 3: | 69 | case 3: |
70 | keyRadio3->setChecked( true ); | 70 | keyRadio3->setChecked( true ); |
71 | break; | 71 | break; |
72 | } | 72 | } |
73 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); | 73 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
74 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); | 74 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
75 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); | 75 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
76 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); | 76 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
77 | return; | 77 | return; |
78 | } | 78 | } |
79 | 79 | ||
80 | bool WLANImp::writeConfig() | 80 | bool WLANImp::writeConfig() |
81 | { | 81 | { |
82 | qWarning( "WLANImp::writeConfig() called." ); | 82 | qWarning( "WLANImp::writeConfig() called." ); |
83 | config->setGroup( "Properties" ); | 83 | config->setGroup( "Properties" ); |
84 | if( essNon->isChecked() ) { | 84 | if( essNon->isChecked() ) { |
85 | config->writeEntry( "SSID", "any" ); | 85 | config->writeEntry( "SSID", "any" ); |
86 | } else { | 86 | } else { |
87 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); | 87 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
88 | } | 88 | } |
89 | if( networkInfrastructure->isChecked() ){ | 89 | if( networkInfrastructure->isChecked() ){ |
90 | config->writeEntry( "Mode", "Managed" ); | 90 | config->writeEntry( "Mode", "Managed" ); |
91 | } else if( network802->isChecked() ){ | 91 | } else if( network802->isChecked() ){ |
92 | config->writeEntry( "Mode", "adhoc" ); | 92 | config->writeEntry( "Mode", "adhoc" ); |
93 | } | 93 | } |
94 | config->writeEntry( "CHANNEL", networkChannel->value() ); | 94 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
95 | // config->readEntry( "RATE", "auto" ); | 95 | // config->readEntry( "RATE", "auto" ); |
96 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); | 96 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
97 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); | 97 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
98 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); | 98 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
99 | if( keyRadio0->isChecked() ){ | 99 | if( keyRadio0->isChecked() ){ |
100 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); | 100 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
101 | } else if( keyRadio1->isChecked() ){ | 101 | } else if( keyRadio1->isChecked() ){ |
102 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); | 102 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
103 | } else if( keyRadio2->isChecked() ){ | 103 | } else if( keyRadio2->isChecked() ){ |
104 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); | 104 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
105 | } else if( keyRadio3->isChecked() ){ | 105 | } else if( keyRadio3->isChecked() ){ |
106 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); | 106 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
107 | } | 107 | } |
108 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 108 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
109 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 109 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
110 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 110 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
111 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 111 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
112 | return true; | ||
113 | return writeWirelessOpts( ); | 112 | return writeWirelessOpts( ); |
114 | } | 113 | } |
115 | 114 | ||
116 | /** | 115 | /** |
117 | */ | 116 | */ |
118 | void WLANImp::accept() | 117 | void WLANImp::accept() |
119 | { | 118 | { |
120 | if ( writeConfig() ){ | 119 | if ( writeConfig() ){ |
121 | interfaceSetup->saveChanges(); | 120 | interfaceSetup->saveChanges(); |
122 | QDialog::accept(); | 121 | QDialog::accept(); |
123 | } | 122 | } |
124 | } | 123 | } |
125 | 124 | ||
126 | bool WLANImp::writeWirelessOpts( QString scheme ) | 125 | bool WLANImp::writeWirelessOpts( QString scheme ) |
127 | { | 126 | { |
128 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 127 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
129 | QString prev = "/etc/pcmcia/wireless.opts"; | 128 | QString prev = "/etc/pcmcia/wireless.opts"; |
130 | QFile prevFile(prev); | 129 | QFile prevFile(prev); |
131 | if ( !prevFile.open( IO_ReadOnly ) ) | 130 | if ( !prevFile.open( IO_ReadOnly ) ) |
132 | return false; | 131 | return false; |
133 | 132 | ||
134 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 133 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
135 | QFile tmpFile(tmp); | 134 | QFile tmpFile(tmp); |
136 | if ( !tmpFile.open( IO_WriteOnly ) ) | 135 | if ( !tmpFile.open( IO_WriteOnly ) ) |
137 | return false; | 136 | return false; |
138 | 137 | ||
139 | bool retval = true; | 138 | bool retval = true; |
140 | 139 | ||
141 | QTextStream in( &prevFile ); | 140 | QTextStream in( &prevFile ); |
142 | QTextStream out( &tmpFile ); | 141 | QTextStream out( &tmpFile ); |
143 | 142 | ||
144 | config->setGroup("Properties"); | 143 | config->setGroup("Properties"); |
145 | 144 | ||
146 | QString line; | 145 | QString line; |
147 | bool found=false; | 146 | bool found=false; |
148 | bool done=false; | 147 | bool done=false; |
149 | while ( !in.atEnd() ) { | 148 | while ( !in.atEnd() ) { |
150 | QString line = in.readLine(); | 149 | QString line = in.readLine(); |
151 | QString wline = line.simplifyWhiteSpace(); | 150 | QString wline = line.simplifyWhiteSpace(); |
152 | if ( !done ) { | 151 | if ( !done ) { |
153 | if ( found ) { | 152 | if ( found ) { |
154 | // skip existing entry for this scheme, and write our own. | 153 | // skip existing entry for this scheme, and write our own. |
155 | if ( wline == ";;" ) { | 154 | if ( wline == ";;" ) { |
156 | found = false; | 155 | found = false; |
157 | continue; | 156 | continue; |
158 | } else { | 157 | } else { |
159 | continue; | 158 | continue; |
160 | } | 159 | } |
161 | } else { | 160 | } else { |
162 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 161 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
163 | found=true; | 162 | found=true; |
164 | continue; // skip this line | 163 | continue; // skip this line |
165 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 164 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
166 | // end - add new entry | 165 | // end - add new entry |
167 | // Not all fields have a GUI, but all are supported | 166 | // Not all fields have a GUI, but all are supported |
168 | // in the letwork configuration files. | 167 | // in the letwork configuration files. |
169 | static const char* txtfields[] = { | 168 | static const char* txtfields[] = { |
170 | 0 | 169 | 0 |
171 | }; | 170 | }; |
172 | QString readmode = config->readEntry( "Mode", "Managed" ); | 171 | QString readmode = config->readEntry( "Mode", "Managed" ); |
173 | QString mode; | 172 | QString mode; |
174 | if( readmode == "Managed" ){ | 173 | if( readmode == "Managed" ){ |
175 | mode = readmode; | 174 | mode = readmode; |
176 | } else if( readmode == "adhoc" ){ | 175 | } else if( readmode == "adhoc" ){ |
177 | mode = "Ad-Hoc"; | 176 | mode = "Ad-Hoc"; |
178 | } | 177 | } |
179 | QString key; | 178 | QString key; |
180 | if( wepEnabled->isChecked() ){ | 179 | if( wepEnabled->isChecked() ){ |
181 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 180 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
182 | switch( defaultkey ){ | 181 | switch( defaultkey ){ |
183 | case 0: | 182 | case 0: |
184 | key += keyLineEdit0->text(); | 183 | key += keyLineEdit0->text(); |
185 | break; | 184 | break; |
186 | case 1: | 185 | case 1: |
187 | key += keyLineEdit1->text(); | 186 | key += keyLineEdit1->text(); |
188 | break; | 187 | break; |
189 | case 2: | 188 | case 2: |
190 | key += keyLineEdit2->text(); | 189 | key += keyLineEdit2->text(); |
191 | break; | 190 | break; |
192 | case 3: | 191 | case 3: |
193 | key += keyLineEdit3->text(); | 192 | key += keyLineEdit3->text(); |
194 | break; | 193 | break; |
195 | } | 194 | } |
196 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") | 195 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
197 | key += " open"; | 196 | key += " open"; |
198 | } | 197 | } |
199 | out << scheme << ",*,*,*)" << "\n" | 198 | out << scheme << ",*,*,*)" << "\n" |
200 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" | 199 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
201 | << " MODE=" << mode << "\n" | 200 | << " MODE=" << mode << "\n" |
202 | << " KEY=" << Global::shellQuote( key ) << "\n" | 201 | << " KEY=" << Global::shellQuote( key ) << "\n" |
203 | << " RATE=" << "auto" << "\n" | 202 | << " RATE=" << "auto" << "\n" |
204 | ; | 203 | ; |
205 | if( mode != "Managed" ) | 204 | if( mode != "Managed" ) |
206 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; | 205 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
207 | const char** f = txtfields; | 206 | const char** f = txtfields; |
208 | while (*f) { | 207 | while (*f) { |
209 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; | 208 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
210 | ++f; | 209 | ++f; |
211 | } | 210 | } |
212 | out << " ;;\n"; | 211 | out << " ;;\n"; |
213 | done = true; | 212 | done = true; |
214 | } | 213 | } |
215 | } | 214 | } |
216 | } | 215 | } |
217 | out << line << "\n"; | 216 | out << line << "\n"; |
218 | } | 217 | } |
219 | 218 | ||
220 | prevFile.close(); | 219 | prevFile.close(); |
221 | tmpFile.close(); | 220 | tmpFile.close(); |
222 | QString initpath; | 221 | QString initpath; |
223 | //system("cardctl suspend"); | 222 | //system("cardctl suspend"); |
224 | if( QDir("/etc/rc.d/init.d").exists() ){ | 223 | if( QDir("/etc/rc.d/init.d").exists() ){ |
225 | initpath = "/etc/rc.d/init.d"; | 224 | initpath = "/etc/rc.d/init.d"; |
226 | } else if( QDir("/etc/init.d").exists() ){ | 225 | } else if( QDir("/etc/init.d").exists() ){ |
227 | initpath = "/etc/init.d"; | 226 | initpath = "/etc/init.d"; |
228 | } | 227 | } |
229 | if( initpath ) | 228 | if( initpath ) |
230 | system(QString("%1/pcmcia stop").arg(initpath)); | 229 | system(QString("%1/pcmcia stop").arg(initpath)); |
231 | 230 | ||
232 | if( system( "mv " + tmp + " " + prev ) ) | 231 | if( system( "mv " + tmp + " " + prev ) ) |
233 | retval = false; | 232 | retval = false; |
234 | //#ifdef USE_SCHEMES | 233 | //#ifdef USE_SCHEMES |
235 | // if ( retval ) | 234 | // if ( retval ) |
236 | //SchemeChanger::changeScheme(scheme); | 235 | //SchemeChanger::changeScheme(scheme); |
237 | //#endif | 236 | //#endif |
238 | 237 | ||
239 | //system("cardctl resume"); | 238 | //system("cardctl resume"); |
240 | if( initpath ) | 239 | if( initpath ) |
241 | system(QString("%1/pcmcia start").arg(initpath)); | 240 | system(QString("%1/pcmcia start").arg(initpath)); |
242 | 241 | ||
243 | return retval; | 242 | return retval; |
244 | } | 243 | } |