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 CRestrictedAudioOutputProxy class. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include 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: CRestrictedAudioOutputProxy::CRestrictedAudioOutputProxy( sl@0: TMMFMessageDestinationPckg aMessageHandler, sl@0: MCustomCommand& aCustomCommand, sl@0: CCustomInterfaceUtility* aCustomInterfaceUtility ) sl@0: : iCustomCommand(&aCustomCommand), sl@0: iMessageHandler(aMessageHandler), sl@0: iCustomInterfaceUtility(aCustomInterfaceUtility), sl@0: iArray(4) sl@0: sl@0: { sl@0: sl@0: } sl@0: sl@0: // Two-phased constructor. sl@0: EXPORT_C CRestrictedAudioOutputProxy* CRestrictedAudioOutputProxy::NewL( sl@0: TMMFMessageDestinationPckg aMessageHandler, sl@0: MCustomCommand& aCustomCommand, sl@0: CCustomInterfaceUtility* aCustomInterfaceUtility) sl@0: { sl@0: sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputProxy::NewL:\n")); sl@0: #endif sl@0: sl@0: sl@0: sl@0: CRestrictedAudioOutputProxy* self = new(ELeave) CRestrictedAudioOutputProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); // Call base class ConstructL sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: sl@0: } sl@0: sl@0: EXPORT_C CRestrictedAudioOutputProxy* CRestrictedAudioOutputProxy::NewL(CMMFDevSound& aDevSound) sl@0: { sl@0: sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputProxy::NewL (DevSound):\n")); sl@0: #endif sl@0: sl@0: CRestrictedAudioOutputProxy* audioOutputProxy = (CRestrictedAudioOutputProxy*)aDevSound.CustomInterface(KUidRestrictedAudioOutput); sl@0: sl@0: if (audioOutputProxy == NULL) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("No Adaptation Support - leaving")); sl@0: #endif sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: return audioOutputProxy; sl@0: sl@0: } sl@0: sl@0: // Destructor sl@0: CRestrictedAudioOutputProxy::~CRestrictedAudioOutputProxy() sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputProxy::~CRestrictedAudioOutputProxy\n")); sl@0: #endif sl@0: sl@0: iArray.Reset(); sl@0: // Remove the custom interface message handler before we destroy the proxy. sl@0: if (iCustomInterfaceUtility) sl@0: { sl@0: iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler); sl@0: } sl@0: delete iCustomInterfaceUtility; sl@0: sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutput::Uid sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C const TUid CRestrictedAudioOutputProxy::Uid() sl@0: { sl@0: return KUidRestrictedAudioOutput; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputProxy::Commit sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C TInt CRestrictedAudioOutputProxy::Commit() sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputProxy::Commit")); sl@0: #endif sl@0: sl@0: TInt count; sl@0: TAllowedOutputPreference pref; sl@0: iArray.Reset(); sl@0: sl@0: TInt err = GetAllowedOutputCount(count); sl@0: sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputProxy::Commit: Current array count = %d"), count); sl@0: #endif sl@0: sl@0: for (TInt i=0; i < count;i++) sl@0: { sl@0: err = GetAllowedOutput(i, pref); sl@0: TRAP(err,iArray.AppendL(pref)); sl@0: } sl@0: sl@0: TInt length = iArray.Length() * count; sl@0: TPtrC8 arrayPtr((const TUint8*)&iArray[0], length); sl@0: TPckgC countPckg(count); sl@0: sl@0: iCustomCommand->CustomCommandSync(iMessageHandler, ERaofCommit, countPckg, arrayPtr ); sl@0: sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: // End of File