calendarui/controller/src/calenmultipledbui.cpp
branchRCL_3
changeset 60 96907930389d
parent 59 aba12c885d83
child 67 1539a383d7b6
--- a/calendarui/controller/src/calenmultipledbui.cpp	Thu Jul 15 18:37:27 2010 +0300
+++ b/calendarui/controller/src/calenmultipledbui.cpp	Thu Aug 19 09:53:43 2010 +0300
@@ -45,6 +45,8 @@
 #include <featmgr.h>
 #include <hlplch.h>
 #include <csxhelp/cale.hlp.hrh>
+#include <calencontext.h>
+#include <calenservices.h>
 
 // User includes
 #include "calendarui_debug.h"
@@ -285,7 +287,11 @@
         delete iCalendarInfoOriginal;
         iCalendarInfoOriginal = NULL;
         }
-
+if(iCalEditedDefaultName)
+        {
+        delete iCalEditedDefaultName;
+        iCalEditedDefaultName = NULL;
+        }
     TRACE_EXIT_POINT;
     }
 
@@ -687,6 +693,11 @@
 	TInt retError = KErrNone;
     
 	iDbEditor = NULL;
+	if(iCalEditedDefaultName)
+	    {
+        delete iCalEditedDefaultName;
+        iCalEditedDefaultName = NULL;
+	    }
     
     if(aItemAdded)
         {
@@ -764,6 +775,7 @@
     
     iCalendarInfoEdited = calendarInfoList[currentIndex];
     
+    iCalEditedDefaultName = calendarInfoList[currentIndex]->FileNameL().AllocL();
     CleanupStack::PopAndDestroy(&calendarInfoList);
     
     //Take a copy of original before editing
@@ -1414,7 +1426,22 @@
         case ECalenNotifyCalendarInfoCreated:
         case ECalenNotifyCalendarInfoUpdated:
             {
-            if (iDbEditor)
+            MCalenContext& context = iController.Services().Context();
+            TDesC& aConflictCalendarName  = context.GetCalendarFileNameL();
+            TBool isSameFileEdited = EFalse;
+            if(iCalEditedDefaultName)
+                {
+                if(!iCalEditedDefaultName->CompareF(aConflictCalendarName))
+                    {
+                    isSameFileEdited = ETrue; 
+                    }
+                else
+                    {
+                    isSameFileEdited = EFalse;
+                    }
+                }
+            
+            if (iDbEditor && isSameFileEdited)
                 {
                 iConflictOccured = ETrue;
                 iDbEditor->SetConflict(CCalenMultiDBEditor::EConflictUpdate);
@@ -1423,7 +1450,28 @@
             break;
         case ECalenNotifyCalendarFileDeleted:
             {
-            if (iDbEditor)
+            RPointerArray<CCalCalendarInfo> calendarInfoList;
+            TBool isSameFileDeleted = EFalse;
+            iController.GetAllCalendarInfoL(calendarInfoList);
+            CleanupClosePushL(calendarInfoList);
+            if(iCalEditedDefaultName)
+                {
+                for(TInt i=0; i<calendarInfoList.Count(); i++)
+                    {
+                    if(!iCalEditedDefaultName->CompareF(calendarInfoList[i]->FileNameL()))
+                        {
+                        isSameFileDeleted = EFalse;
+                        break;
+                        }
+                    else
+                        {
+                        isSameFileDeleted = ETrue;
+                        }
+                    }
+                }
+            CleanupStack::PopAndDestroy(&calendarInfoList);
+            
+            if (iDbEditor && isSameFileDeleted)
                 {
                 iConflictOccured = ETrue;
                 iDbEditor->SetConflict(CCalenMultiDBEditor::EConflictDelete);
@@ -1435,7 +1483,7 @@
         }
 
     // refresh calendar list
-    UpdateListboxL();
+    TRAP_IGNORE(UpdateListboxL());
 
     TRACE_EXIT_POINT;
     }