wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_operation_unload_drivers.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Statemachine for unloading drivers
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 11 %
       
    20 */
       
    21 
       
    22 #include "core_operation_unload_drivers.h"
       
    23 #include "core_operation_release.h"
       
    24 #include "core_server.h"
       
    25 #include "am_debug.h"
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 core_operation_unload_drivers_c::core_operation_unload_drivers_c(
       
    33     u32_t request_id,
       
    34     core_server_c* server,
       
    35     abs_core_driverif_c* drivers,
       
    36     abs_core_server_callback_c* adaptation ) :
       
    37     core_operation_base_c( core_operation_unload_drivers, request_id, server, drivers, adaptation,
       
    38         core_base_flag_only_one_instance )   
       
    39     {
       
    40     DEBUG( "core_operation_unload_drivers_c::core_operation_unload_drivers_c()" );
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 core_operation_unload_drivers_c::~core_operation_unload_drivers_c()
       
    47     {
       
    48     DEBUG( "core_operation_unload_drivers_c::~core_operation_unload_drivers_c()" );
       
    49     }
       
    50     
       
    51 // ---------------------------------------------------------------------------
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 core_error_e core_operation_unload_drivers_c::next_state()
       
    55     {
       
    56     DEBUG( "core_operation_unload_drivers_c::next_state()" );
       
    57     switch( operation_state_m )
       
    58         {
       
    59         case core_state_init:
       
    60             {
       
    61             DEBUG( "- core_state_init" );
       
    62             if( server_m->get_core_settings().is_connected() )
       
    63                 {
       
    64                 DEBUG( "core_operation_unload_drivers_c::next_state() - still connected, notifying state change" );
       
    65                 // connection is open, first send state change notification
       
    66                 u8_t buf[5];
       
    67                 buf[0] = static_cast<u8_t>( core_connection_state_notconnected );
       
    68                 buf[1] = static_cast<u8_t>( core_release_reason_hw_failure );
       
    69                 adaptation_m->notify( 
       
    70                     core_notification_connection_state_changed,
       
    71                     sizeof( buf ),
       
    72                     buf );
       
    73 
       
    74                 server_m->get_connection_data()->set_last_connection_state(
       
    75                     core_connection_state_notconnected );
       
    76 
       
    77                 // Delay unloading a little bit so that data pipe can be
       
    78                 // disconnected from adaptation side
       
    79                 return asynch_goto( core_state_notifying, DELAY_FOR_AGENT );
       
    80                 }
       
    81             else
       
    82                 {               
       
    83                 // not connected, jump directly to unloading drivers
       
    84                 return goto_state( core_state_releasing );
       
    85                 }
       
    86             }
       
    87         case core_state_notifying:
       
    88             {
       
    89             DEBUG( "core_operation_connect_c::next_state() - notification sent, releasing" );
       
    90             core_operation_base_c* operation = new core_operation_release_c(
       
    91                 request_id_m,
       
    92                 server_m,
       
    93                 drivers_m,
       
    94                 adaptation_m,
       
    95                 core_release_reason_hw_failure );
       
    96             operation_state_m = core_state_releasing;
       
    97             return run_sub_operation( operation );
       
    98             }
       
    99         case core_state_releasing:
       
   100             {
       
   101             DEBUG( "core_operation_unload_drivers_c::next_state() - unloading drivers" );
       
   102             drivers_m->unload_drivers( request_id_m );
       
   103             operation_state_m = core_state_unloading;
       
   104             break;
       
   105             }
       
   106         case core_state_unloading:
       
   107             {
       
   108             DEBUG( "core_operation_unload_drivers_c::next_state() - unloading done" );
       
   109             server_m->get_core_settings().set_driver_state( false_t );
       
   110             return core_error_ok;    
       
   111             } 
       
   112         default:
       
   113             {
       
   114             ASSERT( false_t );
       
   115             }
       
   116         }
       
   117     return core_error_request_pending;
       
   118     }