os/mm/devsoundextensions/mmfcustominterfaces/Ra8DecoderIntfc/Ra8DecoderIntfcMsgHdlr/src/ra8custominterfacemsghdlr.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:   Message handler for RA8 decoder custom interface.
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
sl@0
    20
// INCLUDE FILES
sl@0
    21
#include    <Ra8CustomInterface.h>
sl@0
    22
#include    "Ra8CustomInterfaceMsgHdlr.h"
sl@0
    23
#include    "Ra8CustomInterfaceMsgs.h"
sl@0
    24
sl@0
    25
// EXTERNAL DATA STRUCTURES
sl@0
    26
sl@0
    27
// EXTERNAL FUNCTION PROTOTYPES  
sl@0
    28
sl@0
    29
// CONSTANTS
sl@0
    30
sl@0
    31
// MACROS
sl@0
    32
sl@0
    33
// LOCAL CONSTANTS AND MACROS
sl@0
    34
sl@0
    35
// MODULE DATA STRUCTURES
sl@0
    36
sl@0
    37
// LOCAL FUNCTION PROTOTYPES
sl@0
    38
sl@0
    39
// FORWARD DECLARATIONS
sl@0
    40
sl@0
    41
// ============================= LOCAL FUNCTIONS ===============================
sl@0
    42
sl@0
    43
// ============================ MEMBER FUNCTIONS ===============================
sl@0
    44
sl@0
    45
// -----------------------------------------------------------------------------
sl@0
    46
// CRa8CustomInterfaceMsgHdlr::CRa8CustomInterfaceMsgHdlr
sl@0
    47
// C++ default constructor can NOT contain any code, that
sl@0
    48
// might leave.
sl@0
    49
// -----------------------------------------------------------------------------
sl@0
    50
//
sl@0
    51
CRa8CustomInterfaceMsgHdlr::CRa8CustomInterfaceMsgHdlr(
sl@0
    52
                            CRa8CustomInterface* aRa8CustomInterface) :
sl@0
    53
	CMMFObject(KUidRa8DecHwDeviceCI)
sl@0
    54
    {
sl@0
    55
    iRa8CustomInterface = aRa8CustomInterface;
sl@0
    56
    }
sl@0
    57
sl@0
    58
// -----------------------------------------------------------------------------
sl@0
    59
// CRa8CustomInterfaceMsgHdlr::ConstructL
sl@0
    60
// Symbian 2nd phase constructor can leave.
sl@0
    61
// -----------------------------------------------------------------------------
sl@0
    62
//
sl@0
    63
void CRa8CustomInterfaceMsgHdlr::ConstructL()
sl@0
    64
    {
sl@0
    65
    }
sl@0
    66
sl@0
    67
// -----------------------------------------------------------------------------
sl@0
    68
// CRa8CustomInterfaceMsgHdlr::NewL
sl@0
    69
// Two-phased constructor.
sl@0
    70
// -----------------------------------------------------------------------------
sl@0
    71
//
sl@0
    72
EXPORT_C CRa8CustomInterfaceMsgHdlr*
sl@0
    73
    CRa8CustomInterfaceMsgHdlr::NewL(TAny*  aRa8CustomInterface)
sl@0
    74
    {
sl@0
    75
    CRa8CustomInterface* custominterface = 
sl@0
    76
                         (CRa8CustomInterface*)aRa8CustomInterface;
sl@0
    77
    CRa8CustomInterfaceMsgHdlr* self = 
sl@0
    78
            new (ELeave) CRa8CustomInterfaceMsgHdlr(custominterface);
sl@0
    79
    CleanupStack::PushL( self );
sl@0
    80
    self->ConstructL();
sl@0
    81
    CleanupStack::Pop(self);
sl@0
    82
sl@0
    83
    return self;
sl@0
    84
    }
sl@0
    85
sl@0
    86
// -----------------------------------------------------------------------------
sl@0
    87
// Destructor
sl@0
    88
// -----------------------------------------------------------------------------
sl@0
    89
//
sl@0
    90
EXPORT_C CRa8CustomInterfaceMsgHdlr::~CRa8CustomInterfaceMsgHdlr()
sl@0
    91
	{
sl@0
    92
	}
sl@0
    93
sl@0
    94
// -----------------------------------------------------------------------------
sl@0
    95
// CRa8CustomInterfaceMsgHdlr::HandleRequest
sl@0
    96
// Handles the messages from the proxy.
sl@0
    97
// Calls a subfunction which determines which custom interface to call.
sl@0
    98
// A subfunction is used to contain multiple leaving functions for a single
sl@0
    99
// trap.
sl@0
   100
// (other items were commented in a header).
sl@0
   101
// -----------------------------------------------------------------------------
sl@0
   102
//
sl@0
   103
EXPORT_C void CRa8CustomInterfaceMsgHdlr::HandleRequest(TMMFMessage& aMessage)
sl@0
   104
	{
sl@0
   105
	ASSERT(aMessage.Destination().InterfaceId() == KUidRa8DecHwDeviceCI);
sl@0
   106
	TRAPD(error,DoHandleRequestL(aMessage));
sl@0
   107
	if (error)
sl@0
   108
		{
sl@0
   109
		aMessage.Complete(error);
sl@0
   110
		}
sl@0
   111
	}
sl@0
   112
sl@0
   113
// -----------------------------------------------------------------------------
sl@0
   114
// CRa8CustomInterfaceMsgHdlr::DoHandleRequestL
sl@0
   115
// Determines which custom interface to call.
sl@0
   116
// (other items were commented in a header).
sl@0
   117
// -----------------------------------------------------------------------------
sl@0
   118
//
sl@0
   119
void CRa8CustomInterfaceMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
sl@0
   120
	{
sl@0
   121
	switch (aMessage.Function())
sl@0
   122
		{
sl@0
   123
		case ERa8CiFrameNumber:
sl@0
   124
			{
sl@0
   125
    		DoFrameNumberL(aMessage);
sl@0
   126
			break;
sl@0
   127
			}
sl@0
   128
		case ERa8CiSetInitString:
sl@0
   129
			{
sl@0
   130
    		DoSetInitStringL(aMessage);
sl@0
   131
			break;
sl@0
   132
			}
sl@0
   133
		default:
sl@0
   134
			{
sl@0
   135
			aMessage.Complete(KErrNotSupported);
sl@0
   136
			}
sl@0
   137
		}
sl@0
   138
	}
sl@0
   139
sl@0
   140
// -----------------------------------------------------------------------------
sl@0
   141
// CRa8CustomInterfaceMsgHdlr::DoFrameNumberL
sl@0
   142
// Handles the message from the proxy and calls the custom interface method.
sl@0
   143
// The data passed from the proxy is read from the message and passed to
sl@0
   144
// the custom interface.
sl@0
   145
// (other items were commented in a header).
sl@0
   146
// -----------------------------------------------------------------------------
sl@0
   147
//
sl@0
   148
void CRa8CustomInterfaceMsgHdlr::DoFrameNumberL(TMMFMessage& aMessage)
sl@0
   149
    {
sl@0
   150
	TInt frame = iRa8CustomInterface->FrameNumber();
sl@0
   151
	TPckgBuf<TInt> pckg(frame);
sl@0
   152
	aMessage.WriteDataToClientL(pckg);
sl@0
   153
    aMessage.Complete(KErrNone);
sl@0
   154
    }
sl@0
   155
    
sl@0
   156
// -----------------------------------------------------------------------------
sl@0
   157
// CRa8CustomInterfaceMsgHdlr::DoSetInitStringL
sl@0
   158
// Handles the message from the proxy and calls the custom interface method.
sl@0
   159
// The data passed from the proxy is read from the message and passed to
sl@0
   160
// the custom interface.
sl@0
   161
// (other items were commented in a header).
sl@0
   162
// -----------------------------------------------------------------------------
sl@0
   163
//
sl@0
   164
void CRa8CustomInterfaceMsgHdlr::DoSetInitStringL(TMMFMessage& aMessage)
sl@0
   165
    {
sl@0
   166
	TInt size = aMessage.SizeOfData1FromClient();
sl@0
   167
	HBufC8* dataBuf = HBufC8::NewL(size);
sl@0
   168
	CleanupStack::PushL( dataBuf );
sl@0
   169
	TPtr8 dataPtr = dataBuf->Des();
sl@0
   170
    aMessage.ReadData1FromClientL(dataPtr);
sl@0
   171
	TInt status = iRa8CustomInterface->SetInitString(dataPtr);
sl@0
   172
	CleanupStack::Pop(dataBuf);
sl@0
   173
	delete dataBuf;
sl@0
   174
    aMessage.Complete(status);
sl@0
   175
    }
sl@0
   176
sl@0
   177
// ========================== OTHER EXPORTED FUNCTIONS =========================
sl@0
   178
sl@0
   179
// End of File