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