phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycard.cpp
branchRCL_3
changeset 21 b3431bff8c19
parent 15 e8e3147d53eb
child 23 5586b4d2ec3e
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycard.cpp	Mon Mar 15 12:39:26 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycard.cpp	Wed Mar 31 21:13:53 2010 +0300
@@ -576,8 +576,17 @@
         TPbk2ContactEditorParams::EOwnContact ) );
 	
 	if( err != KErrNone )
-        {
+        {        
         self->iPlugin.HandleError( err );
+        
+        if( !self->iMyCard )
+            {
+            self->iCloseCallBack->Call();
+            }
+        else
+            {
+            self->LoadContact();
+            }
         }
 	
 	return err;
@@ -603,11 +612,17 @@
 		}
 	else if( aFlags & TPbk2ContactEditorParams::EModified )
 		{
-		// focused field
-		field = iMyCardContact->Fields().FieldAtLC( iFocusedFieldIndex );
+        if( iFocusedFieldIndex >= KErrNone )
+            {
+            // focused field
+            field = iMyCardContact->Fields().FieldAtLC( iFocusedFieldIndex ); 
+            }
+        				
 		// pass current store contact, ownership is taken
 		contact = iMyCardContact;
-		iMyCardContact = NULL;
+		iMyCardContact = NULL;		
+		delete iPresentationContact;
+		iPresentationContact = NULL;		
 		}
 	// params for the editor
 	TPbk2ContactEditorParams params( aFlags, field, NULL, this );
@@ -657,21 +672,34 @@
 void CCCAppMyCard::ContactEditingComplete( MVPbkStoreContact* aEditedContact )
 	{
     // create link of mycard
-    MVPbkContactLink* link = NULL;
-    TRAPD( err, 
-        link = aEditedContact->CreateLinkLC();   
-        CleanupStack::Pop(); ); //link
+    MVPbkContactLink* link = NULL;       
     
-    if( !err )
+    TRAPD( err,
         {
+        link = aEditedContact->CreateLinkLC(); 
+        
+        if( link )
+            {
+            CleanupStack::Pop(); //link
+            }
+        } );
+        
+    delete aEditedContact; // ignore given contact
+    
+    if( link && err == KErrNone )
+        {
+        
         delete iMyCard;
         iMyCard = link;
         
         // reload mycard to get rid of the empty template fields
         LoadContact();
         }
+    else if( !iMyCard )
+        {
+        iCloseCallBack->Call();
+        }               
     
-    delete aEditedContact; // ignore given contact
     iDialogIsRunning = EFalse;
 	}
 
@@ -774,7 +802,12 @@
             TPbk2ContactEditorParams::EOwnContact) );
     	if( err != KErrNone )
 			{
+            LoadContact();
             iPlugin.HandleError( err );
+            if( !iMyCard )
+                {
+                iCloseCallBack->Call();
+                }                
 			}
     	}    
     else if( aResult.iOpCode == MVPbkContactObserver::EContactDelete )