sl@0: /* sl@0: * Copyright (c) 2006 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: Audio output proxy implementation sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include "AudioOutput.h" sl@0: #include "AudioOutputProxyAO.h" sl@0: #include "AudioOutputProxy.h" sl@0: #include "AudioOutputMessageTypes.h" sl@0: #include sl@0: #include "CustomInterfaceUtility.h" sl@0: sl@0: 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: CAudioOutputProxy::CAudioOutputProxy(TMMFMessageDestinationPckg aMessageHandler, sl@0: MCustomCommand& aCustomCommand, sl@0: CCustomInterfaceUtility* aCustomInterfaceUtility) : sl@0: iCustomCommand(&aCustomCommand), sl@0: iMessageHandler(aMessageHandler), sl@0: iCustomInterfaceUtility(aCustomInterfaceUtility) sl@0: { sl@0: iOutput = ENoPreference; sl@0: iDefaultOutput = ENoPreference; sl@0: iSecureOutput = EFalse; sl@0: iRegistered = EFalse; sl@0: } sl@0: sl@0: // Two-phased constructor. sl@0: EXPORT_C CAudioOutputProxy* CAudioOutputProxy::NewL(TMMFMessageDestinationPckg aMessageHandler, sl@0: MCustomCommand& aCustomCommand, sl@0: CCustomInterfaceUtility* aCustomInterfaceUtility) sl@0: { sl@0: CAudioOutputProxy* self = new(ELeave) CAudioOutputProxy(aMessageHandler,aCustomCommand,aCustomInterfaceUtility); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CAudioOutputProxy::ConstructL sl@0: // Symbian 2nd phase constructor can leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CAudioOutputProxy::ConstructL() sl@0: { sl@0: } sl@0: sl@0: // Destructor sl@0: CAudioOutputProxy::~CAudioOutputProxy() sl@0: { sl@0: if (iRegistered != EFalse) sl@0: { sl@0: if(iObserver) sl@0: UnregisterObserver(*iObserver); sl@0: } sl@0: sl@0: if (iCustomCommand) sl@0: { sl@0: iCustomCommand->CustomCommandSync(iMessageHandler, EAofDelete, KNullDesC8, KNullDesC8); sl@0: } sl@0: sl@0: if(iAsyncSender) sl@0: { sl@0: delete iAsyncSender; sl@0: iAsyncSender = NULL; sl@0: } sl@0: sl@0: if(iCustomInterfaceUtility) sl@0: { sl@0: iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler); sl@0: delete iCustomInterfaceUtility; sl@0: iCustomInterfaceUtility = NULL; sl@0: } sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CAudioOutput::Uid sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: EXPORT_C const TUid CAudioOutputProxy::Uid() sl@0: { sl@0: return KUidAudioOutput; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CAudioOutput::AudioOutput sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: CAudioOutput::TAudioOutputPreference CAudioOutputProxy::AudioOutput() sl@0: { sl@0: sl@0: TPckgBuf outPutPckg; sl@0: TInt error = iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EAofGetAudioOutput, KNullDesC8, KNullDesC8, outPutPckg); sl@0: sl@0: if (KErrNone == error) sl@0: iOutput = outPutPckg(); sl@0: else sl@0: iOutput = ENoPreference; sl@0: sl@0: return iOutput; sl@0: } sl@0: // --------------------------------------------------------- sl@0: // CAudioOutput::DefaultAudioOutput sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: CAudioOutput::TAudioOutputPreference CAudioOutputProxy::DefaultAudioOutput() sl@0: { sl@0: return iDefaultOutput; sl@0: } sl@0: // --------------------------------------------------------- sl@0: // CAudioOutput::RegisterObserverL sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CAudioOutputProxy::RegisterObserverL(MAudioOutputObserver& aObserver) sl@0: { sl@0: if(iRegistered) sl@0: { sl@0: iObserver = &aObserver; sl@0: iAsyncSender->SetObserver(aObserver); sl@0: } sl@0: else sl@0: { sl@0: iRegistered = ETrue; sl@0: iObserver = &aObserver; sl@0: delete iAsyncSender; sl@0: iAsyncSender = NULL; sl@0: sl@0: iAsyncSender = CAudioOutputProxyAO::NewL(this,aObserver,iCustomCommand); sl@0: iAsyncSender->SetRegisterFlag(ETrue); sl@0: iAsyncSender->SendAsyncMessage(iMessageHandler,EAofRegisterObserver); sl@0: } sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CAudioOutput::SecureOutput sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: TBool CAudioOutputProxy::SecureOutput() sl@0: { sl@0: return iSecureOutput; sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CAudioOutput::SetAudioOutputL sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CAudioOutputProxy::SetAudioOutputL(TAudioOutputPreference aAudioOutput) sl@0: { sl@0: iOutput = aAudioOutput; sl@0: TPckgC outputPckg(aAudioOutput); sl@0: iCustomCommand->CustomCommandSync(iMessageHandler, EAofSetAudioOutput, outputPckg, KNullDesC8); sl@0: } sl@0: // --------------------------------------------------------- sl@0: // CAudioOutput::SetAudioOutputL sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CAudioOutputProxy::SetSecureOutputL(TBool aSecureOutput) sl@0: { sl@0: iSecureOutput = aSecureOutput; sl@0: TPckgC outputPckg(aSecureOutput); sl@0: TInt err = KErrNone; sl@0: //ou1cimx1#454515 CAudioOutputConfigurator::SetSecureOutputL() is deprecated sl@0: err = iCustomCommand->CustomCommandSync(iMessageHandler, EAofSetSecureOutput, outputPckg, KNullDesC8); sl@0: if(err != KErrNone) sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: sl@0: } sl@0: sl@0: // --------------------------------------------------------- sl@0: // CAudioOutput::RegisterObserverL sl@0: // ?implementation_description sl@0: // (other items were commented in a header). sl@0: // --------------------------------------------------------- sl@0: // sl@0: void CAudioOutputProxy::UnregisterObserver(MAudioOutputObserver& aObserver) sl@0: { sl@0: iRegistered = EFalse; sl@0: if (iObserver == &aObserver) sl@0: { sl@0: if (iAsyncSender) sl@0: { sl@0: iAsyncSender->SetRegisterFlag(EFalse); sl@0: iCustomCommand->CustomCommandSync(iMessageHandler, EAofUnregisterObserver, KNullDesC8, KNullDesC8); sl@0: iObserver = NULL; sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: // ========================== OTHER EXPORTED FUNCTIONS ========================= sl@0: sl@0: sl@0: sl@0: // End of File