accessoryservices/pluggeddisplay/pluggeddisplayasy/src/pdasycmdhandler.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2  * Copyright (c) 2009 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 "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:
       
    15  * CPDAsyCmdHandler class implementation.
       
    16  *
       
    17  */
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 
       
    21 // USER INCLUDES
       
    22 #include "pdasycmdhandler.h"
       
    23 #include "pdengine.h"
       
    24 #include "pdasymainservice.h"
       
    25 #include "trace.h"
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // C++ constructor.
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CPDAsyCmdHandler::CPDAsyCmdHandler()
       
    34     {
       
    35     FUNC_LOG;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // Symbian 2nd phase constructor.
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 void CPDAsyCmdHandler::ConstructL( MPDAsyCmdHandler* aCmdHandler,
       
    43     CASYMainServiceBase* aMainServiceBase )
       
    44     {
       
    45     FUNC_LOG;
       
    46     
       
    47     // Resolve command handler pointer
       
    48     iCmdHandler = aCmdHandler;
       
    49     if( !aCmdHandler )
       
    50         {
       
    51         iCmdHandler = this;
       
    52         }
       
    53     
       
    54     // Resolve main service pointer
       
    55     iMainService = aMainServiceBase;
       
    56     if( !aMainServiceBase )
       
    57         {
       
    58         iMainService = ASYMainServiceBase();
       
    59         }
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // Symbian two phased constructor.
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CPDAsyCmdHandler* CPDAsyCmdHandler::NewL()
       
    67     {
       
    68     FUNC_LOG;
       
    69 
       
    70     CPDAsyCmdHandler* self = CPDAsyCmdHandler::NewLC();
       
    71     CleanupStack::Pop( self );
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Symbian two phased constructor.
       
    77 // Leaves pointer in the cleanup stack.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CPDAsyCmdHandler* CPDAsyCmdHandler::NewLC()
       
    81     {
       
    82     FUNC_LOG;
       
    83 
       
    84     CPDAsyCmdHandler* self = new ( ELeave ) CPDAsyCmdHandler;
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL();
       
    87     return self;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // Symbian two phased constructor for testing purposes.
       
    92 // Leaves pointer in the cleanup stack.
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 CPDAsyCmdHandler* CPDAsyCmdHandler::CreateTestInstanceL(
       
    96     MPDAsyCmdHandler* aCmdHandler,
       
    97     CASYMainServiceBase* aMainServiceBase )
       
    98     {
       
    99     FUNC_LOG;
       
   100 
       
   101     CPDAsyCmdHandler* self = new ( ELeave ) CPDAsyCmdHandler;
       
   102     CleanupStack::PushL( self );
       
   103     self->ConstructL( aCmdHandler, aMainServiceBase );
       
   104     CleanupStack::Pop( self );
       
   105     return self;
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // C++ destructor.
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 CPDAsyCmdHandler::~CPDAsyCmdHandler()
       
   113     {
       
   114     FUNC_LOG;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CPDAsyCmdHandler::ProcessCommandL
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void CPDAsyCmdHandler::ProcessCommandL( const TProcessCmdId aCommand,
       
   122     const TASYCmdParams& aCmdParams )
       
   123     {
       
   124     FUNC_LOG;
       
   125 
       
   126     INFO_1( "Received command: Command ID = [%d]", aCommand );
       
   127     
       
   128     // Get main service
       
   129     CPDAsyMainService* mainService = MainService();
       
   130     if( mainService )
       
   131         {
       
   132         // Get the plugged display engine
       
   133         CPDEngine& engine = mainService->Engine();
       
   134         engine.ProcessCommandL( aCommand, aCmdParams, *iCmdHandler );
       
   135         INFO_1( "Processed command: Command ID = [%d]", aCommand );
       
   136         }
       
   137     else
       
   138         {
       
   139         // Main service not ready
       
   140         User::Leave( KErrNotReady );
       
   141         }
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // CPDAsyCmdHandler::ProcessResponse
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 void CPDAsyCmdHandler::ProcessResponse(
       
   149     const TAccValueTypeTBool aCmdResponse,
       
   150     TInt aErrCode )
       
   151     {
       
   152     FUNC_LOG;
       
   153     if ( iCmdHandler == this )
       
   154         {
       
   155         TRAP_IGNORE( ProcessResponseL( aCmdResponse, aErrCode ) );
       
   156         }
       
   157     else
       
   158         {
       
   159         iCmdHandler->ProcessResponse( aCmdResponse, aErrCode );
       
   160         }
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // CPDAsyCmdHandler::ProcessResponse
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 void CPDAsyCmdHandler::ProcessResponse( const TAccValueTypeTInt aCmdResponse,
       
   168     TInt aErrCode )
       
   169     {
       
   170     FUNC_LOG;
       
   171    
       
   172     if ( iCmdHandler == this )
       
   173         {
       
   174         TRAP_IGNORE( ProcessResponseL( aCmdResponse, aErrCode ) );
       
   175         }
       
   176     else
       
   177         {
       
   178         iCmdHandler->ProcessResponse( aCmdResponse, aErrCode );
       
   179         }
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // CPDAsyCmdHandler::ProcessResponse
       
   184 // ---------------------------------------------------------------------------
       
   185 //
       
   186 void CPDAsyCmdHandler::ProcessResponse( const TDesC8& aCmdResponse,
       
   187     TInt aErrCode )
       
   188     {
       
   189     FUNC_LOG;
       
   190     
       
   191     
       
   192     if ( iCmdHandler == this )
       
   193         {
       
   194         TRAP_IGNORE( ProcessResponseL( aCmdResponse, aErrCode ) );
       
   195         }
       
   196     else
       
   197         {
       
   198         iCmdHandler->ProcessResponse( aCmdResponse, aErrCode );
       
   199         }
       
   200     }
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 // CPDAsyCmdHandler::ProcessResponse
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 void CPDAsyCmdHandler::ProcessResponse( const CAccPolObjectCon& aObjectCon,
       
   207     TInt aErrCode )
       
   208     {
       
   209     FUNC_LOG;
       
   210     
       
   211     if ( iCmdHandler == this )
       
   212         {
       
   213         TRAP_IGNORE( ProcessResponseL( aObjectCon, aErrCode ) );
       
   214         }
       
   215     else
       
   216         {
       
   217         iCmdHandler->ProcessResponse( aObjectCon, aErrCode );
       
   218         }
       
   219     }
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // CPDAsyCmdHandler::ObjectConDataFromProxy
       
   223 // ---------------------------------------------------------------------------
       
   224 //
       
   225 void CPDAsyCmdHandler::ObjectConDataFromProxy(
       
   226     CAccPolObjectCon& aObjectCon ) const
       
   227     {
       
   228     FUNC_LOG;
       
   229     
       
   230     if ( iCmdHandler == this )
       
   231         {
       
   232         TRAP_IGNORE( ObjectConDataFromProxyL( aObjectCon ) );
       
   233         }
       
   234     else
       
   235         {
       
   236         iCmdHandler->ObjectConDataFromProxy( aObjectCon );
       
   237         }
       
   238     }
       
   239 
       
   240 //------------------------------------------------------------------------------
       
   241 // CPDAsyCmdHandler::MainService
       
   242 //------------------------------------------------------------------------------
       
   243 //
       
   244 CPDAsyMainService* CPDAsyCmdHandler::MainService()
       
   245     {
       
   246     FUNC_LOG;
       
   247 
       
   248     // Double check that the pointer exists
       
   249     if( !iMainService )
       
   250         {
       
   251         iMainService = ASYMainServiceBase();
       
   252         }
       
   253     
       
   254     return static_cast<CPDAsyMainService*>( iMainService );
       
   255     }
       
   256 
       
   257 // End of file