|
1 /* |
|
2 * Copyright (c) 2002-2006 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 "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: Implementation of iapsettings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <EapType.h> |
|
22 #include <cdbpreftable.h> |
|
23 #include "hssiaphandler.h" |
|
24 #include "hotspotclientserver.h" |
|
25 #include "am_debug.h" |
|
26 #include <es_enum.h> |
|
27 |
|
28 #include <cmconnectionmethodext.h> |
|
29 #include <cmconnectionmethoddef.h> |
|
30 #include <cmmanagerext.h> |
|
31 #include <cmmanagerdef.h> |
|
32 #include <cmdestinationext.h> |
|
33 |
|
34 using namespace CMManager; |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CHotSpotPluginSession |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CHssIapHandler::CHssIapHandler( ) |
|
43 { |
|
44 DEBUG("CHssIapHandler::CHssIapHandler"); |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // ConstructL |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CHssIapHandler::ConstructL() |
|
52 { |
|
53 DEBUG("CHssIapHandler::ConstructL()"); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // NewL |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CHssIapHandler* CHssIapHandler::NewL() |
|
61 { |
|
62 CHssIapHandler* self = new( ELeave ) CHssIapHandler(); |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // ~CHssIapHandler |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CHssIapHandler::~CHssIapHandler() |
|
74 { |
|
75 DEBUG("CHssIapHandler::~CHssIapHandler()"); |
|
76 |
|
77 if ( iWLANRecord != NULL ) |
|
78 { |
|
79 delete iWLANRecord; |
|
80 } |
|
81 iWLANRecord = NULL; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // ChangeSettingsL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 TInt CHssIapHandler::ChangeSettingsL( const TUint aIapID, |
|
89 const THssIapSettings& aSettings ) |
|
90 { |
|
91 // Wlan table name -field not modified, because it is used to store UIDs |
|
92 // of clients. |
|
93 DEBUG("CHssIapHandler::ChangeSettingsL"); |
|
94 TInt ret( KErrNone ); |
|
95 |
|
96 RCmManagerExt cmManager; |
|
97 cmManager.OpenL(); |
|
98 CleanupClosePushL( cmManager ); |
|
99 |
|
100 TUint easyWlanId = cmManager.EasyWlanIdL(); |
|
101 // Easy WLAN can't be modified |
|
102 if ( easyWlanId == aIapID ) |
|
103 { |
|
104 cmManager.Close(); |
|
105 return KErrPermissionDenied; |
|
106 } |
|
107 |
|
108 // Read WLAN table service id |
|
109 TUint32 serviceId(0); |
|
110 RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapID ); |
|
111 CleanupClosePushL( plugin ); |
|
112 serviceId = plugin.GetIntAttributeL( EWlanServiceId ); |
|
113 DEBUG1("CHssIapHandler::ChangeSettingsL WLAN serviceId: %d", serviceId); |
|
114 |
|
115 if ( aSettings.Name.Length() > 0 ) |
|
116 { |
|
117 plugin.SetStringAttributeL( ECmName, aSettings.Name ); |
|
118 plugin.UpdateL(); |
|
119 } |
|
120 CleanupStack::PopAndDestroy( &plugin ); // Close() called on "plugin" |
|
121 CleanupStack::PopAndDestroy( &cmManager ); // Close() called on "cmManager" |
|
122 |
|
123 // CommsDat section starts |
|
124 CMDBSession* dbSession = CMDBSession::NewL(CMDBSession::LatestVersion()); |
|
125 CleanupStack::PushL( dbSession ); |
|
126 iWLANRecord = static_cast<CMDBGenericRecord*> |
|
127 ( CCDRecordBase::RecordFactoryL( 0)); |
|
128 |
|
129 iWLANRecord->InitializeL( KGenericTable(),NULL ); |
|
130 iWLANRecord->SetRecordId( serviceId ); |
|
131 iWLANRecord->LoadL( *dbSession ); |
|
132 |
|
133 // Set Network Name |
|
134 if ( aSettings.iSSID.Length() > 0 ) |
|
135 { |
|
136 CMDBField<TDesC>* textField = |
|
137 (CMDBField<TDesC>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanSSID ); |
|
138 textField->SetMaxLengthL( aSettings.iSSID.Length() ); |
|
139 textField->SetL( aSettings.iSSID ); |
|
140 } |
|
141 |
|
142 // Set Connection Mode |
|
143 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanConnMode)) = |
|
144 aSettings.iConnectionMode; |
|
145 |
|
146 // Set Channel Id. |
|
147 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanChannelID )) = 0; |
|
148 |
|
149 // Set Security Mode |
|
150 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanSecMode )) = |
|
151 aSettings.iSecurityMode; |
|
152 |
|
153 // Check if THssIapSettings is created wrong (dynamically). |
|
154 // -> Then default value is not set to security mode and it will be huge. |
|
155 // -> Destination can become unusable. |
|
156 TInt secMode = aSettings.iSecurityMode; |
|
157 if ( secMode > EHssWpa2Only ) |
|
158 { |
|
159 secMode = EHssAllowUnsecure; |
|
160 } |
|
161 |
|
162 if( secMode == EHssWep ) |
|
163 { |
|
164 DEBUG("CHssIapHandler::ChangeSettingsL -> SecurityMode == EHssWep"); |
|
165 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanAuthMode)) = aSettings.iAuthenticationMode; |
|
166 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanWepIndex )) = aSettings.iWepIndex; |
|
167 |
|
168 ret = WriteWepKeysL( aSettings ); |
|
169 |
|
170 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanFormatKey1 )) = aSettings.iWepKeyFormat[0]; |
|
171 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanFormatKey2 )) = aSettings.iWepKeyFormat[1]; |
|
172 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanFormatKey3 )) = aSettings.iWepKeyFormat[2]; |
|
173 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanFormatKey4 )) = aSettings.iWepKeyFormat[3]; |
|
174 } |
|
175 else if( secMode > EHssWep ) |
|
176 { |
|
177 DEBUG("CHssIapHandler::ChangeSettingsL -> SecurityMode > EHssWep"); |
|
178 if ( aSettings.iEnableWpaPsk ) // Use PreSharedKey |
|
179 { |
|
180 TBuf8<KHssWlanWpaPskLength> buf; |
|
181 |
|
182 TInt len = aSettings.iWPAPreSharedKey.Length(); |
|
183 |
|
184 for( TInt i=0; i<len; i++) |
|
185 { |
|
186 buf.Append( aSettings.iWPAPreSharedKey[i]); |
|
187 } |
|
188 |
|
189 CMDBField<TDesC8>* binField = (CMDBField<TDesC8>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanWpaPreSharedKey); |
|
190 binField->SetMaxLengthL( len); |
|
191 binField->SetL( buf); |
|
192 |
|
193 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanWpaKeyLength)) = aSettings.iWPAKeyLength; |
|
194 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk)) = aSettings.iEnableWpaPsk; |
|
195 } |
|
196 else // Use EAP |
|
197 { |
|
198 DEBUG("CHssIapHandler::ChangeSettingsL -> SecurityMode > EHssWep -> EAP"); |
|
199 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk)) = aSettings.iEnableWpaPsk; |
|
200 } |
|
201 } |
|
202 |
|
203 // access point updated EAP data can be now set if needed |
|
204 if ( ( !aSettings.iEnableWpaPsk ) && secMode > EHssWep ) |
|
205 { |
|
206 DEBUG("CHssIapHandler::ChangeSettingsL -> Set EAP data"); |
|
207 TBuf8<KEapListMaxLength> enabledEapList; |
|
208 for (TInt i=0;i<aSettings.iEapDataArray.Count();i++) |
|
209 { |
|
210 TBuf8< KEapExpandedIdLength > eapTypeCue; |
|
211 TChar eapCode; |
|
212 GetEapTypeDesC(aSettings.iEapDataArray[i]->iEAPType, eapTypeCue, eapCode ); |
|
213 |
|
214 CEapType* eapType = NULL; |
|
215 TRAPD( error, ( eapType = CEapType::NewL( eapTypeCue, ELan, serviceId ) ) ); |
|
216 DEBUG1(" CEapType::NewL error: %d", error); |
|
217 if ( ( error == KErrNone ) && eapType ) |
|
218 { |
|
219 CleanupStack::PushL( eapType ); |
|
220 EAPSettings* eapSettings = new (ELeave) EAPSettings; |
|
221 |
|
222 ConvertEApSettings( *aSettings.iEapDataArray[i], *eapSettings ); |
|
223 |
|
224 // Set EAP tunneling |
|
225 if ( aSettings.iEapDataArray[i]->iEncapsulatedInside != EAPSettings::EEapNone ) |
|
226 { |
|
227 DEBUG("iEncapsulatedInside != EAPSettings::EEapNone"); |
|
228 eapType->SetTunnelingType( |
|
229 static_cast<TInt> ( aSettings.iEapDataArray[i]->iEncapsulatedInside ) ); |
|
230 } |
|
231 else // Write to EAP list |
|
232 { |
|
233 DEBUG("CHssIapHandler::ChangeSettingsL -> Add to EAP list"); |
|
234 TBuf8<8> expandedForm; |
|
235 expandedForm.AppendFill( 0xFE, 1 ); |
|
236 if ( THssEapSettings::EEapPlainMschapv2 == aSettings.iEapDataArray[i]->iEAPType ) |
|
237 { |
|
238 expandedForm.AppendFill( 0xFF, 3 ); |
|
239 } |
|
240 else{ |
|
241 expandedForm.AppendFill( 0x00, 6 ); |
|
242 } |
|
243 |
|
244 expandedForm.AppendFill( eapCode, 1 ); |
|
245 |
|
246 enabledEapList.Append( expandedForm ); |
|
247 } |
|
248 |
|
249 DEBUG("CHssIapHandler::ChangeSettingsL -> eapType->SetConfigurationL"); |
|
250 TRAPD( eapErr, eapType->SetConfigurationL( *eapSettings ) ); |
|
251 DEBUG1(" eapType->SetConfigurationL error: %d", eapErr); |
|
252 if( eapErr != KErrNone ) |
|
253 { |
|
254 CleanupStack::PopAndDestroy( eapType ); |
|
255 CleanupStack::PopAndDestroy( dbSession ); |
|
256 DEBUG("CHssIapHandler::ChangeSettingsL EapError DONE"); |
|
257 return eapErr; |
|
258 } |
|
259 CleanupStack::PopAndDestroy( eapType ); |
|
260 } |
|
261 if ( error != KErrNone ) |
|
262 { |
|
263 DEBUG("CHssIapHandler::ChangeSettingsL Eap error"); |
|
264 CleanupStack::PopAndDestroy( dbSession ); |
|
265 return error; |
|
266 } |
|
267 } |
|
268 |
|
269 // Set enabled EAP list |
|
270 if ( enabledEapList.Length() > 0 ) |
|
271 { |
|
272 DEBUG("CHssIapHandler::ChangeSettingsL -> Set EAP list"); |
|
273 CMDBField<TDesC8>* eaps = (CMDBField<TDesC8>*)iWLANRecord->GetFieldByIdL( KCDTIdWlanEnabledEaps ); |
|
274 //eaps->SetMaxLengthL( eapList16.Length() ) |
|
275 eaps->SetL( enabledEapList ); |
|
276 } |
|
277 } |
|
278 // now update the access point |
|
279 iWLANRecord->ModifyL( *dbSession ); |
|
280 |
|
281 CleanupStack::PopAndDestroy( dbSession ); |
|
282 DEBUG("CHssIapHandler::ChangeSettingsL DONE"); |
|
283 return ret; |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // WriteWepKeysL |
|
288 // Writes WEP keys from aSettings to current WLANServiceTable record |
|
289 // The record which the data is written to must be fetched from CommsDat |
|
290 // before calling WriteWepKeysL() |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 TInt CHssIapHandler::WriteWepKeysL( const THssIapSettings& aSettings ) |
|
294 { |
|
295 DEBUG("CHssIapHandler::WriteWepKeysL"); |
|
296 // 1 |
|
297 CMDBField<TDesC8>* wepKey = static_cast<CMDBField<TDesC8>*>(iWLANRecord->GetFieldByIdL(KCDTIdWlanWepKey1)); |
|
298 if ( aSettings.iWepKey1.KeyLength <= KHssMaxWEPKeyLength ) |
|
299 { |
|
300 PackWepKeyCommsDatL( aSettings.iWepKey1, aSettings.iWepKeyFormat[0], wepKey ); |
|
301 } |
|
302 else |
|
303 { |
|
304 return KErrTooBig; |
|
305 } |
|
306 |
|
307 // 2 |
|
308 wepKey = static_cast<CMDBField<TDesC8>*>(iWLANRecord->GetFieldByIdL(KCDTIdWlanWepKey2)); |
|
309 if ( aSettings.iWepKey2.KeyLength <= KHssMaxWEPKeyLength ) |
|
310 { |
|
311 PackWepKeyCommsDatL( aSettings.iWepKey2, aSettings.iWepKeyFormat[1], wepKey ); |
|
312 } |
|
313 else |
|
314 { |
|
315 return KErrTooBig; |
|
316 } |
|
317 |
|
318 // 3 |
|
319 wepKey = static_cast<CMDBField<TDesC8>*>(iWLANRecord->GetFieldByIdL(KCDTIdWlanWepKey3)); |
|
320 if ( aSettings.iWepKey3.KeyLength <= KHssMaxWEPKeyLength ) |
|
321 { |
|
322 PackWepKeyCommsDatL( aSettings.iWepKey3, aSettings.iWepKeyFormat[2], wepKey ); |
|
323 } |
|
324 else |
|
325 { |
|
326 return KErrTooBig; |
|
327 } |
|
328 |
|
329 // 4 |
|
330 wepKey = static_cast<CMDBField<TDesC8>*>(iWLANRecord->GetFieldByIdL(KCDTIdWlanWepKey4)); |
|
331 if ( aSettings.iWepKey4.KeyLength <= KHssMaxWEPKeyLength ) |
|
332 { |
|
333 PackWepKeyCommsDatL( aSettings.iWepKey4,aSettings.iWepKeyFormat[3], wepKey ); |
|
334 } |
|
335 else |
|
336 { |
|
337 return KErrTooBig; |
|
338 } |
|
339 return KErrNone; |
|
340 } |
|
341 |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // PackWepKeyCommsDatL |
|
345 // Copies wepkey string from wepkey structs TUint8 buffer to a WLANServiceTable |
|
346 // record's WEP key field descriptor |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 void CHssIapHandler::PackWepKeyCommsDatL( const SHssWep& aInputKey, |
|
350 const EHssWEPKeyFormat& aFormat, |
|
351 CMDBField<TDesC8>* aPackedKey ) |
|
352 { |
|
353 DEBUG("CHssIapHandler:::PackWepKeyL"); |
|
354 if( aInputKey.KeyLength > KHssMaxWEPKeyLength) |
|
355 { |
|
356 User::Leave( KErrArgument); |
|
357 } |
|
358 |
|
359 TBuf8<KHssMaxWEPKeyLength> wepBuf; |
|
360 |
|
361 for (TUint i = 0 ; i<aInputKey.KeyLength; i++) |
|
362 { |
|
363 wepBuf.Append(aInputKey.KeyMaterial[i]); |
|
364 } |
|
365 |
|
366 // Ascii to hexa convertion, if not already hexa |
|
367 if( EAscii == aFormat ) |
|
368 { |
|
369 HBufC8* buf8Conv = HBufC8::NewLC( wepBuf.Length()*2 ); |
|
370 ConvertAsciiToHex( wepBuf, buf8Conv ); |
|
371 wepBuf.Copy( buf8Conv->Des() ); |
|
372 CleanupStack::PopAndDestroy( buf8Conv ); |
|
373 } |
|
374 |
|
375 aPackedKey->SetL( wepBuf); |
|
376 } |
|
377 |
|
378 // ----------------------------------------------------------------------------- |
|
379 // ConvertEApSettings |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 void CHssIapHandler::ConvertEApSettings( THssEapSettings& aHssEap, EAPSettings& aEap ) |
|
383 { |
|
384 DEBUG("CHssIapHandler::ConvertEApSettings"); |
|
385 aEap.iEAPType = static_cast<EAPSettings::TEapType>(aHssEap.iEAPType); |
|
386 aEap.iUsernamePresent = aHssEap.iUsernamePresent; |
|
387 aEap.iUsername = aHssEap.iUsername; |
|
388 aEap.iPasswordPresent = aHssEap.iPasswordPresent; |
|
389 aEap.iPassword = aHssEap.iPassword; |
|
390 aEap.iRealmPresent = aHssEap.iRealmPresent; |
|
391 aEap.iRealm = aHssEap.iRealm; |
|
392 aEap.iUsePseudonymsPresent = aHssEap.iUsePseudonymsPresent; |
|
393 aEap.iUsePseudonyms = aHssEap.iUsePseudonyms; |
|
394 aEap.iVerifyServerRealmPresent = aHssEap.iVerifyServerRealmPresent; |
|
395 aEap.iVerifyServerRealm = aHssEap.iVerifyServerRealm; |
|
396 aEap.iRequireClientAuthenticationPresent = aHssEap.iRequireClientAuthenticationPresent; |
|
397 aEap.iRequireClientAuthentication = aHssEap.iRequireClientAuthentication; |
|
398 aEap.iSessionValidityTimePresent = aHssEap.iSessionValidityTimePresent; |
|
399 aEap.iSessionValidityTime = aHssEap.iSessionValidityTime; |
|
400 aEap.iCipherSuitesPresent = aHssEap.iCipherSuitesPresent; |
|
401 |
|
402 for( TInt i = 0; i < aHssEap.iCipherSuitesCount; i++ ) |
|
403 { |
|
404 aEap.iCipherSuites.Append( aHssEap.iCipherSuites[i] ); |
|
405 } |
|
406 aEap.iPEAPVersionsPresent = aHssEap.iPEAPVersionsPresent; |
|
407 aEap.iPEAPv0Allowed = aHssEap.iPEAPv0Allowed; |
|
408 aEap.iPEAPv1Allowed = aHssEap.iPEAPv1Allowed; |
|
409 aEap.iPEAPv2Allowed = aHssEap.iPEAPv2Allowed; |
|
410 aEap.iCertificatesPresent = aHssEap.iCertificatesPresent; |
|
411 for( TInt i = 0; i < aHssEap.iCertificatesCount; i++ ) |
|
412 { |
|
413 DEBUG("CHssIapHandler::ConvertEApSettings Certificates present"); |
|
414 CertificateEntry entry; |
|
415 |
|
416 entry.iCertType = static_cast<CertificateEntry::TCertType>( aHssEap.iCertificates[i]->iCertType ); |
|
417 entry.iSubjectNamePresent = aHssEap.iCertificates[i]->iSubjectNamePresent; |
|
418 entry.iSubjectName = aHssEap.iCertificates[i]->iSubjectName; |
|
419 entry.iIssuerNamePresent = aHssEap.iCertificates[i]->iIssuerNamePresent; |
|
420 entry.iIssuerName = aHssEap.iCertificates[i]->iIssuerName; |
|
421 entry.iSerialNumberPresent= aHssEap.iCertificates[i]->iSerialNumberPresent; |
|
422 entry.iSerialNumber = aHssEap.iCertificates[i]->iSerialNumber; |
|
423 entry.iSubjectKeyIDPresent = aHssEap.iCertificates[i]->iSubjectKeyIDPresent; |
|
424 entry.iSubjectKeyID = aHssEap.iCertificates[i]->iSubjectKeyID; |
|
425 |
|
426 entry.iThumbprintPresent = aHssEap.iCertificates[i]->iThumbprintPresent; |
|
427 entry.iThumbprint = aHssEap.iCertificates[i]->iThumbprint; |
|
428 TRAP_IGNORE( aEap.iCertificates.AppendL( entry ) ); // Memory problem, ignored... |
|
429 } |
|
430 aEap.iEncapsulatedEAPTypesPresent = aHssEap.iEncapsulatedEAPTypesPresent; |
|
431 for( TInt i = 0; i < aHssEap.iEncapsulatedEAPTypesCount; i++ ) |
|
432 { |
|
433 aEap.iEncapsulatedEAPTypes.Append( aHssEap.iEncapsulatedEAPTypes[i] ); |
|
434 } |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // ConvertAsciiToHex |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 void CHssIapHandler::ConvertAsciiToHex( const TDes8& aSource, |
|
442 HBufC8*& aDest ) |
|
443 { |
|
444 DEBUG("CHssIapHandler::ConvertAsciiToHex"); |
|
445 _LIT( hex, "0123456789ABCDEF" ); |
|
446 TInt size = aSource.Size(); |
|
447 TPtr8 ptr = aDest->Des(); |
|
448 for ( TInt ii = 0; ii < size; ii++ ) |
|
449 { |
|
450 TText8 ch = aSource[ii]; |
|
451 ptr.Append( hex()[(ch/16)&0x0f] ); |
|
452 ptr.Append( hex()[ch&0x0f] ); |
|
453 } |
|
454 } |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // GetEapTypeDesC |
|
458 // ----------------------------------------------------------------------------- |
|
459 // |
|
460 void CHssIapHandler::GetEapTypeDesC( TUint aEapType, TDes8& aEapString, TChar& aEapCode ) |
|
461 { |
|
462 DEBUG1( "CHssIapHandler::GetEapTypeDesC aEapType: %d", aEapType ); |
|
463 switch ( aEapType ) |
|
464 { |
|
465 // EapNone |
|
466 case 0: |
|
467 aEapString.Copy( KEapNoneId, KEapExpandedIdLength ); |
|
468 aEapCode = KEapNoneId[7]; |
|
469 break; |
|
470 // KEapGtc |
|
471 case 6: |
|
472 aEapString.Copy( KEapGtcId, KEapExpandedIdLength ); |
|
473 aEapCode = KEapGtcId[7]; |
|
474 break; |
|
475 // KEapTls |
|
476 case 13: |
|
477 aEapString.Copy( KEapTlsId, KEapExpandedIdLength ); |
|
478 aEapCode = KEapTlsId[7]; |
|
479 break; |
|
480 // KEapLeap |
|
481 case 17: |
|
482 aEapString.Copy( KEapLeapId, KEapExpandedIdLength ); |
|
483 aEapCode = KEapLeapId[7]; |
|
484 break; |
|
485 // KEapSim |
|
486 case 18: |
|
487 aEapString.Copy( KEapSimId, KEapExpandedIdLength ); |
|
488 aEapCode = KEapSimId[7]; |
|
489 break; |
|
490 // KEapTtls |
|
491 case 21: |
|
492 aEapString.Copy( KEapTtlsId, KEapExpandedIdLength ); |
|
493 aEapCode = KEapTtlsId[7]; |
|
494 break; |
|
495 // KEapAka |
|
496 case 23: |
|
497 aEapString.Copy( KEapAkaId, KEapExpandedIdLength ); |
|
498 aEapCode = KEapAkaId[7]; |
|
499 break; |
|
500 // KEapPeap |
|
501 case 25: |
|
502 aEapString.Copy( KEapPeapId, KEapExpandedIdLength ); |
|
503 aEapCode = KEapPeapId[7]; |
|
504 break; |
|
505 // KEapMschapv2 |
|
506 case 26: |
|
507 aEapString.Copy( KEapMschapv2Id, KEapExpandedIdLength ); |
|
508 aEapCode = KEapMschapv2Id[7]; |
|
509 break; |
|
510 // KEapSecurid |
|
511 case 32: |
|
512 aEapString.Copy( KEapSecuridId, KEapExpandedIdLength ); |
|
513 aEapCode = KEapSecuridId[7]; |
|
514 break; |
|
515 // KEapPlainMschapv2 |
|
516 case 99: |
|
517 aEapString.Copy( KEapPlainMschapv2Id, KEapExpandedIdLength ); |
|
518 aEapCode = KEapPlainMschapv2Id[7]; |
|
519 break; |
|
520 default: |
|
521 aEapString.Copy( KEapNoneId, KEapExpandedIdLength ); |
|
522 aEapCode = KEapNoneId[7]; |
|
523 break; |
|
524 } |
|
525 DEBUG( "CHssIapHandler::GetEapTypeDesC DONE" ); |
|
526 } |
|
527 |
|
528 // ----------------------------------------------------------------------------- |
|
529 // GetNetworkIdL |
|
530 // ----------------------------------------------------------------------------- |
|
531 // |
|
532 void CHssIapHandler::GetNetworkIdL( const TUint aIapId, TUint32& aNetId ) |
|
533 { |
|
534 DEBUG( "CHssIapHandler::GetNetworkIdL()" ); |
|
535 |
|
536 RCmManagerExt cmManager; |
|
537 cmManager.OpenL(); |
|
538 CleanupClosePushL( cmManager ); |
|
539 |
|
540 RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapId ); |
|
541 CleanupClosePushL( plugin ); |
|
542 |
|
543 aNetId = plugin.GetIntAttributeL( ECmNetworkId ); |
|
544 |
|
545 CleanupStack::PopAndDestroy( &plugin ); // Close() called on "plugin" |
|
546 CleanupStack::PopAndDestroy( &cmManager ); // Close() called on "cmManager" |
|
547 |
|
548 DEBUG1( "CHssIapHandler::GetNetworkIdL netId: %d", aNetId ); |
|
549 } |
|
550 |
|
551 // ----------------------------------------------------------------------------- |
|
552 // GetClientIapsL |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 void CHssIapHandler::GetClientIapsL( const TUid aUId, RArray<TUint>& aIapIdArray ) |
|
556 { |
|
557 DEBUG("CHssIapSettingsHandler::GetClientsIapsL"); |
|
558 TBuf<32> buffer; // Temporary buffer for found UID from destination. |
|
559 TUidName uidClient = aUId.Name(); // UID of the client. |
|
560 TUint32 iapId = 0; // IAP Identifiier. |
|
561 |
|
562 RArray<TUint32> destArray = RArray<TUint32>( 10 ); // KCmArrayGranularity instead of 10 |
|
563 CleanupClosePushL( destArray ); |
|
564 |
|
565 RCmManagerExt cmManager; |
|
566 cmManager.OpenL(); |
|
567 CleanupClosePushL( cmManager ); |
|
568 |
|
569 cmManager.AllDestinationsL( destArray ); |
|
570 |
|
571 for (TInt i = 0; i < destArray.Count(); i++) |
|
572 { |
|
573 RCmDestinationExt dest = cmManager.DestinationL( destArray[i] ); |
|
574 CleanupClosePushL( dest ); |
|
575 |
|
576 for (TInt j = 0; j < dest.ConnectionMethodCount(); j++) |
|
577 { |
|
578 TInt bearerType = dest.ConnectionMethodL(j). |
|
579 GetIntAttributeL( CMManager::ECmBearerType ); |
|
580 |
|
581 if (bearerType == KUidWlanBearerType) |
|
582 { |
|
583 HBufC* uid = dest.ConnectionMethodL(j). |
|
584 GetStringAttributeL( EWlanServiceExtensionTableName ); |
|
585 CleanupStack::PushL( uid ); |
|
586 |
|
587 // Copy found uid to temporary buffer |
|
588 buffer.Copy( *uid ); |
|
589 |
|
590 // If uids match, store corresponding IapId to aIapIdArray. |
|
591 if (buffer.Compare( uidClient ) == 0) |
|
592 { |
|
593 iapId = dest.ConnectionMethodL(j).GetIntAttributeL( ECmIapId ); |
|
594 aIapIdArray.Append( iapId ); |
|
595 DEBUG("CHssIapSettingsHandler::GetClientsIapsL: UIDs matched"); |
|
596 DEBUG1("CHssIapSettingsHandler::Found IapId: %d", iapId); |
|
597 } |
|
598 else |
|
599 { |
|
600 DEBUG("CHssIapSettingsHandler::GetClientsIapsL: NO match"); |
|
601 } |
|
602 CleanupStack::PopAndDestroy( uid ); |
|
603 } |
|
604 } |
|
605 CleanupStack::PopAndDestroy( &dest ); |
|
606 } |
|
607 |
|
608 CleanupStack::PopAndDestroy( &cmManager ); |
|
609 CleanupStack::PopAndDestroy( &destArray ); |
|
610 } |
|
611 |
|
612 // End of File |