sl@0: /* sl@0: * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: This is the implementation of the CRestrictedAudioOutputMessageHandler class. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include "RestrictedAudioOutput.h" sl@0: #include "RestrictedAudioOutputMessageHandler.h" sl@0: #include "RestrictedAudioOutputMessageTypes.h" sl@0: sl@0: sl@0: // ================= MEMBER FUNCTIONS ======================= sl@0: sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // sl@0: CRestrictedAudioOutputMessageHandler::CRestrictedAudioOutputMessageHandler(CRestrictedAudioOutput* aAudioOutput) sl@0: : CMMFObject(KUidRestrictedAudioOutput) sl@0: { sl@0: iAudioOutput = aAudioOutput; sl@0: } sl@0: sl@0: // Two-phased constructor. sl@0: EXPORT_C CRestrictedAudioOutputMessageHandler* CRestrictedAudioOutputMessageHandler::NewL(TAny* aCustomInterface) sl@0: { sl@0: CRestrictedAudioOutput* audioOutput = (CRestrictedAudioOutput*)aCustomInterface; sl@0: CRestrictedAudioOutputMessageHandler* self = new (ELeave) CRestrictedAudioOutputMessageHandler(audioOutput); sl@0: sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CRestrictedAudioOutputMessageHandler::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CRestrictedAudioOutputMessageHandler::ConstructL() sl@0: { sl@0: } sl@0: sl@0: sl@0: // Destructor sl@0: CRestrictedAudioOutputMessageHandler::~CRestrictedAudioOutputMessageHandler() sl@0: { sl@0: delete iAudioOutput; sl@0: } sl@0: sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputMessageHandler::AudioOutputL sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C TUid CRestrictedAudioOutputMessageHandler::Uid() sl@0: { sl@0: return KUidRestrictedAudioOutput; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputMessageHandler::SetAudioOutputL sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CRestrictedAudioOutputMessageHandler::HandleRequest(TMMFMessage& aMessage) sl@0: { sl@0: ASSERT(aMessage.Destination().InterfaceId() == KUidRestrictedAudioOutput); sl@0: TRAPD(error,DoHandleRequestL(aMessage)); sl@0: if(error) sl@0: { sl@0: aMessage.Complete(error); sl@0: } sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputMessageHandler::DoHandleRequestL sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CRestrictedAudioOutputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage) sl@0: { sl@0: sl@0: switch(aMessage.Function()) sl@0: { sl@0: case ERaofCommit: sl@0: { sl@0: DoCommitL(aMessage); sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: aMessage.Complete(KErrNotSupported); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputMessageHandler::DoCommitL sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CRestrictedAudioOutputMessageHandler::DoCommitL(TMMFMessage& aMessage) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL")); sl@0: #endif sl@0: sl@0: TPckgBuf countPckg; sl@0: aMessage.ReadData1FromClient(countPckg); sl@0: TInt count = countPckg(); sl@0: sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL Count: %d"),count); sl@0: #endif sl@0: sl@0: CArrayFixFlat* outputArray = sl@0: new(ELeave) CArrayFixFlat(4); sl@0: CleanupStack::PushL(outputArray); sl@0: outputArray->ResizeL(count); sl@0: sl@0: TInt length = count * outputArray->Length(); sl@0: TPtr8 arrayPtr((TUint8*)&(*outputArray)[0],length, length); sl@0: aMessage.ReadData2FromClient(arrayPtr); sl@0: sl@0: CRestrictedAudioOutput::TAllowedOutputPreference pref; sl@0: sl@0: TInt err = iAudioOutput->Reset(); sl@0: sl@0: for (TInt i = 0; i < count; i++) sl@0: { sl@0: pref = (outputArray->Array())[i]; sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("DoCommitL Calling Append for: %d"),pref); sl@0: #endif sl@0: TInt err = iAudioOutput->AppendAllowedOutput(pref); sl@0: } sl@0: sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL Calling Commit...")); sl@0: #endif sl@0: sl@0: iAudioOutput->Commit(); sl@0: CleanupStack::PopAndDestroy(); //outputArray sl@0: sl@0: aMessage.Complete(KErrNone); sl@0: } sl@0: sl@0: sl@0: // End of File