os/mm/devsoundextensions/mmfcustominterfaces/Ra8DecoderIntfc/Ra8DecoderIntfcMsgHdlr/src/ra8custominterfacemsghdlr.cpp
First public contribution.
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Message handler for RA8 decoder custom interface.
21 #include <Ra8CustomInterface.h>
22 #include "Ra8CustomInterfaceMsgHdlr.h"
23 #include "Ra8CustomInterfaceMsgs.h"
25 // EXTERNAL DATA STRUCTURES
27 // EXTERNAL FUNCTION PROTOTYPES
33 // LOCAL CONSTANTS AND MACROS
35 // MODULE DATA STRUCTURES
37 // LOCAL FUNCTION PROTOTYPES
39 // FORWARD DECLARATIONS
41 // ============================= LOCAL FUNCTIONS ===============================
43 // ============================ MEMBER FUNCTIONS ===============================
45 // -----------------------------------------------------------------------------
46 // CRa8CustomInterfaceMsgHdlr::CRa8CustomInterfaceMsgHdlr
47 // C++ default constructor can NOT contain any code, that
49 // -----------------------------------------------------------------------------
51 CRa8CustomInterfaceMsgHdlr::CRa8CustomInterfaceMsgHdlr(
52 CRa8CustomInterface* aRa8CustomInterface) :
53 CMMFObject(KUidRa8DecHwDeviceCI)
55 iRa8CustomInterface = aRa8CustomInterface;
58 // -----------------------------------------------------------------------------
59 // CRa8CustomInterfaceMsgHdlr::ConstructL
60 // Symbian 2nd phase constructor can leave.
61 // -----------------------------------------------------------------------------
63 void CRa8CustomInterfaceMsgHdlr::ConstructL()
67 // -----------------------------------------------------------------------------
68 // CRa8CustomInterfaceMsgHdlr::NewL
69 // Two-phased constructor.
70 // -----------------------------------------------------------------------------
72 EXPORT_C CRa8CustomInterfaceMsgHdlr*
73 CRa8CustomInterfaceMsgHdlr::NewL(TAny* aRa8CustomInterface)
75 CRa8CustomInterface* custominterface =
76 (CRa8CustomInterface*)aRa8CustomInterface;
77 CRa8CustomInterfaceMsgHdlr* self =
78 new (ELeave) CRa8CustomInterfaceMsgHdlr(custominterface);
79 CleanupStack::PushL( self );
81 CleanupStack::Pop(self);
86 // -----------------------------------------------------------------------------
88 // -----------------------------------------------------------------------------
90 EXPORT_C CRa8CustomInterfaceMsgHdlr::~CRa8CustomInterfaceMsgHdlr()
94 // -----------------------------------------------------------------------------
95 // CRa8CustomInterfaceMsgHdlr::HandleRequest
96 // Handles the messages from the proxy.
97 // Calls a subfunction which determines which custom interface to call.
98 // A subfunction is used to contain multiple leaving functions for a single
100 // (other items were commented in a header).
101 // -----------------------------------------------------------------------------
103 EXPORT_C void CRa8CustomInterfaceMsgHdlr::HandleRequest(TMMFMessage& aMessage)
105 ASSERT(aMessage.Destination().InterfaceId() == KUidRa8DecHwDeviceCI);
106 TRAPD(error,DoHandleRequestL(aMessage));
109 aMessage.Complete(error);
113 // -----------------------------------------------------------------------------
114 // CRa8CustomInterfaceMsgHdlr::DoHandleRequestL
115 // Determines which custom interface to call.
116 // (other items were commented in a header).
117 // -----------------------------------------------------------------------------
119 void CRa8CustomInterfaceMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
121 switch (aMessage.Function())
123 case ERa8CiFrameNumber:
125 DoFrameNumberL(aMessage);
128 case ERa8CiSetInitString:
130 DoSetInitStringL(aMessage);
135 aMessage.Complete(KErrNotSupported);
140 // -----------------------------------------------------------------------------
141 // CRa8CustomInterfaceMsgHdlr::DoFrameNumberL
142 // Handles the message from the proxy and calls the custom interface method.
143 // The data passed from the proxy is read from the message and passed to
144 // the custom interface.
145 // (other items were commented in a header).
146 // -----------------------------------------------------------------------------
148 void CRa8CustomInterfaceMsgHdlr::DoFrameNumberL(TMMFMessage& aMessage)
150 TInt frame = iRa8CustomInterface->FrameNumber();
151 TPckgBuf<TInt> pckg(frame);
152 aMessage.WriteDataToClientL(pckg);
153 aMessage.Complete(KErrNone);
156 // -----------------------------------------------------------------------------
157 // CRa8CustomInterfaceMsgHdlr::DoSetInitStringL
158 // Handles the message from the proxy and calls the custom interface method.
159 // The data passed from the proxy is read from the message and passed to
160 // the custom interface.
161 // (other items were commented in a header).
162 // -----------------------------------------------------------------------------
164 void CRa8CustomInterfaceMsgHdlr::DoSetInitStringL(TMMFMessage& aMessage)
166 TInt size = aMessage.SizeOfData1FromClient();
167 HBufC8* dataBuf = HBufC8::NewL(size);
168 CleanupStack::PushL( dataBuf );
169 TPtr8 dataPtr = dataBuf->Des();
170 aMessage.ReadData1FromClientL(dataPtr);
171 TInt status = iRa8CustomInterface->SetInitString(dataPtr);
172 CleanupStack::Pop(dataBuf);
174 aMessage.Complete(status);
177 // ========================== OTHER EXPORTED FUNCTIONS =========================