617 |
617 |
618 CPbk2ImageManager* imageManager = CPbk2ImageManager::NewL( |
618 CPbk2ImageManager* imageManager = CPbk2ImageManager::NewL( |
619 services.ContactManager() ); |
619 services.ContactManager() ); |
620 CleanupStack::PushL( imageManager ); |
620 CleanupStack::PushL( imageManager ); |
621 |
621 |
622 if( CAknQueryDialog::NewL()->ExecuteLD( |
622 const MVPbkFieldType* thumbType = services.ContactManager().FieldTypes().Find( |
623 R_PHONEBOOK2_REMOVE_IMAGE_CONFIRMATION_DIALOG ) ) |
623 R_VPBK_FIELD_TYPE_THUMBNAILPIC ); |
624 { |
624 |
625 TPbk2StoreContactAnalyzer analyzer( |
625 // show a confirmation query if contact has an image |
626 services.ContactManager(), aContact ); |
626 if (thumbType && imageManager->HasImage( *aContact, *thumbType ) ) |
627 TInt imageIndex = analyzer.HasFieldL( R_PHONEBOOK2_IMAGE_SELECTOR ); |
627 { |
628 |
628 if ( CAknQueryDialog::NewL()->ExecuteLD( |
629 if ( imageIndex != KErrNotFound ) |
629 R_PHONEBOOK2_REMOVE_IMAGE_CONFIRMATION_DIALOG ) ) |
630 { |
630 { |
631 //aContact->RemoveField( imageIndex ); |
631 TPbk2StoreContactAnalyzer analyzer( |
632 //Instead of above we don't remove the field, just zero it's data |
632 services.ContactManager(), aContact ); |
633 MVPbkContactFieldData& data(aContact->Fields(). |
633 TInt imageIndex = analyzer.HasFieldL( R_PHONEBOOK2_IMAGE_SELECTOR ); |
634 FieldAt( imageIndex ).FieldData()); |
634 |
635 MVPbkContactFieldTextData::Cast( data ).SetTextL(KNullDesC); |
635 if ( imageIndex != KErrNotFound ) |
636 } |
636 { |
637 |
637 //aContact->RemoveField( imageIndex ); |
638 const MVPbkFieldType* thumbFieldType = ThumbnailFieldTypeL(services); |
638 //Instead of above we don't remove the field, just zero it's data |
639 imageManager->RemoveImage( *aContact, *thumbFieldType ); |
639 MVPbkContactFieldData& data(aContact->Fields(). |
640 } |
640 FieldAt( imageIndex ).FieldData()); |
|
641 MVPbkContactFieldTextData::Cast( data ).SetTextL(KNullDesC); |
|
642 } |
|
643 |
|
644 const MVPbkFieldType* thumbFieldType = ThumbnailFieldTypeL(services); |
|
645 imageManager->RemoveImage( *aContact, *thumbFieldType ); |
|
646 } |
|
647 } |
|
648 |
641 CleanupStack::PopAndDestroy( imageManager ); |
649 CleanupStack::PopAndDestroy( imageManager ); |
642 |
|
643 CleanupStack::PopAndDestroy(); // services |
650 CleanupStack::PopAndDestroy(); // services |
644 |
651 |
645 return NULL; // synchronous operation |
652 return NULL; // synchronous operation |
646 } |
653 } |
647 |
654 |