wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp
branchRCL_3
changeset 6 e0f767079796
parent 5 51a71243e562
child 7 0abc8c98be24
equal deleted inserted replaced
5:51a71243e562 6:e0f767079796
    14 * Description:  Server class of wlan engine
    14 * Description:  Server class of wlan engine
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 99 %
    19 * %version: 102 %
    20 */
    20 */
    21 
    21 
    22 #include <e32def.h>
    22 #include <e32def.h>
    23 #include <e32std.h>
    23 #include <e32std.h>
    24 #include <featmgr.h>
    24 #include <featmgr.h>
   476         aMessage.Complete( err );
   476         aMessage.Complete( err );
   477 
   477 
   478         return;
   478         return;
   479         }
   479         }
   480 
   480 
   481     DEBUG4( "CWlmServer::Connect() - SecurityMode: %u, WPAKeyLength: %u, EnableWpaPsk: %u, PresharedKeyFormat: %u",
   481     DEBUG5( "CWlmServer::Connect() - SecurityMode: %u, WPAKeyLength: %u, WPAPreSharedKey: %u, EnableWpaPsk: %u, PresharedKeyFormat: %u",
   482         iapData.SecurityMode, iapData.WPAKeyLength, iapData.EnableWpaPsk, iapData.PresharedKeyFormat );
   482         iapData.SecurityMode, iapData.WPAKeyLength, iapData.WPAPreSharedKey.Length(),
       
   483         iapData.EnableWpaPsk, iapData.PresharedKeyFormat );
   483 
   484 
   484     // Check whether WAPI is supported
   485     // Check whether WAPI is supported
   485     if( iapData.SecurityMode == Wapi &&
   486     if( iapData.SecurityMode == Wapi &&
   486         !( iSupportedFeatures & EWlanFeatureWapi ) )
   487         !( iSupportedFeatures & EWlanFeatureWapi ) )
   487         {
   488         {
  1125     mapEntry.iSessionId = aSessionId;
  1126     mapEntry.iSessionId = aSessionId;
  1126     mapEntry.iParam0 = scanList;
  1127     mapEntry.iParam0 = scanList;
  1127     mapEntry.iParam1 = coreSsid;
  1128     mapEntry.iParam1 = coreSsid;
  1128     mapEntry.iTime = scanTime;
  1129     mapEntry.iTime = scanTime;
  1129     iRequestMap.Append( mapEntry );
  1130     iRequestMap.Append( mapEntry );
  1130 	
  1131 
  1131     // Scan scheduling timer needs to be set again if this request needs the results earlier or
  1132     // Scan scheduling timer needs to be set again if this request needs the results earlier or
  1132     // if this is the only timed pending request
  1133     // if this is the only timed pending request
  1133     if( scanTime != NULL && ( IsOnlyTimedScanRequestInRequestMap( mapEntry ) || *scanTime < iScanSchedulingTimerExpiration ) )
  1134     if( scanTime != NULL && ( IsOnlyTimedScanRequestInRequestMap( mapEntry ) || *scanTime < iScanSchedulingTimerExpiration ) )
  1134     	{
  1135     	{
  1135         UpdateScanSchedulingTimer( *scanTime, mapEntry.iRequestId );
  1136         UpdateScanSchedulingTimer( *scanTime, mapEntry.iRequestId );
  1796                             interval,
  1797                             interval,
  1797                             duration );
  1798                             duration );
  1798                         iAggressiveScanningAfterLinkLoss = EFalse;
  1799                         iAggressiveScanningAfterLinkLoss = EFalse;
  1799                         }
  1800                         }
  1800                     
  1801                     
  1801                     // if background scan is on, this call will cause a background scan
  1802                     // If background scan is on, this call will cause a background scan to occur.
  1802 					// when the background scan is completed, the icon is updated
  1803 					// The icon is updated after the background scan is completed.
  1803                     iBgScanProvider->NotConnected();
  1804                     iBgScanProvider->WlanStateChanged( MWlanBgScanProvider::EWlanStateDisconnected );
       
  1805                     
  1804                     break;
  1806                     break;
  1805                 case EWlanStateInfrastructure:
  1807                 case EWlanStateInfrastructure:
  1806                     DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" );
  1808                     DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" );
  1807                     iIsRoaming = EFalse;
  1809                     iIsRoaming = EFalse;
  1808                     SetIconState( EWlmIconStatusConnected );
  1810                     SetIconState( EWlmIconStatusConnected );
  2223     	status != core_error_cancel )
  2225     	status != core_error_cancel )
  2224         {
  2226         {
  2225         DEBUG( "CWlmServer::request_complete() - also additional requests can be completed" );
  2227         DEBUG( "CWlmServer::request_complete() - also additional requests can be completed" );
  2226 
  2228 
  2227         /* 
  2229         /* 
  2228          * Request can be completed using other the results of another request if
  2230          * Request can be completed using the results of another request if
  2229          * this method is related to scan scheduling and results of the triggering request can
  2231          * this method is related to scan scheduling and results of the triggering request can
  2230          * be used also to completed this request
  2232          * be used also to complete this request
  2231          *
  2233          *
  2232          * Following rules apply:
  2234          * Following rules apply:
  2233          *  - GetAvailableIaps results can be used to complete another GetAvailableIaps request, 
  2235          *  - GetAvailableIaps results can be used to complete another GetAvailableIaps request, 
  2234          *    background scan request or GetScanResults request without given SSID (broadcast scan) 
  2236          *    background scan request or GetScanResults request without given SSID (broadcast scan) 
  2235          *  - Background scan results can be used to complete GetAvailableIaps request or
  2237          *  - Background scan results can be used to complete GetAvailableIaps request or
  2249                 {
  2251                 {
  2250                 DEBUG1( "CWlmServer::request_complete() - completing additional request (ID %u)", iRequestMap[i].iRequestId );
  2252                 DEBUG1( "CWlmServer::request_complete() - completing additional request (ID %u)", iRequestMap[i].iRequestId );
  2251 
  2253 
  2252                 if( iRequestMap[i].iRequestId == KWlanIntCmdBackgroundScan )
  2254                 if( iRequestMap[i].iRequestId == KWlanIntCmdBackgroundScan )
  2253                     {
  2255                     {
  2254                     CompleteInternalRequest( i, status, EFalse );
  2256                     CompleteInternalRequest( iRequestMap[i], status, EFalse );
  2255                     bgScanCompleted = ETrue;
  2257                     bgScanCompleted = ETrue;
  2256                     }
  2258                     }
  2257                 else
  2259                 else
  2258                     {
  2260                     {
  2259                     CompleteExternalRequest( i, status, &completedMapEntry );
  2261                     CompleteExternalRequest( iRequestMap[i], status, &completedMapEntry );
  2260                     if( IsSessionActive( iRequestMap[i] ) )
  2262                     if( IsSessionActive( iRequestMap[i] ) )
  2261                         {
  2263                         {
  2262                         iRequestMap[i].iMessage.Complete( 
  2264                         iRequestMap[i].iMessage.Complete( 
  2263                             TWlanConversionUtil::ConvertErrorCode( status ) );
  2265                             TWlanConversionUtil::ConvertErrorCode( status ) );
  2264                         }
  2266                         }
  2270                 ++i;
  2272                 ++i;
  2271                 }
  2273                 }
  2272             }
  2274             }
  2273         }
  2275         }
  2274 
  2276 
  2275     // clear completedMapEntry as it is not needed anymore
  2277     DEBUG1( "CWlmServer::request_complete() - completing triggering request (ID %u)", completedMapEntry.iRequestId );
  2276     completedMapEntry = SRequestMapEntry();
       
  2277     
       
  2278     // complete the request which Core has actually handled 
       
  2279     TInt triggerIndex = FindRequestIndex( request_id );
       
  2280 
       
  2281     DEBUG1( "CWlmServer::request_complete() - completing triggering request (ID %u)", iRequestMap[triggerIndex].iRequestId );
       
  2282     if( request_id < KWlanExtCmdBase )
  2278     if( request_id < KWlanExtCmdBase )
  2283         {
  2279         {
  2284         CompleteInternalRequest( triggerIndex, status );
  2280         CompleteInternalRequest( completedMapEntry, status );
  2285         }
  2281         }
  2286     else if( iRequestMap[triggerIndex].iFunction == EJoinByProfileId ) 
  2282     else if( completedMapEntry.iFunction == EJoinByProfileId ) 
  2287         {
  2283         {
  2288         core_iap_data_s* coreIapData =
  2284         core_iap_data_s* coreIapData =
  2289             reinterpret_cast<core_iap_data_s*>( iRequestMap[triggerIndex].iParam0 );
  2285             reinterpret_cast<core_iap_data_s*>( completedMapEntry.iParam0 );
  2290         core_type_list_c<core_ssid_entry_s>* coreSsidList =
  2286         core_type_list_c<core_ssid_entry_s>* coreSsidList =
  2291             reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( iRequestMap[triggerIndex].iParam1 );
  2287             reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( completedMapEntry.iParam1 );
  2292         core_connect_status_e* connectionStatus =
  2288         core_connect_status_e* connectionStatus =
  2293             reinterpret_cast<core_connect_status_e*>( iRequestMap[triggerIndex].iParam2 );
  2289             reinterpret_cast<core_connect_status_e*>( completedMapEntry.iParam2 );
  2294 
  2290 
  2295         if( status == core_error_ok && IsSessionActive( iRequestMap[triggerIndex] ) )
  2291         if( status == core_error_ok && IsSessionActive( completedMapEntry ) )
  2296             {
  2292             {
  2297             DEBUG2("CONNECT COMPLETED WITH status == %u -> adapt == %d",
  2293             DEBUG2("CONNECT COMPLETED WITH status == %u -> adapt == %d",
  2298                 *connectionStatus,
  2294                 *connectionStatus,
  2299                 TWlanConversionUtil::ConvertConnectStatus(
  2295                 TWlanConversionUtil::ConvertConnectStatus(
  2300                     *connectionStatus,
  2296                     *connectionStatus,
  2301                     coreIapData->security_mode ) );
  2297                     coreIapData->security_mode ) );
  2302             iRequestMap[triggerIndex].iMessage.Complete(
  2298             completedMapEntry.iMessage.Complete(
  2303                 TWlanConversionUtil::ConvertConnectStatus(
  2299                 TWlanConversionUtil::ConvertConnectStatus(
  2304                     *connectionStatus,
  2300                     *connectionStatus,
  2305                     coreIapData->security_mode ) );
  2301                     coreIapData->security_mode ) );
  2306             if( *connectionStatus == core_connect_ok )
  2302             if( *connectionStatus == core_connect_ok )
  2307                 {
  2303                 {
  2308                 // If connection succeeded, raise flag indicating that
  2304                 // If connection succeeded, raise flag indicating that
  2309                 // aggressive background scanning has to be carried out
  2305                 // aggressive background scanning has to be carried out
  2310                 // in case the connection drops
  2306                 // in case the connection drops
  2311                 iAggressiveScanningAfterLinkLoss = ETrue;
  2307                 iAggressiveScanningAfterLinkLoss = ETrue;
       
  2308                 
       
  2309                 // Inform BgScan provider about successful connection.
       
  2310                 // If background scan is currently on, background scan
       
  2311                 // will be disabled and it's request will be removed
       
  2312                 // from the request map.
       
  2313                 iBgScanProvider->WlanStateChanged( MWlanBgScanProvider::EWlanStateConnected );
       
  2314                 
  2312                 }
  2315                 }
  2313             }
  2316             }
  2314         else if ( IsSessionActive( iRequestMap[triggerIndex] ) )
  2317         else if ( IsSessionActive( completedMapEntry ) )
  2315             {
  2318             {
  2316             DEBUG2("CONNECT COMPLETED WITH error == %u -> adapt == %d",
  2319             DEBUG2("CONNECT COMPLETED WITH error == %u -> adapt == %d",
  2317                 status,
  2320                 status,
  2318                 TWlanConversionUtil::ConvertErrorCode( status ) );
  2321                 TWlanConversionUtil::ConvertErrorCode( status ) );
  2319             iRequestMap[triggerIndex].iMessage.Complete(
  2322             completedMapEntry.iMessage.Complete(
  2320                 TWlanConversionUtil::ConvertErrorCode( status ) );
  2323                 TWlanConversionUtil::ConvertErrorCode( status ) );
  2321             }
  2324             }
  2322         else
  2325         else
  2323             {
  2326             {
  2324             DEBUG( "CWlmServer::request_complete() - session has already closed" );
  2327             DEBUG( "CWlmServer::request_complete() - session has already closed" );
  2325             }
  2328             }
  2326         delete coreIapData;
  2329         delete coreIapData;
  2327         delete coreSsidList;
  2330         delete coreSsidList;
  2328         delete connectionStatus;
  2331         delete connectionStatus;
  2329         iRequestMap.Remove( triggerIndex );
  2332         // re-use idx variable
  2330         }
  2333         idx = FindRequestIndex( completedMapEntry.iRequestId );
  2331     else if ( iRequestMap[triggerIndex].iFunction == ERunProtectedSetup )
  2334         if( idx < iRequestMap.Count() )
       
  2335             {
       
  2336             iRequestMap.Remove( idx );
       
  2337             }
       
  2338         }
       
  2339     else if ( completedMapEntry.iFunction == ERunProtectedSetup )
  2332         {
  2340         {
  2333         core_iap_data_s* iapData =
  2341         core_iap_data_s* iapData =
  2334             reinterpret_cast<core_iap_data_s*>( iRequestMap[triggerIndex].iParam0 );
  2342             reinterpret_cast<core_iap_data_s*>( completedMapEntry.iParam0 );
  2335         core_type_list_c<core_iap_data_s>* iapDataList =
  2343         core_type_list_c<core_iap_data_s>* iapDataList =
  2336             reinterpret_cast<core_type_list_c<core_iap_data_s>*>( iRequestMap[triggerIndex].iParam1 );
  2344             reinterpret_cast<core_type_list_c<core_iap_data_s>*>( completedMapEntry.iParam1 );
  2337         core_protected_setup_status_e* protectedSetupStatus = 
  2345         core_protected_setup_status_e* protectedSetupStatus = 
  2338             reinterpret_cast<core_protected_setup_status_e*>( iRequestMap[triggerIndex].iParam2 );
  2346             reinterpret_cast<core_protected_setup_status_e*>( completedMapEntry.iParam2 );
  2339         
  2347         
  2340         // Convert the received credentials.
  2348         // Convert the received credentials.
  2341         TWlmProtectedSetupCredentials tmp;
  2349         TWlmProtectedSetupCredentials tmp;
  2342         tmp.count = 0;
  2350         tmp.count = 0;
  2343         core_iap_data_s* iter = iapDataList->first();           
  2351         core_iap_data_s* iter = iapDataList->first();           
  2351             }
  2359             }
  2352 
  2360 
  2353         DEBUG1( "CWlmServer::request_complete() - converted %u Protected Setup credential attributes",
  2361         DEBUG1( "CWlmServer::request_complete() - converted %u Protected Setup credential attributes",
  2354             tmp.count );
  2362             tmp.count );
  2355 
  2363 
  2356         if( IsSessionActive( iRequestMap[triggerIndex] ) )
  2364         if( IsSessionActive( completedMapEntry ) )
  2357             {
  2365             {
  2358             TPckg<TWlmProtectedSetupCredentials> outPckg( tmp );
  2366             TPckg<TWlmProtectedSetupCredentials> outPckg( tmp );
  2359             iRequestMap[triggerIndex].iMessage.Write( 1, outPckg );
  2367             completedMapEntry.iMessage.Write( 1, outPckg );
  2360             }
  2368             }
  2361 
  2369 
  2362         if( status == core_error_ok && IsSessionActive( iRequestMap[triggerIndex] ) )
  2370         if( status == core_error_ok && IsSessionActive( completedMapEntry ) )
  2363             {                    
  2371             {                    
  2364             DEBUG2("PROTECTED SETUP COMPLETED WITH status == %d -> adapt == %d",
  2372             DEBUG2("PROTECTED SETUP COMPLETED WITH status == %u -> adapt == %d",
  2365                 *protectedSetupStatus,
  2373                 *protectedSetupStatus,
  2366                 TWlanConversionUtil::ConvertProtectedSetupStatus( *protectedSetupStatus ) );
  2374                 TWlanConversionUtil::ConvertProtectedSetupStatus( *protectedSetupStatus ) );
  2367             iRequestMap[triggerIndex].iMessage.Complete( 
  2375             completedMapEntry.iMessage.Complete( 
  2368                 TWlanConversionUtil::ConvertProtectedSetupStatus( *protectedSetupStatus ) );
  2376                 TWlanConversionUtil::ConvertProtectedSetupStatus( *protectedSetupStatus ) );
  2369             }
  2377             }
  2370         else if ( IsSessionActive( iRequestMap[triggerIndex] ) )
  2378         else if ( IsSessionActive( completedMapEntry ) )
  2371             {
  2379             {
  2372             DEBUG2("PROTECTED SETUP COMPLETED WITH error == %d -> adapt == %d",
  2380             DEBUG2("PROTECTED SETUP COMPLETED WITH error == %u -> adapt == %d",
  2373                 status,
  2381                 status,
  2374                 TWlanConversionUtil::ConvertErrorCode( status ) );
  2382                 TWlanConversionUtil::ConvertErrorCode( status ) );
  2375             iRequestMap[triggerIndex].iMessage.Complete( 
  2383             completedMapEntry.iMessage.Complete( 
  2376                 TWlanConversionUtil::ConvertErrorCode( status ) );                    
  2384                 TWlanConversionUtil::ConvertErrorCode( status ) );                    
  2377             }
  2385             }
  2378         else
  2386         else
  2379             {
  2387             {
  2380             DEBUG( "CWlmServer::request_complete() - session has already closed" );
  2388             DEBUG( "CWlmServer::request_complete() - session has already closed" );
  2381             }
  2389             }
  2382 
  2390 
  2383         delete iapData;
  2391         delete iapData;
  2384         delete iapDataList;
  2392         delete iapDataList;
  2385         delete protectedSetupStatus;
  2393         delete protectedSetupStatus;
  2386         iRequestMap.Remove( triggerIndex );
  2394         // re-use idx variable
       
  2395         idx = FindRequestIndex( completedMapEntry.iRequestId );
       
  2396         if( idx < iRequestMap.Count() )
       
  2397             {
       
  2398             iRequestMap.Remove( idx );
       
  2399             }
  2387         }
  2400         }
  2388     else
  2401     else
  2389         {
  2402         {
  2390         CompleteExternalRequest( triggerIndex, status );
  2403         CompleteExternalRequest( completedMapEntry, status );
  2391         if( IsSessionActive( iRequestMap[triggerIndex] ) )
  2404         if( IsSessionActive( completedMapEntry ) )
  2392             {
  2405             {
  2393             iRequestMap[triggerIndex].iMessage.Complete( 
  2406         	completedMapEntry.iMessage.Complete( 
  2394                 TWlanConversionUtil::ConvertErrorCode( status ) );
  2407                 TWlanConversionUtil::ConvertErrorCode( status ) );
  2395             }
  2408             }
  2396         iRequestMap.Remove( triggerIndex );
  2409         // re-use idx variable
       
  2410         idx = FindRequestIndex( completedMapEntry.iRequestId );
       
  2411         if( idx < iRequestMap.Count() )
       
  2412             {
       
  2413             iRequestMap.Remove( idx );
       
  2414             }
  2397         }
  2415         }
  2398 
  2416 
  2399     // Background scan request needs to be updated only after all the other request have been completed
  2417     // Background scan request needs to be updated only after all the other request have been completed
  2400     // otherwise the new request will be appended to the pending list too early
  2418     // otherwise the new request will be appended to the pending list too early
  2401     if( bgScanCompleted )
  2419     if( bgScanCompleted )
  2418 #ifdef _DEBUG
  2436 #ifdef _DEBUG
  2419     requestMapCount = iRequestMap.Count();
  2437     requestMapCount = iRequestMap.Count();
  2420     if( requestMapCount )
  2438     if( requestMapCount )
  2421         {
  2439         {
  2422         DEBUG( "CWlmServer::request_complete() - remaining requests:" );
  2440         DEBUG( "CWlmServer::request_complete() - remaining requests:" );
  2423         for ( TInt idx( 0 ); idx < requestMapCount; ++idx )
  2441         // re-use idx variable
       
  2442         for ( idx = 0; idx < requestMapCount; ++idx )
  2424             {
  2443             {
  2425             DEBUG1( "CWlmServer::request_complete() - ID %u", iRequestMap[idx].iRequestId );
  2444             DEBUG1( "CWlmServer::request_complete() - ID %u", iRequestMap[idx].iRequestId );
  2426             DEBUG1( "CWlmServer::request_complete() - function %d", iRequestMap[idx].iFunction );
  2445             DEBUG1( "CWlmServer::request_complete() - function %d", iRequestMap[idx].iFunction );
  2427             }
  2446             }
  2428         }
  2447         }
  2544 // ---------------------------------------------------------
  2563 // ---------------------------------------------------------
  2545 // CWlmServer::CompleteInternalRequest
  2564 // CWlmServer::CompleteInternalRequest
  2546 // ---------------------------------------------------------
  2565 // ---------------------------------------------------------
  2547 //
  2566 //
  2548 void CWlmServer::CompleteInternalRequest(
  2567 void CWlmServer::CompleteInternalRequest(
  2549     TUint32 aIndex, 
  2568     const SRequestMapEntry& aRequest, 
  2550     core_error_e aStatus,
  2569     core_error_e aStatus,
  2551     TBool aCompletedWasTriggering )
  2570     TBool aCompletedWasTriggering )
  2552     {
  2571     {
  2553     DEBUG1( "CWlmServer::CompleteInternalRequest() - index (%d)", aIndex );
  2572 
  2554     
  2573     TInt idx = FindRequestIndex( aRequest.iRequestId );
  2555     // Take the entry out from queue
  2574     
  2556     SRequestMapEntry requestEntry = iRequestMap[ aIndex ];
  2575     if( idx >= iRequestMap.Count() )
  2557 
  2576         {
  2558     iRequestMap.Remove( aIndex );
  2577         DEBUG1("CWlmServer::CompleteInternalRequest() - request (ID %u) not in request map", idx );
  2559 
  2578         return;
  2560     switch( requestEntry.iRequestId )
  2579         }
       
  2580     
       
  2581     DEBUG1( "CWlmServer::CompleteInternalRequest() - index (%d)", idx );
       
  2582     
       
  2583     iRequestMap.Remove( idx );
       
  2584 
       
  2585     switch( aRequest.iRequestId )
  2561         {
  2586         {
  2562         case KWlanIntCmdBackgroundScan:
  2587         case KWlanIntCmdBackgroundScan:
  2563             {
  2588             {
  2564             core_type_list_c<core_ssid_entry_s>* iapSsidList =
  2589             core_type_list_c<core_ssid_entry_s>* iapSsidList =
  2565                 reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( requestEntry.iParam3 );
  2590                 reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( aRequest.iParam3 );
  2566             delete iapSsidList;
  2591             delete iapSsidList;
  2567             iapSsidList = NULL;
  2592             iapSsidList = NULL;
  2568             
  2593             
  2569             ScanList* scanList = 
  2594             ScanList* scanList = 
  2570                 reinterpret_cast<ScanList*>( requestEntry.iParam2 );
  2595                 reinterpret_cast<ScanList*>( aRequest.iParam2 );
  2571             core_type_list_c<u32_t>* idList = 
  2596             core_type_list_c<u32_t>* idList = 
  2572                 reinterpret_cast<core_type_list_c<u32_t>*>( requestEntry.iParam1 );
  2597                 reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
  2573                 
  2598                 
  2574             core_type_list_c<core_iap_data_s>* iapDataList =
  2599             core_type_list_c<core_iap_data_s>* iapDataList =
  2575                 reinterpret_cast<core_type_list_c<core_iap_data_s>*>( requestEntry.iParam0 );
  2600                 reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2576             delete iapDataList;
  2601             delete iapDataList;
  2577             iapDataList = NULL;
  2602             iapDataList = NULL;
  2578             
  2603             
  2579             TTime* completedScanTime = reinterpret_cast<TTime*>( requestEntry.iTime );
  2604             TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
  2580             delete completedScanTime;
  2605             delete completedScanTime;
  2581             completedScanTime = NULL;
  2606             completedScanTime = NULL;
  2582 
  2607 
  2583             if( aCompletedWasTriggering )
  2608             if( aCompletedWasTriggering )
  2584                 {
  2609                 {
  2613 // ---------------------------------------------------------
  2638 // ---------------------------------------------------------
  2614 // CWlmServer::CompleteExternalRequest
  2639 // CWlmServer::CompleteExternalRequest
  2615 // ---------------------------------------------------------
  2640 // ---------------------------------------------------------
  2616 //
  2641 //
  2617 void CWlmServer::CompleteExternalRequest(
  2642 void CWlmServer::CompleteExternalRequest(
  2618     TUint32 aIndex, 
  2643     const SRequestMapEntry& aRequest,
  2619     core_error_e aStatus,
  2644     core_error_e aStatus,
  2620     SRequestMapEntry* aTriggerRequest )
  2645     SRequestMapEntry* aTriggerRequest )
  2621     {
  2646     {
  2622     DEBUG1( "CWlmServer::CompleteExternalRequest() - index (%d)", aIndex );
  2647     
  2623 
  2648     TInt idx = FindRequestIndex( aRequest.iRequestId );
  2624     // Take the entry out from queue
  2649     
  2625     SRequestMapEntry requestEntry = iRequestMap[ aIndex ];
  2650     if( idx >= iRequestMap.Count() )
       
  2651         {
       
  2652         DEBUG1("CWlmServer::CompleteExternalRequest() - request (ID %u) not in request map", idx );
       
  2653         return;
       
  2654         }
       
  2655     
       
  2656     DEBUG1( "CWlmServer::CompleteExternalRequest() - index (%d)", idx );
  2626 
  2657 
  2627     // Find out the request type
  2658     // Find out the request type
  2628     // in order to handle possible return parameters
  2659     // in order to handle possible return parameters
  2629     switch( requestEntry.iFunction )
  2660     switch( aRequest.iFunction )
  2630         {
  2661         {
  2631         case EGetScanResults:
  2662         case EGetScanResults:
  2632             {
  2663             {
  2633             ScanList* tmp( NULL );
  2664             ScanList* tmp( NULL );
  2634             core_ssid_s* ssid = reinterpret_cast<core_ssid_s*>( requestEntry.iParam1 );
  2665             core_ssid_s* ssid = reinterpret_cast<core_ssid_s*>( aRequest.iParam1 );
  2635             TTime* completedScanTime = reinterpret_cast<TTime*>( requestEntry.iTime );
  2666             TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
  2636             ScanList* completedScanList = reinterpret_cast<ScanList*>( requestEntry.iParam0 );
  2667             ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam0 );
  2637 
  2668 
  2638             if( aTriggerRequest == NULL )
  2669             if( aTriggerRequest == NULL )
  2639                 {
  2670                 {
  2640                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetScanResults request handled by core" );    
  2671                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetScanResults request handled by core" );    
  2641 
  2672 
  2642                 tmp = reinterpret_cast<ScanList*>( requestEntry.iParam0);
  2673                 tmp = reinterpret_cast<ScanList*>( aRequest.iParam0);
  2643                 }
  2674                 }
  2644             else
  2675             else
  2645                 {
  2676                 {
  2646                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetScanResults request not handled by core" );    
  2677                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetScanResults request not handled by core" );    
  2647                 // Use the results of the triggering request to complete also this other request
  2678                 // Use the results of the triggering request to complete also this other request
  2670                     tmp->Size() );				
  2701                     tmp->Size() );				
  2671                                                                 
  2702                                                                 
  2672                 DEBUG2( "CWlmServer::CompleteExternalRequest() - scan results count is %u, size is %u",
  2703                 DEBUG2( "CWlmServer::CompleteExternalRequest() - scan results count is %u, size is %u",
  2673                     tmp->Count(), tmp->Size() );
  2704                     tmp->Count(), tmp->Size() );
  2674 
  2705 
  2675                 if( requestEntry.iSessionId != 0 )
  2706                 if( IsSessionActive( aRequest ) )
  2676                     {
  2707                     {
  2677                     requestEntry.iMessage.Write( 0, ptrScanList );
  2708                     aRequest.iMessage.Write( 0, ptrScanList );
  2678                     requestEntry.iMessage.Write( 2, pckgDynamicScanList );
  2709                     aRequest.iMessage.Write( 2, pckgDynamicScanList );
  2679                     }
  2710                     }
  2680 
  2711 
  2681                 // Check whether to cache the results or not
  2712                 // Check whether to cache the results or not
  2682                 if( ssid->length > 0 && aTriggerRequest == NULL )
  2713                 if( ssid->length > 0 && aTriggerRequest == NULL )
  2683                     {
  2714                     {
  2727             core_type_list_c<core_ssid_entry_s>* iapSsidList;
  2758             core_type_list_c<core_ssid_entry_s>* iapSsidList;
  2728             ScanList* scanList;
  2759             ScanList* scanList;
  2729             core_type_list_c<u32_t>* coreIdList;
  2760             core_type_list_c<u32_t>* coreIdList;
  2730             core_type_list_c<core_iap_data_s>* iapDataList;
  2761             core_type_list_c<core_iap_data_s>* iapDataList;
  2731 
  2762 
  2732             iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( requestEntry.iParam3 );
  2763             iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( aRequest.iParam3 );
  2733             iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( requestEntry.iParam0 );
  2764             iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2734             
  2765             
  2735             TTime* completedScanTime = reinterpret_cast<TTime*>( requestEntry.iTime );
  2766             TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
  2736             ScanList* completedScanList = reinterpret_cast<ScanList*>( requestEntry.iParam2);
  2767             ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
  2737             core_type_list_c<u32_t>* completedIdList = reinterpret_cast<core_type_list_c<u32_t>*>( requestEntry.iParam1 );
  2768             core_type_list_c<u32_t>* completedIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
  2738             
  2769             
  2739             if( aTriggerRequest == NULL )
  2770             if( aTriggerRequest == NULL )
  2740                 {
  2771                 {
  2741                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request handled by core" );    
  2772                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request handled by core" );    
  2742 
  2773 
  2743                 scanList = reinterpret_cast<ScanList*>( requestEntry.iParam2);
  2774                 scanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
  2744                 coreIdList = reinterpret_cast<core_type_list_c<u32_t>*>( requestEntry.iParam1 );
  2775                 coreIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
  2745                 }
  2776                 }
  2746             else
  2777             else
  2747                 {
  2778                 {
  2748                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request not handled by core" );    
  2779                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request not handled by core" );    
  2749                 //Use the results of the triggering request to complete also this other request
  2780                 //Use the results of the triggering request to complete also this other request
  2787                     pInt = coreIdList->next();
  2818                     pInt = coreIdList->next();
  2788                     }
  2819                     }
  2789 
  2820 
  2790                 tmp.count = idx;
  2821                 tmp.count = idx;
  2791                 
  2822                 
  2792                 if( requestEntry.iSessionId != 0 )
  2823                 if( IsSessionActive( aRequest ) )
  2793                     {
  2824                     {
  2794                     TPckg<TWlmAvailableIaps> outPckg( tmp );
  2825                     TPckg<TWlmAvailableIaps> outPckg( tmp );
  2795                     requestEntry.iMessage.Write( 0, outPckg );
  2826                     aRequest.iMessage.Write( 0, outPckg );
  2796                     }
  2827                     }
  2797                 if( aTriggerRequest == NULL )
  2828                 if( aTriggerRequest == NULL )
  2798                     {
  2829                     {
  2799                     DEBUG1("CWlmServer::CompleteExternalRequest() - delete iapIdList (%d)", coreIdList);
  2830                     DEBUG("CWlmServer::CompleteExternalRequest() - delete iapIdList" );
  2800 
       
  2801                     delete coreIdList;	
  2831                     delete coreIdList;	
  2802                     }
  2832                     }
  2803                 else
  2833                 else
  2804                     {
  2834                     {
  2805                     // If this completed request was not the triggering request then there is no need
  2835                     // If this completed request was not the triggering request then there is no need
  2839             delete completedScanTime;
  2869             delete completedScanTime;
  2840             break;
  2870             break;
  2841             }
  2871             }
  2842         case EGetCurrentRSSI:
  2872         case EGetCurrentRSSI:
  2843             {
  2873             {
  2844             TUint32 tmp 
  2874             TUint32 tmp = *( reinterpret_cast<TUint32*>( aRequest.iParam0 ) );
  2845                 = *( reinterpret_cast<TUint32*>
  2875             if( IsSessionActive( aRequest ) )
  2846                    ( requestEntry.iParam0 ) );
       
  2847             if( requestEntry.iSessionId != 0 )
       
  2848                 {
  2876                 {
  2849                 TPckg<TUint32> outPckg( tmp );
  2877                 TPckg<TUint32> outPckg( tmp );
  2850                 requestEntry.iMessage.Write( 0, outPckg );
  2878                 aRequest.iMessage.Write( 0, outPckg );
  2851                 }
  2879                 }
  2852             iPrevRcpiValue = tmp;
  2880             iPrevRcpiValue = tmp;
  2853             delete reinterpret_cast<TUint32*>( requestEntry.iParam0 );
  2881             delete reinterpret_cast<TUint32*>( aRequest.iParam0 );
  2854             break;
  2882             break;
  2855             }
  2883             }
  2856         case EGetSystemMode:
  2884         case EGetSystemMode:
  2857             {
  2885             {
  2858             // not asynch request; never comes here
  2886             // not asynch request; never comes here
  2859             break;
  2887             break;
  2860             }
  2888             }
  2861         case EConfigureMulticastGroup:
  2889         case EConfigureMulticastGroup:
  2862             {
  2890             {
  2863             // no parameters to return
  2891             // no parameters to return
  2864             delete reinterpret_cast<TUint32*>( requestEntry.iParam0 );
  2892             delete reinterpret_cast<TUint32*>( aRequest.iParam0 );
  2865             break;
  2893             break;
  2866             }
  2894             }
  2867         case EGetPacketStatistics:
  2895         case EGetPacketStatistics:
  2868             {
  2896             {
  2869             core_packet_statistics_s* coreStatistics =
  2897             core_packet_statistics_s* coreStatistics =
  2870                 reinterpret_cast<core_packet_statistics_s*>( requestEntry.iParam0 );
  2898                 reinterpret_cast<core_packet_statistics_s*>( aRequest.iParam0 );
  2871             if( requestEntry.iSessionId != 0 )                
  2899             if( IsSessionActive( aRequest ) )                
  2872                 {
  2900                 {
  2873                 TPckgBuf<TWlanPacketStatistics> statisticPckg;
  2901                 TPckgBuf<TWlanPacketStatistics> statisticPckg;
  2874                 TWlanConversionUtil::ConvertPacketStatistics(
  2902                 TWlanConversionUtil::ConvertPacketStatistics(
  2875                     statisticPckg(),
  2903                     statisticPckg(),
  2876                     *coreStatistics );
  2904                     *coreStatistics );
  2877                 requestEntry.iMessage.Write( 0, statisticPckg );
  2905                 aRequest.iMessage.Write( 0, statisticPckg );
  2878                 }
  2906                 }
  2879             delete coreStatistics;
  2907             delete coreStatistics;
  2880             break;
  2908             break;
  2881             }
  2909             }
  2882         case ECreateTrafficStream:
  2910         case ECreateTrafficStream:
  2883             {
  2911             {
  2884             u32_t* coreStreamId =
  2912             u32_t* coreStreamId = reinterpret_cast<u32_t*>( aRequest.iParam0 );
  2885                 reinterpret_cast<u32_t*>( requestEntry.iParam0 );
       
  2886             core_traffic_stream_status_e* coreStreamStatus =
  2913             core_traffic_stream_status_e* coreStreamStatus =
  2887                 reinterpret_cast<core_traffic_stream_status_e*>( requestEntry.iParam1 );
  2914                 reinterpret_cast<core_traffic_stream_status_e*>( aRequest.iParam1 );
  2888             if( requestEntry.iSessionId != 0 &&
  2915             if( IsSessionActive( aRequest ) &&
  2889                 aStatus == core_error_ok )
  2916                 aStatus == core_error_ok )
  2890                 {                
  2917                 {                
  2891                 TPckgBuf<TUint> streamIdPckg(
  2918                 TPckgBuf<TUint> streamIdPckg(
  2892                     *coreStreamId ); 
  2919                     *coreStreamId ); 
  2893                 TPckgBuf<TWlanTrafficStreamStatus> streamStatusPckg(
  2920                 TPckgBuf<TWlanTrafficStreamStatus> streamStatusPckg(
  2894                     TWlanConversionUtil::ConvertTrafficStreamStatus( *coreStreamStatus ) );                
  2921                     TWlanConversionUtil::ConvertTrafficStreamStatus( *coreStreamStatus ) );                
  2895                 requestEntry.iMessage.Write( 2, streamIdPckg );
  2922                 aRequest.iMessage.Write( 2, streamIdPckg );
  2896                 requestEntry.iMessage.Write( 3, streamStatusPckg );
  2923                 aRequest.iMessage.Write( 3, streamStatusPckg );
  2897                 }
  2924                 }
  2898             delete coreStreamId;
  2925             delete coreStreamId;
  2899             delete coreStreamStatus;
  2926             delete coreStreamStatus;
  2900             break;
  2927             break;
  2901             }
  2928             }
  2910             break;
  2937             break;
  2911             }            
  2938             }            
  2912         default:
  2939         default:
  2913             {
  2940             {
  2914             DEBUG1( "CWlmServer::CompleteExternalRequest() - ERROR: unknown request type (%d)!",
  2941             DEBUG1( "CWlmServer::CompleteExternalRequest() - ERROR: unknown request type (%d)!",
  2915                 requestEntry.iFunction );
  2942                 aRequest.iFunction );
  2916             break;
  2943             break;
  2917             }
  2944             }
  2918         }    
  2945         }    
  2919     }
  2946     }
  2920 
  2947 
  3118                     // Remove the cancelled request
  3145                     // Remove the cancelled request
  3119                     DEBUG( "CWlmServer::CancelExternalRequest() - Core is not handling currently this scan request" );
  3146                     DEBUG( "CWlmServer::CancelExternalRequest() - Core is not handling currently this scan request" );
  3120                     DEBUG( "CWlmServer::CancelExternalRequest() - this request is not the scan scheduling triggering request" );
  3147                     DEBUG( "CWlmServer::CancelExternalRequest() - this request is not the scan scheduling triggering request" );
  3121                     DEBUG( "CWlmServer::CancelExternalRequest() - remove the cancelled request" );
  3148                     DEBUG( "CWlmServer::CancelExternalRequest() - remove the cancelled request" );
  3122 
  3149 
  3123                     CompleteExternalRequest( i, core_error_cancel );
  3150                     CompleteExternalRequest( iRequestMap[i], core_error_cancel );
  3124                     if( IsSessionActive( iRequestMap[i] ) )
  3151                     if( IsSessionActive( iRequestMap[i] ) )
  3125                         {
  3152                         {
  3126                         iRequestMap[i].iMessage.Complete( 
  3153                         iRequestMap[i].iMessage.Complete( 
  3127                             TWlanConversionUtil::ConvertErrorCode( core_error_cancel ) );
  3154                             TWlanConversionUtil::ConvertErrorCode( core_error_cancel ) );
  3128                         }
  3155                         }
  5097             aCoreIapData.iap_id = wlanIapIds[i].iIAPId;
  5124             aCoreIapData.iap_id = wlanIapIds[i].iIAPId;
  5098             i = IapsCount; 
  5125             i = IapsCount; 
  5099             }
  5126             }
  5100         }
  5127         }
  5101     
  5128     
       
  5129     wlanIapIds.Close();
  5102     wlanSettings.Disconnect();
  5130     wlanSettings.Disconnect();
  5103     
  5131     
  5104     DEBUG( "CWlmServer::GetCurrentIapId() - all done" );   
  5132     DEBUG( "CWlmServer::GetCurrentIapId() - all done" );   
  5105     
  5133     
  5106     return KErrNone;
  5134     return KErrNone;