0
|
1 |
/*
|
|
2 |
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
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".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Implementation of the bassboost proxy class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
|
|
23 |
#ifdef _DEBUG
|
|
24 |
#include <e32svr.h>
|
|
25 |
#endif
|
|
26 |
|
|
27 |
#include "BassBoostProxy.h"
|
|
28 |
#include "BassBoostEventObserver.h"
|
|
29 |
#include <CustomInterfaceUtility.h>
|
|
30 |
|
|
31 |
|
|
32 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
33 |
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
// CBassBoostProxy::CBassBoostProxy
|
|
36 |
// C++ default constructor can NOT contain any code, that
|
|
37 |
// might leave.
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CBassBoostProxy::CBassBoostProxy(
|
|
41 |
TMMFMessageDestinationPckg aMessageHandler,
|
|
42 |
MCustomCommand& aCustomCommand,
|
|
43 |
CCustomInterfaceUtility* aCustomInterfaceUtility )
|
|
44 |
: iCustomCommand(&aCustomCommand),
|
|
45 |
iMessageHandler(aMessageHandler),
|
|
46 |
iCustomInterfaceUtility(aCustomInterfaceUtility)
|
|
47 |
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
// Destructor
|
|
52 |
CBassBoostProxy::~CBassBoostProxy()
|
|
53 |
{
|
|
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;
|
|
59 |
}
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// CBassBoostProxy::NewL
|
|
63 |
// Static function for creating an instance of the BassBoost object.
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
EXPORT_C CBassBoostProxy* CBassBoostProxy::NewL(
|
|
67 |
TMMFMessageDestinationPckg aMessageHandler,
|
|
68 |
MCustomCommand& aCustomCommand,
|
|
69 |
CCustomInterfaceUtility* aCustomInterfaceUtility )
|
|
70 |
{
|
|
71 |
CBassBoostProxy* self = new (ELeave) CBassBoostProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
|
|
72 |
CleanupStack::PushL(self);
|
|
73 |
self->ConstructL();
|
|
74 |
CleanupStack::Pop(self);
|
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
// CBassBoostProxy::ConstructL
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
void CBassBoostProxy::ConstructL()
|
|
83 |
{
|
|
84 |
iBassBoostEventObserver = CBassBoostEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
|
|
85 |
StartObserver();
|
|
86 |
|
|
87 |
TEfBassBoostDataPckg dataPckgFrom;
|
|
88 |
// sends a message to fetch initial data.
|
|
89 |
iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EBfInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
|
|
90 |
SetEffectData(dataPckgFrom);
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// CBassBoostProxy::ApplyL
|
|
96 |
// Apply the bassboost settings.
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
EXPORT_C void CBassBoostProxy::ApplyL()
|
|
100 |
{
|
|
101 |
#ifdef _DEBUG
|
|
102 |
RDebug::Print(_L("CBassBoostProxy::Apply"));
|
|
103 |
#endif
|
|
104 |
|
|
105 |
if (iHaveUpdateRights )
|
|
106 |
{
|
|
107 |
iBassBoostData.iEnabled = iEnabled;
|
|
108 |
iBassBoostData.iEnforced = iEnforced;
|
|
109 |
iBassBoostData.iHaveUpdateRights = iHaveUpdateRights;
|
|
110 |
|
|
111 |
iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EBfApply, DoEffectData(), KNullDesC8);
|
|
112 |
}
|
|
113 |
else
|
|
114 |
{
|
|
115 |
User::Leave(KErrAccessDenied);
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
// CBassBoostProxy::StartObserver
|
|
121 |
// Starts the event observer. The event observer monitors asynchronous events
|
|
122 |
// from the message handler.
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
void CBassBoostProxy::StartObserver()
|
|
126 |
{
|
|
127 |
#ifdef _DEBUG
|
|
128 |
RDebug::Print(_L("CBassBoostProxy::StartObserver"));
|
|
129 |
#endif
|
|
130 |
|
|
131 |
iBassBoostEventObserver->Start();
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CBassBoostProxy::BassBoostEvent
|
|
136 |
// Checks which data member has changed and notify the observers.
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
void CBassBoostProxy::BassBoostEvent(
|
|
140 |
const TDesC8& aBuffer )
|
|
141 |
{
|
|
142 |
#ifdef _DEBUG
|
|
143 |
RDebug::Print(_L("CBassBoostProxy::BassBoostEvent"));
|
|
144 |
#endif
|
|
145 |
|
|
146 |
TEfBassBoostDataPckg dataPckgFrom;
|
|
147 |
dataPckgFrom.Copy(aBuffer);
|
|
148 |
TEfBassBoostData newBassBoostData = dataPckgFrom();
|
|
149 |
|
|
150 |
TUint8 event = 0;
|
|
151 |
|
|
152 |
if ( newBassBoostData.iEnabled != iBassBoostData.iEnabled )
|
|
153 |
{
|
|
154 |
iBassBoostData.iEnabled = newBassBoostData.iEnabled;
|
|
155 |
iEnabled = newBassBoostData.iEnabled;
|
|
156 |
if ( iBassBoostData.iEnabled )
|
|
157 |
{
|
|
158 |
event = MAudioEffectObserver::KEnabled;
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
event = MAudioEffectObserver::KDisabled;
|
|
163 |
}
|
|
164 |
}
|
|
165 |
else if ( newBassBoostData.iEnforced != iBassBoostData.iEnforced )
|
|
166 |
{
|
|
167 |
iBassBoostData.iEnforced = newBassBoostData.iEnforced;
|
|
168 |
iEnforced = newBassBoostData.iEnforced;
|
|
169 |
if ( iBassBoostData.iEnforced )
|
|
170 |
{
|
|
171 |
event = MAudioEffectObserver::KEnforced;
|
|
172 |
}
|
|
173 |
else
|
|
174 |
{
|
|
175 |
event = MAudioEffectObserver::KNotEnforced;
|
|
176 |
}
|
|
177 |
}
|
|
178 |
else if ( newBassBoostData.iHaveUpdateRights != iBassBoostData.iHaveUpdateRights )
|
|
179 |
{
|
|
180 |
iBassBoostData.iHaveUpdateRights = newBassBoostData.iHaveUpdateRights;
|
|
181 |
iHaveUpdateRights = newBassBoostData.iHaveUpdateRights;
|
|
182 |
if ( iBassBoostData.iHaveUpdateRights )
|
|
183 |
{
|
|
184 |
event = MAudioEffectObserver::KGainedUpdateRights;
|
|
185 |
}
|
|
186 |
else
|
|
187 |
{
|
|
188 |
event = MAudioEffectObserver::KLostUpdateRights;
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
if (!event)
|
|
193 |
return;
|
|
194 |
|
|
195 |
for ( TInt i = 0; i < iObservers.Count(); i++ )
|
|
196 |
{
|
|
197 |
iObservers[i]->EffectChanged(this, event);
|
|
198 |
}
|
|
199 |
}
|
|
200 |
|
|
201 |
|
|
202 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
203 |
|
|
204 |
|