First public contribution.
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Implementation of the bassboost proxy class
27 #include "BassBoostProxy.h"
28 #include "BassBoostEventObserver.h"
29 #include <CustomInterfaceUtility.h>
32 // ============================ MEMBER FUNCTIONS ===============================
34 // -----------------------------------------------------------------------------
35 // CBassBoostProxy::CBassBoostProxy
36 // C++ default constructor can NOT contain any code, that
38 // -----------------------------------------------------------------------------
40 CBassBoostProxy::CBassBoostProxy(
41 TMMFMessageDestinationPckg aMessageHandler,
42 MCustomCommand& aCustomCommand,
43 CCustomInterfaceUtility* aCustomInterfaceUtility )
44 : iCustomCommand(&aCustomCommand),
45 iMessageHandler(aMessageHandler),
46 iCustomInterfaceUtility(aCustomInterfaceUtility)
52 CBassBoostProxy::~CBassBoostProxy()
54 // Remove the custom interface message handler before we destroy the proxy.
55 if(iCustomInterfaceUtility)
56 iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
57 delete iBassBoostEventObserver;
58 delete iCustomInterfaceUtility;
61 // -----------------------------------------------------------------------------
62 // CBassBoostProxy::NewL
63 // Static function for creating an instance of the BassBoost object.
64 // -----------------------------------------------------------------------------
66 EXPORT_C CBassBoostProxy* CBassBoostProxy::NewL(
67 TMMFMessageDestinationPckg aMessageHandler,
68 MCustomCommand& aCustomCommand,
69 CCustomInterfaceUtility* aCustomInterfaceUtility )
71 CBassBoostProxy* self = new (ELeave) CBassBoostProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
72 CleanupStack::PushL(self);
74 CleanupStack::Pop(self);
78 // -----------------------------------------------------------------------------
79 // CBassBoostProxy::ConstructL
80 // -----------------------------------------------------------------------------
82 void CBassBoostProxy::ConstructL()
84 iBassBoostEventObserver = CBassBoostEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
87 TEfBassBoostDataPckg dataPckgFrom;
88 // sends a message to fetch initial data.
89 iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EBfInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
90 SetEffectData(dataPckgFrom);
94 // -----------------------------------------------------------------------------
95 // CBassBoostProxy::ApplyL
96 // Apply the bassboost settings.
97 // -----------------------------------------------------------------------------
99 EXPORT_C void CBassBoostProxy::ApplyL()
102 RDebug::Print(_L("CBassBoostProxy::Apply"));
105 if (iHaveUpdateRights )
107 iBassBoostData.iEnabled = iEnabled;
108 iBassBoostData.iEnforced = iEnforced;
109 iBassBoostData.iHaveUpdateRights = iHaveUpdateRights;
111 iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EBfApply, DoEffectData(), KNullDesC8);
115 User::Leave(KErrAccessDenied);
119 // -----------------------------------------------------------------------------
120 // CBassBoostProxy::StartObserver
121 // Starts the event observer. The event observer monitors asynchronous events
122 // from the message handler.
123 // -----------------------------------------------------------------------------
125 void CBassBoostProxy::StartObserver()
128 RDebug::Print(_L("CBassBoostProxy::StartObserver"));
131 iBassBoostEventObserver->Start();
134 // -----------------------------------------------------------------------------
135 // CBassBoostProxy::BassBoostEvent
136 // Checks which data member has changed and notify the observers.
137 // -----------------------------------------------------------------------------
139 void CBassBoostProxy::BassBoostEvent(
140 const TDesC8& aBuffer )
143 RDebug::Print(_L("CBassBoostProxy::BassBoostEvent"));
146 TEfBassBoostDataPckg dataPckgFrom;
147 dataPckgFrom.Copy(aBuffer);
148 TEfBassBoostData newBassBoostData = dataPckgFrom();
152 if ( newBassBoostData.iEnabled != iBassBoostData.iEnabled )
154 iBassBoostData.iEnabled = newBassBoostData.iEnabled;
155 iEnabled = newBassBoostData.iEnabled;
156 if ( iBassBoostData.iEnabled )
158 event = MAudioEffectObserver::KEnabled;
162 event = MAudioEffectObserver::KDisabled;
165 else if ( newBassBoostData.iEnforced != iBassBoostData.iEnforced )
167 iBassBoostData.iEnforced = newBassBoostData.iEnforced;
168 iEnforced = newBassBoostData.iEnforced;
169 if ( iBassBoostData.iEnforced )
171 event = MAudioEffectObserver::KEnforced;
175 event = MAudioEffectObserver::KNotEnforced;
178 else if ( newBassBoostData.iHaveUpdateRights != iBassBoostData.iHaveUpdateRights )
180 iBassBoostData.iHaveUpdateRights = newBassBoostData.iHaveUpdateRights;
181 iHaveUpdateRights = newBassBoostData.iHaveUpdateRights;
182 if ( iBassBoostData.iHaveUpdateRights )
184 event = MAudioEffectObserver::KGainedUpdateRights;
188 event = MAudioEffectObserver::KLostUpdateRights;
195 for ( TInt i = 0; i < iObservers.Count(); i++ )
197 iObservers[i]->EffectChanged(this, event);
202 // ========================== OTHER EXPORTED FUNCTIONS =========================