35
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Volume popup implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <AknVolumePopup.h>
|
|
20 |
#include <cvtlogger.h>
|
|
21 |
#include "cvtuivolumepopup.h"
|
|
22 |
#include "cvtuifeaturemanager.h"
|
|
23 |
#include "tVtuifeaturevariation.h"
|
|
24 |
#include "CVtUiAppUi.h"
|
|
25 |
#include "cvtengmodel.h"
|
|
26 |
|
|
27 |
// ---------------------------------------------------------------------------
|
|
28 |
// CVtUiVolumePopup::NewL
|
|
29 |
// ---------------------------------------------------------------------------
|
|
30 |
//
|
|
31 |
CVtUiVolumePopup* CVtUiVolumePopup::NewL( CVtUiFeatureManager&
|
|
32 |
aFeatureManager )
|
|
33 |
{
|
|
34 |
__VTPRINTENTER( "CVtUiVolumePopup.NewL" )
|
|
35 |
CVtUiVolumePopup* self =
|
|
36 |
new ( ELeave ) CVtUiVolumePopup( aFeatureManager );
|
|
37 |
CleanupStack::PushL( self );
|
|
38 |
self->ConstructL();
|
|
39 |
CleanupStack::Pop();
|
|
40 |
__VTPRINTEXIT( "CVtUiVolumePopup.NewL" )
|
|
41 |
return self;
|
|
42 |
}
|
|
43 |
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
// CVtUiVolumePopup::~CVtUiVolumePopup
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CVtUiVolumePopup::~CVtUiVolumePopup()
|
|
49 |
{
|
|
50 |
__VTPRINTENTER( "CVtUiVolumePopup.~" )
|
|
51 |
__VTPRINTEXIT( "CVtUiVolumePopup.~" )
|
|
52 |
}
|
|
53 |
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
// CVtUiVolumePopup::UpdateVolumeAndRouting
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
//
|
|
58 |
void CVtUiVolumePopup::UpdateVolumeAndRoutingL()
|
|
59 |
{
|
|
60 |
__VTPRINTENTER( "CVtUiVolumePopup.UpdateVolumeAndRoutingL" )
|
|
61 |
MVtEngAudio& audio( iModel.Audio() );
|
|
62 |
MVtEngAudio::TAudioRoutingState audioRouting;
|
|
63 |
User::LeaveIfError( audio.GetRoutingState( audioRouting ) );
|
|
64 |
//update routing and volume for this routing
|
|
65 |
iAudioRouting = audioRouting;
|
|
66 |
iVolume = OutputVolume( iAudioRouting );
|
|
67 |
SetValue( iVolume );
|
|
68 |
__VTPRINTEXIT( "CVtUiVolumePopup.UpdateVolumeAndRoutingL" )
|
|
69 |
}
|
|
70 |
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
// CVtUiVolumePopup::RefreshL
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
void CVtUiVolumePopup::RefreshL()
|
|
76 |
{
|
|
77 |
__VTPRINTENTER( "CVtUiVolumePopup.RefreshL" )
|
|
78 |
MVtEngAudio& audio( iModel.Audio() );
|
|
79 |
MVtEngAudio::TAudioRoutingState audioRouting;
|
|
80 |
User::LeaveIfError( audio.GetRoutingState( audioRouting ) );
|
|
81 |
|
|
82 |
// Check if audio routing has changed
|
|
83 |
if ( audioRouting != iAudioRouting )
|
|
84 |
{
|
|
85 |
__VTPRINT( DEBUG_GEN,
|
|
86 |
"CVtUiVolumePopup.RefreshL audio routing changed" )
|
|
87 |
// Audio routing changed -> update routing and volume for this routing
|
|
88 |
iAudioRouting = audioRouting;
|
|
89 |
iVolume = OutputVolume( iAudioRouting );
|
|
90 |
SetValue( iVolume );
|
|
91 |
__VTPRINT2( DEBUG_GEN, "CVtUiVolumePopup.RefreshL routing = %d",
|
|
92 |
iAudioRouting )
|
|
93 |
__VTPRINT2( DEBUG_GEN, "CVtUiVolumePopup.RefreshL volume = %d",
|
|
94 |
iVolume )
|
|
95 |
ClosePopup();
|
|
96 |
}
|
|
97 |
else
|
|
98 |
{
|
|
99 |
// No change in audio routing
|
|
100 |
const TInt volume( OutputVolume( iAudioRouting ) );
|
|
101 |
if ( volume != iVolume )
|
|
102 |
{
|
|
103 |
__VTPRINT( DEBUG_GEN, "CVtUiVolumePopup.RefreshL volume changed" )
|
|
104 |
iVolume = volume;
|
|
105 |
SetValue( iVolume );
|
|
106 |
__VTPRINT2( DEBUG_GEN, "CVtUiVolumePopup.RefreshL volume = %d",
|
|
107 |
iVolume )
|
|
108 |
if ( !IsPopUpVisible() )
|
|
109 |
{
|
|
110 |
__VTPRINT( DEBUG_GEN, "CVtUiVolumePopup.RefreshL OpenPopupL" )
|
|
111 |
OpenPopupL();
|
|
112 |
}
|
|
113 |
else
|
|
114 |
{
|
|
115 |
__VTPRINT( DEBUG_GEN, "CVtUiVolumePopup.RefreshL ShowPopupL" )
|
|
116 |
ShowPopupL();
|
|
117 |
}
|
|
118 |
}
|
|
119 |
else
|
|
120 |
{
|
|
121 |
__VTPRINT( DEBUG_GEN, "CVtUiVolumePopup.RefreshL ShowPopupL2" )
|
|
122 |
ShowPopupL();
|
|
123 |
}
|
|
124 |
}
|
|
125 |
__VTPRINTEXIT( "CVtUiVolumePopup.RefreshL" )
|
|
126 |
}
|
|
127 |
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
// CVtUiVolumePopup::DoActivateL()
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CVtUiVolumePopup::DoActivateL()
|
|
133 |
{
|
|
134 |
__VTPRINTENTER( "CVtUiVolumePopup.DoActivateL" )
|
|
135 |
CVtUiPopupBase::DoActivateL();
|
|
136 |
// In order to refresh softkey.
|
|
137 |
iFeatureManager.AppUi().RefreshSoftkeysL();
|
|
138 |
__VTPRINTEXIT( "CVtUiVolumePopup.DoActivateL" )
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
// CVtUiVolumePopup::OfferKeyEventL()
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
TKeyResponse CVtUiVolumePopup::OfferKeyEventL( const TKeyEvent& aEvent,
|
|
146 |
TEventCode /*aCode*/ )
|
|
147 |
{
|
|
148 |
__VTPRINTENTER( "CVtUiVolumePopup.OfferKeyEventL" )
|
|
149 |
TKeyResponse response( EKeyWasNotConsumed );
|
|
150 |
TVtUiSideVolumeKeysVariation svkvariation;
|
|
151 |
if ( !svkvariation.IsSideVolumeKeysSupported() &&
|
|
152 |
( aEvent.iScanCode == EStdKeyLeftArrow ||
|
|
153 |
aEvent.iScanCode == EStdKeyRightArrow ) )
|
|
154 |
{
|
|
155 |
ShowPopupL();
|
|
156 |
UpdateVolumeL();
|
|
157 |
}
|
|
158 |
__VTPRINTEXITR( "CVtUiVolumePopup.OfferKeyEventL %d", response )
|
|
159 |
return response;
|
|
160 |
}
|
|
161 |
|
|
162 |
// ---------------------------------------------------------------------------
|
|
163 |
// CVtUiVolumePopup::HandleControlEventL
|
|
164 |
// ---------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
void CVtUiVolumePopup::HandleControlEventL( CCoeControl* aControl,
|
|
167 |
TCoeEvent aEventType )
|
|
168 |
{
|
|
169 |
__VTPRINTENTER( "CVtUiVolumePopup.HandleControlEventL" )
|
|
170 |
CVtUiPopupBase::HandleControlEventL( aControl, aEventType );
|
|
171 |
if ( aEventType == EEventStateChanged )
|
|
172 |
{
|
|
173 |
UpdateVolumeL();
|
|
174 |
}
|
|
175 |
__VTPRINTEXIT( "CVtUiVolumePopup.HandleControlEventL" )
|
|
176 |
}
|
|
177 |
|
|
178 |
// ---------------------------------------------------------------------------
|
|
179 |
// CVtUiVolumePopup::CVtUiVolumePopup
|
|
180 |
// ---------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
CVtUiVolumePopup::CVtUiVolumePopup( CVtUiFeatureManager& aFeatureManager )
|
|
183 |
: CVtUiPopupBase( aFeatureManager.ComponentManager(),
|
|
184 |
TVtUiBlockListBitField(
|
|
185 |
MVtUiComponent::EComponentIdToolbar |
|
|
186 |
MVtUiComponent::EComponentIdNumberEntry |
|
|
187 |
MVtUiComponent::EComponentIdZoom |
|
|
188 |
MVtUiComponent::EVComponentIdContrast |
|
|
189 |
MVtUiComponent::EVComponentIdBrightness ),
|
|
190 |
EComponentIdVolume ),
|
|
191 |
iModel( aFeatureManager.AppUi().Model() ),
|
|
192 |
iFeatureManager ( aFeatureManager )
|
|
193 |
{
|
|
194 |
__VTPRINTENTER( "CVtUiVolumePopup.CVtUiVolumePopup" )
|
|
195 |
__VTPRINTEXIT( "CVtUiVolumePopup.CVtUiVolumePopup" )
|
|
196 |
}
|
|
197 |
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
// CVtUiVolumePopup::ConstructL
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
void CVtUiVolumePopup::ConstructL()
|
|
203 |
{
|
|
204 |
__VTPRINTENTER( "CVtUiVolumePopup.ConstructL" )
|
|
205 |
BaseConstructL();
|
|
206 |
// set default value
|
|
207 |
MVtEngAudio& audio( iModel.Audio() );
|
|
208 |
MVtEngAudio::TAudioRoutingState audioRouting;
|
|
209 |
User::LeaveIfError( audio.GetRoutingState( audioRouting ) );
|
|
210 |
SetValue( OutputVolume( audioRouting ) );
|
|
211 |
// set default audiorouting
|
|
212 |
iAudioRouting = audioRouting;
|
|
213 |
__VTPRINTEXIT( "CVtUiVolumePopup.ConstructL" )
|
|
214 |
}
|
|
215 |
|
|
216 |
// ---------------------------------------------------------------------------
|
|
217 |
// CVtUiVolumePopup::OutputVolume
|
|
218 |
// ---------------------------------------------------------------------------
|
|
219 |
//
|
|
220 |
TInt CVtUiVolumePopup::OutputVolume(
|
|
221 |
MVtEngAudio::TAudioRoutingState aRouting ) const
|
|
222 |
{
|
|
223 |
__VTPRINTENTER( "CVtUiVolumePopup.OutputVolume" )
|
|
224 |
const MVtEngAudio& audio( iModel.Audio() );
|
|
225 |
const TInt volume( audio.OutputVolume(
|
|
226 |
!( aRouting == MVtEngAudio::EAudioLoudspeaker ) ) );
|
|
227 |
__VTPRINTEXITR( "CVtUiVolumePopup.OutputVolume %d", volume )
|
|
228 |
return volume;
|
|
229 |
}
|
|
230 |
|
|
231 |
// ---------------------------------------------------------------------------
|
|
232 |
// CVtUiVolumePopup::UpdateVolumeL
|
|
233 |
// ---------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
void CVtUiVolumePopup::UpdateVolumeL()
|
|
236 |
{
|
|
237 |
__VTPRINTENTER( "CVtUiVolumePopup.UpdateVolumeL" )
|
|
238 |
|
|
239 |
MVtEngAudio& audio( iModel.Audio() );
|
|
240 |
MVtEngAudio::TAudioRoutingState audioRouting;
|
|
241 |
User::LeaveIfError( audio.GetRoutingState( audioRouting ) );
|
|
242 |
|
|
243 |
const TInt volume( OutputVolume( iAudioRouting ) );
|
|
244 |
|
|
245 |
__VTPRINT2( DEBUG_GEN, "CVtUiVolumePopup.UpdateVolumeL volume = %d",
|
|
246 |
volume )
|
|
247 |
__VTPRINT2( DEBUG_GEN, "CVtUiVolumePopup.UpdateVolumeL Value() = %d",
|
|
248 |
Value() )
|
|
249 |
if ( volume != Value() )
|
|
250 |
{
|
|
251 |
MVtEngAudio::TVtEngOutputVolume newVolume;
|
|
252 |
|
|
253 |
// Get current audio values from engine
|
|
254 |
// and set new audio volume to right routing
|
|
255 |
if ( iAudioRouting == MVtEngAudio::EAudioLoudspeaker )
|
|
256 |
{
|
|
257 |
__VTPRINT( DEBUG_GEN, "CVtUiVolumePopup.UpdateVolumeL.LS")
|
|
258 |
// changed value
|
|
259 |
newVolume.iHandsfreeVolume = Value();
|
|
260 |
// old value
|
|
261 |
TInt volume = audio.OutputVolume( ETrue );
|
|
262 |
newVolume.iHandsetVolume = volume;
|
|
263 |
}
|
|
264 |
else
|
|
265 |
{
|
|
266 |
__VTPRINT( DEBUG_GEN, "CVtUiVolumePopup.UpdateVolumeL.HS")
|
|
267 |
// changed value
|
|
268 |
newVolume.iHandsetVolume = Value();
|
|
269 |
// old value
|
|
270 |
TInt volume = audio.OutputVolume( EFalse );
|
|
271 |
newVolume.iHandsfreeVolume = volume;
|
|
272 |
}
|
|
273 |
|
|
274 |
iFeatureManager.AppUi().CmdUpdateVolumeL( newVolume );
|
|
275 |
}
|
|
276 |
__VTPRINTEXIT( "CVtUiVolumePopup.UpdateVolumeL" )
|
|
277 |
}
|