VError DB4DJournalParser::SetEndOfJournal( uLONG8 inOperation )
{
	VError error = VE_OK;
	if ( fFileStream )
	{
		CDB4DJournalData *journalData = NULL;
		error = SetCurrentOperation( inOperation, &journalData );
		if ( journalData )
			journalData->Release();
		if ( error == VE_OK )
		{
			sLONG8 filePos = fFileStream->GetPos();
			error = DeInit();
			if ( error == VE_OK )
			{
				VFileDesc *fileDesc = NULL;
				error = fLogFile->Open( FA_READ_WRITE, &fileDesc );
				if ( error == VE_OK )
				{
					error = fileDesc->SetSize( filePos );
					delete fileDesc;
				}
				if ( error == VE_OK )
					fTotalOperationCount = fCurrentOperation;
			}
		}
	}
	else
	{
		error = VE_UNIMPLEMENTED; // not initialized
	}
	return error;
}
/**
* Adds contact cards and groups in the database
*/
void CTestContactViewCRUDOperationsStep::CreateContactItemsL()
	{
	_LIT(KAddContacts, "add");
	TBool addContacts = EFalse;
	GetBoolFromConfig(ConfigSection(), KAddContacts, addContacts);

	if(!addContacts)
		{
		return;
		}

	// Add contacts and groups in the main thread and validate the view count and view notifications
	// in the contact views thread
	TPtrC currentOperation(KAddContactOperations);
	SetCurrentOperation(currentOperation);
	AddContactEntriesL();
	CloseDatabaseL();
	OpenDataBaseL();
	ResumeContactViewsThreadL();
	}
/**
* Deletes contact items in the database
*/
void CTestContactViewCRUDOperationsStep::RemoveContactItemsL()
	{
	_LIT(KDeleteContacts, "delete");
	TBool deleteContacts = EFalse;
	GetBoolFromConfig(ConfigSection(), KDeleteContacts, deleteContacts);

	if(!deleteContacts)
		{
		return;
		}

	// Delete Contacts in the main thread and validate the view count and view notifications
	// in the contact views thread
	TPtrC currentOperation(KRemoveContactsOperations);
	SetCurrentOperation(currentOperation);
	DeleteContactCardsL();
	CloseDatabaseL();
	OpenDataBaseL();
	ResumeContactViewsThreadL();
	}
/**
 * Loop Function which validates the contact views after each CRUD operation is performed in the main thread
 */
void CContactViews::RunTestL()
	{
	// Suspend the current thread, will be resumed at a later stage by the main thread at the
	// end of each CRUD Operation
	iSemaphore.Signal();
	RThread().Suspend();
	

	while (!ExecutionCompleted())
		{
		TContactViewValidationData actualValidationData;
		SetCurrentOperation(actualValidationData);
		CContactViewEventQueue& desiredViewObserver = ViewCollectionReference().RetrieveDesiredViewObserverL(TestStepReference());
		ListenForContactViewEvents(desiredViewObserver, actualValidationData);
		TInt viewCount = iContactView->CountL();
		actualValidationData.SetViewCount(viewCount);		
		iActualData.AppendL(actualValidationData);
		iSemaphore.Signal();
		RThread().Suspend();
		}

	for(TInt i = 0; i < iExpectedData.Count(); ++i)
		{
		TContactViewValidationData::TContactViewCurrentOperation currentOperation = iExpectedData[i].CurrentOperation();
		TContactViewValidationData actualResult = RetrieveValidationData(currentOperation);
		TBool result = Compare(iExpectedData[i], actualResult);
		if(!result)
			{ 
			PrintDetailsL(iExpectedData[i], actualResult);									
			const TInt KNullCount = 0;
			if(actualResult.ViewCount() == KNullCount)
				{
				return;
				}
			_LIT(KValidationFailed, "The actual data doesnt match with the expected data");
			TestStepReference().ERR_PRINTF1(KValidationFailed);
			TestStepReference().SetTestStepResult(EFail);
			} 
		}
	}