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