phonebookui/Phonebook2/CommonUI/inc/CPbk2CompressPolicyTimer.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Phonebook 2 database compression timeout timer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2COMPRESSPOLICYTIMER_H
       
    20 #define CPBK2COMPRESSPOLICYTIMER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MVPbkContactStoreObserver.h>
       
    25 #include "MPbk2CompressPolicy.h"
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class MPbk2CompressPolicyManager;
       
    29 class MVPbkContactStore;
       
    30 class MPbk2StoreObservationRegister;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35  * Phonebook 2 database compression timeout timer.
       
    36  * Responsible for measuring time since last contact store event.
       
    37  * If the specified time interval is achieved with no interrupting store
       
    38  * events, tells the compress manager to start the compress.
       
    39  */
       
    40 NONSHARABLE_CLASS(CPbk2CompressPolicyTimer) :
       
    41         public CTimer,
       
    42         public MPbk2CompressPolicy,
       
    43         public MVPbkContactStoreObserver
       
    44 
       
    45     {
       
    46     public: // Construction and destruction
       
    47 
       
    48         /**
       
    49          * Creates a new instance of this class.
       
    50          *
       
    51          * @param aStoreObservationRegister     Store observation register.
       
    52          * @param aObserver                     Observer.
       
    53          * @param aTimeout                      Compression time interval.
       
    54          * @return  A new instance of this class.
       
    55          */
       
    56         static CPbk2CompressPolicyTimer* NewL(
       
    57                 MPbk2StoreObservationRegister& aStoreObservationRegister,
       
    58                 MPbk2CompressPolicyManager& aObserver,
       
    59                 TTimeIntervalSeconds aTimeout );
       
    60 
       
    61         /**
       
    62          * Destructor.
       
    63          */
       
    64         ~CPbk2CompressPolicyTimer();
       
    65 
       
    66     public: // From MPbk2CompressPolicy
       
    67         void Start();
       
    68         void Stop();
       
    69 
       
    70     public: // From MVPbkContactStoreObserver
       
    71         void StoreReady(
       
    72                 MVPbkContactStore& aContactStore );
       
    73         void StoreUnavailable(
       
    74                 MVPbkContactStore& aContactStore,
       
    75                 TInt aReason );
       
    76         void HandleStoreEventL(
       
    77                 MVPbkContactStore& aContactStore,
       
    78                 TVPbkContactStoreEvent aStoreEvent );
       
    79 
       
    80     private: // From CTimer
       
    81         void RunL();
       
    82         TInt RunError(
       
    83                 TInt aError );
       
    84 
       
    85     private: // Implementation
       
    86         CPbk2CompressPolicyTimer(
       
    87                 MPbk2StoreObservationRegister& aStoreObservationRegister,
       
    88                 MPbk2CompressPolicyManager& aObserver,
       
    89                 TTimeIntervalSeconds aTimeout );
       
    90         void ConstructL();
       
    91         void StartTimer();
       
    92         void RegisterToListenEventsSafely();
       
    93 
       
    94     private: // Data
       
    95         /// Ref: Store observation register
       
    96         MPbk2StoreObservationRegister& iStoreObservationRegister;
       
    97         /// Ref: Compress policy manager
       
    98         MPbk2CompressPolicyManager& iManager;
       
    99         /// Own: Time out
       
   100         TTimeIntervalMicroSeconds32 iTimeout;
       
   101         /// Own: Restart indicator
       
   102         TBool iRestarted;
       
   103     };
       
   104 
       
   105 #endif // CPBK2COMPRESSPOLICYTIMER_H
       
   106 
       
   107 // End of File