pimappservices/calendar/server/src/agsentrymodel.cpp
branchRCL_3
changeset 30 d68a4b5d5885
parent 13 0f07cd1b5772
child 86 ed599363c2d7
equal deleted inserted replaced
27:55d60436f00b 30:d68a4b5d5885
    83         iExtractor = new (ELeave) TAgnInstanceExtractor(*iSimpleEntryTable);
    83         iExtractor = new (ELeave) TAgnInstanceExtractor(*iSimpleEntryTable);
    84 		iCategoryIndex = CAgnCategoryIndex::NewL();
    84 		iCategoryIndex = CAgnCategoryIndex::NewL();
    85 		iAttachmentIndex = new (ELeave) CAgnAttachmentIndex;
    85 		iAttachmentIndex = new (ELeave) CAgnAttachmentIndex;
    86 		CreateAlarmForServerL();
    86 		CreateAlarmForServerL();
    87 		}
    87 		}
       
    88 	
       
    89 	User::LeaveIfError(iFs.Connect());
       
    90     User::LeaveIfError( iFs.ShareProtected() );
       
    91     
    88 	iIndexFileIsDirty = ETrue; 	// for safety assume that the index
    92 	iIndexFileIsDirty = ETrue; 	// for safety assume that the index
    89 					// file is out of date. We can correct this
    93 					// file is out of date. We can correct this
    90 					// when we read the file
    94 					// when we read the file
    91 
    95 
    92 	iIndexFileIsPresent = ETrue; // Assume the index file is present. 
    96 	iIndexFileIsPresent = ETrue; // Assume the index file is present. 
   111 	delete iSimpleEntryTable;
   115 	delete iSimpleEntryTable;
   112 	delete iAlarm;
   116 	delete iAlarm;
   113 	delete iModelStreamIdSet;
   117 	delete iModelStreamIdSet;
   114 	delete iEntryManager;
   118 	delete iEntryManager;
   115 	delete iCalConverter;
   119 	delete iCalConverter;
       
   120 	iFs.Close();
   116 	}
   121 	}
   117 
   122 
   118 const CAgnServFile& CAgnEntryModel::AgnServFile()
   123 const CAgnServFile& CAgnEntryModel::AgnServFile()
   119 	{
   124 	{
   120 	return *iAgnServerFile;
   125 	return *iAgnServerFile;
  1413         {		
  1418         {		
  1414             TFileName idxfilename;
  1419             TFileName idxfilename;
  1415             if (!GenerateIndexFileName(idxfilename))
  1420             if (!GenerateIndexFileName(idxfilename))
  1416                 {
  1421                 {
  1417                 User::Leave(KErrBadName);
  1422                 User::Leave(KErrBadName);
  1418                 }
  1423                 }           
  1419             
  1424             iFs.Delete(idxfilename); // ignore return as there is nothing we can do with it           
  1420             TInt connectErr = iFs.Connect();
       
  1421             User::LeaveIfError(connectErr);
       
  1422             
       
  1423             iFs.Delete(idxfilename); // ignore return as there is nothing we can do with it
       
  1424         }        
  1425         }        
  1425 	iIndexFileIsDirty = ETrue;
  1426 	iIndexFileIsDirty = ETrue;
  1426 	}
  1427 	}
  1427 	
  1428 	
  1428 // This method allows clients of the model to determine if the index file is
  1429 // This method allows clients of the model to determine if the index file is
  1453 	if (!GenerateIndexFileName(idxfilename))
  1454 	if (!GenerateIndexFileName(idxfilename))
  1454 		{
  1455 		{
  1455 		User::Leave(KErrBadName);
  1456 		User::Leave(KErrBadName);
  1456 		}
  1457 		}
  1457 	
  1458 	
  1458 	TInt connectErr = iFs.Connect();
       
  1459 	User::LeaveIfError(connectErr);
       
  1460 	
       
  1461 	RFile idxFile;
  1459 	RFile idxFile;
  1462 	TInt errReadIdx = idxFile.Open(iFs, idxfilename, EFileRead);
  1460 	TInt errReadIdx = idxFile.Open(iFs, idxfilename, EFileRead);
  1463 	CleanupClosePushL(idxFile);
  1461 	CleanupClosePushL(idxFile);
  1464 	
  1462 	
  1465 	if (errReadIdx == KErrNone)    // we have a file
  1463 	if (errReadIdx == KErrNone)    // we have a file
  1529     TFileName idxfilename;
  1527     TFileName idxfilename;
  1530     if (!GenerateIndexFileName(idxfilename))
  1528     if (!GenerateIndexFileName(idxfilename))
  1531         {
  1529         {
  1532         User::Leave(KErrBadName);
  1530         User::Leave(KErrBadName);
  1533         }
  1531         }
  1534     
  1532    
  1535     TInt connectErr = iFs.Connect();
       
  1536     User::LeaveIfError(connectErr);
       
  1537     
       
  1538     RFile idxFile;
  1533     RFile idxFile;
  1539     TInt errReadIdx = idxFile.Open(iFs, idxfilename, EFileRead);
  1534     TInt errReadIdx = idxFile.Open(iFs, idxfilename, EFileRead);
  1540     CleanupClosePushL(idxFile);
  1535     CleanupClosePushL(idxFile);
  1541     if((errReadIdx == KErrNotFound))
  1536     if((errReadIdx == KErrNotFound))
  1542         {
  1537         {
  1556 	TFileName idxfilename;
  1551 	TFileName idxfilename;
  1557 	if (!GenerateIndexFileName(idxfilename))
  1552 	if (!GenerateIndexFileName(idxfilename))
  1558 		{
  1553 		{
  1559 		User::Leave(KErrBadName);
  1554 		User::Leave(KErrBadName);
  1560 		}
  1555 		}
  1561 	TInt connectErr = iFs.Connect();
  1556 	
  1562 	User::LeaveIfError(connectErr);
       
  1563 
       
  1564 	RFile idxFile;
  1557 	RFile idxFile;
  1565 	TInt errWriteIdx = idxFile.Replace(iFs, idxfilename, EFileWrite);
  1558 	TInt errWriteIdx = idxFile.Replace(iFs, idxfilename, EFileWrite);
  1566 	User::LeaveIfError(errWriteIdx);
  1559 	User::LeaveIfError(errWriteIdx);
  1567 	CleanupClosePushL(idxFile);
  1560 	CleanupClosePushL(idxFile);
  1568 	
  1561 	
  2709 		_DBGLOG_ENTRY(AgmDebug::DebugLog("UpdateEntryL: DoUpdateEntryL failed: Leaving with error - %d",ret);)
  2702 		_DBGLOG_ENTRY(AgmDebug::DebugLog("UpdateEntryL: DoUpdateEntryL failed: Leaving with error - %d",ret);)
  2710 		User::Leave(ret);
  2703 		User::Leave(ret);
  2711 		}
  2704 		}
  2712 
  2705 
  2713 	NotifyingL(MCalChangeCallBack2::EChangeModify, aEntry, instanceInfoBefore);
  2706 	NotifyingL(MCalChangeCallBack2::EChangeModify, aEntry, instanceInfoBefore);
       
  2707 	
       
  2708 	if(iChangeFilter && iTzRuleIndex)
       
  2709         {
       
  2710         //Remove the tz rule from tz rule index
       
  2711         //we have to do it after CAgnEntryModel::NotifyingL that is indirectly using the
       
  2712         //tz rule in oldEntry.
       
  2713         iTzRuleIndex->RemoveTzRuleL(*oldEntry);
       
  2714         }
       
  2715   
  2714 	
  2716 	
  2715 	CleanupStack::PopAndDestroy(instanceInfoBefore);
  2717 	CleanupStack::PopAndDestroy(instanceInfoBefore);
  2716 	CleanupStack::PopAndDestroy(oldEntry);
  2718 	CleanupStack::PopAndDestroy(oldEntry);
  2717 	
  2719 	
  2718 	// Delete the old alarm and if a new alarm exists it will be added by findAndQueue
  2720 	// Delete the old alarm and if a new alarm exists it will be added by findAndQueue