accessoryservices/accessoryserver/src/Server/AccSrvConnectionController.cpp
changeset 29 e5a0aab53f3f
parent 22 effbe8362efc
child 48 86cf7a1b7eb9
equal deleted inserted replaced
22:effbe8362efc 29:e5a0aab53f3f
    28 #include "acc_debug.h"
    28 #include "acc_debug.h"
    29 #include "AccSrvASYProxyHandler.h"
    29 #include "AccSrvASYProxyHandler.h"
    30 #include "AccPolGenericIDAccessor.h"
    30 #include "AccPolGenericIDAccessor.h"
    31 #include "AccSrvSettingsHandler.h"
    31 #include "AccSrvSettingsHandler.h"
    32 #include "AccPolSubblockNameArrayAccessor.h"
    32 #include "AccPolSubblockNameArrayAccessor.h"
    33 #include "AccSrvChargingContextController.h"
       
    34 #include <AccConfigFileParser.h>
    33 #include <AccConfigFileParser.h>
    35 #include <s32mem.h>
    34 #include <s32mem.h>
    36 #include "AccSrvWiredConnectionPublisher.h"
    35 #include "AccSrvWiredConnectionPublisher.h"
    37 
    36 
    38 // EXTERNAL DATA STRUCTURES
    37 // EXTERNAL DATA STRUCTURES
    99     iConnectionStatusHandler = CAccSrvConnectionStatusHandler::NewL( this );
    98     iConnectionStatusHandler = CAccSrvConnectionStatusHandler::NewL( this );
   100     iModeHandler             = CAccSrvModeHandler::NewL( this );
    99     iModeHandler             = CAccSrvModeHandler::NewL( this );
   101     iASYProxyHandler         = CAccSrvASYProxyHandler::NewL( this );
   100     iASYProxyHandler         = CAccSrvASYProxyHandler::NewL( this );
   102     iSettingsHandler         = CAccSrvSettingsHandler::NewL( this, *aServerModel, iPolicy );
   101     iSettingsHandler         = CAccSrvSettingsHandler::NewL( this, *aServerModel, iPolicy );
   103     iWiredConnPublisher      = CAccSrvWiredConnectionPublisher::NewL();
   102     iWiredConnPublisher      = CAccSrvWiredConnectionPublisher::NewL();
   104     TRAPD( err, iChargingContextController = CAccSrvChargingContextController::NewL() );
       
   105     if ( err != KErrNone ) // Server does not need to die on charging context fail.
       
   106         {
       
   107         COM_TRACE_1( "[AccFW:AccServer] CAccSrvConnectionController::ConstructL - CAccSrvChargingContextController err %d", err );
       
   108         iChargingContextController = NULL;
       
   109         }
       
   110 
   103 
   111     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionController::ConstructL - return void" );
   104     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionController::ConstructL - return void" );
   112     }
   105     }
   113 
   106 
   114 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   165     if( NULL != iSettingsHandler )
   158     if( NULL != iSettingsHandler )
   166         {
   159         {
   167         delete iSettingsHandler;
   160         delete iSettingsHandler;
   168         }
   161         }
   169     
   162     
   170     if( NULL != iChargingContextController )
       
   171         {
       
   172         delete iChargingContextController;
       
   173         }
       
   174 
       
   175     delete iWiredConnPublisher;
   163     delete iWiredConnPublisher;
   176 
   164 
   177     // Handlers must be deleted after iPolicy and iASYProxyHandler
   165     // Handlers must be deleted after iPolicy and iASYProxyHandler
   178     // (used from handlers).
   166     // (used from handlers).
   179     iConnectionHandler.ResetAndDestroy();
   167     iConnectionHandler.ResetAndDestroy();
   848 
   836 
   849     TAccPolGenericIDArray genericIDArray;
   837     TAccPolGenericIDArray genericIDArray;
   850     TAccPolAccessoryMode accMode;
   838     TAccPolAccessoryMode accMode;
   851 
   839 
   852     iServerModel->CurrentConnectionStatusL( genericIDArray );
   840     iServerModel->CurrentConnectionStatusL( genericIDArray );
   853 
   841     
   854     if( (EFalse == aAudioOutputStatus) && (KErrUnknown != aDbId) ) 
   842     TUint count;
   855         { 
   843     TBool isHDMIConnected = EFalse;
   856         TInt index( TAccPolGenericIDArrayAccessor::FindWithUniqueIDL( 
   844     
   857                 genericIDArray, aDbId) ); 
   845     count = genericIDArray.Count();
   858 				if(KErrNotFound != index)
   846     if((1 < count) && (EFalse == aAudioOutputStatus) && (KErrUnknown != aDbId))
   859 					{
   847         {
   860         	TAccPolGenericIDArrayAccessor::RemoveIndexFromGenericIDArray(genericIDArray, index); 
   848         for(TInt i( 0 ); i < count; ++i)
   861         	}
   849             {
   862         }
   850             if(genericIDArray.GetGenericIDL(i).PhysicalConnectionCaps() & KPCHDMI)
   863 
   851                 {
   864     accMode = iPolicy->ResolveAccessoryModeL( genericIDArray, 
   852                 isHDMIConnected = ETrue;
   865                                               aDbId, 
   853                 break;
   866                                               aAudioOutputStatus, 
   854                 }        
   867                                               iServerModel->AccessoryMode(), 
   855             }
   868                                               iServerModel->UniqueID() );
   856         }
       
   857     
       
   858     if(isHDMIConnected)
       
   859         {
       
   860         accMode = iServerModel->AccessoryMode();
       
   861         }    
       
   862     else
       
   863         {
       
   864         accMode = iPolicy->ResolveAccessoryModeL( genericIDArray, 
       
   865                                                   aDbId, 
       
   866                                                   aAudioOutputStatus, 
       
   867                                                   iServerModel->AccessoryMode(), 
       
   868                                                   iServerModel->UniqueID() );
       
   869         }
       
   870 
       
   871     
   869 
   872 
   870     if( iServerModel->SetAccessoryMode( accMode, aDbId ) ) //Store accessory mode
   873     if( iServerModel->SetAccessoryMode( accMode, aDbId ) ) //Store accessory mode
   871         {
   874         {
   872         if( iModeHandler->IsActive() || iConnectionStatusHandler->IsActive() )
   875         if( iModeHandler->IsActive() || iConnectionStatusHandler->IsActive() )
   873             {
   876             {