omads/omadsextensions/adapters/contacts/inc/NSmlContactsModsFetcher.h
changeset 0 dab8a81a92de
child 10 b922b9936679
equal deleted inserted replaced
-1:000000000000 0:dab8a81a92de
       
     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:  DS contacts datastore.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __NSMLCONTACTSMODSFETCHER_H__
       
    20 #define __NSMLCONTACTSMODSFETCHER_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <SmlDataProvider.h>
       
    24 #include <SmlDataFormat.h>
       
    25 #include <f32file.h>
       
    26 #include <cntdb.h>
       
    27 #include <cntitem.h>
       
    28 #include "nsmlchangefinder.h"
       
    29 
       
    30 #include <CVPbkContactManager.h>
       
    31 #include <MVPbkContactStore.h>
       
    32 #include <MVPbkContactViewObserver.h>
       
    33 #include <CVPbkSortOrder.h>
       
    34 #include <MVPbkContactViewBase.h>
       
    35 #include <MVPbkSingleContactOperationObserver.h>
       
    36 #include <MVPbkContactOperationBase.h>
       
    37 
       
    38 // CONSTANTS
       
    39 const TInt KNSmlSnapshotSize = 56;
       
    40 const TInt KNSmlSnapshotSmallSize = 8;
       
    41 _LIT( KNSmlContactSyncNoSync, "none" ); // Taken from phonebook
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 // ------------------------------------------------------------------------------------------------
       
    46 // CNSmlContactsModsFetcher
       
    47 //
       
    48 // @lib nsmlcontactsdataprovider.lib
       
    49 // ------------------------------------------------------------------------------------------------
       
    50 class CNSmlContactsModsFetcher : public CActive,
       
    51 								MVPbkContactViewObserver,
       
    52 								MVPbkSingleContactOperationObserver,
       
    53 								MVPbkContactOperationBase
       
    54 								
       
    55 	{
       
    56 	public:
       
    57 		/**
       
    58 		* C++ constructor.
       
    59 		* @param		aSnapshotRegistered	Is snapshot registered.
       
    60 		* @param		aCntDb				Pointer to opened database.
       
    61 		* @param		aKey				Key array.
       
    62 		* @param		aChangeFinder		Pointer to Changefinder.
       
    63 		*/
       
    64 		CNSmlContactsModsFetcher( TBool& aSnapshotRegistered,CVPbkContactManager& aContactManager,MVPbkContactStore& aStore,TKeyArrayFix& aKey, CNSmlChangeFinder& aChangeFinder );
       
    65 		/**
       
    66 		* Second phase constructor.
       
    67 		*/
       
    68 		void ConstructL();
       
    69 
       
    70 		/**
       
    71 		* Reads all modifications from clients contacts databse.
       
    72 		* @param		aStatus				On completion of the operation, contains the result code.
       
    73 		*/
       
    74 		void FetchModificationsL( TRequestStatus& aStatus );
       
    75 
       
    76 		/**
       
    77 		* ~CNSmlContactsModsFetcher() desctructor.
       
    78 		*/
       
    79 		virtual ~CNSmlContactsModsFetcher();
       
    80 		
       
    81 	private:
       
    82 	
       
    83 		/**
       
    84 		* From MVPbkContactViewObserver  
       
    85 		* Called when a view is ready for use. 
       
    86 		*/
       
    87 
       
    88 		void ContactViewReady(
       
    89 		            MVPbkContactViewBase& aView ) ;
       
    90 		/**
       
    91 		* From MVPbkContactViewObserver  
       
    92 		* Called when a view is unavailable for a while. 
       
    93 		*/            
       
    94 		void ContactViewUnavailable(
       
    95 		            MVPbkContactViewBase& aView ) ;
       
    96 		/**
       
    97 		* From MVPbkContactViewObserver  
       
    98 		* Called when a contact has been added to the view.
       
    99 		*/            
       
   100 		void ContactAddedToView(
       
   101 		            MVPbkContactViewBase& aView, 
       
   102 		            TInt aIndex, 
       
   103 		            const MVPbkContactLink& aContactLink );
       
   104 		/**
       
   105 		* From MVPbkContactViewObserver  
       
   106 		* Called when a contact has been removed from a view.
       
   107 		*/            
       
   108 		void ContactRemovedFromView(
       
   109 		            MVPbkContactViewBase& aView, 
       
   110 		            TInt aIndex, 
       
   111 		            const MVPbkContactLink& aContactLink ) ;
       
   112 		/**
       
   113 		* From MVPbkContactViewObserver  
       
   114 		* Called when an error occurs in the view.
       
   115 		*/            
       
   116 		void ContactViewError(
       
   117 		            MVPbkContactViewBase& aView, 
       
   118 		            TInt aError, 
       
   119 		            TBool aErrorNotified ) ;
       
   120 		            /**
       
   121 		* From MVPbkSingleContactOperationObserver  
       
   122 		* Called when the operation is completed.
       
   123 		*/
       
   124          void VPbkSingleContactOperationComplete(MVPbkContactOperationBase& aOperation,MVPbkStoreContact* aContact ); 
       
   125          
       
   126 		/**
       
   127 		* From MVPbkSingleContactOperationObserver  
       
   128 		*  Called if the operation fails.
       
   129 		*/
       
   130  		void VPbkSingleContactOperationFailed(
       
   131  					MVPbkContactOperationBase& aOperation, 
       
   132  					TInt aError );
       
   133 
       
   134 	private:
       
   135 		/**
       
   136 		* Fetches next chunk of data (client contacts data changes).
       
   137 		*/
       
   138 		void FetchNextContactL();
       
   139 
       
   140 		/**
       
   141 		* From CActive. Called when asynchronous operation completes.
       
   142 		*/
       
   143 		void RunL();
       
   144 		
       
   145 		/**
       
   146 		* From CActive. Called when RunL leaves.
       
   147 		*/    
       
   148 		TInt RunError( TInt aError );
       
   149 
       
   150 		/**
       
   151 		* From CActive. Cancels operation.
       
   152 		*/
       
   153 		void DoCancel();
       
   154 		
       
   155 		/**
       
   156 		* Checks if aItem is confidential or not.
       
   157 		* @param    aItem   Item that is checked.
       
   158 		* @return   TBool   ETrue if item is confidential.
       
   159 		*                   Otherwise EFalse is returned.
       
   160 		*/
       
   161         TBool IsConfidentialL( MVPbkStoreContact& aItem );
       
   162         /**
       
   163 		* Create a contact view of the store which is opened
       
   164 		*/
       
   165         void CreateViewL();
       
   166         /**
       
   167 		* Add the fetched contacts id and timestamp 
       
   168 		* to the snapshot.
       
   169 		* @param    aContact   Fetched contact to be 
       
   170 		*						added to snapshot
       
   171 		*/
       
   172         void UpdateSnapshotL( MVPbkStoreContact* aContact );
       
   173 		
       
   174 	private: // data
       
   175 		TRequestStatus* iCallerStatus;
       
   176 		TTime iFromTime;
       
   177 		
       
   178 		
       
   179 		CArrayFixSeg<TNSmlSnapshotItem>* iSnapshot;
       
   180 		
       
   181 		TBool& iSnapshotRegistered;
       
   182 
       
   183 
       
   184 		TKeyArrayFix& iKey;
       
   185 
       
   186 		CNSmlChangeFinder& iChangeFinder;
       
   187 		TInt iCurrentSnapshotCounter;
       
   188 
       
   189 		CVPbkContactManager& iContactManager;
       
   190         MVPbkContactStore& iStore;
       
   191         MVPbkContactViewBase* iContactViewBase;
       
   192         TInt iContactCount;
       
   193 
       
   194 	};
       
   195 
       
   196 #endif // __NSMLCONTACTSMODSFETCHER_H__
       
   197 
       
   198 // End of File