accessoryservices/accessoryremotecontrol/src/remconkeyeventconverter/RemConKeyEventConverterImpl.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Implementation for the key event handling API.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "RemConKeyEventConverterImpl.h"
       
    22 #include    "RemConDebug.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CRemConKeyEventConverterImpl::CRemConKeyEventConverterImpl
       
    28 // C++ default constructor can NOT contain any code, that
       
    29 // might leave.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CRemConKeyEventConverterImpl::CRemConKeyEventConverterImpl()
       
    33     {
       
    34     COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::CRemConKeyEventConverterImpl()" );
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CRemConKeyEventConverterImpl::ConstructL
       
    39 // Symbian 2nd phase constructor can leave.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 void CRemConKeyEventConverterImpl::ConstructL()
       
    43     {
       
    44     COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::ConstructL()" );
       
    45 	iKeyEventContainer = CRemConKeyEventContainer::NewL();
       
    46     COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::ConstructL() return void" );
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CRemConKeyEventConverterImpl::NewL
       
    51 // Two-phased constructor.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CRemConKeyEventConverterImpl* CRemConKeyEventConverterImpl::NewL()
       
    55     {
       
    56     COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::NewL()" );
       
    57 
       
    58     CRemConKeyEventConverterImpl* self = new( ELeave ) 
       
    59         CRemConKeyEventConverterImpl;
       
    60     
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL();
       
    63     CleanupStack::Pop( self );
       
    64 
       
    65     COM_TRACE_1( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::NewL() return %d", self );
       
    66     return self;
       
    67     }
       
    68 
       
    69 // Destructor
       
    70 CRemConKeyEventConverterImpl::~CRemConKeyEventConverterImpl()
       
    71     {
       
    72     COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::~CRemConKeyEventConverterImpl()" );
       
    73 
       
    74     delete iKeyEventContainer;
       
    75     iKeyEventContainer = 0;
       
    76     COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::~CRemConKeyEventConverterImpl() return void" );
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CRemConKeyEventConverterImpl::ResolveOperationID()
       
    81 // Handle key event received from accessory.
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 TInt CRemConKeyEventConverterImpl::ResolveOperationID( 
       
    86     const TRemConKeyEventData& aEvent, TUid& aInterfaceUID, 
       
    87     TUint& aOperationID, TDes8& aData ) const
       
    88     {
       
    89     COM_TRACE_1( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::ResolveOperationID(%d)", aEvent );
       
    90 	COM_TRACE_4( "[AccFW:RemConConverter] Event: Code:%d, Mod:%d, State:%d, Type:%d", aEvent.iKeyCode, aEvent.iKeyModifiers, aEvent.iKeyState, aEvent.iKeyEventType );
       
    91     	
       
    92     TInt ret( KErrNotSupported ); 
       
    93     const RPointerArray<CRemConKeyEvent>& events( iKeyEventContainer->GetEvents() );
       
    94     
       
    95     // Go through all supported events
       
    96     for ( TInt i(0); i < events.Count(); ++i )
       
    97         {
       
    98         CRemConKeyEvent& event( * ( events[i] ) );
       
    99         if ( event.Compare( aEvent ) )
       
   100             {
       
   101             COM_TRACE_( "[AccFW:RemConConverter] Event was found !" );
       
   102             
       
   103             if ( aData.MaxSize() <= 0 )
       
   104             	{
       
   105                 // No room for the key action -data
       
   106                 COM_TRACE_2( "[AccFW:RemConConverter] The ref. descriptor from bearer has too small max size (%d) , should be at least %d", aData.MaxSize(), event.Parameter().Size() );
       
   107                 return KErrGeneral;
       
   108                 }
       
   109             
       
   110             aInterfaceUID = event.InterfaceUID();
       
   111             aOperationID = event.OperationID();
       
   112             aData.Zero(); // Just in case
       
   113             aData.Append( event.Parameter() );
       
   114             
       
   115             ret = KErrNone;
       
   116             
       
   117             COM_TRACE_1( "[AccFW:RemConConverter] Interface ID for this event is: %d", aInterfaceUID.iUid );
       
   118             COM_TRACE_1( "[AccFW:RemConConverter] Operation ID for this event is: %d", aOperationID );
       
   119             COM_TRACE_1( "[AccFW:RemConConverter] Parameter for this event is: %S", &aData );
       
   120                        
       
   121             break; // from for -loop
       
   122             }
       
   123         }
       
   124     
       
   125     COM_TRACE_1( "[AccFW:RemConConverter] CRemConKeyEventConverterImpl::ResolveOperationID() return %d", ret );
       
   126     return ret;
       
   127     }
       
   128 
       
   129 //  End of File