omads/omadsextensions/adapters/contactsgroup/inc/changefinder.h
changeset 40 b63e67867dcd
equal deleted inserted replaced
39:9905f7d46607 40:b63e67867dcd
       
     1 /*
       
     2 * Copyright (c) 2008-2010 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:  Part of ContactGroup DS adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CHANGEFINDER_H__
       
    20 #define __CHANGEFINDER_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <nsmlchangefinder.h>
       
    24 #include "snapshotitem.h"
       
    25 
       
    26 // DATATYPES
       
    27 typedef CArrayFixSeg<TSnapshotItem> CSnapshotArray;
       
    28 
       
    29 // Granularity used with dynamic array
       
    30 const TInt KSnapshotGranularity = 32;
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34 * @brief CChangeFinder Class
       
    35 * This is a ChangeFinder class, which can be used to track down changes in the contacts group store.
       
    36 * It's functionality is equal to CSmlChangeFinder. Because neither of these classes contained virtual
       
    37 * functionality, the functionality of this class couldn't be inherited from the CSmlChangeFinder
       
    38 */
       
    39 class CChangeFinder : public CBase
       
    40 	{ 
       
    41 public:
       
    42 	
       
    43 	/**
       
    44     * Class constructor, Creates a new class instance.
       
    45     *
       
    46     * @param aSyncRelationship  IN: Reference to MSmlSyncRelationship interface.
       
    47     * @param aKey               IN: Key that is used in sorting snapshot.
       
    48     * @param aStreamUid         IN: Snapshot stream UID.
       
    49     * @return CChangeFinder*, New ChangeFinder instance.
       
    50     */
       
    51     static CChangeFinder* NewL( MSmlSyncRelationship& aSyncRelationship, 
       
    52                                TKeyArrayFix aKey,
       
    53                                TBool& aHasHistory, 
       
    54                                TInt aStreamUid = KNSmlDefaultSnapshotStreamUID );
       
    55 
       
    56     /**
       
    57     * Class destructor.
       
    58     */
       
    59 	~CChangeFinder();
       
    60 	
       
    61     /**
       
    62     * Close ChangeFinder object, stores snapshot.
       
    63     */
       
    64 	void CloseL();
       
    65 
       
    66     /**
       
    67     * Reset change information, makes all content new from ChangeFinder point of view.
       
    68     */
       
    69 	void ResetL();
       
    70 
       
    71     /**
       
    72     * Find changed items by comparing snapshots.
       
    73     * 
       
    74     * @param aChangedUids   IN: Array for results.
       
    75     */
       
    76 	void FindChangedItemsL( CNSmlDataItemUidSet& aChangedUids );
       
    77 
       
    78     /**
       
    79     * Find deleteed items by comparing snapshots.
       
    80     * 
       
    81     * @param aDeletedUids   IN: Array for results.
       
    82     */
       
    83 	void FindDeletedItemsL( CNSmlDataItemUidSet& aDeletedUids );
       
    84 	
       
    85     /**
       
    86     * Find new items by comparing snapshots.
       
    87     * 
       
    88     * @param aNewUids   IN: Array for results.
       
    89     */	
       
    90 	void FindNewItemsL(CNSmlDataItemUidSet& aNewUids);
       
    91 	
       
    92     /**
       
    93     * Add item to snapshot, it is no loger reported.
       
    94     * 
       
    95     * @param aItem   IN: item to add.
       
    96     */
       
    97 	void ItemAddedL( const TSnapshotItem& aItem );
       
    98 
       
    99     /**
       
   100     * Delete item from snapshot, it is no loger reported.
       
   101     * 
       
   102     * @param aItem   IN: item to delete.
       
   103     */
       
   104 	void ItemDeleted( const TSnapshotItem& aItem );
       
   105 	
       
   106     /**
       
   107     * Update item to snapshot, it is no loger reported.
       
   108     * 
       
   109     * @param aItem   IN: item to update.
       
   110     */
       
   111 	void ItemUpdatedL( const TSnapshotItem& aItem );
       
   112 	
       
   113     /**
       
   114     * Commit all changes to snapshot, there's nothing to report anymore.
       
   115     */
       
   116 	void CommitChangesL();
       
   117 
       
   118     /**
       
   119     * Commit a set of items to snapshot, these items won't be reported anymore.
       
   120     * 
       
   121     * @param aUids   IN: a set of items to commit.
       
   122     */
       
   123 	void CommitChangesL( const MSmlDataItemUidSet& aUids );
       
   124 	
       
   125 	/**
       
   126     * Sets new snapshot to compare against.
       
   127     * 
       
   128     * @param aNewSnapshot   IN: a new snapshot.
       
   129     */
       
   130 	void SetNewSnapshot( CSnapshotArray* aNewSnapshot );
       
   131 	
       
   132 protected:
       
   133 	
       
   134     /**
       
   135     * C++ Constructor
       
   136     *
       
   137     * @param aSyncRelationship  IN: Reference to MSmlSyncRelationship interface.
       
   138     * @param aKey               IN: Key that is used in sorting snapshot.
       
   139     * @param aStreamUid         IN: Snapshot stream UID.
       
   140     */    
       
   141 	CChangeFinder( MSmlSyncRelationship& aSyncRelationship, 
       
   142 	              TKeyArrayFix aKey, 
       
   143 	              TInt aStreamUid );
       
   144     
       
   145     /**
       
   146     * 2nd-phase Constructor
       
   147     *
       
   148     * @param aHasHistory   IN: ETrue, if there was synchronization history.
       
   149     */    
       
   150     void ConstructL( TBool& aHasHistory );
       
   151 
       
   152 private:
       
   153 
       
   154     /**
       
   155     * Allows access to streams.
       
   156     */
       
   157 	MSmlSyncRelationship& iSyncRelationship;
       
   158 	
       
   159     /**
       
   160     * New snapshot to compare against.
       
   161     */	
       
   162 	CSnapshotArray* iCurrentSnapshot;
       
   163 
       
   164     /**
       
   165     * Current snapshot.
       
   166     */
       
   167 	CSnapshotArray* iOldSnapshot;
       
   168 	
       
   169     /**
       
   170     * Key that is used in sorting snapshot.
       
   171     */
       
   172 	TKeyArrayFix iKey;
       
   173 	
       
   174     /**
       
   175     * Stream id number to access sync relationship.
       
   176     */	
       
   177 	TInt iStreamUid;
       
   178 	
       
   179     };
       
   180 
       
   181 #endif // __CHANGEFINDER_H__