bluetoothengine/bteng/src/btengsrvstate.cpp
branchRCL_3
changeset 10 0707dd69d236
parent 0 f63038272f30
child 19 43824b19ee35
equal deleted inserted replaced
6:6a29d5ad0713 10:0707dd69d236
    20 #include <ecom/ecomresolverparams.h>
    20 #include <ecom/ecomresolverparams.h>
    21 
    21 
    22 #include "btengsrvstate.h"
    22 #include "btengsrvstate.h"
    23 #include "btengserver.h"
    23 #include "btengserver.h"
    24 #include "btengsrvpluginmgr.h"
    24 #include "btengsrvpluginmgr.h"
       
    25 #include "btengsrvsettingsmgr.h"
    25 #include "debug.h"
    26 #include "debug.h"
    26 
    27 
    27 
    28 
    28 // ======== MEMBER FUNCTIONS ========
    29 // ======== MEMBER FUNCTIONS ========
    29 
    30 
    91 
    92 
    92 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
    93 // ?implementation_description
    94 // ?implementation_description
    94 // ---------------------------------------------------------------------------
    95 // ---------------------------------------------------------------------------
    95 //
    96 //
    96 void CBTEngSrvState::StartStateMachineL( TBool aState )
    97 void CBTEngSrvState::StartStateMachineL( TBTPowerState aState )
    97     {
    98     {
    98     TRACE_FUNC_ENTRY
    99     TRACE_FUNC_ENTRY
    99     if( aState )
   100     if( aState == EBTOn )
   100         {
   101         {
   101         // Power on; starting state is initializing the stack
   102         // Power on; starting state is initializing the stack
   102         iState = EInitBTStack;
   103         iState = EInitBTStack;
   103         iOperation = EPowerOn;
   104         iOperation = EPowerOn;
   104         }
   105         }
   105     else
   106     else
   106         {
   107         {
   107         // Power off, starting state is to disconnect the plug-ins
   108         // Power off, starting state is to disconnect the plug-ins
   108         iState = EDisconnectPlugins;
   109         iState = EDisconnectPlugins;
   109         iOperation = EPowerOff;
   110         iOperation = EPowerOff;
   110         iServer->UpdateCenRepPowerKeyL( EBTPowerOff );
   111         iServer->SettingsManager()->UpdateCenRepPowerKeyL( EBTOff );
   111         iServer->SetUiIndicatorsL();
   112         iServer->SettingsManager()->SetUiIndicatorsL();
   112         }
   113         }
   113     ChangeState();
   114     ChangeState();
   114     }
   115     }
   115 
   116 
   116 
   117 
   119 // ---------------------------------------------------------------------------
   120 // ---------------------------------------------------------------------------
   120 //
   121 //
   121 void CBTEngSrvState::ChangeState()
   122 void CBTEngSrvState::ChangeState()
   122     {
   123     {
   123     TRACE_FUNC_ENTRY
   124     TRACE_FUNC_ENTRY
   124     if(!iAsyncCallback->IsActive())
   125     iAsyncCallback->CallBack();
   125         {
       
   126         iAsyncCallback->CallBack();
       
   127         }
       
   128     }
   126     }
   129 
   127 
   130 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   131 // ?implementation_description
   129 // ?implementation_description
   132 // ---------------------------------------------------------------------------
   130 // ---------------------------------------------------------------------------
   151     switch( iState )
   149     switch( iState )
   152         {
   150         {
   153         case EInitBTStack:
   151         case EInitBTStack:
   154             {
   152             {
   155             iState = ELoadDIService;
   153             iState = ELoadDIService;
   156             iServer->InitBTStackL();
   154             iServer->SettingsManager()->InitBTStackL();
   157             }
   155             }
   158             break;
   156             break;
   159         case ELoadDIService:
   157         case ELoadDIService:
   160             {
   158             {
   161             iState = ELoadPlugins;
   159             iState = ELoadPlugins;
   164             break;
   162             break;
   165         case ELoadPlugins:
   163         case ELoadPlugins:
   166             {
   164             {
   167             iState = ELoadNextPlugin;
   165             iState = ELoadNextPlugin;
   168             TEComResolverParams params;
   166             TEComResolverParams params;
   169             iServer->iPluginMgr->LoadProfilePluginsL( params );
   167             iServer->PluginManager()->LoadProfilePluginsL( params );
   170             }
   168             }
   171             break;
   169             break;
   172         case ELoadNextPlugin:
   170         case ELoadNextPlugin:
   173             {
   171             {
   174                 // Only change the state when all plug-ins are loaded
   172                 // Only change the state when all plug-ins are loaded
   175             if( iServer->iPluginMgr->LoadPluginL() <= 0 )
   173             if( iServer->PluginManager()->LoadPluginL() <= 0 )
   176                 {
   174                 {
   177                 iState = EIdle;
   175                 iState = EIdle;
   178                 }
   176                 }
   179             }
   177             }
   180             break;
   178             break;
   181         case EStopBTStack:
   179         case EStopBTStack:
   182             {
   180             {
   183             iState = EWaitingForPowerOff;
   181             iState = EWaitingForPowerOff;
   184             iServer->StopBTStackL();
   182             iServer->SettingsManager()->StopBTStackL();
   185             }
   183             }
   186             break;
   184             break;
   187         case EUnloadDIService:
   185         case EUnloadDIService:
   188             {
   186             {
   189             iState = EStopBTStack;
   187             iState = EStopBTStack;
   191             }
   189             }
   192             break;
   190             break;
   193         case EUnloadPlugins:
   191         case EUnloadPlugins:
   194             {
   192             {
   195             iState = EUnloadDIService;
   193             iState = EUnloadDIService;
   196             iServer->iPluginMgr->UnloadProfilePlugins();
   194             iServer->PluginManager()->UnloadProfilePlugins();
   197             }
   195             }
   198             break;
   196             break;
   199         case EDisconnectPlugins:
   197         case EDisconnectPlugins:
   200             {
   198             {
   201             iState = EUnloadPlugins;
   199             iState = EUnloadPlugins;
   212             }   // Fall through
   210             }   // Fall through
   213         case EIdle:
   211         case EIdle:
   214             {
   212             {
   215             if( iOperation == EPowerOn )
   213             if( iOperation == EPowerOn )
   216                 {
   214                 {
   217                 iServer->UpdateCenRepPowerKeyL( EBTPowerOn );
   215                 iServer->SettingsManager()->UpdateCenRepPowerKeyL( EBTOn );
   218                 iServer->SetUiIndicatorsL();
   216                 iServer->SettingsManager()->SetUiIndicatorsL();
   219                 }
   217                 }
   220             iOperation = ESrvOpIdle;
   218             iOperation = ESrvOpIdle;
   221             iServer->CheckIdle();
   219             iServer->CheckIdle();
   222             }
   220             }
   223         case EInit:
   221         case EInit: