syncmlfw/common/historylog/inc/NSmlHistoryArray.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2004 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: 
       
    15 *		Declaration file for history array.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __NSMLHISTORYARRAY_H__
       
    21 #define __NSMLHISTORYARRAY_H__
       
    22 
       
    23 #include <e32cmn.h>
       
    24 #include "nsmlconstants.h"
       
    25 #include <SyncMLHistory.h>
       
    26 
       
    27 
       
    28 class CSyncMLHistoryEntry;
       
    29 
       
    30 class CNSmlHistoryArray : public CBase
       
    31 	{
       
    32 	public:
       
    33 	
       
    34 		/**
       
    35         * Two-phased constructor.
       
    36         */
       
    37 		static IMPORT_C CNSmlHistoryArray* NewL();
       
    38 		
       
    39 		/**
       
    40         * Destructor
       
    41         */
       
    42 		~CNSmlHistoryArray();
       
    43 		
       
    44 	public:
       
    45 		
       
    46 		/**
       
    47         * Returns count of history entries
       
    48         * @since Series ?XX ?SeriesXX_version
       
    49         * @param -
       
    50         * @return Count of history entries in the array
       
    51         */
       
    52 		IMPORT_C TInt Count();
       
    53 		
       
    54 		/**
       
    55         * Adds new entry to history entry array
       
    56         * @since Series ?XX ?SeriesXX_version
       
    57         * @param aEntry pointer to entry to be added
       
    58         * @return -
       
    59         */
       
    60 		IMPORT_C void AppendEntryL( CSyncMLHistoryEntry* aEntry );
       
    61 		
       
    62 		/**
       
    63         * Removes entry from the specified index
       
    64         * @since Series ?XX ?SeriesXX_version
       
    65         * @param aIndex Index of the entry to be removed
       
    66         * @return Pointer to the removed entry
       
    67         */
       
    68 		IMPORT_C CSyncMLHistoryEntry* RemoveEntry( TInt aIndex );
       
    69 		
       
    70 		/**
       
    71         * Removes all history entries from the array
       
    72         * @since Series ?XX ?SeriesXX_version
       
    73         * @param -
       
    74         * @return -
       
    75         */
       
    76 		IMPORT_C void DeleteAllEntries();
       
    77 		
       
    78 		/**
       
    79         * Retrieves an entry from the array
       
    80         * @since Series ?XX ?SeriesXX_version
       
    81         * @param aIndex Index of the entry to be retrieved 
       
    82         * @return Reference to the retrieved entry
       
    83         */
       
    84 		IMPORT_C CSyncMLHistoryEntry& Entry( TInt aIndex );
       
    85 		
       
    86 		/**
       
    87         * Sorts the history array by specified key
       
    88         * @since Series ?XX ?SeriesXX_version
       
    89         * @param aSortOrder Specifies the way sorting is performed
       
    90         * @return -
       
    91         */
       
    92 		IMPORT_C void SortEntries( CSyncMLHistoryEntry::TSortOrder aSortOrder );
       
    93 		
       
    94 		/**
       
    95         * Transfers the ownership of the entries in the array
       
    96         * @since Series ?XX ?SeriesXX_version
       
    97         * @param aOwner ETrue transfers ownership to history array, EFalse sets ownership to caller
       
    98         * @return -
       
    99         */
       
   100 		IMPORT_C void SetOwnerShip( TBool aOwner );
       
   101 		
       
   102 		/**
       
   103         * Reads data from the given stream
       
   104         * @since Series ?XX ?SeriesXX_version
       
   105         * @param aStream Reference to stream data is read from
       
   106         * @return -
       
   107         */
       
   108 		IMPORT_C void InternalizeL( RReadStream& aStream );
       
   109 		
       
   110 		/**
       
   111         * Writes data to the given stream
       
   112         * @since Series ?XX ?SeriesXX_version
       
   113         * @param aStream Reference to stream data is written to
       
   114         * @return -
       
   115         */
       
   116 		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   117 		
       
   118 		/**
       
   119         * Implements sort by entry type
       
   120         * @since Series ?XX ?SeriesXX_version
       
   121         * @param aLeft Reference to entry
       
   122         * @param aRight Reference to entry aLeft is compared to
       
   123         * @return Positive, if entry is greater than the specified entry. Negative, if this entry is less than the specified entry. Zero, if the content of both entries match
       
   124         */
       
   125 		static TInt SortByType( const CSyncMLHistoryEntry& aLeft, const CSyncMLHistoryEntry& aRight );
       
   126 		
       
   127 		/**
       
   128         * Implements sort by entry time
       
   129         * @since Series ?XX ?SeriesXX_version
       
   130         * @param aLeft Reference to entry
       
   131         * @param aRight Reference to entry aLeft is compared to
       
   132         * @return Positive, if entry's timestamp is greater than the specified entry's. Negative, if this entry's timestamp is less than the specified entry's. Zero, if the content of both entries' timestamps match
       
   133         */
       
   134         static TInt SortByTime( const CSyncMLHistoryEntry& aLeft, const CSyncMLHistoryEntry& aRight );
       
   135         
       
   136 	private:
       
   137 	    void UpdateTaskListL(const CSyncMLHistoryJob* aHistoryJob, RArray<TInt>& aTaskList);
       
   138 	    void InitializeTaskListL(RArray<TInt>& aTaskList);
       
   139 	    void RemoveHistoryJobL();
       
   140 	    void RemoveHistoryJob();
       
   141 	    TBool RemoveHistoryJobL(RArray<TInt>& aTaskList);
       
   142 	    TBool CanRemove(const CSyncMLHistoryJob* aHistoryJob, RArray<TInt>& aTaskList);
       
   143 	    void ResetCorruptedHistroy () ;
       
   144 	    
       
   145 #ifdef _DEBUG	    
       
   146 	    void LogHistoryJobL(const CSyncMLHistoryJob* aHistoryJob);
       
   147 	    void LogHistoryArrayL();
       
   148 	    void GetDateTimeTextL(TDes& aText, TTime aDateTime);
       
   149 	    void CheckHistoryJobCount();
       
   150 #endif	        
       
   151 	    
       
   152 	private:
       
   153 		
       
   154 		/**
       
   155         * C++ default constructor.
       
   156         */
       
   157 		CNSmlHistoryArray();	
       
   158 		
       
   159 		/**
       
   160         * By default Symbian 2nd phase constructor is private.
       
   161         */
       
   162 		void ConstructL();
       
   163 		
       
   164 		/**
       
   165         * Checks the count of job entries is within the limit
       
   166         * @since Series ?XX ?SeriesXX_version
       
   167         * @param -
       
   168         * @return -
       
   169         */
       
   170 		void DoJobLimitCheck();
       
   171 		
       
   172 		/**
       
   173         * Checks the count of push message entries is within the limit
       
   174         * @since Series ?XX ?SeriesXX_version
       
   175         * @param -
       
   176         * @return -
       
   177         */
       
   178 		void DoPushMsgLimitCheck();
       
   179 		
       
   180 	private:
       
   181 		RPointerArray<CSyncMLHistoryEntry> iHistory;
       
   182 		TBool iHistoryOwned;
       
   183 		CSyncMLHistoryEntry::TSortOrder iSortOrder;
       
   184 	};
       
   185 
       
   186 #endif