emailservices/emailserver/cmailhandlerplugin/src/emailsoundstates.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Class to handle email sound playing.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <AudioPreference.h>
       
    20 #include <MProfileEngine.h>
       
    21 #include <MProfile.h>
       
    22 #include <MProfileTones.h>
       
    23 #include <MProfileExtraTones.h>
       
    24 #include <TProfileToneSettings.h>
       
    25 #include <CProfileChangeNotifyHandler.h>
       
    26 #include <coreapplicationuisdomainpskeys.h>
       
    27 
       
    28 #include "emailtrace.h"
       
    29 #include "memailsoundstatecontext.h"
       
    30 #include "emailsoundstates.h"
       
    31 #include "fsnotificationhandlertimer.h"
       
    32 #include "cmailhandlerpluginpanic.h"
       
    33 
       
    34 // Local constants
       
    35 static const TInt KToneMinVolume = 0;
       
    36 static const TInt KToneMaxVolume = 10;
       
    37 static const TInt KDelayTimerInterval = 60000000; // 60s
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // Initializes the state machine by setting initial state and creating
       
    41 // failure state that can be entered at any time in error cases.
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 void CEmailSoundState::InitializeL( MEmailSoundStateContext* aContext )
       
    45     {
       
    46     FUNC_LOG
       
    47     TAny* tls = Dll::Tls();
       
    48     if ( !tls )
       
    49         {
       
    50         // prepare failed state so its always available
       
    51         CEmailSoundState* failedState = new ( ELeave ) CEmailSoundFailed( *aContext );
       
    52         Dll::SetTls( failedState );
       
    53         // now enter to initial state, use failed state for obtaining context
       
    54         CEmailInitilisingTone::EnterL( failedState );
       
    55         }
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // Exits the state machine and frees memory allocated for states
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 void CEmailSoundState::Uninitialize( CEmailSoundState* aCurrentState )
       
    63     {
       
    64     FUNC_LOG
       
    65 
       
    66     if ( aCurrentState )
       
    67         {
       
    68         // Exit must be called before deleting failedState because it may
       
    69         // also be current state.
       
    70         aCurrentState->Exit();
       
    71         }
       
    72 
       
    73     TAny* tls = Dll::Tls();
       
    74     if ( tls )
       
    75         {
       
    76         CEmailSoundState* failedState =
       
    77             reinterpret_cast<CEmailSoundState*>( tls );
       
    78         delete failedState;
       
    79         Dll::SetTls( NULL );
       
    80         }
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // No-op in base class, also enough for some derived classes.
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CEmailSoundState::ProfileChanged()
       
    88     {
       
    89     FUNC_LOG
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // Tone initialization failure always leads to failed state.
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 void CEmailSoundState::AudioInitFailed()
       
    97     {
       
    98     FUNC_LOG
       
    99     // enter to failed state.
       
   100     StateTransition( EFailed );
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // Derived classes implement
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CEmailSoundState::AudioInitCompleted()
       
   108     {
       
   109     FUNC_LOG
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // Derived classes implement
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 void CEmailSoundState::AudioPlayCompleted()
       
   117     {
       
   118     FUNC_LOG
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // Handled in CEmailReadyToPlay state, in most other states ignored.
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CEmailSoundState::PlayTone()
       
   126     {
       
   127     FUNC_LOG
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // Applicable only in playing state
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 void CEmailSoundState::StopTone()
       
   135     {
       
   136     FUNC_LOG
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // Tries to create audio player or activas failed state if error occurs
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 TBool CEmailSoundState::TryStartToneInitialization()
       
   144     {
       
   145     FUNC_LOG
       
   146     TRAPD( err, iContext.RecreateAudioPlayerL() );
       
   147     if ( err )
       
   148         {
       
   149         StateTransition( EFailed );
       
   150         }
       
   151     return ( err == KErrNone );
       
   152     }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // Stores as current state in owner of the state machine.
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void CEmailSoundState::BaseEnter()
       
   159     {
       
   160     FUNC_LOG
       
   161     iContext.SetState( this );
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // State transition to requested state or failed state if attempt doesn't
       
   166 // succeed.
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 void CEmailSoundState::StateTransition( const TSoundState aState )
       
   170     {
       
   171     FUNC_LOG
       
   172     TRAPD( err,
       
   173         {
       
   174         switch ( aState )
       
   175             {
       
   176             case EInit:
       
   177                 CEmailInitilisingTone::EnterL( this );
       
   178                 break;
       
   179             case EReady:
       
   180                 CEmailReadyToPlay::EnterL( this );
       
   181                 break;
       
   182             case EPlaying:
       
   183                 CEmailPlayingTone::EnterL( this );
       
   184                 break;
       
   185             case EPendingPlay:
       
   186                 CEmailPendingPlay::EnterL( this );
       
   187                 break;
       
   188             case EPendingInit:
       
   189                 CEmailPendingInit::EnterL( this );
       
   190                 break;
       
   191             case EDelay:
       
   192                 CEmailTimerDelay::EnterL( this );
       
   193                 break;
       
   194             case EFailed:
       
   195             default:
       
   196                 // to failed state
       
   197                 /* CodeScanner warning ignored because CS does not regognize
       
   198                  * TRAP being used */
       
   199                 User::Leave( KErrArgument ); // codescanner::leave
       
   200                 break;
       
   201             }
       
   202         } );
       
   203     if ( err != KErrNone )
       
   204         {
       
   205         CEmailSoundFailed::Enter( this );
       
   206         }
       
   207     // exit old state
       
   208     Exit();
       
   209     }
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // For most states destructor call is fine.
       
   213 // See also CEmailSoundFailed::Exit()
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 void CEmailSoundState::Exit()
       
   217     {
       
   218     FUNC_LOG
       
   219     delete this;
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------------------------
       
   223 // ---------------------------------------------------------------------------
       
   224 //
       
   225 MEmailSoundStateContext& CEmailSoundState::Context() const
       
   226     {
       
   227     FUNC_LOG
       
   228     return iContext;
       
   229     }
       
   230 
       
   231 // ---------------------------------------------------------------------------
       
   232 //
       
   233 // ---------------------------------------------------------------------------
       
   234 //
       
   235 CEmailSoundState::~CEmailSoundState()
       
   236     {
       
   237     FUNC_LOG
       
   238     }
       
   239 
       
   240 // ---------------------------------------------------------------------------
       
   241 // c++ constructor
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 CEmailSoundState::CEmailSoundState(
       
   245     MEmailSoundStateContext& aContext ) :
       
   246     iContext( aContext )
       
   247     {
       
   248     FUNC_LOG
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // c++ constructor
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 CEmailInitilisingTone::CEmailInitilisingTone(
       
   256     MEmailSoundStateContext& aContext ) :
       
   257     CEmailSoundState( aContext )
       
   258     {
       
   259     FUNC_LOG
       
   260     }
       
   261 
       
   262 // ---------------------------------------------------------------------------
       
   263 // Need to cancel and restart tone initialization
       
   264 // ---------------------------------------------------------------------------
       
   265 //
       
   266 void CEmailInitilisingTone::ProfileChanged()
       
   267     {
       
   268     FUNC_LOG
       
   269     TryStartToneInitialization();
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------------------------
       
   273 //
       
   274 // ---------------------------------------------------------------------------
       
   275 //
       
   276 void CEmailInitilisingTone::AudioInitCompleted()
       
   277     {
       
   278     FUNC_LOG
       
   279     StateTransition( EReady );
       
   280     }
       
   281 
       
   282 
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 // ---------------------------------------------------------------------------
       
   286 //
       
   287 void CEmailInitilisingTone::PlayTone()
       
   288     {
       
   289     FUNC_LOG
       
   290     // not ready yet, postpone playing
       
   291     StateTransition( EPendingPlay );
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 //
       
   296 // ---------------------------------------------------------------------------
       
   297 //
       
   298 void CEmailInitilisingTone::DoEnterL()
       
   299     {
       
   300     FUNC_LOG
       
   301     iContext.RecreateAudioPlayerL();
       
   302     CEmailSoundState::BaseEnter();
       
   303     }
       
   304 
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 // ---------------------------------------------------------------------------
       
   308 //
       
   309 void CEmailInitilisingTone::EnterL( CEmailSoundState* aPreviousState )
       
   310     {
       
   311     FUNC_LOG
       
   312     CEmailInitilisingTone* state = new ( ELeave )
       
   313         CEmailInitilisingTone( aPreviousState->Context() );
       
   314     CleanupStack::PushL( state );
       
   315     state->DoEnterL();
       
   316     CleanupStack::Pop();
       
   317     }
       
   318 
       
   319 // ---------------------------------------------------------------------------
       
   320 // c++ constructor
       
   321 // ---------------------------------------------------------------------------
       
   322 //
       
   323 CEmailReadyToPlay::CEmailReadyToPlay( MEmailSoundStateContext& aContext )
       
   324  : CEmailSoundState( aContext )
       
   325     {
       
   326     FUNC_LOG
       
   327     }
       
   328 
       
   329 // ---------------------------------------------------------------------------
       
   330 // New profile may have different tone, initialize it.
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 void CEmailReadyToPlay::ProfileChanged()
       
   334     {
       
   335     FUNC_LOG
       
   336     StateTransition( EInit );
       
   337     }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 //
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 void CEmailReadyToPlay::PlayTone()
       
   344     {
       
   345     FUNC_LOG
       
   346     StateTransition( EPlaying );
       
   347     }
       
   348 
       
   349 // ---------------------------------------------------------------------------
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 void CEmailReadyToPlay::DoEnterL()
       
   353     {
       
   354     FUNC_LOG
       
   355     CEmailSoundState::BaseEnter();
       
   356     }
       
   357 
       
   358 // ---------------------------------------------------------------------------
       
   359 // ---------------------------------------------------------------------------
       
   360 //
       
   361 void CEmailReadyToPlay::EnterL(
       
   362     CEmailSoundState* aPreviousState )
       
   363     {
       
   364     FUNC_LOG
       
   365     CEmailReadyToPlay* state = new ( ELeave ) CEmailReadyToPlay(
       
   366         aPreviousState->Context() );
       
   367     CleanupStack::PushL( state );
       
   368     state->DoEnterL();
       
   369     CleanupStack::Pop();
       
   370     }
       
   371 
       
   372 // ---------------------------------------------------------------------------
       
   373 // c++ constructor
       
   374 // ---------------------------------------------------------------------------
       
   375 //
       
   376 CEmailSoundFailed::CEmailSoundFailed( MEmailSoundStateContext& aContext )
       
   377  : CEmailSoundState( aContext )
       
   378     {
       
   379     FUNC_LOG
       
   380     }
       
   381 
       
   382 // ---------------------------------------------------------------------------
       
   383 // Something has gone wrong earlier, now try recovery (re-init).
       
   384 // ---------------------------------------------------------------------------
       
   385 //
       
   386 void CEmailSoundFailed::ProfileChanged()
       
   387     {
       
   388     FUNC_LOG
       
   389     // try re-initialization
       
   390     StateTransition( EInit );
       
   391     }
       
   392 
       
   393 // ---------------------------------------------------------------------------
       
   394 // Something has gone wrong earlier, now try recovery (re-init + play ).
       
   395 // ---------------------------------------------------------------------------
       
   396 //
       
   397 void CEmailSoundFailed::PlayTone()
       
   398     {
       
   399     FUNC_LOG
       
   400     // kick off tone re-creation again
       
   401     if ( TryStartToneInitialization() )
       
   402         {
       
   403         StateTransition( EPendingPlay );
       
   404         }
       
   405     }
       
   406 
       
   407 // ---------------------------------------------------------------------------
       
   408 // Set failed state as current state.
       
   409 // ---------------------------------------------------------------------------
       
   410 //
       
   411 void CEmailSoundFailed::DoEnter()
       
   412     {
       
   413     FUNC_LOG
       
   414     CEmailSoundState::BaseEnter();
       
   415     }
       
   416 
       
   417 // ---------------------------------------------------------------------------
       
   418 // Failed state is preserved until plugin shutdown, therefore base class Exit()
       
   419 // is overridden and explicit destruction for this class is done in
       
   420 // CEmailSoundState::Uninitialize.
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 void CEmailSoundFailed::Exit()
       
   424     {
       
   425     FUNC_LOG
       
   426     }
       
   427 
       
   428 // ---------------------------------------------------------------------------
       
   429 // Obtain failed state from TLS and set it as current state.
       
   430 // ---------------------------------------------------------------------------
       
   431 //
       
   432 void CEmailSoundFailed::Enter( CEmailSoundState* /*aPreviousState*/ )
       
   433     {
       
   434     FUNC_LOG
       
   435     TAny* tls = Dll::Tls();
       
   436     __ASSERT_ALWAYS( tls, Panic( ECmailHandlerPluginPanicNoFailedState ) );
       
   437     CEmailSoundFailed* failedState = reinterpret_cast<CEmailSoundFailed*>( tls );
       
   438     failedState->DoEnter();
       
   439     }
       
   440 
       
   441 // ---------------------------------------------------------------------------
       
   442 // c++ constructor
       
   443 // ---------------------------------------------------------------------------
       
   444 //
       
   445 CEmailPlayingTone::CEmailPlayingTone( MEmailSoundStateContext& aContext )
       
   446  : CEmailSoundState( aContext )
       
   447     {
       
   448     FUNC_LOG
       
   449     }
       
   450 
       
   451 // ---------------------------------------------------------------------------
       
   452 // When playing completes, recreate tone because new profile may have
       
   453 // different one.
       
   454 // ---------------------------------------------------------------------------
       
   455 //
       
   456 void CEmailPlayingTone::ProfileChanged()
       
   457     {
       
   458     FUNC_LOG
       
   459     StateTransition( EPendingInit );
       
   460     }
       
   461 
       
   462 // ---------------------------------------------------------------------------
       
   463 // Proceed to delay state.
       
   464 // Existing player instance owned by context is preserved.
       
   465 // ---------------------------------------------------------------------------
       
   466 //
       
   467 void CEmailPlayingTone::AudioPlayCompleted()
       
   468     {
       
   469     FUNC_LOG
       
   470 
       
   471     // Tell sysap that tone playing has stopped
       
   472     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, ECoreAppUIsStopTonePlaying );
       
   473 
       
   474     StateTransition( EDelay );
       
   475     }
       
   476 
       
   477 // ---------------------------------------------------------------------------
       
   478 // Stop tone and proceed to delay state.
       
   479 // ---------------------------------------------------------------------------
       
   480 //
       
   481 void CEmailPlayingTone::StopTone()
       
   482     {
       
   483     FUNC_LOG
       
   484     CMdaAudioPlayerUtility* player = iContext.AudioPlayer();
       
   485     // should never be null in this state
       
   486     __ASSERT_ALWAYS( player, Panic( ECmailHandlerPluginPanicNullAudioPlayer ) );
       
   487     player->Stop();
       
   488 
       
   489     // Tell sysap that tone playing has stopped
       
   490     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, ECoreAppUIsStopTonePlaying );
       
   491 
       
   492     StateTransition( EDelay );
       
   493     }
       
   494 
       
   495 // ---------------------------------------------------------------------------
       
   496 // Starts playing of already initialized tone.
       
   497 // ---------------------------------------------------------------------------
       
   498 //
       
   499 void CEmailPlayingTone::EnterL( CEmailSoundState* aPreviousState )
       
   500     {
       
   501     FUNC_LOG
       
   502     CEmailPlayingTone* state = new ( ELeave ) CEmailPlayingTone(
       
   503         aPreviousState->Context() );
       
   504     CleanupStack::PushL( state );
       
   505     state->DoEnterL();
       
   506     CleanupStack::Pop();
       
   507     }
       
   508 
       
   509 // ---------------------------------------------------------------------------
       
   510 // Playes 'new email' tone.
       
   511 // ---------------------------------------------------------------------------
       
   512 //
       
   513 void CEmailPlayingTone::DoEnterL()
       
   514     {
       
   515     FUNC_LOG
       
   516     CMdaAudioPlayerUtility* player = iContext.AudioPlayer();
       
   517     // should never be null in this state
       
   518     __ASSERT_ALWAYS( player, Panic( ECmailHandlerPluginPanicNullAudioPlayer ) );
       
   519 
       
   520     MProfile* profile = iContext.ProfileEngine().ActiveProfileL(); // owned
       
   521 
       
   522     const TInt profileVolume =
       
   523         profile->ProfileTones().ToneSettings().iRingingVolume;
       
   524     TInt volume = Max( KToneMinVolume, Min( profileVolume, KToneMaxVolume ) );
       
   525     profile->Release();
       
   526     profile = NULL;
       
   527 
       
   528     // scale with player but only if volume is greater than zero
       
   529     if ( volume > 0 )
       
   530         {
       
   531         volume = volume * player->MaxVolume() / KToneMaxVolume ;
       
   532         }
       
   533     INFO_1( "email tone volume", volume )
       
   534     player->SetVolume( volume );
       
   535 
       
   536     // Set time
       
   537     TTimeIntervalMicroSeconds time = TTimeIntervalMicroSeconds( 0 );
       
   538 
       
   539     // Tell sysap that there's a tone playing at the moment
       
   540     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsMessageToneQuit, ECoreAppUIsTonePlaying );
       
   541 
       
   542     // Set repeats and start playing
       
   543     player->SetRepeats( 0, time );
       
   544     player->Play();
       
   545     CEmailSoundState::BaseEnter();
       
   546     };
       
   547 
       
   548 // ---------------------------------------------------------------------------
       
   549 // c++ constructor
       
   550 // ---------------------------------------------------------------------------
       
   551 //
       
   552 CEmailPendingPlay::CEmailPendingPlay( MEmailSoundStateContext& aContext )
       
   553  : CEmailSoundState( aContext )
       
   554     {
       
   555     FUNC_LOG
       
   556     }
       
   557 
       
   558 // ---------------------------------------------------------------------------
       
   559 // Currently initializing tone is outdated, need to re-init and play
       
   560 // immediately.
       
   561 // ---------------------------------------------------------------------------
       
   562 //
       
   563 void CEmailPendingPlay::ProfileChanged()
       
   564     {
       
   565     FUNC_LOG
       
   566     TryStartToneInitialization();
       
   567     }
       
   568 
       
   569 // ---------------------------------------------------------------------------
       
   570 // Play was requested while tone initialization was ongoing, no its ready
       
   571 // and tone can be played.
       
   572 // ---------------------------------------------------------------------------
       
   573 //
       
   574 void CEmailPendingPlay::AudioInitCompleted()
       
   575     {
       
   576     FUNC_LOG
       
   577     StateTransition( EPlaying );
       
   578     }
       
   579 
       
   580 // ---------------------------------------------------------------------------
       
   581 // Activates this state.
       
   582 // ---------------------------------------------------------------------------
       
   583 //
       
   584 void CEmailPendingPlay::DoEnterL()
       
   585     {
       
   586     FUNC_LOG
       
   587     CEmailSoundState::BaseEnter();
       
   588     }
       
   589 
       
   590 // ---------------------------------------------------------------------------
       
   591 // Playing tone was requested during initialization.
       
   592 // ---------------------------------------------------------------------------
       
   593 //
       
   594 void CEmailPendingPlay::EnterL( CEmailSoundState* aPreviousState )
       
   595     {
       
   596     FUNC_LOG
       
   597     CEmailPendingPlay* state = new ( ELeave ) CEmailPendingPlay(
       
   598         aPreviousState->Context() );
       
   599     CleanupStack::PushL( state );
       
   600     state->DoEnterL();
       
   601     CleanupStack::Pop();
       
   602     }
       
   603 
       
   604 // ---------------------------------------------------------------------------
       
   605 // c++ constructor
       
   606 // ---------------------------------------------------------------------------
       
   607 //
       
   608 CEmailPendingInit::CEmailPendingInit( MEmailSoundStateContext& aContext )
       
   609  : CEmailSoundState( aContext )
       
   610     {
       
   611     FUNC_LOG
       
   612     }
       
   613 
       
   614 // ---------------------------------------------------------------------------
       
   615 // Playback finished and tone can be initialized.
       
   616 // ---------------------------------------------------------------------------
       
   617 //
       
   618 void CEmailPendingInit::AudioPlayCompleted()
       
   619     {
       
   620     FUNC_LOG
       
   621     // now we can re-init new tone
       
   622     StateTransition( EInit );
       
   623     }
       
   624 
       
   625 // ---------------------------------------------------------------------------
       
   626 // Activates this state.
       
   627 // ---------------------------------------------------------------------------
       
   628 //
       
   629 void CEmailPendingInit::DoEnterL()
       
   630     {
       
   631     FUNC_LOG
       
   632     CEmailSoundState::BaseEnter();
       
   633     }
       
   634 
       
   635 // ---------------------------------------------------------------------------
       
   636 // Tone initialization was requested during playback.
       
   637 // ---------------------------------------------------------------------------
       
   638 //
       
   639 void CEmailPendingInit::EnterL( CEmailSoundState* aPreviousState )
       
   640     {
       
   641     FUNC_LOG
       
   642     CEmailPendingInit* state = new ( ELeave ) CEmailPendingInit(
       
   643         aPreviousState->Context() );
       
   644     CleanupStack::PushL( state );
       
   645     state->DoEnterL();
       
   646     CleanupStack::Pop();
       
   647     }
       
   648 
       
   649 // ---------------------------------------------------------------------------
       
   650 // c++ constructor
       
   651 // ---------------------------------------------------------------------------
       
   652 //
       
   653 CEmailTimerDelay::CEmailTimerDelay( MEmailSoundStateContext& aContext )
       
   654  : CEmailSoundState( aContext )
       
   655     {
       
   656     FUNC_LOG
       
   657     }
       
   658 
       
   659 // ---------------------------------------------------------------------------
       
   660 // New profile may have different tone, try initialize it.
       
   661 // ---------------------------------------------------------------------------
       
   662 //
       
   663 void CEmailTimerDelay::ProfileChanged()
       
   664     {
       
   665     FUNC_LOG
       
   666     TryStartToneInitialization();
       
   667     }
       
   668 
       
   669 // ---------------------------------------------------------------------------
       
   670 // Timer expired. Ready to play again.
       
   671 // ---------------------------------------------------------------------------
       
   672 //
       
   673 void CEmailTimerDelay::TimerCallBackL( TInt /*aError*/ )
       
   674     {
       
   675     FUNC_LOG
       
   676     StateTransition( EReady );
       
   677     }
       
   678 
       
   679 // ---------------------------------------------------------------------------
       
   680 // Destructor
       
   681 // ---------------------------------------------------------------------------
       
   682 //
       
   683 CEmailTimerDelay::~CEmailTimerDelay()
       
   684     {
       
   685     FUNC_LOG
       
   686     delete iTimer;
       
   687     }
       
   688 
       
   689 // ---------------------------------------------------------------------------
       
   690 // 
       
   691 // ---------------------------------------------------------------------------
       
   692 //
       
   693 void CEmailTimerDelay::DoEnterL()
       
   694     {
       
   695     FUNC_LOG
       
   696     iTimer = CFSNotificationHandlerTimer::NewL( *this );
       
   697     iTimer->After( KDelayTimerInterval );
       
   698     CEmailSoundState::BaseEnter();
       
   699     }
       
   700 // ---------------------------------------------------------------------------
       
   701 // Starts delay timer
       
   702 // ---------------------------------------------------------------------------
       
   703 //
       
   704 void CEmailTimerDelay::EnterL( CEmailSoundState* aPreviousState )
       
   705     {
       
   706     FUNC_LOG
       
   707     CEmailTimerDelay* state = new ( ELeave ) CEmailTimerDelay(
       
   708         aPreviousState->Context() );
       
   709     CleanupStack::PushL( state );
       
   710     state->DoEnterL();
       
   711     CleanupStack::Pop( state );
       
   712     }
       
   713 
       
   714 // End of file