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