diff -r 6b5524b4f673 -r 38bb213f60ba phonebookengines/VirtualPhonebook/VPbkSimStore/src/CContact.cpp --- a/phonebookengines/VirtualPhonebook/VPbkSimStore/src/CContact.cpp Wed Sep 15 11:56:55 2010 +0300 +++ b/phonebookengines/VirtualPhonebook/VPbkSimStore/src/CContact.cpp Wed Oct 13 14:15:33 2010 +0300 @@ -30,8 +30,6 @@ #include #include #include -#include -#include #include #include #include @@ -50,8 +48,6 @@ KNewContact = 1 }; -const TInt KDefinedAnrFieldTypeCount = 3; // count of defined additional number types - // ============================= LOCAL FUNCTIONS =============================== MVPbkContactObserver::TContactOp ConvertContactOperation( @@ -102,35 +98,15 @@ break; } case EVPbkSimGsmNumber: // FALLTHROUGH - case EVPbkSimAdditionalNumberLast: // the EVPbkSimAdditionalNumber + case EVPbkSimAdditionalNumber: { ++result; // always at least one number if ( aUsimProp.iMaxNumOfAnrs != KVPbkSimStorePropertyUndefined ) { - if ( !FeatureManager::FeatureSupported( - KFeatureIdFfTdClmcontactreplicationfromphonebooktousimcard ) ) - { - result += aUsimProp.iMaxNumOfAnrs; - } - else - { - if ( aUsimProp.iMaxNumOfAnrs - KDefinedAnrFieldTypeCount > 0 ) - { - result += (aUsimProp.iMaxNumOfAnrs - KDefinedAnrFieldTypeCount); - } - } + result += aUsimProp.iMaxNumOfAnrs; } break; } - case EVPbkSimAdditionalNumber1: - result = aUsimProp.iMaxNumOfAnrs >= 1 ? 1 : 0; // according the max number of anrs. - break; - case EVPbkSimAdditionalNumber2: - result = aUsimProp.iMaxNumOfAnrs >= 2 ? 1 : 0; - break; - case EVPbkSimAdditionalNumber3: - result = aUsimProp.iMaxNumOfAnrs >= 3 ? 1 : 0; - break; default: { // Do nothing @@ -143,7 +119,6 @@ namespace VPbkSimStore { -_LIT( KEmptyData, "+" ); //the empty data, modifiy this string to keep its a special string. // ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- @@ -169,11 +144,6 @@ { iFlags.Set( KNewContact ); } - if( FeatureManager::FeatureSupported( - KFeatureIdFfTdClmcontactreplicationfromphonebooktousimcard ) ) - { - RemoveAllEmptyFields( aSimContact ); // remove the empty contacts where added before save. - } iFields.SetContact( *this, aSimContact ); iAsyncOp = new( ELeave ) VPbkEngUtils::CVPbkAsyncOperation; } @@ -204,126 +174,6 @@ } // ----------------------------------------------------------------------------- -// CContact::RemoveAllEmptyFields -// ----------------------------------------------------------------------------- -// -void CContact::RemoveAllEmptyFields( CVPbkSimContact& aSimContact ) - { - TInt i = aSimContact.FieldCount() - 1 ; - while( i >= 0 ) - { - CVPbkSimCntField& cntField = aSimContact.FieldAt( i ); - TVPbkSimCntFieldType simCntType = cntField.Type(); - if( simCntType == EVPbkSimGsmNumber - || simCntType == EVPbkSimAdditionalNumber1 - || simCntType == EVPbkSimAdditionalNumber2 - || simCntType == EVPbkSimAdditionalNumber3 - || simCntType == EVPbkSimAdditionalNumberLast ) - { - if( cntField. Data().Compare( KEmptyData ) == 0 ) - { - aSimContact.DeleteField( i ); - } - } - i --; - } - } - -// ----------------------------------------------------------------------------- -// CContact::FillWithEmptyFieldsL -// ----------------------------------------------------------------------------- -// -void CContact::FillWithEmptyFieldsL() const - { - RPointerArray & contactFieldArray = iSimContact->FieldArray(); - TInt i = contactFieldArray.Count() - 1 ; - while( i >= 0 ) // remove all empty content. - { - CVPbkSimCntField& cntField = iSimContact->FieldAt( i ); - TVPbkSimCntFieldType type = cntField.Type(); - if( cntField. Data().Length() == 0 ) - { - iSimContact->DeleteField( i ); - } - i --; - } - - if( contactFieldArray.Count() == 0 ) // no un-empty fields. - { - return; - } - CVPbkSimContact::TFieldLookup lookupAdnNumber = - iSimContact->FindField( EVPbkSimAdditionalNumber ); - if( lookupAdnNumber.EndOfLookup()) // if there is no additional number in the contact then no need to add placeholder - { - return; - } - RPointerArray tempFieldArray; - CleanupClosePushL( tempFieldArray ); - // mappings - CFieldTypeMappings & mappings = iParentStore.FieldTypeMappings(); - // supported types. - const CSupportedFieldTypes& supportedTypes = iParentStore.SupportedFieldTypes(); - - // check all supported field types in the fields list. If not exist created new. - // if data length is 0, set data to empty data. - for( int i = 0; i < supportedTypes.FieldTypeCount(); i ++ ) - { - const MVPbkFieldType& fieldType = supportedTypes.FieldTypeAt( i ); - TVPbkSimCntFieldType simCntType = mappings.Match( fieldType ); - if( simCntType == EVPbkSimGsmNumber - || simCntType == EVPbkSimAdditionalNumber1 - || simCntType == EVPbkSimAdditionalNumber2 - || simCntType == EVPbkSimAdditionalNumber3 - || simCntType == EVPbkSimAdditionalNumberLast ) - { - CVPbkSimCntField * field = NULL; - CVPbkSimContact::TFieldLookup lookup = - iSimContact->FindField( simCntType ); - - if( lookup.EndOfLookup() ) - { - field= iSimContact->CreateFieldLC( simCntType ); - field->SetDataL( KEmptyData ); - tempFieldArray.Append( field ); - CleanupStack::Pop(); - } - else - { - field = contactFieldArray[lookup.Index()]; - if( field->Data().Length() == 0 ) - { - field->SetDataL( KEmptyData ); - } - if( simCntType == EVPbkSimAdditionalNumber1 - || simCntType == EVPbkSimAdditionalNumber2 - || simCntType == EVPbkSimAdditionalNumber3 ) - { - contactFieldArray.Remove( lookup.Index() ); - tempFieldArray.AppendL( field ); - } - } - } - } - TInt j = contactFieldArray.Count() - 1; - while( j >= 0 ) // EVPbkSimAdditionalNumberLast type field will append at last. - { - if( contactFieldArray[j]->Type() == EVPbkSimAdditionalNumberLast ) - { - tempFieldArray.AppendL( contactFieldArray[ j ] ); - contactFieldArray.Remove( j ); - } - j --; - } - for( int i = 0; i < tempFieldArray.Count(); i ++ ) - { - contactFieldArray.AppendL( tempFieldArray[i]); - } - tempFieldArray.Reset(); - CleanupStack::Pop(); - } - -// ----------------------------------------------------------------------------- // CContact::ParentObject // ----------------------------------------------------------------------------- // @@ -451,7 +301,7 @@ VPbkSimStore::Panic( ESimFieldTypeNotFound ) ); if ( simType == EVPbkSimGsmNumber || - simType == EVPbkSimAdditionalNumberLast ) //the same field type as EVPbkSimGsmNumber + simType == EVPbkSimAdditionalNumber ) { // EVPbkSimGsmNumber and EVPbkSimAdditionalNumber maps to same // VPbk field type. A sim contact can have only one EVPbkSimGsmNumber @@ -470,7 +320,7 @@ } else { - simType = EVPbkSimAdditionalNumberLast; + simType = EVPbkSimAdditionalNumber; } } @@ -571,10 +421,6 @@ } // From the client point of view the MVPbkStoreContact is constant but // implementation needs a non const contact. - if( FeatureManager::FeatureSupported( KFeatureIdFfTdClmcontactreplicationfromphonebooktousimcard ) ) - { - FillWithEmptyFieldsL(); - } iStoreOperation = iSimContact->SaveL( const_cast( *this )); iObserver = &aObserver; } @@ -652,12 +498,6 @@ MVPbkContactObserver* observer = iObserver; ResetContactOperationState(); - - // remove filled placeholder fields. - if( vpbkOpResult.iOpCode == MVPbkContactObserver::EContactCommit ) - { - RemoveAllEmptyFields( *iSimContact ); - } observer->ContactOperationCompleted( vpbkOpResult ); } @@ -676,12 +516,6 @@ MVPbkContactObserver* observer = iObserver; ResetContactOperationState(); MVPbkContactObserver::TContactOp op = ConvertContactOperation( aEvent ); - - // remove filled placeholder fields. - if( op == MVPbkContactObserver::EContactCommit ) - { - RemoveAllEmptyFields( *iSimContact ); - } observer->ContactOperationFailed( op, aError, EFalse ); }