accessoryservices/accessoryremotecontrol/src/remconextensionapi/RemConPocTarget.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  This class deliveres PoC related operations from accessories 
       
    15 *				 to client that listens to them. It also provides methods for 
       
    16 *				 client to respond to PoC operations.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "RemConExtensionApi.h"
       
    24 #include "RemConPocTarget.h"
       
    25 #include "RemConPocTargetObserver.h"
       
    26 #include "RemConDebug.h"
       
    27 #include <e32base.h>
       
    28 #include <remconinterfaceselector.h>
       
    29 #include <RemConCallHandlingTarget.h>
       
    30 
       
    31 // EXTERNAL DATA STRUCTURES
       
    32 
       
    33 // EXTERNAL FUNCTION PROTOTYPES  
       
    34 
       
    35 // CONSTANTS
       
    36 
       
    37 // MACROS
       
    38 
       
    39 // LOCAL CONSTANTS AND MACROS
       
    40 
       
    41 // MODULE DATA STRUCTURES
       
    42 
       
    43 // LOCAL FUNCTION PROTOTYPES
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 
       
    47 
       
    48 // ============================= LOCAL FUNCTIONS ===============================
       
    49 
       
    50 // ============================ MEMBER FUNCTIONS ===============================
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CRemConPocTarget::CRemConPocTarget
       
    54 // C++ default constructor can NOT contain any code, that
       
    55 // might leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CRemConPocTarget::CRemConPocTarget(CRemConInterfaceSelector& aInterfaceSelector, 
       
    59 								   MRemConPocTargetObserver& aObserver)
       
    60 :	CRemConInterfaceBase(TUid::Uid(KRemConExtPocApiUid), 
       
    61 						 KMaxName,
       
    62 						 aInterfaceSelector,
       
    63 						 ERemConClientTypeTarget),
       
    64 	iObserver(aObserver)
       
    65 	{
       
    66 	}
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CRemConPocTarget::ConstructL
       
    70 // Symbian 2nd phase constructor can leave.
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CRemConPocTarget::NewL
       
    76 // Two-phased constructor.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CRemConPocTarget* CRemConPocTarget::NewL(CRemConInterfaceSelector& aInterfaceSelector, 
       
    80 												  MRemConPocTargetObserver& aObserver)
       
    81 	{
       
    82 	COM_TRACE_( "[REMCONEXTAPI] CRemConPocTarget::NewL() start" );
       
    83 		
       
    84 	CRemConPocTarget* self = new(ELeave) CRemConPocTarget(aInterfaceSelector, aObserver);
       
    85 	CleanupStack::PushL(self);
       
    86 	self->BaseConstructL();
       
    87 	CleanupStack::Pop(self);
       
    88 	
       
    89 	COM_TRACE_( "[REMCONEXTAPI] CRemConPocTarget::NewL() end" );
       
    90 	return self;
       
    91 	}
       
    92     
       
    93 // Destructor
       
    94 EXPORT_C CRemConPocTarget::~CRemConPocTarget()
       
    95 	{
       
    96 	COM_TRACE_( "[REMCONEXTAPI] ~CRemConPocTarget()" );
       
    97 	}
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CRemConPocTarget::SendResponse
       
   101 // Sends responses to accessories.
       
   102 // (other items were commented in a header).
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CRemConPocTarget::SendResponse( 
       
   106 							TRequestStatus& aStatus,
       
   107 							TInt aOperationId,
       
   108 							TInt aError )
       
   109 	{
       
   110 	COM_TRACE_2( "[REMCONEXTAPI] CRemConPocTarget::SendResponse() opId=0x%x, error=0x%x", aOperationId, aError );
       
   111 	
       
   112 	iNumRemotes = 0;
       
   113 	TUint8* parameter = reinterpret_cast<TUint8*>( &aError );
       
   114 	iOutData.Copy( parameter );
       
   115 	
       
   116 	InterfaceSelector().Send(aStatus, 
       
   117 		TUid::Uid(KRemConExtPocApiUid),
       
   118 		(TUint)aOperationId, 
       
   119 		iNumRemotes,
       
   120 		ERemConResponse,
       
   121 		iOutData);
       
   122 	
       
   123 	COM_TRACE_1( "[REMCONEXTAPI] CRemConPocTarget::SendResponse() iNumRemotes=0x%x", iNumRemotes );
       
   124 	}
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CRemConPocTarget::GetInterfaceIf
       
   128 // Called by Remote Control intermediate client when an operation is sent to 
       
   129 // this API. Intermediate client uses this method to figure out version of 
       
   130 // interface it should call to inform this API about incoming operation.
       
   131 // (other items were commented in a header).
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 TAny* CRemConPocTarget::GetInterfaceIf( TUid aUid )
       
   135     {
       
   136     COM_TRACE_2( "[REMCONEXTAPI] CRemConPocTarget::GetInterfaceIf() this=0x%x, aUid=0x%x", this, aUid );
       
   137 
       
   138 	TAny* ret = NULL;
       
   139 	
       
   140 	// Asked interface version implemented by this API ?
       
   141 	if ( aUid == TUid::Uid( KRemConInterfaceIf3 ) )
       
   142 		{
       
   143 		// Return this interface version
       
   144 		ret = reinterpret_cast< TAny* >( 
       
   145 				static_cast< MRemConInterfaceIf3* >( this ) );
       
   146 		}
       
   147 
       
   148 	COM_TRACE_1( "[REMCONEXTAPI] CRemConPocTarget::GetInterfaceIf() this=0x%x", ret );
       
   149 	return ret;
       
   150     }
       
   151 		
       
   152 // -----------------------------------------------------------------------------
       
   153 // CRemConPocTarget::MrcibNewMessage
       
   154 // Called by Remote Control intermediate client when accessory has sent 
       
   155 // PoC related operation.
       
   156 // (other items were commented in a header).
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CRemConPocTarget::MrcibNewMessage(TUint aOperationId, const TDesC8& /*aData*/, TRemConMessageSubType /*aMessageSubType*/, const TRemConAddress& aRemoteAddr)
       
   160 	{
       
   161 	
       
   162 	iSourceUID = aRemoteAddr.BearerUid().iUid;
       
   163 	
       
   164 	switch ( aOperationId )
       
   165 		{
       
   166 		case ERemConExtAPOCButtonUp:
       
   167 			{
       
   168 			COM_TRACE_( "[REMCONEXTAPI] APOCButtonUp()" );
       
   169 		 	iObserver.APOCButtonUp();
       
   170 			break;
       
   171 			}
       
   172 			
       
   173 		case ERemConExtAPOCButtonDown:
       
   174 			{
       
   175 			COM_TRACE_( "[REMCONEXTAPI] APOCButtonDown()" );
       
   176 		 	iObserver.APOCButtonDown();
       
   177 			break;
       
   178 			}
       
   179 					
       
   180 		default:
       
   181 			COM_TRACE_( "[REMCONEXTAPI] CRemConPocTarget::MrcibNewMessage() Operation not identified" );
       
   182 			break;
       
   183 		}
       
   184 	}
       
   185 	
       
   186 // -----------------------------------------------------------------------------
       
   187 // CRemConPocTarget::AnswerCallResponse
       
   188 // Called by client to send a response to accessory's operation after
       
   189 // client has processed operation. 
       
   190 // (other items were commented in a header).
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 EXPORT_C void CRemConPocTarget::APOCButtonUpResponse( 
       
   194 											TRequestStatus& aStatus, 
       
   195 											TInt aError)
       
   196 	{
       
   197 	SendResponse( aStatus, ERemConExtAPOCButtonUp, aError );
       
   198 	}	
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 // CRemConPocTarget::EndCallResponse
       
   202 // Called by client to send a response to accessory's operation after
       
   203 // client has processed operation. 
       
   204 // (other items were commented in a header).
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 EXPORT_C void CRemConPocTarget::APOCButtonDownResponse( 
       
   208 											TRequestStatus& aStatus, 
       
   209 											TInt aError )	
       
   210 	{
       
   211 	SendResponse( aStatus, ERemConExtAPOCButtonDown, aError );
       
   212 	}
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CRemConPocTarget::GetCommandSourceInfo
       
   216 // Method to get the bearer source detail for the last command received
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 EXPORT_C void CRemConPocTarget::GetCommandSourceInfo( TRemConExtCmdSource& aSource )
       
   220   {
       
   221   CRemConCallHandlingTarget::GetUIDSource( iSourceUID, aSource );
       
   222   }
       
   223 
       
   224 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   225 
       
   226 //  End of File