mtpfws/mtpfw/src/cmtpdeltadatamgr.cpp
changeset 47 63cf70d3ecd8
parent 22 a5c0bb5018eb
child 52 866b4af7ffbe
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    18  @publishedPartner
    18  @publishedPartner
    19 */
    19 */
    20 
    20 
    21 
    21 
    22 #include "cmtpdeltadatamgr.h"
    22 #include "cmtpdeltadatamgr.h"
       
    23 #include "mtpdebug.h"
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "cmtpdeltadatamgrTraces.h"
       
    27 #endif
       
    28 
    23 //! Size of a PUID in bytes
    29 //! Size of a PUID in bytes
    24 static const TInt KMTPPuidSize = 16;
    30 static const TInt KMTPPuidSize = 16;
    25 
    31 
    26 
    32 
    27 __FLOG_STMT(_LIT8(KComponent,"MTPDeltaDataMgr:");)
       
    28 
    33 
    29 _LIT(KMTPDeltaDataTable, "MTPDeltaDataTable");
    34 _LIT(KMTPDeltaDataTable, "MTPDeltaDataTable");
    30 _LIT(KSQLPuidIndexName, "PuidIndex");
    35 _LIT(KSQLPuidIndexName, "PuidIndex");
    31 _LIT(KSQLIdentifierIndexName, "IdentifierIndex");
    36 _LIT(KSQLIdentifierIndexName, "IdentifierIndex");
    32 _LIT(KAnchorIdTable, "AnchorIdTable");
    37 _LIT(KAnchorIdTable, "AnchorIdTable");
    44 Second-phase construction
    49 Second-phase construction
    45 @leave One of the system wide error codes, if a processing failure occurs.
    50 @leave One of the system wide error codes, if a processing failure occurs.
    46 */	
    51 */	
    47 void CMtpDeltaDataMgr::ConstructL()
    52 void CMtpDeltaDataMgr::ConstructL()
    48 	{
    53 	{
    49 	__FLOG_OPEN(KMTPSubsystem, KComponent);
    54     OstTraceFunctionEntry0( CMTPDELTADATAMGR_CONSTRUCTL_ENTRY );
    50 	__FLOG(_L8("ConstructL - Entry"));
    55 	OstTraceFunctionExit0( CMTPDELTADATAMGR_CONSTRUCTL_EXIT );
    51 	__FLOG(_L8("ConstructL - Exit"));
       
    52 	}
    56 	}
    53 
    57 
    54 
    58 
    55 /**
    59 /**
    56 Two-phase construction
    60 Two-phase construction
    74 	{
    78 	{
    75 	iDeltaTableBatched.Close();
    79 	iDeltaTableBatched.Close();
    76 	iAnchorTableBatched.Close();
    80 	iAnchorTableBatched.Close();
    77 	iView.Close();
    81 	iView.Close();
    78 	iSuidIdArray.Close();
    82 	iSuidIdArray.Close();
    79 	__FLOG_CLOSE;
       
    80 	}
    83 	}
    81 /**
    84 /**
    82 Create the MTP Delta Data Table
    85 Create the MTP Delta Data Table
    83 @leave One of the system wide error codes, if a processing failure occurs.
    86 @leave One of the system wide error codes, if a processing failure occurs.
    84 */
    87 */
    85 EXPORT_C void CMtpDeltaDataMgr::CreateDeltaDataTableL()
    88 EXPORT_C void CMtpDeltaDataMgr::CreateDeltaDataTableL()
    86 	{
    89 	{
    87 	__FLOG(_L8("CreateDeltaDataTableL - Entry"));
    90 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_CREATEDELTADATATABLEL_ENTRY );
       
    91 	
    88 	
    92 	
    89 	iDeltaTableBatched.Close();
    93 	iDeltaTableBatched.Close();
    90 	if(!DBUtility::IsTableExistsL(iDatabase, KMTPDeltaDataTable))
    94 	if(!DBUtility::IsTableExistsL(iDatabase, KMTPDeltaDataTable))
    91 		{
    95 		{
    92 		_LIT(KSQLCreateMTPDeltaDataTableText,"CREATE TABLE MTPDeltaDataTable (SuidId BIGINT , OpCode TINYINT )");		
    96 		_LIT(KSQLCreateMTPDeltaDataTableText,"CREATE TABLE MTPDeltaDataTable (SuidId BIGINT , OpCode TINYINT )");		
    93 		User::LeaveIfError(iDatabase.Execute(KSQLCreateMTPDeltaDataTableText));
    97 		LEAVEIFERROR(iDatabase.Execute(KSQLCreateMTPDeltaDataTableText),
    94 		
    98 		        OstTrace0( TRACE_ERROR, CMTPDELTADATAMGR_CREATEDELTADATATABLEL, "MTPDeltaDataTable create error!" ));
       
    99 
    95 		if(!DBUtility::IsIndexExistsL(iDatabase, KMTPDeltaDataTable, KSQLPuidIndexName))
   100 		if(!DBUtility::IsIndexExistsL(iDatabase, KMTPDeltaDataTable, KSQLPuidIndexName))
    96 			{
   101 			{
    97 			_LIT(KSQLCreateReferenceIndexText,"CREATE UNIQUE INDEX PuidIndex on MTPDeltaDataTable (SuidId)");
   102 			_LIT(KSQLCreateReferenceIndexText,"CREATE UNIQUE INDEX PuidIndex on MTPDeltaDataTable (SuidId)");
    98 			User::LeaveIfError(iDatabase.Execute(KSQLCreateReferenceIndexText));
   103 			LEAVEIFERROR(iDatabase.Execute(KSQLCreateReferenceIndexText),
       
   104 			        OstTrace0( TRACE_ERROR, DUP1_CMTPDELTADATAMGR_CREATEDELTADATATABLEL, "PuidIndex on MTPDeltaDataTable create error!" ));       
    99 			}
   105 			}
   100 		}
   106 		}
   101 	iDeltaTableBatched.Open(iDatabase, KMTPDeltaDataTable, RDbRowSet::EUpdatable);
   107 	iDeltaTableBatched.Open(iDatabase, KMTPDeltaDataTable, RDbRowSet::EUpdatable);
   102 		
   108 		
   103 	__FLOG(_L8("CreateDeltaDataTableL - Exit"));
   109 	OstTraceFunctionExit0( CMTPDELTADATAMGR_CREATEDELTADATATABLEL_EXIT );
   104 	}
   110 	}
   105 
   111 
   106 /**
   112 /**
   107 Create the Anchor Id Table anchor Id will be stored here
   113 Create the Anchor Id Table anchor Id will be stored here
   108 @leave One of the system wide error codes, if a processing failure occurs.
   114 @leave One of the system wide error codes, if a processing failure occurs.
   109 */
   115 */
   110 EXPORT_C void CMtpDeltaDataMgr::CreateAnchorIdTableL()
   116 EXPORT_C void CMtpDeltaDataMgr::CreateAnchorIdTableL()
   111 	{
   117 	{
   112 	__FLOG(_L8("CreateAnchorIdTableL - Entry"));
   118 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_CREATEANCHORIDTABLEL_ENTRY );
       
   119 	
   113 	iAnchorTableBatched.Close();
   120 	iAnchorTableBatched.Close();
   114 	if(!DBUtility::IsTableExistsL(iDatabase, KAnchorIdTable))
   121 	if(!DBUtility::IsTableExistsL(iDatabase, KAnchorIdTable))
   115 		{
   122 		{
   116 		_LIT(KSQLCreateAnchorIdTableText,"CREATE TABLE AnchorIdTable (anchorid INTEGER, curindex INTEGER, identifier INTEGER)");
   123 		_LIT(KSQLCreateAnchorIdTableText,"CREATE TABLE AnchorIdTable (anchorid INTEGER, curindex INTEGER, identifier INTEGER)");
   117 		User::LeaveIfError(iDatabase.Execute(KSQLCreateAnchorIdTableText));
   124 		LEAVEIFERROR(iDatabase.Execute(KSQLCreateAnchorIdTableText),
       
   125 		        OstTrace0( TRACE_ERROR, CMTPDELTADATAMGR_CREATEANCHORIDTABLEL, "TABLE AnchorIdTable create error!" ));
       
   126 		        
   118 			
   127 			
   119 		if(!DBUtility::IsIndexExistsL(iDatabase, KAnchorIdTable, KSQLIdentifierIndexName))
   128 		if(!DBUtility::IsIndexExistsL(iDatabase, KAnchorIdTable, KSQLIdentifierIndexName))
   120 			{
   129 			{
   121 			_LIT(KSQLCreateRefIndexText,"CREATE UNIQUE INDEX IdentifierIndex on AnchorIdTable (identifier)");
   130 			_LIT(KSQLCreateRefIndexText,"CREATE UNIQUE INDEX IdentifierIndex on AnchorIdTable (identifier)");
   122 			User::LeaveIfError(iDatabase.Execute(KSQLCreateRefIndexText));
   131 			LEAVEIFERROR(iDatabase.Execute(KSQLCreateRefIndexText),
       
   132 			        OstTrace0( TRACE_ERROR, DUP1_CMTPDELTADATAMGR_CREATEANCHORIDTABLEL, "INDEX IdentifierIndex on AnchorIdTable create error!" ));
   123 			}
   133 			}
   124 		}
   134 		}
   125 	iAnchorTableBatched.Open(iDatabase, KAnchorIdTable, RDbRowSet::EUpdatable);
   135 	iAnchorTableBatched.Open(iDatabase, KAnchorIdTable, RDbRowSet::EUpdatable);
   126 		
   136 		
   127 	__FLOG(_L8("CreateAnchorIdTableL - Exit"));
   137 	OstTraceFunctionExit0( CMTPDELTADATAMGR_CREATEANCHORIDTABLEL_EXIT );
   128 	}
   138 	}
   129 
   139 
   130 /**
   140 /**
   131 Add a new anchor ID to the AnchorIdTable
   141 Add a new anchor ID to the AnchorIdTable
   132 @param aAnchorId The anchor ID
   142 @param aAnchorId The anchor ID
   133 @param aIdentifier The identifier of the anchor
   143 @param aIdentifier The identifier of the anchor
   134 @leave One of the system wide error codes, if a processing failure occurs.
   144 @leave One of the system wide error codes, if a processing failure occurs.
   135 */	
   145 */	
   136 EXPORT_C void CMtpDeltaDataMgr::InsertAnchorIdL(TInt aAnchorId, TInt aIdentifier)
   146 EXPORT_C void CMtpDeltaDataMgr::InsertAnchorIdL(TInt aAnchorId, TInt aIdentifier)
   137 	{
   147 	{
   138 	__FLOG(_L8("InsertAnchorIdL - Entry"));	
   148 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_INSERTANCHORIDL_ENTRY );
       
   149 	
   139 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   150 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   140 	if(!(iAnchorTableBatched.SeekL(aIdentifier)))
   151 	if(!(iAnchorTableBatched.SeekL(aIdentifier)))
   141 		{
   152 		{
   142 		iAnchorTableBatched.InsertL();
   153 		iAnchorTableBatched.InsertL();
   143 		iAnchorTableBatched.SetColL(1, aAnchorId);
   154 		iAnchorTableBatched.SetColL(1, aAnchorId);
   144 		iAnchorTableBatched.SetColL(2, 0);
   155 		iAnchorTableBatched.SetColL(2, 0);
   145 		iAnchorTableBatched.SetColL(3, aIdentifier);
   156 		iAnchorTableBatched.SetColL(3, aIdentifier);
   146 		iAnchorTableBatched.PutL();
   157 		iAnchorTableBatched.PutL();
   147 		}
   158 		}
   148 	__FLOG(_L8("InsertAnchorIdL - Exit"));
   159 	OstTraceFunctionExit0( CMTPDELTADATAMGR_INSERTANCHORIDL_EXIT );
   149 	}
   160 	}
   150 
   161 
   151 /**
   162 /**
   152 Overwrite the anchor Id with new one
   163 Overwrite the anchor Id with new one
   153 @param aAnchorId The new anchor ID
   164 @param aAnchorId The new anchor ID
   154 @param aIdentifier The identifier of the anchor
   165 @param aIdentifier The identifier of the anchor
   155 @leave One of the system wide error codes, if a processing failure occurs.
   166 @leave One of the system wide error codes, if a processing failure occurs.
   156 */	
   167 */	
   157 EXPORT_C void CMtpDeltaDataMgr::UpdateAnchorIdL(TInt aAnchorId, TInt aIdentifier)
   168 EXPORT_C void CMtpDeltaDataMgr::UpdateAnchorIdL(TInt aAnchorId, TInt aIdentifier)
   158 	{
   169 	{
   159 	__FLOG(_L8("UpdateAnchorIdL - Entry"));
   170 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_UPDATEANCHORIDL_ENTRY );
       
   171 	
   160 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   172 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   161 	if(iAnchorTableBatched.SeekL(aIdentifier))
   173 	if(iAnchorTableBatched.SeekL(aIdentifier))
   162 		{
   174 		{
   163 		iAnchorTableBatched.UpdateL();
   175 		iAnchorTableBatched.UpdateL();
   164 		iAnchorTableBatched.SetColL(1, aAnchorId);
   176 		iAnchorTableBatched.SetColL(1, aAnchorId);
   165 		iAnchorTableBatched.PutL();
   177 		iAnchorTableBatched.PutL();
   166 		}
   178 		}
   167 	__FLOG(_L8("UpdateAnchorIdL - Exit"));
   179 	OstTraceFunctionExit0( CMTPDELTADATAMGR_UPDATEANCHORIDL_EXIT );
   168 	}
   180 	}
   169 
   181 
   170 /**
   182 /**
   171 Get the anchor ID with specified identifier
   183 Get the anchor ID with specified identifier
   172 @param aIdentifier The identifier of the anchor
   184 @param aIdentifier The identifier of the anchor
   173 @leave One of the system wide error codes, if a processing failure occurs.
   185 @leave One of the system wide error codes, if a processing failure occurs.
   174 */	
   186 */	
   175 EXPORT_C TInt CMtpDeltaDataMgr::GetAnchorIdL(TInt aIdentifier)
   187 EXPORT_C TInt CMtpDeltaDataMgr::GetAnchorIdL(TInt aIdentifier)
   176 	{
   188 	{
   177 	__FLOG(_L8("GetAnchorIdL - Entry"));
   189 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_GETANCHORIDL_ENTRY );
       
   190 	
   178 	TInt anchorId = 0;
   191 	TInt anchorId = 0;
   179 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   192 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   180 	if(iAnchorTableBatched.SeekL(aIdentifier))
   193 	if(iAnchorTableBatched.SeekL(aIdentifier))
   181 		{
   194 		{
   182 		iAnchorTableBatched.GetL();
   195 		iAnchorTableBatched.GetL();
   183 		anchorId = iAnchorTableBatched.ColInt32(1);
   196 		anchorId = iAnchorTableBatched.ColInt32(1);
   184 		}
   197 		}
   185 	__FLOG(_L8("GetAnchorIdL - Exit"));
   198 	OstTraceFunctionExit0( CMTPDELTADATAMGR_GETANCHORIDL_EXIT );
   186 	return anchorId;
   199 	return anchorId;
   187 	}
   200 	}
   188 
   201 
   189 /**
   202 /**
   190 Overwrite the old index  with new one
   203 Overwrite the old index  with new one
   191 @leave One of the system wide error codes, if a processing failure occurs.
   204 @leave One of the system wide error codes, if a processing failure occurs.
   192 */	
   205 */	
   193 EXPORT_C void CMtpDeltaDataMgr::UpdatePersistentIndexL(TInt aCurindex, TInt aIdentifier)
   206 EXPORT_C void CMtpDeltaDataMgr::UpdatePersistentIndexL(TInt aCurindex, TInt aIdentifier)
   194 	{	
   207 	{	
   195 	__FLOG(_L8("UpdatePersistentIndexL - Entry"));
   208 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_UPDATEPERSISTENTINDEXL_ENTRY );
       
   209 	
   196 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   210 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   197 	if(iAnchorTableBatched.SeekL(aIdentifier))
   211 	if(iAnchorTableBatched.SeekL(aIdentifier))
   198 		{
   212 		{
   199 		iAnchorTableBatched.UpdateL();
   213 		iAnchorTableBatched.UpdateL();
   200 		iAnchorTableBatched.SetColL(2, aCurindex);
   214 		iAnchorTableBatched.SetColL(2, aCurindex);
   201 		iAnchorTableBatched.PutL();
   215 		iAnchorTableBatched.PutL();
   202 		}
   216 		}
   203 	__FLOG(_L8("UpdatePersistentIndexL - Exit"));
   217 	OstTraceFunctionExit0( CMTPDELTADATAMGR_UPDATEPERSISTENTINDEXL_EXIT );
   204 	}
   218 	}
   205 	
   219 	
   206 /**
   220 /**
   207 returns the stored index 
   221 returns the stored index 
   208 @leave One of the system wide error codes, if a processing failure occurs.
   222 @leave One of the system wide error codes, if a processing failure occurs.
   209 */
   223 */
   210 EXPORT_C TInt CMtpDeltaDataMgr::GetPersistentIndexL(TInt aIdentifier)
   224 EXPORT_C TInt CMtpDeltaDataMgr::GetPersistentIndexL(TInt aIdentifier)
   211 	{
   225 	{
   212 	__FLOG(_L8("GetPersistentIndexL - Entry"));
   226 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_GETPERSISTENTINDEXL_ENTRY );
       
   227 	
   213 
   228 
   214 	TInt currIndex = 0;
   229 	TInt currIndex = 0;
   215 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   230 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
   216 	if(iAnchorTableBatched.SeekL(aIdentifier))
   231 	if(iAnchorTableBatched.SeekL(aIdentifier))
   217 		{
   232 		{
   218 		iAnchorTableBatched.GetL();
   233 		iAnchorTableBatched.GetL();
   219 		currIndex = iAnchorTableBatched.ColInt32(2);
   234 		currIndex = iAnchorTableBatched.ColInt32(2);
   220 		}
   235 		}	
   221 	__FLOG(_L8("GetPersistentIndexL - Exit"));		
   236 	OstTraceFunctionExit0( CMTPDELTADATAMGR_GETPERSISTENTINDEXL_EXIT );
   222 	return currIndex;
   237 	return currIndex;
   223 	}
   238 	}
   224 
   239 
   225 /**
   240 /**
   226 Add the Opcode and SuidId to the MTPDeltaDataTable
   241 Add the Opcode and SuidId to the MTPDeltaDataTable
   228 @param aOpCode operation code 
   243 @param aOpCode operation code 
   229 @leave  One of the system wide error codes, if a processing failure occurs.
   244 @leave  One of the system wide error codes, if a processing failure occurs.
   230 */
   245 */
   231 void CMtpDeltaDataMgr::UpdateDeltaDataTableL(TInt64 aSuidId, TOpCode aOpCode)
   246 void CMtpDeltaDataMgr::UpdateDeltaDataTableL(TInt64 aSuidId, TOpCode aOpCode)
   232 	{
   247 	{
   233 	__FLOG(_L8("UpdateDeltaDataTableL - Entry"));
   248 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_UPDATEDELTADATATABLEL_ENTRY );
       
   249 	
   234 	if(!DBUtility::IsTableExistsL(iDatabase, KMTPDeltaDataTable))
   250 	if(!DBUtility::IsTableExistsL(iDatabase, KMTPDeltaDataTable))
   235 		return;
   251 		return;
   236 		
   252 		
   237 	iDeltaTableBatched.SetIndex(KSQLPuidIndexName);
   253 	iDeltaTableBatched.SetIndex(KSQLPuidIndexName);
   238 	if(iDeltaTableBatched.SeekL(aSuidId))
   254 	if(iDeltaTableBatched.SeekL(aSuidId))
   245 		iDeltaTableBatched.InsertL();
   261 		iDeltaTableBatched.InsertL();
   246 		iDeltaTableBatched.SetColL(1, aSuidId);
   262 		iDeltaTableBatched.SetColL(1, aSuidId);
   247 		iDeltaTableBatched.SetColL(2, aOpCode);
   263 		iDeltaTableBatched.SetColL(2, aOpCode);
   248 		}
   264 		}
   249 	iDeltaTableBatched.PutL();
   265 	iDeltaTableBatched.PutL();
   250 	__FLOG(_L8("UpdateDeltaDataTableL - Exit"));
   266 	OstTraceFunctionExit0( CMTPDELTADATAMGR_UPDATEDELTADATATABLEL_EXIT );
   251 	}
   267 	}
   252 
   268 
   253 /**
   269 /**
   254 @param total number of items to be  filled into aModifiedPuidIdArray and aDeletedPuidArray
   270 @param total number of items to be  filled into aModifiedPuidIdArray and aDeletedPuidArray
   255 @param the start position 
   271 @param the start position 
   257 @return Number of remaining items to be retrieved from table
   273 @return Number of remaining items to be retrieved from table
   258 @leave One of the system wide error codes, if a processing failure occurs.
   274 @leave One of the system wide error codes, if a processing failure occurs.
   259 */
   275 */
   260 EXPORT_C TInt CMtpDeltaDataMgr::GetChangedPuidsL(TInt aMaxArraySize, TInt& aPosition, CMTPTypeArray& aModifiedPuidIdArray, CMTPTypeArray& aDeletedPuidArray)
   276 EXPORT_C TInt CMtpDeltaDataMgr::GetChangedPuidsL(TInt aMaxArraySize, TInt& aPosition, CMTPTypeArray& aModifiedPuidIdArray, CMTPTypeArray& aDeletedPuidArray)
   261 	{
   277 	{
   262 	__FLOG(_L8("GetChangedPuidsL - Entry"));
   278 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_GETCHANGEDPUIDSL_ENTRY );
       
   279 	
   263 	
   280 	
   264 	if(!iNeedToSendMore)
   281 	if(!iNeedToSendMore)
   265 		{
   282 		{
   266 		_LIT(KSQLGetAll, "SELECT * FROM MTPDeltaDataTable");
   283 		_LIT(KSQLGetAll, "SELECT * FROM MTPDeltaDataTable");
   267 		
   284 		
   268 		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(KSQLGetAll)));
   285 		LEAVEIFERROR(iView.Prepare(iDatabase, TDbQuery(KSQLGetAll)),
   269 		User::LeaveIfError(iView.EvaluateAll());
   286 		        OstTrace0( TRACE_ERROR, CMTPDELTADATAMGR_GETCHANGEDPUIDSL, "view for MTPDeltaDataTable prepare failure!" ));
       
   287 		LEAVEIFERROR(iView.EvaluateAll(),
       
   288 		        OstTrace0( TRACE_ERROR, DUP1_CMTPDELTADATAMGR_GETCHANGEDPUIDSL, "view evaluate failed!" ));    
   270 		iNeedToSendMore = ETrue;
   289 		iNeedToSendMore = ETrue;
   271 		iView.FirstL();
   290 		iView.FirstL();
   272 		iTotalRows = iView.CountL();
   291 		iTotalRows = iView.CountL();
   273 
   292 
   274 		if(aPosition !=0 && aPosition < iTotalRows)
   293 		if(aPosition !=0 && aPosition < iTotalRows)
   282 		
   301 		
   283 	if(iTotalRows == 0 || aPosition >= iTotalRows)
   302 	if(iTotalRows == 0 || aPosition >= iTotalRows)
   284 		{
   303 		{
   285 		iNeedToSendMore = EFalse;
   304 		iNeedToSendMore = EFalse;
   286 		iView.Close();
   305 		iView.Close();
       
   306 		OstTraceFunctionExit0( CMTPDELTADATAMGR_GETCHANGEDPUIDSL_EXIT );
   287 		return 0;
   307 		return 0;
   288 		}
   308 		}
   289 	
   309 	
   290 	TInt64 suidId = 0;
   310 	TInt64 suidId = 0;
   291 	TInt64 puidlow = 1;
   311 	TInt64 puidlow = 1;
   322 			//Move to the next row
   342 			//Move to the next row
   323 			iView.NextL();
   343 			iView.NextL();
   324 			}
   344 			}
   325 		}
   345 		}
   326 	
   346 	
   327 	__FLOG(_L8("GetChangedPuidsL - Exit"));
   347 	OstTraceFunctionExit0( DUP1_CMTPDELTADATAMGR_GETCHANGEDPUIDSL_EXIT );
   328 	return	(iTotalRows - aPosition);
   348 	return	(iTotalRows - aPosition);
   329 	}
   349 	}
   330 
   350 
   331 /**
   351 /**
   332 @param total number of items to be  filled into aAddedPuidIdArray
   352 @param total number of items to be  filled into aAddedPuidIdArray
   334 @return Number of remaining items to be retrieved from table
   354 @return Number of remaining items to be retrieved from table
   335 @leave One of the system wide error codes, if a processing failure occurs.
   355 @leave One of the system wide error codes, if a processing failure occurs.
   336 */
   356 */
   337 EXPORT_C TInt CMtpDeltaDataMgr::GetAddedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aAddedPuidIdArray)
   357 EXPORT_C TInt CMtpDeltaDataMgr::GetAddedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aAddedPuidIdArray)
   338 	{
   358 	{
   339 	__FLOG(_L8("GetAddedPuidsL - Entry"));
   359 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_GETADDEDPUIDSL_ENTRY );
   340 	
   360 	
   341 	if(!iNeedToSendMore)
   361 	if(!iNeedToSendMore)
   342 		{
   362 		{
   343 		TInt opcode = EAdded;
   363 		TInt opcode = EAdded;
   344 		_LIT(KSQLSelectAdded, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
   364 		_LIT(KSQLSelectAdded, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
   345 		iSqlStatement.Format(KSQLSelectAdded, opcode);
   365 		iSqlStatement.Format(KSQLSelectAdded, opcode);
   346 		
   366 		
   347 		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
   367 		LEAVEIFERROR(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)),
   348 		User::LeaveIfError(iView.EvaluateAll());
   368 		        OstTrace0( TRACE_ERROR, CMTPDELTADATAMGR_GETADDEDPUIDSL, "view for MTPDeltaDataTable prepare failed!" ));	        
       
   369 		LEAVEIFERROR(iView.EvaluateAll(),
       
   370 		        OstTrace0( TRACE_ERROR, DUP1_CMTPDELTADATAMGR_GETADDEDPUIDSL, "view evaluate failed!" ));
   349 		iNeedToSendMore = ETrue;
   371 		iNeedToSendMore = ETrue;
   350 		iView.FirstL();
   372 		iView.FirstL();
   351 		iTotalRows = iView.CountL();
   373 		iTotalRows = iView.CountL();
   352 
   374 
   353 		if(aPosition !=0 && aPosition < iTotalRows)
   375 		if(aPosition !=0 && aPosition < iTotalRows)
   361 		
   383 		
   362 	if(iTotalRows == 0 || aPosition >= iTotalRows)
   384 	if(iTotalRows == 0 || aPosition >= iTotalRows)
   363 		{
   385 		{
   364 		iNeedToSendMore = EFalse;
   386 		iNeedToSendMore = EFalse;
   365 		iView.Close();
   387 		iView.Close();
       
   388 		OstTraceFunctionExit0( CMTPDELTADATAMGR_GETADDEDPUIDSL_EXIT );
   366 		return 0;
   389 		return 0;
   367 		}
   390 		}
   368 	
   391 	
   369 	TInt64 suidId = 0;
   392 	TInt64 suidId = 0;
   370 	TInt64 puidlow = 1;
   393 	TInt64 puidlow = 1;
   394 			//Move to the next row
   417 			//Move to the next row
   395 			iView.NextL();		
   418 			iView.NextL();		
   396 			}
   419 			}
   397 		}
   420 		}
   398 	
   421 	
   399 	__FLOG(_L8("GetAddedPuidsL - Exit"));
   422 	OstTraceFunctionExit0( DUP1_CMTPDELTADATAMGR_GETADDEDPUIDSL_EXIT );
   400 	return 	(iTotalRows - aPosition);
   423 	return 	(iTotalRows - aPosition);
   401 	}
   424 	}
   402 
   425 
   403 /**
   426 /**
   404 @param total number of items to be  filled into aAddedPuidIdArray
   427 @param total number of items to be  filled into aAddedPuidIdArray
   406 @return Number of remaining items to be retrieved from table
   429 @return Number of remaining items to be retrieved from table
   407 @leave One of the system wide error codes, if a processing failure occurs.
   430 @leave One of the system wide error codes, if a processing failure occurs.
   408 */
   431 */
   409 EXPORT_C TInt CMtpDeltaDataMgr::GetDeletedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aDeletedPuidIdArray)
   432 EXPORT_C TInt CMtpDeltaDataMgr::GetDeletedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aDeletedPuidIdArray)
   410 	{
   433 	{
   411 	__FLOG(_L8("GetDeletedPuidsL - Entry"));
   434 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_GETDELETEDPUIDSL_ENTRY );
   412 
   435 
   413 	if(!iNeedToSendMore)
   436 	if(!iNeedToSendMore)
   414 		{
   437 		{
   415 		TInt opcode = EDeleted;
   438 		TInt opcode = EDeleted;
   416 		_LIT(KSQLSelectDeleted, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
   439 		_LIT(KSQLSelectDeleted, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
   417 		iSqlStatement.Format(KSQLSelectDeleted, opcode);
   440 		iSqlStatement.Format(KSQLSelectDeleted, opcode);
   418 		
   441 		
   419 		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
   442 		LEAVEIFERROR(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)),
   420 		User::LeaveIfError(iView.EvaluateAll());
   443 		        OstTrace0( TRACE_ERROR, CMTPDELTADATAMGR_GETDELETEDPUIDSL, "view for MTPDeltaDataTable prepare failed!" ));
       
   444 		LEAVEIFERROR(iView.EvaluateAll(),
       
   445 		        OstTrace0( TRACE_ERROR, DUP1_CMTPDELTADATAMGR_GETDELETEDPUIDSL, "view evaluated failed!" ));
       
   446 		        
   421 		iNeedToSendMore = ETrue;
   447 		iNeedToSendMore = ETrue;
   422 		iView.FirstL();
   448 		iView.FirstL();
   423 		iTotalRows = iView.CountL();
   449 		iTotalRows = iView.CountL();
   424 
   450 
   425 		if(aPosition !=0 && aPosition < iTotalRows)
   451 		if(aPosition !=0 && aPosition < iTotalRows)
   433 		
   459 		
   434 	if(iTotalRows == 0 || aPosition >= iTotalRows)
   460 	if(iTotalRows == 0 || aPosition >= iTotalRows)
   435 		{
   461 		{
   436 		iNeedToSendMore = EFalse;
   462 		iNeedToSendMore = EFalse;
   437 		iView.Close();
   463 		iView.Close();
       
   464 		OstTraceFunctionExit0( CMTPDELTADATAMGR_GETDELETEDPUIDSL_EXIT );
   438 		return 0;
   465 		return 0;
   439 		}
   466 		}
   440 	
   467 	
   441 	TInt64 suidId = 0;
   468 	TInt64 suidId = 0;
   442 	TInt64 puidlow = 1;
   469 	TInt64 puidlow = 1;
   466 			//Move to the next row
   493 			//Move to the next row
   467 			iView.NextL();		
   494 			iView.NextL();		
   468 			}
   495 			}
   469 		}
   496 		}
   470 		
   497 		
   471 	__FLOG(_L8("GetDeletedPuidsL - Exit"));
   498 	OstTraceFunctionExit0( DUP1_CMTPDELTADATAMGR_GETDELETEDPUIDSL_EXIT );
   472 	return 	(iTotalRows - aPosition);
   499 	return 	(iTotalRows - aPosition);
   473 	}
   500 	}
   474 
   501 
   475 /**
   502 /**
   476 @param total number of items to be  filled into aAddedPuidIdArray
   503 @param total number of items to be  filled into aAddedPuidIdArray
   478 @return Number of remaining items to be retrieved from table
   505 @return Number of remaining items to be retrieved from table
   479 @leave One of the system wide error codes, if a processing failure occurs.
   506 @leave One of the system wide error codes, if a processing failure occurs.
   480 */
   507 */
   481 EXPORT_C TInt CMtpDeltaDataMgr::GetModifiedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aModifiedPuidIdArray)
   508 EXPORT_C TInt CMtpDeltaDataMgr::GetModifiedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aModifiedPuidIdArray)
   482 	{
   509 	{
   483 	__FLOG(_L8("GetDeletedPuidsL - Entry"));
   510 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_GETMODIFIEDPUIDSL_ENTRY );
   484 
   511 
   485 	if(!iNeedToSendMore)
   512 	if(!iNeedToSendMore)
   486 		{
   513 		{
   487 		TInt opcode = EModified;
   514 		TInt opcode = EModified;
   488 		_LIT(KSQLSelectModified, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
   515 		_LIT(KSQLSelectModified, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
   489 		iSqlStatement.Format(KSQLSelectModified, opcode);
   516 		iSqlStatement.Format(KSQLSelectModified, opcode);
   490 		
   517 		
   491 		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
   518 		LEAVEIFERROR(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)),
   492 		User::LeaveIfError(iView.EvaluateAll());
   519 		        OstTrace0( TRACE_ERROR, CMTPDELTADATAMGR_GETMODIFIEDPUIDSL, "view for MTPDeltaDataTable prepare failed!" ));
       
   520 		LEAVEIFERROR(iView.EvaluateAll(),
       
   521 		        OstTrace0( TRACE_ERROR, DUP1_CMTPDELTADATAMGR_GETMODIFIEDPUIDSL, "view evaluate failed!" ));
   493 		iNeedToSendMore = ETrue;
   522 		iNeedToSendMore = ETrue;
   494 		iView.FirstL();
   523 		iView.FirstL();
   495 		iTotalRows = iView.CountL();
   524 		iTotalRows = iView.CountL();
   496 
   525 
   497 		if(aPosition !=0 && aPosition < iTotalRows)
   526 		if(aPosition !=0 && aPosition < iTotalRows)
   505 		
   534 		
   506 	if(iTotalRows == 0 || aPosition >= iTotalRows)
   535 	if(iTotalRows == 0 || aPosition >= iTotalRows)
   507 		{
   536 		{
   508 		iNeedToSendMore = EFalse;
   537 		iNeedToSendMore = EFalse;
   509 		iView.Close();
   538 		iView.Close();
       
   539 		OstTraceFunctionExit0( CMTPDELTADATAMGR_GETMODIFIEDPUIDSL_EXIT );
   510 		return 0;
   540 		return 0;
   511 		}
   541 		}
   512 	
   542 	
   513 	TInt64 suidId = 0;
   543 	TInt64 suidId = 0;
   514 	TInt64 puidlow = 1;
   544 	TInt64 puidlow = 1;
   538 			//Move to the next row
   568 			//Move to the next row
   539 			iView.NextL();		
   569 			iView.NextL();		
   540 			}
   570 			}
   541 		}
   571 		}
   542 		
   572 		
   543 	__FLOG(_L8("GetDeletedPuidsL - Exit"));
   573 	OstTraceFunctionExit0( DUP1_CMTPDELTADATAMGR_GETMODIFIEDPUIDSL_EXIT );
   544 	return 	(iTotalRows - aPosition);
   574 	return 	(iTotalRows - aPosition);
   545 	}
   575 	}
   546 
   576 
   547 /**
   577 /**
   548 @leave One of the system wide error codes, if a processing failure occurs.
   578 @leave One of the system wide error codes, if a processing failure occurs.
   549 */
   579 */
   550 EXPORT_C void CMtpDeltaDataMgr::ResetMTPDeltaDataTableL()
   580 EXPORT_C void CMtpDeltaDataMgr::ResetMTPDeltaDataTableL()
   551 	{
   581 	{
   552 	__FLOG(_L8("ResetMTPDeltaDataTableL - Entry"));
   582 	OstTraceFunctionEntry0( CMTPDELTADATAMGR_RESETMTPDELTADATATABLEL_ENTRY );
   553 
   583 
   554 	iView.Close();
   584 	iView.Close();
   555 	iNeedToSendMore = EFalse;
   585 	iNeedToSendMore = EFalse;
   556 	User::LeaveIfError(iDatabase.Execute(KDeleteDeltaTable));
   586 	LEAVEIFERROR(iDatabase.Execute(KDeleteDeltaTable),
   557 	
   587 	        OstTrace0( TRACE_ERROR, CMTPDELTADATAMGR_RESETMTPDELTADATATABLEL, "DELETE FROM MTPDeltaDataTable failed!" ));
   558 	__FLOG(_L8("ResetMTPDeltaDataTableL - Exit"));
   588 	
   559 	}
   589 	OstTraceFunctionExit0( CMTPDELTADATAMGR_RESETMTPDELTADATATABLEL_EXIT );
       
   590 	}