Revision: 201003 RCL_3 PDK_3.0.h
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Sat, 20 Feb 2010 00:38:18 +0200
branchRCL_3
changeset 3 6524e815f76f
parent 0 c40eb8fe8501
child 5 51a71243e562
Revision: 201003 Kit: 201007
wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/abs_core_driverif.h
wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_sub_operation_connect.h
wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_sub_operation_wpa_connect.h
wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_types.h
wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_operation_roam.cpp
wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_connect.cpp
wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_wep_connect.cpp
wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_wpa_connect.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/bwinscw/wlmplatformu.def
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/bwinscw/wlmserveru.def
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/eabi/wlmplatformu.def
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/eabi/wlmserveru.def
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/group/wlmserversrv.mmh
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/rwlmserver.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscan.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscanawscomms.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscanawscommsinterface.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscanstates.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanconversionutil.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanmgmtcommandhandler.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanmgmtimpl.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanscanproviderinterface.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlantimer.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlantimerserviceinterface.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlantimerservices.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmclientserver.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmdriverif.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmplatform.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmplatformdata.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmserver.h
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/rom/wlaneng.iby
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/rwlmserver.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanbgscan.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanbgscanawscomms.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanbgscanstates.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanconversionutil.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanmgmtcommandhandler.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanmgmtimpl.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlansystemtimehandler.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlantimer.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmdriverif.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmplatform.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmplatformdata.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp
wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmsession.cpp
wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacContextImpl.h
wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacContextImpl.inl
wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacDot11Synchronize.h
wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacconnectcontext.h
wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacconnectcontext.inl
wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacoidmsg.h
wlan_bearer/wlanldd/wlan_common/umac_common/src/Umac.cpp
wlan_bearer/wlanldd/wlan_common/umac_common/src/UmacDot11Associated.cpp
wlan_bearer/wlanldd/wlan_common/umac_common/src/UmacDot11Synchronize.cpp
wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/DataFrameMemMngr.h
wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/EthernetFrameMemMngr.h
wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/MgmtFrameMemMngr.h
wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/DataFrameMemMngr.cpp
wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/EthernetFrameMemMngr.cpp
wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/MgmtFrameMemMngr.cpp
wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp
wlan_bearer/wlannwif/inc/CLanxBearer.h
wlan_bearer/wlannwif/src/CLanIp4Bearer.cpp
wlan_bearer/wlannwif/src/CLanIp6Bearer.cpp
wlan_bearer/wlanpsmplugin/rom/wlanpsmplugin.iby
wlan_plat/wlan_aws_plugin_api/inc/awsenginebase.h
wlan_plat/wlan_info_api/inc/wlaninternalpskeys.h
wlan_plat/wlan_management_api/inc/wlanmgmtinterface.h
--- a/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/abs_core_driverif.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/abs_core_driverif.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,6 +16,9 @@
 *
 */
 
+/*
+* %version: 35 %
+*/
 
 #ifndef ABS_CORE_DRIVERIF_H
 #define ABS_CORE_DRIVERIF_H
@@ -121,6 +124,7 @@
      * @param is_pairwise_key_invalidated Whether the pairwise key should be invalidated.
      * @param is_group_key_invalidated Whether the group key should be invalidated
      * @param is_radio_measurement_supported Whether the radio measurement is supported
+     * @param pairwise_key Pairwise key to set before association. NULL if none.
      */
     virtual void connect(
         u32_t request_id,
@@ -137,7 +141,8 @@
         const u8_t* scan_frame,
         bool_t is_pairwise_key_invalidated,
         bool_t is_group_key_invalidated,
-        bool_t is_radio_measurement_supported ) = 0;
+        bool_t is_radio_measurement_supported,
+        const core_cipher_key_s* pairwise_key ) = 0;
 
     /**
      * Disconnect from the current network.
--- a/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_sub_operation_connect.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_sub_operation_connect.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 18 %
+*/
 
 #ifndef CORE_SUB_OPERATION_CONNECT_H
 #define CORE_SUB_OPERATION_CONNECT_H
@@ -73,7 +76,8 @@
         core_type_list_c<core_frame_dot11_ie_c>& assoc_ie_list,
         core_frame_assoc_resp_c** assoc_resp,
         bool_t is_pairwise_key_invalidated,
-        bool_t is_group_key_invalidated );
+        bool_t is_group_key_invalidated,
+        const core_cipher_key_s* pairwise_key );
 
     /**
      * Destructor.
@@ -186,6 +190,11 @@
      */
     bool_t is_group_key_invalidated_m;
 
+    /**
+     * Pairwise key to be set before association. Not owned by this pointer.
+     */
+    const core_cipher_key_s* pairwise_key_m;
+
     };
 
 #endif // CORE_SUB_OPERATION_CONNECT_H
--- a/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_sub_operation_wpa_connect.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_sub_operation_wpa_connect.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 28 %
+*/
 
 #ifndef CORE_SUB_OPERATION_WPA_CONNECT_H
 #define CORE_SUB_OPERATION_WPA_CONNECT_H
@@ -269,6 +272,11 @@
      */
     bool_t is_key_caching_used_m;
 
+    /**
+     * Pairwise key to set before association. CIPHER_KEY_NOT_DEFINED if none.
+     */
+    core_cipher_key_s pairwise_key_m;
+
     };
 
 #endif // CORE_SUB_OPERATION_WPA_CONNECT_H
--- a/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_types.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_types.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 93 %
+* %version: 93.1.1 %
 */
 
 #ifndef CORE_TYPES_H
@@ -416,6 +416,21 @@
     } core_wep_key_s;
 
 /**
+ * Data structure for storing a cipher key.
+ */
+typedef struct _core_cipher_key_s
+    {
+    /** The length of KeyMaterial in bytes. Range: 0-29. */
+    u32_t key_length;
+    /** Specifies which key to add or remove. Range: 0-3. */
+    u8_t key_index;
+    /** Array that stores the WEP key. */
+    u8_t key_data[MAX_CIPHER_KEY_LENGTH];
+    } core_cipher_key_s;    
+
+const core_cipher_key_s CIPHER_KEY_NOT_DEFINED = { 0,0 };
+
+/**
  * Data structure for storing an ARP filters.
  */
 typedef struct _core_arp_filter_s
--- a/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_operation_roam.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_operation_roam.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 75 %
+* %version: 76 %
 */
 
 #include "core_operation_roam.h"
@@ -328,7 +328,8 @@
                     assoc_ie_list_m,
                     is_ibss_mode ? NULL : &assoc_resp_m,
                     true_t,    // ignored, pairwise key not used
-                    true_t );  // ignored, group key not used
+                    true_t,    // ignored, group key not used
+                    NULL );
 
                 return run_sub_operation( operation );
                 }
@@ -813,9 +814,10 @@
                     return core_connect_wep_shared_authentication_unsupported;
                     }
                 }
-            else if ( iap_data.authentication_mode() == core_authentication_mode_shared &&            
+            else if ( iap_data.authentication_mode() == core_authentication_mode_shared &&
                       ( management_status == core_management_status_auth_challenge_failure ||
                         management_status == core_management_status_auth_frame_out_of_sequence ||
+                        management_status == core_management_status_unspecified_failure ||
                         request_status == core_error_timeout ) )
                 {
                 DEBUG( "core_operation_roam_c::connect_status() - shared authentication failed (WEP)" );
--- a/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_connect.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_connect.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 29 %
+*/
 
 #include "core_sub_operation_connect.h"
 #include "core_operation_update_tx_rate_policies.h"
@@ -45,7 +48,8 @@
     core_type_list_c<core_frame_dot11_ie_c>& assoc_ie_list,
     core_frame_assoc_resp_c** assoc_resp,
     bool_t is_pairwise_key_invalidated,
-    bool_t is_group_key_invalidated ) :
+    bool_t is_group_key_invalidated,
+    const core_cipher_key_s* pairwise_key ) :
     core_operation_base_c( core_operation_unspecified, request_id, server, drivers, adaptation,
         core_base_flag_drivers_needed ),
     is_connected_m( is_connected ),
@@ -60,7 +64,8 @@
     assoc_ie_data_m( NULL ),
     assoc_resp_m( assoc_resp ),
     is_pairwise_key_invalidated_m( is_pairwise_key_invalidated ),
-    is_group_key_invalidated_m( is_group_key_invalidated )
+    is_group_key_invalidated_m( is_group_key_invalidated ),
+    pairwise_key_m( pairwise_key )
     {
     DEBUG( "core_sub_operation_connect_c::core_sub_operation_connect_c()" );
     }
@@ -75,6 +80,7 @@
     server_m->unregister_frame_handler( this );
     delete[] assoc_ie_data_m;   
     assoc_resp_m = NULL;
+    pairwise_key_m = NULL;
     }
 
 // ---------------------------------------------------------------------------
@@ -242,7 +248,8 @@
                 ap_data_m.frame()->payload_data(),
                 is_pairwise_key_invalidated_m,
                 is_group_key_invalidated_m,
-                ap_data_m.is_radio_measurement_supported() );
+                ap_data_m.is_radio_measurement_supported(),
+                pairwise_key_m );
 
             break;    
             }
--- a/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_wep_connect.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_wep_connect.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 6 %
+*/
 
 #include "core_sub_operation_wep_connect.h"
 #include "core_sub_operation_connect.h"
@@ -101,7 +104,8 @@
                 assoc_ie_list_m,
                 assoc_resp_m,
                 true_t,    // ignored, pairwise key not used
-                false_t );
+                false_t,
+                NULL );
 
             return run_sub_operation( operation, core_state_connect );
             }
--- a/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_wpa_connect.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_wpa_connect.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 59 %
+*/
 
 #include "core_sub_operation_wpa_connect.h"
 #include "core_sub_operation_connect.h"
@@ -59,7 +62,8 @@
     eapol_auth_type_m( wlan_eapol_if_eapol_key_authentication_type_none ),
     assoc_ie_list_m( assoc_ie_list ),
     assoc_resp_m( assoc_resp ),
-    is_key_caching_used_m( false_t )
+    is_key_caching_used_m( false_t ),
+    pairwise_key_m( CIPHER_KEY_NOT_DEFINED )
     {
     DEBUG( "core_sub_operation_wpa_connect_c::core_sub_operation_wpa_connect_c()" );
     }
@@ -380,7 +384,8 @@
                 assoc_ie_list_m,
                 assoc_resp_m,
                 is_pairwise_key_invalidated,
-                true_t );
+                true_t,
+                pairwise_key_m.key_length ? &pairwise_key_m : NULL );
 
             return run_sub_operation( operation );
             }
@@ -797,14 +802,32 @@
             ap_data_m.best_pairwise_cipher(),
             ap_data_m.best_group_cipher() );
 
-    ASSERT( drivers_m );
-    drivers_m->add_cipher_key(
-        type,
-        static_cast<u8_t>( key->key_index ),
-        static_cast<u16_t>( key->key_length ),
-        key->key,
-        mac,
-        true_t );
+    /**
+     * If a pairwise key is supplied before association, we cache it for
+     * later use instead of immediately setting it.
+     */
+    if ( is_cached_sa_used_m &&
+         eapol_auth_type_m == wlan_eapol_if_eapol_key_authentication_type_wpx_fast_roam &&
+         key->eapol_key_type == wlan_eapol_if_eapol_key_type_unicast )
+        {
+        pairwise_key_m.key_length = static_cast<u16_t>( key->key_length );
+        pairwise_key_m.key_index = static_cast<u8_t>( key->key_index );
+        core_tools_c::copy(
+            &pairwise_key_m.key_data[0],
+            key->key,
+            pairwise_key_m.key_length );
+        }
+    else
+        {
+        ASSERT( drivers_m );
+        drivers_m->add_cipher_key(
+            type,
+            static_cast<u8_t>( key->key_index ),
+            static_cast<u16_t>( key->key_length ),
+            key->key,
+            mac,
+            true_t );
+        }
 
     return core_error_ok;
     }
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/bwinscw/wlmplatformu.def	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/bwinscw/wlmplatformu.def	Sat Feb 20 00:38:18 2010 +0200
@@ -9,4 +9,4 @@
 	?PublishMacAddress@CWlmPlatform@@QAEHAAUTMacAddress@@@Z @ 8 NONAME ; int CWlmPlatform::PublishMacAddress(struct TMacAddress &)
 	?SetIconState@CWlmPlatform@@QAEHW4TWlmIconStatus@@@Z @ 9 NONAME ; int CWlmPlatform::SetIconState(enum TWlmIconStatus)
 	?InitializeSystemTimeHandler@CWlmPlatform@@QAEXXZ @ 10 NONAME ; void CWlmPlatform::InitializeSystemTimeHandler(void)
-
+	?PublishBgScanInterval@CWlmPlatform@@QAEXAAK@Z @ 11 NONAME ; void CWlmPlatform::PublishBgScanInterval(unsigned long &)
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/bwinscw/wlmserveru.def	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/bwinscw/wlmserveru.def	Sat Feb 20 00:38:18 2010 +0200
@@ -46,4 +46,4 @@
 	?Connect@RWLMServer@@QAEHXZ @ 45 NONAME ; int RWLMServer::Connect(void)
 	?SetPowerSaveMode@RWLMServer@@QAEHW4TWlanPowerSaveMode@@@Z @ 46 NONAME ; int RWLMServer::SetPowerSaveMode(enum TWlanPowerSaveMode)
 	?GetPowerSaveSettings@RWLMServer@@QAEHAAUTWlanPowerSaveSettings@@@Z @ 47 NONAME ; int RWLMServer::GetPowerSaveSettings(struct TWlanPowerSaveSettings &)
-
+	?StartAggressiveBgScan@RWLMServer@@QAEHI@Z @ 48 NONAME ; int RWLMServer::StartAggressiveBgScan(unsigned int)
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/eabi/wlmplatformu.def	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/eabi/wlmplatformu.def	Sat Feb 20 00:38:18 2010 +0200
@@ -11,4 +11,4 @@
 	_ZN12CWlmPlatformD1Ev @ 10 NONAME
 	_ZN12CWlmPlatformD2Ev @ 11 NONAME
 	_ZN12CWlmPlatform27InitializeSystemTimeHandlerEv @ 12 NONAME
-
+	_ZN12CWlmPlatform21PublishBgScanIntervalERm @ 13 NONAME
\ No newline at end of file
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/eabi/wlmserveru.def	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/eabi/wlmserveru.def	Sat Feb 20 00:38:18 2010 +0200
@@ -46,4 +46,5 @@
 	_ZN10RWLMServer7ConnectEv @ 45 NONAME
 	_ZN10RWLMServer7ReleaseEv @ 46 NONAME
 	_ZN10RWLMServer8GetBSSIDER11TMacAddress @ 47 NONAME
+	_ZN10RWLMServer21StartAggressiveBgScanEj @ 48 NONAME
 
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/group/wlmserversrv.mmh	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/group/wlmserversrv.mmh	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 8 %
+* %version: 9 %
 */
 
 TARGETTYPE      dll
@@ -142,7 +142,9 @@
 SOURCE          wlanbgscan.cpp
 SOURCE          wlanbgscanawscomms.cpp
 SOURCE          wlanbgscancommand.cpp
+SOURCE          wlanbgscanstates.cpp
 SOURCE          wlantimerservices.cpp
+SOURCE          wlantimer.cpp
 
 USERINCLUDE     ../inc
 USERINCLUDE     ../../../../inc
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/rwlmserver.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/rwlmserver.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 24 %
+* %version: 25 %
 */
 
 #ifndef RWLMSERVER_H
@@ -546,6 +546,27 @@
          * Cancel an outstanding directed roam request.
          */
         IMPORT_C void CancelDirectedRoam();
+        
+        /**
+         * Start aggressive background scanning.
+         * 
+         * Sends a blind request (i.e. request is sent without waiting for
+         * reply) to WLAN Engine to enter aggressive BG scan mode. WLAN
+         * Engine decides how long it stays in the aggressive mode. The
+         * client can monitor BG scan interval changes via WLAN Info P&S.
+         * The request is valid only when WLAN is disconnected, if the request
+         * is sent when WLAN is connected, it is ignored. If the interval
+         * given as a parameter is out of valid range, it is automatically
+         * corrected to closest valid value. In case of multiple simultaneous
+         * requests, the one with highest scan frequency is served.
+         * 
+         * @since S60 v5.2
+         * @param aInterval Desired background scan interval in seconds.
+         *                  Valid range is from 1 to 120 seconds.
+         * @return KErrNone if sending succeeded, an error otherwise
+         */
+        IMPORT_C TInt StartAggressiveBgScan(
+            TUint aInterval );
 
     protected: // Methods
 
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscan.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscan.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 7 %
+* %version: 9 %
 */
 
 #ifndef WLANBGSCAN_H
@@ -25,8 +25,12 @@
 #include "awsinterface.h"
 #include "awsenginebase.h"
 #include "wlanscanproviderinterface.h"
-#include "wlantimerservices.h"
-#include "wlanbgscanawscomms.h"
+#include "wlantimerserviceinterface.h"
+#include "wlanbgscanawscommsinterface.h"
+#include "wlanbgscancommandlistener.h"
+#include "wlanbgscanstates.h"
+
+
 
 /**
  *  WLAN Background Scan
@@ -37,22 +41,12 @@
 NONSHARABLE_CLASS( CWlanBgScan ) :
     public MWlanBgScanProvider,
     public MWlanTimerServiceCallback,
-    public MWlanBgScanCommandListener
+    public MWlanBgScanCommandListener,
+    public CWlanBgScanStates
     {
 
 public:
-        
-    /**
-     * States for WLAN Background Scan.
-     */
-    enum TWlanBgScanState
-        {
-        EBgScanOff = 0,
-        EBgScanOn,
-        EBgScanAuto,
-        EBgScanAutoAws
-        };
-    
+            
     /**
      * States for Auto period.
      */
@@ -72,11 +66,21 @@
         EInsideRange,
         EGreater
         };
+    
+    /**
+     * Possible statuses for AWS presence.
+     */
+    enum TAwsPresence
+        {
+        EAwsPresent,
+        EAwsNotPresent,
+        EAwsStarting
+        };
 
     /**
      * Two-phased constructor.
      */
-    static CWlanBgScan* NewL( MWlanScanResultProvider& aProvider, CWlanTimerServices& aTimerServices );
+    static CWlanBgScan* NewL( MWlanScanResultProvider& aProvider, MWlanTimerServices& aTimerServices );
     
     /**
     * Destructor.
@@ -86,18 +90,6 @@
     /**
      * From MWlanBgScanProvider.
      * Called when Scan has been completed.
-     * 
-     * \msc
-     * ScanResultProvider,CWlanBgScan;
-     * --- [label="Scan is done"];
-     * ScanResultProvider=>CWlanBgScan [label="ScanComplete()"];
-     * ScanResultProvider<=CWlanBgScan [label="Scan()"];
-     * --- [label="New scan request is placed to queue or"];
-     * --- [label="existing request's scan time is updated"];
-     * ScanResultProvider>>CWlanBgScan [label="return"];
-     * ScanResultProvider<<CWlanBgScan [label="return"];
-     * \endmsc
-     * 
      *
      * @since S60 v5.2
      */
@@ -107,15 +99,6 @@
      * From MWlanBgScanProvider.
      * Issued when WLAN is disconnected.
      *
-     * \msc
-     * ScanResultProvider,CWlanBgScan;
-     * --- [label="WLAN is disconnected"];
-     * ScanResultProvider=>CWlanBgScan [label="NotConnected()"];
-     * ScanResultProvider<=CWlanBgScan [label="Scan( aMaxDelay=0 )"];
-     * ScanResultProvider>>CWlanBgScan [label="return"];
-     * ScanResultProvider<<CWlanBgScan [label="return"];
-     * \endmsc
-     *
      * @since S60 v5.2
      */
     void NotConnected();
@@ -144,7 +127,7 @@
      * From MAwsBgScanProvider.
      * Set new background scan interval.
      * Asynchronous method to set new background scan interval, executed in
-     * AWS thread.
+     * AWS thread context.
      *
      * @since S60 v5.2
      * @param aNewInterval new interval to be taken into use
@@ -172,61 +155,44 @@
      */
     void DoSetInterval( TUint32 aNewInterval );
     
-private:
-    
     /**
-     * Constructor.
+     * This method is called by the command queue when
+     * AWS startup has been completed.
+     * 
+     * @since S60 v5.2
      */
-    CWlanBgScan( MWlanScanResultProvider& aProvider, CWlanTimerServices& aTimerServices  );
+    void AwsStartupComplete( TInt aStatus );
     
     /**
-     * Two-phased constructor.
+     * This method is called by the command queue when
+     * AWS command has been completed.
+     * 
+     * @param aCommand completed command
+     * @param aStatus completion code of the command
+     * 
+     * @since S60 v5.2
      */
-    void ConstructL();
-        
-    /**
-     * Main state machine
-     *
-     * @since S60 v5.2
-     * @param aNewBgScanSetting new background scan setting to be taken into use
-     */
-    void NextState( TUint32 aNewBgScanSetting );
+    void AwsCommandComplete( MWlanBgScanAwsComms::TAwsCommand& aCommand, TInt aStatus );
     
     /**
-     * State machine for Off state
+     * Send AWS command
+     * 
+     * @param aCommand command to be sent
+     * 
+     * @since S60 v5.2
+     */
+    void AwsCommand( MWlanBgScanAwsComms::TAwsMessage& aCommand );
+    
+    /**
+     * AWS presence status.
      *
      * @since S60 v5.2
-     * @param aState reference to state
-     * @param aNewInterval new background scan setting to be taken into use
-     */
-    void InStateOff( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
-    
-    /**
-     * State machine for On state
-     *
-     * @since S60 v5.2
-     * @param aState reference to state
-     * @param aNewBgScanSetting new background scan setting to be taken into use
+     * @return EAwsPresent if AWS is available,
+     *         EAwsNotPresent if AWS is not available,
+     *         EAwsStarting if AWS is still starting up 
+     *         
      */
-    void InStateOn( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
-
-    /**
-     * State machine for Auto state
-     *
-     * @since S60 v5.2
-     * @param aState reference to state
-     * @param aNewBgScanSetting new background scan setting to be taken into use
-     */
-    void InStateAuto( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
-    
-    /**
-     * State machine for Auto with AWS state
-     *
-     * @since S60 v5.2
-     * @param aState reference to state
-     * @param aNewBgScanSetting new background scan setting to be taken into use
-     */
-    void InStateAutoAws( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
+    CWlanBgScan::TAwsPresence AwsPresence();
     
     /**
      * Request callback when interval change should take place.
@@ -243,24 +209,34 @@
      * @return interval
      */
     TUint32 CurrentAutoInterval();
-    
+  
     /**
-     * Get current interval.
+     * Start aggressive background scanning.
      *
      * @since S60 v5.2
-     * @return current interval in use
+     * @param aInterval scan interval for aggressive mode, in seconds
+     * @param aTimeout aggressive mode duration, in microseconds
      */
-    TUint32 GetInterval();
+    void StartAggressiveBgScan( TUint32& aInterval, TUint32& aTimeout );
+
+private:
     
     /**
-     * Set current interval.
-     *
-     * @param aInterval interval to take into use
-     * @since S60 v5.2
+     * Constructor.
+     */
+    CWlanBgScan( MWlanScanResultProvider& aProvider, MWlanTimerServices& aTimerServices );
+    
+    /**
+     * Default constructor, no implementation.
      */
-    void SetInterval( TUint32 aInterval );
+    CWlanBgScan();
     
     /**
+     * Two-phased constructor.
+     */
+    void ConstructL();
+        
+    /**
      * Get next time when to change Auto interval.
      *
      * @since S60 v5.2
@@ -281,24 +257,6 @@
     TRelation TimeRelationToRange( const TTime& aTime, TUint aRangeStart, TUint aRangeEnd ) const;
     
     /**
-     * Deliver new background interval.
-     *
-     * @since S60 v5.2
-     * 
-     * @param aNewInterval new interval to be taken into use
-     */
-    void IntervalChanged( TUint32 aNewInterval );
-    
-    /**
-     * Is AWS present in system.
-     *
-     * @since S60 v5.2
-     * @return ETrue if background scan is enabled,
-     *         EFalse otherwise.
-     */
-    TBool IsAwsPresent();
-    
-    /**
      * Check the proposed settings are valid.
      *
      * @since S60 v5.2
@@ -327,19 +285,9 @@
     MWlanScanResultProvider& iProvider;
     
     /**
-     * Actually used interval for backgroundscan. 
-     */
-    TUint32 iCurrentBgScanInterval;
-    
-    /**
-     * Reference to BgScan <-> AWS communications object. 
+     * Interface to AWS comms object. 
      */
-    CWlanBgScanAwsComms* iAwsComms;
-    
-    /**
-     * Current background scan state. 
-     */
-    TWlanBgScanState iBgScanState;
+    MWlanBgScanAwsComms* iAwsComms;
     
     /**
      * Current Auto period. 
@@ -347,36 +295,15 @@
     TWlanBgScanAutoPeriod iAutoPeriod;
     
     /**
-     * Reference to WLAN Timer services. 
+     * Whether AWS is ok or not. 
      */
-    CWlanTimerServices& iTimerServices;
-
-    /**
-     * Id of the timer service request regarding 
-     * background scan interval change.
-     */
-    TUint iIntervalChangeRequestId;
-
-    /**
-     * Background scan peak start time.
-     */
-    TUint iBgScanPeakStartTime;
+    TBool iAwsOk;
     
     /**
-     * Background scan peak end time.
-     */
-    TUint iBgScanPeakEndTime;
-    
-    /**
-     * Peak time interval.
+     * Current PSM server mode. 
      */
-    TUint iBgScanIntervalPeak;
-    
-    /**
-     * Off-peak time interval.
-     */
-    TUint iBgScanIntervalOffPeak;
-        
+    TUint iCurrentPsmServerMode;
+            
     };
 
 #endif // WLANBGSCAN_H
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscanawscomms.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscanawscomms.h	Sat Feb 20 00:38:18 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 1 %
+* %version: 2 %
 */
 
 #ifndef WLANBGSCANAWSCOMMS_H
@@ -40,30 +40,11 @@
 NONSHARABLE_CLASS( CWlanBgScanAwsComms ) :
     public CActive,
     public MAwsBgScanProvider,
-    public MWlanBgScanCommandListener
+    public MWlanBgScanCommandListener,
+    public MWlanBgScanAwsComms
     {
 
 public:
-    
-    /**
-     * AWS commands.
-     */
-    enum TAwsCommand
-        {
-        EStart = 0,
-        EStop,
-        ESetPowerSaveMode,
-        EAwsCommandMax //not a real command
-        };
-    
-    /**
-     * AWS message.
-     */
-    struct TAwsMessage
-        {
-        TAwsCommand iCmd;
-        TInt iParameter;
-        };
 
     /**
      * Two-phased constructor.
@@ -103,14 +84,13 @@
      * @since S60 v5.2
      */
     void SendOrQueueAwsCommand( TAwsMessage& aMessage );
-
+    
     /**
-     * Whether AWS is present in system.
+     * Blocks calling thread until AWS is constructed.
      *
      * @since S60 v5.2
-     * @return ETrue if present, EFalse if not
      */
-    TBool IsAwsPresent();
+    //void WaitForAwsStartupToComplete();
     
 private: // From CActive
     
@@ -169,9 +149,9 @@
     static TInt AwsThreadEntryPoint( TAny* aThisPtr );
     
     /**
-     * Instantiate AWS ECOM Plugin.
+     * Instantiate and run AWS ECOM Plugin.
      */
-    void InstantiateAwsPluginL();
+    void InstantiateAndRunAwsPluginL();
 
     /**
      * Send message to AWS.
@@ -194,9 +174,9 @@
     CAwsEngineBase* iAws;
     
     /**
-     * Reference to AWS ECOM plugin implementation info. 
+     * AWS ECOM plugin UID. 
      */
-    CImplementationInformation* iAwsImplInfo;
+    TInt iAwsImplUid;
 
     /**
      * Command Handler.
@@ -222,6 +202,16 @@
      * If AWS instantiation was successful.
      */
     TBool iAwsOk;
+    
+    /**
+     * Synchronization object between WLAN Engine and AWS threads.
+     */
+    //RSemaphore iStartupLock;
+    
+    /**
+     * Handle to WLAN Engine thread.
+     */
+    RThread iWlanEngineThread;
         
     };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscanawscommsinterface.h	Sat Feb 20 00:38:18 2010 +0200
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This abstract class defines WLAN scan provider interface.
+*
+*/
+
+/*
+* %version: 3 %
+*/
+
+
+#ifndef WLANBGSCANAWSCOMMSINTERFACE_H
+#define WLANBGSCANAWSCOMMSINTERFACE_H
+
+#include <e32def.h>
+#include <e32base.h>
+
+/**
+ * @brief Interface definition for WLAN Scan Result Provider API.
+ *
+ * This class defines the methods used for issuing and cancelling Scan requests.
+ *
+ * @since S60 v5.2
+ */
+class MWlanBgScanAwsComms
+    {
+    
+public:
+    
+    virtual ~MWlanBgScanAwsComms(){};
+    
+    /**
+     * AWS commands.
+     */
+    enum TAwsCommand
+        {
+        EStart = 0,
+        EStop,
+        ESetPowerSaveMode,
+        EAwsStartupCompleted,
+        EAwsCommandMax //not a real command
+        };
+    
+    /**
+     * AWS message.
+     */
+    struct TAwsMessage
+        {
+        TAwsCommand iCmd;
+        TInt iParameter;
+        };
+
+    /**
+     * Send or queue a message to be sent to AWS.
+     *
+     * @param aMessage Message to be sent
+     * @since S60 v5.2
+     */
+    virtual void SendOrQueueAwsCommand( TAwsMessage& aMessage ) = 0;
+
+    };
+
+
+// forward declarations
+class CWlanBgScan;
+
+class CWlanBgScanAwsCommsFactory : public CBase
+    {
+public:
+    static MWlanBgScanAwsComms* InstanceL( CWlanBgScan& aBgScan );
+    };
+
+
+
+#endif // WLANBGSCANAWSCOMMSINTERFACE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanbgscanstates.h	Sat Feb 20 00:38:18 2010 +0200
@@ -0,0 +1,544 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class implementing WLAN background scan logic
+*
+*/
+
+/*
+* %version: 2 %
+*/
+
+#ifndef WLANBGSCANSTATES_H
+#define WLANBGSCANSTATES_H
+
+//#include "wlanbgscan.h"
+#include "awsinterface.h"
+#include "awsenginebase.h"
+#include "wlanscanproviderinterface.h"
+#include "wlantimerserviceinterface.h"
+#include "wlanbgscanawscommsinterface.h"
+#include "wlanbgscancommandlistener.h"
+
+// forward declarations
+class CWlanBgScan;
+class CWlanTimer;
+
+/**
+ *  WLAN Background Scan States
+ *  This class implements WLAN Background Scan state machine.
+ *  
+ *  @since S60 S60 v5.2
+ */
+NONSHARABLE_CLASS( CWlanBgScanStates )
+    {
+
+public:
+        
+    /**
+     * States for WLAN Background Scan.
+     */
+    enum TWlanBgScanState
+        {
+        EBgScanInit = 0,
+        EBgScanOff,
+        EBgScanOn,
+        EBgScanAuto,
+        EBgScanAutoAws,
+        EBgScanSendingAwsCmd,
+        EBgScanStateMax
+        };
+    
+    /**
+     * Events for state machine.
+     */
+    enum TWlanBgScanSmEvent
+        {
+        EBgScanEventAwsCmdComplete = 0,
+        EBgScanEventIntervalChanged,
+        EBgScanEventAwsStartupComplete,
+        EBgScanEventAwsIntervalChanged
+        };
+
+    /**
+     * Constructor.
+     */
+    CWlanBgScanStates( CWlanBgScan& aBgScan, MWlanScanResultProvider& aProvider, MWlanTimerServices& aTimerServices );
+    
+    /**
+     * Two-phased constructor.
+     */
+    void ConstructL();
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CWlanBgScanStates();
+    
+    /**
+     * Start aggressive background scanning.
+     *
+     * @since S60 v5.2
+     * @param aInterval interval for aggressive BG scanning, in seconds
+     * @param aDuration aggressive mode duration, in microseconds
+     */
+    void StartAggressiveBgScan( TUint32& aInterval, TUint32& aDuration );
+    
+    /**
+     * Stop aggressive scanning.
+     *
+     * @since S60 v5.2
+     * @param aPtr pointer to CWlanBgScanStates instance
+     * @return always KErrNone
+     */
+    static TInt StopAggressiveBgScan( TAny* aPtr );
+    
+private:
+   
+    /**
+     * Default constructor, no implementation.
+     */
+    CWlanBgScanStates();
+    
+    /**
+     * State machine for Init state
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aEvent event to handle
+     */
+    void InStateInit( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent );
+    
+    /**
+     * State machine for Off state
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aEvent event to handle
+     */
+    void InStateOff( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent );
+    
+    /**
+     * State machine for On state
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aEvent event to handle
+     */
+    void InStateOn( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent );
+
+    /**
+     * State machine for Auto state
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aEvent event to handle
+     */
+    void InStateAuto( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent );
+    
+    /**
+     * State machine for Auto with AWS state
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aEvent event to handle
+     */
+    void InStateAutoAws( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent );
+    
+    /**
+     * State machine for Sending AWS command state
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aEvent event to handle
+     */
+    void InStateSendingAwsCmd( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent );
+
+    /**
+     * Handles state transition from SendingAwsCmd state to Off state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeSendingAwsCmdToOff( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from SendingAwsCmd state to On state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeSendingAwsCmdToOn( TWlanBgScanState& aState );
+
+    /**
+     * Handles state transition from SendingAwsCmd state to Auto state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeSendingAwsCmdToAuto( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from SendingAwsCmd state to AutoAws state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeSendingAwsCmdToAutoAws( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from Init to Automatic state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeInitToAutoAws( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from AutoAws to On state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeAutoAwsToOn( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from AutoAws to Off state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeAutoAwsToOff( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from Auto to Off state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeAutoToOff( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from Auto to Auto state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeAutoToAuto( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from Auto to On state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aNewBgScanSetting new background scan setting to be taken into use
+     */
+    void StateChangeAutoToOn( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
+    
+    /**
+     * Handles state transition from On to Off state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeOnToOff( TWlanBgScanState& aState );  
+    
+    /**
+     * Handles state transition from On to Automatic state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeOnToAutomatic( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from On to On state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aNewBgScanSetting new background scan setting to be taken into use
+     */
+    void StateChangeOnToOn( TWlanBgScanState& aState, TUint32 aNewBgScanSetting );
+    
+    /**
+     * Handles state transition from Off to Automatic state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     */
+    void StateChangeOffToAutomatic( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from Off to On state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aNewBgScanInterval new background scan interval to be taken into use
+     */
+    void StateChangeOffToOn( TWlanBgScanState& aState, TUint32 aNewBgScanInterval );
+    
+    /**
+     * Handles state transition from Init to Auto state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aNewBgScanInterval new background scan interval to be taken into use
+     */
+    void StateChangeInitToAuto( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from Init to Off state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aNewBgScanInterval new background scan interval to be taken into use
+     */
+    void StateChangeInitToOff( TWlanBgScanState& aState );
+    
+    /**
+     * Handles state transition from Init to On state.
+     *
+     * @since S60 v5.2
+     * @param aState reference to state
+     * @param aNewBgScanInterval new background scan interval to be taken into use
+     */
+    void StateChangeInitToOn( TWlanBgScanState& aState );
+        
+    /**
+     * Getter for AwsStartupStatus.
+     *
+     * @since S60 v5.2
+     * @return AwsStartupStatus
+     */
+    inline TInt AwsStartupStatus() const
+        {
+        return iAwsStartupStatus;
+        }
+    
+    /**
+     * Getter for AwsCmdStatus.
+     *
+     * @since S60 v5.2
+     * @return AwsCmdStatus
+     */
+    inline TInt AwsCmdStatus() const
+        {
+        return iAwsCmdStatus;
+        }
+    
+    /**
+     * Getter for AwsCmd.
+     *
+     * @since S60 v5.2
+     * @return AwsCmd
+     */
+    inline TInt AwsCmd() const
+        {
+        return iAwsCmd;
+        }
+    
+    /**
+     * Getter for AutoInterval.
+     *
+     * @since S60 v5.2
+     * @return AutoInterval
+     */
+    inline TInt AutoInterval() const
+        {
+        return iAutoInterval;
+        }
+    
+    /**
+     * Sets background scan interval and refreshes the used
+     * interval.
+     *
+     * @since S60 v5.2
+     * @param aInterval new background scan interval to be taken into use
+     */
+    void SetInterval( TUint32 aInterval );
+    
+    /**
+     * Refreshes the used background scan interval.
+     *
+     * @since S60 v5.2
+     */
+    void RefreshUsedInterval();
+      
+protected:
+    
+    /**
+     * Main state machine
+     *
+     * @since S60 v5.2
+     * @param aEvent event for state machine
+     */
+    void NextState( const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent );
+        
+    /**
+     * Get current interval.
+     *
+     * @since S60 v5.2
+     * @return current interval in use
+     */
+    TUint32 GetBgInterval();
+    
+    /**
+     * Interval change is delivered to state machine
+     * 
+     * @since S60 v5.2
+     */
+    void IntervalChanged();
+    
+    /**
+     * PSM server mode changed command is given to state
+     * machine
+     *
+     * @since S60 v5.2
+     */
+    void DeliverPsmServerModeChange();
+    
+    /**
+     * Set AWS startup status.
+     *
+     * @param aStatus new status
+     * @since S60 v5.2
+     */
+    inline void SetAwsStartupStatus( TInt aStatus )
+        {
+        iAwsStartupStatus = aStatus;
+        }
+    
+    /**
+     * Set AWS command status.
+     *
+     * @param aCmd new command
+     * @param aStatus new status
+     * @since S60 v5.2
+     */
+    inline void SetAwsCmdStatus( MWlanBgScanAwsComms::TAwsCommand aCmd, TInt aStatus )
+        {
+        iAwsCmd = aCmd;
+        iAwsCmdStatus = aStatus;
+        }
+    
+    /**
+     * Set Auto interval.
+     *
+     * @param aAutoInterval new auto interval
+     * @since S60 v5.2
+     */
+    inline void SetAutoInterval( TUint aAutoInterval )
+        {
+        iAutoInterval = aAutoInterval;
+        }
+    
+private: // data
+    
+    /**
+     * Reference to the Bg Scan
+     */
+    CWlanBgScan& iBgScan;
+    
+    /**
+     * Used background scan interval, in seconds.
+     * This is the smaller one of iBgScanInterval
+     * and iAggressiveBgScanInterval. 
+     */
+    TUint32 iUsedBgScanInterval;
+    
+    /**
+     * Scan interval dictated by AWS component or
+     * set (fixed interval) from UI. The value is
+     * in seconds.
+     */
+    TUint32 iBgScanInterval;
+    
+    /**
+     * Aggressive background scan interval, in seconds.
+     * Interval used for temporary aggressive BG scanning
+     * when requested by the client or when activated by
+     * WLAN Engine.
+     */
+    TUint32 iAggressiveBgScanInterval;
+     
+    /**
+     * Timer guarding when to drop out of aggressive BG scan mode
+     */
+    CWlanTimer* iAggressiveBgScanTimer; 
+     
+    /**
+     * Next state to enter if AWS command delivery
+     * is successful.
+     */
+    TWlanBgScanState iNextState;
+    
+    /**
+     * AWS startup status code.
+     */
+    TInt iAwsStartupStatus;
+    
+    /**
+     * AWS command.
+     */
+    MWlanBgScanAwsComms::TAwsCommand iAwsCmd;
+    
+    /**
+     * AWS command status.
+     */
+    TInt iAwsCmdStatus;
+    
+    /**
+     * Auto interval to be used in AutoAWS and Auto states
+     */
+    TUint iAutoInterval;
+    
+protected: // data
+    
+    /**
+     * Reference to the Scan Result Provider
+     */
+    MWlanScanResultProvider& iProvider;
+
+    /**
+     * Reference to WLAN Timer services. 
+     */
+    MWlanTimerServices& iTimerServices;
+
+    /**
+     * Current background scan state. 
+     */
+    TWlanBgScanState iBgScanState;
+    
+    /**
+     * Received settings for background scan.
+     */
+    MWlanBgScanProvider::TWlanBgScanSettings iBgScanSettings;
+    
+    /**
+     * Id of the timer service request regarding 
+     * background scan interval change.
+     */
+    TUint iIntervalChangeRequestId;
+    
+    /**
+     * Completed AWS command.
+     */
+    MWlanBgScanAwsComms::TAwsCommand iCompletedAwsCommand;
+    
+    /**
+     * Status code of the completed AWS command.
+     */
+    TInt iAwsCommandCompletionCode;           
+    };
+
+#endif // WLANBGSCANSTATES_H
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanconversionutil.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanconversionutil.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 32 %
+* %version: 33 %
 */
 
 #ifndef WLANCONVERSIONUTIL_H
@@ -623,6 +623,13 @@
         static u32_t ConvertTxRate(
             TWlanRate aRate );
 
+        /**
+         * Convert cipher key data.
+         */
+        static void ConvertCipherKey(
+            TPairwiseKeyData& aAmKey,
+            const core_cipher_key_s& aCoreKey );
+
     };
 
 #endif // WLANCONVERSIONUTIL_H
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanmgmtcommandhandler.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanmgmtcommandhandler.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 30 %
+* %version: 31 %
 */
 
 #ifndef WLANMGMTCOMMANDHANDLER_H
@@ -392,6 +392,7 @@
      * @param aIsPairwiseKeyInvalidated    Whether the pairwise key should be invalidated.
      * @param aIsGroupKeyInvalidated       Whether the group key should be invalidated
      * @param aIsRadioMeasurementSupported Whether the radio measurement is supported
+     * @param aPairwiseKey                 Pairwise key to set before association.
      */
     void Connect(
         const TSSID& aSSID,                 
@@ -406,7 +407,8 @@
         const TUint8* aScanFrame,
         TBool aIsPairwiseKeyInvalidated,
         TBool aIsGroupKeyInvalidated,
-        TBool aIsRadioMeasurementSupported );
+        TBool aIsRadioMeasurementSupported,
+        const TPairwiseKeyData& aPairwiseKey );
 
 protected: // From CActive
 
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanmgmtimpl.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanmgmtimpl.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 20 %
+* %version: 21 %
 */
 
 #ifndef WLANMGMTIMPL_H
@@ -453,6 +453,14 @@
         void ProtectedSetupComplete(
             TInt aStatus );
 
+        /**
+         * Start aggressive background scanning.
+         * @param aInterval Scan interval for aggressive mode (in seconds).
+         *                  Valid range: 1-120 seconds.
+         */
+        virtual TInt StartAggressiveBgScan(
+            TUint aInterval );
+
 	protected: // Methods
 
         /**
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanscanproviderinterface.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlanscanproviderinterface.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,13 +16,15 @@
 */
 
 /*
-* %version: 4 %
+* %version: 6 %
 */
 
 
 #ifndef WLANSCANPROVIDERINTERFACE_H
 #define WLANSCANPROVIDERINTERFACE_H
 
+#include <e32def.h>
+
 /**
  * @brief Interface definition for WLAN Scan Result Provider API.
  *
@@ -52,6 +54,13 @@
      */        
     virtual void CancelScan() = 0;
 
+    /**
+     * Publish WLAN background scan interval via P&S.
+     *
+     * @since S60 v5.2
+     * @param aInterval Background scan interval in seconds.
+     */
+    virtual void PublishBgScanInterval( TUint32& aInterval ) = 0;
     };
 
 
@@ -111,7 +120,7 @@
     virtual void ScanComplete() = 0;
         
     /**
-     * Issued when WLAN is disconnected.
+     * Called to indicate that WLAN is no longer connected.
      *
      * @since S60 v5.2
      */
@@ -135,6 +144,16 @@
      */
     virtual void NotifyChangedSettings( TWlanBgScanSettings& aSettings ) = 0;
 
+    /**
+     * Start aggressive background scanning.
+     *
+     * @since S60 v5.2
+     * @param aInterval interval for aggressive scan, in seconds
+     * @param aTimeout how long aggressive scanning is carried out
+     */
+    virtual void StartAggressiveBgScan(
+        TUint32& aInterval,
+        TUint32& aTimeout ) = 0;
     };
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlantimer.h	Sat Feb 20 00:38:18 2010 +0200
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* This class implements timer services.
+*
+*/
+
+/*
+* %version: 1 %
+*/
+
+#ifndef C_WLANTIMER_H
+#define C_WLANTIMER_H
+
+#include <e32base.h>
+
+/**
+ *  CWlanTimer class.
+ *
+ *  Class providing timer services. The underlaying implementation relies
+ *  on CTimer. Therefore this module has the same limitations as CTimer.
+ * 
+ *  @lib wlmserversrv.dll
+ *  @since S60 v5.2
+ */
+ 
+NONSHARABLE_CLASS( CWlanTimer ) : public CTimer
+    {
+    
+public: // CWlanTimer public methods
+
+    /**
+     * Static constructor.
+     * @param aTimerExpiredCB   Callback for indicating timer expiry.
+     * @param aTimerCancelledCB Callback for indicating timer cancellation.
+     * @param aTimerErrorCB     Callback for indicating timer error.
+     */
+    static CWlanTimer* NewL(
+        const TCallBack& aTimerExpiredCB,
+        const TCallBack& aTimerCancelledCB,
+        const TCallBack& aTimerErrorCB );
+        
+    /**
+     * Destructor.
+     */
+    ~CWlanTimer();
+
+private: // CWlanTimer private methods
+
+    /**
+     * C++ constructor.
+     * @param aTimerExpiredCB   Callback for indicating timer expiry.
+     * @param aTimerCancelledCB Callback for indicating timer cancellation.
+     * @param aTimerErrorCB     Callback for indicating timer error.
+     */
+    CWlanTimer(
+        const TCallBack& aTimerExpiredCB,
+        const TCallBack& aTimerCancelledCB,
+        const TCallBack& aTimerErrorCB );
+    
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    void ConstructL();
+
+private: // From CTimer
+
+    /**
+     * Handles timer events.
+     */
+    void RunL();
+    
+    /**
+     * Implements cancellation of an outstanding request.
+     */
+    void DoCancel();
+
+private: // CWlanTimer private data
+
+    /**
+     * TimerExpiredCB.
+     * Registered callback method that is called, when the timer
+     * expires. This is set when CWlanTimer instance is created.
+     */   
+    TCallBack iTimerExpiredCB;
+    
+    /**
+     * TimerCancelledCB.
+     * Registered callback method that is called, when the timer
+     * is cancelled by an external event (i.e. cancellation is
+     * not requested by the client). This is set when CWlanTimer
+     * instance is created.
+     */
+    TCallBack iTimerCancelledCB;
+    
+    /**
+     * TimerErrorCB.
+     * Registered callback method that is called, when there is
+     * a timer error. This is set when CWlanTimer instance is created.
+     */
+    TCallBack iTimerErrorCB;
+    };
+
+#endif // C_WLANTIMER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlantimerserviceinterface.h	Sat Feb 20 00:38:18 2010 +0200
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This abstract class defines WLAN scan provider interface.
+*
+*/
+
+/*
+* %version: 1 %
+*/
+
+
+#ifndef WLANTIMERSERVICEINTERFACE_H
+#define WLANTIMERSERVICEINTERFACE_H
+
+#include <e32def.h>
+
+
+
+/**
+ * @brief Interface definition for WLAN Timer service callback.
+ *
+ * @since S60 v5.2
+ */
+class MWlanTimerServiceCallback
+    {
+    public:
+    
+        /**
+         * Timeout has occurred.
+         */
+        virtual void OnTimeout() = 0;
+
+    };
+
+class MWlanTimerServices
+    {
+    
+public:
+    /**
+     * Start the timer
+     *
+     * @since S60 v5.2
+     * @param aRequestId reference to request id
+     * @param aAt reference to time when timeout should occur
+     * @param aCb reference to callback object
+     * @return error code
+     */
+    virtual TInt StartTimer( TUint& aRequestId, TTime& aAt, MWlanTimerServiceCallback& aCb ) = 0;
+
+    /**
+     * Stop the timer
+     *
+     * @since S60 v5.2
+     * @param aRequestId Id of timer to stop
+     */
+    virtual void StopTimer( const TUint& aRequestId ) = 0;
+    
+    /**
+     * Handles timer timeout.
+     *
+     * @since S60 v5.2
+     */
+    virtual void HandleTimeout() = 0;
+
+    };
+
+#endif // WLANTIMERSERVICEINTERFACE_H
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlantimerservices.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlantimerservices.h	Sat Feb 20 00:38:18 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 3 %
+* %version: 4 %
 */
 
 #ifndef WLANTIMERSERVICES_H
@@ -26,20 +26,7 @@
 #include <e32std.h>
 #include <e32cmn.h>
 
-
-/**
- * Callback interface
- */
-class MWlanTimerServiceCallback
-    {
-    public:
-    
-        /**
-         * Timeout has occurred.
-         */
-        virtual void OnTimeout() = 0;
-
-    };
+#include "wlantimerserviceinterface.h"
 
 class CTimeoutRequestEntry : public CBase
     {
@@ -87,7 +74,7 @@
  *
  * @since S60 v5.2
  */
-NONSHARABLE_CLASS( CWlanTimerServices ) : public CActive
+NONSHARABLE_CLASS( CWlanTimerServices ) : public CActive, public MWlanTimerServices
     {
 public: // Constructors and destructor
 
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmclientserver.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmclientserver.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 40 %
+* %version: 41 %
 */
 
 #ifndef WLMCLIENTSERVER_H
@@ -219,7 +219,9 @@
     /** Initiate a roam to the given BSSID. */
     EDirectedRoam,
     /** Cancel a pending directed roam request. */
-    ECancelDirectedRoam
+    ECancelDirectedRoam,
+    /** Request entry to aggressive background scan mode. */
+    EStartAggressiveBgScan
     };
 
 /**
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmdriverif.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmdriverif.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 38 %
+*/
 
 #ifndef WLMDRIVERIF_H
 #define WLMDRIVERIF_H
@@ -140,6 +143,7 @@
      * @param is_pairwise_key_invalidated Whether the pairwise key should be invalidated.
      * @param is_group_key_invalidated Whether the group key should be invalidated
      * @param is_radio_measurement_supported Whether the radio measurement is supported
+     * @param pairwise_key Pairwise key to set before association. NULL if none.
      */
     void connect(
         u32_t request_id,
@@ -156,7 +160,8 @@
         const u8_t* scan_frame,
         bool_t is_pairwise_key_invalidated,
         bool_t is_group_key_invalidated,
-        bool_t is_radio_measurement_supported );
+        bool_t is_radio_measurement_supported,
+        const core_cipher_key_s* pairwise_key );
 
     /**
      * Disconnect from the current network.
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmplatform.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmplatform.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 12 %
+*/
 
 #ifndef WLMPLATFORM_H
 #define WLMPLATFORM_H
@@ -177,6 +180,12 @@
          */
         IMPORT_C void InitializeSystemTimeHandler();
 
+        /**
+         * Publishes WLAN background scan interval.
+         * @param aInterval WLAN BG scan interval in seconds.
+         */
+        IMPORT_C void PublishBgScanInterval( TUint32& aInterval );
+
     protected:  // Methods
 
        // Methods from base classes
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmplatformdata.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmplatformdata.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 12 %
+*/
 
 #ifndef WLMPLATFORMDATA_H
 #define WLMPLATFORMDATA_H
@@ -88,6 +91,15 @@
             const TUid& aCategory,
             const TUint aKey );
 
+        /**
+         * Publishes WLAN background scanning interval via P&S.
+         * @since S60 v5.2
+         * @param aInterval WLAN BG scan interval in seconds.
+         * @return Symbian error code
+         */
+        TInt PublishBgScanInterval(
+            TUint32& aInterval );
+
     private:   // Methods
 
         /**
@@ -117,6 +129,9 @@
         
         /** Handle to KPropertyWlanIndicator property via P&S. */
         RProperty iPsIndicator;
+        
+        /** Handle to KPropertyWlanBgScanInterval property via P&S. */
+        RProperty iPsBgScanInterval;
 
         /** Callback for notifications. */
         MWlmSystemNotify& iCallback;
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmserver.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/inc/wlmserver.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 49 %
+* %version: 50 %
 */
 
 #ifndef WLMSERVER_H
@@ -39,11 +39,11 @@
 #include "wlaneapolinterface.h"
 #include "wlaneapolclient.h"
 #include "wlangenericplugin.h"
-#include "wlantimerservices.h"
 #include "wlancbwaiter.h"
 
 class CWlmDriverIf;
 class CWlanSsidListDb;
+class CWlanTimerServices;
 
 /**
  * Command Ids to be used un the asynchronous core service requests
@@ -766,6 +766,18 @@
             const RMessage2& aMessage );
 
         /**
+         * StartAggressiveBgScan
+         * Sets WLAN background scanning into more aggressive mode for a while.
+         * 
+         * @since S60 v5.2
+         * @param aSessionId ID identifying the session.
+         * @param aMessage Message containing the respective command.
+         */
+        void StartAggressiveBgScan(
+            TUint aSessionId,
+            const RMessage2& aMessage );
+
+        /**
          * From MWlmPlatformCallback
          * Send an indication to request data pipe disconnection.
          *
@@ -1150,6 +1162,22 @@
         TInt GetCurrentIapId( 
             const TUint aLanServiceId, 
             core_iap_data_s& aCoreIapData );
+        
+        /**
+         * Store region and timestamp to CenRep.
+         *
+         * @param aRegion Specifies a region to be stored.
+         * @param aTimestamp Specifies a timestamp to be stored.
+         */
+        void StoreRegionAndTimestamp( const TInt aRegion, const TInt aTimestamp );
+
+        /**
+         * Publish WLAN background scan interval.
+         * 
+         * @see MWlanScanResultProvider
+         * @param aInterval WLAN BG scan interval in seconds.
+         */
+        void PublishBgScanInterval( TUint32& aInterval );
 
     private:    // Data
     
@@ -1349,7 +1377,12 @@
          * Timer services.
          */
         CWlanTimerServices* iTimerServices;
-                
+        
+        /**
+         * Flag indicating whether aggressive scanning has to be performed
+         * after link loss.
+         */   
+        TBool iAggressiveScanningAfterLinkLoss;        
     };
     
 
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/rom/wlaneng.iby	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/rom/wlaneng.iby	Sat Feb 20 00:38:18 2010 +0200
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 13 %
+*/
 
 #ifndef __WLANENG_IBY__
 #define __WLANENG_IBY__
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/rwlmserver.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/rwlmserver.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 27 %
+* %version: 28 %
 */
 
 #include <in_sock.h>
@@ -833,6 +833,21 @@
 // ---------------------------------------------------------
 // ---------------------------------------------------------
 //
+EXPORT_C TInt RWLMServer::StartAggressiveBgScan(
+    TUint aInterval )
+    {
+    DEBUG1( "RWLMServer::StartAggressiveBgScan( %u )",
+        aInterval );
+    
+    TIpcArgs params( aInterval );
+    
+    // Send the command as a "blind" request
+    return Send( EStartAggressiveBgScan, params );
+    }
+
+// ---------------------------------------------------------
+// ---------------------------------------------------------
+//
 TInt RWLMServer::StartServer()
     {
     DEBUG( "RWLMServer::StartServer()" );
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanbgscan.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanbgscan.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 12 %
+* %version: 14 %
 */
 
 #include <e32base.h>
@@ -26,7 +26,8 @@
 #include "awsinterface.h"
 #include "awsenginebase.h"
 #include "wlancbwaiter.h"
-#include "wlanbgscanawscomms.h"
+#include "wlanbgscanawscommsinterface.h"
+#include "wlanbgscanstates.h"
 #include "wlanbgscan.h"
 #include "wlandevicesettings.h" // default values in case invalid data is passed in NotifyChangedSettings
 #include "am_debug.h"
@@ -60,7 +61,8 @@
 /**
  * Formatting of date time debug string.
  */
-_LIT( KWlanBgScanDateTimeFormat, "%F %*E %*N %D %H:%T:%S" );
+_LIT( KWlanBgScanDateTimeFormat, "%F %*E %*N %Y %H:%T:%S" );
+_LIT( KWlanBgScanDateTimeFormat2, "%H%T" );
 
 /**
  * Maximun length for date time debug string.
@@ -68,24 +70,20 @@
 const TInt KWlanBgScanMaxDateTimeStrLen = 50;
 #endif
 
+
 // ======== MEMBER FUNCTIONS ========
 
 // ---------------------------------------------------------------------------
 // CWlanBgScan::CWlanBgScan
 // ---------------------------------------------------------------------------
 //
-CWlanBgScan::CWlanBgScan( MWlanScanResultProvider& aProvider, CWlanTimerServices& aTimerServices ) :
+CWlanBgScan::CWlanBgScan( MWlanScanResultProvider& aProvider, MWlanTimerServices& aTimerServices ) :
+    CWlanBgScanStates( *this, aProvider, aTimerServices ),
     iProvider ( aProvider ),
-    iCurrentBgScanInterval( 0 ),
     iAwsComms( NULL ),
-    iBgScanState( EBgScanOff ),
     iAutoPeriod( EAutoPeriodNone ),
-    iTimerServices( aTimerServices ),
-    iIntervalChangeRequestId( 0 ),
-    iBgScanPeakStartTime( 0 ),
-    iBgScanPeakEndTime( 0 ),
-    iBgScanIntervalPeak( 0 ),
-    iBgScanIntervalOffPeak( 0 )
+    iAwsOk( EFalse ),
+    iCurrentPsmServerMode( 0 )
     {
     DEBUG( "CWlanBgScan::CWlanBgScan()" );
     }
@@ -99,21 +97,21 @@
     DEBUG( "CWlanBgScan::ConstructL()" );
     
     // create AWS comms interface
-    TRAPD( err, iAwsComms = CWlanBgScanAwsComms::NewL( *this ) );
+    TRAPD( err, iAwsComms = CWlanBgScanAwsCommsFactory::InstanceL( *this ) );
     if( err != KErrNone )
         {
-        if( iAwsComms )
-            {
-            delete iAwsComms;
-            iAwsComms = NULL;
-            }
         DEBUG1( "CWlanBgScan::ConstructL() - AWS comms creation failed with code %i", err );
+
+        delete iAwsComms;
+        iAwsComms = NULL;
         }
     else
         {
         DEBUG( "CWlanBgScan::ConstructL() - AWS comms creation successful" );
         }
-        
+    
+    CWlanBgScanStates::ConstructL();
+            
     DEBUG( "CWlanBgScan::ConstructL() - done" );    
     }
 
@@ -121,7 +119,7 @@
 // CWlanBgScan::NewL
 // ---------------------------------------------------------------------------
 //
-CWlanBgScan* CWlanBgScan::NewL( MWlanScanResultProvider& aProvider, CWlanTimerServices& aTimerServices )
+CWlanBgScan* CWlanBgScan::NewL( MWlanScanResultProvider& aProvider, MWlanTimerServices& aTimerServices )
     {
     DEBUG( "CWlanBgScan::NewL()" );
     CWlanBgScan* self = new ( ELeave ) CWlanBgScan( aProvider, aTimerServices );
@@ -137,7 +135,9 @@
 //
 CWlanBgScan::~CWlanBgScan()
     {
-    DEBUG( "CWlanBgScan::CWlanBgScan()" );
+    DEBUG1( "CWlanBgScan::~CWlanBgScan() - deallocating iAwsComms @ 0x%08X", iAwsComms );
+    delete iAwsComms;
+    iAwsComms = NULL;
     }
 
 // ---------------------------------------------------------------------------
@@ -147,29 +147,13 @@
 //
 void CWlanBgScan::ScanComplete()
     {
-    DEBUG1( "CWlanBgScan::ScanComplete() - current interval %us", GetInterval() );
-
-    if ( GetInterval() != KWlanBgScanIntervalNever )
-        {
-        DEBUG1( "CWlanBgScan::ScanComplete() - issue a new request with %us as expiry", GetInterval() );
-        iProvider.Scan( GetInterval() );
-        }
-    }
+    DEBUG1( "CWlanBgScan::ScanComplete() - current interval %us", GetBgInterval() );
 
-// ---------------------------------------------------------------------------
-// From class MWlanBgScanProvider.
-// CWlanBgScan::IntervalChanged
-// ---------------------------------------------------------------------------
-//
-void CWlanBgScan::IntervalChanged( TUint32 aNewInterval )
-    {
-    DEBUG1( "CWlanBgScan::IntervalChanged() - aNewInterval %u", aNewInterval );
-
-    NextState( aNewInterval );
-            
-    DEBUG2( "CWlanBgScan::IntervalChanged() - current interval %u, current state %u",
-            GetInterval(),
-            iBgScanState );
+    if ( GetBgInterval() != KWlanBgScanIntervalNever )
+        {
+        DEBUG1( "CWlanBgScan::ScanComplete() - issue a new request with %us as expiry", GetBgInterval() );
+        iProvider.Scan( GetBgInterval() );
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -179,9 +163,9 @@
 //
 void CWlanBgScan::NotConnected()
     {
-    DEBUG1( "CWlanBgScan::NotConnected() - current interval %us", GetInterval() );
+    DEBUG1( "CWlanBgScan::NotConnected() - current interval %us", GetBgInterval() );
         
-    if ( GetInterval() != KWlanBgScanIntervalNever )
+    if ( GetBgInterval() != KWlanBgScanIntervalNever )
         {
         DEBUG( "CWlanBgScan::NotConnected() - issue a new request with immediate expiry" );
         iProvider.Scan( KWlanBgScanMaxDelayExpireImmediately );
@@ -198,9 +182,9 @@
     // If ( interval != never )                              -> Return True
     // Otherwise                                             -> return False
     DEBUG1( "CWlanBgScan::IsBgScanEnabled() - returning %u", 
-           ( GetInterval() != KWlanBgScanIntervalNever ) ? 1 : 0 );
+           ( GetBgInterval() != KWlanBgScanIntervalNever ) ? 1 : 0 );
         
-    return ( GetInterval() != KWlanBgScanIntervalNever );
+    return ( GetBgInterval() != KWlanBgScanIntervalNever );
     }
 
 // ---------------------------------------------------------------------------
@@ -218,21 +202,28 @@
             aSettings.bgScanIntervalPeak,
             aSettings.bgScanIntervalOffPeak);
     
+    // validate settings and use default values if needed
     MWlanBgScanProvider::TWlanBgScanSettings settingsToUse;
-    CheckSettings( settingsToUse, aSettings );
+    CheckSettings( settingsToUse, aSettings ); // Note: Any PSM server mode value is allowed.
     
-    iBgScanPeakStartTime = settingsToUse.bgScanPeakStartTime;
-    iBgScanPeakEndTime = settingsToUse.bgScanPeakEndTime;
-    iBgScanIntervalPeak = settingsToUse.bgScanIntervalPeak;
-    iBgScanIntervalOffPeak = settingsToUse.bgScanIntervalOffPeak;
+    // store settings for later use
+    iBgScanSettings = settingsToUse;
+    
+    IntervalChanged();
     
-    IntervalChanged( settingsToUse.backgroundScanInterval );
-        
-    if( IsAwsPresent() )
+    if( iCurrentPsmServerMode != iBgScanSettings.psmServerMode )
         {
-        CWlanBgScanAwsComms::TAwsMessage msg = { CWlanBgScanAwsComms::ESetPowerSaveMode, aSettings.psmServerMode };
-        iAwsComms->SendOrQueueAwsCommand( msg );
+        if( AwsPresence() == CWlanBgScan::EAwsPresent )
+            {
+            DEBUG( "CWlanBgScan::NotifyChangedSettings() - sending power mode command to AWS" );
+            MWlanBgScanAwsComms::TAwsMessage msg = { MWlanBgScanAwsComms::ESetPowerSaveMode, iBgScanSettings.psmServerMode };
+            iAwsComms->SendOrQueueAwsCommand( msg );
+            }
+        
+        // remember current psm server mode
+        iCurrentPsmServerMode = iBgScanSettings.psmServerMode;
         }
+    
     }
 
 // ---------------------------------------------------------------------------
@@ -269,24 +260,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// CWlanBgScan::GetInterval
-// ---------------------------------------------------------------------------
-//
-TUint32 CWlanBgScan::GetInterval()
-    {
-    return iCurrentBgScanInterval;
-    }
-
-// ---------------------------------------------------------------------------
-// CWlanBgScan::SetInterval
-// ---------------------------------------------------------------------------
-//
-void CWlanBgScan::SetInterval( TUint32 aInterval )
-    {
-    iCurrentBgScanInterval = aInterval;
-    }
-
-// ---------------------------------------------------------------------------
 // CWlanBgScan::IsIntervalChangeNeeded
 // ---------------------------------------------------------------------------
 //
@@ -295,7 +268,7 @@
     TBool ret( ETrue );
     
     // no need to change interval if both peak and off-peak intervals are the same
-    if( iBgScanPeakStartTime == iBgScanPeakEndTime )
+    if( iBgScanSettings.bgScanPeakStartTime == iBgScanSettings.bgScanPeakEndTime )
         {
         ret = EFalse;
         }
@@ -343,23 +316,30 @@
     currentTime.HomeTime();
     TDateTime change_time( currentTime.DateTime() );
     
-    switch( TimeRelationToRange( currentTime, iBgScanPeakStartTime, iBgScanPeakEndTime ) )
+#ifdef _DEBUG
+    change_time = currentTime.DateTime();
+    TBuf<KWlanBgScanMaxDateTimeStrLen> timeNow;
+    TRAP_IGNORE( currentTime.FormatL( timeNow, KWlanBgScanDateTimeFormat ) );
+    DEBUG1( "CWlanBgScan::AutoIntervalChangeAt() - time now: %S", &timeNow );
+#endif
+    
+    switch( TimeRelationToRange( currentTime, iBgScanSettings.bgScanPeakStartTime, iBgScanSettings.bgScanPeakEndTime ) )
         {
         case ESmaller:
             {
-            change_time.SetHour( iBgScanPeakStartTime / KGetHours );
-            change_time.SetMinute( iBgScanPeakStartTime % KGetHours );
+            change_time.SetHour( iBgScanSettings.bgScanPeakStartTime / KGetHours );
+            change_time.SetMinute( iBgScanSettings.bgScanPeakStartTime % KGetHours );
             change_time.SetSecond( KZeroSeconds );
             currentTime = change_time;
             break;
             }
         case EInsideRange:
             {
-            change_time.SetHour( iBgScanPeakEndTime / KGetHours );
-            change_time.SetMinute( iBgScanPeakEndTime % KGetHours );
+            change_time.SetHour( iBgScanSettings.bgScanPeakEndTime / KGetHours );
+            change_time.SetMinute( iBgScanSettings.bgScanPeakEndTime % KGetHours );
             change_time.SetSecond( KZeroSeconds );
             currentTime = change_time;
-            if( iBgScanPeakStartTime > iBgScanPeakEndTime )
+            if( iBgScanSettings.bgScanPeakStartTime > iBgScanSettings.bgScanPeakEndTime )
                 {
                 DEBUG( "CWlanBgScan::AutoIntervalChangeAt() - peak end happens tomorrow" );
                 currentTime += TTimeIntervalDays( KAddOneDay );
@@ -372,8 +352,8 @@
             }
         case EGreater:
             {
-            change_time.SetHour( iBgScanPeakStartTime / KGetHours );
-            change_time.SetMinute( iBgScanPeakStartTime % KGetHours );
+            change_time.SetHour( iBgScanSettings.bgScanPeakStartTime / KGetHours );
+            change_time.SetMinute( iBgScanSettings.bgScanPeakEndTime % KGetHours );
             change_time.SetSecond( KZeroSeconds );
             currentTime = change_time;
             currentTime += TTimeIntervalDays( KAddOneDay );
@@ -399,64 +379,57 @@
     {
 #ifdef _DEBUG
     TBuf<KWlanBgScanMaxDateTimeStrLen> dbgString;
-    TRAP_IGNORE( aTime.FormatL( dbgString, KWlanBgScanDateTimeFormat ) );
+    TRAP_IGNORE( aTime.FormatL( dbgString, KWlanBgScanDateTimeFormat2 ) );
     DEBUG1( "CWlanBgScan::TimeRelationToRange() - time:  %S", &dbgString );
 #endif
-    
-    TTime time( aTime );
+        
+    TDateTime dateTime( aTime.DateTime() );
     
-    TDateTime start_time( aTime.DateTime() );
-    start_time.SetHour( aRangeStart / KGetHours );
-    start_time.SetMinute( aRangeStart % KGetHours );
-    start_time.SetSecond( KZeroSeconds );
+    TUint timeToCheck = ( dateTime.Hour() * KGetHours ) + dateTime.Minute();
+
+    DEBUG2( "CWlanBgScan::TimeRelationToRange() - range: %04u - %04u", aRangeStart, aRangeEnd );
+
+    CWlanBgScan::TRelation relation( ESmaller );
     
-    if( aRangeStart > aRangeEnd )
+    if( aRangeStart == aRangeEnd )
         {
-        DEBUG( "CWlanBgScan::TimeRelationToRange() - end time of range must to be tomorrow" );
-        if( time.DayNoInMonth() == ( time.DaysInMonth() - 1 ) )
+        DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EGreater" );
+        relation = EGreater;
+        }
+    else if( aRangeStart > aRangeEnd )
+        {
+        DEBUG( "CWlanBgScan::TimeRelationToRange() - range crosses the midnight" );
+        /**
+         * As range crosses midnight, there is no way for the relation to be ESmaller.
+         */
+        if( timeToCheck < aRangeEnd || timeToCheck >= aRangeStart )
             {
-            DEBUG( "CWlanBgScan::TimeRelationToRange() - last day of the month, move to next month" );
-            time += TTimeIntervalMonths( 1 );
-            DEBUG( "CWlanBgScan::TimeRelationToRange() - move to first day of the month" );
-            TDateTime new_time( time.DateTime() );
-            new_time.SetDay( 0 );
-
-            time = TTime( new_time );
+            DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EInsideRange" );
+            relation = EInsideRange;
             }
         else
             {
-            DEBUG( "CWlanBgScan::TimeRelationToRange() - add one day to end time" );
-            time += TTimeIntervalDays( KAddOneDay );
+            DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EGreater" );
+            relation = EGreater;
             }
         }
-    
-    TDateTime end_time( time.DateTime() );
-    end_time.SetHour( aRangeEnd / KGetHours );
-    end_time.SetMinute( aRangeEnd % KGetHours );
-    end_time.SetSecond( KZeroSeconds );
-        
-#ifdef _DEBUG
-    TBuf<KWlanBgScanMaxDateTimeStrLen> rngStart, rngEnd;
-    TRAP_IGNORE( TTime( start_time ).FormatL( rngStart, KWlanBgScanDateTimeFormat ) );
-    TRAP_IGNORE( TTime( end_time ).FormatL( rngEnd, KWlanBgScanDateTimeFormat ) );
-    DEBUG2( "CWlanBgScan::TimeRelationToRange() - range: %S - %S", &rngStart, &rngEnd );
-#endif
-    
-    CWlanBgScan::TRelation relation( ESmaller );
-    if( aTime < TTime( start_time ) )
-        {
-        DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: ESmaller" );
-        relation = ESmaller;
-        }
-    else if( aTime >= TTime( start_time ) && aTime < TTime( end_time ) )
-        {
-        DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EInsideRange" );
-        relation = EInsideRange;
-        }
     else
         {
-        DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EGreater" );
-        relation = EGreater;
+        if( timeToCheck < aRangeStart )
+            {
+            DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: ESmaller" );
+            relation = ESmaller;
+            }
+        else if( timeToCheck >= aRangeStart && timeToCheck < aRangeEnd )
+            {
+            DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EInsideRange" );
+            relation = EInsideRange;
+            }
+        else
+            {
+            DEBUG( "CWlanBgScan::TimeRelationToRange() - returning: EGreater" );
+            relation = EGreater;
+            }
         }
     
     return relation;
@@ -472,13 +445,13 @@
     TTime currentTime;
     currentTime.HomeTime();
 
-    if( TimeRelationToRange( currentTime, iBgScanPeakStartTime, iBgScanPeakEndTime ) == CWlanBgScan::EInsideRange )
+    if( TimeRelationToRange( currentTime, iBgScanSettings.bgScanPeakStartTime, iBgScanSettings.bgScanPeakEndTime ) == CWlanBgScan::EInsideRange )
         {
-        interval = iBgScanIntervalPeak;
+        interval = iBgScanSettings.bgScanIntervalPeak;
         }
     else
         {       
-        interval = iBgScanIntervalOffPeak;
+        interval = iBgScanSettings.bgScanIntervalOffPeak;
         }
     
     DEBUG1( "CWlanBgScan::CurrentAutoInterval() - current interval: %u", interval );
@@ -487,304 +460,23 @@
     }
 
 // ---------------------------------------------------------------------------
-// CWlanBgScan::NextState
-// ---------------------------------------------------------------------------
-//
-void CWlanBgScan::NextState( TUint32 aNewBgScanSetting )
-    {
-    DEBUG1( "CWlanBgScan::NextState() - aNewBgScanSetting %u", aNewBgScanSetting );
-    
-    switch ( iBgScanState )
-        {
-        case EBgScanOff:
-            {
-            InStateOff( iBgScanState, aNewBgScanSetting );
-            break;
-            }
-        case EBgScanOn:
-            {
-            InStateOn( iBgScanState, aNewBgScanSetting );
-            break;
-            }
-        case EBgScanAuto:
-            {
-            InStateAuto( iBgScanState, aNewBgScanSetting );
-            break;
-            }
-        case EBgScanAutoAws:
-            {
-            InStateAutoAws( iBgScanState, aNewBgScanSetting );
-            break;
-            }
-        default:
-            {
-            ASSERT( 0 );
-            break;
-            }
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CWlanBgScan::InStateOff
-// ---------------------------------------------------------------------------
-//
-void CWlanBgScan::InStateOff( TWlanBgScanState& aState, TUint32 aNewBgScanSetting )
-    {
-    switch( aNewBgScanSetting )
-        {
-        case KWlanBgScanIntervalNever:
-            {
-            DEBUG( "CWlanBgScan::InStateOff() - no change in the interval" );
-            aState = EBgScanOff;
-            break;
-            }
-        case KWlanBgScanIntervalAutomatic:
-            {
-            if ( IsAwsPresent() )
-                {
-                DEBUG( "CWlanBgScan::InStateOff() - state change Off to AutoAws" );
-
-                aState = EBgScanAutoAws;
-                DEBUG( "CWlanBgScan::InStateOff() - calling SendOrQueueAwsCommand()" );
-                CWlanBgScanAwsComms::TAwsMessage msg = { CWlanBgScanAwsComms::EStart, 0 };
-                iAwsComms->SendOrQueueAwsCommand( msg );
-                DEBUG( "CWlanBgScan::InStateOff() - SendOrQueueAwsCommand() returned" );
-                }
-            else
-                {
-                DEBUG( "CWlanBgScan::InStateOff() - state change Off to Auto" );
-                DEBUG( "CWlanBgScan::InStateOff() - * determine next interval change time and request callback" );
-                ScheduleAutoIntervalChange();
-                SetInterval( CurrentAutoInterval() );
-                if( GetInterval() != KWlanBgScanIntervalNever )
-                    {
-                    DEBUG( "CWlanBgScan::InStateOff() - * cause immediate background scan" );
-                    NotConnected();
-                    }
-                else
-                    {
-                    DEBUG( "CWlanBgScan::InStateOff() - Auto interval zero, background scanning is off" );
-                    }
-                aState = EBgScanAuto;
-                }
-            break;
-            }
-        default:
-            {
-            DEBUG1( "CWlanBgScan::InStateOff() - state change Off to On (interval: %u)", aNewBgScanSetting );
-            SetInterval( aNewBgScanSetting );
-            // cause immediate background scan
-            NotConnected();
-            aState = EBgScanOn;
-            }
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CWlanBgScan::InStateOn
+// CWlanBgScan::StartAggressiveBgScan
 // ---------------------------------------------------------------------------
 //
-void CWlanBgScan::InStateOn( TWlanBgScanState& aState, TUint32 aNewBgScanSetting )
-    {
-    switch( aNewBgScanSetting )
-        {
-        case KWlanBgScanIntervalNever:
-            {
-            DEBUG( "CWlanBgScan::InStateOn() - state change On to Off" );
-            SetInterval( KWlanBgScanIntervalNever );
-            iProvider.CancelScan();
-            aState = EBgScanOff;
-            break;
-            }
-        case KWlanBgScanIntervalAutomatic:
-            {
-            DEBUG( "CWlanBgScan::InStateOn() - state change On to Auto" );
-            SetInterval( KWlanBgScanIntervalNever );
-            iProvider.CancelScan();
-            if ( IsAwsPresent() )
-                {
-                aState = EBgScanAutoAws;
-                DEBUG( "CWlanBgScan::InStateOn() - calling SendOrQueueAwsCommand()" );
-                CWlanBgScanAwsComms::TAwsMessage msg = { CWlanBgScanAwsComms::EStart, 0 };
-                iAwsComms->SendOrQueueAwsCommand( msg );
-                DEBUG( "CWlanBgScan::InStateOn() - SendOrQueueAwsCommand() returned" );
-                }
-            else
-                {
-                DEBUG( "CWlanBgScan::InStateOn() - * determine next interval change time and request callback" );
-                ScheduleAutoIntervalChange();
-                SetInterval( CurrentAutoInterval() );
-                if( GetInterval() != KWlanBgScanIntervalNever )
-                    {
-                    DEBUG( "CWlanBgScan::InStateOn() - * cause immediate background scan" );
-                    NotConnected();
-                    }
-                else
-                    {
-                    DEBUG( "CWlanBgScan::InStateOn() - Auto interval zero, background scanning is off" );
-                    }
-                aState = EBgScanAuto;
-                }
-            break;
-            }
-        default:
-            {
-            DEBUG( "CWlanBgScan::InStateOn() - state change On to On" );
-            if ( GetInterval() == aNewBgScanSetting ) 
-                {
-                DEBUG( "CWlanBgScan::InStateOn() - no change in the interval" );
-                }
-            else if ( GetInterval() > aNewBgScanSetting )
-                {
-                DEBUG( "CWlanBgScan::InStateOn() - current interval greater than the new interval" );
-                DEBUG( "CWlanBgScan::InStateOn() - * cancel scan and cause immediate background scan" );
-                iProvider.CancelScan();
-                SetInterval( aNewBgScanSetting );
-                NotConnected();
-                }
-            else
-                {
-                DEBUG( "CWlanBgScan::InStateOn() - current interval smaller than the new interval" );
-                DEBUG( "CWlanBgScan::InStateOn() - * cancel scan and issue new with interval as expiry" );
-                iProvider.CancelScan();
-                SetInterval( aNewBgScanSetting );
-                ScanComplete();
-                }
-            aState = EBgScanOn;
-            }
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CWlanBgScan::InStateAuto
-// ---------------------------------------------------------------------------
-//
-void CWlanBgScan::InStateAuto( TWlanBgScanState& aState, TUint32 aNewBgScanSetting )
+void CWlanBgScan::StartAggressiveBgScan( TUint32& aInterval, TUint32& aTimeout )
     {
-    switch( aNewBgScanSetting )
-        {
-        case KWlanBgScanIntervalNever:
-            {
-            DEBUG( "CWlanBgScan::InStateAuto() - state change Auto to Off" );
-            SetInterval( KWlanBgScanIntervalNever );
-            iTimerServices.StopTimer( iIntervalChangeRequestId );
-            iIntervalChangeRequestId = 0;
-            iProvider.CancelScan();
-            aState = EBgScanOff;
-            break;
-            }
-        case KWlanBgScanIntervalAutomatic:
-            {
-            DEBUG( "CWlanBgScan::InStateAuto() - state still Auto" );
-            
-            ScheduleAutoIntervalChange();
-
-            TUint32 currentInterval = GetInterval();
-            
-            TUint32 autoInterval = CurrentAutoInterval();
-                        
-            if ( autoInterval == KWlanBgScanIntervalNever ) 
-                {
-                DEBUG( "CWlanBgScan::InStateAuto() - Auto interval zero, background scanning is off" );
-                DEBUG( "CWlanBgScan::InStateAuto() - * cancel scan" );
-                iProvider.CancelScan();
-                SetInterval( autoInterval );
-                }
-            else if ( currentInterval == autoInterval ) 
-                {
-                DEBUG( "CWlanBgScan::InStateAuto() - no change in the Auto interval" );
-                }
-            else if ( currentInterval > autoInterval )
-                {
-                DEBUG( "CWlanBgScan::InStateAuto() - current Auto interval greater than the new Auto interval" );
-                DEBUG( "CWlanBgScan::InStateAuto() - * cancel scan and issue new with immediate expiry" );
-                iProvider.CancelScan();
-                SetInterval( autoInterval );
-                NotConnected();
-                }
-            else
-                {
-                DEBUG( "CWlanBgScan::InStateAuto() - current Auto interval smaller than the new Auto interval" );
-                DEBUG( "CWlanBgScan::InStateAuto() - * cancel scan and issue new with interval expiry" );
-                iProvider.CancelScan();
-                SetInterval( autoInterval );
-                ScanComplete();
-                }
-            
-            aState = EBgScanAuto;
-            break;
-            }
-        default:
-            {
-            DEBUG( "CWlanBgScan::InStateAuto() - state change Auto to On" );
-            SetInterval( aNewBgScanSetting );
-            iTimerServices.StopTimer( iIntervalChangeRequestId );
-            iIntervalChangeRequestId = 0;
-            // need to issue new scan request as it is possible that currently there is
-            // no scan requested
-            iProvider.CancelScan();
-            NotConnected();
-            aState = EBgScanOn;
-            }
-        }
+    CWlanBgScanStates::StartAggressiveBgScan( aInterval, aTimeout );
     }
-
-// ---------------------------------------------------------------------------
-// CWlanBgScan::InStateAutoAws
+    
 // ---------------------------------------------------------------------------
-//
-void CWlanBgScan::InStateAutoAws( TWlanBgScanState& aState, TUint32 aNewBgScanSetting )
-    {
-    switch( aNewBgScanSetting )
-        {
-        case KWlanBgScanIntervalNever:
-            {
-            DEBUG( "CWlanBgScan::InStateAutoAws() - state change Auto to Off" );
-            SetInterval( KWlanBgScanIntervalNever );
-            aState = EBgScanOff;
-            DEBUG( "CWlanBgScan::InStateAutoAws() - calling SendOrQueueAwsCommand()" );
-            CWlanBgScanAwsComms::TAwsMessage msg = { CWlanBgScanAwsComms::EStop, 0 };
-            iAwsComms->SendOrQueueAwsCommand( msg );
-            DEBUG( "CWlanBgScan::InStateAutoAws() - SendOrQueueAwsCommand() returned" );
-            iProvider.CancelScan();
-			break;
-            }
-        case KWlanBgScanIntervalAutomatic:
-            {
-            DEBUG( "CWlanBgScan::InStateAutoAws() - no change in the interval" );
-            aState = EBgScanAutoAws;
-            break;
-            }
-        default:
-            {
-            DEBUG( "CWlanBgScan::InStateAutoAws() - state change Auto to On" );
-            SetInterval( aNewBgScanSetting );
-            aState = EBgScanOn;
-            // need to issue new scan request as it is possible that currently there is
-            // no scan requested
-            DEBUG( "CWlanBgScan::InStateAutoAws() - calling SendAwsCommand()" );
-            CWlanBgScanAwsComms::TAwsMessage msg = { CWlanBgScanAwsComms::EStop, 0 };
-            iAwsComms->SendOrQueueAwsCommand( msg );
-            DEBUG( "CWlanBgScan::InStateAutoAws() - SendAwsCommand() returned" );
-            iProvider.CancelScan();
-            NotConnected();
-            }
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CWlanBgScan::Timeout
+// CWlanBgScan::OnTimeout
 // ---------------------------------------------------------------------------
 //
 void CWlanBgScan::OnTimeout()
     {
     DEBUG( "CWlanBgScan::OnTimeout()" );
-
-    // by design, OnTimeout should only happen
-    // in Auto state
-    ASSERT( iBgScanState == EBgScanAuto );
     
-    NextState( KWlanBgScanIntervalAutomatic );
+    NextState( CWlanBgScanStates::EBgScanEventIntervalChanged );
     
     }
 
@@ -795,60 +487,88 @@
 void CWlanBgScan::DoSetInterval( TUint32 aNewInterval )
     {
     DEBUG1( "CWlanBgScan::DoSetInterval( aNewInterval: %u )", aNewInterval );
+        
+    SetAutoInterval( aNewInterval );
+    DEBUG( "CWlanBgScan::DoSetInterval() - interval stored, giving event to state machine" );
     
-    if( iBgScanState != EBgScanAutoAws )
+    NextState( CWlanBgScanStates::EBgScanEventAwsIntervalChanged );
+
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScan::AwsPresence
+// --------------------------------------------------------------------------
+//
+CWlanBgScan::TAwsPresence CWlanBgScan::AwsPresence()
+    {
+    CWlanBgScan::TAwsPresence ret( CWlanBgScan::EAwsPresent );
+    
+    // If ( ( iAwsOk == EFalse ) And ( iAwsComms == NULL ) )  -> Return EAwsNotPresent
+    // If ( ( iAwsOk == EFalse ) And ( iAwsComms != NULL ) )  -> Return EAwsStarting
+    // Otherwise                                              -> return EAwsPresent
+    
+    if( iAwsOk == EFalse && iAwsComms == NULL )
         {
-        DEBUG( "CWlanBgScan::DoSetInterval() - state not AutoAws, ignoring request" );
-        return;
+        ret = CWlanBgScan::EAwsNotPresent;
+        }
+    if( iAwsOk == EFalse && iAwsComms != NULL )
+        {
+        ret = CWlanBgScan::EAwsStarting;
         }
     
-    TUint32 currentInterval( GetInterval() );
-        
-    if ( ( currentInterval == 0 ) && ( aNewInterval != 0 ) )
-        {
-        DEBUG( "CWlanBgScan::DoSetInterval() - current interval is zero and new interval is non-zero" );
-        DEBUG( "CWlanBgScan::DoSetInterval() - cancel scan and issue new with immediate expiry" );
-        iProvider.CancelScan();
-        SetInterval( aNewInterval );
-        NotConnected();
-        }
-    else if ( currentInterval == aNewInterval ) 
+    DEBUG1( "CWlanBgScan::AwsStatus() - returning %i", ret );
+    
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScan::AwsStartupComplete
+// --------------------------------------------------------------------------
+//
+void CWlanBgScan::AwsStartupComplete( TInt aStatus )
+    {
+    DEBUG1( "CWlanBgScan::AwsStartupComplete( aStatus: %d )", aStatus );
+    
+    SetAwsStartupStatus( aStatus );
+
+    if( aStatus == KErrNone )
         {
-        DEBUG( "CWlanBgScan::DoSetInterval() - no change in the interval" );
+        // AWS is ok
+        iAwsOk = ETrue;
         }
-    else if ( currentInterval > aNewInterval )
-        {
-        // if current interval greater than new interval -> cancel scan and 
-        // issue new with immediate expiry
-        DEBUG( "CWlanBgScan::DoSetInterval() - current interval greater than the new interval" );
-        DEBUG( "CWlanBgScan::DoSetInterval() - cancel scan and issue new with immediate expiry" );
-        iProvider.CancelScan();
-        SetInterval( aNewInterval );
-        NotConnected();
-        }
+#ifdef _DEBUG
     else
         {
-        DEBUG( "CWlanBgScan::DoSetInterval() - current interval smaller than the new interval" );
-        DEBUG( "CWlanBgScan::DoSetInterval() - take new interval into use after currently pending scan is completed" );
-        SetInterval( aNewInterval );
+        DEBUG( "CWlanBgScan::AwsStartupComplete() - error: AWS startup completed with error status, AWS not in use" );
         }
+#endif
+    
+    NextState( CWlanBgScanStates::EBgScanEventAwsStartupComplete );
     
     }
 
 // ---------------------------------------------------------------------------
-// CWlanBgScan::IsAwsPresent
+// CWlanBgScan::AwsCommandComplete
 // --------------------------------------------------------------------------
 //
-TBool CWlanBgScan::IsAwsPresent()
+void CWlanBgScan::AwsCommandComplete( MWlanBgScanAwsComms::TAwsCommand& aCommand, TInt aStatus )
     {
-    TBool ret( ETrue );
+    DEBUG2( "CWlanBgScan::AwsCommandComplete( aCommand: %d, aStatus: %d )", aCommand, aStatus );
+    
+    SetAwsCmdStatus( aCommand, aStatus );
+
+    NextState( CWlanBgScanStates::EBgScanEventAwsCmdComplete );
     
-    if( iAwsComms == NULL || !iAwsComms->IsAwsPresent() )
-        {
-        ret = EFalse;
-        }
+    }
 
-    DEBUG1( "CWlanBgScan::IsAwsPresent() - returning %i", ret );
+// ---------------------------------------------------------------------------
+// CWlanBgScan::AwsCommand
+// --------------------------------------------------------------------------
+//
+void CWlanBgScan::AwsCommand( MWlanBgScanAwsComms::TAwsMessage& aCommand )
+    {
+    DEBUG( "CWlanBgScan::AwsCommand() - calling SendOrQueueAwsCommand()" );
+    iAwsComms->SendOrQueueAwsCommand( aCommand );
     
-    return ret;
     }
+
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanbgscanawscomms.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanbgscanawscomms.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -16,13 +16,15 @@
 */
 
 /*
-* %version: 2 %
+* %version: 3 %
 */
 
 #include <e32base.h>
-#include <e32atomics.h>
+#include <e32cmn.h>
+#include <e32std.h>
 
 #include "awsinterface.h"
+#include "wlanbgscanawscommsinterface.h"
 #include "awsenginebase.h"
 #include "wlanbgscancommandlistener.h"
 #include "wlanbgscancommand.h"
@@ -45,6 +47,12 @@
  */
 const TInt KFirstItemIndex = 0;
 
+MWlanBgScanAwsComms* CWlanBgScanAwsCommsFactory::InstanceL( CWlanBgScan& aBgScan )
+    {
+    DEBUG( "CWlanBgScanAwsCommsFactory::Instance()" );
+    return CWlanBgScanAwsComms::NewL( aBgScan );
+    }
+
 // ======== MEMBER FUNCTIONS ========
 
 // ---------------------------------------------------------------------------
@@ -55,7 +63,7 @@
     CActive( CActive::EPriorityStandard ),
     iBgScan( aBgScan ),
     iAws( NULL ),
-    iAwsImplInfo( NULL ),
+    iAwsImplUid( 0 ),
     iCommandHandler( NULL ),
     iAwsVersion( 0 ),
     iPendingCommand( EAwsCommandMax ),
@@ -65,22 +73,23 @@
     }
 
 // ---------------------------------------------------------------------------
-// CWlanBgScanAwsComms::ConstructL
+// CWlanBgScanAwsComms::~CWlanBgScanAwsComms()
 // ---------------------------------------------------------------------------
 //
-void CWlanBgScanAwsComms::ConstructL()
+CWlanBgScanAwsComms::~CWlanBgScanAwsComms()
     {
-    DEBUG( "CWlanBgScanAwsComms::ConstructL()" );
+    DEBUG( "CWlanBgScanAwsComms::~CWlanBgScanAwsComms()" );
+
+    delete iAws;
+    iAws = NULL;
 
-    // create handler for incoming messages from AWS
-    iCommandHandler = CWlanBgScanCommand::NewL( *this );
-    
-    CActiveScheduler::Add( this );
+    delete iCommandHandler;
+    iCommandHandler = NULL;
 
-    // leaves if no AWS present in system
-    StartAwsThreadL();
-            
-    DEBUG( "CWlanBgScanAwsComms::ConstructL() - done" );    
+    iAwsMsgQueue.Close();
+    Cancel();
+    iWlanEngineThread.Close();
+    //iStartupLock.Close();
     }
 
 // ---------------------------------------------------------------------------
@@ -98,24 +107,35 @@
     }
 
 // ---------------------------------------------------------------------------
-// CWlanBgScanAwsComms::~CWlanBgScanAwsComms()
+// CWlanBgScanAwsComms::ConstructL
 // ---------------------------------------------------------------------------
 //
-CWlanBgScanAwsComms::~CWlanBgScanAwsComms()
+void CWlanBgScanAwsComms::ConstructL()
     {
-    DEBUG( "CWlanBgScanAwsComms::~CWlanBgScanAwsComms()" );
-
-    delete iAws;
-    iAws = NULL;
-
-    delete iAwsImplInfo;
-    iAwsImplInfo = NULL;
-
-    delete iCommandHandler;
-    iCommandHandler = NULL;
-
-    iAwsMsgQueue.Close();
-    Cancel();    
+    DEBUG( "CWlanBgScanAwsComms::ConstructL()" );
+    
+    // Get handle to current (WLAN Engine) thread so that
+    // the handle can be later used for completing the
+    // request status from AWS thread.
+    TThreadId id = RThread().Id();
+    TInt err = iWlanEngineThread.Open( id );
+    if( err != KErrNone )
+        {
+        DEBUG( "CWlanBgScanAwsComms::ConstructL() - Opening own thread handle failed" );
+        User::Leave( KErrBadHandle );
+        }
+        
+    // create handler for incoming messages from AWS
+    iCommandHandler = CWlanBgScanCommand::NewL( *this );
+    
+    CActiveScheduler::Add( this );
+    
+    DEBUG( "CWlanBgScanAwsComms::ConstructL() - Starting AWS thread" );
+    
+    // leaves if no AWS present in system
+    StartAwsThreadL();
+            
+    DEBUG( "CWlanBgScanAwsComms::ConstructL() - done" );    
     }
 
 // ---------------------------------------------------------------------------
@@ -135,6 +155,8 @@
 
 // ---------------------------------------------------------------------------
 // CWlanBgScanAwsComms::StartAwsThreadL
+//
+// This method is executing in the context of the WLAN Engine thread.
 // ---------------------------------------------------------------------------
 //
 void CWlanBgScanAwsComms::StartAwsThreadL()
@@ -154,28 +176,48 @@
         }
     
     // first found AWS implementation will be taken into use
-    iAwsImplInfo = static_cast<CImplementationInformation*>( awsImplArray[KFirstItemIndex] );
-    awsImplArray.Remove( KFirstItemIndex );
+    CImplementationInformation* awsImplInfo = static_cast<CImplementationInformation*>( awsImplArray[KFirstItemIndex] );
+    iAwsImplUid = awsImplInfo->ImplementationUid().iUid;
+
+    DEBUG( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - trying to instantiate AWS implementation:" );
+    DEBUG1( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - ImplementationUid:  0x%08X", awsImplInfo->ImplementationUid().iUid );
+#ifdef _DEBUG
+    TBuf8<KPrintLineLength> buf8;
+    buf8.Copy( awsImplInfo->DisplayName() );
+#endif
+    DEBUG1S( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - DisplayName:        ", buf8.Length(), buf8.Ptr() );
+    DEBUG1(  "CWlanBgScanAwsComms::InstantiateAwsPluginL() - Version:            %i", awsImplInfo->Version() );
+    DEBUG1S( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - DataType:           ", awsImplInfo->DataType().Length(), awsImplInfo->DataType().Ptr() );
+    DEBUG1S( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - OpaqueData:         ", awsImplInfo->OpaqueData().Length(), awsImplInfo->OpaqueData().Ptr() );
+    DEBUG1(  "CWlanBgScanAwsComms::InstantiateAwsPluginL() - RomOnly:            %i", awsImplInfo->RomOnly() );
+    DEBUG1(  "CWlanBgScanAwsComms::InstantiateAwsPluginL() - RomBased:           %i", awsImplInfo->RomBased() );
+    DEBUG1(  "CWlanBgScanAwsComms::InstantiateAwsPluginL() - VendorId:           0x%08X", awsImplInfo->VendorId().iId );
+                
+    DEBUG( "CWlanBgScanAwsComms::StartAwsThreadL() - setting request status to pending" );
+    iStatus = KRequestPending;
+    DEBUG( "CWlanBgScanAwsComms::StartAwsThreadL() - setting pending command to EAwsStartupCompleted" );
+    iPendingCommand = EAwsStartupCompleted;
+    DEBUG( "CWlanBgScanAwsComms::StartAwsThreadL() - setting ao active" );
+    SetActive();
     
-    CleanupStack::PopAndDestroy( &awsImplArray ); //this causes a call to CleanupEComArray
-
     DEBUG( "CWlanBgScanAwsComms::StartAwsThreadL() - creating AWS thread" );
     RThread thread;
-    TInt err = thread.Create( iAwsImplInfo->DisplayName(),
+    TInt err = thread.Create( awsImplInfo->DisplayName(),
                                 AwsThreadEntryPoint,
                                 KDefaultStackSize,
                                 KMinHeapSize,
                                 KMaxHeapSize, 
                                 reinterpret_cast<TAny*>( this ) );
+    
+    CleanupStack::PopAndDestroy( &awsImplArray ); //this causes a call to CleanupEComArray
+        
     if( err != KErrNone)
         {
         DEBUG1( "CWlanBgScanAwsComms::StartAwsThreadL() - error: thread creation failed with error %i", err );
-        delete iAwsImplInfo;
-        iAwsImplInfo = NULL;
         User::Leave( err );
         }
 
-    DEBUG( "CWlanBgScanAwsComms::StartAwsThreadL() - Resuming AWS thread" );
+    DEBUG( "CWlanBgScanAwsComms::StartAwsThreadL() - resuming AWS thread" );
     thread.Resume();
     thread.Close();
 
@@ -190,7 +232,7 @@
 //
 TInt CWlanBgScanAwsComms::AwsThreadEntryPoint( TAny* aThisPtr )
     {
-    DEBUG("CWlanBgScanAwsComms::AwsThreadEntryPoint()");
+    DEBUG( "CWlanBgScanAwsComms::AwsThreadEntryPoint()" );
     
     CWlanBgScanAwsComms* self = static_cast<CWlanBgScanAwsComms*>( aThisPtr );
     
@@ -204,71 +246,59 @@
     
     __UHEAP_MARK;
     
-    TRAPD( err, self->InstantiateAwsPluginL() );
+    TRAPD( err, self->InstantiateAndRunAwsPluginL() );
     if ( err != KErrNone )
         {
-        DEBUG1("CWlanBgScanAwsComms::AwsThreadEntryPoint() - AWS instantiation leaved with code %i", err);
+        DEBUG1( "CWlanBgScanAwsComms::AwsThreadEntryPoint() - error: AWS instantiation leaved, completing request to WLAN Engine thread with code %i", err );
+        TRequestStatus *status = &self->iStatus;
+        self->iWlanEngineThread.RequestComplete( status, err );
         }
-
+    
     __UHEAP_MARKEND;
 
     delete cleanup;
     cleanup = NULL;
+    DEBUG( "CWlanBgScanAwsComms::AwsThreadEntryPoint() - AWS thread exiting" );
     return KErrNone;    
     }
 
 // -----------------------------------------------------------------------------
-// CWlanBgScanAwsComms::InstantiateAwsPluginL
+// CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL
 //
 // This method is executing in the context of the AWS thread.
 // -----------------------------------------------------------------------------
 //
-void CWlanBgScanAwsComms::InstantiateAwsPluginL()
+void CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL()
     {
-    DEBUG("CWlanBgScanAwsComms::InstantiateAwsPluginL()");
-    
-    ASSERT( iAwsImplInfo );
+    DEBUG( "CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL()" );
     
     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
     CleanupStack::PushL( scheduler );
     CActiveScheduler::Install( scheduler );
     
-    DEBUG( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - trying to instantiate AWS implementation:" );
-    DEBUG1( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - ImplementationUid:  0x%08X", iAwsImplInfo->ImplementationUid().iUid );
-#ifdef _DEBUG
-    TBuf8<KPrintLineLength> buf8;
-    buf8.Copy( iAwsImplInfo->DisplayName() );
-#endif
-    DEBUG1S("CWlanBgScanAwsComms::InstantiateAwsPluginL() - DisplayName:        ", buf8.Length(), buf8.Ptr() );
-    DEBUG1( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - Version:            %i", iAwsImplInfo->Version() );
-    DEBUG1S("CWlanBgScanAwsComms::InstantiateAwsPluginL() - DataType:           ", iAwsImplInfo->DataType().Length(), iAwsImplInfo->DataType().Ptr() );
-    DEBUG1S("CWlanBgScanAwsComms::InstantiateAwsPluginL() - OpaqueData:         ", iAwsImplInfo->OpaqueData().Length(), iAwsImplInfo->OpaqueData().Ptr() );
-    DEBUG1( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - RomOnly:            %i", iAwsImplInfo->RomOnly() );
-    DEBUG1( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - RomBased:           %i", iAwsImplInfo->RomBased() );
-    DEBUG1( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - VendorId:           0x%08X", iAwsImplInfo->VendorId().iId );
+    DEBUG( "CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL() - active scheduler installed" );
+    CAwsEngineBase::TAwsEngineConstructionParameters params = { this, KBgScanVersion, iAwsVersion };
+
+    TRequestStatus *status = &iStatus;
     
-    CAwsEngineBase::TAwsEngineConstructionParameters params = { this, KBgScanVersion, iAwsVersion };
-    iAws = CAwsEngineBase::NewL( iAwsImplInfo->ImplementationUid().iUid, &params );
+    DEBUG( "CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL() - calling CAwsEngineBase::NewL()" );
+    iAws = CAwsEngineBase::NewL( iAwsImplUid, &params ); // iAws deallocated in destructor
+
+    DEBUG1( "CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL() - AWS version %u instantiated", iAwsVersion );
     
-    DEBUG1( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - AWS instantiated OK, iAwsVersion %u", iAwsVersion );
-    iAwsOk = ETrue;
-
-    __e32_memory_barrier();
-    DEBUG( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - data members synchronized" );
+    DEBUG( "CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL() - completing request to WLAN Engine thread" );
+    iWlanEngineThread.RequestComplete( status, KErrNone );
     
-    DEBUG( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - starting active scheduler - AWS is now in control of this thread" );
+    DEBUG( "CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL() - starting active scheduler - AWS is now in control of this thread" );
     CActiveScheduler::Start();
 
     // Thread execution will stay in CActiveScheduler::Start() until active scheduler is stopped
-    DEBUG("CWlanBgScanAwsComms::InstantiateAwsPluginL() - active scheduler stopped" );
-    
+    DEBUG("CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL() - active scheduler stopped" );
+
     // clean up
-    delete iAws;
-    iAws = NULL;
     CleanupStack::PopAndDestroy( scheduler );
     
-    DEBUG( "CWlanBgScanAwsComms::InstantiateAwsPluginL() - exiting..." );
-    User::Exit( KErrNone );
+    DEBUG( "CWlanBgScanAwsComms::InstantiateAndRunAwsPluginL() - done" );
     }
 
 // ---------------------------------------------------------------------------
@@ -289,6 +319,8 @@
 
 // ---------------------------------------------------------------------------
 // CWlanBgScanAwsComms::SendOrQueueAwsCommand
+//
+// This method is executing in the context of the WLAN Engine thread.
 // ---------------------------------------------------------------------------
 //
 void CWlanBgScanAwsComms::SendOrQueueAwsCommand( TAwsMessage& aMessage )
@@ -320,6 +352,8 @@
 
 // ---------------------------------------------------------------------------
 // CWlanBgScanAwsComms::SendAwsCommand
+//
+// This method is executing in the context of the WLAN Engine thread.
 // ---------------------------------------------------------------------------
 //
 void CWlanBgScanAwsComms::SendAwsCommand( TAwsMessage& aMessage )
@@ -373,12 +407,30 @@
 
 // ---------------------------------------------------------------------------
 // CWlanBgScanAwsComms::RunL
+//
+// This method is executing in the context of the WLAN Engine thread.
 // ---------------------------------------------------------------------------
 //
 void CWlanBgScanAwsComms::RunL()
     {   
     DEBUG2( "CWlanBgScanAwsComms::RunL() - command: %u, completion status: %d", iPendingCommand, iStatus.Int() );
     
+    switch ( iPendingCommand )
+        {
+        case EAwsStartupCompleted:
+            {
+            DEBUG( "CWlanBgScanAwsComms::RunL() - AWS startup has been completed" );
+            iBgScan.AwsStartupComplete( iStatus.Int() );
+            break;
+            }
+        default:
+            {
+            DEBUG( "CWlanBgScanAwsComms::RunL() - AWS command has been completed" );
+            iBgScan.AwsCommandComplete( iPendingCommand, iStatus.Int() );
+            break;
+            }
+        }
+    
     TAwsMessage cmd = { EAwsCommandMax, NULL };
 
     // if there are more commands, send the next one
@@ -421,13 +473,3 @@
     iBgScan.DoSetInterval( aNewInterval );
     }
 
-// ---------------------------------------------------------------------------
-// CWlanBgScanAwsComms::IsAwsPresent
-// ---------------------------------------------------------------------------
-//
-TBool CWlanBgScanAwsComms::IsAwsPresent()
-    {
-    DEBUG1( "CWlanBgScanAwsComms::IsAwsPresent() - returning %d", iAwsOk );
-    
-    return iAwsOk;
-    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanbgscanstates.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -0,0 +1,883 @@
+/*
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements WLAN background scan logic.
+*
+*/
+
+/*
+* %version: 2 %
+*/
+
+#include <e32base.h>
+#include <e32const.h> 
+
+#include "wlanscanproviderinterface.h"
+#include "awsinterface.h"
+#include "awsenginebase.h"
+#include "wlancbwaiter.h"
+#include "wlanbgscanawscommsinterface.h"
+#include "wlanbgscan.h"
+#include "wlanbgscanstates.h"
+#include "wlandevicesettings.h" // default values in case invalid data is passed in NotifyChangedSettings
+#include "wlantimer.h"
+#include "am_debug.h"
+
+/** Constant indicating that scanning is disabled */
+const TUint32 KWlanNoScanning( 0xFFFFFFFF );
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::CWlanBgScanStates
+// ---------------------------------------------------------------------------
+//
+CWlanBgScanStates::CWlanBgScanStates( CWlanBgScan& aBgScan, MWlanScanResultProvider& aProvider, MWlanTimerServices& aTimerServices ) :
+    iBgScan( aBgScan ),
+    iUsedBgScanInterval( KWlanNoScanning ),
+    iBgScanInterval( KWlanNoScanning ),
+    iAggressiveBgScanInterval( KWlanNoScanning ),
+    iAggressiveBgScanTimer( NULL ),
+    iNextState( EBgScanStateMax ),
+    iAwsStartupStatus( KErrNotFound ),
+    iAwsCmd( MWlanBgScanAwsComms::EAwsCommandMax ),
+    iAwsCmdStatus( KErrNone ),
+    iAutoInterval( KWlanBgScanIntervalNever ),
+    iProvider( aProvider ),
+    iTimerServices( aTimerServices ),
+    iBgScanState( EBgScanStateMax ),
+    iIntervalChangeRequestId( 0 ),
+    iCompletedAwsCommand( MWlanBgScanAwsComms::EAwsCommandMax ),
+    iAwsCommandCompletionCode( KErrNone )
+    {
+    DEBUG( "CWlanBgScanStates::CWlanBgScanStates()" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::ConstructL()
+    {
+    DEBUG( "CWlanBgScanStates::ConstructL()" );
+    
+    if( iBgScan.AwsPresence() == CWlanBgScan::EAwsStarting )
+        {
+        DEBUG( "CWlanBgScanStates::ConstructL() - AWS starting up, goto Init state" );
+        iBgScanState = EBgScanInit;
+        }
+    else
+        {
+        DEBUG( "CWlanBgScanStates::ConstructL() - AWS not present, goto Off state" );
+        iBgScanState = EBgScanOff;
+        }
+        
+    // Create a timer for guarding when to drop out of aggressive BG scan mode
+    iAggressiveBgScanTimer = CWlanTimer::NewL( TCallBack( StopAggressiveBgScan, this ),
+                                               TCallBack( StopAggressiveBgScan, this ),
+                                               TCallBack( StopAggressiveBgScan, this ) );
+                
+    DEBUG( "CWlanBgScanStates::ConstructL() - done" );    
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::~CWlanBgScanStates
+// ---------------------------------------------------------------------------
+//
+CWlanBgScanStates::~CWlanBgScanStates()
+    {
+    DEBUG( "CWlanBgScanStates::~CWlanBgScanStates()" );
+    delete iAggressiveBgScanTimer;
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StartAggressiveBgScan
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StartAggressiveBgScan( TUint32& aInterval, TUint32& aDuration )
+    {
+    DEBUG3( "CWlanBgScanStates::StartAggressiveBgScan() - new interval: %u, old interval: %u, duration: %u",
+        aInterval, iAggressiveBgScanInterval, aDuration );
+    // Serve the request only if the requested interval is smaller or equal than
+    // what is already being served
+    if( aInterval <= iAggressiveBgScanInterval )
+        {
+        iAggressiveBgScanInterval = aInterval;
+    
+        // Start the timer guarding when to drop out of aggressive mode
+        iAggressiveBgScanTimer->Cancel();
+        iAggressiveBgScanTimer->After( aDuration );    
+    
+        // Refresh interval used in BG scanning
+        RefreshUsedInterval();
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StopAggressiveBgScan
+// ---------------------------------------------------------------------------
+//
+TInt CWlanBgScanStates::StopAggressiveBgScan( TAny* aPtr )
+    {
+    DEBUG( "CWlanBgScanStates::StopAggressiveBgScan()" );
+    
+    CWlanBgScanStates* self = static_cast<CWlanBgScanStates*>( aPtr );
+    
+    // Disable aggressive mode
+    self->iAggressiveBgScanInterval = KWlanNoScanning;
+    
+    // Refresh interval used in BG scanning
+    self->RefreshUsedInterval();
+    
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::GetBgInterval
+// ---------------------------------------------------------------------------
+//
+TUint32 CWlanBgScanStates::GetBgInterval()
+    {
+    TUint32 scanInterval( iUsedBgScanInterval );
+    
+    if( scanInterval == KWlanNoScanning )
+        {
+        scanInterval = KWlanBgScanIntervalNever;
+        }
+        
+    return scanInterval;
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::IntervalChanged
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::IntervalChanged()
+    {
+    DEBUG( "CWlanBgScanStates::IntervalChanged()" );
+
+    if( iBgScan.AwsPresence() == CWlanBgScan::EAwsStarting )
+        {
+        DEBUG( "CWlanBgScanStates::IntervalChanged() - AWS is still starting up, returning" );
+        return;
+        }
+    
+    NextState( CWlanBgScanStates::EBgScanEventIntervalChanged );
+    
+    DEBUG2( "CWlanBgScanStates::IntervalChanged() - current interval %u, current state %u",
+            GetBgInterval(),
+            iBgScanState );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::NextState
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::NextState( const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent )
+    {
+    DEBUG1( "CWlanBgScanStates::NextState() - aEvent %u", aEvent );
+    
+    switch ( iBgScanState )
+        {
+        case EBgScanInit:
+            {
+            InStateInit( iBgScanState, aEvent );
+            break;
+            }
+        case EBgScanOff:
+            {
+            InStateOff( iBgScanState, aEvent );
+            break;
+            }
+        case EBgScanOn:
+            {
+            InStateOn( iBgScanState, aEvent );
+            break;
+            }
+        case EBgScanAuto:
+            {
+            InStateAuto( iBgScanState, aEvent );
+            break;
+            }
+        case EBgScanAutoAws:
+            {
+            InStateAutoAws( iBgScanState, aEvent );
+            break;
+            }
+        case EBgScanSendingAwsCmd:
+            {
+            InStateSendingAwsCmd( iBgScanState, aEvent );
+            break;
+            }
+        default:
+            {
+            DEBUG1( "CWlanBgScanStates::NextState() - error: invalid state %d", iBgScanState );
+            ASSERT( 0 );
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::InStateInit
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::InStateInit( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent )
+    {
+    switch( aEvent )
+        {
+        case CWlanBgScanStates::EBgScanEventAwsStartupComplete:
+            {
+            DEBUG( "CWlanBgScanStates::InStateInit() - event: EBgScanEventAwsStartupComplete" );
+            switch( AwsStartupStatus() )
+                {
+                case KErrNone:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateInit() - AWS startup successful" );
+                    switch ( iBgScanSettings.backgroundScanInterval )
+                        {
+                        case KWlanBgScanIntervalNever:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateInit() - state change Init to Off" );
+                            StateChangeInitToOff( aState );
+                            break;
+                            }
+                        case KWlanBgScanIntervalAutomatic:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateInit() - state change Init to AutoAws" );
+                            StateChangeInitToAutoAws( aState );
+                            break;
+                            }
+                        default:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateInit() - state change Init to On" );
+                            StateChangeInitToOn( aState );
+                            }
+                        }
+                    break;
+                    }
+                default:
+                    {
+                    DEBUG1( "CWlanBgScanStates::InStateInit() - AWS startup failed! Status %d", AwsStartupStatus() );
+                    switch ( iBgScanSettings.backgroundScanInterval )
+                        {
+                        case KWlanBgScanIntervalNever:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateInit() - state change Init to Off" );
+                            StateChangeInitToOff( aState );
+                            break;
+                            }
+                        case KWlanBgScanIntervalAutomatic:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateInit() - state change Init to Auto" );
+                            StateChangeInitToAuto( aState );
+                            break;
+                            }
+                        default:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateInit() - state change Init to On" );
+                            StateChangeInitToOn( aState );
+                            break;
+                            }
+                        }
+                    break;
+                    }
+                }
+            break;
+            }
+        default:
+            {
+            DEBUG1( "CWlanBgScanStates::InStateInit() - event %d ignored", aEvent );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeInitToOn
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeInitToOn( TWlanBgScanState& aState )
+    {
+    DEBUG( "CWlanBgScanStates::StateChangeInitToOn()" );
+    aState = EBgScanOn;
+    SetInterval( iBgScanSettings.backgroundScanInterval );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeInitToOff
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeInitToOff( TWlanBgScanState& aState )
+    {
+    DEBUG( "CWlanBgScanStates::StateChangeInitToOff()" );
+    aState = EBgScanOff;
+    SetInterval( KWlanBgScanIntervalNever );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeInitToAuto
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeInitToAuto( TWlanBgScanState& aState )
+    {
+    aState = EBgScanAuto;
+    DEBUG( "CWlanBgScanStates::StateChangeInitToAuto() - determine next interval change time and request callback" );
+    iBgScan.ScheduleAutoIntervalChange();
+    SetInterval( iBgScan.CurrentAutoInterval() );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::InStateOff
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::InStateOff( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent )
+    {
+    switch( aEvent )
+        {
+        case CWlanBgScanStates::EBgScanEventIntervalChanged:
+            {
+            DEBUG( "CWlanBgScanStates::InStateOff() - event: EBgScanEventIntervalChanged" );
+            switch( iBgScanSettings.backgroundScanInterval )
+                {
+                case KWlanBgScanIntervalNever:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateOff() - no change in the interval" );
+                    aState = EBgScanOff;
+                    break;
+                    }
+                case KWlanBgScanIntervalAutomatic:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateOff() - state change Off to Automatic" );
+                    StateChangeOffToAutomatic( aState );
+                    break;
+                    }
+                default:
+                    {
+                    DEBUG1( "CWlanBgScanStates::InStateOff() - state change Off to On (interval: %u)", iBgScanSettings.backgroundScanInterval );
+                    StateChangeOffToOn( aState, iBgScanSettings.backgroundScanInterval );
+                    }
+                }
+            break;
+            }
+        default:
+            {
+            DEBUG1( "CWlanBgScanStates::InStateOff() - event %d ignored", aEvent );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeOffToOn
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeOffToOn( TWlanBgScanState& aState, TUint32 aNewBgScanInterval )
+    {
+    aState = EBgScanOn;
+    SetInterval( aNewBgScanInterval );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeOffToAutomatic
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeOffToAutomatic( TWlanBgScanState& aState )
+    {
+    if ( iBgScan.AwsPresence() == CWlanBgScan::EAwsPresent )
+        {
+        DEBUG( "CWlanBgScanStates::StateChangeOffToAutomatic() - state change Off to SendingAwsCmd" );
+        aState = EBgScanSendingAwsCmd;
+        DEBUG( "CWlanBgScanStates::InStaStateChangeOffToAutomaticteOff() - if command sending succeeds, next state is AutoAws" );
+        iNextState = EBgScanAutoAws;
+        MWlanBgScanAwsComms::TAwsMessage msg = { MWlanBgScanAwsComms::EStart, 0 };
+        iBgScan.AwsCommand( msg );
+        DEBUG( "CWlanBgScanStates::StateChangeOffToAutomatic() - SendOrQueueAwsCommand() returned" );
+        }
+    else
+        {
+        DEBUG( "CWlanBgScanStates::StateChangeOffToAutomatic() - state change Off to Auto" );
+        DEBUG( "CWlanBgScanStates::StateChangeOffToAutomatic() - determine next interval change time and request callback" );
+        aState = EBgScanAuto;
+        iBgScan.ScheduleAutoIntervalChange();
+        SetInterval( iBgScan.CurrentAutoInterval() );
+        }
+    }
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::InStateOn
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::InStateOn( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent )
+    {
+    switch( aEvent )
+        {
+        case CWlanBgScanStates::EBgScanEventIntervalChanged:
+            {
+            DEBUG( "CWlanBgScanStates::InStateOn() - event: EBgScanEventIntervalChanged" );
+            switch( iBgScanSettings.backgroundScanInterval )
+                {
+                case KWlanBgScanIntervalNever:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateOn() - state change On to Off" );
+                    StateChangeOnToOff( aState );
+                    break;
+                    }
+                case KWlanBgScanIntervalAutomatic:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateOn() - state change On to Auto" );
+                    StateChangeOnToAutomatic( aState );
+                    break;
+                    }
+                default:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateOn() - state change On to On" );
+                    StateChangeOnToOn( aState, iBgScanSettings.backgroundScanInterval );
+                    }
+                }
+            break;
+            }
+        default:
+            {
+            DEBUG1( "CWlanBgScanStates::InStateOn() - event %d ignored", aEvent );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeOnToOn
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeOnToOn( TWlanBgScanState& aState, TUint32 aNewBgScanSetting  )
+    {
+    aState = EBgScanOn;
+    SetInterval( aNewBgScanSetting );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeOnToAutomatic
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeOnToAutomatic( TWlanBgScanState& aState )
+    {
+    if ( iBgScan.AwsPresence() == CWlanBgScan::EAwsPresent )
+        {
+        DEBUG( "CWlanBgScanStates::StateChangeOnToAutomatic() - state change Init to SendingAwsCmd" );
+        aState = EBgScanSendingAwsCmd;
+        DEBUG( "CWlanBgScanStates::StateChangeOnToAutomatic() - if command sending succeeds, next state is AutoAws" );
+        iNextState = EBgScanAutoAws;
+        MWlanBgScanAwsComms::TAwsMessage msg = { MWlanBgScanAwsComms::EStart, 0 };
+        iBgScan.AwsCommand( msg );
+        DEBUG( "CWlanBgScanStates::StateChangeOnToAutomatic() - SendOrQueueAwsCommand() returned" );
+        }
+    else
+        {
+        aState = EBgScanAuto;
+        iBgScan.ScheduleAutoIntervalChange();
+        SetInterval( iBgScan.CurrentAutoInterval() );        
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeOnToOff
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeOnToOff( TWlanBgScanState& aState )
+    {
+    aState = EBgScanOff;
+    SetInterval( KWlanBgScanIntervalNever );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::InStateAuto
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::InStateAuto( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent )
+    {
+    switch( aEvent )
+        {
+        case CWlanBgScanStates::EBgScanEventIntervalChanged:
+            {
+            DEBUG( "CWlanBgScanStates::InStateAuto() - event: EBgScanEventIntervalChanged" );
+            switch( iBgScanSettings.backgroundScanInterval )
+                {
+                case KWlanBgScanIntervalNever:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateAuto() - state change Auto to Off" );
+                    StateChangeAutoToOff( aState );
+                    break;
+                    }
+                case KWlanBgScanIntervalAutomatic:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateAuto() - state still Auto" );
+                    StateChangeAutoToAuto( aState );
+                    break;
+                    }
+                default:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateAuto() - state change Auto to On" );
+                    StateChangeAutoToOn( aState, iBgScanSettings.backgroundScanInterval );
+                    }
+                }
+            break;
+            }
+        default:
+            {
+            DEBUG1( "CWlanBgScanStates::InStateAuto() - event %d ignored", aEvent );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeAutoToOff
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeAutoToOff( TWlanBgScanState& aState )
+    {
+    aState = EBgScanOff;
+    iTimerServices.StopTimer( iIntervalChangeRequestId );
+    iIntervalChangeRequestId = 0;
+    SetInterval( KWlanBgScanIntervalNever );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeAutoToAuto
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeAutoToAuto( TWlanBgScanState& aState )
+    {
+    aState = EBgScanAuto;
+    iBgScan.ScheduleAutoIntervalChange();
+    SetInterval( iBgScan.CurrentAutoInterval() );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeAutoToOn
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeAutoToOn( TWlanBgScanState& aState, TUint32 aNewBgScanSetting  )
+    {
+    aState = EBgScanOn;
+    iTimerServices.StopTimer( iIntervalChangeRequestId );
+    iIntervalChangeRequestId = 0;
+    SetInterval( aNewBgScanSetting );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::InStateAutoAws
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::InStateAutoAws( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent )
+    {
+    switch( aEvent )
+        {
+        case CWlanBgScanStates::EBgScanEventIntervalChanged:
+            {
+            DEBUG( "CWlanBgScanStates::InStateAutoAws() - event: EBgScanEventIntervalChanged" );
+            switch( iBgScanSettings.backgroundScanInterval )
+                {
+                case KWlanBgScanIntervalNever:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateAutoAws() - state change AutoAws to Off" );
+                    StateChangeAutoAwsToOff( aState );
+                    break;
+                    }
+                case KWlanBgScanIntervalAutomatic:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateAutoAws() - no change in the interval" );
+                    aState = EBgScanAutoAws;
+                    break;
+                    }
+                default:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateAutoAws() - state change AutoAws to On" );
+                    StateChangeAutoAwsToOn( aState );
+                    }
+                }
+            break;
+            }
+        case CWlanBgScanStates::EBgScanEventAwsIntervalChanged:
+            {
+            DEBUG( "CWlanBgScanStates::InStateAutoAws() - event: EBgScanEventAwsIntervalChanged" );
+            SetInterval( AutoInterval() );
+            break;
+            }
+        default:
+            {
+            DEBUG1( "CWlanBgScanStates::InStateAutoAws() - event %d ignored", aEvent );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeAutoAwsToOff
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeAutoAwsToOff( TWlanBgScanState& aState )
+    {
+    aState = EBgScanSendingAwsCmd;
+    iNextState = EBgScanOff;
+    DEBUG( "CWlanBgScanStates::StateChangeAutoAwsToOff() - calling SendOrQueueAwsCommand()" );
+    MWlanBgScanAwsComms::TAwsMessage msg = { MWlanBgScanAwsComms::EStop, 0 };
+    iBgScan.AwsCommand( msg );
+    DEBUG( "CWlanBgScanStates::StateChangeAutoAwsToOff() - SendOrQueueAwsCommand() returned" );
+    iProvider.CancelScan();
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeAutoAwsToOn
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeAutoAwsToOn( TWlanBgScanState& aState )
+    {
+    aState = EBgScanSendingAwsCmd;
+    iNextState = EBgScanOn;
+    DEBUG( "CWlanBgScanStates::StateChangeAutoAwsToOn() - calling SendAwsCommand()" );
+    MWlanBgScanAwsComms::TAwsMessage msg = { MWlanBgScanAwsComms::EStop, 0 };
+    iBgScan.AwsCommand( msg );
+    DEBUG( "CWlanBgScanStates::StateChangeAutoAwsToOn() - SendAwsCommand() returned" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::InStateSendingAwsCmd
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::InStateSendingAwsCmd( TWlanBgScanState& aState, const CWlanBgScanStates::TWlanBgScanSmEvent& aEvent )
+    {
+    DEBUG1( "CWlanBgScanStates::InStateSendingAwsCmd() - event: %d", aEvent );
+
+    switch( aEvent )
+        {
+        case CWlanBgScanStates::EBgScanEventAwsCmdComplete:
+            {
+            DEBUG( "CWlanBgScanStates::InStateSendingAwsCmd() - event: EBgScanEventAwsCmdComplete" );
+            switch( AwsCmdStatus() )
+                {
+                case KErrNone:
+                    {
+                    DEBUG( "CWlanBgScanStates::InStateSendingAwsCmd() - AWS command sending successful" );
+                    switch ( iNextState )
+                        {
+                        case EBgScanOff:
+                            {
+                            ASSERT( AwsCmd() == MWlanBgScanAwsComms::EStop );
+                            DEBUG( "CWlanBgScanStates::InStateSendingAwsCmd() - state change SendingAwsCmd to Off" );
+                            StateChangeSendingAwsCmdToOff( aState );
+                            break;
+                            }
+                        case EBgScanOn:
+                            {
+                            ASSERT( AwsCmd() == MWlanBgScanAwsComms::EStop );
+                            DEBUG( "CWlanBgScanStates::InStateSendingAwsCmd() - state change SendingAwsCmd to On" );
+                            StateChangeSendingAwsCmdToOn( aState );
+                            break;
+                            }
+                        case EBgScanAutoAws:
+                            {
+                            ASSERT( AwsCmd() == MWlanBgScanAwsComms::EStart );
+                            DEBUG( "CWlanBgScanStates::InStateSendingAwsCmd() - state change SendingAwsCmd to AutoAws" );
+                            StateChangeSendingAwsCmdToAutoAws( aState );
+                            break;
+                            }
+                        default:
+                            {
+                            DEBUG1( "CWlanBgScanStates::InStateSendingAwsCmd() - illegal state change from SendingAwsCmd to %u", iNextState );
+                            ASSERT( 0 );
+                            }
+                        }
+                    break;
+                    }
+                default:
+                    {
+                    DEBUG2( "CWlanBgScanStates::InStateSendingAwsCmd() - AWS command %d sending failed! Status %d", AwsCmd(), AwsCmdStatus() );
+                    switch ( iNextState )
+                        {
+                        case EBgScanOff:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateSendingAwsCmd() - state change SendingAwsCmd to Off" );
+                            StateChangeSendingAwsCmdToOff( aState );
+                            break;
+                            }
+                        case EBgScanOn:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateSendingAwsCmd() - state change SendingAwsCmd to On" );
+                            StateChangeSendingAwsCmdToOn( aState );
+                            break;
+                            }
+                        case EBgScanAutoAws:
+                            {
+                            DEBUG( "CWlanBgScanStates::InStateSendingAwsCmd() - state change SendingAwsCmd to Auto" );
+                            StateChangeSendingAwsCmdToAuto( aState );
+                            break;
+                            }
+                        default:
+                            {
+                            DEBUG1( "CWlanBgScanStates::InStateSendingAwsCmd() - illegal state change from SendingAwsCmd to %u", iNextState );
+                            ASSERT( 0 );
+                            }
+                        }
+                    break;
+                    }
+                }
+            break;
+            }
+        default:
+            {
+            DEBUG1( "CWlanBgScanStates::InStateSendingAwsCmd() - event %d ignored", aEvent );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeInitToAutoAws
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeInitToAutoAws( TWlanBgScanState& aState )
+    {
+    if ( iBgScan.AwsPresence() == CWlanBgScan::EAwsPresent )
+        {
+        DEBUG( "CWlanBgScanStates::StateChangeInitToAutoAws() - state change Init to SendingAwsCmd" );
+        aState = EBgScanSendingAwsCmd;
+        DEBUG( "CWlanBgScanStates::StateChangeInitToAutoAws() - if command sending succeeds, next state is AutoAws" );
+        iNextState = EBgScanAutoAws;
+        MWlanBgScanAwsComms::TAwsMessage msg = { MWlanBgScanAwsComms::EStart, 0 };
+        iBgScan.AwsCommand( msg );
+        DEBUG( "CWlanBgScanStates::StateChangeInitToAutoAws() - SendOrQueueAwsCommand() returned" );
+        }
+    else
+        {
+        DEBUG( "CWlanBgScanStates::StateChangeInitToAutoAws() - error: AWS not present!" );
+        ASSERT( 0 );
+        DEBUG( "CWlanBgScanStates::StateChangeInitToAutoAws() - state change Init to Auto" );
+        aState = EBgScanAuto;
+        DEBUG( "CWlanBgScanStates::StateChangeInitToAutoAws() - * determine next interval change time and request callback" );
+        iBgScan.ScheduleAutoIntervalChange();
+        SetInterval( iBgScan.CurrentAutoInterval() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeSendingAwsCmdToOff
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeSendingAwsCmdToOff( TWlanBgScanState& aState )
+    {
+    DEBUG( "CWlanBgScanStates::StateChangeSendingAwsCmdToOff()" );
+    aState = EBgScanOff;
+    SetInterval( KWlanBgScanIntervalNever );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeSendingAwsCmdToOn
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeSendingAwsCmdToOn( TWlanBgScanState& aState )
+    {
+    DEBUG( "CWlanBgScanStates::StateChangeSendingAwsCmdToOn()" );
+    aState = EBgScanOn;
+    SetInterval( iBgScanSettings.backgroundScanInterval );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeSendingAwsCmdToAuto
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeSendingAwsCmdToAuto( TWlanBgScanState& aState )
+    {
+    DEBUG( "CWlanBgScanStates::StateChangeSendingAwsCmdToAuto()" );
+    aState = EBgScanAuto;
+    DEBUG( "CWlanBgScanStates::StateChangeSendingAwsCmdToAuto() - * determine next interval change time and request callback" );
+    iBgScan.ScheduleAutoIntervalChange();
+    SetInterval( iBgScan.CurrentAutoInterval() );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::StateChangeSendingAwsCmdToAutoAws
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::StateChangeSendingAwsCmdToAutoAws( TWlanBgScanState& aState )
+    {
+    DEBUG( "CWlanBgScanStates::StateChangeSendingAwsCmdToAutoAws()" );
+    aState = EBgScanAutoAws;
+    SetInterval( AutoInterval() );
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::SetInterval
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::SetInterval( TUint32 aInterval )
+    {
+    DEBUG2( "CWlanBgScanStates::SetInterval() - current: %u, new: %u", iBgScanInterval, aInterval );
+
+    if( aInterval == KWlanBgScanIntervalNever )
+        {
+        iBgScanInterval = KWlanNoScanning;
+        }
+    else
+        {
+        iBgScanInterval = aInterval;
+        }
+    
+    RefreshUsedInterval();
+    }
+
+// ---------------------------------------------------------------------------
+// CWlanBgScanStates::RefreshUsedInterval
+// ---------------------------------------------------------------------------
+//
+void CWlanBgScanStates::RefreshUsedInterval()
+    {
+    TUint oldInterval = iUsedBgScanInterval;
+    
+    DEBUG2( "CWlanBgScanStates::RefreshUsedInterval() - agg: %u, normal: %u",
+        iAggressiveBgScanInterval, iBgScanInterval );
+    
+    // Smaller of the two intervals will be taken into use
+    if( iAggressiveBgScanInterval < iBgScanInterval )
+        {
+        iUsedBgScanInterval = iAggressiveBgScanInterval;
+        }
+    else
+        {
+        iUsedBgScanInterval = iBgScanInterval;
+        }
+    
+    // If the interval changed, update it to P&S
+    if( iUsedBgScanInterval != oldInterval )
+        {
+        DEBUG2( "CWlanBgScanStates::RefreshUsedInterval() - used interval changed (new: %u, old: %u), publish it via P&S",
+            iUsedBgScanInterval, oldInterval );
+        TUint32 interval = GetBgInterval();
+        iProvider.PublishBgScanInterval( interval );
+        }
+   
+    // Check if scanning has to be cancelled or carried out immediately
+    if( KWlanNoScanning == iUsedBgScanInterval )
+        {
+        DEBUG( "CWlanBgScanStates::RefreshUsedInterval() - scanning disabled, cancel pending scan" );
+        // In case scanning was disabled, cancel the pending scan request
+        iProvider.CancelScan();
+        }
+    else if( iUsedBgScanInterval < oldInterval )
+        {
+        DEBUG( "CWlanBgScanStates::RefreshUsedInterval() - new interval smaller than the old one, scan immediately" );
+        // In case the new interval is smaller than the old one, scan
+        // immediately
+        iProvider.CancelScan();
+        iProvider.Scan( KWlanBgScanMaxDelayExpireImmediately );
+        }
+    // else
+        // In case the new interval is bigger than the old one, it
+        // is taken into use after the pending scan request completes.
+    }
+
+    
+    
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanconversionutil.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanconversionutil.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 82 %
+* %version: 83 %
 */
 
 #include <in_sock.h>
@@ -2025,3 +2025,19 @@
             return 0;
         }
     }
+
+// ---------------------------------------------------------
+// TWlanConversionUtil::ConvertCipherKey()
+// ---------------------------------------------------------
+//
+void TWlanConversionUtil::ConvertCipherKey(
+    TPairwiseKeyData& aAmKey,
+    const core_cipher_key_s& aCoreKey )
+    {
+    aAmKey.keyIndex = aCoreKey.key_index;
+    aAmKey.length = aCoreKey.key_length;
+    Mem::Copy(
+        &aAmKey.data[0],
+        &aCoreKey.key_data[0],
+        MAX_CIPHER_KEY_LENGTH );
+    }
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanmgmtcommandhandler.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanmgmtcommandhandler.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 37 %
+* %version: 38 %
 */
 
 // INCLUDES
@@ -997,12 +997,15 @@
     const TUint8* aScanFrame,
     TBool aIsPairwiseKeyInvalidated,
     TBool aIsGroupKeyInvalidated,
-    TBool aIsRadioMeasurementSupported )
+    TBool aIsRadioMeasurementSupported,
+    const TPairwiseKeyData& aPairwiseKey )
     {
     DEBUG( "CWlanMgmtCommandHandler::Connect()" );
     
     DEBUG1( "CWlanMgmtCommandHandler::Connect() - aPairwiseKeyType = %u",
         aPairwiseKeyType );
+    DEBUG1( "CWlanMgmtCommandHandler::Connect() - aPairwiseKey.length = %u",
+        aPairwiseKey.length );
 
     TConnectMsg msg;
     msg.hdr.oid_id = E802_11_CONNECT;
@@ -1019,7 +1022,7 @@
     msg.invalidatePairwiseKey = aIsPairwiseKeyInvalidated;
     msg.invalidateGroupKey = aIsGroupKeyInvalidated;
     msg.radioMeasurement = aIsRadioMeasurementSupported;
-
+    msg.pairwiseKey = aPairwiseKey;
     TPckg<TConnectMsg> buf( msg );
 
     TInt err = iChannel.ManagementCommand( buf, NULL, &iStatus );
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanmgmtimpl.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanmgmtimpl.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 29 %
+* %version: 30 %
 */
 
 // INCLUDE FILES
@@ -790,6 +790,17 @@
     }
 
 // ---------------------------------------------------------
+// CWlanMgmtImpl::StartAggressiveBgScan
+// ---------------------------------------------------------
+//
+TInt CWlanMgmtImpl::StartAggressiveBgScan(
+    TUint aInterval )
+    {
+    TraceDump( INFO_LEVEL, ( _L( "CWlanMgmtImpl::StartAggressiveBgScan()" ) ) );
+    return iServer.StartAggressiveBgScan( aInterval );
+    }
+
+// ---------------------------------------------------------
 // CWlanMgmtImpl::ScanComplete
 // ---------------------------------------------------------
 //
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlansystemtimehandler.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlansystemtimehandler.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 3 %
+* %version: 4 %
 */
 
 // INCLUDE FILES
@@ -158,8 +158,9 @@
              * Inform client that system time has now been changed. 
              */
             iClient.OnSystemTimeChange();
+            // falls through on purpose
             }
-        case KErrNone: // flow through from KErrAbort on purpose
+        case KErrNone:
             {
             Cancel();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlantimer.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* This class implements timer services.
+*
+*/
+
+/*
+* %version: 1 %
+*/
+
+#include "wlantimer.h"
+#include "am_debug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// C++ constructor
+// ---------------------------------------------------------------------------
+//
+CWlanTimer::CWlanTimer( 
+    const TCallBack& aTimerExpiredCB,
+    const TCallBack& aTimerCancelledCB,
+    const TCallBack& aTimerErrorCB ) :
+    CTimer( CActive::EPriorityStandard ),
+    iTimerExpiredCB( aTimerExpiredCB ),
+    iTimerCancelledCB( aTimerCancelledCB ),
+    iTimerErrorCB( aTimerErrorCB )
+    {
+    // No implementation required
+    }
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CWlanTimer::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// Static constructor.
+//
+// @return  Pointer to CWlanTimer instance.
+// ---------------------------------------------------------------------------
+//
+CWlanTimer* CWlanTimer::NewL(  
+    const TCallBack& aTimerExpiredCB,
+    const TCallBack& aTimerCancelledCB,
+    const TCallBack& aTimerErrorCB )
+    {
+    CWlanTimer* self = new (ELeave) CWlanTimer(
+        aTimerExpiredCB,
+        aTimerCancelledCB,
+        aTimerErrorCB );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CWlanTimer::~CWlanTimer()
+    {
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// RunL.
+// Handles timer events.
+// ---------------------------------------------------------------------------
+//
+void CWlanTimer::RunL()
+    {
+    switch( iStatus.Int() )
+        {
+        case KErrNone: // Timer expired
+            iTimerExpiredCB.CallBack();
+            break;
+        case KErrCancel: // Timer cancelled
+            DEBUG( "CWlanTimer::RunL() - timer cancelled" );
+            iTimerCancelledCB.CallBack();
+            break;
+        default: // Timer error code
+            DEBUG1( "CWlanTimer::RunL() - timer error (status: %d)",
+                iStatus.Int() );
+            iTimerErrorCB.CallBack();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Cancel timer.
+// ---------------------------------------------------------------------------
+//
+void CWlanTimer::DoCancel()
+    {
+    CTimer::DoCancel();
+    }
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmdriverif.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmdriverif.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 51 %
+*/
 
 #include <wlanhwinit.h>
 #include "wlanlddcommon.h"
@@ -824,7 +827,8 @@
     const u8_t* scan_frame,
     bool_t is_pairwise_key_invalidated,
     bool_t is_group_key_invalidated,
-    bool_t is_radio_measurement_supported )
+    bool_t is_radio_measurement_supported,
+    const core_cipher_key_s* pairwise_key )
     {
 #ifdef _DEBUG
     if( is_infra == true_t )
@@ -850,6 +854,11 @@
     TWlanConversionUtil::ConvertSSID( tmpSsid, ssid );
     TMacAddress tmpBssid;
     TWlanConversionUtil::ConvertMacAddress( tmpBssid, bssid );
+    TPairwiseKeyData tmpKey = { 0, 0 };
+    if( pairwise_key )
+        {
+        TWlanConversionUtil::ConvertCipherKey( tmpKey, *pairwise_key );
+        }
 
     iManagementCommandHandler->Connect(
         tmpSsid,
@@ -864,8 +873,8 @@
         scan_frame,
         is_pairwise_key_invalidated,
         is_group_key_invalidated,
-        is_radio_measurement_supported );
-        
+        is_radio_measurement_supported,
+        tmpKey );
     }
 
 // -----------------------------------------------------------------------------
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmplatform.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmplatform.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,10 @@
 *
 */
 
+/*
+* %version: 12 %
+*/
+
 
 #include <e32std.h>
 #include "wlmplatform.h"
@@ -184,6 +188,15 @@
     }
 
 // ---------------------------------------------------------
+// CWlmPlatform::PublishBgScanInterval
+// ---------------------------------------------------------
+//
+EXPORT_C void CWlmPlatform::PublishBgScanInterval( TUint32& aInterval )
+    {
+    iPlatformData->PublishBgScanInterval( aInterval );
+    }
+
+// ---------------------------------------------------------
 // CWlmPlatform::SystemModeChanged
 // ---------------------------------------------------------
 //
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmplatformdata.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmplatformdata.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -15,6 +15,9 @@
 *
 */
 
+/*
+* %version: 12 %
+*/
 
 // INCLUDE FILES
 #include <e32base.h>
@@ -93,6 +96,16 @@
         }
     User::LeaveIfError( iPsIndicator.Attach( KPSUidWlan,
        KPSWlanIndicator, EOwnerThread ) );
+       
+    // Create PubSub property for publishing WLAN BG scan interval
+    ret = RProperty::Define( KPSWlanBgScanInterval, KPSWlanBgScanIntervalType,
+        KWlmPSReadPolicy, KWlmPSWritePolicy );
+    if( ret != KErrAlreadyExists )
+        {
+        User::LeaveIfError( ret );
+        }
+    User::LeaveIfError( iPsBgScanInterval.Attach( KPSUidWlan,
+        KPSWlanBgScanInterval, EOwnerThread ) );
     }
 
 // ---------------------------------------------------------
@@ -120,6 +133,8 @@
     RProperty::Delete( KPSUidWlan, KPSWlanIndicator );
     iPsMacAddress.Close();
     RProperty::Delete( KPSUidWlan, KPSWlanMacAddress );
+    iPsBgScanInterval.Close();
+    RProperty::Delete( KPSUidWlan, KPSWlanBgScanInterval );
     delete iPropertySystemState;
     delete iBtConnections;
     delete iEmergencyCall;    
@@ -380,3 +395,16 @@
     TPtrC8 mac( aMacAddr.iMacAddress, KPSWlanMacAddressLength );
     return iPsMacAddress.Set( mac );
     }
+
+// ---------------------------------------------------------
+// CWlmPlatformData::PublishBgScanInterval
+// Status : Draft
+// ---------------------------------------------------------
+//
+TInt CWlmPlatformData::PublishBgScanInterval( TUint32& aInterval )
+    {
+    DEBUG1( "CWlmPlatformData::PublishBgScanInterval( %u )",
+        aInterval );
+    
+    return iPsBgScanInterval.Set( aInterval );
+    }
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 96 %
+* %version: 97 %
 */
 
 #include <e32def.h>
@@ -89,6 +89,26 @@
     CWlmServer::EWlanFeaturePowerSaveTest |
     CWlmServer::EWlanFeature802dot11k;
 
+/** Multiplier for converting seconds into microseconds */
+const TUint KWlanSecsToMicrosecsMultiplier( 1000000 );
+
+/** Minimum value for aggressive background scan interval, in seconds */
+const TUint KWlanAggressiveBgScanMinInterval( 1 );
+
+/** Maximum value for aggressive background scan interval, in seconds */
+const TUint KWlanAggressiveBgScanMaxInterval( 120 );
+
+/** Multiplier for deciding aggressive scan mode duration from set interval */
+const TUint KWlanAggressiveBgScanDurationMultiplier( 6 );
+
+/** Interval (in seconds) used for aggressive background scanning after
+    unintentional link break. */
+const TUint32 KWlanLinkBreakRecoveryInterval( 10 );
+
+/** How long (in microseconds) aggressive background scanning is performed
+    after unintentional link break. */
+const TUint32 KWlanLinkBreakRecoveryDuration( 55000000 );  // 55 seconds
+
 // ============================ MEMBER FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
@@ -130,7 +150,8 @@
     iShowBrokenPowerSaveNote( ETrue ),
     iBrokenPowerSaveNotifierWaiter( NULL ),
     iBgScanProvider( NULL ),
-    iTimerServices( NULL )
+    iTimerServices( NULL ),
+    iAggressiveScanningAfterLinkLoss( EFalse )
     {
     }
 
@@ -323,7 +344,7 @@
 
         if ( err != KErrNone )
             {
-            DEBUG1( "CWlmServer::NewL leaved with code %d", err );
+            DEBUG1( "CWlmServer::StartServerThread() - NewL leaved with code %d", err );
             }
         }
     else
@@ -338,7 +359,7 @@
     // Start the active Scheduler (if there are no errors)
     if ( err == KErrNone )
         {
-        DEBUG( "CWlmServer Starting scheduler..." );
+        DEBUG( "CWlmServer::StartServerThread() - Starting scheduler..." );
         CActiveScheduler::Start();
         }
     
@@ -658,6 +679,8 @@
     {
     DEBUG( "CWlmServer::CancelConnect()" );
 
+    iAggressiveScanningAfterLinkLoss = EFalse;
+
     aMessage.Complete( KErrNone );
     }
 
@@ -1400,6 +1423,8 @@
     {
     DEBUG( "CWlmServer::ReleaseComplete()" );
 
+    iAggressiveScanningAfterLinkLoss = EFalse;
+
     // Data pipe should now be disconnected
     // -> safe to disconnect the management pipe.
 
@@ -1793,6 +1818,18 @@
                     // set icon to "not available"
                     SetIconState( EWlmIconStatusNotAvailable );
                     
+                    // if link was unintentionally lost, scan aggressively
+                    // for a while in order to try to find it again
+                    if( iAggressiveScanningAfterLinkLoss )
+                        {
+                        TUint32 interval( KWlanLinkBreakRecoveryInterval );
+                        TUint32 duration( KWlanLinkBreakRecoveryDuration );
+                        iBgScanProvider->StartAggressiveBgScan(
+                            interval,
+                            duration );
+                        iAggressiveScanningAfterLinkLoss = EFalse;
+                        }
+                    
                     // if background scan is on, this call will cause a background scan
 					// when the background scan is completed, the icon is updated
                     iBgScanProvider->NotConnected();
@@ -2045,7 +2082,6 @@
     	}
     }
 
-
 // ---------------------------------------------------------
 // CWlmServer::store_ap_country_info
 // ---------------------------------------------------------
@@ -2070,23 +2106,8 @@
             region = KWlmRegionETSI;
             }
         
-        TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, region ));
-        if ( ret == KErrNone )
-            {
-            TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) ));
-            if ( ret == KErrNone )
-                {
-                DEBUG1( "CWlmServer::regulatory_domain() - stored regulatory domain is 0x%02X ", iRegion );
-                }
-            else
-                {
-                DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region timestamp leaved with code %d,", ret );                    
-                }
-            }
-        else
-            {
-            DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region leaved with code %d,", ret );
-            }
+        StoreRegionAndTimestamp( region, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) );
+
    		}
   	// If the APs country information was inconsistent then region is selected to be ETSI
   	else
@@ -2097,14 +2118,38 @@
         DEBUG1( "CWlmServer::store_ap_country_info() - regulatory domain is 0x%02X", iRegion );
    		}
 
-
     // Set timers to notice if system time is changed
     iPlatform->InitializeSystemTimeHandler();
     
     iCoreAsynchCbId = request_id;
     iCoreAsynchCbStatus = core_error_ok;
     iCoreAsynchCb->CallBack();
-      
+    
+    }
+
+// ---------------------------------------------------------
+// CWlmServer::StoreRegionAndTimestamp
+// ---------------------------------------------------------
+//
+void CWlmServer::StoreRegionAndTimestamp( const TInt aRegion, const TInt aTimestamp )
+    {
+    TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, aRegion ) );
+    if ( ret == KErrNone )
+        {
+        TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, aTimestamp ) );
+        if ( ret == KErrNone )
+            {
+            DEBUG1( "CWlmServer::StoreRegionAndTimestamp() - stored regulatory domain is 0x%02X ", aRegion );
+            }
+        else
+            {
+            DEBUG1( "CWlmServer::StoreRegionAndTimestamp() - attempt to store region timestamp leaved with code %d,", ret );                    
+            }
+        }
+    else
+        {
+        DEBUG1( "CWlmServer::StoreRegionAndTimestamp() - attempt to store region leaved with code %d,", ret );
+        }
     }
 
 // ---------------------------------------------------------
@@ -2157,30 +2202,15 @@
                     break;
                     }
                 }
-            // Write the WLAN region and timestamp to CenRep
+
             TInt wlanRegion( KWlmRegionFCC );
             if ( iRegion == EETSI )
             	{
             	wlanRegion = KWlmRegionETSI;
             	}
             
-            TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, wlanRegion ));
-            if ( ret == KErrNone )
-                {
-                TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) ));
-                if ( ret == KErrNone )
-                    {
-                    DEBUG1( "CWlmServer::regulatory_domain() - stored regulatory domain is 0x%02X ", iRegion );
-                    }
-                else
-                    {
-                    DEBUG1( "CWlmServer::regulatory_domain() - attempt to store timestamp leaved with code %d,", ret );                    
-                    }
-                }
-            else
-                {
-                DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region leaved with code %d,", ret );
-                }
+            // Store the WLAN region and timestamp to CenRep
+            StoreRegionAndTimestamp( wlanRegion, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) );
             
             // Set timers to notice if system time is changed
             iPlatform->InitializeSystemTimeHandler();
@@ -2232,23 +2262,7 @@
                     wlanRegion = KWlmRegionETSI;
                     }
                 
-                TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, wlanRegion ));
-                if ( ret == KErrNone )
-                    {
-                    TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) ));
-                    if ( ret == KErrNone )
-                        {
-                        DEBUG1( "CWlmServer::regulatory_domain() - stored regulatory domain is 0x%02X ", iRegion );
-                        }
-                    else
-                        {
-                        DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region timestamp leaved with code %d,", ret );                    
-                        }
-                    }
-                else
-                    {
-                    DEBUG1( "CWlmServer::regulatory_domain() - attempt to store region leaved with code %d,", ret );
-                    }
+                StoreRegionAndTimestamp( wlanRegion, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) );
                 
                 // Set timers to notice if system time is changed
                 iPlatform->InitializeSystemTimeHandler();
@@ -2409,6 +2423,13 @@
                 TWlanConversionUtil::ConvertConnectStatus(
                     *connectionStatus,
                     coreIapData->security_mode ) );
+            if( *connectionStatus == core_connect_ok )
+                {
+                // If connection succeeded, raise flag indicating that
+                // aggressive background scanning has to be carried out
+                // in case the connection drops
+                iAggressiveScanningAfterLinkLoss = ETrue;
+                }
             }
         else if ( IsSessionActive( iRequestMap[triggerIndex] ) )
             {
@@ -3940,19 +3961,7 @@
             TTime timestampClear(1);
             iTimeofDomainQuery = timestampClear;
             
-            TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, KWlmRegionUnknown ));
-            if ( ret == KErrNone )
-                {
-                TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, iTimeofDomainQuery.Int64() ));
-                if ( ret != KErrNone )
-                    {
-                    DEBUG1( "CWlmServer::SystemTimeChanged() - attempt to store region timestamp leaved with code %d,", ret );                    
-                    }
-                }
-            else
-                {
-                DEBUG1( "CWlmServer::SystemTimeChanged() - attempt to store region leaved with code %d,", ret );
-                }
+            StoreRegionAndTimestamp( KWlmRegionUnknown, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep ) );
     	    }
     	
         DEBUG("CWlmServer::SystemTimeChanged() - inform timer services about system time change");
@@ -4006,16 +4015,8 @@
     TTime timestampClear(1);
     iTimeofDomainQuery = timestampClear;
     
-    TRAPD( ret, StoreWlanCenRepKeyValueL( KWlanRegion, KWlmRegionUnknown ));
-    if ( ret != KErrNone )
-        {
-   	    DEBUG1( "CWlmServer::ClearRegionCache() - StoreWlanCenRepKeyValueL() leaved with code %d,", ret );
-   	    }
-    TRAP( ret, StoreWlanCenRepKeyValueL( KWlanRegionTimestamp, iTimeofDomainQuery.Int64() ));
-    if ( ret != KErrNone )
-        {
-        DEBUG1( "CWlmServer::ClearRegionCache() - StoreWlanCenRepKeyValueL() leaved with code %d,", ret );
-        }
+    StoreRegionAndTimestamp( KWlmRegionUnknown, ( iTimeofDomainQuery.Int64() / KWlmTimestampInCenrep )  );
+
     }
 
 // ---------------------------------------------------------
@@ -4060,7 +4061,7 @@
         }
     else
         {
-        DEBUG1( "CWlmServer::Scan() - there is a pending background scan request, index (%d)", index);
+        DEBUG1( "CWlmServer::Scan() - there is a pending background scan request, index (%d)", index );
         
         ASSERT( iRequestMap[index].iTime );
         
@@ -4118,7 +4119,9 @@
     {
     DEBUG( "CWlmServer::CancelScan()" );
     
-    if( iConnectionState == EWlanStateNotConnected )
+    // if background scan is not enabled anymore, set icon
+    if( iConnectionState == EWlanStateNotConnected &&
+        !iBgScanProvider->IsBgScanEnabled() )
         {
         SetIconState( EWlmIconStatusNotAvailable );
         }
@@ -4176,6 +4179,48 @@
     }
 
 // ---------------------------------------------------------
+// CWlmServer::StartAggressiveBgScan
+// ---------------------------------------------------------
+//
+void CWlmServer::StartAggressiveBgScan(
+    TUint /* aSessionId */,
+    const RMessage2& aMessage )
+    {
+    DEBUG( "CWlmServer::StartAggressiveBgScan" );
+    
+    // Scan interval in seconds
+    TUint32 ScanInterval( aMessage.Int0() );
+    
+    aMessage.Complete( KErrNone );
+    
+    // Check that requested interval is in valid range
+    // and if it is not, adjust the value.
+    if( ScanInterval < KWlanAggressiveBgScanMinInterval )
+        {
+        DEBUG1( "CWlmServer::StartAggressiveBgScan - Requested value (%u) is below minimum limit",
+            ScanInterval );
+        ScanInterval = KWlanAggressiveBgScanMinInterval;
+        }
+    else if( ScanInterval > KWlanAggressiveBgScanMaxInterval )
+        {
+        DEBUG1( "CWlmServer::StartAggressiveBgScan - Requested value (%u) is above maximum limit",
+            ScanInterval );
+        ScanInterval = KWlanAggressiveBgScanMaxInterval;
+        }
+    
+    // Calculate from scan interval how long the aggressive
+    // mode will be kept active
+    TUint32 duration( KWlanAggressiveBgScanDurationMultiplier *
+                     ScanInterval *
+                     KWlanSecsToMicrosecsMultiplier );
+    
+    // Forward request to BG scan module
+    iBgScanProvider->StartAggressiveBgScan(
+        ScanInterval,
+        duration );
+    }
+
+// ---------------------------------------------------------
 // CWlmServer::GetPacketStatistics
 // ---------------------------------------------------------
 //
@@ -5175,3 +5220,15 @@
     
     return KErrNone;
     }
+    
+// ---------------------------------------------------------
+// CWlmServer::PublishBgScanInterval
+// ---------------------------------------------------------
+//
+void CWlmServer::PublishBgScanInterval( TUint32& aInterval )
+    {
+    DEBUG1( "CWlmServer::PublishWlanBgScanInterval( %u )", aInterval );
+    
+    iPlatform->PublishBgScanInterval( aInterval );
+    }
+    
--- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmsession.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmsession.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 23 %
+* %version: 24 %
 */
 
 // INCLUDE FILES
@@ -273,6 +273,10 @@
         // --------------------------------------------------------------------
         case ECancelDirectedRoam:
             iWlmServer.CancelDirectedRoam( iId, aMessage );
+            break;
+        // --------------------------------------------------------------------
+        case EStartAggressiveBgScan:
+            iWlmServer.StartAggressiveBgScan( iId, aMessage );
             break;        
         // --------------------------------------------------------------------
         default:
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacContextImpl.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacContextImpl.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 102 %
+* %version: 103 %
 */
 
 #ifndef WLANCONTEXTIMPL_H
@@ -630,6 +630,9 @@
     inline void NetworkOperationMode( 
         WHA::TOperationMode aOperationMode );
 
+    inline const TPairwiseKeyData* RoamingPairwiseKey() const;
+    inline void  RoamingPairwiseKey( const TPairwiseKeyData* aKeyData );
+    
     // setters and getters for key type
     inline void GroupKeyType( WHA::TKeyType aKeyType );
     inline WHA::TKeyType GroupKeyType() const;
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacContextImpl.inl	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacContextImpl.inl	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 75 %
+* %version: 76 %
 */
 
 #include "umacconnectcontext.h"
@@ -658,6 +658,25 @@
 // 
 // ---------------------------------------------------------------------------
 //
+inline const TPairwiseKeyData* WlanContextImpl::RoamingPairwiseKey() const
+    {
+    return iConnectContext.iRoamingPairwiseKey;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+inline void WlanContextImpl::RoamingPairwiseKey( 
+    const TPairwiseKeyData* aKeyData )
+    {
+    iConnectContext.iRoamingPairwiseKey = aKeyData;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
 inline void WlanContextImpl::GroupKeyType( 
     WHA::TKeyType aKeyType )
     {
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacDot11Synchronize.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/inc/UmacDot11Synchronize.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 18 %
+* %version: 19 %
 */
 
 #ifndef WLANDOT11SYNCHRONIZE_H
@@ -81,6 +81,7 @@
         EISSUEJOIN,                 // issue join command
         ESETHTBLOCKACKCONF,         // configure HT Block Ack configure mib
         ERESETHTBLOCKACKCONF,       // reset HT Block Ack configure mib
+        ESETPAIRWISEKEY,            // set pairwise key
         ECONTINUEDOT11TRAVERSE,     // continue dot11 fsm traversal
         ESTATEMAX                   // defined as an upper bound                       
         }; 
@@ -153,9 +154,37 @@
     * @param aCtxImpl statemachine context
     */
     void SetHtBlockAckConfiguration( WlanContextImpl& aCtxImpl );
+
+    /**
+     * Sets pairwise key according to the used cipher suite
+     *
+     * @param aCtxImpl global statemachine context
+     */
+    void SetPtk( WlanContextImpl& aCtxImpl );
+
+    /**
+     * Sets CCMP key
+     *
+     * @param aCtxImpl global statemachine context
+     */
+    TBool SetCcmpPtk( WlanContextImpl& aCtxImpl );
+
+    /**
+     * Sets TKIP key
+     *
+     * @param aCtxImpl global statemachine context
+     */
+    TBool SetTkipPtk( WlanContextImpl& aCtxImpl );
+
+    /**
+     * Sets WEP key
+     *
+     * @param aCtxImpl global statemachine context
+     */
+    TBool SetWepKey( WlanContextImpl& aCtxImpl );
     
 #ifndef NDEBUG 
-        virtual const TInt8* GetStateName( TUint8& aLength ) const;
+    virtual const TInt8* GetStateName( TUint8& aLength ) const;
 #endif // !NDEBUG 
 
     void Entry( WlanContextImpl& aCtxImpl );
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacconnectcontext.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacconnectcontext.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 21 %
+* %version: 22 %
 */
 
 #ifndef WLANCONNECTCONTEXT_H
@@ -96,6 +96,8 @@
     TBool                   iRadioMeasurement;
     /** adhoc or infrastructure mode */
     WHA::TOperationMode     iOperationMode;
+    /** roaming pairwise cipher key data context. Not own */
+    const TPairwiseKeyData* iRoamingPairwiseKey;
     /** items from Connect mgmt command; end */
     
     /** group key type inserted */
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacconnectcontext.inl	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacconnectcontext.inl	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 15 %
+* %version: 16 %
 */
 
 // -----------------------------------------------------------------------------
@@ -34,6 +34,7 @@
     iPairwiseCipher( EWlanCipherSuiteNone ),
     iRadioMeasurement( EFalse ),
     iOperationMode( WHA::EBSS ),
+    iRoamingPairwiseKey( NULL ),
     iGroupKeyType( WHA::EKeyNone ), 
     iPairWiseKeyType( WHA::EKeyNone ),
     iNwsaMinBasicRate( 0 ), 
@@ -114,4 +115,5 @@
     {
     iScanResponseFrameBody = NULL;
     iIeData = NULL;
+    iRoamingPairwiseKey = NULL;
     }
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacoidmsg.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/inc/umacoidmsg.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -17,7 +17,7 @@
 */
 
 /*
-* %version: 42 %
+* %version: 43 %
 */
 
 #ifndef WLAN_OID_MSG_H
@@ -347,6 +347,21 @@
 
 // -------------------------------------------------------------------------
 
+typedef struct _TPairwiseKeyData
+    {
+    /** 
+    * length of the data block. 
+    * If zero, the other fields in this struct are not relevant. 
+    */
+    TUint32 length;
+    /** data block that holds the cipher key */
+    TUint8 data[KMaxCipherKeyLength];
+    /** index of the key */
+    TUint8 keyIndex;
+    } TPairwiseKeyData;
+        
+// -------------------------------------------------------------------------
+
     
 /**
 * Common header for all messages.
@@ -410,7 +425,9 @@
     /**
      * ETrue if Radio Measurements are on
      */
-    TBool radioMeasurement;    
+    TBool radioMeasurement;
+    /** pairwise key data; if relevant */
+    TPairwiseKeyData pairwiseKey;
     } TConnectMsg;
 
 // -------------------------------------------------------------------------
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/src/Umac.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/src/Umac.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 54 %
+* %version: 55 %
 */
 
 #include "config.h"
@@ -519,6 +519,9 @@
     OsTracePrint( KWlmCmdDetails, (TUint8*)
         ("Umac::HandleConnect: radiomeasurement (bool): %d"), 
         msg->radioMeasurement );		
+    OsTracePrint( KWlmCmdDetails, (TUint8*)
+        ("Umac::HandleConnect: pairwise key length: %d"), 
+        msg->pairwiseKey.length );
 #endif // !NDEBUG 
 
     // make sure that these are clear when starting the connect operation
@@ -542,6 +545,15 @@
     //Set Radio Measurement setting for later use
     iPimpl->RadioMeasurement( msg->radioMeasurement );
     
+    if ( msg->pairwiseKey.length != 0 )
+        {
+        iPimpl->RoamingPairwiseKey( &(msg->pairwiseKey) );
+        }
+    else
+        {
+        iPimpl->RoamingPairwiseKey( NULL );
+        }
+    
     return iPimpl->CurrentState().Connect( 
         *iPimpl, 
         msg->SSID, 
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/src/UmacDot11Associated.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/src/UmacDot11Associated.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 95 %
+* %version: 96 %
 */
 
 #include "config.h"
@@ -918,7 +918,7 @@
         // inform Null Send Controller about data frame Rx
         aCtxImpl.OnDataRxCompleted( 
             ( KEtherType == KEapolType || KEtherType == KWaiType ) ?
-            // as EAPOL and WAI frames or not really Voice data (they
+            // as EAPOL and WAI frames are not really Voice data (they
             // are just sometimes sent with Voice priority), handle them 
             // here as Best Effort (Legacy)
             WHA::ELegacy : 
@@ -2077,7 +2077,7 @@
             // data frame Tx completion
             aCtxImpl.OnDataTxCompleted( 
                 aPacketId == E802Dot11FrameTypeDataEapol ?
-                // as EAPOL and WAI frames or not really Voice data (we just
+                // as EAPOL and WAI frames are not really Voice data (we just
                 // send them with Voice priority in WMM nw), handle them
                 // here as Best Effort (Legacy)
                 WHA::ELegacy : 
--- a/wlan_bearer/wlanldd/wlan_common/umac_common/src/UmacDot11Synchronize.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_common/umac_common/src/UmacDot11Synchronize.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 28 %
+* %version: 29 %
 */
 
 #include "config.h"
@@ -25,6 +25,7 @@
 #include "UmacWsaWriteMib.h"
 #include "UmacWsaJoin.h"
 #include "umacconfiguretxqueueparams.h"
+#include "UmacWsaAddKey.h"
 #include "wha_mibDefaultvalues.h"
 
 #ifndef NDEBUG
@@ -45,6 +46,7 @@
         {"EISSUEJOIN"}, 
         {"ESETHTBLOCKACKCONF"},
         {"ERESETHTBLOCKACKCONF"},
+        {"ESETPAIRWISEKEY"},
         {"ECONTINUEDOT11TRAVERSE"}
     };
 
@@ -157,6 +159,9 @@
         case ETXCOMPLETE:
             OnTxCompleteEvent( aCtxImpl );
             break;
+        case EABORT:
+            OnAbortEvent( aCtxImpl );
+            break;
         default:
             OsTracePrint( 
                 KErrorLevel, 
@@ -252,6 +257,9 @@
         case ERESETHTBLOCKACKCONF:
             ResetHtBlockAckConfiguration( aCtxImpl );            
             break;
+        case ESETPAIRWISEKEY:
+            SetPtk( aCtxImpl );
+            break;
         case ECONTINUEDOT11TRAVERSE:
             ContinueDot11StateTraversal( aCtxImpl );
             break;
@@ -341,14 +349,29 @@
                     }
                 else
                     {
-                    ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE );                    
+                    if ( aCtxImpl.RoamingPairwiseKey() )
+                        {
+                        ChangeInternalState( aCtxImpl, ESETPAIRWISEKEY );
+                        }
+                    else
+                        {
+                        ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE );
+                        }
                     }
                 }
             break;
         case ESETHTBLOCKACKCONF:
-            ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE );
+        case ERESETHTBLOCKACKCONF:
+            if ( aCtxImpl.RoamingPairwiseKey() )
+                {
+                ChangeInternalState( aCtxImpl, ESETPAIRWISEKEY );
+                }
+            else
+                {
+                ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE );
+                }
             break;
-        case ERESETHTBLOCKACKCONF:
+        case ESETPAIRWISEKEY:
             ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE );            
             break;
         default:
@@ -784,6 +807,149 @@
     os_free( mib );
     }
 
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void WlanDot11Synchronize::SetPtk( WlanContextImpl& aCtxImpl )
+    {
+    TBool ret( EFalse );
+
+    const TWlanCipherSuite pairwiseCipher( aCtxImpl.PairwiseCipher());
+
+    if ( pairwiseCipher == EWlanCipherSuiteCcmp )
+        {
+        ret = SetCcmpPtk( aCtxImpl );
+        }
+    else if ( pairwiseCipher == EWlanCipherSuiteTkip )
+        {
+        ret = SetTkipPtk( aCtxImpl );
+        }
+    else if ( pairwiseCipher == EWlanCipherSuiteWep )
+        {
+        ret = SetWepKey( aCtxImpl );
+        }
+    else
+        {
+        OsTracePrint( KErrorLevel, (TUint8*)
+            ("UMAC: unsupported cipher: %d"), pairwiseCipher );
+        OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
+        }
+
+    if ( !ret )
+        {
+        // Alloc failue. Send abort event to fsm. It takes care of the rest
+        Fsm( aCtxImpl, EABORT );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool WlanDot11Synchronize::SetCcmpPtk( WlanContextImpl& aCtxImpl )
+    {
+    OsTracePrint( KUmacDetails, (TUint8*)
+        ("UMAC: WlanDot11Synchronize::SetCcmpPtk"));
+
+    TBool ret( EFalse );
+
+    const TPairwiseKeyData& keyData( *(aCtxImpl.RoamingPairwiseKey()) );
+    WlanWsaAddKey& wsa_cmd( aCtxImpl.WsaAddKey() );
+    WHA::SAesPairwiseKey* key( CreateAesPtkCtx( 
+            aCtxImpl, 
+            wsa_cmd,
+            keyData.data, 
+            aCtxImpl.GetBssId() ) 
+            );
+
+    if ( key )
+        {
+        ret = ETrue;
+        // change global state: entry procedure triggers action
+        ChangeState( aCtxImpl, 
+            *this,  // prev state
+            wsa_cmd // next state
+            );
+        
+        os_free( key ); // release the memory
+        }
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+TBool WlanDot11Synchronize::SetTkipPtk( WlanContextImpl& aCtxImpl )
+    {
+    OsTracePrint( KUmacDetails, (TUint8*)
+        ("UMAC: WlanDot11Synchronize::SetTkipPtk"));
+
+    TBool ret( EFalse );
+
+    const TPairwiseKeyData& keyData( *(aCtxImpl.RoamingPairwiseKey()) );
+    WlanWsaAddKey& wsa_cmd( aCtxImpl.WsaAddKey() );    
+    WHA::STkipPairwiseKey* key( CreateTkipPtkCtx( 
+            aCtxImpl, 
+            wsa_cmd,
+            keyData.data, 
+            static_cast<T802Dot11WepKeyId>(keyData.keyIndex),
+            aCtxImpl.GetBssId() ) 
+            );
+
+    if ( key )
+        {
+        ret = ETrue;
+        // change global state: entry procedure triggers action
+        ChangeState( aCtxImpl, 
+            *this,  // prev state
+            wsa_cmd // next state
+            );   
+
+        os_free( key ); // release the memory
+        }
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+
+TBool WlanDot11Synchronize::SetWepKey( WlanContextImpl& aCtxImpl )
+    {
+    OsTracePrint( KUmacDetails, (TUint8*)
+        ("UMAC: WlanDot11Synchronize::SetWepPairwiseKey"));
+
+    TBool ret( EFalse );
+
+    const TPairwiseKeyData& keyData( *(aCtxImpl.RoamingPairwiseKey()) );
+    WlanWsaAddKey& wha_cmd( aCtxImpl.WsaAddKey() );    
+    WHA::SWepPairwiseKey* key( CreateUnicastWepKeyCtx( 
+            aCtxImpl, 
+            wha_cmd,
+            aCtxImpl.GetBssId(),
+            keyData.length,
+            keyData.data ) );
+
+    if ( key )
+        {
+        ret = ETrue;
+        // change global state: entry procedure triggers action
+        ChangeState( aCtxImpl, 
+            *this,  // prev state
+            wha_cmd // next state
+            );
+
+        os_free( key ); // release the memory
+        }
+
+    return ret;
+    }
+
 // -----------------------------------------------------------------------------
 // 
 // -----------------------------------------------------------------------------
--- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/DataFrameMemMngr.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/DataFrameMemMngr.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 11 %
+* %version: 12 %
 */
 
 #ifndef DATAFRAMEMMNGR_H
@@ -145,8 +145,10 @@
     /**
     * From DEthernetFrameMemMngr
     * Memory finalization method.
+    * 
+    * @param aThread The user mode client thread
     */
-    virtual void OnReleaseMemory();
+    virtual void OnReleaseMemory( DThread& aThread );
     
     // Prohibit copy constructor.
     DataFrameMemMngr( const DataFrameMemMngr& );
--- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/EthernetFrameMemMngr.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/EthernetFrameMemMngr.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 17 %
+* %version: 18 %
 */
 
 #ifndef DETHERNETFRAMEMEMMNGR_H
@@ -85,8 +85,9 @@
     * Deallocates the shared memory chunk, if relevant
     *
     * @since S60 3.1
+    * @param aThread The user mode client thread
     */
-    virtual void OnReleaseMemory();
+    virtual void OnReleaseMemory( DThread& aThread ) = 0;
 
     /**
     * Gets a memory block that can be used for tx frame write
@@ -281,6 +282,7 @@
         iRxBufAlignmentPadding( 0 ),
         iVendorTxHdrLen( 0 ),
         iVendorTxTrailerLen( 0 ),
+        iClientChunkHandle( -1 ),
         iInUse( EFalse )
         {};
 
@@ -446,6 +448,9 @@
     */
     TUint iVendorTxTrailerLen;
     
+    /** user mode client's handle to the shared memory chunk */
+    TInt iClientChunkHandle;
+    
 private:    // Data
     
     /** is memory in use or not */
--- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/MgmtFrameMemMngr.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/MgmtFrameMemMngr.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 14 %
+* %version: 15 %
 */
 
 #ifndef MGMTFRAMEMMNGR_H
@@ -164,8 +164,9 @@
     * Deallocates the shared memory chunk
     *
     * @since S60 3.1
+    * @param aThread The user mode client thread
     */
-    virtual void OnReleaseMemory();
+    virtual void OnReleaseMemory( DThread& aThread );
 
     // Prohibit copy constructor.
     MgmtFrameMemMngr( const MgmtFrameMemMngr& );
--- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/DataFrameMemMngr.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/DataFrameMemMngr.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 17 %
+* %version: 18 %
 */
 
 #include "WlLddWlanLddConfig.h"
@@ -60,6 +60,7 @@
             // store the handle & chunk size
             aSharedChunkInfo.iChunkHandle = r;
             aSharedChunkInfo.iSize = aSharedMemoryChunk->Size();
+            iClientChunkHandle = r;
 
             // store the kernel addresses
 
@@ -375,15 +376,16 @@
     
     TDataBuffer* metaHdr ( NULL );
 
-    if ( aLength > KMaxEthernetFrameLength )
+    if ( ( !IsMemInUse() ) || ( aLength > KMaxEthernetFrameLength ) )
         {
 #ifndef NDEBUG
         TraceDump( NWSA_TX_DETAILS, 
-            ("WLANLDD: DataFrameMemMngr::AllocTxBuffer: WARNING: max size exceeded; req. denied") );
+            ("WLANLDD: DataFrameMemMngr::AllocTxBuffer: WARNING: either "
+             "memory not in use OR max size exceeded. Req. denied") );
         os_assert( 
             (TUint8*)("WLANLDD: panic"), 
             (TUint8*)(WLAN_FILE), 
-            __LINE__ );                    
+            __LINE__ );
 #endif        
         
         return metaHdr;
@@ -439,7 +441,7 @@
 // 
 // ---------------------------------------------------------------------------
 //
-void DataFrameMemMngr::OnReleaseMemory()
+void DataFrameMemMngr::OnReleaseMemory( DThread& aThread )
     {
     TraceDump(INIT_LEVEL, ("WLANLDD: DataFrameMemMngr::OnReleaseMemory"));
 
@@ -452,6 +454,18 @@
         iTxFrameMemoryPool = NULL;
         iTxDataChunk = NULL;
         
-        MarkMemFree();            
+        MarkMemFree();
+        }
+    
+    if ( iClientChunkHandle >= 0 )
+        {
+        TraceDump(INIT_LEVEL, 
+            (("WLANLDD: DataFrameMemMngr::OnReleaseMemory: close shared chunk "
+             "handle: %d"), 
+            iClientChunkHandle));
+        
+        // We have a valid client handle to the shared chunk, so close it 
+        Kern::CloseHandle( &aThread, iClientChunkHandle );
+        iClientChunkHandle = -1;
         }
     }
--- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/EthernetFrameMemMngr.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/EthernetFrameMemMngr.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 23 %
+* %version: 24 %
 */
 
 #include "WlLddWlanLddConfig.h"
@@ -168,7 +168,7 @@
 //
 DEthernetFrameMemMngr::~DEthernetFrameMemMngr()
     {
-    OnReleaseMemory();
+    MarkMemFree();
     
     iFrameXferBlock = NULL;
     iTxDataBuffer = NULL;
@@ -179,15 +179,6 @@
 // 
 // ---------------------------------------------------------------------------
 //
-void DEthernetFrameMemMngr::OnReleaseMemory()
-    {
-    MarkMemFree();      // mark as free
-    }
-
-// ---------------------------------------------------------------------------
-// 
-// ---------------------------------------------------------------------------
-//
 TDataBuffer* DEthernetFrameMemMngr::OnWriteEthernetFrame() const
     {
     if ( iTxDataBuffer->GetLength() >= sizeof( SEthernetHeader ) )
@@ -420,11 +411,18 @@
     TDataBuffer*& aPacketInKernSpace,
     TBool aUserDataTxEnabled )
     {
-    return (static_cast<RFrameXferBlockProtocolStack*>(
-        iFrameXferBlock))->AddTxFrame( 
-            aPacketInUserSpace, 
-            aPacketInKernSpace,
-            aUserDataTxEnabled );
+    if ( IsMemInUse() )
+        {
+        return (static_cast<RFrameXferBlockProtocolStack*>(
+            iFrameXferBlock))->AddTxFrame( 
+                aPacketInUserSpace, 
+                aPacketInKernSpace,
+                aUserDataTxEnabled );
+        }
+    else
+        {
+        return EFalse;
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -435,13 +433,15 @@
     const TWhaTxQueueState& aTxQueueState,
     TBool& aMore )
     {
-    if ( IsMemInUse() )
+    if ( IsMemInUse() && iFrameXferBlock )
         {
         return (static_cast<RFrameXferBlockProtocolStack*>(
             iFrameXferBlock))->GetTxFrame( aTxQueueState, aMore );
         }
     else
+        {
         return NULL;
+        }
     }
 
 // ---------------------------------------------------------------------------
--- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/MgmtFrameMemMngr.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/MgmtFrameMemMngr.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 19 %
+* %version: 20 %
 */
 
 #include "WlLddWlanLddConfig.h"
@@ -91,7 +91,11 @@
     TUint32 physicalAddressNotNeeded ( 0 );
 
     // Map our device's memory into the chunk (at offset 0)
-    r = Kern::ChunkCommitContiguous( chunk, 0, iChunkSize, physicalAddressNotNeeded );
+    r = Kern::ChunkCommitContiguous( 
+            chunk, 
+            0, 
+            iChunkSize, 
+            physicalAddressNotNeeded );
 
     if ( r != KErrNone)
         {
@@ -163,6 +167,7 @@
             // store the handle & the chunk size
             aSharedChunkInfo.iChunkHandle = r;
             aSharedChunkInfo.iSize = iChunkSize;
+            iClientChunkHandle = r;
 
             // store the kernel addresses
 
@@ -595,28 +600,39 @@
 // 
 // ---------------------------------------------------------------------------
 //
-void MgmtFrameMemMngr::OnReleaseMemory()
+void MgmtFrameMemMngr::OnReleaseMemory( DThread& aThread )
     {
     TraceDump(INIT_LEVEL, ("WLANLDD: MgmtFrameMemMngr::OnReleaseMemory"));
 
-    TraceDump(MEMORY, (("WLANLDD: delete WlanChunk: 0x%08x"), 
-        reinterpret_cast<TUint32>(iRxFrameMemoryPool)));        
-
-    delete iRxFrameMemoryPool;
-    iRxFrameMemoryPool = NULL;
+    if ( iRxFrameMemoryPool )
+        {
+        TraceDump(MEMORY, (("WLANLDD: delete WlanChunk: 0x%08x"), 
+            reinterpret_cast<TUint32>(iRxFrameMemoryPool)));        
+    
+        delete iRxFrameMemoryPool;
+        iRxFrameMemoryPool = NULL;
+        }
 
     if ( iParent.SharedMemoryChunk() )
         {
         TraceDump(MEMORY, (("WLANLDD: delete DChunk: 0x%08x"), 
             reinterpret_cast<TUint32>(iParent.SharedMemoryChunk())));        
 
+        if ( iClientChunkHandle >= 0 )
+            {
+            TraceDump(INIT_LEVEL, 
+                (("WLANLDD: MgmtFrameMemMngr::OnReleaseMemory: close shared "
+                 "chunk handle: %d"), 
+                iClientChunkHandle));
+            
+            // We have a valid client handle to the shared chunk, so close it 
+            Kern::CloseHandle( &aThread, iClientChunkHandle );
+            iClientChunkHandle = -1;
+            }
+        
         // schedule the shared memory chunk for destruction
         Kern::ChunkClose( iParent.SharedMemoryChunk() );
         iParent.SharedMemoryChunk() = NULL;
-        MarkMemFree();      // mark as free            
+        MarkMemFree();
         }    
-    else
-        {
-        // nothing here
-        }
     }
--- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 56 %
+* %version: 57 %
 */
 
 #include "WlLddWlanLddConfig.h"
@@ -196,6 +196,12 @@
     if ( iEthernetFrameMemMngr )
         {
         TraceDump(INIT_LEVEL, ("WLANLDD: deallocate ethernet frame memory pool"));
+        
+        // normally the user side client will do this, but just to be on 
+        // the safe side, make sure it really is done before proceeding with
+        // frame memory mgr destruction
+        OnReleaseEthernetFrameBuffers();
+        
         TraceDump(MEMORY, (("WLANLDD: delete DEthernetFrameMemMngr: 0x%08x"), 
         reinterpret_cast<TUint32>(iEthernetFrameMemMngr)));        
     
@@ -844,7 +850,8 @@
 //
 void DWlanLogicalChannel::UserDataReEnabled()
     {
-    if ( !( iFlags & KTxTriggerArmed ) )
+    if ( ProtocolStackSideClientReady() &&
+         !( iFlags & KTxTriggerArmed ) )
         {
         iFlags |= KTxTriggerArmed;
         iTxTriggerDfc.Enque();
@@ -935,7 +942,8 @@
     // someone else than the Protocol Stack Side Client unblocks the WHA Tx
     // pipeline and
     // b) to avoid the Tx pipe from getting stuck even temporarily
-    if ( !( iFlags & KTxTriggerArmed ) )
+    if ( ProtocolStackSideClientReady() &&
+         !( iFlags & KTxTriggerArmed ) )
         {
         iFlags |= KTxTriggerArmed;
         iTxTriggerDfc.Enque(); // we do this via a DFC
@@ -957,7 +965,8 @@
     // makes a WHA Txqueue - for which there are packets pending in our Tx 
     // queues - non-full
     // b) to avoid the Tx pipe from getting stuck even temporarily
-    if ( !( iFlags & KTxTriggerArmed ) )
+    if ( ProtocolStackSideClientReady() &&
+         !( iFlags & KTxTriggerArmed ) )
         {
         iFlags |= KTxTriggerArmed;
         iTxTriggerDfc.Enque(); // we do this via a DFC
@@ -1001,7 +1010,7 @@
         TBool morePackets ( EFalse );
         iTxActive = ETrue;
         
-        while ( iUmac.TxPermitted( txQueueState ) )
+        while ( iUmac.TxPermitted( txQueueState ) && iEthernetFrameMemMngr )
             {
             TDataBuffer* metaHeader = 
                 iEthernetFrameMemMngr->GetTxFrame( txQueueState, morePackets );
@@ -1603,7 +1612,7 @@
     {
     if ( iEthernetFrameMemMngr )
         {
-        iEthernetFrameMemMngr->OnReleaseMemory();    
+        iEthernetFrameMemMngr->OnReleaseMemory( *iClient );    
         }
     }
 
--- a/wlan_bearer/wlannwif/inc/CLanxBearer.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlannwif/inc/CLanxBearer.h	Sat Feb 20 00:38:18 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 7 %
+* %version: 8 %
 */
 
 #ifndef CLANXBEARER_H
@@ -31,6 +31,8 @@
 #include <es_mbuf.h>
 #include <comms-infras/ss_protflow.h>
 #include <comms-infras/ss_flowbinders.h>
+#include <es_prot.h>
+
 
 class CLANLinkCommon;
 class TLanProvision;
--- a/wlan_bearer/wlannwif/src/CLanIp4Bearer.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlannwif/src/CLanIp4Bearer.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 12 %
+* %version: 13 %
 */
 
 #include <in_sock.h> // Header is retained, but in_sock.h is modified for ipv6
@@ -24,6 +24,7 @@
 #include <in6_if.h>
 #include <nifvar.h>
 #include <comms-infras/connectionsettings.h>
+#include <nifmbuf.h>
 #include "CLanIp4Bearer.h"
 #include "arp_hdr.h"
 #include <commdb.h>
--- a/wlan_bearer/wlannwif/src/CLanIp6Bearer.cpp	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlannwif/src/CLanIp6Bearer.cpp	Sat Feb 20 00:38:18 2010 +0200
@@ -16,13 +16,14 @@
 */
 
 /*
-* %version: 11 %
+* %version: 12 %
 */
 
 #include <in_sock.h> // Header is retained, but in_sock.h is modified for ipv6
 #include <in6_if.h>
 #include <in_pkt.h>
 #include <comms-infras/connectionsettings.h>
+#include <nifmbuf.h>
 #include "CLanIp6Bearer.h"
 #include "WlanProto.h"
 #include <comms-infras/es_protbinder.h>
--- a/wlan_bearer/wlanpsmplugin/rom/wlanpsmplugin.iby	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_bearer/wlanpsmplugin/rom/wlanpsmplugin.iby	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -16,17 +16,20 @@
 */
 
 /*
-* %version: 4 %
+* %version: 5 %
 */
 
 #ifndef WLANPSMPLUGIN_IBY
 #define WLANPSMPLUGIN_IBY
 
+#ifdef __PROTOCOL_WLAN
+
 data=ZPRIVATE\2000b187\200100c0.xml         			private\2000b187\200100c0.xml
 data=ZPRIVATE\2000b187\cenrep\101f8e44.xml     			private\2000b187\cenrep\101f8e44.xml
 
 ECOM_PLUGIN(wlanpsmplugin.dll, wlanpsmplugin.rsc)
 
+#endif // __PROTOCOL_WLAN
 #endif // WLANPSMPLUGIN_IBY
 
 // End of File
--- a/wlan_plat/wlan_aws_plugin_api/inc/awsenginebase.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_plat/wlan_aws_plugin_api/inc/awsenginebase.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 5 %
+* %version: 6 %
 */
 
 
@@ -75,7 +75,7 @@
      * List implementations for AWS Plugin interface.
      * @param aImplInfoArray Array of implementation informations.
      */
-    inline static void CAwsEngineBase::ListImplementationsL(
+    inline static void ListImplementationsL(
             RImplInfoPtrArray& aImplInfoArray);
 
 private: // data
--- a/wlan_plat/wlan_info_api/inc/wlaninternalpskeys.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_plat/wlan_info_api/inc/wlaninternalpskeys.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -18,7 +18,7 @@
 */
 
 /*
-* %version: 5 %
+* %version: 6 %
 */
 
 #ifndef WLANINTERNALPSKEYS_H
@@ -61,6 +61,12 @@
     EPSWlanIndicatorActiveSecure
     };
 
+/**
+* WLAN background scan interval (in seconds)
+*/
+const TUint KPSWlanBgScanInterval = 0x00000003;
+const RProperty::TType KPSWlanBgScanIntervalType = RProperty::EInt;
+
 #endif // WLANINTERNALPSKEYS_H
            
 //  End of File
--- a/wlan_plat/wlan_management_api/inc/wlanmgmtinterface.h	Tue Feb 02 02:03:13 2010 +0200
+++ b/wlan_plat/wlan_management_api/inc/wlanmgmtinterface.h	Sat Feb 20 00:38:18 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 15 %
+* %version: 16 %
 */
 
 #ifndef WLANMGMTINTERFACE_H
@@ -403,6 +403,13 @@
          */
         virtual void CancelDirectedRoam() = 0;
 
+        /**
+         * Start aggressive background scanning.
+         *
+         * @param aInterval Scan interval (in seconds) for aggressive mode.
+         */
+        virtual TInt StartAggressiveBgScan(
+            TUint aInterval ) = 0;
     };
 
 #endif // WLANMGMTINTERFACE_H