コード例 #1
0
HBufC* CAgentAddressbook::ReadFieldAsTextL(const CContactItemField& itemField)
	{
	if (itemField.Storage() == NULL || !itemField.Storage()->IsFull())
		return HBufC::NewL(0);

	switch (itemField.StorageType())
		{
		case KStorageTypeText:
			{
			CContactTextField* txtField = itemField.TextStorage();
			if (txtField == NULL)
				return HBufC::NewL(0);
			return txtField->Text().AllocL();
			}
		case KStorageTypeDateTime:
			{
			CContactDateField* dateField = itemField.DateTimeStorage();
			if (dateField == NULL)
				return HBufC::NewL(0);
			TTime time = dateField->Time();
			_LIT(KFORMAT_DATE, "%D%M%Y%/0%1%/1%2%/2%3%/3");
			TBuf<30> strTime;
			time.FormatL(strTime, KFORMAT_DATE);
			return strTime.AllocL();
			}
		default:
			return HBufC::NewL(0);
		}
	}
コード例 #2
0
QContactDetail *CntTransformBirthday::transformItemField(const CContactItemField& field, const QContact &contact)
{
	Q_UNUSED(contact);

	QContactBirthday *birthday = new QContactBirthday();

	CContactDateField* storage = field.DateTimeStorage();
	TTime time(storage->Time());
	QDate qDate(time.DateTime().Year(), time.DateTime().Month() + 1, time.DateTime().Day() + 1);
	birthday->setDate(qDate);

	return birthday;
}
コード例 #3
0
QContactDetail *CntTransformAnniversarySimple::transformItemField(const CContactItemField& field, const QContact &contact)
{
    Q_UNUSED(contact);

    QContactAnniversary *anniversary = new QContactAnniversary();

    CContactDateField* storage = field.DateTimeStorage();
    TTime time(storage->Time());
    QDate qDate(time.DateTime().Year(), time.DateTime().Month() + 1, time.DateTime().Day() + 1);
    anniversary->setOriginalDate(qDate);

    return anniversary;
}
コード例 #4
0
void CTestImpExvCardSuiteStepBase::ImportBDAYCardL(RReadStream& aReadStream)
	{
	INFO_PRINTF1(_L("Importing vCard....."));
	

	CVCardToContactsAppConverter* converter=new(ELeave)	CVCardToContactsAppConverter;
	CleanupStack::PushL(converter); // converter

	CParserVCard* vCard= CParserVCard::NewL();
	CleanupStack::PushL(vCard);
	TInt err = KErrNone;
	TRAP(err, vCard->InternalizeL(aReadStream));
	User::LeaveIfError(err);
	
	CContactItem* contactItem = NULL;
	
	// set to local time
	contactItem = converter->GetVCardAsContactItemLC(*vCard, CVCardToContactsAppConverter::EPreserveAllProperties, CContactVCardConverter::ELocalTime);
	
	CContactItemFieldSet& cardFields = contactItem->CardFields();
	
	INFO_PRINTF1(_L("Looking for Birthday field in Contact entry....."));
	TInt pos = cardFields.Find(KUidContactFieldBirthday);
	
	if (pos==KErrNotFound)
		{
		INFO_PRINTF1(_L("Birthday field not found in Contact entry"));
		iBDayFromImport = NULL;
		}
	else
		{
		INFO_PRINTF1(_L("Birthday field found in Contact entry"));
		CContactItemField& itemField = cardFields[pos];
	
		CContactDateField* dateTimeField = itemField.DateTimeStorage();
		CleanupStack::PushL(dateTimeField);
	
		iBDayFromImport = dateTimeField->Time();
		
		CleanupStack::Pop();
		}
	
	INFO_PRINTF1(_L("Imported to Contact Entry"));
		
	CleanupStack::PopAndDestroy(3); 
	}