calendarui/globaldata/src/calenglobaldata.cpp
branchRCL_3
changeset 86 ed599363c2d7
parent 78 356f28cd5ca0
--- a/calendarui/globaldata/src/calenglobaldata.cpp	Wed Sep 15 12:11:35 2010 +0300
+++ b/calendarui/globaldata/src/calenglobaldata.cpp	Wed Oct 13 14:30:35 2010 +0300
@@ -1550,7 +1550,7 @@
     resourceFile.ConfirmSignatureL( 0 );   
 	for(TInt index=0;index < iCalendarInfoList.Count();index++)
 	    {
-        
+        CCalCalendarInfo* calendarInfo = iCalendarInfoList[index];
 	    TPtrC calendarNamePtr = iCalendarInfoList[index]->NameL();
         if(calendarNamePtr.Compare(KPersonal) == 0)
             {  
@@ -1562,9 +1562,34 @@
             iCalendarInfoList[index]->SetNameL(*personalCalendar);
             CleanupStack::PopAndDestroy( 2,personalBuffer );
             }
-       
-	   
+        TBuf8<KBuffLength> keyBuff;
+        // Mark the meta property as SoftDeleted
+        keyBuff.Zero();
+        keyBuff.AppendNum(EMarkAsDelete);
+        TBool softDelete = EFalse;
+        TPckgC<TBool> pkgSoftDelete( softDelete );
+        TRAPD(err,pkgSoftDelete.Set(calendarInfo->PropertyValueL(keyBuff)));
+        if( KErrNone == err )
+            {
+            softDelete = pkgSoftDelete();
+            }
+        if( !softDelete )
+            {
             aCalendarInfoList.AppendL(iCalendarInfoList[index]);
+            }
+        else
+            {
+            iCalendarInfoList.Remove(index);
+    		delete calendarInfo;
+    				
+            iHashDbidIndexMap.Close();
+    
+            iFileMappingArray.Remove(index);
+            for(TInt index = 0; index < iFileMappingArray.Count(); index++)
+                {
+                iHashDbidIndexMap.InsertL(iFileMappingArray[index]->GetCollectionId(), index);
+                }
+            }
 	        
 	    }
 	 CleanupStack::PopAndDestroy(2);
@@ -1673,31 +1698,6 @@
     }
 
 // -----------------------------------------------------------------------------
-// CCalenGlobalData::UpdateCalendarListL
-// Update calendar list whenever CalendarInfoUpdated notification is received.
-// -----------------------------------------------------------------------------
-//
-void CCalenGlobalData::UpdateCalendarListL()
-    {
-	//Getting calendar name updated from calennotifier infochangednotification
-    HBufC* calendarNameUpdated = iContext->GetCalendarFileNameL().AllocLC();
-    TInt index = iFileMappingArray.Find( *calendarNameUpdated, 
-                    CCalenGlobalData::CalenInfoIdentifierL);
-
-    if(index != KErrNotFound)
-        {
-        CCalSession* session = iFileMappingArray[index]->GetSessionPtr();
-        for(TInt i=0; i<iCalendarInfoList.Count() ;i++)
-            {
-            if( !iCalendarInfoList[i]->FileNameL().CompareF(calendarNameUpdated->Des()))
-                {
-                iCalendarInfoList[i] = session->CalendarInfoL();
-                }
-            }
-        }
-    CleanupStack::PopAndDestroy(calendarNameUpdated);
-    }
-// -----------------------------------------------------------------------------
 // CCalenGlobalData::GetDefaultCalendarInfoL
 // Get default calendar info
 // -----------------------------------------------------------------------------
@@ -1813,10 +1813,10 @@
 void CCalenGlobalData::HandleCalendarInfoUpdatedL()
 	{
 	TRACE_ENTRY_POINT;
-    
-	//Update Calendar list.
-    	UpdateCalendarListL();
-	    
+	
+	// reconstruct the calendar list using the iterator
+	ConstructCalendarsListL();
+
 	TRACE_EXIT_POINT;
 	}