phonebookui/Phonebook2/NamesListExtension/src/CPbk2DelayedWaitNote.cpp
branchRCL_3
changeset 13 a6539d1e8e43
child 21 9da50d567e3c
equal deleted inserted replaced
12:4ae315f230bc 13:a6539d1e8e43
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Phonebook2  helper class
       
    15 *              
       
    16 */
       
    17 
       
    18 //  INCLUDES
       
    19 #include <Pbk2ProcessDecoratorFactory.h>
       
    20 #include <Pbk2UIControls.rsg>
       
    21 #include <avkon.hrh>
       
    22 #include "CPbk2DelayedWaitNote.h"
       
    23 
       
    24 #include <coemain.h> // For EActivePriorityClockTimer
       
    25 
       
    26 const TInt KDelay = 500000; // 0.5 seconds
       
    27 
       
    28 CPbk2DelayedWaitNote* CPbk2DelayedWaitNote::NewL
       
    29         ( MPbk2ProcessDecoratorObserver& aObserver, TInt aResourceId )
       
    30     {
       
    31     CPbk2DelayedWaitNote* self = 
       
    32         new ( ELeave ) CPbk2DelayedWaitNote( aObserver, aResourceId );
       
    33     CleanupStack::PushL( self );
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 CPbk2DelayedWaitNote::~CPbk2DelayedWaitNote()
       
    40     {
       
    41     Cancel();
       
    42     delete iDecorator;
       
    43     iDecorator = NULL;
       
    44     }
       
    45 
       
    46 CPbk2DelayedWaitNote::CPbk2DelayedWaitNote
       
    47         ( MPbk2ProcessDecoratorObserver& aObserver, TInt aResourceId )
       
    48         : CTimer( EActivePriorityClockTimer ), iObserver( aObserver ), 
       
    49           iResourceId( aResourceId )
       
    50     {
       
    51     
       
    52     }
       
    53 
       
    54 void CPbk2DelayedWaitNote::ConstructL()
       
    55     {
       
    56     CActiveScheduler::Add( this );
       
    57     CTimer::ConstructL();
       
    58     }
       
    59 
       
    60 void CPbk2DelayedWaitNote::Stop()
       
    61     {
       
    62     Cancel();
       
    63     DismissWaitNote();
       
    64     }
       
    65 
       
    66 void CPbk2DelayedWaitNote::Start()
       
    67     {
       
    68     if ( !IsActive() && !iStarted )
       
    69         {
       
    70         After( TTimeIntervalMicroSeconds32( KDelay ) );
       
    71         }
       
    72     }
       
    73 
       
    74 void CPbk2DelayedWaitNote::RunL()
       
    75     {   
       
    76     if( !iStarted && !iDecorator )
       
    77         {   
       
    78         iDecorator = Pbk2ProcessDecoratorFactory::CreateWaitNoteDecoratorL
       
    79                   ( iResourceId, EFalse );
       
    80         iDecorator->SetObserver( *this );
       
    81         iDecorator->ProcessStartedL( 0 ); // wait note doesn't care about amount
       
    82         iStarted = ETrue;
       
    83         }
       
    84     }
       
    85 
       
    86 void CPbk2DelayedWaitNote::ProcessDismissed( TInt aCancelCode )
       
    87     {
       
    88     iStarted = EFalse;
       
    89     iObserver.ProcessDismissed( aCancelCode );
       
    90     }
       
    91 
       
    92 TInt CPbk2DelayedWaitNote::RunError( TInt /*aError*/ )
       
    93     {
       
    94     iStarted = EFalse;
       
    95     DismissWaitNote();
       
    96     return KErrNone;
       
    97     }
       
    98 
       
    99 void CPbk2DelayedWaitNote::DismissWaitNote()
       
   100     {
       
   101     if ( iDecorator )
       
   102         {
       
   103         TRAPD( err, iDecorator->ProcessStopped() );
       
   104         if ( err != KErrNone )
       
   105             {
       
   106             delete iDecorator;
       
   107             iDecorator = NULL;
       
   108             }
       
   109         }
       
   110     else 
       
   111         {
       
   112         iObserver.ProcessDismissed( EAknSoftkeyDone );
       
   113         }   
       
   114     }
       
   115 // End of File