calendarui/globaldata/src/calenglobaldata.cpp
branchRCL_3
changeset 86 ed599363c2d7
parent 78 356f28cd5ca0
equal deleted inserted replaced
78:356f28cd5ca0 86:ed599363c2d7
  1548     BaflUtils::NearestLanguageFile( fsSession, resourceFileName );
  1548     BaflUtils::NearestLanguageFile( fsSession, resourceFileName );
  1549     resourceFile.OpenL(fsSession, resourceFileName );
  1549     resourceFile.OpenL(fsSession, resourceFileName );
  1550     resourceFile.ConfirmSignatureL( 0 );   
  1550     resourceFile.ConfirmSignatureL( 0 );   
  1551 	for(TInt index=0;index < iCalendarInfoList.Count();index++)
  1551 	for(TInt index=0;index < iCalendarInfoList.Count();index++)
  1552 	    {
  1552 	    {
  1553         
  1553         CCalCalendarInfo* calendarInfo = iCalendarInfoList[index];
  1554 	    TPtrC calendarNamePtr = iCalendarInfoList[index]->NameL();
  1554 	    TPtrC calendarNamePtr = iCalendarInfoList[index]->NameL();
  1555         if(calendarNamePtr.Compare(KPersonal) == 0)
  1555         if(calendarNamePtr.Compare(KPersonal) == 0)
  1556             {  
  1556             {  
  1557             HBufC8* personalBuffer = resourceFile.AllocReadLC( R_CALE_DB_PERSONAL );    
  1557             HBufC8* personalBuffer = resourceFile.AllocReadLC( R_CALE_DB_PERSONAL );    
  1558             const TPtrC16 ptrPBuffer(( TText16*) personalBuffer->Ptr(),
  1558             const TPtrC16 ptrPBuffer(( TText16*) personalBuffer->Ptr(),
  1560             HBufC *personalCalendar = ptrPBuffer.AllocL();    
  1560             HBufC *personalCalendar = ptrPBuffer.AllocL();    
  1561             CleanupStack::PushL(personalCalendar);
  1561             CleanupStack::PushL(personalCalendar);
  1562             iCalendarInfoList[index]->SetNameL(*personalCalendar);
  1562             iCalendarInfoList[index]->SetNameL(*personalCalendar);
  1563             CleanupStack::PopAndDestroy( 2,personalBuffer );
  1563             CleanupStack::PopAndDestroy( 2,personalBuffer );
  1564             }
  1564             }
  1565        
  1565         TBuf8<KBuffLength> keyBuff;
  1566 	   
  1566         // Mark the meta property as SoftDeleted
       
  1567         keyBuff.Zero();
       
  1568         keyBuff.AppendNum(EMarkAsDelete);
       
  1569         TBool softDelete = EFalse;
       
  1570         TPckgC<TBool> pkgSoftDelete( softDelete );
       
  1571         TRAPD(err,pkgSoftDelete.Set(calendarInfo->PropertyValueL(keyBuff)));
       
  1572         if( KErrNone == err )
       
  1573             {
       
  1574             softDelete = pkgSoftDelete();
       
  1575             }
       
  1576         if( !softDelete )
       
  1577             {
  1567             aCalendarInfoList.AppendL(iCalendarInfoList[index]);
  1578             aCalendarInfoList.AppendL(iCalendarInfoList[index]);
       
  1579             }
       
  1580         else
       
  1581             {
       
  1582             iCalendarInfoList.Remove(index);
       
  1583     		delete calendarInfo;
       
  1584     				
       
  1585             iHashDbidIndexMap.Close();
       
  1586     
       
  1587             iFileMappingArray.Remove(index);
       
  1588             for(TInt index = 0; index < iFileMappingArray.Count(); index++)
       
  1589                 {
       
  1590                 iHashDbidIndexMap.InsertL(iFileMappingArray[index]->GetCollectionId(), index);
       
  1591                 }
       
  1592             }
  1568 	        
  1593 	        
  1569 	    }
  1594 	    }
  1570 	 CleanupStack::PopAndDestroy(2);
  1595 	 CleanupStack::PopAndDestroy(2);
  1571 	 CleanupStack::Pop(&aCalendarInfoList);
  1596 	 CleanupStack::Pop(&aCalendarInfoList);
  1572 	TRACE_EXIT_POINT;
  1597 	TRACE_EXIT_POINT;
  1670     CleanupStack::PopAndDestroy(calendarIterator);
  1695     CleanupStack::PopAndDestroy(calendarIterator);
  1671     
  1696     
  1672     TRACE_EXIT_POINT;
  1697     TRACE_EXIT_POINT;
  1673     }
  1698     }
  1674 
  1699 
  1675 // -----------------------------------------------------------------------------
       
  1676 // CCalenGlobalData::UpdateCalendarListL
       
  1677 // Update calendar list whenever CalendarInfoUpdated notification is received.
       
  1678 // -----------------------------------------------------------------------------
       
  1679 //
       
  1680 void CCalenGlobalData::UpdateCalendarListL()
       
  1681     {
       
  1682 	//Getting calendar name updated from calennotifier infochangednotification
       
  1683     HBufC* calendarNameUpdated = iContext->GetCalendarFileNameL().AllocLC();
       
  1684     TInt index = iFileMappingArray.Find( *calendarNameUpdated, 
       
  1685                     CCalenGlobalData::CalenInfoIdentifierL);
       
  1686 
       
  1687     if(index != KErrNotFound)
       
  1688         {
       
  1689         CCalSession* session = iFileMappingArray[index]->GetSessionPtr();
       
  1690         for(TInt i=0; i<iCalendarInfoList.Count() ;i++)
       
  1691             {
       
  1692             if( !iCalendarInfoList[i]->FileNameL().CompareF(calendarNameUpdated->Des()))
       
  1693                 {
       
  1694                 iCalendarInfoList[i] = session->CalendarInfoL();
       
  1695                 }
       
  1696             }
       
  1697         }
       
  1698     CleanupStack::PopAndDestroy(calendarNameUpdated);
       
  1699     }
       
  1700 // -----------------------------------------------------------------------------
  1700 // -----------------------------------------------------------------------------
  1701 // CCalenGlobalData::GetDefaultCalendarInfoL
  1701 // CCalenGlobalData::GetDefaultCalendarInfoL
  1702 // Get default calendar info
  1702 // Get default calendar info
  1703 // -----------------------------------------------------------------------------
  1703 // -----------------------------------------------------------------------------
  1704 //
  1704 //
  1811 // -----------------------------------------------------------------------------
  1811 // -----------------------------------------------------------------------------
  1812 //
  1812 //
  1813 void CCalenGlobalData::HandleCalendarInfoUpdatedL()
  1813 void CCalenGlobalData::HandleCalendarInfoUpdatedL()
  1814 	{
  1814 	{
  1815 	TRACE_ENTRY_POINT;
  1815 	TRACE_ENTRY_POINT;
  1816     
  1816 	
  1817 	//Update Calendar list.
  1817 	// reconstruct the calendar list using the iterator
  1818     	UpdateCalendarListL();
  1818 	ConstructCalendarsListL();
  1819 	    
  1819 
  1820 	TRACE_EXIT_POINT;
  1820 	TRACE_EXIT_POINT;
  1821 	}
  1821 	}
  1822 
  1822 
  1823 // -----------------------------------------------------------------------------
  1823 // -----------------------------------------------------------------------------
  1824 // CCalenGlobalData::HandleCalendarFileDeletedL
  1824 // CCalenGlobalData::HandleCalendarFileDeletedL