//******************************************************************************************** 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); }
void CTestImportContactMergeModeStep::ExternaliseFileL(CVersitParser& aParser,const TDesC& aFileName, RFs& fsSession) { RFile file; User::LeaveIfError(file.Replace(fsSession, aFileName, EFileWrite)); CleanupClosePushL(file); aParser.ExternalizeL(file); CleanupStack::PopAndDestroy(&file); }
void CTestImportContactMergeModeStep::InternalizeFileL(CVersitParser& aParser,const TDesC& aFileName, RFs& fsSession) { RFile file; User::LeaveIfError(file.Open(fsSession, aFileName, EFileRead)); CleanupClosePushL(file); TInt start = 0; aParser.InternalizeL(file,start); CleanupStack::PopAndDestroy(&file); }
// ------------------------------------------------------------------------------------------------ // CNSmlDataModBase::StripL // Strips data that is to be transmitted to the sync partner. // ------------------------------------------------------------------------------------------------ void CNSmlDataModBase::StripL( TDes8& aItem ) { _DBG_FILE("CNSmlDataModBase::StripL(): begin"); if ( !NeedsMerge() ) { if ( iUsedRemoteMimeType == -1 ) { User::Leave( KErrNotFound ); } return; } TBool modified( EFalse ); CVersitParser* parser = ChildCreateParserLC(); RDesReadStream drs( aItem ); CleanupClosePushL( drs ); parser->InternalizeL( drs ); // Now we're ready to start analysis CArrayPtr<CVersitParser>* entities = parser->ArrayOfEntities( EFalse ); if( entities ) { for( TInt i = 0; i < entities->Count(); i++ ) { StripEntityL( entities->At( i ), modified ); } } else { StripEntityL( parser, modified ); } // Only update if anything was modified in process if( modified ) { aItem.Zero(); RDesWriteStream dws( aItem ); CleanupClosePushL( dws ); parser->ExternalizeL( dws ); dws.CommitL(); CleanupStack::PopAndDestroy(); // dws } CleanupStack::PopAndDestroy( 2 ); // drs, parser _DBG_FILE("CNSmlDataModBase::StripL(): end"); }
// ------------------------------------------------------------------------------------------------ // CNSmlDataModBase::MergeL // Merges data from old item to new item. // ------------------------------------------------------------------------------------------------ void CNSmlDataModBase::MergeL( TDes8& aNewItem, const TDesC8& aOldItem,TBool aFieldLevel ) { TBool modified( EFalse ); CVersitParser* newItemParser = ChildCreateParserLC(); RDesReadStream newStream( aNewItem ); CleanupClosePushL( newStream ); newItemParser->InternalizeL( newStream ); CVersitParser* oldItemParser = ChildCreateParserLC(); RDesReadStream oldStream( aOldItem ); CleanupClosePushL( oldStream ); oldItemParser->InternalizeL( oldStream ); // Now we're ready to start analysis CArrayPtr<CVersitParser>* newEntities = newItemParser->ArrayOfEntities( EFalse ); CArrayPtr<CVersitParser>* oldEntities = oldItemParser->ArrayOfEntities( ETrue ); if( newEntities && oldEntities ) { CleanupPtrArrayPushL( oldEntities ); for( TInt i = 0; ( i < newEntities->Count() ) && ( i < oldEntities->Count() ); i++ ) { MergeEntityL( newEntities->At( i ), oldEntities->At( i ), modified, aFieldLevel ); } CleanupStack::PopAndDestroy(); // oldEntities } else { MergeEntityL( newItemParser, oldItemParser, modified, aFieldLevel ); } // Only update if anything was modified in process if ( modified ) { aNewItem.Zero(); RDesWriteStream dws( aNewItem ); CleanupClosePushL( dws ); newItemParser->ExternalizeL( dws ); dws.CommitL(); CleanupStack::PopAndDestroy(); // dws } CleanupStack::PopAndDestroy( 4 ); // oldStream, oldItemParser, newStream, newItemParser }