mtpfws/mtpfw/src/cmtpdeltadatamgr.cpp
changeset 0 d0791faffa3f
child 6 ef55b168cedb
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedPartner
       
    19 */
       
    20 
       
    21 
       
    22 #include "cmtpdeltadatamgr.h"
       
    23 //! Size of a PUID in bytes
       
    24 static const TInt KMTPPuidSize = 16;
       
    25 
       
    26 
       
    27 __FLOG_STMT(_LIT8(KComponent,"MTPDeltaDataMgr:");)
       
    28 
       
    29 _LIT(KMTPDeltaDataTable, "MTPDeltaDataTable");
       
    30 _LIT(KSQLPuidIndexName, "PuidIndex");
       
    31 _LIT(KSQLIdentifierIndexName, "IdentifierIndex");
       
    32 _LIT(KAnchorIdTable, "AnchorIdTable");
       
    33 _LIT (KDeleteDeltaTable, "DELETE FROM MTPDeltaDataTable");
       
    34 /**
       
    35 Standard c++ constructor
       
    36 */	
       
    37 CMtpDeltaDataMgr::CMtpDeltaDataMgr(RDbDatabase& aDatabase)
       
    38 	:iDatabase(aDatabase)
       
    39  	{
       
    40  	}
       
    41 
       
    42  
       
    43 /**
       
    44 Second-phase construction
       
    45 @leave One of the system wide error codes, if a processing failure occurs.
       
    46 */	
       
    47 void CMtpDeltaDataMgr::ConstructL()
       
    48 	{
       
    49 	__FLOG_OPEN(KMTPSubsystem, KComponent);
       
    50 	__FLOG(_L8("ConstructL - Entry"));
       
    51 	__FLOG(_L8("ConstructL - Exit"));
       
    52 	}
       
    53 
       
    54 
       
    55 /**
       
    56 Two-phase construction
       
    57 @param aDatabase	The reference to the database object
       
    58 @return	pointer to the created CMtpDeltaDataMgr instance
       
    59 */
       
    60 CMtpDeltaDataMgr* CMtpDeltaDataMgr::NewL(RDbDatabase& aDatabase)
       
    61 	{
       
    62 	CMtpDeltaDataMgr* self = new (ELeave) CMtpDeltaDataMgr(aDatabase);
       
    63 	CleanupStack::PushL(self);
       
    64 	self->ConstructL();
       
    65 	CleanupStack::Pop(self);
       
    66 	return self;
       
    67 	}
       
    68 
       
    69 
       
    70 /**
       
    71 Destructor
       
    72 */	
       
    73 CMtpDeltaDataMgr::~CMtpDeltaDataMgr()
       
    74 	{
       
    75 	iDeltaTableBatched.Close();
       
    76 	iAnchorTableBatched.Close();
       
    77 	iView.Close();
       
    78 	iSuidIdArray.Close();
       
    79 	__FLOG_CLOSE;
       
    80 	}
       
    81 /**
       
    82 Create the MTP Delta Data Table
       
    83 @leave One of the system wide error codes, if a processing failure occurs.
       
    84 */
       
    85 EXPORT_C void CMtpDeltaDataMgr::CreateDeltaDataTableL()
       
    86 	{
       
    87 	__FLOG(_L8("CreateDeltaDataTableL - Entry"));
       
    88 	
       
    89 	iDeltaTableBatched.Close();
       
    90 	if(!DBUtility::IsTableExistsL(iDatabase, KMTPDeltaDataTable))
       
    91 		{
       
    92 		_LIT(KSQLCreateMTPDeltaDataTableText,"CREATE TABLE MTPDeltaDataTable (SuidId BIGINT , OpCode TINYINT )");		
       
    93 		User::LeaveIfError(iDatabase.Execute(KSQLCreateMTPDeltaDataTableText));
       
    94 		
       
    95 		if(!DBUtility::IsIndexExistsL(iDatabase, KMTPDeltaDataTable, KSQLPuidIndexName))
       
    96 			{
       
    97 			_LIT(KSQLCreateReferenceIndexText,"CREATE UNIQUE INDEX PuidIndex on MTPDeltaDataTable (SuidId)");
       
    98 			User::LeaveIfError(iDatabase.Execute(KSQLCreateReferenceIndexText));
       
    99 			}
       
   100 		}
       
   101 	iDeltaTableBatched.Open(iDatabase, KMTPDeltaDataTable, RDbRowSet::EUpdatable);
       
   102 		
       
   103 	__FLOG(_L8("CreateDeltaDataTableL - Exit"));
       
   104 	}
       
   105 
       
   106 /**
       
   107 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.
       
   109 */
       
   110 EXPORT_C void CMtpDeltaDataMgr::CreateAnchorIdTableL()
       
   111 	{
       
   112 	__FLOG(_L8("CreateAnchorIdTableL - Entry"));
       
   113 	iAnchorTableBatched.Close();
       
   114 	if(!DBUtility::IsTableExistsL(iDatabase, KAnchorIdTable))
       
   115 		{
       
   116 		_LIT(KSQLCreateAnchorIdTableText,"CREATE TABLE AnchorIdTable (anchorid INTEGER, curindex INTEGER, identifier INTEGER)");
       
   117 		User::LeaveIfError(iDatabase.Execute(KSQLCreateAnchorIdTableText));
       
   118 			
       
   119 		if(!DBUtility::IsIndexExistsL(iDatabase, KAnchorIdTable, KSQLIdentifierIndexName))
       
   120 			{
       
   121 			_LIT(KSQLCreateRefIndexText,"CREATE UNIQUE INDEX IdentifierIndex on AnchorIdTable (identifier)");
       
   122 			User::LeaveIfError(iDatabase.Execute(KSQLCreateRefIndexText));
       
   123 			}
       
   124 		}
       
   125 	iAnchorTableBatched.Open(iDatabase, KAnchorIdTable, RDbRowSet::EUpdatable);
       
   126 		
       
   127 	__FLOG(_L8("CreateAnchorIdTableL - Exit"));
       
   128 	}
       
   129 
       
   130 /**
       
   131 Add a new anchor ID to the AnchorIdTable
       
   132 @param aAnchorId The anchor ID
       
   133 @param aIdentifier The identifier of the anchor
       
   134 @leave One of the system wide error codes, if a processing failure occurs.
       
   135 */	
       
   136 EXPORT_C void CMtpDeltaDataMgr::InsertAnchorIdL(TInt aAnchorId, TInt aIdentifier)
       
   137 	{
       
   138 	__FLOG(_L8("InsertAnchorIdL - Entry"));	
       
   139 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
       
   140 	if(!(iAnchorTableBatched.SeekL(aIdentifier)))
       
   141 		{
       
   142 		iAnchorTableBatched.InsertL();
       
   143 		iAnchorTableBatched.SetColL(1, aAnchorId);
       
   144 		iAnchorTableBatched.SetColL(2, 0);
       
   145 		iAnchorTableBatched.SetColL(3, aIdentifier);
       
   146 		iAnchorTableBatched.PutL();
       
   147 		}
       
   148 	__FLOG(_L8("InsertAnchorIdL - Exit"));
       
   149 	}
       
   150 
       
   151 /**
       
   152 Overwrite the anchor Id with new one
       
   153 @param aAnchorId The new anchor ID
       
   154 @param aIdentifier The identifier of the anchor
       
   155 @leave One of the system wide error codes, if a processing failure occurs.
       
   156 */	
       
   157 EXPORT_C void CMtpDeltaDataMgr::UpdateAnchorIdL(TInt aAnchorId, TInt aIdentifier)
       
   158 	{
       
   159 	__FLOG(_L8("UpdateAnchorIdL - Entry"));
       
   160 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
       
   161 	if(iAnchorTableBatched.SeekL(aIdentifier))
       
   162 		{
       
   163 		iAnchorTableBatched.UpdateL();
       
   164 		iAnchorTableBatched.SetColL(1, aAnchorId);
       
   165 		iAnchorTableBatched.PutL();
       
   166 		}
       
   167 	__FLOG(_L8("UpdateAnchorIdL - Exit"));
       
   168 	}
       
   169 
       
   170 /**
       
   171 Get the anchor ID with specified identifier
       
   172 @param aIdentifier The identifier of the anchor
       
   173 @leave One of the system wide error codes, if a processing failure occurs.
       
   174 */	
       
   175 EXPORT_C TInt CMtpDeltaDataMgr::GetAnchorIdL(TInt aIdentifier)
       
   176 	{
       
   177 	__FLOG(_L8("GetAnchorIdL - Entry"));
       
   178 	TInt anchorId = 0;
       
   179 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
       
   180 	if(iAnchorTableBatched.SeekL(aIdentifier))
       
   181 		{
       
   182 		iAnchorTableBatched.GetL();
       
   183 		anchorId = iAnchorTableBatched.ColInt32(1);
       
   184 		}
       
   185 	__FLOG(_L8("GetAnchorIdL - Exit"));
       
   186 	return anchorId;
       
   187 	}
       
   188 
       
   189 /**
       
   190 Overwrite the old index  with new one
       
   191 @leave One of the system wide error codes, if a processing failure occurs.
       
   192 */	
       
   193 EXPORT_C void CMtpDeltaDataMgr::UpdatePersistentIndexL(TInt aCurindex, TInt aIdentifier)
       
   194 	{	
       
   195 	__FLOG(_L8("UpdatePersistentIndexL - Entry"));
       
   196 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
       
   197 	if(iAnchorTableBatched.SeekL(aIdentifier))
       
   198 		{
       
   199 		iAnchorTableBatched.UpdateL();
       
   200 		iAnchorTableBatched.SetColL(2, aCurindex);
       
   201 		iAnchorTableBatched.PutL();
       
   202 		}
       
   203 	__FLOG(_L8("UpdatePersistentIndexL - Exit"));
       
   204 	}
       
   205 	
       
   206 /**
       
   207 returns the stored index 
       
   208 @leave One of the system wide error codes, if a processing failure occurs.
       
   209 */
       
   210 EXPORT_C TInt CMtpDeltaDataMgr::GetPersistentIndexL(TInt aIdentifier)
       
   211 	{
       
   212 	__FLOG(_L8("GetPersistentIndexL - Entry"));
       
   213 
       
   214 	TInt currIndex = 0;
       
   215 	iAnchorTableBatched.SetIndex(KSQLIdentifierIndexName);
       
   216 	if(iAnchorTableBatched.SeekL(aIdentifier))
       
   217 		{
       
   218 		iAnchorTableBatched.GetL();
       
   219 		currIndex = iAnchorTableBatched.ColInt32(2);
       
   220 		}
       
   221 	__FLOG(_L8("GetPersistentIndexL - Exit"));		
       
   222 	return currIndex;
       
   223 	}
       
   224 
       
   225 /**
       
   226 Add the Opcode and SuidId to the MTPDeltaDataTable
       
   227 @param aSuidId The suid identifier of the object to be added
       
   228 @param aOpCode operation code 
       
   229 @leave  One of the system wide error codes, if a processing failure occurs.
       
   230 */
       
   231 void CMtpDeltaDataMgr::UpdateDeltaDataTableL(TInt64 aSuidId, TOpCode aOpCode)
       
   232 	{
       
   233 	__FLOG(_L8("UpdateDeltaDataTableL - Entry"));
       
   234 	if(!DBUtility::IsTableExistsL(iDatabase, KMTPDeltaDataTable))
       
   235 		return;
       
   236 		
       
   237 	iDeltaTableBatched.SetIndex(KSQLPuidIndexName);
       
   238 	if(iDeltaTableBatched.SeekL(aSuidId))
       
   239 		{
       
   240 		iDeltaTableBatched.UpdateL();
       
   241 		iDeltaTableBatched.SetColL(2, aOpCode);
       
   242 		}
       
   243 	else
       
   244 		{
       
   245 		iDeltaTableBatched.InsertL();
       
   246 		iDeltaTableBatched.SetColL(1, aSuidId);
       
   247 		iDeltaTableBatched.SetColL(2, aOpCode);
       
   248 		}
       
   249 	iDeltaTableBatched.PutL();
       
   250 	__FLOG(_L8("UpdateDeltaDataTableL - Exit"));
       
   251 	}
       
   252 
       
   253 /**
       
   254 @param total number of items to be  filled into aModifiedPuidIdArray and aDeletedPuidArray
       
   255 @param the start position 
       
   256 @param reference to modifed and deleted mtp arrays 
       
   257 @return Number of remaining items to be retrieved from table
       
   258 @leave One of the system wide error codes, if a processing failure occurs.
       
   259 */
       
   260 EXPORT_C TInt CMtpDeltaDataMgr::GetChangedPuidsL(TInt aMaxArraySize, TInt& aPosition, CMTPTypeArray& aModifiedPuidIdArray, CMTPTypeArray& aDeletedPuidArray)
       
   261 	{
       
   262 	__FLOG(_L8("GetChangedPuidsL - Entry"));
       
   263 	
       
   264 	if(!iNeedToSendMore)
       
   265 		{
       
   266 		_LIT(KSQLGetAll, "SELECT * FROM MTPDeltaDataTable");
       
   267 		
       
   268 		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(KSQLGetAll)));
       
   269 		User::LeaveIfError(iView.EvaluateAll());
       
   270 		iNeedToSendMore = ETrue;
       
   271 		iView.FirstL();
       
   272 		iTotalRows = iView.CountL();
       
   273 
       
   274 		if(aPosition !=0 && aPosition < iTotalRows)
       
   275 			{
       
   276 			for(TInt i=0; i<aPosition; i++)
       
   277 				{
       
   278 				iView.NextL();
       
   279 				}
       
   280 			}
       
   281 		}
       
   282 		
       
   283 	if(iTotalRows == 0 || aPosition >= iTotalRows)
       
   284 		{
       
   285 		iNeedToSendMore = EFalse;
       
   286 		iView.Close();
       
   287 		return 0;
       
   288 		}
       
   289 	
       
   290 	TInt64 suidId = 0;
       
   291 	TInt64 puidlow = 1;
       
   292 	TBuf8<KMTPPuidSize> puidBuffer;
       
   293 	
       
   294 	for(TInt count=0;count <aMaxArraySize;count++)
       
   295 		{
       
   296 		iView.GetL();
       
   297 		//Get the data from the current row
       
   298 		suidId = iView.ColInt64(1);
       
   299 		TInt8 opCode = iView.ColInt8(2);	
       
   300 		puidBuffer.Copy(TPtrC8((const TUint8*)&suidId, sizeof(TInt64)));
       
   301 		puidBuffer.Append(TPtrC8((const TUint8*)&puidlow, sizeof(TInt64)));
       
   302 		TMTPTypeUint128 puid(puidBuffer);
       
   303 
       
   304 		if(opCode  == EDeleted)
       
   305 			{
       
   306 			aDeletedPuidArray.AppendL(puid);
       
   307 			}
       
   308 		else
       
   309 			{
       
   310 			aModifiedPuidIdArray.AppendL(puid);
       
   311 			}
       
   312 		aPosition++;
       
   313 
       
   314 		if(aPosition == iTotalRows)
       
   315 			{
       
   316 			iNeedToSendMore = EFalse;
       
   317 			iView.Close();
       
   318 			break;	
       
   319 			}
       
   320 		else
       
   321 			{
       
   322 			//Move to the next row
       
   323 			iView.NextL();
       
   324 			}
       
   325 		}
       
   326 	
       
   327 	__FLOG(_L8("GetChangedPuidsL - Exit"));
       
   328 	return	(iTotalRows - aPosition);
       
   329 	}
       
   330 
       
   331 /**
       
   332 @param total number of items to be  filled into aAddedPuidIdArray
       
   333 @param reference to added mtp arrays 
       
   334 @return Number of remaining items to be retrieved from table
       
   335 @leave One of the system wide error codes, if a processing failure occurs.
       
   336 */
       
   337 EXPORT_C TInt CMtpDeltaDataMgr::GetAddedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aAddedPuidIdArray)
       
   338 	{
       
   339 	__FLOG(_L8("GetAddedPuidsL - Entry"));
       
   340 	
       
   341 	if(!iNeedToSendMore)
       
   342 		{
       
   343 		TInt opcode = EAdded;
       
   344 		_LIT(KSQLSelectAdded, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
       
   345 		iSqlStatement.Format(KSQLSelectAdded, opcode);
       
   346 		
       
   347 		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
       
   348 		User::LeaveIfError(iView.EvaluateAll());
       
   349 		iNeedToSendMore = ETrue;
       
   350 		iView.FirstL();
       
   351 		iTotalRows = iView.CountL();
       
   352 
       
   353 		if(aPosition !=0 && aPosition < iTotalRows)
       
   354 			{
       
   355 			for(TInt i=0; i<aPosition; i++)
       
   356 				{
       
   357 				iView.NextL();
       
   358 				}
       
   359 			}
       
   360 		}
       
   361 		
       
   362 	if(iTotalRows == 0 || aPosition >= iTotalRows)
       
   363 		{
       
   364 		iNeedToSendMore = EFalse;
       
   365 		iView.Close();
       
   366 		return 0;
       
   367 		}
       
   368 	
       
   369 	TInt64 suidId = 0;
       
   370 	TInt64 puidlow = 1;
       
   371 	TBuf8<KMTPPuidSize> puidBuffer;
       
   372 	
       
   373 	for(TInt count=0;count <aMaxArraySize;count++)
       
   374 		{
       
   375 
       
   376 		iView.GetL();
       
   377 		//Get the data from the current row
       
   378 		suidId = iView.ColInt64(1);
       
   379 		puidBuffer.Copy(TPtrC8((const TUint8*)&suidId, sizeof(TInt64)));
       
   380 		puidBuffer.Append(TPtrC8((const TUint8*)&puidlow, sizeof(TInt64)));
       
   381 		TMTPTypeUint128 puid(puidBuffer);
       
   382 
       
   383 		aAddedPuidIdArray.AppendL(puid);
       
   384 		aPosition++;
       
   385 
       
   386 		if(aPosition == iTotalRows)
       
   387 			{
       
   388 			iNeedToSendMore = EFalse;
       
   389 			iView.Close();
       
   390 			break;	
       
   391 			}
       
   392 		else
       
   393 			{
       
   394 			//Move to the next row
       
   395 			iView.NextL();		
       
   396 			}
       
   397 		}
       
   398 	
       
   399 	__FLOG(_L8("GetAddedPuidsL - Exit"));
       
   400 	return 	(iTotalRows - aPosition);
       
   401 	}
       
   402 
       
   403 /**
       
   404 @param total number of items to be  filled into aAddedPuidIdArray
       
   405 @param reference to deleted mtp arrays 
       
   406 @return Number of remaining items to be retrieved from table
       
   407 @leave One of the system wide error codes, if a processing failure occurs.
       
   408 */
       
   409 EXPORT_C TInt CMtpDeltaDataMgr::GetDeletedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aDeletedPuidIdArray)
       
   410 	{
       
   411 	__FLOG(_L8("GetDeletedPuidsL - Entry"));
       
   412 
       
   413 	if(!iNeedToSendMore)
       
   414 		{
       
   415 		TInt opcode = EDeleted;
       
   416 		_LIT(KSQLSelectDeleted, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
       
   417 		iSqlStatement.Format(KSQLSelectDeleted, opcode);
       
   418 		
       
   419 		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
       
   420 		User::LeaveIfError(iView.EvaluateAll());
       
   421 		iNeedToSendMore = ETrue;
       
   422 		iView.FirstL();
       
   423 		iTotalRows = iView.CountL();
       
   424 
       
   425 		if(aPosition !=0 && aPosition < iTotalRows)
       
   426 			{
       
   427 			for(TInt i=0; i<aPosition; i++)
       
   428 				{
       
   429 				iView.NextL();
       
   430 				}
       
   431 			}
       
   432 		}
       
   433 		
       
   434 	if(iTotalRows == 0 || aPosition >= iTotalRows)
       
   435 		{
       
   436 		iNeedToSendMore = EFalse;
       
   437 		iView.Close();
       
   438 		return 0;
       
   439 		}
       
   440 	
       
   441 	TInt64 suidId = 0;
       
   442 	TInt64 puidlow = 1;
       
   443 	TBuf8<KMTPPuidSize> puidBuffer;
       
   444 	
       
   445 	for(TInt count=0;count <aMaxArraySize;count++)
       
   446 		{
       
   447 
       
   448 		iView.GetL();
       
   449 		//Get the data from the current row
       
   450 		suidId = iView.ColInt64(1);
       
   451 		puidBuffer.Copy(TPtrC8((const TUint8*)&suidId, sizeof(TInt64)));
       
   452 		puidBuffer.Append(TPtrC8((const TUint8*)&puidlow, sizeof(TInt64)));
       
   453 		TMTPTypeUint128 puid(puidBuffer);
       
   454 
       
   455 		aDeletedPuidIdArray.AppendL(puid);
       
   456 		aPosition++;
       
   457 
       
   458 		if(aPosition == iTotalRows)
       
   459 			{
       
   460 			iNeedToSendMore = EFalse;
       
   461 			iView.Close();
       
   462 			break;	
       
   463 			}
       
   464 		else
       
   465 			{
       
   466 			//Move to the next row
       
   467 			iView.NextL();		
       
   468 			}
       
   469 		}
       
   470 		
       
   471 	__FLOG(_L8("GetDeletedPuidsL - Exit"));
       
   472 	return 	(iTotalRows - aPosition);
       
   473 	}
       
   474 
       
   475 /**
       
   476 @param total number of items to be  filled into aAddedPuidIdArray
       
   477 @param reference to Modified mtp arrays 
       
   478 @return Number of remaining items to be retrieved from table
       
   479 @leave One of the system wide error codes, if a processing failure occurs.
       
   480 */
       
   481 EXPORT_C TInt CMtpDeltaDataMgr::GetModifiedPuidsL(TInt aMaxArraySize, TInt &aPosition, CMTPTypeArray& aModifiedPuidIdArray)
       
   482 	{
       
   483 	__FLOG(_L8("GetDeletedPuidsL - Entry"));
       
   484 
       
   485 	if(!iNeedToSendMore)
       
   486 		{
       
   487 		TInt opcode = EModified;
       
   488 		_LIT(KSQLSelectModified, "SELECT * FROM MTPDeltaDataTable WHERE OpCode = %d");
       
   489 		iSqlStatement.Format(KSQLSelectModified, opcode);
       
   490 		
       
   491 		User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(iSqlStatement)));
       
   492 		User::LeaveIfError(iView.EvaluateAll());
       
   493 		iNeedToSendMore = ETrue;
       
   494 		iView.FirstL();
       
   495 		iTotalRows = iView.CountL();
       
   496 
       
   497 		if(aPosition !=0 && aPosition < iTotalRows)
       
   498 			{
       
   499 			for(TInt i=0; i<aPosition; i++)
       
   500 				{
       
   501 				iView.NextL();
       
   502 				}
       
   503 			}
       
   504 		}
       
   505 		
       
   506 	if(iTotalRows == 0 || aPosition >= iTotalRows)
       
   507 		{
       
   508 		iNeedToSendMore = EFalse;
       
   509 		iView.Close();
       
   510 		return 0;
       
   511 		}
       
   512 	
       
   513 	TInt64 suidId = 0;
       
   514 	TInt64 puidlow = 1;
       
   515 	TBuf8<KMTPPuidSize> puidBuffer;
       
   516 	
       
   517 	for(TInt count=0;count <aMaxArraySize;count++)
       
   518 		{
       
   519 		iView.GetL();
       
   520 		//Get the data from the current row
       
   521 		suidId = iView.ColInt64(1);		
       
   522 		
       
   523 		puidBuffer.Copy(TPtrC8((const TUint8*)&suidId, sizeof(TInt64)));
       
   524 		puidBuffer.Append(TPtrC8((const TUint8*)&puidlow, sizeof(TInt64)));
       
   525 		TMTPTypeUint128 puid(puidBuffer);
       
   526 
       
   527 		aModifiedPuidIdArray.AppendL(puid);
       
   528 		aPosition++;
       
   529 
       
   530 		if(aPosition == iTotalRows)
       
   531 			{
       
   532 			iNeedToSendMore = EFalse;
       
   533 			iView.Close();
       
   534 			break;	
       
   535 			}
       
   536 		else
       
   537 			{
       
   538 			//Move to the next row
       
   539 			iView.NextL();		
       
   540 			}
       
   541 		}
       
   542 		
       
   543 	__FLOG(_L8("GetDeletedPuidsL - Exit"));
       
   544 	return 	(iTotalRows - aPosition);
       
   545 	}
       
   546 
       
   547 /**
       
   548 @leave One of the system wide error codes, if a processing failure occurs.
       
   549 */
       
   550 EXPORT_C void CMtpDeltaDataMgr::ResetMTPDeltaDataTableL()
       
   551 	{
       
   552 	__FLOG(_L8("ResetMTPDeltaDataTableL - Entry"));
       
   553 
       
   554 	iView.Close();
       
   555 	iNeedToSendMore = EFalse;
       
   556 	User::LeaveIfError(iDatabase.Execute(KDeleteDeltaTable));
       
   557 	
       
   558 	__FLOG(_L8("ResetMTPDeltaDataTableL - Exit"));
       
   559 	}