574 CCCAppMyCard* self = static_cast<CCCAppMyCard*>( aPtr ); |
574 CCCAppMyCard* self = static_cast<CCCAppMyCard*>( aPtr ); |
575 TRAPD( err, self->LaunchContactEditorL( TPbk2ContactEditorParams::ENewContact | |
575 TRAPD( err, self->LaunchContactEditorL( TPbk2ContactEditorParams::ENewContact | |
576 TPbk2ContactEditorParams::EOwnContact ) ); |
576 TPbk2ContactEditorParams::EOwnContact ) ); |
577 |
577 |
578 if( err != KErrNone ) |
578 if( err != KErrNone ) |
579 { |
579 { |
580 self->iPlugin.HandleError( err ); |
580 self->iPlugin.HandleError( err ); |
|
581 |
|
582 if( !self->iMyCard ) |
|
583 { |
|
584 self->iCloseCallBack->Call(); |
|
585 } |
|
586 else |
|
587 { |
|
588 self->LoadContact(); |
|
589 } |
581 } |
590 } |
582 |
591 |
583 return err; |
592 return err; |
584 } |
593 } |
585 |
594 |
601 contact = store->CreateNewContactLC(); |
610 contact = store->CreateNewContactLC(); |
602 CleanupStack::Pop(); // contact, whose ownership is taken away |
611 CleanupStack::Pop(); // contact, whose ownership is taken away |
603 } |
612 } |
604 else if( aFlags & TPbk2ContactEditorParams::EModified ) |
613 else if( aFlags & TPbk2ContactEditorParams::EModified ) |
605 { |
614 { |
606 // focused field |
615 if( iFocusedFieldIndex >= KErrNone ) |
607 field = iMyCardContact->Fields().FieldAtLC( iFocusedFieldIndex ); |
616 { |
|
617 // focused field |
|
618 field = iMyCardContact->Fields().FieldAtLC( iFocusedFieldIndex ); |
|
619 } |
|
620 |
608 // pass current store contact, ownership is taken |
621 // pass current store contact, ownership is taken |
609 contact = iMyCardContact; |
622 contact = iMyCardContact; |
610 iMyCardContact = NULL; |
623 iMyCardContact = NULL; |
|
624 delete iPresentationContact; |
|
625 iPresentationContact = NULL; |
611 } |
626 } |
612 // params for the editor |
627 // params for the editor |
613 TPbk2ContactEditorParams params( aFlags, field, NULL, this ); |
628 TPbk2ContactEditorParams params( aFlags, field, NULL, this ); |
614 |
629 |
615 // pass custom title text |
630 // pass custom title text |
655 // --------------------------------------------------------------------------- |
670 // --------------------------------------------------------------------------- |
656 // |
671 // |
657 void CCCAppMyCard::ContactEditingComplete( MVPbkStoreContact* aEditedContact ) |
672 void CCCAppMyCard::ContactEditingComplete( MVPbkStoreContact* aEditedContact ) |
658 { |
673 { |
659 // create link of mycard |
674 // create link of mycard |
660 MVPbkContactLink* link = NULL; |
675 MVPbkContactLink* link = NULL; |
661 TRAPD( err, |
676 |
662 link = aEditedContact->CreateLinkLC(); |
677 TRAPD( err, |
663 CleanupStack::Pop(); ); //link |
678 { |
664 |
679 link = aEditedContact->CreateLinkLC(); |
665 if( !err ) |
680 |
666 { |
681 if( link ) |
|
682 { |
|
683 CleanupStack::Pop(); //link |
|
684 } |
|
685 } ); |
|
686 |
|
687 delete aEditedContact; // ignore given contact |
|
688 |
|
689 if( link && err == KErrNone ) |
|
690 { |
|
691 |
667 delete iMyCard; |
692 delete iMyCard; |
668 iMyCard = link; |
693 iMyCard = link; |
669 |
694 |
670 // reload mycard to get rid of the empty template fields |
695 // reload mycard to get rid of the empty template fields |
671 LoadContact(); |
696 LoadContact(); |
672 } |
697 } |
673 |
698 else if( !iMyCard ) |
674 delete aEditedContact; // ignore given contact |
699 { |
|
700 iCloseCallBack->Call(); |
|
701 } |
|
702 |
675 iDialogIsRunning = EFalse; |
703 iDialogIsRunning = EFalse; |
676 } |
704 } |
677 |
705 |
678 // --------------------------------------------------------------------------- |
706 // --------------------------------------------------------------------------- |
679 // CCCAppMyCard::ContactEditingDeletedContact |
707 // CCCAppMyCard::ContactEditingDeletedContact |
772 { |
800 { |
773 TRAPD( err, LaunchContactEditorL( TPbk2ContactEditorParams::EModified | |
801 TRAPD( err, LaunchContactEditorL( TPbk2ContactEditorParams::EModified | |
774 TPbk2ContactEditorParams::EOwnContact) ); |
802 TPbk2ContactEditorParams::EOwnContact) ); |
775 if( err != KErrNone ) |
803 if( err != KErrNone ) |
776 { |
804 { |
|
805 LoadContact(); |
777 iPlugin.HandleError( err ); |
806 iPlugin.HandleError( err ); |
|
807 if( !iMyCard ) |
|
808 { |
|
809 iCloseCallBack->Call(); |
|
810 } |
778 } |
811 } |
779 } |
812 } |
780 else if( aResult.iOpCode == MVPbkContactObserver::EContactDelete ) |
813 else if( aResult.iOpCode == MVPbkContactObserver::EContactDelete ) |
781 { |
814 { |
782 iCloseCallBack->Call(); |
815 iCloseCallBack->Call(); |