author | kergoth <kergoth> | 2002-10-19 20:58:09 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-10-19 20:58:09 (UTC) |
commit | d7449e1e0070a068c5e83366cb75b64142b71b89 (patch) (unidiff) | |
tree | 0049f8b29e274c2b973ac74ce8f8a93b8bc38a77 | |
parent | 8c9e2e893540c0a405637f10ac2f656df69991a7 (diff) | |
download | opie-d7449e1e0070a068c5e83366cb75b64142b71b89.zip opie-d7449e1e0070a068c5e83366cb75b64142b71b89.tar.gz opie-d7449e1e0070a068c5e83366cb75b64142b71b89.tar.bz2 |
Cleaned up Config handling a bit.
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 83 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.h | 10 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 83 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.h | 10 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 3 |
6 files changed, 96 insertions, 96 deletions
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 517604f..3b0e0b7 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -1,234 +1,235 @@ | |||
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 | ||
19 | WLANImp::WLANImp( Config &cfg, QWidget* parent, const char* name):WLAN(parent, name),config(cfg){ | 19 | WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name){ |
20 | config = new Config("wireless"); | ||
20 | readConfig(); | 21 | readConfig(); |
21 | } | 22 | } |
22 | 23 | ||
23 | void WLANImp::readConfig() | 24 | void WLANImp::readConfig() |
24 | { | 25 | { |
25 | qWarning( "WLANImp::readConfig() called." ); | 26 | qWarning( "WLANImp::readConfig() called." ); |
26 | config.setGroup( "Properties" ); | 27 | config->setGroup( "Properties" ); |
27 | QString ssid = config.readEntry( "SSID", "any" ); | 28 | QString ssid = config->readEntry( "SSID", "any" ); |
28 | if( ssid == "any" || ssid == "ANY" ){ | 29 | if( ssid == "any" || ssid == "ANY" ){ |
29 | essNon->setChecked( true ); | 30 | essNon->setChecked( true ); |
30 | } else { | 31 | } else { |
31 | essSpecific->setChecked( true ); | 32 | essSpecific->setChecked( true ); |
32 | essSpecificLineEdit->setText( ssid ); | 33 | essSpecificLineEdit->setText( ssid ); |
33 | } | 34 | } |
34 | QString mode = config.readEntry( "Mode", "Managed" ); | 35 | QString mode = config->readEntry( "Mode", "Managed" ); |
35 | if( mode == "adhoc" ) { | 36 | if( mode == "adhoc" ) { |
36 | network802->setChecked( true ); | 37 | network802->setChecked( true ); |
37 | } else { | 38 | } else { |
38 | networkInfrastructure->setChecked( true ); | 39 | networkInfrastructure->setChecked( true ); |
39 | } | 40 | } |
40 | networkChannel->setValue( config.readNumEntry( "CHANNEL", 1 ) ); | 41 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
41 | // config.readEntry( "RATE", "auto" ); | 42 | // config->readEntry( "RATE", "auto" ); |
42 | config.readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 43 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
43 | config.readEntry( "AuthType", "opensystem" ); | 44 | config->readEntry( "AuthType", "opensystem" ); |
44 | config.readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 45 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
45 | int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 46 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
46 | switch( defaultkey ){ | 47 | switch( defaultkey ){ |
47 | case 0: | 48 | case 0: |
48 | keyRadio0->setChecked( true ); | 49 | keyRadio0->setChecked( true ); |
49 | break; | 50 | break; |
50 | case 1: | 51 | case 1: |
51 | keyRadio1->setChecked( true ); | 52 | keyRadio1->setChecked( true ); |
52 | break; | 53 | break; |
53 | case 2: | 54 | case 2: |
54 | keyRadio2->setChecked( true ); | 55 | keyRadio2->setChecked( true ); |
55 | break; | 56 | break; |
56 | case 3: | 57 | case 3: |
57 | keyRadio3->setChecked( true ); | 58 | keyRadio3->setChecked( true ); |
58 | break; | 59 | break; |
59 | } | 60 | } |
60 | keyLineEdit0->setText(config.readEntry( "dot11WEPDefaultKey0" )); | 61 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
61 | keyLineEdit1->setText(config.readEntry( "dot11WEPDefaultKey1" )); | 62 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
62 | keyLineEdit2->setText(config.readEntry( "dot11WEPDefaultKey2" )); | 63 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
63 | keyLineEdit3->setText(config.readEntry( "dot11WEPDefaultKey3" )); | 64 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
64 | return; | 65 | return; |
65 | } | 66 | } |
66 | 67 | ||
67 | bool WLANImp::writeConfig() | 68 | bool WLANImp::writeConfig() |
68 | { | 69 | { |
69 | qWarning( "WLANImp::writeConfig() called." ); | 70 | qWarning( "WLANImp::writeConfig() called." ); |
70 | config.setGroup( "Properties" ); | 71 | config->setGroup( "Properties" ); |
71 | if( essNon->isChecked() ) { | 72 | if( essNon->isChecked() ) { |
72 | config.writeEntry( "SSID", "any" ); | 73 | config->writeEntry( "SSID", "any" ); |
73 | } else { | 74 | } else { |
74 | config.writeEntry( "SSID", essSpecificLineEdit->text() ); | 75 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
75 | } | 76 | } |
76 | if( networkInfrastructure->isChecked() ){ | 77 | if( networkInfrastructure->isChecked() ){ |
77 | config.writeEntry( "Mode", "Managed" ); | 78 | config->writeEntry( "Mode", "Managed" ); |
78 | } else if( network802->isChecked() ){ | 79 | } else if( network802->isChecked() ){ |
79 | config.writeEntry( "Mode", "adhoc" ); | 80 | config->writeEntry( "Mode", "adhoc" ); |
80 | } | 81 | } |
81 | config.writeEntry( "CHANNEL", networkChannel->value() ); | 82 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
82 | // config.readEntry( "RATE", "auto" ); | 83 | // config->readEntry( "RATE", "auto" ); |
83 | wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); | 84 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
84 | authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); | 85 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
85 | key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); | 86 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
86 | if( keyRadio0->isChecked() ){ | 87 | if( keyRadio0->isChecked() ){ |
87 | config.writeEntry( "dot11WEPDefaultKeyID", 0 ); | 88 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
88 | } else if( keyRadio1->isChecked() ){ | 89 | } else if( keyRadio1->isChecked() ){ |
89 | config.writeEntry( "dot11WEPDefaultKeyID", 1 ); | 90 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
90 | } else if( keyRadio2->isChecked() ){ | 91 | } else if( keyRadio2->isChecked() ){ |
91 | config.writeEntry( "dot11WEPDefaultKeyID", 2 ); | 92 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
92 | } else if( keyRadio3->isChecked() ){ | 93 | } else if( keyRadio3->isChecked() ){ |
93 | config.writeEntry( "dot11WEPDefaultKeyID", 3 ); | 94 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
94 | } | 95 | } |
95 | config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 96 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
96 | config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 97 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
97 | config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 98 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
98 | config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 99 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
99 | return writeWirelessOpts( config ); | 100 | return writeWirelessOpts( ); |
100 | } | 101 | } |
101 | 102 | ||
102 | /** | 103 | /** |
103 | */ | 104 | */ |
104 | void WLANImp::accept() | 105 | void WLANImp::accept() |
105 | { | 106 | { |
106 | if ( writeConfig() ) | 107 | if ( writeConfig() ) |
107 | QDialog::accept(); | 108 | QDialog::accept(); |
108 | } | 109 | } |
109 | 110 | ||
110 | void WLANImp::done ( int r ) | 111 | void WLANImp::done ( int r ) |
111 | { | 112 | { |
112 | QDialog::done ( r ); | 113 | QDialog::done ( r ); |
113 | close ( ); | 114 | close ( ); |
114 | } | 115 | } |
115 | 116 | ||
116 | bool WLANImp::writeWirelessOpts( Config &config, QString scheme ) | 117 | bool WLANImp::writeWirelessOpts( QString scheme ) |
117 | { | 118 | { |
118 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 119 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
119 | QString prev = "/etc/pcmcia/wireless.opts"; | 120 | QString prev = "/etc/pcmcia/wireless.opts"; |
120 | QFile prevFile(prev); | 121 | QFile prevFile(prev); |
121 | if ( !prevFile.open( IO_ReadOnly ) ) | 122 | if ( !prevFile.open( IO_ReadOnly ) ) |
122 | return false; | 123 | return false; |
123 | 124 | ||
124 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 125 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
125 | QFile tmpFile(tmp); | 126 | QFile tmpFile(tmp); |
126 | if ( !tmpFile.open( IO_WriteOnly ) ) | 127 | if ( !tmpFile.open( IO_WriteOnly ) ) |
127 | return false; | 128 | return false; |
128 | 129 | ||
129 | bool retval = true; | 130 | bool retval = true; |
130 | 131 | ||
131 | QTextStream in( &prevFile ); | 132 | QTextStream in( &prevFile ); |
132 | QTextStream out( &tmpFile ); | 133 | QTextStream out( &tmpFile ); |
133 | 134 | ||
134 | config.setGroup("Properties"); | 135 | config->setGroup("Properties"); |
135 | 136 | ||
136 | QString line; | 137 | QString line; |
137 | bool found=false; | 138 | bool found=false; |
138 | bool done=false; | 139 | bool done=false; |
139 | while ( !in.atEnd() ) { | 140 | while ( !in.atEnd() ) { |
140 | QString line = in.readLine(); | 141 | QString line = in.readLine(); |
141 | QString wline = line.simplifyWhiteSpace(); | 142 | QString wline = line.simplifyWhiteSpace(); |
142 | if ( !done ) { | 143 | if ( !done ) { |
143 | if ( found ) { | 144 | if ( found ) { |
144 | // skip existing entry for this scheme, and write our own. | 145 | // skip existing entry for this scheme, and write our own. |
145 | if ( wline == ";;" ) { | 146 | if ( wline == ";;" ) { |
146 | found = false; | 147 | found = false; |
147 | continue; | 148 | continue; |
148 | } else { | 149 | } else { |
149 | continue; | 150 | continue; |
150 | } | 151 | } |
151 | } else { | 152 | } else { |
152 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 153 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
153 | found=true; | 154 | found=true; |
154 | continue; // skip this line | 155 | continue; // skip this line |
155 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 156 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
156 | // end - add new entry | 157 | // end - add new entry |
157 | // Not all fields have a GUI, but all are supported | 158 | // Not all fields have a GUI, but all are supported |
158 | // in the letwork configuration files. | 159 | // in the letwork configuration files. |
159 | static const char* txtfields[] = { | 160 | static const char* txtfields[] = { |
160 | 0 | 161 | 0 |
161 | }; | 162 | }; |
162 | QString readmode = config.readEntry( "Mode", "Managed" ); | 163 | QString readmode = config->readEntry( "Mode", "Managed" ); |
163 | QString mode; | 164 | QString mode; |
164 | if( readmode == "Managed" ){ | 165 | if( readmode == "Managed" ){ |
165 | mode = readmode; | 166 | mode = readmode; |
166 | } else if( readmode == "adhoc" ){ | 167 | } else if( readmode == "adhoc" ){ |
167 | mode = "Ad-Hoc"; | 168 | mode = "Ad-Hoc"; |
168 | } | 169 | } |
169 | QString key; | 170 | QString key; |
170 | if( wepEnabled->isChecked() ){ | 171 | if( wepEnabled->isChecked() ){ |
171 | int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 172 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
172 | switch( defaultkey ){ | 173 | switch( defaultkey ){ |
173 | case 0: | 174 | case 0: |
174 | key += keyLineEdit0->text(); | 175 | key += keyLineEdit0->text(); |
175 | break; | 176 | break; |
176 | case 1: | 177 | case 1: |
177 | key += keyLineEdit1->text(); | 178 | key += keyLineEdit1->text(); |
178 | break; | 179 | break; |
179 | case 2: | 180 | case 2: |
180 | key += keyLineEdit2->text(); | 181 | key += keyLineEdit2->text(); |
181 | break; | 182 | break; |
182 | case 3: | 183 | case 3: |
183 | key += keyLineEdit3->text(); | 184 | key += keyLineEdit3->text(); |
184 | break; | 185 | break; |
185 | } | 186 | } |
186 | if( config.readEntry( "AuthType", "opensystem" ) == "opensystem") | 187 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
187 | key += " open"; | 188 | key += " open"; |
188 | } | 189 | } |
189 | out << scheme << ",*,*,*)" << "\n" | 190 | out << scheme << ",*,*,*)" << "\n" |
190 | << " ESSID=" << Global::shellQuote( config.readEntry( "SSID", "any" ) ) << "\n" | 191 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
191 | << " MODE=" << mode << "\n" | 192 | << " MODE=" << mode << "\n" |
192 | << " KEY=" << Global::shellQuote( key ) << "\n" | 193 | << " KEY=" << Global::shellQuote( key ) << "\n" |
193 | << " RATE=" << "auto" << "\n" | 194 | << " RATE=" << "auto" << "\n" |
194 | ; | 195 | ; |
195 | if( mode != "Managed" ) | 196 | if( mode != "Managed" ) |
196 | out << " CHANNEL=" << config.readNumEntry( "CHANNEL", 1 ) << "\n"; | 197 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
197 | const char** f = txtfields; | 198 | const char** f = txtfields; |
198 | while (*f) { | 199 | while (*f) { |
199 | out << " " << *f << "=" << config.readEntry(*f,"") << "\n"; | 200 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
200 | ++f; | 201 | ++f; |
201 | } | 202 | } |
202 | out << " ;;\n"; | 203 | out << " ;;\n"; |
203 | done = true; | 204 | done = true; |
204 | } | 205 | } |
205 | } | 206 | } |
206 | } | 207 | } |
207 | out << line << "\n"; | 208 | out << line << "\n"; |
208 | } | 209 | } |
209 | 210 | ||
210 | prevFile.close(); | 211 | prevFile.close(); |
211 | tmpFile.close(); | 212 | tmpFile.close(); |
212 | QString initpath; | 213 | QString initpath; |
213 | //system("cardctl suspend"); | 214 | //system("cardctl suspend"); |
214 | if( QDir("/etc/rc.d/init.d").exists() ){ | 215 | if( QDir("/etc/rc.d/init.d").exists() ){ |
215 | initpath = "/etc/rc.d/init.d"; | 216 | initpath = "/etc/rc.d/init.d"; |
216 | } else if( QDir("/etc/init.d").exists() ){ | 217 | } else if( QDir("/etc/init.d").exists() ){ |
217 | initpath = "/etc/init.d"; | 218 | initpath = "/etc/init.d"; |
218 | } | 219 | } |
219 | if( initpath ) | 220 | if( initpath ) |
220 | system(QString("%1/pcmcia stop").arg(initpath)); | 221 | system(QString("%1/pcmcia stop").arg(initpath)); |
221 | 222 | ||
222 | if( system( "mv " + tmp + " " + prev ) ) | 223 | if( system( "mv " + tmp + " " + prev ) ) |
223 | retval = false; | 224 | retval = false; |
224 | //#ifdef USE_SCHEMES | 225 | //#ifdef USE_SCHEMES |
225 | // if ( retval ) | 226 | // if ( retval ) |
226 | //SchemeChanger::changeScheme(scheme); | 227 | //SchemeChanger::changeScheme(scheme); |
227 | //#endif | 228 | //#endif |
228 | 229 | ||
229 | //system("cardctl resume"); | 230 | //system("cardctl resume"); |
230 | if( initpath ) | 231 | if( initpath ) |
231 | system(QString("%1/pcmcia start").arg(initpath)); | 232 | system(QString("%1/pcmcia start").arg(initpath)); |
232 | 233 | ||
233 | return retval; | 234 | return retval; |
234 | } | 235 | } |
diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h index 8e355ce..79e931d 100644 --- a/noncore/net/networksetup/wlan/wlanimp.h +++ b/noncore/net/networksetup/wlan/wlanimp.h | |||
@@ -1,27 +1,27 @@ | |||
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 | class Config; | 6 | #include <qpe/config.h> |
7 | 7 | ||
8 | class WLANImp : public WLAN { | 8 | class WLANImp : public WLAN { |
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | 10 | ||
11 | public: | 11 | public: |
12 | WLANImp( Config& cfg, QWidget* parent = 0, const char* name = 0); | 12 | WLANImp( QWidget* parent = 0, const char* name = 0); |
13 | 13 | ||
14 | protected: | 14 | protected: |
15 | void accept(); | 15 | void accept(); |
16 | void done ( int r ); | 16 | void done ( int r ); |
17 | 17 | ||
18 | private: | 18 | private: |
19 | void readConfig(); | 19 | void readConfig(); |
20 | bool writeConfig(); | 20 | bool writeConfig(); |
21 | bool writeWirelessOpts( Config &cfg, QString scheme = "*" ); | 21 | bool writeWirelessOpts( QString scheme = "*" ); |
22 | bool writeWlanngOpts( Config &cfg, QString scheme = "*" ); | 22 | bool writeWlanngOpts( QString scheme = "*" ); |
23 | Config& config; | 23 | Config* config; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | #endif | 26 | #endif |
27 | 27 | ||
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp index f12e608..cbb520d 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp | |||
@@ -1,224 +1,223 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include <qpe/config.h> | 2 | #include <qpe/config.h> |
3 | #include "wlanimp.h" | 3 | #include "wlanimp.h" |
4 | #include "info.h" | 4 | #include "info.h" |
5 | 5 | ||
6 | 6 | ||
7 | #include <arpa/inet.h> | 7 | #include <arpa/inet.h> |
8 | #include <sys/socket.h> | 8 | #include <sys/socket.h> |
9 | #include <linux/if_ether.h> | 9 | #include <linux/if_ether.h> |
10 | #include <netinet/ip.h> | 10 | #include <netinet/ip.h> |
11 | #include <sys/ioctl.h> | 11 | #include <sys/ioctl.h> |
12 | #include <linux/wireless.h> | 12 | #include <linux/wireless.h> |
13 | 13 | ||
14 | #include <unistd.h> | 14 | #include <unistd.h> |
15 | #include <math.h> | 15 | #include <math.h> |
16 | #include <errno.h> | 16 | #include <errno.h> |
17 | #include <string.h> | 17 | #include <string.h> |
18 | #include <stdio.h> | 18 | #include <stdio.h> |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | 21 | ||
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * Constructor, find all of the possible interfaces | 25 | * Constructor, find all of the possible interfaces |
26 | */ | 26 | */ |
27 | WLANModule::WLANModule() : Module() { | 27 | WLANModule::WLANModule() : Module() { |
28 | // get output from iwconfig | 28 | // get output from iwconfig |
29 | } | 29 | } |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Change the current profile | 32 | * Change the current profile |
33 | */ | 33 | */ |
34 | void WLANModule::setProfile(QString newProfile){ | 34 | void WLANModule::setProfile(QString newProfile){ |
35 | profile = newProfile; | 35 | profile = newProfile; |
36 | } | 36 | } |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * get the icon name for this device. | 39 | * get the icon name for this device. |
40 | * @param Interface* can be used in determining the icon. | 40 | * @param Interface* can be used in determining the icon. |
41 | * @return QString the icon name (minus .png, .gif etc) | 41 | * @return QString the icon name (minus .png, .gif etc) |
42 | */ | 42 | */ |
43 | QString WLANModule::getPixmapName(Interface* ){ | 43 | QString WLANModule::getPixmapName(Interface* ){ |
44 | return "wlan"; | 44 | return "wlan"; |
45 | } | 45 | } |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Check to see if the interface i is owned by this module. | 48 | * Check to see if the interface i is owned by this module. |
49 | * @param Interface* interface to check against | 49 | * @param Interface* interface to check against |
50 | * @return bool true if i is owned by this module, false otherwise. | 50 | * @return bool true if i is owned by this module, false otherwise. |
51 | */ | 51 | */ |
52 | bool WLANModule::isOwner(Interface *i){ | 52 | bool WLANModule::isOwner(Interface *i){ |
53 | if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ | 53 | if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ |
54 | i->setHardwareName("802.11b"); | 54 | i->setHardwareName("802.11b"); |
55 | return true; | 55 | return true; |
56 | } | 56 | } |
57 | return false; | 57 | return false; |
58 | } | 58 | } |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Create, set tabWiget and return the WLANConfigure Module | 61 | * Create, set tabWiget and return the WLANConfigure Module |
62 | * @param tabWidget a pointer to the tab widget that this configure has. | 62 | * @param tabWidget a pointer to the tab widget that this configure has. |
63 | * @return QWidget* pointer to the tab widget in this modules configure. | 63 | * @return QWidget* pointer to the tab widget in this modules configure. |
64 | */ | 64 | */ |
65 | QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){ | 65 | QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){ |
66 | Config *cfg = new Config("wireless config"); | 66 | WLANImp *wlanconfig = new WLANImp( ); |
67 | WLANImp *wlanconfig = new WLANImp(*cfg); | ||
68 | (*tabWidget) = wlanconfig->tabWidget; | 67 | (*tabWidget) = wlanconfig->tabWidget; |
69 | return wlanconfig; | 68 | return wlanconfig; |
70 | } | 69 | } |
71 | 70 | ||
72 | /** | 71 | /** |
73 | * Create, set tabWiget and return the Information Module | 72 | * Create, set tabWiget and return the Information Module |
74 | * @param tabWidget a pointer to the tab widget that this information has. | 73 | * @param tabWidget a pointer to the tab widget that this information has. |
75 | * @return QWidget* pointer to the tab widget in this modules info. | 74 | * @return QWidget* pointer to the tab widget in this modules info. |
76 | */ | 75 | */ |
77 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ | 76 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ |
78 | WlanInfo *info = new WlanInfo(0, "wireless info"); | 77 | WlanInfo *info = new WlanInfo(0, "wireless info"); |
79 | (*tabWidget) = info->tabWidget; | 78 | (*tabWidget) = info->tabWidget; |
80 | 79 | ||
81 | struct ifreq ifr; | 80 | struct ifreq ifr; |
82 | struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; | 81 | struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; |
83 | int fd = socket( AF_INET, SOCK_DGRAM, 0 ); | 82 | int fd = socket( AF_INET, SOCK_DGRAM, 0 ); |
84 | 83 | ||
85 | const char* buffer[200]; | 84 | const char* buffer[200]; |
86 | struct iwreq iwr; | 85 | struct iwreq iwr; |
87 | memset( &iwr, 0, sizeof( iwr ) ); | 86 | memset( &iwr, 0, sizeof( iwr ) ); |
88 | iwr.u.essid.pointer = (caddr_t) buffer; | 87 | iwr.u.essid.pointer = (caddr_t) buffer; |
89 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 88 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
90 | iwr.u.essid.flags = 0; | 89 | iwr.u.essid.flags = 0; |
91 | 90 | ||
92 | // check if it is an IEEE 802.11 standard conform | 91 | // check if it is an IEEE 802.11 standard conform |
93 | // wireless device by sending SIOCGIWESSID | 92 | // wireless device by sending SIOCGIWESSID |
94 | // which also gives back the Extended Service Set ID | 93 | // which also gives back the Extended Service Set ID |
95 | // (see IEEE 802.11 for more information) | 94 | // (see IEEE 802.11 for more information) |
96 | 95 | ||
97 | QString n = (i->getInterfaceName()); | 96 | QString n = (i->getInterfaceName()); |
98 | const char* iname = n.latin1(); | 97 | const char* iname = n.latin1(); |
99 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | 98 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); |
100 | int result = ioctl( fd, SIOCGIWESSID, &iwr ); | 99 | int result = ioctl( fd, SIOCGIWESSID, &iwr ); |
101 | if ( result == 0 ){ | 100 | if ( result == 0 ){ |
102 | //hasWirelessExtensions = true; | 101 | //hasWirelessExtensions = true; |
103 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | 102 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; |
104 | info->essidLabel->setText(QString(iwr.u.essid.pointer)); | 103 | info->essidLabel->setText(QString(iwr.u.essid.pointer)); |
105 | } | 104 | } |
106 | else | 105 | else |
107 | return info; | 106 | return info; |
108 | //info->essidLabel->setText("*** Unknown ***"); | 107 | //info->essidLabel->setText("*** Unknown ***"); |
109 | 108 | ||
110 | // Address of associated access-point | 109 | // Address of associated access-point |
111 | result = ioctl( fd, SIOCGIWAP, &iwr ); | 110 | result = ioctl( fd, SIOCGIWAP, &iwr ); |
112 | if ( result == 0 ){ | 111 | if ( result == 0 ){ |
113 | QString foo = foo.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 112 | QString foo = foo.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
114 | iwr.u.ap_addr.sa_data[0]&0xff, | 113 | iwr.u.ap_addr.sa_data[0]&0xff, |
115 | iwr.u.ap_addr.sa_data[1]&0xff, | 114 | iwr.u.ap_addr.sa_data[1]&0xff, |
116 | iwr.u.ap_addr.sa_data[2]&0xff, | 115 | iwr.u.ap_addr.sa_data[2]&0xff, |
117 | iwr.u.ap_addr.sa_data[3]&0xff, | 116 | iwr.u.ap_addr.sa_data[3]&0xff, |
118 | iwr.u.ap_addr.sa_data[4]&0xff, | 117 | iwr.u.ap_addr.sa_data[4]&0xff, |
119 | iwr.u.ap_addr.sa_data[5]&0xff ); | 118 | iwr.u.ap_addr.sa_data[5]&0xff ); |
120 | info->apLabel->setText(foo); | 119 | info->apLabel->setText(foo); |
121 | } | 120 | } |
122 | else info->apLabel->setText("*** Unknown ***"); | 121 | else info->apLabel->setText("*** Unknown ***"); |
123 | 122 | ||
124 | iwr.u.data.pointer = (caddr_t) buffer; | 123 | iwr.u.data.pointer = (caddr_t) buffer; |
125 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 124 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
126 | iwr.u.data.flags = 0; | 125 | iwr.u.data.flags = 0; |
127 | result = ioctl( fd, SIOCGIWNICKN, &iwr ); | 126 | result = ioctl( fd, SIOCGIWNICKN, &iwr ); |
128 | if ( result == 0 ){ | 127 | if ( result == 0 ){ |
129 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 128 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; |
130 | info->stationLabel->setText(iwr.u.data.pointer); | 129 | info->stationLabel->setText(iwr.u.data.pointer); |
131 | } | 130 | } |
132 | else info->stationLabel->setText("*** Unknown ***"); | 131 | else info->stationLabel->setText("*** Unknown ***"); |
133 | 132 | ||
134 | result = ioctl( fd, SIOCGIWMODE, &iwr ); | 133 | result = ioctl( fd, SIOCGIWMODE, &iwr ); |
135 | if ( result == 0 ) | 134 | if ( result == 0 ) |
136 | info->modeLabel->setText( QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed")); | 135 | info->modeLabel->setText( QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed")); |
137 | else | 136 | else |
138 | info->modeLabel->setText("*** Unknown ***"); | 137 | info->modeLabel->setText("*** Unknown ***"); |
139 | 138 | ||
140 | result = ioctl( fd, SIOCGIWFREQ, &iwr ); | 139 | result = ioctl( fd, SIOCGIWFREQ, &iwr ); |
141 | if ( result == 0 ) | 140 | if ( result == 0 ) |
142 | info->freqLabel->setText(QString("%1").arg((double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000))); | 141 | info->freqLabel->setText(QString("%1").arg((double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000))); |
143 | else | 142 | else |
144 | info->freqLabel->setText("*** Unknown ***"); | 143 | info->freqLabel->setText("*** Unknown ***"); |
145 | 144 | ||
146 | /* | 145 | /* |
147 | // gather link quality from /proc/net/wireless | 146 | // gather link quality from /proc/net/wireless |
148 | 147 | ||
149 | char c; | 148 | char c; |
150 | QString status; | 149 | QString status; |
151 | QString name; | 150 | QString name; |
152 | QFile wfile( PROCNETWIRELESS ); | 151 | QFile wfile( PROCNETWIRELESS ); |
153 | bool hasFile = wfile.open( IO_ReadOnly ); | 152 | bool hasFile = wfile.open( IO_ReadOnly ); |
154 | QTextStream wstream( &wfile ); | 153 | QTextStream wstream( &wfile ); |
155 | if ( hasFile ) | 154 | if ( hasFile ) |
156 | { | 155 | { |
157 | wstream.readLine(); // skip the first two lines | 156 | wstream.readLine(); // skip the first two lines |
158 | wstream.readLine(); // because they only contain headers | 157 | wstream.readLine(); // because they only contain headers |
159 | } | 158 | } |
160 | if ( ( !hasFile ) || ( wstream.atEnd() ) ) | 159 | if ( ( !hasFile ) || ( wstream.atEnd() ) ) |
161 | { | 160 | { |
162 | #ifdef MDEBUG | 161 | #ifdef MDEBUG |
163 | qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); | 162 | qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); |
164 | #endif | 163 | #endif |
165 | quality = -1; | 164 | quality = -1; |
166 | signal = IW_LOWER; | 165 | signal = IW_LOWER; |
167 | noise = IW_LOWER; | 166 | noise = IW_LOWER; |
168 | return false; | 167 | return false; |
169 | } | 168 | } |
170 | 169 | ||
171 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 170 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
172 | 171 | ||
173 | if ( quality > 92 ) | 172 | if ( quality > 92 ) |
174 | #ifdef MDEBUG | 173 | #ifdef MDEBUG |
175 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 174 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
176 | #endif | 175 | #endif |
177 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 176 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
178 | #ifdef MDEBUG | 177 | #ifdef MDEBUG |
179 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 178 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
180 | #endif | 179 | #endif |
181 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 180 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
182 | #ifdef MDEBUG | 181 | #ifdef MDEBUG |
183 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 182 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
184 | #endif | 183 | #endif |
185 | 184 | ||
186 | return true; | 185 | return true; |
187 | 186 | ||
188 | } | 187 | } |
189 | */ | 188 | */ |
190 | return info; | 189 | return info; |
191 | } | 190 | } |
192 | 191 | ||
193 | /** | 192 | /** |
194 | * Get all active (up or down) interfaces | 193 | * Get all active (up or down) interfaces |
195 | * @return QList<Interface> A list of interfaces that exsist that havn't | 194 | * @return QList<Interface> A list of interfaces that exsist that havn't |
196 | * been called by isOwner() | 195 | * been called by isOwner() |
197 | */ | 196 | */ |
198 | QList<Interface> WLANModule::getInterfaces(){ | 197 | QList<Interface> WLANModule::getInterfaces(){ |
199 | return list; | 198 | return list; |
200 | } | 199 | } |
201 | 200 | ||
202 | /** | 201 | /** |
203 | * Attempt to add a new interface as defined by name | 202 | * Attempt to add a new interface as defined by name |
204 | * @param name the name of the type of interface that should be created given | 203 | * @param name the name of the type of interface that should be created given |
205 | * by possibleNewInterfaces(); | 204 | * by possibleNewInterfaces(); |
206 | * @return Interface* NULL if it was unable to be created. | 205 | * @return Interface* NULL if it was unable to be created. |
207 | */ | 206 | */ |
208 | Interface *WLANModule::addNewInterface(QString ){ | 207 | Interface *WLANModule::addNewInterface(QString ){ |
209 | // We can't add a 802.11 interface, either the hardware will be there | 208 | // We can't add a 802.11 interface, either the hardware will be there |
210 | // or it wont. | 209 | // or it wont. |
211 | return NULL; | 210 | return NULL; |
212 | } | 211 | } |
213 | 212 | ||
214 | /** | 213 | /** |
215 | * Attempts to remove the interface, doesn't delete i | 214 | * Attempts to remove the interface, doesn't delete i |
216 | * @return bool true if successfull, false otherwise. | 215 | * @return bool true if successfull, false otherwise. |
217 | */ | 216 | */ |
218 | bool WLANModule::remove(Interface*){ | 217 | bool WLANModule::remove(Interface*){ |
219 | // Can't remove a hardware device, you can stop it though. | 218 | // Can't remove a hardware device, you can stop it though. |
220 | return false; | 219 | return false; |
221 | } | 220 | } |
222 | 221 | ||
223 | // wlanmodule.cpp | 222 | // wlanmodule.cpp |
224 | 223 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 517604f..3b0e0b7 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -1,234 +1,235 @@ | |||
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 | ||
19 | WLANImp::WLANImp( Config &cfg, QWidget* parent, const char* name):WLAN(parent, name),config(cfg){ | 19 | WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name){ |
20 | config = new Config("wireless"); | ||
20 | readConfig(); | 21 | readConfig(); |
21 | } | 22 | } |
22 | 23 | ||
23 | void WLANImp::readConfig() | 24 | void WLANImp::readConfig() |
24 | { | 25 | { |
25 | qWarning( "WLANImp::readConfig() called." ); | 26 | qWarning( "WLANImp::readConfig() called." ); |
26 | config.setGroup( "Properties" ); | 27 | config->setGroup( "Properties" ); |
27 | QString ssid = config.readEntry( "SSID", "any" ); | 28 | QString ssid = config->readEntry( "SSID", "any" ); |
28 | if( ssid == "any" || ssid == "ANY" ){ | 29 | if( ssid == "any" || ssid == "ANY" ){ |
29 | essNon->setChecked( true ); | 30 | essNon->setChecked( true ); |
30 | } else { | 31 | } else { |
31 | essSpecific->setChecked( true ); | 32 | essSpecific->setChecked( true ); |
32 | essSpecificLineEdit->setText( ssid ); | 33 | essSpecificLineEdit->setText( ssid ); |
33 | } | 34 | } |
34 | QString mode = config.readEntry( "Mode", "Managed" ); | 35 | QString mode = config->readEntry( "Mode", "Managed" ); |
35 | if( mode == "adhoc" ) { | 36 | if( mode == "adhoc" ) { |
36 | network802->setChecked( true ); | 37 | network802->setChecked( true ); |
37 | } else { | 38 | } else { |
38 | networkInfrastructure->setChecked( true ); | 39 | networkInfrastructure->setChecked( true ); |
39 | } | 40 | } |
40 | networkChannel->setValue( config.readNumEntry( "CHANNEL", 1 ) ); | 41 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
41 | // config.readEntry( "RATE", "auto" ); | 42 | // config->readEntry( "RATE", "auto" ); |
42 | config.readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 43 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
43 | config.readEntry( "AuthType", "opensystem" ); | 44 | config->readEntry( "AuthType", "opensystem" ); |
44 | config.readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 45 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
45 | int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 46 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
46 | switch( defaultkey ){ | 47 | switch( defaultkey ){ |
47 | case 0: | 48 | case 0: |
48 | keyRadio0->setChecked( true ); | 49 | keyRadio0->setChecked( true ); |
49 | break; | 50 | break; |
50 | case 1: | 51 | case 1: |
51 | keyRadio1->setChecked( true ); | 52 | keyRadio1->setChecked( true ); |
52 | break; | 53 | break; |
53 | case 2: | 54 | case 2: |
54 | keyRadio2->setChecked( true ); | 55 | keyRadio2->setChecked( true ); |
55 | break; | 56 | break; |
56 | case 3: | 57 | case 3: |
57 | keyRadio3->setChecked( true ); | 58 | keyRadio3->setChecked( true ); |
58 | break; | 59 | break; |
59 | } | 60 | } |
60 | keyLineEdit0->setText(config.readEntry( "dot11WEPDefaultKey0" )); | 61 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
61 | keyLineEdit1->setText(config.readEntry( "dot11WEPDefaultKey1" )); | 62 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
62 | keyLineEdit2->setText(config.readEntry( "dot11WEPDefaultKey2" )); | 63 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
63 | keyLineEdit3->setText(config.readEntry( "dot11WEPDefaultKey3" )); | 64 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
64 | return; | 65 | return; |
65 | } | 66 | } |
66 | 67 | ||
67 | bool WLANImp::writeConfig() | 68 | bool WLANImp::writeConfig() |
68 | { | 69 | { |
69 | qWarning( "WLANImp::writeConfig() called." ); | 70 | qWarning( "WLANImp::writeConfig() called." ); |
70 | config.setGroup( "Properties" ); | 71 | config->setGroup( "Properties" ); |
71 | if( essNon->isChecked() ) { | 72 | if( essNon->isChecked() ) { |
72 | config.writeEntry( "SSID", "any" ); | 73 | config->writeEntry( "SSID", "any" ); |
73 | } else { | 74 | } else { |
74 | config.writeEntry( "SSID", essSpecificLineEdit->text() ); | 75 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
75 | } | 76 | } |
76 | if( networkInfrastructure->isChecked() ){ | 77 | if( networkInfrastructure->isChecked() ){ |
77 | config.writeEntry( "Mode", "Managed" ); | 78 | config->writeEntry( "Mode", "Managed" ); |
78 | } else if( network802->isChecked() ){ | 79 | } else if( network802->isChecked() ){ |
79 | config.writeEntry( "Mode", "adhoc" ); | 80 | config->writeEntry( "Mode", "adhoc" ); |
80 | } | 81 | } |
81 | config.writeEntry( "CHANNEL", networkChannel->value() ); | 82 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
82 | // config.readEntry( "RATE", "auto" ); | 83 | // config->readEntry( "RATE", "auto" ); |
83 | wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); | 84 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
84 | authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); | 85 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
85 | key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); | 86 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
86 | if( keyRadio0->isChecked() ){ | 87 | if( keyRadio0->isChecked() ){ |
87 | config.writeEntry( "dot11WEPDefaultKeyID", 0 ); | 88 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
88 | } else if( keyRadio1->isChecked() ){ | 89 | } else if( keyRadio1->isChecked() ){ |
89 | config.writeEntry( "dot11WEPDefaultKeyID", 1 ); | 90 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
90 | } else if( keyRadio2->isChecked() ){ | 91 | } else if( keyRadio2->isChecked() ){ |
91 | config.writeEntry( "dot11WEPDefaultKeyID", 2 ); | 92 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
92 | } else if( keyRadio3->isChecked() ){ | 93 | } else if( keyRadio3->isChecked() ){ |
93 | config.writeEntry( "dot11WEPDefaultKeyID", 3 ); | 94 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
94 | } | 95 | } |
95 | config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 96 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
96 | config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 97 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
97 | config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 98 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
98 | config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 99 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
99 | return writeWirelessOpts( config ); | 100 | return writeWirelessOpts( ); |
100 | } | 101 | } |
101 | 102 | ||
102 | /** | 103 | /** |
103 | */ | 104 | */ |
104 | void WLANImp::accept() | 105 | void WLANImp::accept() |
105 | { | 106 | { |
106 | if ( writeConfig() ) | 107 | if ( writeConfig() ) |
107 | QDialog::accept(); | 108 | QDialog::accept(); |
108 | } | 109 | } |
109 | 110 | ||
110 | void WLANImp::done ( int r ) | 111 | void WLANImp::done ( int r ) |
111 | { | 112 | { |
112 | QDialog::done ( r ); | 113 | QDialog::done ( r ); |
113 | close ( ); | 114 | close ( ); |
114 | } | 115 | } |
115 | 116 | ||
116 | bool WLANImp::writeWirelessOpts( Config &config, QString scheme ) | 117 | bool WLANImp::writeWirelessOpts( QString scheme ) |
117 | { | 118 | { |
118 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 119 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
119 | QString prev = "/etc/pcmcia/wireless.opts"; | 120 | QString prev = "/etc/pcmcia/wireless.opts"; |
120 | QFile prevFile(prev); | 121 | QFile prevFile(prev); |
121 | if ( !prevFile.open( IO_ReadOnly ) ) | 122 | if ( !prevFile.open( IO_ReadOnly ) ) |
122 | return false; | 123 | return false; |
123 | 124 | ||
124 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 125 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
125 | QFile tmpFile(tmp); | 126 | QFile tmpFile(tmp); |
126 | if ( !tmpFile.open( IO_WriteOnly ) ) | 127 | if ( !tmpFile.open( IO_WriteOnly ) ) |
127 | return false; | 128 | return false; |
128 | 129 | ||
129 | bool retval = true; | 130 | bool retval = true; |
130 | 131 | ||
131 | QTextStream in( &prevFile ); | 132 | QTextStream in( &prevFile ); |
132 | QTextStream out( &tmpFile ); | 133 | QTextStream out( &tmpFile ); |
133 | 134 | ||
134 | config.setGroup("Properties"); | 135 | config->setGroup("Properties"); |
135 | 136 | ||
136 | QString line; | 137 | QString line; |
137 | bool found=false; | 138 | bool found=false; |
138 | bool done=false; | 139 | bool done=false; |
139 | while ( !in.atEnd() ) { | 140 | while ( !in.atEnd() ) { |
140 | QString line = in.readLine(); | 141 | QString line = in.readLine(); |
141 | QString wline = line.simplifyWhiteSpace(); | 142 | QString wline = line.simplifyWhiteSpace(); |
142 | if ( !done ) { | 143 | if ( !done ) { |
143 | if ( found ) { | 144 | if ( found ) { |
144 | // skip existing entry for this scheme, and write our own. | 145 | // skip existing entry for this scheme, and write our own. |
145 | if ( wline == ";;" ) { | 146 | if ( wline == ";;" ) { |
146 | found = false; | 147 | found = false; |
147 | continue; | 148 | continue; |
148 | } else { | 149 | } else { |
149 | continue; | 150 | continue; |
150 | } | 151 | } |
151 | } else { | 152 | } else { |
152 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 153 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
153 | found=true; | 154 | found=true; |
154 | continue; // skip this line | 155 | continue; // skip this line |
155 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 156 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
156 | // end - add new entry | 157 | // end - add new entry |
157 | // Not all fields have a GUI, but all are supported | 158 | // Not all fields have a GUI, but all are supported |
158 | // in the letwork configuration files. | 159 | // in the letwork configuration files. |
159 | static const char* txtfields[] = { | 160 | static const char* txtfields[] = { |
160 | 0 | 161 | 0 |
161 | }; | 162 | }; |
162 | QString readmode = config.readEntry( "Mode", "Managed" ); | 163 | QString readmode = config->readEntry( "Mode", "Managed" ); |
163 | QString mode; | 164 | QString mode; |
164 | if( readmode == "Managed" ){ | 165 | if( readmode == "Managed" ){ |
165 | mode = readmode; | 166 | mode = readmode; |
166 | } else if( readmode == "adhoc" ){ | 167 | } else if( readmode == "adhoc" ){ |
167 | mode = "Ad-Hoc"; | 168 | mode = "Ad-Hoc"; |
168 | } | 169 | } |
169 | QString key; | 170 | QString key; |
170 | if( wepEnabled->isChecked() ){ | 171 | if( wepEnabled->isChecked() ){ |
171 | int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 172 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
172 | switch( defaultkey ){ | 173 | switch( defaultkey ){ |
173 | case 0: | 174 | case 0: |
174 | key += keyLineEdit0->text(); | 175 | key += keyLineEdit0->text(); |
175 | break; | 176 | break; |
176 | case 1: | 177 | case 1: |
177 | key += keyLineEdit1->text(); | 178 | key += keyLineEdit1->text(); |
178 | break; | 179 | break; |
179 | case 2: | 180 | case 2: |
180 | key += keyLineEdit2->text(); | 181 | key += keyLineEdit2->text(); |
181 | break; | 182 | break; |
182 | case 3: | 183 | case 3: |
183 | key += keyLineEdit3->text(); | 184 | key += keyLineEdit3->text(); |
184 | break; | 185 | break; |
185 | } | 186 | } |
186 | if( config.readEntry( "AuthType", "opensystem" ) == "opensystem") | 187 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
187 | key += " open"; | 188 | key += " open"; |
188 | } | 189 | } |
189 | out << scheme << ",*,*,*)" << "\n" | 190 | out << scheme << ",*,*,*)" << "\n" |
190 | << " ESSID=" << Global::shellQuote( config.readEntry( "SSID", "any" ) ) << "\n" | 191 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
191 | << " MODE=" << mode << "\n" | 192 | << " MODE=" << mode << "\n" |
192 | << " KEY=" << Global::shellQuote( key ) << "\n" | 193 | << " KEY=" << Global::shellQuote( key ) << "\n" |
193 | << " RATE=" << "auto" << "\n" | 194 | << " RATE=" << "auto" << "\n" |
194 | ; | 195 | ; |
195 | if( mode != "Managed" ) | 196 | if( mode != "Managed" ) |
196 | out << " CHANNEL=" << config.readNumEntry( "CHANNEL", 1 ) << "\n"; | 197 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
197 | const char** f = txtfields; | 198 | const char** f = txtfields; |
198 | while (*f) { | 199 | while (*f) { |
199 | out << " " << *f << "=" << config.readEntry(*f,"") << "\n"; | 200 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
200 | ++f; | 201 | ++f; |
201 | } | 202 | } |
202 | out << " ;;\n"; | 203 | out << " ;;\n"; |
203 | done = true; | 204 | done = true; |
204 | } | 205 | } |
205 | } | 206 | } |
206 | } | 207 | } |
207 | out << line << "\n"; | 208 | out << line << "\n"; |
208 | } | 209 | } |
209 | 210 | ||
210 | prevFile.close(); | 211 | prevFile.close(); |
211 | tmpFile.close(); | 212 | tmpFile.close(); |
212 | QString initpath; | 213 | QString initpath; |
213 | //system("cardctl suspend"); | 214 | //system("cardctl suspend"); |
214 | if( QDir("/etc/rc.d/init.d").exists() ){ | 215 | if( QDir("/etc/rc.d/init.d").exists() ){ |
215 | initpath = "/etc/rc.d/init.d"; | 216 | initpath = "/etc/rc.d/init.d"; |
216 | } else if( QDir("/etc/init.d").exists() ){ | 217 | } else if( QDir("/etc/init.d").exists() ){ |
217 | initpath = "/etc/init.d"; | 218 | initpath = "/etc/init.d"; |
218 | } | 219 | } |
219 | if( initpath ) | 220 | if( initpath ) |
220 | system(QString("%1/pcmcia stop").arg(initpath)); | 221 | system(QString("%1/pcmcia stop").arg(initpath)); |
221 | 222 | ||
222 | if( system( "mv " + tmp + " " + prev ) ) | 223 | if( system( "mv " + tmp + " " + prev ) ) |
223 | retval = false; | 224 | retval = false; |
224 | //#ifdef USE_SCHEMES | 225 | //#ifdef USE_SCHEMES |
225 | // if ( retval ) | 226 | // if ( retval ) |
226 | //SchemeChanger::changeScheme(scheme); | 227 | //SchemeChanger::changeScheme(scheme); |
227 | //#endif | 228 | //#endif |
228 | 229 | ||
229 | //system("cardctl resume"); | 230 | //system("cardctl resume"); |
230 | if( initpath ) | 231 | if( initpath ) |
231 | system(QString("%1/pcmcia start").arg(initpath)); | 232 | system(QString("%1/pcmcia start").arg(initpath)); |
232 | 233 | ||
233 | return retval; | 234 | return retval; |
234 | } | 235 | } |
diff --git a/noncore/settings/networksettings/wlan/wlanimp.h b/noncore/settings/networksettings/wlan/wlanimp.h index 8e355ce..79e931d 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.h +++ b/noncore/settings/networksettings/wlan/wlanimp.h | |||
@@ -1,27 +1,27 @@ | |||
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 | class Config; | 6 | #include <qpe/config.h> |
7 | 7 | ||
8 | class WLANImp : public WLAN { | 8 | class WLANImp : public WLAN { |
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | 10 | ||
11 | public: | 11 | public: |
12 | WLANImp( Config& cfg, QWidget* parent = 0, const char* name = 0); | 12 | WLANImp( QWidget* parent = 0, const char* name = 0); |
13 | 13 | ||
14 | protected: | 14 | protected: |
15 | void accept(); | 15 | void accept(); |
16 | void done ( int r ); | 16 | void done ( int r ); |
17 | 17 | ||
18 | private: | 18 | private: |
19 | void readConfig(); | 19 | void readConfig(); |
20 | bool writeConfig(); | 20 | bool writeConfig(); |
21 | bool writeWirelessOpts( Config &cfg, QString scheme = "*" ); | 21 | bool writeWirelessOpts( QString scheme = "*" ); |
22 | bool writeWlanngOpts( Config &cfg, QString scheme = "*" ); | 22 | bool writeWlanngOpts( QString scheme = "*" ); |
23 | Config& config; | 23 | Config* config; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | #endif | 26 | #endif |
27 | 27 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index f12e608..cbb520d 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -1,224 +1,223 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include <qpe/config.h> | 2 | #include <qpe/config.h> |
3 | #include "wlanimp.h" | 3 | #include "wlanimp.h" |
4 | #include "info.h" | 4 | #include "info.h" |
5 | 5 | ||
6 | 6 | ||
7 | #include <arpa/inet.h> | 7 | #include <arpa/inet.h> |
8 | #include <sys/socket.h> | 8 | #include <sys/socket.h> |
9 | #include <linux/if_ether.h> | 9 | #include <linux/if_ether.h> |
10 | #include <netinet/ip.h> | 10 | #include <netinet/ip.h> |
11 | #include <sys/ioctl.h> | 11 | #include <sys/ioctl.h> |
12 | #include <linux/wireless.h> | 12 | #include <linux/wireless.h> |
13 | 13 | ||
14 | #include <unistd.h> | 14 | #include <unistd.h> |
15 | #include <math.h> | 15 | #include <math.h> |
16 | #include <errno.h> | 16 | #include <errno.h> |
17 | #include <string.h> | 17 | #include <string.h> |
18 | #include <stdio.h> | 18 | #include <stdio.h> |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | 21 | ||
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * Constructor, find all of the possible interfaces | 25 | * Constructor, find all of the possible interfaces |
26 | */ | 26 | */ |
27 | WLANModule::WLANModule() : Module() { | 27 | WLANModule::WLANModule() : Module() { |
28 | // get output from iwconfig | 28 | // get output from iwconfig |
29 | } | 29 | } |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Change the current profile | 32 | * Change the current profile |
33 | */ | 33 | */ |
34 | void WLANModule::setProfile(QString newProfile){ | 34 | void WLANModule::setProfile(QString newProfile){ |
35 | profile = newProfile; | 35 | profile = newProfile; |
36 | } | 36 | } |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * get the icon name for this device. | 39 | * get the icon name for this device. |
40 | * @param Interface* can be used in determining the icon. | 40 | * @param Interface* can be used in determining the icon. |
41 | * @return QString the icon name (minus .png, .gif etc) | 41 | * @return QString the icon name (minus .png, .gif etc) |
42 | */ | 42 | */ |
43 | QString WLANModule::getPixmapName(Interface* ){ | 43 | QString WLANModule::getPixmapName(Interface* ){ |
44 | return "wlan"; | 44 | return "wlan"; |
45 | } | 45 | } |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Check to see if the interface i is owned by this module. | 48 | * Check to see if the interface i is owned by this module. |
49 | * @param Interface* interface to check against | 49 | * @param Interface* interface to check against |
50 | * @return bool true if i is owned by this module, false otherwise. | 50 | * @return bool true if i is owned by this module, false otherwise. |
51 | */ | 51 | */ |
52 | bool WLANModule::isOwner(Interface *i){ | 52 | bool WLANModule::isOwner(Interface *i){ |
53 | if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ | 53 | if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ |
54 | i->setHardwareName("802.11b"); | 54 | i->setHardwareName("802.11b"); |
55 | return true; | 55 | return true; |
56 | } | 56 | } |
57 | return false; | 57 | return false; |
58 | } | 58 | } |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Create, set tabWiget and return the WLANConfigure Module | 61 | * Create, set tabWiget and return the WLANConfigure Module |
62 | * @param tabWidget a pointer to the tab widget that this configure has. | 62 | * @param tabWidget a pointer to the tab widget that this configure has. |
63 | * @return QWidget* pointer to the tab widget in this modules configure. | 63 | * @return QWidget* pointer to the tab widget in this modules configure. |
64 | */ | 64 | */ |
65 | QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){ | 65 | QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){ |
66 | Config *cfg = new Config("wireless config"); | 66 | WLANImp *wlanconfig = new WLANImp( ); |
67 | WLANImp *wlanconfig = new WLANImp(*cfg); | ||
68 | (*tabWidget) = wlanconfig->tabWidget; | 67 | (*tabWidget) = wlanconfig->tabWidget; |
69 | return wlanconfig; | 68 | return wlanconfig; |
70 | } | 69 | } |
71 | 70 | ||
72 | /** | 71 | /** |
73 | * Create, set tabWiget and return the Information Module | 72 | * Create, set tabWiget and return the Information Module |
74 | * @param tabWidget a pointer to the tab widget that this information has. | 73 | * @param tabWidget a pointer to the tab widget that this information has. |
75 | * @return QWidget* pointer to the tab widget in this modules info. | 74 | * @return QWidget* pointer to the tab widget in this modules info. |
76 | */ | 75 | */ |
77 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ | 76 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ |
78 | WlanInfo *info = new WlanInfo(0, "wireless info"); | 77 | WlanInfo *info = new WlanInfo(0, "wireless info"); |
79 | (*tabWidget) = info->tabWidget; | 78 | (*tabWidget) = info->tabWidget; |
80 | 79 | ||
81 | struct ifreq ifr; | 80 | struct ifreq ifr; |
82 | struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; | 81 | struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr; |
83 | int fd = socket( AF_INET, SOCK_DGRAM, 0 ); | 82 | int fd = socket( AF_INET, SOCK_DGRAM, 0 ); |
84 | 83 | ||
85 | const char* buffer[200]; | 84 | const char* buffer[200]; |
86 | struct iwreq iwr; | 85 | struct iwreq iwr; |
87 | memset( &iwr, 0, sizeof( iwr ) ); | 86 | memset( &iwr, 0, sizeof( iwr ) ); |
88 | iwr.u.essid.pointer = (caddr_t) buffer; | 87 | iwr.u.essid.pointer = (caddr_t) buffer; |
89 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 88 | iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
90 | iwr.u.essid.flags = 0; | 89 | iwr.u.essid.flags = 0; |
91 | 90 | ||
92 | // check if it is an IEEE 802.11 standard conform | 91 | // check if it is an IEEE 802.11 standard conform |
93 | // wireless device by sending SIOCGIWESSID | 92 | // wireless device by sending SIOCGIWESSID |
94 | // which also gives back the Extended Service Set ID | 93 | // which also gives back the Extended Service Set ID |
95 | // (see IEEE 802.11 for more information) | 94 | // (see IEEE 802.11 for more information) |
96 | 95 | ||
97 | QString n = (i->getInterfaceName()); | 96 | QString n = (i->getInterfaceName()); |
98 | const char* iname = n.latin1(); | 97 | const char* iname = n.latin1(); |
99 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); | 98 | strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); |
100 | int result = ioctl( fd, SIOCGIWESSID, &iwr ); | 99 | int result = ioctl( fd, SIOCGIWESSID, &iwr ); |
101 | if ( result == 0 ){ | 100 | if ( result == 0 ){ |
102 | //hasWirelessExtensions = true; | 101 | //hasWirelessExtensions = true; |
103 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; | 102 | iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0'; |
104 | info->essidLabel->setText(QString(iwr.u.essid.pointer)); | 103 | info->essidLabel->setText(QString(iwr.u.essid.pointer)); |
105 | } | 104 | } |
106 | else | 105 | else |
107 | return info; | 106 | return info; |
108 | //info->essidLabel->setText("*** Unknown ***"); | 107 | //info->essidLabel->setText("*** Unknown ***"); |
109 | 108 | ||
110 | // Address of associated access-point | 109 | // Address of associated access-point |
111 | result = ioctl( fd, SIOCGIWAP, &iwr ); | 110 | result = ioctl( fd, SIOCGIWAP, &iwr ); |
112 | if ( result == 0 ){ | 111 | if ( result == 0 ){ |
113 | QString foo = foo.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 112 | QString foo = foo.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
114 | iwr.u.ap_addr.sa_data[0]&0xff, | 113 | iwr.u.ap_addr.sa_data[0]&0xff, |
115 | iwr.u.ap_addr.sa_data[1]&0xff, | 114 | iwr.u.ap_addr.sa_data[1]&0xff, |
116 | iwr.u.ap_addr.sa_data[2]&0xff, | 115 | iwr.u.ap_addr.sa_data[2]&0xff, |
117 | iwr.u.ap_addr.sa_data[3]&0xff, | 116 | iwr.u.ap_addr.sa_data[3]&0xff, |
118 | iwr.u.ap_addr.sa_data[4]&0xff, | 117 | iwr.u.ap_addr.sa_data[4]&0xff, |
119 | iwr.u.ap_addr.sa_data[5]&0xff ); | 118 | iwr.u.ap_addr.sa_data[5]&0xff ); |
120 | info->apLabel->setText(foo); | 119 | info->apLabel->setText(foo); |
121 | } | 120 | } |
122 | else info->apLabel->setText("*** Unknown ***"); | 121 | else info->apLabel->setText("*** Unknown ***"); |
123 | 122 | ||
124 | iwr.u.data.pointer = (caddr_t) buffer; | 123 | iwr.u.data.pointer = (caddr_t) buffer; |
125 | iwr.u.data.length = IW_ESSID_MAX_SIZE; | 124 | iwr.u.data.length = IW_ESSID_MAX_SIZE; |
126 | iwr.u.data.flags = 0; | 125 | iwr.u.data.flags = 0; |
127 | result = ioctl( fd, SIOCGIWNICKN, &iwr ); | 126 | result = ioctl( fd, SIOCGIWNICKN, &iwr ); |
128 | if ( result == 0 ){ | 127 | if ( result == 0 ){ |
129 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; | 128 | iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; |
130 | info->stationLabel->setText(iwr.u.data.pointer); | 129 | info->stationLabel->setText(iwr.u.data.pointer); |
131 | } | 130 | } |
132 | else info->stationLabel->setText("*** Unknown ***"); | 131 | else info->stationLabel->setText("*** Unknown ***"); |
133 | 132 | ||
134 | result = ioctl( fd, SIOCGIWMODE, &iwr ); | 133 | result = ioctl( fd, SIOCGIWMODE, &iwr ); |
135 | if ( result == 0 ) | 134 | if ( result == 0 ) |
136 | info->modeLabel->setText( QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed")); | 135 | info->modeLabel->setText( QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed")); |
137 | else | 136 | else |
138 | info->modeLabel->setText("*** Unknown ***"); | 137 | info->modeLabel->setText("*** Unknown ***"); |
139 | 138 | ||
140 | result = ioctl( fd, SIOCGIWFREQ, &iwr ); | 139 | result = ioctl( fd, SIOCGIWFREQ, &iwr ); |
141 | if ( result == 0 ) | 140 | if ( result == 0 ) |
142 | info->freqLabel->setText(QString("%1").arg((double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000))); | 141 | info->freqLabel->setText(QString("%1").arg((double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000))); |
143 | else | 142 | else |
144 | info->freqLabel->setText("*** Unknown ***"); | 143 | info->freqLabel->setText("*** Unknown ***"); |
145 | 144 | ||
146 | /* | 145 | /* |
147 | // gather link quality from /proc/net/wireless | 146 | // gather link quality from /proc/net/wireless |
148 | 147 | ||
149 | char c; | 148 | char c; |
150 | QString status; | 149 | QString status; |
151 | QString name; | 150 | QString name; |
152 | QFile wfile( PROCNETWIRELESS ); | 151 | QFile wfile( PROCNETWIRELESS ); |
153 | bool hasFile = wfile.open( IO_ReadOnly ); | 152 | bool hasFile = wfile.open( IO_ReadOnly ); |
154 | QTextStream wstream( &wfile ); | 153 | QTextStream wstream( &wfile ); |
155 | if ( hasFile ) | 154 | if ( hasFile ) |
156 | { | 155 | { |
157 | wstream.readLine(); // skip the first two lines | 156 | wstream.readLine(); // skip the first two lines |
158 | wstream.readLine(); // because they only contain headers | 157 | wstream.readLine(); // because they only contain headers |
159 | } | 158 | } |
160 | if ( ( !hasFile ) || ( wstream.atEnd() ) ) | 159 | if ( ( !hasFile ) || ( wstream.atEnd() ) ) |
161 | { | 160 | { |
162 | #ifdef MDEBUG | 161 | #ifdef MDEBUG |
163 | qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); | 162 | qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); |
164 | #endif | 163 | #endif |
165 | quality = -1; | 164 | quality = -1; |
166 | signal = IW_LOWER; | 165 | signal = IW_LOWER; |
167 | noise = IW_LOWER; | 166 | noise = IW_LOWER; |
168 | return false; | 167 | return false; |
169 | } | 168 | } |
170 | 169 | ||
171 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 170 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
172 | 171 | ||
173 | if ( quality > 92 ) | 172 | if ( quality > 92 ) |
174 | #ifdef MDEBUG | 173 | #ifdef MDEBUG |
175 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 174 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
176 | #endif | 175 | #endif |
177 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 176 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
178 | #ifdef MDEBUG | 177 | #ifdef MDEBUG |
179 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 178 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
180 | #endif | 179 | #endif |
181 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 180 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
182 | #ifdef MDEBUG | 181 | #ifdef MDEBUG |
183 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 182 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
184 | #endif | 183 | #endif |
185 | 184 | ||
186 | return true; | 185 | return true; |
187 | 186 | ||
188 | } | 187 | } |
189 | */ | 188 | */ |
190 | return info; | 189 | return info; |
191 | } | 190 | } |
192 | 191 | ||
193 | /** | 192 | /** |
194 | * Get all active (up or down) interfaces | 193 | * Get all active (up or down) interfaces |
195 | * @return QList<Interface> A list of interfaces that exsist that havn't | 194 | * @return QList<Interface> A list of interfaces that exsist that havn't |
196 | * been called by isOwner() | 195 | * been called by isOwner() |
197 | */ | 196 | */ |
198 | QList<Interface> WLANModule::getInterfaces(){ | 197 | QList<Interface> WLANModule::getInterfaces(){ |
199 | return list; | 198 | return list; |
200 | } | 199 | } |
201 | 200 | ||
202 | /** | 201 | /** |
203 | * Attempt to add a new interface as defined by name | 202 | * Attempt to add a new interface as defined by name |
204 | * @param name the name of the type of interface that should be created given | 203 | * @param name the name of the type of interface that should be created given |
205 | * by possibleNewInterfaces(); | 204 | * by possibleNewInterfaces(); |
206 | * @return Interface* NULL if it was unable to be created. | 205 | * @return Interface* NULL if it was unable to be created. |
207 | */ | 206 | */ |
208 | Interface *WLANModule::addNewInterface(QString ){ | 207 | Interface *WLANModule::addNewInterface(QString ){ |
209 | // We can't add a 802.11 interface, either the hardware will be there | 208 | // We can't add a 802.11 interface, either the hardware will be there |
210 | // or it wont. | 209 | // or it wont. |
211 | return NULL; | 210 | return NULL; |
212 | } | 211 | } |
213 | 212 | ||
214 | /** | 213 | /** |
215 | * Attempts to remove the interface, doesn't delete i | 214 | * Attempts to remove the interface, doesn't delete i |
216 | * @return bool true if successfull, false otherwise. | 215 | * @return bool true if successfull, false otherwise. |
217 | */ | 216 | */ |
218 | bool WLANModule::remove(Interface*){ | 217 | bool WLANModule::remove(Interface*){ |
219 | // Can't remove a hardware device, you can stop it though. | 218 | // Can't remove a hardware device, you can stop it though. |
220 | return false; | 219 | return false; |
221 | } | 220 | } |
222 | 221 | ||
223 | // wlanmodule.cpp | 222 | // wlanmodule.cpp |
224 | 223 | ||