sl@0: /* sl@0: * Copyright (c) 2004 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: Implementation of the Source Doppler Proxy class sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: sl@0: #ifdef _DEBUG sl@0: #include sl@0: #endif sl@0: sl@0: #include "SourceDopplerProxy.h" sl@0: #include "SourceDopplerEventObserver.h" sl@0: #include sl@0: sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSourceDopplerProxy::CSourceDopplerProxy sl@0: // C++ default constructor can NOT contain any code, that sl@0: // might leave. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CSourceDopplerProxy::CSourceDopplerProxy( 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: sl@0: { sl@0: } sl@0: sl@0: // Destructor sl@0: CSourceDopplerProxy::~CSourceDopplerProxy() sl@0: { sl@0: // Remove the custom interface message handler before we destroy the proxy. sl@0: if(iCustomInterfaceUtility) sl@0: iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler); sl@0: delete iDopplerEventObserver; sl@0: delete iCustomInterfaceUtility; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSourceDopplerProxy::NewL sl@0: // Static function for creating an instance of the SourceDoppler object. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C CSourceDopplerProxy* CSourceDopplerProxy::NewL( sl@0: TMMFMessageDestinationPckg aMessageHandler, sl@0: MCustomCommand& aCustomCommand, sl@0: CCustomInterfaceUtility* aCustomInterfaceUtility ) sl@0: { sl@0: CSourceDopplerProxy* self = new (ELeave) CSourceDopplerProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility); 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: // CSourceDopplerProxy::ConstructL sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CSourceDopplerProxy::ConstructL() sl@0: { sl@0: iDopplerEventObserver = CSourceDopplerEventObserver::NewL(iMessageHandler, *iCustomCommand, *this); sl@0: StartObserver(); sl@0: sl@0: TEfDopplerDataPckg dataPckgFrom; sl@0: // sends a message to fetch initial data. sl@0: iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESourceDopplerOfInitialize, KNullDesC8, KNullDesC8, dataPckgFrom); sl@0: SetEffectData(dataPckgFrom); sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSourceDopplerProxy::ApplyL sl@0: // Apply the SourceDoppler settings. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: EXPORT_C void CSourceDopplerProxy::ApplyL() sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CSourceDopplerProxy::Apply")); sl@0: #endif sl@0: sl@0: if (iHaveUpdateRights ) sl@0: { sl@0: iDopplerData.iEnabled = iEnabled; sl@0: iDopplerData.iEnforced = iEnforced; sl@0: iDopplerData.iHaveUpdateRights = iHaveUpdateRights; sl@0: sl@0: iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESourceDopplerOfApply, DoEffectData(), KNullDesC8); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrAccessDenied); sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSourceDopplerProxy::StartObserver sl@0: // Starts the event observer. The event observer monitors asynchronous events sl@0: // from the message handler. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CSourceDopplerProxy::StartObserver() sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CSourceDopplerProxy::StartObserver")); sl@0: #endif sl@0: sl@0: iDopplerEventObserver->Start(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CSourceDopplerProxy::DopplerEvent sl@0: // Checks which data member has changed and notify the observers. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CSourceDopplerProxy::SourceDopplerEvent( sl@0: const TDesC8& aBuffer ) sl@0: { sl@0: #ifdef _DEBUG sl@0: RDebug::Print(_L("CSourceDopplerProxy::SourceDopplerEvent")); sl@0: #endif sl@0: sl@0: TEfDopplerDataPckg dataPckgFrom; sl@0: dataPckgFrom.Copy(aBuffer); sl@0: TEfDoppler newDopplerData = dataPckgFrom(); sl@0: sl@0: TUint8 event = 0; sl@0: sl@0: if ( newDopplerData.iEnabled != iDopplerData.iEnabled ) sl@0: { sl@0: iDopplerData.iEnabled = newDopplerData.iEnabled; sl@0: iEnabled = newDopplerData.iEnabled; sl@0: if ( iDopplerData.iEnabled ) sl@0: { sl@0: event = MAudioEffectObserver::KEnabled; sl@0: } sl@0: else sl@0: { sl@0: event = MAudioEffectObserver::KDisabled; sl@0: } sl@0: } sl@0: else if ( newDopplerData.iEnforced != iDopplerData.iEnforced ) sl@0: { sl@0: iDopplerData.iEnforced = newDopplerData.iEnforced; sl@0: iEnforced = newDopplerData.iEnforced; sl@0: if ( iDopplerData.iEnforced ) sl@0: { sl@0: event = MAudioEffectObserver::KEnforced; sl@0: } sl@0: else sl@0: { sl@0: event = MAudioEffectObserver::KNotEnforced; sl@0: } sl@0: } sl@0: else if ( newDopplerData.iHaveUpdateRights != iDopplerData.iHaveUpdateRights ) sl@0: { sl@0: iDopplerData.iHaveUpdateRights = newDopplerData.iHaveUpdateRights; sl@0: iHaveUpdateRights = newDopplerData.iHaveUpdateRights; sl@0: if ( iDopplerData.iHaveUpdateRights ) sl@0: { sl@0: event = MAudioEffectObserver::KGainedUpdateRights; sl@0: } sl@0: else sl@0: { sl@0: event = MAudioEffectObserver::KLostUpdateRights; sl@0: } sl@0: } sl@0: sl@0: else if ( newDopplerData.iVelocityX != iDopplerData.iVelocityX ) sl@0: { sl@0: iDopplerData.iVelocityX = newDopplerData.iVelocityX; sl@0: event = MSourceDopplerObserver::KCartesianVelocityChanged; sl@0: } sl@0: else if ( newDopplerData.iVelocityY != iDopplerData.iVelocityY ) sl@0: { sl@0: iDopplerData.iVelocityY = newDopplerData.iVelocityY; sl@0: event = MSourceDopplerObserver::KCartesianVelocityChanged; sl@0: } sl@0: else if ( newDopplerData.iVelocityZ != iDopplerData.iVelocityZ ) sl@0: { sl@0: iDopplerData.iVelocityZ = newDopplerData.iVelocityZ; sl@0: event = MSourceDopplerObserver::KCartesianVelocityChanged; sl@0: } sl@0: else if ( newDopplerData.iAzimuth != iDopplerData.iAzimuth ) sl@0: { sl@0: iDopplerData.iAzimuth = newDopplerData.iAzimuth; sl@0: event = MSourceDopplerObserver::KSphericalVelocityChanged; sl@0: } sl@0: else if ( newDopplerData.iElevation != iDopplerData.iElevation ) sl@0: { sl@0: iDopplerData.iElevation = newDopplerData.iElevation; sl@0: event = MSourceDopplerObserver::KSphericalVelocityChanged; sl@0: } sl@0: else if ( newDopplerData.iRadius != iDopplerData.iRadius ) sl@0: { sl@0: iDopplerData.iRadius = newDopplerData.iRadius; sl@0: event = MSourceDopplerObserver::KSphericalVelocityChanged; sl@0: } sl@0: else if ( newDopplerData.iFactor != iDopplerData.iFactor ) sl@0: { sl@0: iDopplerData.iFactor = newDopplerData.iFactor; sl@0: event = MSourceDopplerObserver::KFactorChanged; sl@0: } sl@0: else if ( newDopplerData.iMaxFactor != iDopplerData.iMaxFactor ) sl@0: { sl@0: iDopplerData.iMaxFactor = newDopplerData.iMaxFactor; sl@0: event = MSourceDopplerObserver::KMaxFactorChanged; sl@0: } sl@0: sl@0: sl@0: if (!event) sl@0: return; sl@0: sl@0: for ( TInt i = 0; i < iObservers.Count(); i++ ) sl@0: { sl@0: iObservers[i]->EffectChanged(this, event); sl@0: } sl@0: } sl@0: sl@0: sl@0: // ========================== OTHER EXPORTED FUNCTIONS ========================= sl@0: sl@0: // End of File sl@0: