os/mm/devsoundextensions/mmfcustominterfaces/Ra8DecoderIntfc/Ra8DecoderIntfcMsgHdlr/src/ra8custominterfacemsghdlr.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsoundextensions/mmfcustominterfaces/Ra8DecoderIntfc/Ra8DecoderIntfcMsgHdlr/src/ra8custominterfacemsghdlr.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,179 @@
     1.4 +/*
     1.5 +* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:   Message handler for RA8 decoder custom interface.
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +// INCLUDE FILES
    1.24 +#include    <Ra8CustomInterface.h>
    1.25 +#include    "Ra8CustomInterfaceMsgHdlr.h"
    1.26 +#include    "Ra8CustomInterfaceMsgs.h"
    1.27 +
    1.28 +// EXTERNAL DATA STRUCTURES
    1.29 +
    1.30 +// EXTERNAL FUNCTION PROTOTYPES  
    1.31 +
    1.32 +// CONSTANTS
    1.33 +
    1.34 +// MACROS
    1.35 +
    1.36 +// LOCAL CONSTANTS AND MACROS
    1.37 +
    1.38 +// MODULE DATA STRUCTURES
    1.39 +
    1.40 +// LOCAL FUNCTION PROTOTYPES
    1.41 +
    1.42 +// FORWARD DECLARATIONS
    1.43 +
    1.44 +// ============================= LOCAL FUNCTIONS ===============================
    1.45 +
    1.46 +// ============================ MEMBER FUNCTIONS ===============================
    1.47 +
    1.48 +// -----------------------------------------------------------------------------
    1.49 +// CRa8CustomInterfaceMsgHdlr::CRa8CustomInterfaceMsgHdlr
    1.50 +// C++ default constructor can NOT contain any code, that
    1.51 +// might leave.
    1.52 +// -----------------------------------------------------------------------------
    1.53 +//
    1.54 +CRa8CustomInterfaceMsgHdlr::CRa8CustomInterfaceMsgHdlr(
    1.55 +                            CRa8CustomInterface* aRa8CustomInterface) :
    1.56 +	CMMFObject(KUidRa8DecHwDeviceCI)
    1.57 +    {
    1.58 +    iRa8CustomInterface = aRa8CustomInterface;
    1.59 +    }
    1.60 +
    1.61 +// -----------------------------------------------------------------------------
    1.62 +// CRa8CustomInterfaceMsgHdlr::ConstructL
    1.63 +// Symbian 2nd phase constructor can leave.
    1.64 +// -----------------------------------------------------------------------------
    1.65 +//
    1.66 +void CRa8CustomInterfaceMsgHdlr::ConstructL()
    1.67 +    {
    1.68 +    }
    1.69 +
    1.70 +// -----------------------------------------------------------------------------
    1.71 +// CRa8CustomInterfaceMsgHdlr::NewL
    1.72 +// Two-phased constructor.
    1.73 +// -----------------------------------------------------------------------------
    1.74 +//
    1.75 +EXPORT_C CRa8CustomInterfaceMsgHdlr*
    1.76 +    CRa8CustomInterfaceMsgHdlr::NewL(TAny*  aRa8CustomInterface)
    1.77 +    {
    1.78 +    CRa8CustomInterface* custominterface = 
    1.79 +                         (CRa8CustomInterface*)aRa8CustomInterface;
    1.80 +    CRa8CustomInterfaceMsgHdlr* self = 
    1.81 +            new (ELeave) CRa8CustomInterfaceMsgHdlr(custominterface);
    1.82 +    CleanupStack::PushL( self );
    1.83 +    self->ConstructL();
    1.84 +    CleanupStack::Pop(self);
    1.85 +
    1.86 +    return self;
    1.87 +    }
    1.88 +
    1.89 +// -----------------------------------------------------------------------------
    1.90 +// Destructor
    1.91 +// -----------------------------------------------------------------------------
    1.92 +//
    1.93 +EXPORT_C CRa8CustomInterfaceMsgHdlr::~CRa8CustomInterfaceMsgHdlr()
    1.94 +	{
    1.95 +	}
    1.96 +
    1.97 +// -----------------------------------------------------------------------------
    1.98 +// CRa8CustomInterfaceMsgHdlr::HandleRequest
    1.99 +// Handles the messages from the proxy.
   1.100 +// Calls a subfunction which determines which custom interface to call.
   1.101 +// A subfunction is used to contain multiple leaving functions for a single
   1.102 +// trap.
   1.103 +// (other items were commented in a header).
   1.104 +// -----------------------------------------------------------------------------
   1.105 +//
   1.106 +EXPORT_C void CRa8CustomInterfaceMsgHdlr::HandleRequest(TMMFMessage& aMessage)
   1.107 +	{
   1.108 +	ASSERT(aMessage.Destination().InterfaceId() == KUidRa8DecHwDeviceCI);
   1.109 +	TRAPD(error,DoHandleRequestL(aMessage));
   1.110 +	if (error)
   1.111 +		{
   1.112 +		aMessage.Complete(error);
   1.113 +		}
   1.114 +	}
   1.115 +
   1.116 +// -----------------------------------------------------------------------------
   1.117 +// CRa8CustomInterfaceMsgHdlr::DoHandleRequestL
   1.118 +// Determines which custom interface to call.
   1.119 +// (other items were commented in a header).
   1.120 +// -----------------------------------------------------------------------------
   1.121 +//
   1.122 +void CRa8CustomInterfaceMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
   1.123 +	{
   1.124 +	switch (aMessage.Function())
   1.125 +		{
   1.126 +		case ERa8CiFrameNumber:
   1.127 +			{
   1.128 +    		DoFrameNumberL(aMessage);
   1.129 +			break;
   1.130 +			}
   1.131 +		case ERa8CiSetInitString:
   1.132 +			{
   1.133 +    		DoSetInitStringL(aMessage);
   1.134 +			break;
   1.135 +			}
   1.136 +		default:
   1.137 +			{
   1.138 +			aMessage.Complete(KErrNotSupported);
   1.139 +			}
   1.140 +		}
   1.141 +	}
   1.142 +
   1.143 +// -----------------------------------------------------------------------------
   1.144 +// CRa8CustomInterfaceMsgHdlr::DoFrameNumberL
   1.145 +// Handles the message from the proxy and calls the custom interface method.
   1.146 +// The data passed from the proxy is read from the message and passed to
   1.147 +// the custom interface.
   1.148 +// (other items were commented in a header).
   1.149 +// -----------------------------------------------------------------------------
   1.150 +//
   1.151 +void CRa8CustomInterfaceMsgHdlr::DoFrameNumberL(TMMFMessage& aMessage)
   1.152 +    {
   1.153 +	TInt frame = iRa8CustomInterface->FrameNumber();
   1.154 +	TPckgBuf<TInt> pckg(frame);
   1.155 +	aMessage.WriteDataToClientL(pckg);
   1.156 +    aMessage.Complete(KErrNone);
   1.157 +    }
   1.158 +    
   1.159 +// -----------------------------------------------------------------------------
   1.160 +// CRa8CustomInterfaceMsgHdlr::DoSetInitStringL
   1.161 +// Handles the message from the proxy and calls the custom interface method.
   1.162 +// The data passed from the proxy is read from the message and passed to
   1.163 +// the custom interface.
   1.164 +// (other items were commented in a header).
   1.165 +// -----------------------------------------------------------------------------
   1.166 +//
   1.167 +void CRa8CustomInterfaceMsgHdlr::DoSetInitStringL(TMMFMessage& aMessage)
   1.168 +    {
   1.169 +	TInt size = aMessage.SizeOfData1FromClient();
   1.170 +	HBufC8* dataBuf = HBufC8::NewL(size);
   1.171 +	CleanupStack::PushL( dataBuf );
   1.172 +	TPtr8 dataPtr = dataBuf->Des();
   1.173 +    aMessage.ReadData1FromClientL(dataPtr);
   1.174 +	TInt status = iRa8CustomInterface->SetInitString(dataPtr);
   1.175 +	CleanupStack::Pop(dataBuf);
   1.176 +	delete dataBuf;
   1.177 +    aMessage.Complete(status);
   1.178 +    }
   1.179 +
   1.180 +// ========================== OTHER EXPORTED FUNCTIONS =========================
   1.181 +
   1.182 +// End of File