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 CRestrictedAudioOutputImpl class. sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include sl@0: #include "RestrictedAudioOutputImpl.h" sl@0: sl@0: #ifdef _DEBUG sl@0: #define DEBPRN0(str) RDebug::Print(str, this) sl@0: #define DEBPRN1(str) RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str ); sl@0: #else sl@0: #define DEBPRN0 sl@0: #define DEBPRN1(str) sl@0: #endif sl@0: sl@0: const TInt KGranularity=20; sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::CRestrictedAudioOutputImpl sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CRestrictedAudioOutputImpl::CRestrictedAudioOutputImpl() sl@0: : iAllowedOutputPrefArray(KGranularity) sl@0: { sl@0: DEBPRN0(_L("CRestrictedAudioOutputImpl::[0x%x]::CRestrictedAudioOutputImpl\n")); sl@0: iAllowedOutputPrefArray.Reset(); sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: // assumes that iParent has already been set up properly sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CRestrictedAudioOutputImpl::ConstructL() sl@0: { sl@0: sl@0: } sl@0: sl@0: sl@0: // Two-phased constructor. sl@0: CRestrictedAudioOutputImpl* CRestrictedAudioOutputImpl::NewL() sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputImpl::NewL\n")); sl@0: #endif sl@0: sl@0: CRestrictedAudioOutputImpl* self = new(ELeave) CRestrictedAudioOutputImpl(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::~CRestrictedAudioOutputImpl sl@0: // Destructor sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CRestrictedAudioOutputImpl::~CRestrictedAudioOutputImpl() sl@0: { sl@0: DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::~CRestrictedAudioOutputImpl\n")); sl@0: sl@0: iAllowedOutputPrefArray.Close(); sl@0: sl@0: DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::~CRestrictedAudioOutputImpl:EXIT")); sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::AppendAllowedOutput sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: TInt CRestrictedAudioOutputImpl::AppendAllowedOutput( CRestrictedAudioOutput::TAllowedOutputPreference aOutput) sl@0: { sl@0: DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::AppendAllowedOutput\n")); sl@0: sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("Append Output: %d\n"), aOutput); sl@0: #endif sl@0: sl@0: // Check to see if it's in array already sl@0: TBool found = ExistsInArray(aOutput); sl@0: if (found) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("Append Output ERROR. Output already in List\n")); sl@0: #endif sl@0: return KErrAlreadyExists; sl@0: } sl@0: sl@0: TInt err = KErrNone; sl@0: TRAP(err,iAllowedOutputPrefArray.AppendL(aOutput)); sl@0: if (err != KErrNone) sl@0: return err; sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::RemoveAllowedOutput sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: TInt CRestrictedAudioOutputImpl::RemoveAllowedOutput(CRestrictedAudioOutput::TAllowedOutputPreference aOutput) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("Remove Output: %d\n"), aOutput); sl@0: #endif sl@0: sl@0: // Make sure it's in list sl@0: TBool found = ExistsInArray(aOutput); sl@0: if (!found) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("Remove Output ERROR. Output not in List\n")); sl@0: #endif sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: for (TInt i = 0; i < iAllowedOutputPrefArray.Count(); i++) sl@0: { sl@0: if (iAllowedOutputPrefArray[i] == aOutput) sl@0: { sl@0: iAllowedOutputPrefArray.Remove(i); sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("RemoveAllowedOutput: Item Removed\n")); sl@0: #endif sl@0: break; sl@0: } sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::GetAllowedOutput sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: TInt CRestrictedAudioOutputImpl::GetAllowedOutput(TInt aIndex, CRestrictedAudioOutput::TAllowedOutputPreference& aOutput) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputImpl::GetAllowedOutput for index: %d\n"), aIndex); sl@0: #endif sl@0: sl@0: // Verify aIndex valid: sl@0: if (aIndex >= iAllowedOutputPrefArray.Count()) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("GetAllowedOutput ERROR. Invalid Index: %d\n"),aIndex); sl@0: #endif sl@0: return KErrNotFound; sl@0: } sl@0: aOutput = iAllowedOutputPrefArray[aIndex]; sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("GetAllowedOutput: Returning %d\n"),aOutput); sl@0: #endif sl@0: return KErrNone; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::GetAllowedOutputCount sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: TInt CRestrictedAudioOutputImpl::GetAllowedOutputCount(TInt& aSize) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CRestrictedAudioOutputImpl::GetAllowedOutputCount\n")); sl@0: #endif sl@0: aSize = iAllowedOutputPrefArray.Count(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::Reset sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: TInt CRestrictedAudioOutputImpl::Reset() sl@0: { sl@0: iAllowedOutputPrefArray.Reset(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::Commit sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: TInt CRestrictedAudioOutputImpl::Commit() sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CRestrictedAudioOutputImpl::ExistsInArray sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: TBool CRestrictedAudioOutputImpl::ExistsInArray(CRestrictedAudioOutput::TAllowedOutputPreference& aOutput) sl@0: { sl@0: sl@0: for (TInt i = 0; i < iAllowedOutputPrefArray.Count(); i++) sl@0: { sl@0: if (iAllowedOutputPrefArray[i] == aOutput) sl@0: return ETrue; sl@0: } sl@0: sl@0: return EFalse; sl@0: } sl@0: sl@0: // End of file sl@0: