calendarui/globaldata/src/calenglobaldata.cpp
branchRCL_3
changeset 27 aba12c885d83
parent 25 bf573002ff72
child 28 96907930389d
equal deleted inserted replaced
25:bf573002ff72 27:aba12c885d83
    25 #include "RImplInfoPtrArrayOwn.inl" // Wrapper class with array deletion on close
    25 #include "RImplInfoPtrArrayOwn.inl" // Wrapper class with array deletion on close
    26 #include "calensend.h"              // CCalenSend
    26 #include "calensend.h"              // CCalenSend
    27 #include "CalenInterimUtils2.h"     // CalenInterimUtils
    27 #include "CalenInterimUtils2.h"     // CalenInterimUtils
    28 #include "calencontextimpl.h"       // Calendar context implementation
    28 #include "calencontextimpl.h"       // Calendar context implementation
    29 #include "calenfilemapping.h"
    29 #include "calenfilemapping.h"
       
    30 #include "missedalarmstore.h"
       
    31 #include "CleanupResetAndDestroy.h"
       
    32 #include "calendar.hrh"
    30 
    33 
    31 #include <Calendar.rsg>             // Calendar resources
    34 #include <Calendar.rsg>             // Calendar resources
    32 #include <cmrmailboxutils.h>        // CMRMailboxUtils
    35 #include <cmrmailboxutils.h>        // CMRMailboxUtils
    33 #include <utf.h>                    // CnvUtfConverter
    36 #include <utf.h>                    // CnvUtfConverter
    34 #include <StringLoader.h>           // Loads strings from resource files
    37 #include <StringLoader.h>           // Loads strings from resource files
  1267 // -----------------------------------------------------------------------------
  1270 // -----------------------------------------------------------------------------
  1268 //
  1271 //
  1269 EXPORT_C void CCalenGlobalData::AddCalendarL(CCalCalendarInfo* aCalendarInfo)
  1272 EXPORT_C void CCalenGlobalData::AddCalendarL(CCalCalendarInfo* aCalendarInfo)
  1270 	{	
  1273 	{	
  1271 	TRACE_ENTRY_POINT;
  1274 	TRACE_ENTRY_POINT;
  1272 
  1275 	CleanupStack::PushL(aCalendarInfo);
       
  1276 	
  1273 	CCalenFileMapping* fileMapping = CCalenFileMapping::NewL();
  1277 	CCalenFileMapping* fileMapping = CCalenFileMapping::NewL();
  1274 	CleanupStack::PushL(fileMapping);
  1278 	CleanupStack::PushL(fileMapping);
  1275 	
  1279 	
  1276 	HBufC* calendarFileName = CCalenMultiCalUtil::GetNextAvailableCalFileL();
  1280 	HBufC* calendarFileName = CCalenMultiCalUtil::GetNextAvailableCalFileL();
  1277 	CleanupStack::PushL(calendarFileName);
  1281 	CleanupStack::PushL(calendarFileName);
  1281 		{
  1285 		{
  1282 		iNewCalSession = NULL;
  1286 		iNewCalSession = NULL;
  1283 		iNewEntryView  = NULL;
  1287 		iNewEntryView  = NULL;
  1284 		iNewEntryViewCreation  = NULL;
  1288 		iNewEntryViewCreation  = NULL;
  1285 		TPtrC calFileName = fileMapping->GetCalendarFileName();
  1289 		TPtrC calFileName = fileMapping->GetCalendarFileName();
  1286 		CleanupStack::PushL(aCalendarInfo);
       
  1287 		CCalSession& tempSession = CreateNewSessionL( calFileName,
  1290 		CCalSession& tempSession = CreateNewSessionL( calFileName,
  1288 													*aCalendarInfo );
  1291 													*aCalendarInfo );
  1289 		fileMapping->SetSessionPtr(&tempSession);
  1292 		fileMapping->SetSessionPtr(&tempSession);
  1290 		fileMapping->SetCollectionId(tempSession.CollectionIdL());
  1293 		fileMapping->SetCollectionId(tempSession.CollectionIdL());
  1291 		
  1294 		
  1295 			}
  1298 			}
  1296 		fileMapping->SetEntryView( iNewEntryView );
  1299 		fileMapping->SetEntryView( iNewEntryView );
  1297 		CCalenDbChangeNotifier* dbChangeNotifier = CCalenDbChangeNotifier::NewL( tempSession );
  1300 		CCalenDbChangeNotifier* dbChangeNotifier = CCalenDbChangeNotifier::NewL( tempSession );
  1298 		dbChangeNotifier->RegisterObserverL(*iDBChangeNotifier);
  1301 		dbChangeNotifier->RegisterObserverL(*iDBChangeNotifier);
  1299 		fileMapping->SetDBChangeNotifier(dbChangeNotifier);
  1302 		fileMapping->SetDBChangeNotifier(dbChangeNotifier);
  1300 		CleanupStack::PopAndDestroy(aCalendarInfo);
       
  1301 		iCalendarInfoList.Append(tempSession.CalendarInfoL());
  1303 		iCalendarInfoList.Append(tempSession.CalendarInfoL());
  1302 		}
  1304 		}
  1303 
  1305 	
  1304 	CleanupStack::Pop(fileMapping);
  1306 	CleanupStack::Pop(fileMapping);
  1305 	iFileMappingArray.Append(fileMapping);
  1307 	iFileMappingArray.Append(fileMapping);
  1306 	
  1308 	
  1307 	iHashDbidIndexMap.Close();   
  1309 	iHashDbidIndexMap.Close();   
  1308 	for(TInt index = 0; index < iFileMappingArray.Count(); index++)
  1310 	for(TInt index = 0; index < iFileMappingArray.Count(); index++)
  1309 	    {
  1311 	    {
  1310 	    iHashDbidIndexMap.InsertL( iFileMappingArray[index]->GetCollectionId(),
  1312 	    iHashDbidIndexMap.InsertL( iFileMappingArray[index]->GetCollectionId(),
  1311                                    index);
  1313                                    index);
  1312 	    }
  1314 	    }
       
  1315 	
       
  1316 	CleanupStack::PopAndDestroy(aCalendarInfo);
       
  1317 	aCalendarInfo = NULL;
  1313 	
  1318 	
  1314 	TRACE_EXIT_POINT
  1319 	TRACE_EXIT_POINT
  1315 	}
  1320 	}
  1316 
  1321 
  1317 // -----------------------------------------------------------------------------
  1322 // -----------------------------------------------------------------------------
  1413                 caleninfo->SetPropertyL(keyBuff, pkgSoftDelete);
  1418                 caleninfo->SetPropertyL(keyBuff, pkgSoftDelete);
  1414                 
  1419                 
  1415                 session->SetCalendarInfoL( *caleninfo );
  1420                 session->SetCalendarInfoL( *caleninfo );
  1416                 CleanupStack::PopAndDestroy(caleninfo);            
  1421                 CleanupStack::PopAndDestroy(caleninfo);            
  1417                 }
  1422                 }
       
  1423             
       
  1424             TRAP_IGNORE(DeleteCalendarMissedAlarmsL(aCalendarFileName));
       
  1425             
  1418             TInt infoListIndex = iCalendarInfoList.Find(*calendarFilename,
  1426             TInt infoListIndex = iCalendarInfoList.Find(*calendarFilename,
  1419                         CCalenGlobalData::CalenCalendarInfoIdentiferL);
  1427                         CCalenGlobalData::CalenCalendarInfoIdentiferL);
  1420             
  1428             
  1421             CCalCalendarInfo* calendarInfo = iCalendarInfoList[infoListIndex];
  1429             CCalCalendarInfo* calendarInfo = iCalendarInfoList[infoListIndex];
  1422             iCalendarInfoList.Remove(infoListIndex);
  1430             iCalendarInfoList.Remove(infoListIndex);
  1641 	{
  1649 	{
  1642 	TRACE_ENTRY_POINT;
  1650 	TRACE_ENTRY_POINT;
  1643 
  1651 
  1644 	CCalCalendarInfo* defaultCalendarInfo = CCalCalendarInfo::NewL();
  1652 	CCalCalendarInfo* defaultCalendarInfo = CCalCalendarInfo::NewL();
  1645 	CleanupStack::PushL(defaultCalendarInfo);
  1653 	CleanupStack::PushL(defaultCalendarInfo);
  1646 	defaultCalendarInfo->SetColor(KRgbRed.Value());
  1654 	defaultCalendarInfo->SetColor(KCalenBlue.Value());
  1647 	defaultCalendarInfo->SetEnabled(ETrue);
  1655 	defaultCalendarInfo->SetEnabled(ETrue);
  1648 	defaultCalendarInfo->SetNameL(KPhoneCalendar);
  1656 	defaultCalendarInfo->SetNameL(KPhoneCalendar);
  1649 	CleanupStack::Pop(defaultCalendarInfo);
  1657 	CleanupStack::Pop(defaultCalendarInfo);
  1650 
  1658 
  1651 	TRACE_EXIT_POINT;
  1659 	TRACE_EXIT_POINT;
  1771 	RemoveCalendarL(fileName);
  1779 	RemoveCalendarL(fileName);
  1772 	
  1780 	
  1773 	TRACE_EXIT_POINT;
  1781 	TRACE_EXIT_POINT;
  1774 	}
  1782 	}
  1775 
  1783 
       
  1784 // -----------------------------------------------------------------------------
       
  1785 // CCalenGlobalData::DeleteCalendarMissedAlarmsL
       
  1786 // Delete all missed alarms for deleted calendar 
       
  1787 // -----------------------------------------------------------------------------
       
  1788 //
       
  1789 void CCalenGlobalData::DeleteCalendarMissedAlarmsL(const TDesC& aCalendarFilename)
       
  1790     {
       
  1791     TRACE_ENTRY_POINT
       
  1792     //Clear all missed alarms related to this calendar
       
  1793     CMissedAlarmStore* missedAlarmStore = CMissedAlarmStore::NewLC();
       
  1794     RPointerArray<CMissedAlarm> missedAlarms;
       
  1795     CleanupResetAndDestroyPushL(missedAlarms);
       
  1796 
       
  1797     missedAlarmStore->GetL(missedAlarms);
       
  1798 
       
  1799     for (TInt idx = 0; idx < missedAlarms.Count(); idx++)
       
  1800         {
       
  1801         CMissedAlarm* missedAlarm = missedAlarms[idx];
       
  1802         if (!missedAlarm->iCalFileName.CompareF(aCalendarFilename))
       
  1803             {
       
  1804             missedAlarmStore->RemoveL(*missedAlarm);
       
  1805             }
       
  1806         }
       
  1807 
       
  1808     CleanupStack::PopAndDestroy(&missedAlarms);
       
  1809     CleanupStack::PopAndDestroy(missedAlarmStore);
       
  1810     TRACE_EXIT_POINT    
       
  1811     }
       
  1812 
  1776 // End of file
  1813 // End of file