accessoryservices/accessoryremotecontrol/src/remconextensionapi/RemConSynchronizationTarget.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 synchronization related operations from 
       
    15 *				 accessories to client that listens to them. It also provides 
       
    16 *				 methods for client to respond to synchronization operations.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "RemConExtensionApi.h"
       
    24 #include "RemConSynchronizationTarget.h"
       
    25 #include "RemConSynchronizationTargetObserver.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 // CRemConSynchronizationTarget::CRemConSynchronizationTarget
       
    54 // C++ default constructor can NOT contain any code, that
       
    55 // might leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CRemConSynchronizationTarget::CRemConSynchronizationTarget(
       
    59 								CRemConInterfaceSelector& aInterfaceSelector, 
       
    60 								MRemConSynchronizationTargetObserver& aObserver)
       
    61 :	CRemConInterfaceBase(TUid::Uid(KRemConExtSynchronizationApiUid), 
       
    62 						 KMaxName,
       
    63 						 aInterfaceSelector,
       
    64 						 ERemConClientTypeTarget),
       
    65 	iObserver(aObserver)
       
    66 	{
       
    67 	}
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CRemConSynchronizationTarget::ConstructL
       
    71 // Symbian 2nd phase constructor can leave.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CRemConSynchronizationTarget::NewL
       
    77 // Two-phased constructor.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 EXPORT_C CRemConSynchronizationTarget* CRemConSynchronizationTarget::NewL(
       
    81 								CRemConInterfaceSelector& aInterfaceSelector, 
       
    82 								MRemConSynchronizationTargetObserver& aObserver)
       
    83 	{
       
    84 	COM_TRACE_( "[REMCONEXTAPI] CRemConSynchronizationTarget::NewL() start" );
       
    85 	
       
    86 	CRemConSynchronizationTarget* self = new(ELeave) 
       
    87 					CRemConSynchronizationTarget(aInterfaceSelector, aObserver);
       
    88 	CleanupStack::PushL(self);
       
    89 	self->BaseConstructL();
       
    90 	CleanupStack::Pop(self);
       
    91 	
       
    92 	COM_TRACE_( "[REMCONEXTAPI] CRemConSynchronizationTarget::NewL() end" );
       
    93 	return self;
       
    94 	}
       
    95     
       
    96 // Destructor
       
    97 EXPORT_C CRemConSynchronizationTarget::~CRemConSynchronizationTarget()
       
    98 	{
       
    99 	COM_TRACE_( "[REMCONEXTAPI] ~CRemConSynchronizationTarget()" );
       
   100 	}
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CRemConSynchronizationTarget::GetInterfaceIf
       
   104 // Called by Remote Control intermediate client when an operation is sent to 
       
   105 // this API. Intermediate client uses this method to figure out version of 
       
   106 // interface it should call to inform this API about incoming operation.
       
   107 // (other items were commented in a header).
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 TAny* CRemConSynchronizationTarget::GetInterfaceIf( TUid aUid )
       
   111     {
       
   112     COM_TRACE_2( "[REMCONEXTAPI] CRemConPocTarget::GetInterfaceIf() this=0x%x, aUid=0x%x", this, aUid );
       
   113 
       
   114 	TAny* ret = NULL;
       
   115 	
       
   116 	// Asked interface version implemented by this API ?
       
   117 	if ( aUid == TUid::Uid( KRemConInterfaceIf3 ) )
       
   118 		{
       
   119 		// Return this interface version
       
   120 		ret = reinterpret_cast< TAny* >( 
       
   121 				static_cast< MRemConInterfaceIf3* >( this ) );
       
   122 		}
       
   123 
       
   124 	COM_TRACE_1( "[REMCONEXTAPI] CRemConPocTarget::GetInterfaceIf() this=0x%x", ret );
       
   125 	return ret;
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CRemConSynchronizationTarget::MrcibNewMessage
       
   130 // Called by Remote Control intermediate client when accessory has sent 
       
   131 // PoC related operation.
       
   132 // (other items were commented in a header).
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CRemConSynchronizationTarget::MrcibNewMessage(TUint aOperationId, const TDesC8& /*aData*/, TRemConMessageSubType /*aMessageSubType*/, const TRemConAddress& aRemoteAddr)
       
   136 	{
       
   137 	
       
   138 	iSourceUID = aRemoteAddr.BearerUid().iUid;
       
   139 	
       
   140 	switch ( aOperationId )
       
   141 		{
       
   142 		case ERemConExtSynchronization:
       
   143 			{
       
   144 			COM_TRACE_( "[REMCONEXTAPI] Synchronize()" );
       
   145 		 	iObserver.Synchronize();
       
   146 			break;
       
   147 			}
       
   148 							
       
   149 		default:
       
   150 			COM_TRACE_( "[REMCONEXTAPI] CRemConSynchronizationTarget::MrcibNewMessage() Operation not identified" );
       
   151 			break;
       
   152 		}
       
   153 	}
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CRemConSynchronizationTarget::SynchronizeResponse
       
   157 // Called by client to send a response to accessory's operation after
       
   158 // client has processed operation. 
       
   159 // (other items were commented in a header).
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 EXPORT_C void CRemConSynchronizationTarget::SynchronizeResponse( 
       
   163 											TRequestStatus& aStatus, 
       
   164 											TInt aError)
       
   165 	{
       
   166 	COM_TRACE_1( "[REMCONEXTAPI] CRemConSynchronizationTarget::SynchronizeResponse() error=0x%x", aError );
       
   167 	
       
   168 	iNumRemotes = 0;
       
   169 	TUint8* parameter = reinterpret_cast< TUint8*> ( &aError );
       
   170 	iOutData.Copy( parameter );
       
   171 		
       
   172 	InterfaceSelector().Send(aStatus, 
       
   173 		TUid::Uid(KRemConExtSynchronizationApiUid),
       
   174 		(TUint)ERemConExtSynchronization, 
       
   175 		iNumRemotes,
       
   176 		ERemConResponse,
       
   177 		iOutData);
       
   178 	
       
   179 	COM_TRACE_1( "[REMCONEXTENSIOAPI] CRemConSynchronizationTarget::SynchronizeResponse() iNumRemotes=0x%x", iNumRemotes );
       
   180 	}	
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CRemConSynchronizationTarget::GetCommandSourceInfo
       
   184 // Method to get the bearer source detail for the last command received
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 EXPORT_C void CRemConSynchronizationTarget::GetCommandSourceInfo( TRemConExtCmdSource& aSource )
       
   188   {
       
   189   CRemConCallHandlingTarget::GetUIDSource( iSourceUID, aSource );
       
   190   }
       
   191   
       
   192 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   193 
       
   194 //  End of File