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 "SourceLocationProxy.h"
|
|
28 |
#include "SourceLocationEventObserver.h"
|
|
29 |
#include <CustomInterfaceUtility.h>
|
|
30 |
|
|
31 |
|
|
32 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
33 |
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
// CSourceLocationProxy::CSourceLocationProxy
|
|
36 |
// C++ default constructor can NOT contain any code, that
|
|
37 |
// might leave.
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CSourceLocationProxy::CSourceLocationProxy(
|
|
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 |
CSourceLocationProxy::~CSourceLocationProxy()
|
|
53 |
{
|
|
54 |
// Remove the custom interface message handler before we destroy the proxy.
|
|
55 |
if(iCustomInterfaceUtility)
|
|
56 |
iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
|
|
57 |
delete iSourceLocationEventObserver;
|
|
58 |
delete iCustomInterfaceUtility;
|
|
59 |
}
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// CSourceLocationProxy::NewL
|
|
63 |
// Static function for creating an instance of the SourceLocation object.
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
EXPORT_C CSourceLocationProxy* CSourceLocationProxy::NewL(
|
|
67 |
TMMFMessageDestinationPckg aMessageHandler,
|
|
68 |
MCustomCommand& aCustomCommand,
|
|
69 |
CCustomInterfaceUtility* aCustomInterfaceUtility )
|
|
70 |
{
|
|
71 |
CSourceLocationProxy* self = new (ELeave) CSourceLocationProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
|
|
72 |
CleanupStack::PushL(self);
|
|
73 |
self->ConstructL();
|
|
74 |
CleanupStack::Pop(self);
|
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
// CSourceLocationProxy::ConstructL
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
void CSourceLocationProxy::ConstructL()
|
|
83 |
{
|
|
84 |
iSourceLocationEventObserver = CSourceLocationEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
|
|
85 |
StartObserver();
|
|
86 |
|
|
87 |
TEfLocationDataPckg dataPckgFrom;
|
|
88 |
// sends a message to fetch initial data.
|
|
89 |
iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESlfInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
|
|
90 |
SetEffectData(dataPckgFrom);
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// CSourceLocationProxy::ApplyL
|
|
96 |
// Apply the bassboost settings.
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
EXPORT_C void CSourceLocationProxy::ApplyL()
|
|
100 |
{
|
|
101 |
#ifdef _DEBUG
|
|
102 |
RDebug::Print(_L("CSourceLocationProxy::Apply"));
|
|
103 |
#endif
|
|
104 |
|
|
105 |
if (iHaveUpdateRights )
|
|
106 |
{
|
|
107 |
iLocationData.iEnabled = iEnabled;
|
|
108 |
iLocationData.iEnforced = iEnforced;
|
|
109 |
iLocationData.iHaveUpdateRights = iHaveUpdateRights;
|
|
110 |
|
|
111 |
iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESlfApply, DoEffectData(), KNullDesC8);
|
|
112 |
}
|
|
113 |
else
|
|
114 |
{
|
|
115 |
User::Leave(KErrAccessDenied);
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
// CSourceLocationProxy::StartObserver
|
|
121 |
// Starts the event observer. The event observer monitors asynchronous events
|
|
122 |
// from the message handler.
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
void CSourceLocationProxy::StartObserver()
|
|
126 |
{
|
|
127 |
#ifdef _DEBUG
|
|
128 |
RDebug::Print(_L("CSourceLocationProxy::StartObserver"));
|
|
129 |
#endif
|
|
130 |
|
|
131 |
iSourceLocationEventObserver->Start();
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CSourceLocationProxy::SourceLocationEvent
|
|
136 |
// Checks which data member has changed and notify the observers.
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
void CSourceLocationProxy::SourceLocationEvent(
|
|
140 |
const TDesC8& aBuffer )
|
|
141 |
{
|
|
142 |
#ifdef _DEBUG
|
|
143 |
RDebug::Print(_L("CSourceLocationProxy::SourceLocationEvent"));
|
|
144 |
#endif
|
|
145 |
|
|
146 |
TEfLocationDataPckg dataPckgFrom;
|
|
147 |
dataPckgFrom.Copy(aBuffer);
|
|
148 |
TEfLocation newLocationData = dataPckgFrom();
|
|
149 |
|
|
150 |
TUint8 event = 0;
|
|
151 |
|
|
152 |
if ( newLocationData.iEnabled != iLocationData.iEnabled )
|
|
153 |
{
|
|
154 |
iLocationData.iEnabled = newLocationData.iEnabled;
|
|
155 |
iEnabled = newLocationData.iEnabled;
|
|
156 |
if ( iLocationData.iEnabled )
|
|
157 |
{
|
|
158 |
event = MAudioEffectObserver::KEnabled;
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
event = MAudioEffectObserver::KDisabled;
|
|
163 |
}
|
|
164 |
}
|
|
165 |
else if ( newLocationData.iEnforced != iLocationData.iEnforced )
|
|
166 |
{
|
|
167 |
iLocationData.iEnforced = newLocationData.iEnforced;
|
|
168 |
iEnforced = newLocationData.iEnforced;
|
|
169 |
if ( iLocationData.iEnforced )
|
|
170 |
{
|
|
171 |
event = MAudioEffectObserver::KEnforced;
|
|
172 |
}
|
|
173 |
else
|
|
174 |
{
|
|
175 |
event = MAudioEffectObserver::KNotEnforced;
|
|
176 |
}
|
|
177 |
}
|
|
178 |
else if ( newLocationData.iHaveUpdateRights != iLocationData.iHaveUpdateRights )
|
|
179 |
{
|
|
180 |
iLocationData.iHaveUpdateRights = newLocationData.iHaveUpdateRights;
|
|
181 |
iHaveUpdateRights = newLocationData.iHaveUpdateRights;
|
|
182 |
if ( iLocationData.iHaveUpdateRights )
|
|
183 |
{
|
|
184 |
event = MAudioEffectObserver::KGainedUpdateRights;
|
|
185 |
}
|
|
186 |
else
|
|
187 |
{
|
|
188 |
event = MAudioEffectObserver::KLostUpdateRights;
|
|
189 |
}
|
|
190 |
}
|
|
191 |
else if ( newLocationData.iXCoordinate != iLocationData.iXCoordinate )
|
|
192 |
{
|
|
193 |
iLocationData.iXCoordinate = newLocationData.iXCoordinate;
|
|
194 |
event = MSourceLocationObserver::KLocationCartesianChanged;
|
|
195 |
}
|
|
196 |
else if ( newLocationData.iYCoordinate != iLocationData.iYCoordinate )
|
|
197 |
{
|
|
198 |
iLocationData.iYCoordinate = newLocationData.iYCoordinate;
|
|
199 |
event = MSourceLocationObserver::KLocationCartesianChanged;
|
|
200 |
}
|
|
201 |
else if ( newLocationData.iZCoordinate != iLocationData.iZCoordinate )
|
|
202 |
{
|
|
203 |
iLocationData.iZCoordinate = newLocationData.iZCoordinate;
|
|
204 |
event = MSourceLocationObserver::KLocationCartesianChanged;
|
|
205 |
}
|
|
206 |
else if ( newLocationData.iAzimuth != iLocationData.iAzimuth )
|
|
207 |
{
|
|
208 |
iLocationData.iAzimuth = newLocationData.iAzimuth;
|
|
209 |
event = MSourceLocationObserver::KLocationSphericalChanged;
|
|
210 |
}
|
|
211 |
else if ( newLocationData.iElevation != iLocationData.iElevation )
|
|
212 |
{
|
|
213 |
iLocationData.iElevation = newLocationData.iElevation;
|
|
214 |
event = MSourceLocationObserver::KLocationSphericalChanged;
|
|
215 |
}
|
|
216 |
else if ( newLocationData.iRadius != iLocationData.iRadius )
|
|
217 |
{
|
|
218 |
iLocationData.iRadius = newLocationData.iRadius;
|
|
219 |
event = MSourceLocationObserver::KLocationSphericalChanged;
|
|
220 |
}
|
|
221 |
|
|
222 |
if (!event)
|
|
223 |
return;
|
|
224 |
|
|
225 |
for ( TInt i = 0; i < iObservers.Count(); i++ )
|
|
226 |
{
|
|
227 |
iObservers[i]->EffectChanged(this, event);
|
|
228 |
}
|
|
229 |
}
|
|
230 |
|
|
231 |
|
|
232 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
233 |
|
|
234 |
// End of File
|