456 |
456 |
457 CArrayPtr<CParserProperty>* allProps = aEntity->ArrayOfProperties( EFalse ); |
457 CArrayPtr<CParserProperty>* allProps = aEntity->ArrayOfProperties( EFalse ); |
458 for( TInt i = 0; i < allProps->Count(); ) // Variable i is not increased here because size of count might be changes during loop |
458 for( TInt i = 0; i < allProps->Count(); ) // Variable i is not increased here because size of count might be changes during loop |
459 { |
459 { |
460 const CParserProperty& ownProperty = *allProps->At( i ); |
460 const CParserProperty& ownProperty = *allProps->At( i ); |
461 TBuf8<30> name = ownProperty.Name(); |
|
462 CParserPropertyValue* ownValue = ownProperty.Value(); |
461 CParserPropertyValue* ownValue = ownProperty.Value(); |
463 |
462 |
464 TBool removeMe( ETrue ); |
463 TBool removeMe( ETrue ); |
465 |
464 |
466 for( TInt i2 = 0; i2 < iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount(); i2++ ) |
465 for( TInt i2 = 0; i2 < iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount(); i2++ ) |
674 |
673 |
675 // Remove all data that was not supposed to be supported by the partner but |
674 // Remove all data that was not supposed to be supported by the partner but |
676 // it was still sent to us. |
675 // it was still sent to us. |
677 StripAllNotOnPartnerListL( aNewEntity, aModified ); |
676 StripAllNotOnPartnerListL( aNewEntity, aModified ); |
678 |
677 |
679 // Remove all properties from old item that are supported by remote server. |
|
680 // If it is field level then old this is not done. |
|
681 if( !aFieldLevel ) |
678 if( !aFieldLevel ) |
682 { |
679 { |
|
680 // Remove all properties from old item that are supported by remote server. |
|
681 // If it is field level then old this is not done. |
683 StripAllOnPartnerListL( aOldEntity, aModified, ETrue ); |
682 StripAllOnPartnerListL( aOldEntity, aModified, ETrue ); |
684 CArrayPtr<CParserProperty>* mergeProps = aOldEntity->ArrayOfProperties( ETrue ); |
683 CArrayPtr<CParserProperty>* mergeProps = aOldEntity->ArrayOfProperties( ETrue ); |
685 if( mergeProps ) |
684 if( mergeProps ) |
686 { |
685 { |
687 CleanupStack::PushL( mergeProps ); |
686 CleanupStack::PushL( mergeProps ); |
692 } |
691 } |
693 |
692 |
694 CleanupStack::PopAndDestroy(); // mergeProps |
693 CleanupStack::PopAndDestroy(); // mergeProps |
695 } |
694 } |
696 } |
695 } |
697 else |
696 else // Support for Field level merge |
698 { |
697 { |
699 User::Leave( KErrNotSupported ); |
698 //Field level merge. Merge new item with old item. Properties of |
|
699 //the old item are copied to new item if the new item entity does not |
|
700 //contain certain property. |
|
701 //------------------------------------------------------------------------ |
|
702 // Old New Merged |
|
703 //------------------------------------------------------------------------ |
|
704 // BEGIN:VCARD -> BEGIN:VCARD = BEGIN:VCARD |
|
705 // VERSION:2.1 -> VERSION:2.1 = VERSION:2.1 |
|
706 // N:Smith;John -> N:White;John = N:White;John |
|
707 // ORG:Firm = ORG:Firm |
|
708 // TITLE:Boss = TITLE:Boss |
|
709 // -> TEL;CELL;VOICE:1234 = TEL;CELL;VOICE:1234 |
|
710 // END:VCARD -> END:VCARD = END:VCARD |
|
711 |
|
712 CArrayPtr<CParserProperty>* newProps = aNewEntity->ArrayOfProperties( EFalse ); |
|
713 if( newProps ) |
|
714 { |
|
715 CArrayPtr<CParserProperty>* oldProps = aOldEntity->ArrayOfProperties( EFalse ); |
|
716 |
|
717 // Iterate through old list of properties. Add missing properties from old |
|
718 // contact item, if some of the properties is not included in new item. |
|
719 for( TInt i = 0; i < oldProps->Count(); ) |
|
720 { |
|
721 CParserProperty* oldProperty = oldProps->At( i ); |
|
722 |
|
723 //Check if the property is included in received vCard |
|
724 CArrayPtr<CParserProperty>* properties = aNewEntity->PropertyL( |
|
725 oldProperty->Name(), oldProperty->Uid(), EFalse ); |
|
726 |
|
727 if ( !properties ) |
|
728 { |
|
729 // New vCard does not include certain property. Copy all matching properties from |
|
730 // existing contact item. |
|
731 CArrayPtr<CParserProperty>* oldProperties = |
|
732 aOldEntity->PropertyL( oldProperty->Name(), oldProperty->Uid(), ETrue ); |
|
733 CleanupPtrArrayPushL( oldProperties ); |
|
734 |
|
735 for ( TInt j = oldProperties->Count()-1; j >= 0; --j ) |
|
736 { |
|
737 CParserProperty* property = oldProperties->At( j ); |
|
738 oldProperties->Delete( j ); |
|
739 CleanupStack::PushL( property ); |
|
740 aNewEntity->AddPropertyL( property, EFalse ); |
|
741 CleanupStack::Pop( property ); |
|
742 aModified = ETrue; |
|
743 } |
|
744 CleanupStack::PopAndDestroy( oldProperties ); |
|
745 } |
|
746 else |
|
747 { |
|
748 // If new vCard includes at least one property with same name we will not copy |
|
749 // any any property with same name from existing contact item. |
|
750 delete properties; |
|
751 ++i; |
|
752 } |
|
753 } |
|
754 } |
700 } |
755 } |
701 |
756 |
702 #ifdef __NSML_DEBUG__ |
757 #ifdef __NSML_DEBUG__ |
703 CArrayPtr<CParserProperty>* props = aNewEntity->ArrayOfProperties( EFalse ); |
758 CArrayPtr<CParserProperty>* props = aNewEntity->ArrayOfProperties( EFalse ); |
704 for( TInt i = 0; i < props->Count(); i++ ) |
759 for( TInt i = 0; i < props->Count(); i++ ) |