mpxmusicplayer/mediakeyhandler/src/mpxremconkeyresponse.cpp
changeset 0 ff3acec5bc43
child 21 cb96c29156b2
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Helper class for sending response back to RemCon Framework.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "mpxremconkeyresponse.h"
       
    22 #include "mpxlog.h"
       
    23 
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // C++ default constructor can NOT contain any code, that
       
    29 // might leave.
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CMPXRemConKeyResponse::CMPXRemConKeyResponse( 
       
    33     CRemConCoreApiTarget& aRemConCoreApiTarget ) : 
       
    34     CActive( CActive::EPriorityStandard ),
       
    35     iRemConCoreApiTarget( aRemConCoreApiTarget )
       
    36     {
       
    37     CActiveScheduler::Add( this );
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // Two-phased constructor.
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CMPXRemConKeyResponse* CMPXRemConKeyResponse::NewL(
       
    45     CRemConCoreApiTarget& aRemConCoreApiTarget )
       
    46     {
       
    47     CMPXRemConKeyResponse* self = 
       
    48         new (ELeave) CMPXRemConKeyResponse( aRemConCoreApiTarget );
       
    49 
       
    50     return self;
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // Destructor
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CMPXRemConKeyResponse::~CMPXRemConKeyResponse()
       
    58     {
       
    59     Cancel();
       
    60     iResponseArray.Close();
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Send the any key response back to Remcon server
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CMPXRemConKeyResponse::CompleteAnyKey( 
       
    68     TRemConCoreApiOperationId aOperationId )
       
    69     {
       
    70     if ( !IsActive() )
       
    71         {
       
    72         switch ( aOperationId )
       
    73             {
       
    74             case ERemConCoreApiVolumeUp:
       
    75                 {
       
    76                 iRemConCoreApiTarget.VolumeUpResponse( iStatus, KErrNone );
       
    77                 SetActive();
       
    78                 break;
       
    79                 }
       
    80             case ERemConCoreApiVolumeDown:
       
    81                 {
       
    82                 iRemConCoreApiTarget.VolumeDownResponse( iStatus, KErrNone );
       
    83                 SetActive();
       
    84                 break;
       
    85                 }
       
    86             default:
       
    87                 {
       
    88                 TInt error = KErrNone;
       
    89                 iRemConCoreApiTarget.SendResponse(
       
    90                     iStatus, aOperationId, error );
       
    91                 SetActive();
       
    92                 break;
       
    93                 }
       
    94             }
       
    95         }
       
    96     // already active. Append to array and complete later.
       
    97     else
       
    98         {
       
    99         iResponseArray.Append( aOperationId );
       
   100         }
       
   101     }
       
   102     
       
   103 // ---------------------------------------------------------------------------
       
   104 // Implements cancellation of an outstanding request.
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CMPXRemConKeyResponse::DoCancel()
       
   108     {
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // Handles an active object's request completion event.
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CMPXRemConKeyResponse::RunL()
       
   116     {
       
   117     MPX_DEBUG2( "CMPXRemConKeyResponse.RunL() -- iStatus=%d", iStatus.Int() );
       
   118 
       
   119     // if any existing -> Send response
       
   120     if ( iResponseArray.Count() )
       
   121         {
       
   122         CompleteAnyKey( iResponseArray[0] );
       
   123         // Remove already completed key
       
   124         iResponseArray.Remove( 0 );
       
   125         iResponseArray.Compress();
       
   126         }
       
   127     }
       
   128 
       
   129 // End of File