os/mm/devsoundextensions/restrictedaudiooutput/RestrictedAudioOutputMessageHandler/src/RestrictedAudioOutputMessageHandler.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/restrictedaudiooutput/RestrictedAudioOutputMessageHandler/src/RestrictedAudioOutputMessageHandler.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,168 @@
1.4 +/*
1.5 +* Copyright (c) 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: This is the implementation of the CRestrictedAudioOutputMessageHandler class.
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +// INCLUDE FILES
1.24 +#include "RestrictedAudioOutput.h"
1.25 +#include "RestrictedAudioOutputMessageHandler.h"
1.26 +#include "RestrictedAudioOutputMessageTypes.h"
1.27 +
1.28 +
1.29 +// ================= MEMBER FUNCTIONS =======================
1.30 +
1.31 +// C++ default constructor can NOT contain any code, that
1.32 +// might leave.
1.33 +//
1.34 +CRestrictedAudioOutputMessageHandler::CRestrictedAudioOutputMessageHandler(CRestrictedAudioOutput* aAudioOutput)
1.35 + : CMMFObject(KUidRestrictedAudioOutput)
1.36 + {
1.37 + iAudioOutput = aAudioOutput;
1.38 + }
1.39 +
1.40 +// Two-phased constructor.
1.41 +EXPORT_C CRestrictedAudioOutputMessageHandler* CRestrictedAudioOutputMessageHandler::NewL(TAny* aCustomInterface)
1.42 + {
1.43 + CRestrictedAudioOutput* audioOutput = (CRestrictedAudioOutput*)aCustomInterface;
1.44 + CRestrictedAudioOutputMessageHandler* self = new (ELeave) CRestrictedAudioOutputMessageHandler(audioOutput);
1.45 +
1.46 + self->ConstructL();
1.47 + return self;
1.48 + }
1.49 +
1.50 +// -----------------------------------------------------------------------------
1.51 +// CRestrictedAudioOutputMessageHandler::ConstructL
1.52 +// Symbian 2nd phase constructor can leave.
1.53 +// -----------------------------------------------------------------------------
1.54 +//
1.55 +void CRestrictedAudioOutputMessageHandler::ConstructL()
1.56 + {
1.57 + }
1.58 +
1.59 +
1.60 +// Destructor
1.61 +CRestrictedAudioOutputMessageHandler::~CRestrictedAudioOutputMessageHandler()
1.62 + {
1.63 + delete iAudioOutput;
1.64 + }
1.65 +
1.66 +
1.67 +// ---------------------------------------------------------
1.68 +// CRestrictedAudioOutputMessageHandler::AudioOutputL
1.69 +// ?implementation_description
1.70 +// (other items were commented in a header).
1.71 +// ---------------------------------------------------------
1.72 +//
1.73 +EXPORT_C TUid CRestrictedAudioOutputMessageHandler::Uid()
1.74 + {
1.75 + return KUidRestrictedAudioOutput;
1.76 + }
1.77 +
1.78 +// ---------------------------------------------------------
1.79 +// CRestrictedAudioOutputMessageHandler::SetAudioOutputL
1.80 +// ?implementation_description
1.81 +// (other items were commented in a header).
1.82 +// ---------------------------------------------------------
1.83 +//
1.84 +void CRestrictedAudioOutputMessageHandler::HandleRequest(TMMFMessage& aMessage)
1.85 + {
1.86 + ASSERT(aMessage.Destination().InterfaceId() == KUidRestrictedAudioOutput);
1.87 + TRAPD(error,DoHandleRequestL(aMessage));
1.88 + if(error)
1.89 + {
1.90 + aMessage.Complete(error);
1.91 + }
1.92 + }
1.93 +
1.94 +// ---------------------------------------------------------
1.95 +// CRestrictedAudioOutputMessageHandler::DoHandleRequestL
1.96 +// ?implementation_description
1.97 +// (other items were commented in a header).
1.98 +// ---------------------------------------------------------
1.99 +//
1.100 +void CRestrictedAudioOutputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage)
1.101 + {
1.102 +
1.103 + switch(aMessage.Function())
1.104 + {
1.105 + case ERaofCommit:
1.106 + {
1.107 + DoCommitL(aMessage);
1.108 + break;
1.109 + }
1.110 + default:
1.111 + {
1.112 + aMessage.Complete(KErrNotSupported);
1.113 + }
1.114 + }
1.115 + }
1.116 +
1.117 +
1.118 +// ---------------------------------------------------------
1.119 +// CRestrictedAudioOutputMessageHandler::DoCommitL
1.120 +// ?implementation_description
1.121 +// (other items were commented in a header).
1.122 +// ---------------------------------------------------------
1.123 +//
1.124 +void CRestrictedAudioOutputMessageHandler::DoCommitL(TMMFMessage& aMessage)
1.125 + {
1.126 +#ifdef _DEBUG
1.127 + RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL"));
1.128 +#endif
1.129 +
1.130 + TPckgBuf<TInt> countPckg;
1.131 + aMessage.ReadData1FromClient(countPckg);
1.132 + TInt count = countPckg();
1.133 +
1.134 +#ifdef _DEBUG
1.135 + RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL Count: %d"),count);
1.136 +#endif
1.137 +
1.138 + CArrayFixFlat<CRestrictedAudioOutput::TAllowedOutputPreference>* outputArray =
1.139 + new(ELeave) CArrayFixFlat<CRestrictedAudioOutput::TAllowedOutputPreference>(4);
1.140 + CleanupStack::PushL(outputArray);
1.141 + outputArray->ResizeL(count);
1.142 +
1.143 + TInt length = count * outputArray->Length();
1.144 + TPtr8 arrayPtr((TUint8*)&(*outputArray)[0],length, length);
1.145 + aMessage.ReadData2FromClient(arrayPtr);
1.146 +
1.147 + CRestrictedAudioOutput::TAllowedOutputPreference pref;
1.148 +
1.149 + TInt err = iAudioOutput->Reset();
1.150 +
1.151 + for (TInt i = 0; i < count; i++)
1.152 + {
1.153 + pref = (outputArray->Array())[i];
1.154 +#ifdef _DEBUG
1.155 + RDebug::Print(_L("DoCommitL Calling Append for: %d"),pref);
1.156 +#endif
1.157 + TInt err = iAudioOutput->AppendAllowedOutput(pref);
1.158 + }
1.159 +
1.160 +#ifdef _DEBUG
1.161 + RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL Calling Commit..."));
1.162 +#endif
1.163 +
1.164 + iAudioOutput->Commit();
1.165 + CleanupStack::PopAndDestroy(); //outputArray
1.166 +
1.167 + aMessage.Complete(KErrNone);
1.168 + }
1.169 +
1.170 +
1.171 +// End of File