22 #include "hssiaphandler.h" |
22 #include "hssiaphandler.h" |
23 #include "hotspotclientserver.h" |
23 #include "hotspotclientserver.h" |
24 #include "am_debug.h" |
24 #include "am_debug.h" |
25 #include <es_enum.h> |
25 #include <es_enum.h> |
26 |
26 |
27 #include <cmconnectionmethodext.h> |
27 #include <cmconnectionmethod.h> |
28 #include <cmconnectionmethoddef.h> |
28 #include <cmconnectionmethoddef.h> |
29 #include <cmmanagerext.h> |
29 #include <cmmanager.h> |
30 #include <cmmanagerdef.h> |
30 #include <cmmanagerdef.h> |
31 #include <cmdestinationext.h> |
31 #include <cmdestination.h> |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KRetryCount = 20; |
|
35 const TInt KRetryTimeout = 100000; |
32 |
36 |
33 using namespace CMManager; |
37 using namespace CMManager; |
34 |
38 |
35 // ============================ MEMBER FUNCTIONS =============================== |
39 // ============================ MEMBER FUNCTIONS =============================== |
36 |
40 |
90 // Wlan table name -field not modified, because it is used to store UIDs |
94 // Wlan table name -field not modified, because it is used to store UIDs |
91 // of clients. |
95 // of clients. |
92 DEBUG("CHssIapHandler::ChangeSettingsL"); |
96 DEBUG("CHssIapHandler::ChangeSettingsL"); |
93 TInt ret( KErrNone ); |
97 TInt ret( KErrNone ); |
94 |
98 |
95 RCmManagerExt cmManager; |
99 RCmManager cmManager; |
96 cmManager.OpenL(); |
100 cmManager.OpenL(); |
97 CleanupClosePushL( cmManager ); |
101 CleanupClosePushL( cmManager ); |
98 |
102 |
99 TUint easyWlanId = cmManager.EasyWlanIdL(); |
|
100 |
|
101 // Easy WLAN can't be modified |
|
102 if ( easyWlanId == aIapID ) |
|
103 { |
|
104 CleanupStack::PopAndDestroy( &cmManager ); |
|
105 return KErrPermissionDenied; |
|
106 } |
|
107 |
|
108 // Read WLAN table service id |
103 // Read WLAN table service id |
109 TUint32 serviceId(0); |
104 TUint32 serviceId(0); |
110 RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapID ); |
105 RCmConnectionMethod plugin = cmManager.ConnectionMethodL( aIapID ); |
111 CleanupClosePushL( plugin ); |
106 CleanupClosePushL( plugin ); |
112 serviceId = plugin.GetIntAttributeL( EWlanServiceId ); |
107 serviceId = plugin.GetIntAttributeL( EWlanServiceId ); |
113 DEBUG1("CHssIapHandler::ChangeSettingsL WLAN serviceId: %d", serviceId); |
108 DEBUG1("CHssIapHandler::ChangeSettingsL WLAN serviceId: %d", serviceId); |
114 |
109 |
115 if ( aSettings.Name.Length() > 0 ) |
110 if ( aSettings.Name.Length() > 0 ) |
197 { |
192 { |
198 DEBUG("CHssIapHandler::ChangeSettingsL -> SecurityMode > EHssWep -> EAP"); |
193 DEBUG("CHssIapHandler::ChangeSettingsL -> SecurityMode > EHssWep -> EAP"); |
199 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk)) = aSettings.iEnableWpaPsk; |
194 *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk)) = aSettings.iEnableWpaPsk; |
200 } |
195 } |
201 } |
196 } |
202 // now update the access point |
197 // Update access point, be prepared that Commsdat might be locked |
203 iWLANRecord->ModifyL( *dbSession ); |
198 TInt errCode( KErrLocked ); |
204 |
199 TInt retryCount( 0 ); |
|
200 |
|
201 while( errCode == KErrLocked && retryCount < KRetryCount ) |
|
202 { |
|
203 TRAP( errCode, iWLANRecord->ModifyL( *dbSession ) ); |
|
204 |
|
205 if ( errCode == KErrLocked ) |
|
206 { |
|
207 User::After( KRetryTimeout ); |
|
208 } |
|
209 retryCount++; |
|
210 } |
|
211 |
|
212 if ( errCode ) |
|
213 { |
|
214 // override previous ret value only when error happened |
|
215 ret = errCode; |
|
216 } |
|
217 |
205 CleanupStack::PopAndDestroy( dbSession ); |
218 CleanupStack::PopAndDestroy( dbSession ); |
206 DEBUG("CHssIapHandler::ChangeSettingsL DONE"); |
219 DEBUG("CHssIapHandler::ChangeSettingsL DONE"); |
207 return ret; |
220 return ret; |
208 } |
221 } |
209 |
222 |
324 // |
337 // |
325 void CHssIapHandler::GetNetworkIdL( const TUint aIapId, TUint32& aNetId ) |
338 void CHssIapHandler::GetNetworkIdL( const TUint aIapId, TUint32& aNetId ) |
326 { |
339 { |
327 DEBUG( "CHssIapHandler::GetNetworkIdL()" ); |
340 DEBUG( "CHssIapHandler::GetNetworkIdL()" ); |
328 |
341 |
329 RCmManagerExt cmManager; |
342 RCmManager cmManager; |
330 cmManager.OpenL(); |
343 cmManager.OpenL(); |
331 CleanupClosePushL( cmManager ); |
344 CleanupClosePushL( cmManager ); |
332 |
345 |
333 RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( aIapId ); |
346 RCmConnectionMethod plugin = cmManager.ConnectionMethodL( aIapId ); |
334 CleanupClosePushL( plugin ); |
347 CleanupClosePushL( plugin ); |
335 |
348 |
336 aNetId = plugin.GetIntAttributeL( ECmNetworkId ); |
349 aNetId = plugin.GetIntAttributeL( ECmNetworkId ); |
337 |
350 |
338 CleanupStack::PopAndDestroy( &plugin ); // Close() called on "plugin" |
351 CleanupStack::PopAndDestroy( &plugin ); // Close() called on "plugin" |
347 // |
360 // |
348 void CHssIapHandler::GetClientIapsL( const TUid aUId, RArray<TUint>& aIapIdArray ) |
361 void CHssIapHandler::GetClientIapsL( const TUid aUId, RArray<TUint>& aIapIdArray ) |
349 { |
362 { |
350 DEBUG("CHssIapSettingsHandler::GetClientsIapsL"); |
363 DEBUG("CHssIapSettingsHandler::GetClientsIapsL"); |
351 TBuf<32> buffer; // Temporary buffer for found UID from destination. |
364 TBuf<32> buffer; // Temporary buffer for found UID from destination. |
352 TUidName uidClient = aUId.Name(); // UID of the client. |
|
353 TUint32 iapId = 0; // IAP Identifiier. |
365 TUint32 iapId = 0; // IAP Identifiier. |
|
366 TBuf<KIapNameLength> uidClient; // UID of the client. |
|
367 |
|
368 uidClient.Copy( aUId.Name() ); |
|
369 ModifyClientUid( uidClient ); |
354 |
370 |
355 RArray<TUint32> destArray = RArray<TUint32>( 10 ); // KCmArrayGranularity instead of 10 |
371 RArray<TUint32> destArray = RArray<TUint32>( 10 ); // KCmArrayGranularity instead of 10 |
356 CleanupClosePushL( destArray ); |
372 CleanupClosePushL( destArray ); |
357 |
373 |
358 RCmManagerExt cmManager; |
374 RCmManager cmManager; |
359 cmManager.OpenL(); |
375 cmManager.OpenL(); |
360 CleanupClosePushL( cmManager ); |
376 CleanupClosePushL( cmManager ); |
361 |
377 |
362 cmManager.AllDestinationsL( destArray ); |
378 cmManager.AllDestinationsL( destArray ); |
363 |
379 |
364 for (TInt i = 0; i < destArray.Count(); i++) |
380 for (TInt i = 0; i < destArray.Count(); i++) |
365 { |
381 { |
366 RCmDestinationExt dest = cmManager.DestinationL( destArray[i] ); |
382 RCmDestination dest = cmManager.DestinationL( destArray[i] ); |
367 CleanupClosePushL( dest ); |
383 CleanupClosePushL( dest ); |
368 |
384 |
369 for (TInt j = 0; j < dest.ConnectionMethodCount(); j++) |
385 for (TInt j = 0; j < dest.ConnectionMethodCount(); j++) |
370 { |
386 { |
371 TInt bearerType = dest.ConnectionMethodL(j). |
387 TInt bearerType = dest.ConnectionMethodL(j). |
400 |
416 |
401 CleanupStack::PopAndDestroy( &cmManager ); |
417 CleanupStack::PopAndDestroy( &cmManager ); |
402 CleanupStack::PopAndDestroy( &destArray ); |
418 CleanupStack::PopAndDestroy( &destArray ); |
403 } |
419 } |
404 |
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // ModifyClientUid |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 void CHssIapHandler::ModifyClientUid( TDes& aUid ) |
|
426 { |
|
427 DEBUG("CHssIapHandler::ModifyClientUid"); |
|
428 TInt indx = aUid.Find( KMark1 ); |
|
429 if ( KErrNotFound != indx ) |
|
430 { |
|
431 aUid.Delete( indx, 1 ); |
|
432 indx = aUid.Find( KMark2 ); |
|
433 if ( KErrNotFound != indx ) |
|
434 { |
|
435 aUid.Delete( indx, 1 ); |
|
436 } |
|
437 } |
|
438 } |
|
439 |
405 // End of File |
440 // End of File |