sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description: Implementation of the Source Doppler Proxy class
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
// INCLUDE FILES
|
sl@0
|
22 |
|
sl@0
|
23 |
#ifdef _DEBUG
|
sl@0
|
24 |
#include <e32svr.h>
|
sl@0
|
25 |
#endif
|
sl@0
|
26 |
|
sl@0
|
27 |
#include "SourceDopplerProxy.h"
|
sl@0
|
28 |
#include "SourceDopplerEventObserver.h"
|
sl@0
|
29 |
#include <CustomInterfaceUtility.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
// ============================ MEMBER FUNCTIONS ===============================
|
sl@0
|
33 |
|
sl@0
|
34 |
// -----------------------------------------------------------------------------
|
sl@0
|
35 |
// CSourceDopplerProxy::CSourceDopplerProxy
|
sl@0
|
36 |
// C++ default constructor can NOT contain any code, that
|
sl@0
|
37 |
// might leave.
|
sl@0
|
38 |
// -----------------------------------------------------------------------------
|
sl@0
|
39 |
//
|
sl@0
|
40 |
CSourceDopplerProxy::CSourceDopplerProxy(
|
sl@0
|
41 |
TMMFMessageDestinationPckg aMessageHandler,
|
sl@0
|
42 |
MCustomCommand& aCustomCommand,
|
sl@0
|
43 |
CCustomInterfaceUtility* aCustomInterfaceUtility )
|
sl@0
|
44 |
: iCustomCommand(&aCustomCommand),
|
sl@0
|
45 |
iMessageHandler(aMessageHandler),
|
sl@0
|
46 |
iCustomInterfaceUtility(aCustomInterfaceUtility)
|
sl@0
|
47 |
|
sl@0
|
48 |
{
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
// Destructor
|
sl@0
|
52 |
CSourceDopplerProxy::~CSourceDopplerProxy()
|
sl@0
|
53 |
{
|
sl@0
|
54 |
// Remove the custom interface message handler before we destroy the proxy.
|
sl@0
|
55 |
if(iCustomInterfaceUtility)
|
sl@0
|
56 |
iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
|
sl@0
|
57 |
delete iDopplerEventObserver;
|
sl@0
|
58 |
delete iCustomInterfaceUtility;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
// -----------------------------------------------------------------------------
|
sl@0
|
62 |
// CSourceDopplerProxy::NewL
|
sl@0
|
63 |
// Static function for creating an instance of the SourceDoppler object.
|
sl@0
|
64 |
// -----------------------------------------------------------------------------
|
sl@0
|
65 |
//
|
sl@0
|
66 |
EXPORT_C CSourceDopplerProxy* CSourceDopplerProxy::NewL(
|
sl@0
|
67 |
TMMFMessageDestinationPckg aMessageHandler,
|
sl@0
|
68 |
MCustomCommand& aCustomCommand,
|
sl@0
|
69 |
CCustomInterfaceUtility* aCustomInterfaceUtility )
|
sl@0
|
70 |
{
|
sl@0
|
71 |
CSourceDopplerProxy* self = new (ELeave) CSourceDopplerProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
|
sl@0
|
72 |
CleanupStack::PushL(self);
|
sl@0
|
73 |
self->ConstructL();
|
sl@0
|
74 |
CleanupStack::Pop(self);
|
sl@0
|
75 |
return self;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
// -----------------------------------------------------------------------------
|
sl@0
|
79 |
// CSourceDopplerProxy::ConstructL
|
sl@0
|
80 |
// -----------------------------------------------------------------------------
|
sl@0
|
81 |
//
|
sl@0
|
82 |
void CSourceDopplerProxy::ConstructL()
|
sl@0
|
83 |
{
|
sl@0
|
84 |
iDopplerEventObserver = CSourceDopplerEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
|
sl@0
|
85 |
StartObserver();
|
sl@0
|
86 |
|
sl@0
|
87 |
TEfDopplerDataPckg dataPckgFrom;
|
sl@0
|
88 |
// sends a message to fetch initial data.
|
sl@0
|
89 |
iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESourceDopplerOfInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
|
sl@0
|
90 |
SetEffectData(dataPckgFrom);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
|
sl@0
|
94 |
// -----------------------------------------------------------------------------
|
sl@0
|
95 |
// CSourceDopplerProxy::ApplyL
|
sl@0
|
96 |
// Apply the SourceDoppler settings.
|
sl@0
|
97 |
// -----------------------------------------------------------------------------
|
sl@0
|
98 |
//
|
sl@0
|
99 |
EXPORT_C void CSourceDopplerProxy::ApplyL()
|
sl@0
|
100 |
{
|
sl@0
|
101 |
#ifdef _DEBUG
|
sl@0
|
102 |
RDebug::Print(_L("CSourceDopplerProxy::Apply"));
|
sl@0
|
103 |
#endif
|
sl@0
|
104 |
|
sl@0
|
105 |
if (iHaveUpdateRights )
|
sl@0
|
106 |
{
|
sl@0
|
107 |
iDopplerData.iEnabled = iEnabled;
|
sl@0
|
108 |
iDopplerData.iEnforced = iEnforced;
|
sl@0
|
109 |
iDopplerData.iHaveUpdateRights = iHaveUpdateRights;
|
sl@0
|
110 |
|
sl@0
|
111 |
iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESourceDopplerOfApply, DoEffectData(), KNullDesC8);
|
sl@0
|
112 |
}
|
sl@0
|
113 |
else
|
sl@0
|
114 |
{
|
sl@0
|
115 |
User::Leave(KErrAccessDenied);
|
sl@0
|
116 |
}
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
// -----------------------------------------------------------------------------
|
sl@0
|
120 |
// CSourceDopplerProxy::StartObserver
|
sl@0
|
121 |
// Starts the event observer. The event observer monitors asynchronous events
|
sl@0
|
122 |
// from the message handler.
|
sl@0
|
123 |
// -----------------------------------------------------------------------------
|
sl@0
|
124 |
//
|
sl@0
|
125 |
void CSourceDopplerProxy::StartObserver()
|
sl@0
|
126 |
{
|
sl@0
|
127 |
#ifdef _DEBUG
|
sl@0
|
128 |
RDebug::Print(_L("CSourceDopplerProxy::StartObserver"));
|
sl@0
|
129 |
#endif
|
sl@0
|
130 |
|
sl@0
|
131 |
iDopplerEventObserver->Start();
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
// -----------------------------------------------------------------------------
|
sl@0
|
135 |
// CSourceDopplerProxy::DopplerEvent
|
sl@0
|
136 |
// Checks which data member has changed and notify the observers.
|
sl@0
|
137 |
// -----------------------------------------------------------------------------
|
sl@0
|
138 |
//
|
sl@0
|
139 |
void CSourceDopplerProxy::SourceDopplerEvent(
|
sl@0
|
140 |
const TDesC8& aBuffer )
|
sl@0
|
141 |
{
|
sl@0
|
142 |
#ifdef _DEBUG
|
sl@0
|
143 |
RDebug::Print(_L("CSourceDopplerProxy::SourceDopplerEvent"));
|
sl@0
|
144 |
#endif
|
sl@0
|
145 |
|
sl@0
|
146 |
TEfDopplerDataPckg dataPckgFrom;
|
sl@0
|
147 |
dataPckgFrom.Copy(aBuffer);
|
sl@0
|
148 |
TEfDoppler newDopplerData = dataPckgFrom();
|
sl@0
|
149 |
|
sl@0
|
150 |
TUint8 event = 0;
|
sl@0
|
151 |
|
sl@0
|
152 |
if ( newDopplerData.iEnabled != iDopplerData.iEnabled )
|
sl@0
|
153 |
{
|
sl@0
|
154 |
iDopplerData.iEnabled = newDopplerData.iEnabled;
|
sl@0
|
155 |
iEnabled = newDopplerData.iEnabled;
|
sl@0
|
156 |
if ( iDopplerData.iEnabled )
|
sl@0
|
157 |
{
|
sl@0
|
158 |
event = MAudioEffectObserver::KEnabled;
|
sl@0
|
159 |
}
|
sl@0
|
160 |
else
|
sl@0
|
161 |
{
|
sl@0
|
162 |
event = MAudioEffectObserver::KDisabled;
|
sl@0
|
163 |
}
|
sl@0
|
164 |
}
|
sl@0
|
165 |
else if ( newDopplerData.iEnforced != iDopplerData.iEnforced )
|
sl@0
|
166 |
{
|
sl@0
|
167 |
iDopplerData.iEnforced = newDopplerData.iEnforced;
|
sl@0
|
168 |
iEnforced = newDopplerData.iEnforced;
|
sl@0
|
169 |
if ( iDopplerData.iEnforced )
|
sl@0
|
170 |
{
|
sl@0
|
171 |
event = MAudioEffectObserver::KEnforced;
|
sl@0
|
172 |
}
|
sl@0
|
173 |
else
|
sl@0
|
174 |
{
|
sl@0
|
175 |
event = MAudioEffectObserver::KNotEnforced;
|
sl@0
|
176 |
}
|
sl@0
|
177 |
}
|
sl@0
|
178 |
else if ( newDopplerData.iHaveUpdateRights != iDopplerData.iHaveUpdateRights )
|
sl@0
|
179 |
{
|
sl@0
|
180 |
iDopplerData.iHaveUpdateRights = newDopplerData.iHaveUpdateRights;
|
sl@0
|
181 |
iHaveUpdateRights = newDopplerData.iHaveUpdateRights;
|
sl@0
|
182 |
if ( iDopplerData.iHaveUpdateRights )
|
sl@0
|
183 |
{
|
sl@0
|
184 |
event = MAudioEffectObserver::KGainedUpdateRights;
|
sl@0
|
185 |
}
|
sl@0
|
186 |
else
|
sl@0
|
187 |
{
|
sl@0
|
188 |
event = MAudioEffectObserver::KLostUpdateRights;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
}
|
sl@0
|
191 |
|
sl@0
|
192 |
else if ( newDopplerData.iVelocityX != iDopplerData.iVelocityX )
|
sl@0
|
193 |
{
|
sl@0
|
194 |
iDopplerData.iVelocityX = newDopplerData.iVelocityX;
|
sl@0
|
195 |
event = MSourceDopplerObserver::KCartesianVelocityChanged;
|
sl@0
|
196 |
}
|
sl@0
|
197 |
else if ( newDopplerData.iVelocityY != iDopplerData.iVelocityY )
|
sl@0
|
198 |
{
|
sl@0
|
199 |
iDopplerData.iVelocityY = newDopplerData.iVelocityY;
|
sl@0
|
200 |
event = MSourceDopplerObserver::KCartesianVelocityChanged;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
else if ( newDopplerData.iVelocityZ != iDopplerData.iVelocityZ )
|
sl@0
|
203 |
{
|
sl@0
|
204 |
iDopplerData.iVelocityZ = newDopplerData.iVelocityZ;
|
sl@0
|
205 |
event = MSourceDopplerObserver::KCartesianVelocityChanged;
|
sl@0
|
206 |
}
|
sl@0
|
207 |
else if ( newDopplerData.iAzimuth != iDopplerData.iAzimuth )
|
sl@0
|
208 |
{
|
sl@0
|
209 |
iDopplerData.iAzimuth = newDopplerData.iAzimuth;
|
sl@0
|
210 |
event = MSourceDopplerObserver::KSphericalVelocityChanged;
|
sl@0
|
211 |
}
|
sl@0
|
212 |
else if ( newDopplerData.iElevation != iDopplerData.iElevation )
|
sl@0
|
213 |
{
|
sl@0
|
214 |
iDopplerData.iElevation = newDopplerData.iElevation;
|
sl@0
|
215 |
event = MSourceDopplerObserver::KSphericalVelocityChanged;
|
sl@0
|
216 |
}
|
sl@0
|
217 |
else if ( newDopplerData.iRadius != iDopplerData.iRadius )
|
sl@0
|
218 |
{
|
sl@0
|
219 |
iDopplerData.iRadius = newDopplerData.iRadius;
|
sl@0
|
220 |
event = MSourceDopplerObserver::KSphericalVelocityChanged;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
else if ( newDopplerData.iFactor != iDopplerData.iFactor )
|
sl@0
|
223 |
{
|
sl@0
|
224 |
iDopplerData.iFactor = newDopplerData.iFactor;
|
sl@0
|
225 |
event = MSourceDopplerObserver::KFactorChanged;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
else if ( newDopplerData.iMaxFactor != iDopplerData.iMaxFactor )
|
sl@0
|
228 |
{
|
sl@0
|
229 |
iDopplerData.iMaxFactor = newDopplerData.iMaxFactor;
|
sl@0
|
230 |
event = MSourceDopplerObserver::KMaxFactorChanged;
|
sl@0
|
231 |
}
|
sl@0
|
232 |
|
sl@0
|
233 |
|
sl@0
|
234 |
if (!event)
|
sl@0
|
235 |
return;
|
sl@0
|
236 |
|
sl@0
|
237 |
for ( TInt i = 0; i < iObservers.Count(); i++ )
|
sl@0
|
238 |
{
|
sl@0
|
239 |
iObservers[i]->EffectChanged(this, event);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
|
sl@0
|
244 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
sl@0
|
245 |
|
sl@0
|
246 |
// End of File
|
sl@0
|
247 |
|