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 bassboost 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 "SourceOrientationProxy.h"
|
sl@0
|
28 |
#include "SourceOrientationEventObserver.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 |
// CSourceOrientationProxy::CSourceOrientationProxy
|
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 |
CSourceOrientationProxy::CSourceOrientationProxy(
|
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 |
CSourceOrientationProxy::~CSourceOrientationProxy()
|
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 iSourceOrientationEventObserver;
|
sl@0
|
58 |
delete iCustomInterfaceUtility;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
// -----------------------------------------------------------------------------
|
sl@0
|
62 |
// CSourceOrientationProxy::NewL
|
sl@0
|
63 |
// Static function for creating an instance of the SourceOrientation object.
|
sl@0
|
64 |
// -----------------------------------------------------------------------------
|
sl@0
|
65 |
//
|
sl@0
|
66 |
EXPORT_C CSourceOrientationProxy* CSourceOrientationProxy::NewL(
|
sl@0
|
67 |
TMMFMessageDestinationPckg aMessageHandler,
|
sl@0
|
68 |
MCustomCommand& aCustomCommand,
|
sl@0
|
69 |
CCustomInterfaceUtility* aCustomInterfaceUtility )
|
sl@0
|
70 |
{
|
sl@0
|
71 |
CSourceOrientationProxy* self = new (ELeave) CSourceOrientationProxy(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 |
// CSourceOrientationProxy::ConstructL
|
sl@0
|
80 |
// -----------------------------------------------------------------------------
|
sl@0
|
81 |
//
|
sl@0
|
82 |
void CSourceOrientationProxy::ConstructL()
|
sl@0
|
83 |
{
|
sl@0
|
84 |
iSourceOrientationEventObserver = CSourceOrientationEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
|
sl@0
|
85 |
StartObserver();
|
sl@0
|
86 |
|
sl@0
|
87 |
TEfOrientationDataPckg dataPckgFrom;
|
sl@0
|
88 |
// sends a message to fetch initial data.
|
sl@0
|
89 |
iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESofInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
|
sl@0
|
90 |
SetEffectData(dataPckgFrom);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
|
sl@0
|
94 |
// -----------------------------------------------------------------------------
|
sl@0
|
95 |
// CSourceOrientationProxy::ApplyL
|
sl@0
|
96 |
// Apply the bassboost settings.
|
sl@0
|
97 |
// -----------------------------------------------------------------------------
|
sl@0
|
98 |
//
|
sl@0
|
99 |
EXPORT_C void CSourceOrientationProxy::ApplyL()
|
sl@0
|
100 |
{
|
sl@0
|
101 |
#ifdef _DEBUG
|
sl@0
|
102 |
RDebug::Print(_L("CSourceOrientationProxy::Apply"));
|
sl@0
|
103 |
#endif
|
sl@0
|
104 |
|
sl@0
|
105 |
if (iHaveUpdateRights )
|
sl@0
|
106 |
{
|
sl@0
|
107 |
iOrientationData.iEnabled = iEnabled;
|
sl@0
|
108 |
iOrientationData.iEnforced = iEnforced;
|
sl@0
|
109 |
iOrientationData.iHaveUpdateRights = iHaveUpdateRights;
|
sl@0
|
110 |
|
sl@0
|
111 |
iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESofApply, 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 |
// CSourceOrientationProxy::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 CSourceOrientationProxy::StartObserver()
|
sl@0
|
126 |
{
|
sl@0
|
127 |
#ifdef _DEBUG
|
sl@0
|
128 |
RDebug::Print(_L("CSourceOrientationProxy::StartObserver"));
|
sl@0
|
129 |
#endif
|
sl@0
|
130 |
|
sl@0
|
131 |
iSourceOrientationEventObserver->Start();
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
// -----------------------------------------------------------------------------
|
sl@0
|
135 |
// CSourceOrientationProxy::SourceOrientationEvent
|
sl@0
|
136 |
// Checks which data member has changed and notify the observers.
|
sl@0
|
137 |
// -----------------------------------------------------------------------------
|
sl@0
|
138 |
//
|
sl@0
|
139 |
void CSourceOrientationProxy::SourceOrientationEvent(
|
sl@0
|
140 |
const TDesC8& aBuffer )
|
sl@0
|
141 |
{
|
sl@0
|
142 |
#ifdef _DEBUG
|
sl@0
|
143 |
RDebug::Print(_L("CSourceOrientationProxy::SourceOrientationEvent"));
|
sl@0
|
144 |
#endif
|
sl@0
|
145 |
|
sl@0
|
146 |
TEfOrientationDataPckg dataPckgFrom;
|
sl@0
|
147 |
dataPckgFrom.Copy(aBuffer);
|
sl@0
|
148 |
TEfOrientation newOrientationData = dataPckgFrom();
|
sl@0
|
149 |
|
sl@0
|
150 |
TUint8 event = 0;
|
sl@0
|
151 |
|
sl@0
|
152 |
if ( newOrientationData.iEnabled != iOrientationData.iEnabled )
|
sl@0
|
153 |
{
|
sl@0
|
154 |
iOrientationData.iEnabled = newOrientationData.iEnabled;
|
sl@0
|
155 |
iEnabled = newOrientationData.iEnabled;
|
sl@0
|
156 |
if ( iOrientationData.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 ( newOrientationData.iEnforced != iOrientationData.iEnforced )
|
sl@0
|
166 |
{
|
sl@0
|
167 |
iOrientationData.iEnforced = newOrientationData.iEnforced;
|
sl@0
|
168 |
iEnforced = newOrientationData.iEnforced;
|
sl@0
|
169 |
if ( iOrientationData.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 ( newOrientationData.iHaveUpdateRights != iOrientationData.iHaveUpdateRights )
|
sl@0
|
179 |
{
|
sl@0
|
180 |
iOrientationData.iHaveUpdateRights = newOrientationData.iHaveUpdateRights;
|
sl@0
|
181 |
iHaveUpdateRights = newOrientationData.iHaveUpdateRights;
|
sl@0
|
182 |
if ( iOrientationData.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 |
else if ( newOrientationData.iHeading != iOrientationData.iHeading )
|
sl@0
|
192 |
{
|
sl@0
|
193 |
iOrientationData.iHeading = newOrientationData.iHeading;
|
sl@0
|
194 |
event = MSourceOrientationObserver::KOrientationChanged;
|
sl@0
|
195 |
}
|
sl@0
|
196 |
else if ( newOrientationData.iPitch != iOrientationData.iPitch )
|
sl@0
|
197 |
{
|
sl@0
|
198 |
iOrientationData.iPitch = newOrientationData.iPitch;
|
sl@0
|
199 |
event = MSourceOrientationObserver::KOrientationChanged;
|
sl@0
|
200 |
}
|
sl@0
|
201 |
else if ( newOrientationData.iRoll != iOrientationData.iRoll )
|
sl@0
|
202 |
{
|
sl@0
|
203 |
iOrientationData.iRoll = newOrientationData.iRoll;
|
sl@0
|
204 |
event = MSourceOrientationObserver::KOrientationChanged;
|
sl@0
|
205 |
}
|
sl@0
|
206 |
else if ( newOrientationData.iFrontX != iOrientationData.iFrontX )
|
sl@0
|
207 |
{
|
sl@0
|
208 |
iOrientationData.iFrontX = newOrientationData.iFrontX;
|
sl@0
|
209 |
event = MSourceOrientationObserver::KOrientationVectorsChanged;
|
sl@0
|
210 |
}
|
sl@0
|
211 |
else if ( newOrientationData.iFrontY != iOrientationData.iFrontY )
|
sl@0
|
212 |
{
|
sl@0
|
213 |
iOrientationData.iFrontY = newOrientationData.iFrontY;
|
sl@0
|
214 |
event = MSourceOrientationObserver::KOrientationVectorsChanged;
|
sl@0
|
215 |
}
|
sl@0
|
216 |
else if ( newOrientationData.iFrontZ != iOrientationData.iFrontZ )
|
sl@0
|
217 |
{
|
sl@0
|
218 |
iOrientationData.iFrontZ = newOrientationData.iFrontZ;
|
sl@0
|
219 |
event = MSourceOrientationObserver::KOrientationVectorsChanged;
|
sl@0
|
220 |
}
|
sl@0
|
221 |
else if ( newOrientationData.iAboveX != iOrientationData.iAboveX )
|
sl@0
|
222 |
{
|
sl@0
|
223 |
iOrientationData.iAboveX = newOrientationData.iAboveX;
|
sl@0
|
224 |
event = MSourceOrientationObserver::KOrientationVectorsChanged;
|
sl@0
|
225 |
}
|
sl@0
|
226 |
else if ( newOrientationData.iFrontY != iOrientationData.iAboveY )
|
sl@0
|
227 |
{
|
sl@0
|
228 |
iOrientationData.iAboveY = newOrientationData.iAboveY;
|
sl@0
|
229 |
event = MSourceOrientationObserver::KOrientationVectorsChanged;
|
sl@0
|
230 |
}
|
sl@0
|
231 |
else if ( newOrientationData.iAboveZ != iOrientationData.iAboveZ )
|
sl@0
|
232 |
{
|
sl@0
|
233 |
iOrientationData.iAboveZ = newOrientationData.iAboveZ;
|
sl@0
|
234 |
event = MSourceOrientationObserver::KOrientationVectorsChanged;
|
sl@0
|
235 |
}
|
sl@0
|
236 |
|
sl@0
|
237 |
if (!event)
|
sl@0
|
238 |
return;
|
sl@0
|
239 |
|
sl@0
|
240 |
for ( TInt i = 0; i < iObservers.Count(); i++ )
|
sl@0
|
241 |
{
|
sl@0
|
242 |
iObservers[i]->EffectChanged(this, event);
|
sl@0
|
243 |
}
|
sl@0
|
244 |
}
|
sl@0
|
245 |
|
sl@0
|
246 |
|
sl@0
|
247 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
sl@0
|
248 |
|
sl@0
|
249 |
// End of File
|