|
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: Implementation of CMPXLbxExtendedFeatures |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eiktxlbx.h> |
|
21 #include <eiktxlbm.h> |
|
22 #include <aknconsts.h> |
|
23 #include <aknsoundsystem.h> |
|
24 #include <aknViewAppUi.h> |
|
25 #include <aknnavide.h> |
|
26 #include <aknnavilabel.h> |
|
27 #include <eikspane.h> |
|
28 #include <aknappui.h> |
|
29 #include <StringLoader.h> |
|
30 #include <centralrepository.h> |
|
31 #include <AknUtils.h> |
|
32 #include <bautils.h> |
|
33 #include <data_caging_path_literals.hrh> |
|
34 #include <MProfileEngine.h> |
|
35 #include <MProfile.h> |
|
36 #include <MProfileTones.h> |
|
37 #include <TProfileToneSettings.h> |
|
38 #include <AudioPreference.h> |
|
39 #include <mpxcommandgeneraldefs.h> |
|
40 #include <mpxcollectioncommanddefs.h> |
|
41 #include <mpxcollectionmessage.h> |
|
42 #include <mpxmessagegeneraldefs.h> |
|
43 #include <mpxsubscription.h> |
|
44 #include <mpxuser.h> |
|
45 #include <mpxcommonui.rsg> |
|
46 #include <mpxcollectionutility.h> |
|
47 #include "mpxinternalcrkeys.h" |
|
48 #include "mpxlbxextendedfeatures.h" |
|
49 #include "mpxlog.h" |
|
50 |
|
51 // CONSTANTS |
|
52 const TInt KMPXDefaultKeyRepeatInitDelay = KAknKeyboardRepeatInitialDelay; |
|
53 const TInt KMPMicroSecPerMilliSec = 1000; |
|
54 const TInt KSoundInterval = 1000000; // 1 second |
|
55 const TInt KMaxVolumeLevel = 3; |
|
56 const TInt KSpeedScrollSetIndexInterval = 5; |
|
57 |
|
58 _LIT( KMPXCommonUiRscPath, "mpxcommonui.rsc" ); |
|
59 //_LIT8( KPhoneNormalBeepSequence, "\x00\x11\x0A\x71\x06\x0B" ); |
|
60 _LIT8( KPhoneFastBeepSequence, "\x00\x11\x0A\x76\x06\x0B" ); |
|
61 |
|
62 // ============================ MEMBER FUNCTIONS =============================== |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CMPXLbxExtendedFeatures::CMPXLbxExtendedFeatures |
|
66 // C++ default constructor can NOT contain any code, that |
|
67 // might leave. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CMPXLbxExtendedFeatures::CMPXLbxExtendedFeatures( |
|
71 CEikTextListBox* aLbx, |
|
72 TBool aEnableSetIndex ) : |
|
73 iLbx( aLbx ), |
|
74 iKeyStatus( EMPXKeyOther ), |
|
75 iScrollingState( EMPXScrollingIdle ), |
|
76 iNaviEnabled( ETrue ), |
|
77 iKeysoundEnabled( ETrue ), |
|
78 iEnableSetIndex( aEnableSetIndex ) |
|
79 { |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CMPXLbxExtendedFeatures::ConstructL |
|
84 // Symbian 2nd phase constructor can leave. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CMPXLbxExtendedFeatures::ConstructL() |
|
88 { |
|
89 MPX_FUNC( "CMPXLbxExtendedFeatures::ConstructL" ); |
|
90 |
|
91 CCoeEnv* coeEnv = CEikonEnv::Static(); |
|
92 TParse parse; |
|
93 parse.Set( KMPXCommonUiRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
94 TFileName resourceFile( parse.FullName() ); |
|
95 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
96 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
97 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
98 |
|
99 // connect to window server for scrolling speed setting |
|
100 iWsSession = CEikonEnv::Static()->WsSession(); |
|
101 TUid naviPaneUid; |
|
102 naviPaneUid.iUid = EEikStatusPaneUidNavi; |
|
103 iNaviPane = |
|
104 static_cast<CAknNavigationControlContainer*> |
|
105 ( iAvkonViewAppUi->StatusPane()->ControlL( naviPaneUid ) ); |
|
106 |
|
107 GetInfoFromCenRepL(); |
|
108 |
|
109 iNaviDecorator = iNaviPane->CreateNavigationLabelL( KNullDesC ); |
|
110 //Create label to change text in Navi pane |
|
111 iNaviLabel = static_cast<CAknNaviLabel*> |
|
112 ( iNaviDecorator->DecoratedControl() ); |
|
113 |
|
114 iTimer = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
115 |
|
116 iToneUtility = CMdaAudioToneUtility::NewL( *this, NULL ); |
|
117 iToneUtility->SetPriority( |
|
118 KAudioPriorityKeyPress, |
|
119 static_cast<TMdaPriorityPreference>( KAudioPrefKeyPressNonDTMF ) ); |
|
120 iToneUtility->SetRepeats( 1, |
|
121 TTimeIntervalMicroSeconds( KSoundInterval ) ); |
|
122 |
|
123 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault ); |
|
124 |
|
125 #ifdef __USE_MESSAGE_SUBSCRIPTION |
|
126 // Subscribe to only a few messages from collection utility |
|
127 CMPXSubscription* subscription( CMPXSubscription::NewL() ); |
|
128 CleanupStack::PushL( subscription ); |
|
129 CMPXSubscriptionItem* subItem1( CMPXSubscriptionItem::NewL() ); |
|
130 CleanupStack::PushL( subItem1 ); |
|
131 subItem1->SetTObjectValueL( KMPXMessageGeneralId, KMPXMessageGeneral ); |
|
132 subItem1->SetTObjectValueL( KMPXMessageGeneralEvent, TMPXCollectionMessage::EPathChanged ); |
|
133 subItem1->SetTObjectValueL( KMPXMessageGeneralType, EMcPathChangedByOpen ); |
|
134 subscription->AddItemL( *subItem1 ); |
|
135 iCollectionUtility->Collection().AddSubscriptionL( *subscription ); |
|
136 CleanupStack::PopAndDestroy( subItem1 ); |
|
137 CleanupStack::PopAndDestroy( subscription ); |
|
138 #endif |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CMPXLbxExtendedFeatures::NewL |
|
143 // Two-phased constructor. |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C CMPXLbxExtendedFeatures* CMPXLbxExtendedFeatures::NewL( |
|
147 CEikTextListBox* aLbx, TBool aEnableSetIndex ) |
|
148 { |
|
149 MPX_FUNC( "CMPXLbxExtendedFeatures::NewL" ); |
|
150 __ASSERT_DEBUG( aLbx, User::Panic( _L("NewL"), KErrArgument ) ); |
|
151 |
|
152 CMPXLbxExtendedFeatures* self = |
|
153 new ( ELeave ) CMPXLbxExtendedFeatures( aLbx, aEnableSetIndex ); |
|
154 |
|
155 CleanupStack::PushL( self ); |
|
156 self->ConstructL(); |
|
157 CleanupStack::Pop(); |
|
158 |
|
159 return self; |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // Destructor |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C CMPXLbxExtendedFeatures::~CMPXLbxExtendedFeatures() |
|
167 { |
|
168 MPX_FUNC( "CMPXLbxExtendedFeatures::~CMPXLbxExtendedFeatures" ); |
|
169 delete iTimer; |
|
170 |
|
171 iWsSession.SetKeyboardRepeatRate( |
|
172 KAknKeyboardRepeatInitialDelay, KAknStandardKeyboardRepeatRate ); |
|
173 iWsSession.Flush(); |
|
174 |
|
175 if ( !iKeysoundEnabled ) |
|
176 { |
|
177 // Enable keysound if it's not already enabled |
|
178 iAvkonViewAppUi->KeySounds()->PopContext(); |
|
179 } |
|
180 |
|
181 if ( iNaviDecorator ) |
|
182 { |
|
183 delete iNaviDecorator; |
|
184 } |
|
185 |
|
186 if ( iResourceOffset ) |
|
187 { |
|
188 CEikonEnv::Static()->DeleteResourceFile( iResourceOffset ); |
|
189 } |
|
190 |
|
191 if( iToneUtility ) |
|
192 { |
|
193 if( iToneUtility->State() == EMdaAudioToneUtilityPlaying ) |
|
194 { |
|
195 iToneUtility->CancelPlay(); |
|
196 } |
|
197 else |
|
198 { |
|
199 iToneUtility->CancelPrepare(); |
|
200 } |
|
201 delete iToneUtility; |
|
202 } |
|
203 |
|
204 if ( iCollectionUtility ) |
|
205 { |
|
206 iCollectionUtility->Close(); |
|
207 } |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CMPXLbxExtendedFeatures::HandleLbxKeyEventL |
|
212 // Handle key events |
|
213 // (other items were commented in a header). |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 EXPORT_C TKeyResponse CMPXLbxExtendedFeatures::HandleLbxKeyEventL( |
|
217 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
218 { |
|
219 //MPX_FUNC( "CMPXLbxExtendedFeatures::HandleLbxKeyEventL" ); |
|
220 TKeyResponse keyResponse = EKeyWasNotConsumed; |
|
221 |
|
222 if ( iSpeedScrollEnabled ) |
|
223 { |
|
224 //MPX_DEBUG2( "CMPXLbxExtendedFeatures::HandleLbxKeyEventL EventType: %d", aType ); |
|
225 if ( aType == EEventKeyDown ) |
|
226 { |
|
227 MPX_PERF_CHECKPT("Key down issued") |
|
228 // pass it to listbox to handle |
|
229 keyResponse = iLbx->OfferKeyEventL( aKeyEvent, aType ); |
|
230 keyResponse = HandleEventKeyDownL( aKeyEvent ); |
|
231 iFirstKeyEvent = ETrue; |
|
232 } |
|
233 else if ( aType == EEventKeyUp ) |
|
234 { |
|
235 // pass it to listbox to handle |
|
236 keyResponse = iLbx->OfferKeyEventL( aKeyEvent, aType ); |
|
237 keyResponse = HandleEventKeyUpL( aKeyEvent ); |
|
238 } |
|
239 else if ( aType == EEventKey ) |
|
240 { |
|
241 if ( ( aKeyEvent.iScanCode == EStdKeyLeftArrow ) || |
|
242 ( aKeyEvent.iScanCode == EStdKeyRightArrow ) ) |
|
243 { |
|
244 keyResponse = iLbx->OfferKeyEventL( |
|
245 aKeyEvent, aType ); |
|
246 } |
|
247 else if ( !CheckBoundaryCases( iKeyStatus ) ) |
|
248 { |
|
249 if ( !iSkipEvent ) |
|
250 { |
|
251 keyResponse = iLbx->OfferKeyEventL( |
|
252 aKeyEvent, aType ); |
|
253 |
|
254 if ( ( ( aKeyEvent.iScanCode == EStdKeyUpArrow ) || |
|
255 ( aKeyEvent.iScanCode == EStdKeyDownArrow ) ) && |
|
256 iEnableSetIndex ) |
|
257 { |
|
258 // Get current listbox item index |
|
259 TInt currentItem = iLbx->CurrentItemIndex(); |
|
260 if ( currentItem != KErrNotFound ) |
|
261 { |
|
262 SetIndexToCollectionL( currentItem ); |
|
263 } |
|
264 } |
|
265 } |
|
266 else |
|
267 { |
|
268 // Simulate the key event to activate the updated scrolling speed |
|
269 iWsSession.SimulateKeyEvent(aKeyEvent); |
|
270 keyResponse = EKeyWasConsumed; |
|
271 } |
|
272 } |
|
273 else |
|
274 { |
|
275 // bump effect |
|
276 if ( iFirstKeyEvent ) |
|
277 { |
|
278 iSkipEvent = ETrue; |
|
279 keyResponse = iLbx->OfferKeyEventL( |
|
280 aKeyEvent, aType ); |
|
281 |
|
282 if ( ( ( aKeyEvent.iScanCode == EStdKeyUpArrow ) || |
|
283 ( aKeyEvent.iScanCode == EStdKeyDownArrow ) ) && |
|
284 iEnableSetIndex ) |
|
285 { |
|
286 TInt currentItem = iLbx->CurrentItemIndex(); |
|
287 if ( currentItem != KErrNotFound ) |
|
288 { |
|
289 SetIndexToCollectionL( currentItem ); |
|
290 } |
|
291 } |
|
292 |
|
293 iKeyStatus = EMPXKeyDown; |
|
294 if ( aKeyEvent.iScanCode == EStdKeyUpArrow ) |
|
295 { |
|
296 iKeyStatus = EMPXKeyUp; |
|
297 } |
|
298 |
|
299 // reset scrolling speed to normal |
|
300 iScrollingState = EMPXScrollingIdle; |
|
301 UpdateScrollingSpeed( iKeyStatus ); |
|
302 iScrollingState = EMPXScrolling1stBufferTime; |
|
303 |
|
304 // after crossing the boundary, start timer again |
|
305 StopTimer(); |
|
306 StartTimerL(); |
|
307 } |
|
308 EnableKeySoundL( EFalse ); |
|
309 keyResponse = EKeyWasConsumed; |
|
310 MPX_PERF_CHECKPT("End of list reaches - bump effect"); |
|
311 } |
|
312 iFirstKeyEvent = EFalse; |
|
313 iSkipEvent = EFalse; |
|
314 } |
|
315 else |
|
316 { |
|
317 // Other TEventCode; do nothing |
|
318 } |
|
319 } // end if iSpeedScrollEnabled |
|
320 else // iSpeedScrollEnabled is false |
|
321 { |
|
322 // pass it to listbox to handle |
|
323 keyResponse = iLbx->OfferKeyEventL( aKeyEvent, aType ); |
|
324 |
|
325 // Get current listbox item index |
|
326 if ( ( ( aKeyEvent.iScanCode == EStdKeyUpArrow ) || |
|
327 ( aKeyEvent.iScanCode == EStdKeyDownArrow ) ) && |
|
328 iEnableSetIndex ) |
|
329 { |
|
330 TInt currentItem = iLbx->CurrentItemIndex(); |
|
331 if ( currentItem != KErrNotFound ) |
|
332 { |
|
333 SetIndexToCollectionL( currentItem ); |
|
334 } |
|
335 } |
|
336 } |
|
337 |
|
338 return keyResponse; |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CMPXLbxExtendedFeatures::EnableSpeedScroll |
|
343 // Enable/disable speed scroll |
|
344 // (other items were commented in a header) |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 EXPORT_C void CMPXLbxExtendedFeatures::EnableSpeedScrollL( TBool aIsEnable ) |
|
348 { |
|
349 MPX_FUNC( "CMPXLbxExtendedFeatures::EnableSpeedScrollL" ); |
|
350 iSpeedScrollEnabled = aIsEnable; |
|
351 |
|
352 if ( !aIsEnable ) |
|
353 { |
|
354 Reset(); |
|
355 } |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // CMPXLbxExtendedFeatures::SpeedNaviUpdating |
|
360 // Enable or disable speedscroll specific navi labelling |
|
361 // (other items were commented in a header). |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 EXPORT_C void CMPXLbxExtendedFeatures::SpeedNaviUpdating( TBool aNaviEnable ) |
|
365 { |
|
366 MPX_FUNC( "CMPXLbxExtendedFeatures::SpeedNaviUpdating" ); |
|
367 iNaviEnabled = aNaviEnable; |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CMPXLbxExtendedFeatures::Reset |
|
372 // Reset everything to default (eg. scrolling speed) |
|
373 // (other items were commented in a header). |
|
374 // ----------------------------------------------------------------------------- |
|
375 // |
|
376 void CMPXLbxExtendedFeatures::Reset() |
|
377 { |
|
378 MPX_FUNC( "CMPXLbxExtendedFeatures::Reset" ); |
|
379 StopTimer(); |
|
380 |
|
381 // Reset all states to idle |
|
382 iKeyStatus = EMPXKeyOther; |
|
383 iScrollingState = EMPXScrollingIdle; |
|
384 |
|
385 // Revert to original speed |
|
386 UpdateScrollingSpeed( iKeyStatus ); |
|
387 TRAP_IGNORE( EnableKeySoundL( ETrue ) ); |
|
388 } |
|
389 |
|
390 // ----------------------------------------------------------------------------- |
|
391 // CMPXLbxExtendedFeatures::EnableAutoLoop |
|
392 // Enable/disable auto loop |
|
393 // (other items were commented in a header) |
|
394 // ----------------------------------------------------------------------------- |
|
395 // |
|
396 void CMPXLbxExtendedFeatures::EnableAutoLoop( TBool aIsEnable ) |
|
397 { |
|
398 MPX_FUNC( "CMPXLbxExtendedFeatures::EnableAutoLoop" ); |
|
399 iAutoLoopEnabled = aIsEnable; |
|
400 } |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // CMPXLbxExtendedFeatures::StartTimer |
|
404 // Start the timer |
|
405 // (other items were commented in a header). |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 void CMPXLbxExtendedFeatures::StartTimerL() |
|
409 { |
|
410 MPX_FUNC( "CMPXLbxExtendedFeatures::StartTimerL" ); |
|
411 TInt bufferTime = 0; |
|
412 TBool enabled = EFalse; |
|
413 |
|
414 switch ( iScrollingState ) |
|
415 { |
|
416 case EMPXScrolling1stBufferTime: |
|
417 { |
|
418 // Enable 1st buffer timer |
|
419 bufferTime = iFirstBufferTime; |
|
420 enabled = ETrue; |
|
421 break; |
|
422 } |
|
423 case EMPXScrolling2ndBufferTime: |
|
424 { |
|
425 // Enable 2nd buffer timer |
|
426 bufferTime = iSecondBufferTime; |
|
427 enabled = ETrue; |
|
428 break; |
|
429 } |
|
430 default: |
|
431 { |
|
432 // Do nothing |
|
433 break; |
|
434 } |
|
435 } |
|
436 |
|
437 if ( enabled ) |
|
438 { |
|
439 StopTimer(); |
|
440 |
|
441 iTimer->Start( TTimeIntervalMicroSeconds32( |
|
442 bufferTime * KMPMicroSecPerMilliSec ), |
|
443 TTimeIntervalMicroSeconds32( |
|
444 bufferTime * KMPMicroSecPerMilliSec ), |
|
445 TCallBack( TimerCallBack, this ) ); |
|
446 } |
|
447 } |
|
448 |
|
449 // ----------------------------------------------------------------------------- |
|
450 // CMPXLbxExtendedFeatures::StopTimer |
|
451 // Stop the timer |
|
452 // (other items were commented in a header). |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 void CMPXLbxExtendedFeatures::StopTimer() |
|
456 { |
|
457 //MPX_FUNC( "CMPXLbxExtendedFeatures::StopTimer" ); |
|
458 if ( iTimer && iTimer->IsActive() ) |
|
459 { |
|
460 iTimer->Cancel(); |
|
461 } |
|
462 } |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // CMPXLbxExtendedFeatures::TimerCallBack |
|
466 // Callback function for the timer |
|
467 // (other items were commented in a header). |
|
468 // ----------------------------------------------------------------------------- |
|
469 // |
|
470 TInt CMPXLbxExtendedFeatures::TimerCallBack( TAny* aPtr ) |
|
471 { |
|
472 //MPX_FUNC( "CMPXLbxExtendedFeatures::TimerCallBack" ); |
|
473 CMPXLbxExtendedFeatures *p = ( CMPXLbxExtendedFeatures* )aPtr; |
|
474 p->BufferTimerHandler(); |
|
475 return EFalse; |
|
476 } |
|
477 |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CMPXLbxExtendedFeatures::BufferTimerHandler |
|
480 // Change scrolling status, called by TimerCallBack() |
|
481 // (other items were commented in a header). |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 void CMPXLbxExtendedFeatures::BufferTimerHandler() |
|
485 { |
|
486 //MPX_FUNC( "CMPXLbxExtendedFeatures::BufferTimerHandler" ); |
|
487 StopTimer(); |
|
488 switch ( iScrollingState ) |
|
489 { |
|
490 case EMPXScrolling1stBufferTime: |
|
491 { |
|
492 iScrollingState = EMPXScrolling1stSpeed; |
|
493 // Goto first speed |
|
494 UpdateScrollingSpeed( iKeyStatus ); |
|
495 TRAP_IGNORE( EnableKeySoundL( EFalse ) ); |
|
496 break; |
|
497 } |
|
498 default: |
|
499 { |
|
500 // Reset all states if timeout |
|
501 Reset(); |
|
502 break; |
|
503 } |
|
504 } |
|
505 } |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // CMPXLbxExtendedFeatures::UpdateScrollingSpeed |
|
509 // Update and return scrolling speed |
|
510 // (other items were commented in a header). |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 void CMPXLbxExtendedFeatures::UpdateScrollingSpeed( TMPXKeyStatus aKeyStatus ) |
|
514 { |
|
515 MPX_FUNC( "CMPXLbxExtendedFeatures::UpdateScrollingSpeed" ); |
|
516 TInt rate = 0; |
|
517 TInt repeatInitDelay = 0; |
|
518 TBool updated = EFalse; |
|
519 |
|
520 switch ( iScrollingState ) |
|
521 { |
|
522 case EMPXScrolling1stSpeed: |
|
523 { |
|
524 MPX_DEBUG1( ">>>CMPXLbxExtendedFeatures::UpdateScrollingSpeed rate changed: first speed" ); |
|
525 repeatInitDelay = iFirstSpeed * KMPMicroSecPerMilliSec; |
|
526 rate = iFirstSpeed * KMPMicroSecPerMilliSec; |
|
527 updated = ETrue; |
|
528 |
|
529 iSkipPlaying = EFalse; |
|
530 // TO-DO: timing problem with CMdaAudioToneUtility in S60 3.0, |
|
531 // enable this may crash, should be fixed in 3.1? |
|
532 iToneUtility->PrepareToPlayDesSequence( KPhoneFastBeepSequence() ); |
|
533 break; |
|
534 } |
|
535 case EMPXScrolling2ndSpeed: |
|
536 { |
|
537 MPX_DEBUG1( ">>>CMPXLbxExtendedFeatures::UpdateScrollingSpeed rate changed: second speed" ); |
|
538 repeatInitDelay = iSecondSpeed * KMPMicroSecPerMilliSec; |
|
539 rate = iSecondSpeed * KMPMicroSecPerMilliSec; |
|
540 updated = ETrue; |
|
541 |
|
542 iSkipPlaying = EFalse; |
|
543 // TO-DO: timing problem with CMdaAudioToneUtility in S60 3.0, |
|
544 // enable this may crash, should be fixed in 3.1? |
|
545 iToneUtility->CancelPrepare(); |
|
546 iToneUtility->PrepareToPlayDesSequence( KPhoneFastBeepSequence() ); |
|
547 break; |
|
548 } |
|
549 case EMPXScrollingIdle: |
|
550 { |
|
551 MPX_DEBUG1( ">>>CMPXLbxExtendedFeatures::UpdateScrollingSpeed rate changed: idle" ); |
|
552 repeatInitDelay = KMPXDefaultKeyRepeatInitDelay; |
|
553 rate = iFirstSpeed * KMPMicroSecPerMilliSec; |
|
554 updated = ETrue; |
|
555 |
|
556 if( iToneUtility->State() == EMdaAudioToneUtilityPlaying ) |
|
557 { |
|
558 MPX_DEBUG1( ">>>CMPXLbxExtendedFeatures::UpdateScrollingSpeed rate changed: idle cancel play" ); |
|
559 iSkipPlaying = EFalse; |
|
560 iToneUtility->CancelPlay(); |
|
561 } |
|
562 |
|
563 break; |
|
564 } |
|
565 default: |
|
566 { |
|
567 // Do nothing |
|
568 break; |
|
569 } |
|
570 } |
|
571 |
|
572 if ( updated ) |
|
573 { |
|
574 if( !CheckBoundaryCases( aKeyStatus ) ) |
|
575 { |
|
576 TRAP_IGNORE( SetNaviSpeedTextL( EFalse ) ); |
|
577 } |
|
578 // Change scrolling speed |
|
579 iWsSession.SetKeyboardRepeatRate( repeatInitDelay, rate ); |
|
580 iWsSession.Flush(); |
|
581 } |
|
582 } |
|
583 |
|
584 // ----------------------------------------------------------------------------- |
|
585 // CMPXLbxExtendedFeatures::CheckBoundaryCases |
|
586 // Check whether boundary is reached |
|
587 // (other items were commented in a header). |
|
588 // ----------------------------------------------------------------------------- |
|
589 // |
|
590 TBool CMPXLbxExtendedFeatures::CheckBoundaryCases( |
|
591 TMPXKeyStatus aKeyStatus ) |
|
592 { |
|
593 //MPX_FUNC( "CMPXLbxExtendedFeatures::CheckBoundaryCases" ); |
|
594 __ASSERT_DEBUG( iLbx, User::Panic( _L("CheckBoundaryCases"), KErrArgument ) ); |
|
595 |
|
596 TBool reached = EFalse; |
|
597 |
|
598 if ( !iAutoLoopEnabled ) |
|
599 { |
|
600 // Get total number of items in the listbox |
|
601 TInt totalCount = iLbx->Model()->NumberOfItems(); |
|
602 |
|
603 // Get current listbox item index |
|
604 TInt currentItem = iLbx->CurrentItemIndex(); |
|
605 |
|
606 //CHECK BOUNDARIES |
|
607 if ( aKeyStatus == EMPXKeyUp && currentItem == 0 ) |
|
608 { |
|
609 reached = ETrue; |
|
610 } |
|
611 if ( aKeyStatus == EMPXKeyDown && ( currentItem == totalCount - 1 ) ) |
|
612 { |
|
613 reached = ETrue; |
|
614 } |
|
615 } |
|
616 |
|
617 if( reached ) |
|
618 { |
|
619 // boundary reached, stop all keytones |
|
620 if( iToneUtility->State() == EMdaAudioToneUtilityPlaying ) |
|
621 { |
|
622 MPX_DEBUG1( ">>>CMPXLbxExtendedFeatures::CheckBoundaryCases cancel play" ); |
|
623 iSkipPlaying = ETrue; |
|
624 iToneUtility->CancelPlay(); |
|
625 } |
|
626 |
|
627 TRAP_IGNORE( SetNaviSpeedTextL( reached ) ); |
|
628 } |
|
629 |
|
630 return reached; |
|
631 } |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // CMPXLbxExtendedFeatures::GetInfoFromCenRepL |
|
635 // Get info (eg. scrolling speed) from the cenrep |
|
636 // (other items were commented in a header). |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 void CMPXLbxExtendedFeatures::GetInfoFromCenRepL() |
|
640 { |
|
641 MPX_FUNC( "CMPXLbxExtendedFeatures::GetInfoFromCenRepL" ); |
|
642 CRepository* repository = CRepository::NewLC( KCRUidMPXMPExtendedFeatures ); |
|
643 |
|
644 User::LeaveIfError( repository->Get( KMPXMPSpeedScrollFirBuffTime, |
|
645 iFirstBufferTime ) ); |
|
646 User::LeaveIfError( repository->Get( KMPXMPSpeedScrollSecBuffTime, |
|
647 iSecondBufferTime ) ); |
|
648 User::LeaveIfError( repository->Get( KMPXMPSpeedScrollFirSpeed, |
|
649 iFirstSpeed ) ); |
|
650 User::LeaveIfError( repository->Get( KMPXMPSpeedScrollSecSpeed, |
|
651 iSecondSpeed ) ); |
|
652 |
|
653 CleanupStack::PopAndDestroy(); // repository |
|
654 } |
|
655 |
|
656 // ----------------------------------------------------------------------------- |
|
657 // CMPXLbxExtendedFeatures::SetNaviSpeedTextL |
|
658 // Update navi pane label for speed scrolling. |
|
659 // (other items were commented in a header). |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 void CMPXLbxExtendedFeatures::SetNaviSpeedTextL( TBool boundaryReached ) |
|
663 { |
|
664 //MPX_FUNC( "CMPXLbxExtendedFeatures::SetNaviSpeedTextL" ); |
|
665 if ( iNaviEnabled ) |
|
666 { |
|
667 if( iScrollingState == EMPXScrolling2ndSpeed |
|
668 && !boundaryReached ) |
|
669 { |
|
670 HBufC* speedFast = |
|
671 StringLoader::LoadLC( R_MPX_CUI_SCROLL_SPEED_FAST ); |
|
672 iNaviLabel->SetTextL( *speedFast ); |
|
673 CleanupStack::PopAndDestroy(); |
|
674 |
|
675 iNaviPane->PushL( *iNaviDecorator ); |
|
676 iNaviPane->DrawNow(); |
|
677 } |
|
678 // Boundary or idle |
|
679 else |
|
680 { |
|
681 iNaviPane->Pop( iNaviDecorator ); |
|
682 } |
|
683 } |
|
684 } |
|
685 |
|
686 // ----------------------------------------------------------------------------- |
|
687 // CMPXLbxExtendedFeatures::HandleEventKeyDownL |
|
688 // Handles key down event |
|
689 // (other items were commented in a header). |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 TKeyResponse CMPXLbxExtendedFeatures::HandleEventKeyDownL( |
|
693 const TKeyEvent& aKeyEvent ) |
|
694 { |
|
695 MPX_FUNC( "CMPXLbxExtendedFeatures::HandleEventKeyDown" ); |
|
696 |
|
697 TKeyResponse keyResponse = EKeyWasNotConsumed; |
|
698 // Stop the timer |
|
699 StopTimer(); |
|
700 iSkipPlaying = EFalse; |
|
701 |
|
702 // if not up or down arrow key, don't start timer |
|
703 if ( ( aKeyEvent.iScanCode == EStdKeyUpArrow ) || |
|
704 ( aKeyEvent.iScanCode == EStdKeyDownArrow ) ) |
|
705 { |
|
706 keyResponse = EKeyWasConsumed; |
|
707 |
|
708 // current key event |
|
709 // used to compare with previous key event |
|
710 TMPXKeyStatus currentKeyStatus = EMPXKeyDown; |
|
711 |
|
712 if ( aKeyEvent.iScanCode == EStdKeyUpArrow ) |
|
713 { |
|
714 currentKeyStatus = EMPXKeyUp; |
|
715 } |
|
716 |
|
717 if ( CheckBoundaryCases( currentKeyStatus ) ) |
|
718 { |
|
719 EnableKeySoundL( EFalse ); |
|
720 } |
|
721 else |
|
722 { |
|
723 EnableKeySoundL( ETrue ); |
|
724 } |
|
725 |
|
726 if ( iKeyStatus == currentKeyStatus ) |
|
727 { |
|
728 switch ( iScrollingState ) |
|
729 { |
|
730 case EMPXScrolling2ndBufferTime: |
|
731 { |
|
732 iScrollingState = EMPXScrolling2ndSpeed; |
|
733 iIndexCount = 0; // reset counter |
|
734 // Goto second speed |
|
735 UpdateScrollingSpeed( iKeyStatus ); |
|
736 EnableKeySoundL( EFalse ); |
|
737 break; |
|
738 } |
|
739 default: |
|
740 { |
|
741 // Do nothing |
|
742 break; |
|
743 } |
|
744 } |
|
745 } |
|
746 else // if current key is opposite from previous |
|
747 { |
|
748 switch ( iScrollingState ) |
|
749 { |
|
750 case EMPXScrolling1stSpeed: |
|
751 case EMPXScrolling2ndBufferTime: |
|
752 case EMPXScrolling2ndSpeed: |
|
753 { |
|
754 // Need to activate the updated scrolling speed |
|
755 iSkipEvent = ETrue; |
|
756 break; |
|
757 } |
|
758 default: |
|
759 { |
|
760 break; |
|
761 } |
|
762 } |
|
763 |
|
764 // Reset to idle state |
|
765 Reset(); |
|
766 // Update key status |
|
767 iKeyStatus = currentKeyStatus; |
|
768 // Start the 1st buffer timer for next key |
|
769 iScrollingState = EMPXScrolling1stBufferTime; |
|
770 StartTimerL(); |
|
771 } |
|
772 } |
|
773 else |
|
774 { |
|
775 // Reset everything to idle state |
|
776 Reset(); |
|
777 } |
|
778 return keyResponse; |
|
779 } |
|
780 |
|
781 // ----------------------------------------------------------------------------- |
|
782 // CMPXLbxExtendedFeatures::HandleEventKeyUpL |
|
783 // Handles key down event |
|
784 // (other items were commented in a header). |
|
785 // ----------------------------------------------------------------------------- |
|
786 // |
|
787 TKeyResponse CMPXLbxExtendedFeatures::HandleEventKeyUpL( |
|
788 const TKeyEvent& aKeyEvent ) |
|
789 { |
|
790 MPX_FUNC( "CMPXLbxExtendedFeatures::HandleEventKeyUp" ); |
|
791 TKeyResponse keyResponse = EKeyWasNotConsumed; |
|
792 iSkipPlaying = EFalse; |
|
793 |
|
794 // if not up or down arrow key, don't reset timer |
|
795 if ( ( aKeyEvent.iScanCode == EStdKeyUpArrow ) || |
|
796 ( aKeyEvent.iScanCode == EStdKeyDownArrow ) ) |
|
797 { |
|
798 switch ( iScrollingState ) |
|
799 { |
|
800 case EMPXScrolling2ndSpeed: |
|
801 { |
|
802 // leaving speed scrolling, set index |
|
803 SetIndexToCollectionL( iLbx->CurrentItemIndex(), ETrue ); |
|
804 } // fall through |
|
805 case EMPXScrolling1stSpeed: |
|
806 { |
|
807 // Enable 2nd buffer timer |
|
808 iScrollingState = EMPXScrolling2ndBufferTime; |
|
809 StartTimerL(); |
|
810 EnableKeySoundL( ETrue ); |
|
811 break; |
|
812 } |
|
813 default: |
|
814 { |
|
815 // Reset all states for other scrolling states |
|
816 Reset(); |
|
817 break; |
|
818 } |
|
819 } |
|
820 keyResponse = EKeyWasConsumed; |
|
821 } |
|
822 return keyResponse; |
|
823 } |
|
824 |
|
825 // ----------------------------------------------------------------------------- |
|
826 // CMPXLbxExtendedFeatures::EnableKeySoundL |
|
827 // Enables/Disables Keysound |
|
828 // (other items were commented in a header). |
|
829 // ----------------------------------------------------------------------------- |
|
830 // |
|
831 void CMPXLbxExtendedFeatures::EnableKeySoundL( TBool aEnable ) |
|
832 { |
|
833 //MPX_FUNC( "CMPXLbxExtendedFeatures::EnableKeySoundL" ); |
|
834 //MPX_DEBUG2( "CMPXLbxExtendedFeatures::EnableKeySoundL: aEnable: %d", aEnable ); |
|
835 |
|
836 if ( aEnable ) |
|
837 { |
|
838 if ( !iKeysoundEnabled ) |
|
839 { |
|
840 MPX_DEBUG1( "CMPXLbxExtendedFeatures::EnableKeySoundL: aEnable: pop" ); |
|
841 iKeysoundEnabled = ETrue; |
|
842 // Enable keysound if it's not already enabled |
|
843 iAvkonViewAppUi->KeySounds()->PopContext(); |
|
844 MPX_DEBUG2( "CMPXLbxExtendedFeatures::EnableKeySoundL: aEnable: %d", aEnable ); |
|
845 } |
|
846 } |
|
847 else |
|
848 { |
|
849 if ( iKeysoundEnabled ) |
|
850 { |
|
851 MPX_DEBUG1( "CMPXLbxExtendedFeatures::EnableKeySoundL: aEnable: push" ); |
|
852 iKeysoundEnabled = EFalse; |
|
853 // Disable keysound if it's enabled |
|
854 iAvkonViewAppUi->KeySounds()->PushContextL( |
|
855 R_MPX_CUI_UP_DOWN_KEYS_SILENT ); |
|
856 MPX_DEBUG2( "CMPXLbxExtendedFeatures::EnableKeySoundL: aEnable: %d", aEnable ); |
|
857 } |
|
858 } |
|
859 } |
|
860 |
|
861 // ----------------------------------------------------------------------------- |
|
862 // CMPXLbxExtendedFeatures::SetIndexToCollectionL |
|
863 // Send a select index command to collection async |
|
864 // ----------------------------------------------------------------------------- |
|
865 // |
|
866 void CMPXLbxExtendedFeatures::SetIndexToCollectionL( |
|
867 TInt aIndex, TBool aForceSet ) |
|
868 { |
|
869 MPX_FUNC( "CMPXLbxExtendedFeatures::SetIndexToCollectionL" ); |
|
870 // In case we are speed scrolling, we may flood w/ many unfinished selects |
|
871 // |
|
872 TBool okToSet( ETrue ); |
|
873 if ( !aForceSet && iScrollingState == EMPXScrolling2ndSpeed ) |
|
874 { |
|
875 iIndexCount++; |
|
876 if ( iIndexCount < KSpeedScrollSetIndexInterval ) |
|
877 { |
|
878 okToSet = EFalse; |
|
879 } |
|
880 else |
|
881 { |
|
882 iIndexCount = 0; |
|
883 } |
|
884 } |
|
885 if ( okToSet ) |
|
886 { |
|
887 MPX_DEBUG1( "CMPXLbxExtendedFeatures::SetIndexToCollectionL ok to set" ); |
|
888 CMPXCommand* command = CMPXCommand::NewL(); |
|
889 CleanupStack::PushL( command ); |
|
890 command->SetTObjectValueL<TMPXCommandId>( KMPXCommandGeneralId, |
|
891 KMPXCommandIdCollectionSelect ); |
|
892 command->SetTObjectValueL( KMPXCommandCollectionSelectIndex, aIndex ); |
|
893 |
|
894 iCollectionUtility->Collection().CommandL( *command ); |
|
895 CleanupStack::PopAndDestroy( command ); |
|
896 } |
|
897 } |
|
898 |
|
899 // ----------------------------------------------------------------------------- |
|
900 // CMPXLbxExtendedFeatures::DoHandleCollectionMessageL |
|
901 // ----------------------------------------------------------------------------- |
|
902 void CMPXLbxExtendedFeatures::DoHandleCollectionMessageL( |
|
903 CMPXMessage* aMessage, |
|
904 TInt /*aError*/ ) |
|
905 { |
|
906 MPX_FUNC("CMPXLbxExtendedFeatures::DoHandleCollectionMessageL()"); |
|
907 |
|
908 TMPXMessageId id( aMessage->ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
909 if ( KMPXMessageGeneral == id ) |
|
910 { |
|
911 TInt event( aMessage->ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) ); |
|
912 TInt type( aMessage->ValueTObjectL<TInt>( KMPXMessageGeneralType ) ); |
|
913 if ( event == TMPXCollectionMessage::EPathChanged && |
|
914 type == EMcPathChangedByOpen ) |
|
915 { |
|
916 iCollectionUtility->Collection().CancelRequest(); |
|
917 } |
|
918 } |
|
919 } |
|
920 |
|
921 |
|
922 // ----------------------------------------------------------------------------- |
|
923 // CMPXLbxExtendedFeatures::MatoPrepareComplete |
|
924 // |
|
925 // Once tone initialization is complete, set tone settings and start playing |
|
926 // the tone. |
|
927 // |
|
928 // There's no fallback mechanism for tone player |
|
929 // ----------------------------------------------------------------------------- |
|
930 // |
|
931 void CMPXLbxExtendedFeatures::MatoPrepareComplete( TInt aError ) |
|
932 { |
|
933 //MPX_FUNC( "CMPXLbxExtendedFeatures::MatoPrepareComplete" ); |
|
934 MPX_DEBUG2( "CMPXLbxExtendedFeatures::MatoPrepareComplete START: aError = %d", aError ); |
|
935 |
|
936 MProfileEngine* profileEngine = NULL; |
|
937 MProfile* profile = NULL; |
|
938 TInt profileVolume = 0; |
|
939 |
|
940 MPX_TRAPD( err, profileEngine = CreateProfileEngineL() ); |
|
941 if( err ) |
|
942 { |
|
943 profileEngine = NULL; |
|
944 } |
|
945 |
|
946 if( profileEngine ) |
|
947 { |
|
948 TRAP_IGNORE( profile = profileEngine->ActiveProfileL() ); |
|
949 |
|
950 if( profile ) |
|
951 { |
|
952 const TProfileToneSettings& setting = |
|
953 profile->ProfileTones().ToneSettings(); |
|
954 profileVolume = ( setting.iRingingType == EProfileRingingTypeSilent ? |
|
955 0 : setting.iKeypadVolume ); |
|
956 profile->Release(); |
|
957 } |
|
958 profileEngine->Release(); |
|
959 } |
|
960 |
|
961 TInt toneVolume = iToneUtility->MaxVolume() * |
|
962 profileVolume / KMaxVolumeLevel; |
|
963 iToneUtility->SetVolume( toneVolume ); |
|
964 |
|
965 MPX_DEBUG1( "CMPXLbxExtendedFeatures::MatoPrepareComplete start playing" ); |
|
966 if ( KErrNone == aError ) |
|
967 { |
|
968 iSkipPlaying = EFalse; |
|
969 iToneUtility->Play(); |
|
970 } |
|
971 } |
|
972 |
|
973 // ----------------------------------------------------------------------------- |
|
974 // CMPXLbxExtendedFeatures::MatoPlayComplete |
|
975 // ----------------------------------------------------------------------------- |
|
976 // |
|
977 void CMPXLbxExtendedFeatures::MatoPlayComplete( TInt aError ) |
|
978 { |
|
979 //MPX_FUNC( "CMPXLbxExtendedFeatures::MatoPlayComplete" ); |
|
980 MPX_DEBUG4( "CMPXLbxExtendedFeatures::MatoPlayComplete START: iScrollingState = %d, iSkipPlaying = %d, aError = %d", |
|
981 iScrollingState, iSkipPlaying, aError); |
|
982 if ( ( KErrNone == aError ) && ( !iSkipPlaying ) ) |
|
983 { |
|
984 iToneUtility->Play(); |
|
985 } |
|
986 } |
|
987 |
|
988 // --------------------------------------------------------------------------- |
|
989 // From MMPXCollectionObserver. |
|
990 // Handle collection message. |
|
991 // --------------------------------------------------------------------------- |
|
992 // |
|
993 void CMPXLbxExtendedFeatures::HandleCollectionMessage( |
|
994 CMPXMessage* aMessage, TInt aError ) |
|
995 { |
|
996 MPX_FUNC( "CMPXLbxExtendedFeatures::HandleCollectionMessage" ); |
|
997 TRAP_IGNORE( DoHandleCollectionMessageL( aMessage, aError )); |
|
998 } |
|
999 |
|
1000 // --------------------------------------------------------------------------- |
|
1001 // From MMPXCollectionObserver |
|
1002 // Handles the collection entries being opened. Typically called |
|
1003 // when client has Open()'d a folder |
|
1004 // --------------------------------------------------------------------------- |
|
1005 // |
|
1006 void CMPXLbxExtendedFeatures::HandleOpenL( |
|
1007 const CMPXMedia& /*aEntries*/, |
|
1008 TInt /*aIndex*/, |
|
1009 TBool /*aComplete*/, |
|
1010 TInt /*aError*/ ) |
|
1011 { |
|
1012 MPX_FUNC( "CMPXLbxExtendedFeatures::HandleOpenL" ); |
|
1013 } |
|
1014 |
|
1015 // --------------------------------------------------------------------------- |
|
1016 // From MMPXCollectionObserver |
|
1017 // Handles the collection entries being opened. Typically called |
|
1018 // when client has Open()'d an item. Client typically responds by |
|
1019 // 'playing' the item |
|
1020 // --------------------------------------------------------------------------- |
|
1021 // |
|
1022 void CMPXLbxExtendedFeatures::HandleOpenL( |
|
1023 const CMPXCollectionPlaylist& /*aPlaylist*/, |
|
1024 TInt /*aError*/ ) |
|
1025 { |
|
1026 MPX_FUNC( "CMPXLbxExtendedFeatures::HandleOpenL 2" ); |
|
1027 // Do Nothing: playback/fetch client should handle this stage |
|
1028 } |
|
1029 |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // From MMPXCollectionObserver |
|
1032 // Handle media properties |
|
1033 // --------------------------------------------------------------------------- |
|
1034 // |
|
1035 void CMPXLbxExtendedFeatures::HandleCollectionMediaL( |
|
1036 const CMPXMedia& /*aMedia*/, |
|
1037 TInt /*aError*/) |
|
1038 { |
|
1039 MPX_FUNC( "CMPXLbxExtendedFeatures::HandleCollectionMediaL" ); |
|
1040 } |
|
1041 |
|
1042 // End of File |