uiservicetab/vimpststorage/src/cvimpststorageactivehandler.cpp
changeset 15 81eeb8c83ce5
parent 0 5e5d6b214f4f
equal deleted inserted replaced
0:5e5d6b214f4f 15:81eeb8c83ce5
     1 /*
       
     2 * Copyright (c) 2008 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:  The CVIMPSTStorageActiveHandler class handles the waiting functionality 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cvimpststorageactivehandler.h"
       
    21 #include "mvimpststorageactiveobserver.h"
       
    22 
       
    23 #include "vimpstdebugtrace.h"
       
    24 #include <e32base.h>
       
    25 
       
    26 // CONSTANTS
       
    27 const TInt KTimeToWaitBeforeRefresh( 1000000 ); // 1 seconds in microseconds
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CVIMPSTStorageActiveHandler::CVIMPSTStorageActiveHandler
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CVIMPSTStorageActiveHandler::CVIMPSTStorageActiveHandler( MVIMPSTStorageActiveObserver* aObserver ) : 
       
    37     CTimer( EPriorityIdle ),
       
    38     iObserver( aObserver )
       
    39     {
       
    40 	CActiveScheduler::Add( this );
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CVIMPSTStorageActiveHandler::ConstructL
       
    45 // Symbian 2nd phase constructor can leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 void CVIMPSTStorageActiveHandler::ConstructL()
       
    49     {
       
    50 	// the base class must be constructed explicitely
       
    51 	CTimer::ConstructL();
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CVIMPSTStorageActiveHandler::NewL
       
    56 // Two-phased constructor.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CVIMPSTStorageActiveHandler* CVIMPSTStorageActiveHandler::NewL( 
       
    60 					MVIMPSTStorageActiveObserver* aObserver )
       
    61     {
       
    62     CVIMPSTStorageActiveHandler* self = new( ELeave ) CVIMPSTStorageActiveHandler( aObserver );
       
    63 	CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     CleanupStack::Pop( self );
       
    66 	return self;
       
    67     }
       
    68 
       
    69 // Destructor
       
    70 CVIMPSTStorageActiveHandler::~CVIMPSTStorageActiveHandler()
       
    71     {
       
    72 	Cancel();
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CVIMPSTStorageActiveHandler::Start
       
    77 // -----------------------------------------------------------------------------
       
    78 
       
    79 void CVIMPSTStorageActiveHandler::IssueRequest(TVIMPSTEnums::TVIMPSTStorgaeEventType aType,
       
    80 											  MVIMPSTStorageContactList *aList,
       
    81 					                          MVIMPSTStorageContact* aContact,
       
    82 					                          TInt aContactIndex )
       
    83 	{
       
    84 	TRACE( T_LIT("CVIMPSTStorageActiveHandler::IssueRequest() begin") );
       
    85 	
       
    86 	 if( IsActive() )
       
    87         {
       
    88         Cancel();
       
    89         }
       
    90     TTimeIntervalMicroSeconds32 waittime( KTimeToWaitBeforeRefresh );
       
    91     CTimer::After( waittime );
       
    92   
       
    93 	iEventType = aType ;
       
    94 	iList = aList ; 
       
    95 	iContact = aContact ;
       
    96 	iContactIndex = aContactIndex;
       
    97 	TRACE( T_LIT("CVIMPSTStorageActiveHandler::IssueRequest() end") );
       
    98 	}
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CVIMPSTStorageActiveHandler::RunL
       
   102 // Derived from CActive
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CVIMPSTStorageActiveHandler::RunL()
       
   106 	{
       
   107 	TRACE( T_LIT("CVIMPSTStorageActiveHandler::RunL() begin") );
       
   108 	if( iObserver )
       
   109 		{
       
   110 		TRACE( T_LIT("CVIMPSTStorageActiveHandler::RunL() send notification") );
       
   111 		TInt status( iStatus.Int() );
       
   112 	    if( status != KErrCancel )
       
   113             {
       
   114 		    iObserver->HandleDelayedNotificationL(iEventType,
       
   115 											iList ,
       
   116 											iContact,
       
   117 											iContactIndex );
       
   118             }
       
   119             
       
   120         
       
   121 		TRACE( T_LIT("CVIMPSTStorageActiveHandler::RunL() notification sent") );
       
   122 		}
       
   123     TRACE( T_LIT("CVIMPSTStorageActiveHandler::RunL() end") );
       
   124 	}
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CVIMPSTStorageActiveHandler::RunError
       
   128 // Derived from CActive
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 TInt CVIMPSTStorageActiveHandler::RunError( TInt aError )
       
   132 	{
       
   133 	TRACE( T_LIT("CVIMPSTStorageActiveHandler::RunError() begin") );
       
   134 	if( iObserver )
       
   135 		{
       
   136 	    TRAP_IGNORE( iObserver->HandleDelayedNotificationL(iEventType,
       
   137 											iList ,
       
   138 											iContact,
       
   139 											iContactIndex ) );
       
   140         }
       
   141     TRACE( T_LIT("CVIMPSTStorageActiveHandler::RunError() End ") );
       
   142 	return aError;
       
   143 	}
       
   144 // ---------------------------------------------------------
       
   145 // CVIMPSTStorageActiveHandler::DoCancel
       
   146 // Derived from CActive
       
   147 // ---------------------------------------------------------
       
   148 //
       
   149 void CVIMPSTStorageActiveHandler::DoCancel()
       
   150 	{
       
   151 	CTimer::DoCancel();// not required
       
   152 	}
       
   153 
       
   154 //  End of File