|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Scan info |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include "gendebug.h" |
|
22 #include "genscaninfo.h" |
|
23 #include "wlanscaninfoimpl.h" |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // C++ default constructor can NOT contain any code, that |
|
28 // might leave. |
|
29 // |
|
30 CWlanScanInfoImpl::CWlanScanInfoImpl() |
|
31 { |
|
32 TraceDump( INFO_LEVEL, ( _L( "CWlanScanInfoImpl::CWlanScanInfoImpl()" ) ) ); |
|
33 } |
|
34 |
|
35 // Symbian 2nd phase constructor can leave. |
|
36 void CWlanScanInfoImpl::ConstructL() |
|
37 { |
|
38 TraceDump( INFO_LEVEL, ( _L( "CWlanScanInfoImpl::ConstructL()" ) ) ); |
|
39 |
|
40 iScanInfo = new(ELeave) ScanInfo( iScanList ); |
|
41 } |
|
42 |
|
43 // Static constructor. |
|
44 CWlanScanInfoImpl* CWlanScanInfoImpl::NewL() |
|
45 { |
|
46 TraceDump( INFO_LEVEL, ( _L( "CWlanScanInfoImpl::NewL()" ) ) ); |
|
47 |
|
48 CWlanScanInfoImpl* self = new (ELeave) CWlanScanInfoImpl; |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // Destructor |
|
56 CWlanScanInfoImpl::~CWlanScanInfoImpl() |
|
57 { |
|
58 TraceDump( INFO_LEVEL, ( _L( "CWlanScanInfoImpl::~CWlanScanInfoImpl()" ) ) ); |
|
59 delete iScanInfo; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // CWlanScanInfoImpl::Size |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 TUint16 CWlanScanInfoImpl::Size() const |
|
67 { |
|
68 return iScanInfo->Size(); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------- |
|
72 // CWlanScanInfoImpl::First |
|
73 // --------------------------------------------------------- |
|
74 // |
|
75 const TWlanScanInfoFrame* CWlanScanInfoImpl::First() |
|
76 { |
|
77 return iScanInfo->First(); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------- |
|
81 // CWlanScanInfoImpl::Next |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 const TWlanScanInfoFrame* CWlanScanInfoImpl::Next() |
|
85 { |
|
86 return iScanInfo->Next(); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------- |
|
90 // CWlanScanInfoImpl::Current |
|
91 // --------------------------------------------------------- |
|
92 // |
|
93 const TWlanScanInfoFrame* CWlanScanInfoImpl::Current() const |
|
94 { |
|
95 return iScanInfo->Current(); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CWlanScanInfoImpl::IsDone |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 TBool CWlanScanInfoImpl::IsDone() const |
|
103 { |
|
104 return iScanInfo->IsDone(); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CWlanScanInfoImpl::RXLevel |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 TUint8 CWlanScanInfoImpl::RXLevel() const |
|
112 { |
|
113 TUint8 rssiValue = 110 - ( iScanInfo->RXLevel() / 2 ); |
|
114 TraceDump( INFO_LEVEL, ( _L( "CWlanScanInfoImpl::RXLevel(): (RCP, RSS) == (%u, %u )" ), iScanInfo->RXLevel(), rssiValue ) ); |
|
115 return rssiValue; |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------- |
|
119 // CWlanScanInfoImpl::Bssid |
|
120 // --------------------------------------------------------- |
|
121 // |
|
122 void CWlanScanInfoImpl::Bssid( TWlanBssid& aBssid ) const |
|
123 { |
|
124 TMacAddress bssid={0}; |
|
125 iScanInfo->BSSID( bssid.iMacAddress ); |
|
126 aBssid.Copy( &bssid.iMacAddress[0], KMacAddressLength ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CWlanScanInfoImpl::BeaconInterval |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 TUint16 CWlanScanInfoImpl::BeaconInterval() const |
|
134 { |
|
135 return iScanInfo->BeaconInterval(); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // CWlanScanInfoImpl::Capability |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 TUint16 CWlanScanInfoImpl::Capability() const |
|
143 { |
|
144 return iScanInfo->Capability(); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // CWlanScanInfoImpl::SecurityMode |
|
149 // Status : Draft |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 TWlanConnectionSecurityMode CWlanScanInfoImpl::SecurityMode() const |
|
153 { |
|
154 TWlanConnectionSecurityMode securityMode; |
|
155 switch( iScanInfo->SecurityMode() ) |
|
156 { |
|
157 case WlanSecurityModeWep: |
|
158 securityMode = EWlanConnectionSecurityWep; |
|
159 break; |
|
160 case WlanSecurityMode802_1x: // Fallthrough on purpose |
|
161 case WlanSecurityModeWapi: // Fallthrough on purpose |
|
162 case WlanSecurityModeWapiPsk: |
|
163 securityMode = EWlanConnectionSecurity802d1x; |
|
164 break; |
|
165 case WlanSecurityModeWpaEap: // Fallthrough on purpose |
|
166 case WlanSecurityModeWpa2Eap: |
|
167 securityMode = EWlanConnectionSecurityWpa; |
|
168 break; |
|
169 case WlanSecurityModeWpaPsk: // Fallthrough on purpose |
|
170 case WlanSecurityModeWpa2Psk: |
|
171 securityMode = EWlanConnectionSecurityWpaPsk; |
|
172 break; |
|
173 default: |
|
174 securityMode = EWlanConnectionSecurityOpen; |
|
175 break; |
|
176 } |
|
177 return securityMode; |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------- |
|
181 // CWlanScanInfoImpl::InformationElement |
|
182 // --------------------------------------------------------- |
|
183 // |
|
184 TInt CWlanScanInfoImpl::InformationElement( TUint8 aIE, |
|
185 TUint8& aLength, |
|
186 const TUint8** aData ) |
|
187 { |
|
188 return ConvertErrorCode( iScanInfo->InformationElement( aIE, aLength, aData ) ); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------- |
|
192 // CWlanScanInfoImpl::WpaIE |
|
193 // --------------------------------------------------------- |
|
194 // |
|
195 TInt CWlanScanInfoImpl::WpaIE( TUint8& aLength, |
|
196 const TUint8** aData ) |
|
197 { |
|
198 return ConvertErrorCode( iScanInfo->WpaIE( aLength, aData ) ); |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------- |
|
202 // CWlanScanInfoImpl::FirstIE |
|
203 // --------------------------------------------------------- |
|
204 // |
|
205 TInt CWlanScanInfoImpl::FirstIE( TUint8& aIE, |
|
206 TUint8& aLength, |
|
207 const TUint8** aData ) |
|
208 { |
|
209 return ConvertErrorCode( iScanInfo->FirstIE( aIE, aLength, aData ) ); |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------- |
|
213 // CWlanScanInfoImpl::NextIE |
|
214 // --------------------------------------------------------- |
|
215 // |
|
216 TInt CWlanScanInfoImpl::NextIE( TUint8& aIE, |
|
217 TUint8& aLength, |
|
218 const TUint8** aData ) |
|
219 { |
|
220 return ConvertErrorCode( iScanInfo->NextIE( aIE, aLength, aData ) ); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------- |
|
224 // CWlanScanInfoImpl::GetInternalList |
|
225 // --------------------------------------------------------- |
|
226 // |
|
227 ScanList& CWlanScanInfoImpl::GetInternalList() |
|
228 { |
|
229 return iScanList; |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------- |
|
233 // CWlanScanInfoImpl::UpdateResults |
|
234 // --------------------------------------------------------- |
|
235 // |
|
236 TInt CWlanScanInfoImpl::UpdateResults() |
|
237 { |
|
238 ScanInfo* info = new ScanInfo( iScanList ); |
|
239 if ( !info ) |
|
240 { |
|
241 return KErrNoMemory; |
|
242 } |
|
243 |
|
244 delete iScanInfo; |
|
245 iScanInfo = info; |
|
246 |
|
247 return KErrNone; |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------- |
|
251 // CWlanScanInfoImpl::IsProtectedSetupSupported |
|
252 // --------------------------------------------------------- |
|
253 // |
|
254 TBool CWlanScanInfoImpl::IsProtectedSetupSupported() |
|
255 { |
|
256 return (iScanInfo->IsProtectedSetupSupported() ? ETrue : EFalse); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------- |
|
260 // CWlanScanInfoImpl::ExtendedSecurityMode |
|
261 // --------------------------------------------------------- |
|
262 // |
|
263 TWlanConnectionExtentedSecurityMode CWlanScanInfoImpl::ExtendedSecurityMode() const |
|
264 { |
|
265 TWlanConnectionExtentedSecurityMode securityMode; |
|
266 switch( iScanInfo->SecurityMode() ) |
|
267 { |
|
268 case WlanSecurityModeWep: |
|
269 /** |
|
270 * It's impossible to determine whether the AP requires open or shared |
|
271 * authentication based on scan results, assume open. |
|
272 */ |
|
273 securityMode = EWlanConnectionExtentedSecurityModeWepOpen; |
|
274 break; |
|
275 case WlanSecurityMode802_1x: |
|
276 securityMode = EWlanConnectionExtentedSecurityMode802d1x; |
|
277 break; |
|
278 case WlanSecurityModeWpaEap: |
|
279 securityMode = EWlanConnectionExtentedSecurityModeWpa; |
|
280 break; |
|
281 case WlanSecurityModeWpa2Eap: |
|
282 securityMode = EWlanConnectionExtentedSecurityModeWpa2; |
|
283 break; |
|
284 case WlanSecurityModeWpaPsk: |
|
285 securityMode = EWlanConnectionExtentedSecurityModeWpaPsk; |
|
286 break; |
|
287 case WlanSecurityModeWpa2Psk: |
|
288 securityMode = EWlanConnectionExtentedSecurityModeWpa2Psk; |
|
289 break; |
|
290 case WlanSecurityModeWapi: |
|
291 securityMode = EWlanConnectionExtentedSecurityModeWapi; |
|
292 break; |
|
293 case WlanSecurityModeWapiPsk: |
|
294 securityMode = EWlanConnectionExtentedSecurityModeWapiPsk; |
|
295 break; |
|
296 default: |
|
297 securityMode = EWlanConnectionExtentedSecurityModeOpen; |
|
298 break; |
|
299 } |
|
300 return securityMode; |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------- |
|
304 // CWlanScanInfoImpl::ConvertErrorCode |
|
305 // --------------------------------------------------------- |
|
306 // |
|
307 TInt CWlanScanInfoImpl::ConvertErrorCode( TInt aCode ) const |
|
308 { |
|
309 TInt errorCode( KErrGeneral ); |
|
310 |
|
311 switch( aCode ) |
|
312 { |
|
313 case WlanScanError_Ok: |
|
314 { |
|
315 errorCode = KErrNone; |
|
316 break; |
|
317 } |
|
318 case WlanScanError_IeNotFound: |
|
319 { |
|
320 errorCode = KErrNotFound; |
|
321 break; |
|
322 } |
|
323 } |
|
324 return errorCode; |
|
325 } |
|
326 |
|
327 // End of File |