locationtriggering/ltserver/ltserverlogic/inc/lbtcleanuphandler.h
changeset 56 4e949f03ecc5
equal deleted inserted replaced
-1:000000000000 56:4e949f03ecc5
       
     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:  This header file describes the class reposnible cleanuping
       
    15 *				 of triggers based on some filter after a particular duration
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef C_LBTCLEANUPHANDLER_H
       
    21 #define C_LBTCLEANUPHANDLER_H
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <e32base.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CLbtContainer;
       
    28 class CLbtCleanupItem;
       
    29 class TTime;
       
    30 
       
    31 class CLbtCleanupHandler : public CTimer
       
    32 	{
       
    33 	public:
       
    34 		/**
       
    35 	     * Constructs a new instance of cleanup handler. As soon as this object is 
       
    36 	     * created the a low priority timer is started and the cleanup is done after
       
    37 	     * the specified time. 
       
    38 	     *
       
    39 	     *
       
    40 	     * @return The new instance of cleanup handler object.
       
    41 	     */
       
    42 		static CLbtCleanupHandler* NewL( CLbtContainer &aContainer );
       
    43 				
       
    44 		/**
       
    45 		 * Adds triggers into the cleanup mechanism. The specified triggers will be
       
    46 		 * cleaned up after the specified cleanup time retreived from central repository.
       
    47 		 * The triggers specified will be saved onto a file for retreiving the trigger ids
       
    48 		 * in case of system reboot.
       
    49 		 *
       
    50 		 * @param aTriggers the trigger ids that need to be cleanedup
       
    51 		 */
       
    52 		void AddTriggersForCleanupL( const RArray<TLbtTriggerId>& aTriggers );
       
    53 		
       
    54 		/**
       
    55 		 * Removes the specified triggers from cleanup.
       
    56 		 *
       
    57 		 * @param aTriggers the trigger ids that need to be removed from clean up
       
    58 		 */
       
    59 		void RemoveTriggersFromCleanupL(const RArray<TLbtTriggerId>& aTriggers );
       
    60 		
       
    61 		/**
       
    62 		 * Cancels the ongoing operation. 
       
    63 		 */
       
    64 		void Cancel();
       
    65 		
       
    66 		/**
       
    67 	     * Destructor.
       
    68 	     */
       
    69 		~CLbtCleanupHandler();
       
    70 	
       
    71 	private: // new functions
       
    72 	
       
    73 		// Default constructor
       
    74 		CLbtCleanupHandler( CLbtContainer &aContainer );
       
    75 		
       
    76 		/**
       
    77 	     * Symbian 2nd phase of construction
       
    78 	     */
       
    79 		void ConstructL( );
       
    80 		
       
    81 		/**
       
    82 		 * Write the cleanup triggers into a file. This is needed in cases
       
    83 		 * when the system is rebooted.
       
    84 		 */
       
    85 		void WriteCleanupDataToFileL();
       
    86 		
       
    87 		/**
       
    88 		 * Reads the cleanup triggers from the saved file. This is done during
       
    89 		 * system startup
       
    90 		 */
       
    91 		void ReadCleanupDataFromFileL();
       
    92 		
       
    93 		/**
       
    94 		 * Cleans up the next item on the cleanup list. The cleanup list is
       
    95 		 * maintained and saved in a chronological order.
       
    96 		 *
       
    97 		 */
       
    98 		void CleanupNextItemL();
       
    99 			
       
   100 	private: // From CActive		
       
   101 		void RunL();		
       
   102 		TInt RunError(TInt aError);
       
   103 		
       
   104 	private: // data members
       
   105 
       
   106 		// Pointer to instance of Lbt Container
       
   107 		CLbtContainer &iContainer;
       
   108 	
       
   109 		// Array of pointers to hold the clean items
       
   110 		RPointerArray<CLbtCleanupItem> iCleanupItems;
       
   111 		
       
   112 		// Days for cleanup read up from repository
       
   113 		TInt iDaysForCleanup;
       
   114 		
       
   115 		// Local integer to ascertain the asynch operation
       
   116 		TInt iOperation;
       
   117 		
       
   118 		// operation code for container requests
       
   119 		TInt iContainerOp;
       
   120 	};
       
   121 
       
   122 /**
       
   123  * 
       
   124  */
       
   125 class CLbtCleanupItem : public CBase
       
   126 	{
       
   127 	public:
       
   128 	    /**
       
   129 	     *
       
   130 	     */
       
   131 		void AddCleanupItem( const RArray<TLbtTriggerId>& aTriggers, TTime& aUTCTime );
       
   132 		
       
   133 		/**
       
   134 	     *
       
   135 	     */
       
   136 		const TTime& GetTime() const;
       
   137 		
       
   138 		/**
       
   139 	     *
       
   140 	     */
       
   141 		RArray<TLbtTriggerId>& GetTriggers();
       
   142 
       
   143 		/**
       
   144 		 * Destructor
       
   145 		 */
       
   146 		 ~CLbtCleanupItem();
       
   147 
       
   148 	private:
       
   149 		// Array of trigger ids that need to be cleaned up
       
   150 		RArray<TLbtTriggerId> iTriggers;
       
   151 		
       
   152 		// The time at which the items have to be cleanedup
       
   153 		TTime iUTCTime;
       
   154 	};
       
   155 
       
   156 
       
   157 #endif //C_LBTCLEANUPHANDLER_H
       
   158 
       
   159 // end of file
       
   160