コード例 #1
0
//********************************************************************************************
void CVersitCardTest::CreateVCardTestL()
//
//
//
    {
	CVersitParser* parser = CParserVCard::NewL();
	CleanupStack::PushL(parser);

    // Add Name
    {
    CDesCArrayFlat* nameArray = new(ELeave) CDesCArrayFlat(2);
    CleanupStack::PushL(nameArray);
    nameArray->AppendL(_L("Wibble"));
    nameArray->AppendL(_L("Wobble"));
    //
    CParserPropertyValue* propNameValue = new(ELeave) CParserPropertyValueCDesCArray(nameArray);
    CleanupStack::Pop(nameArray);
    CleanupStack::PushL(propNameValue);
    CParserProperty* propName = CParserProperty::NewL(*propNameValue, KVersitTokenN, NULL);
    CleanupStack::Pop(propNameValue);
    parser->AddPropertyL(propName);
    }

    // Add Sound
    {
    CDesCArrayFlat* soundArray = new(ELeave) CDesCArrayFlat(2);
    CleanupStack::PushL(soundArray);
    soundArray->AppendL(_L("Sound1"));
    soundArray->AppendL(_L("Sound2"));
    //
    CParserPropertyValue* propSoundValue = new(ELeave) CParserPropertyValueCDesCArray(soundArray);
    CleanupStack::Pop(soundArray);
    CleanupStack::PushL(propSoundValue);
    CParserProperty* propSound = CParserProperty::NewL(*propSoundValue, KVersitTokenSOUND, NULL);
    CleanupStack::Pop(propSoundValue);
    //
	CParserParam* param = CParserParam::NewL(KSoundExtensionPropertyParameterName, KNullDesC8);
	CleanupStack::PushL(param);
    propSound->AddParamL(param);
	CleanupStack::Pop(param);
    //
    parser->AddPropertyL(propSound);
    }

    // Export vCard
    _LIT(KFileName, "C:\\JapaneseSound.vcf");
	RFile file;
	User::LeaveIfError(file.Replace(TheFsSession, KFileName, EFileWrite));
	CleanupClosePushL(file);
    parser->ExternalizeL(file);
	CleanupStack::PopAndDestroy(&file);
    
    // Test
    CParserVCard* importedCard = CVersitCardTest::InternalizeCardLC(KFileName);
    CheckNumberOfSoundPropertiesL(KFileName, *importedCard, 2);
    CleanupStack::PopAndDestroy(importedCard);

    // Tidy up
    CleanupStack::PopAndDestroy(parser);    
    }
コード例 #2
0
/** Appends the property to the array in AddIntraContactPropertiesL
@param	aPropertyName The property name to append
@param	aPropertyValue Value of the property
@param  aPropertyList The property list array in AddIntraContactPropertiesL to append
*/
void CContactsPBAPExportUtilityClass::AddPropertyL(const TDesC& aPropertyName, CParserPropertyValue* aPropertyValue, CParserParam* aPropParameter, CArrayPtr<CParserProperty>* aPropertyList)
{
    TBuf8<KMaxLengthField> propertyName;
    propertyName.Copy(aPropertyName);
    CParserProperty* property = CParserProperty::NewL(*aPropertyValue,propertyName,NULL);
    CleanupStack::PushL(property);
    if(aPropParameter)
    {
        property->AddParamL(aPropParameter);
    }
    aPropertyList->AppendL(property);
    CleanupStack::Pop();
}