116 } |
116 } |
117 |
117 |
118 const CAgnServFile& CAgnEntryModel::AgnServFile() |
118 const CAgnServFile& CAgnEntryModel::AgnServFile() |
119 { |
119 { |
120 return *iAgnServerFile; |
120 return *iAgnServerFile; |
|
121 } |
|
122 |
|
123 /** |
|
124 * Resets delete rollback array before the callback |
|
125 */ |
|
126 void CAgnEntryModel::ResetDeleteRollbackArray() |
|
127 { |
|
128 iDeleteRollbackArray.ResetAndDestroy(); |
121 } |
129 } |
122 |
130 |
123 /** Load up the stream network |
131 /** Load up the stream network |
124 */ |
132 */ |
125 void CAgnEntryModel::DoOpenL(const TStreamId& aModelStreamId) |
133 void CAgnEntryModel::DoOpenL(const TStreamId& aModelStreamId) |
1396 // This method marks the index file as dirty (i.e. out of sync with the indices |
1404 // This method marks the index file as dirty (i.e. out of sync with the indices |
1397 // in RAM) by deleting it. A flag is kept internally to allow us to know that the |
1405 // in RAM) by deleting it. A flag is kept internally to allow us to know that the |
1398 // file needs to be rebuilt and to no try to delete the file more than once. |
1406 // file needs to be rebuilt and to no try to delete the file more than once. |
1399 void CAgnEntryModel::MarkIndexFileAsDirtyL() |
1407 void CAgnEntryModel::MarkIndexFileAsDirtyL() |
1400 { |
1408 { |
1401 if (iIndexFileIsDirty) |
1409 |
1402 { |
1410 if(IsIndexFileAvailableL()) |
1403 return; // the file is already marked as dirty |
1411 { |
1404 } |
1412 TFileName idxfilename; |
1405 |
1413 if (!GenerateIndexFileName(idxfilename)) |
1406 TFileName idxfilename; |
1414 { |
1407 if (!GenerateIndexFileName(idxfilename)) |
1415 User::Leave(KErrBadName); |
1408 { |
1416 } |
1409 User::Leave(KErrBadName); |
1417 |
1410 } |
1418 TInt connectErr = iFs.Connect(); |
1411 |
1419 User::LeaveIfError(connectErr); |
1412 TInt connectErr = iFs.Connect(); |
1420 |
1413 User::LeaveIfError(connectErr); |
1421 iFs.Delete(idxfilename); // ignore return as there is nothing we can do with it |
1414 |
1422 } |
1415 iFs.Delete(idxfilename); // ignore return as there is nothing we can do with it |
|
1416 |
|
1417 iIndexFileIsDirty = ETrue; |
1423 iIndexFileIsDirty = ETrue; |
1418 } |
1424 } |
1419 |
1425 |
1420 // This method allows clients of the model to determine if the index file is |
1426 // This method allows clients of the model to determine if the index file is |
1421 // dirty and therefore in need of being rewritten with the current data. |
1427 // dirty and therefore in need of being rewritten with the current data. |
1510 MarkIndexFileAsDirtyL(); |
1516 MarkIndexFileAsDirtyL(); |
1511 iIndexFileIsPresent = EFalse; |
1517 iIndexFileIsPresent = EFalse; |
1512 return EFalse; |
1518 return EFalse; |
1513 } |
1519 } |
1514 |
1520 |
|
1521 // This method check the index file is exist. |
|
1522 // It returns: |
|
1523 // ETrue - File is already exist |
|
1524 // EFalse - File is not available |
|
1525 TBool CAgnEntryModel::IsIndexFileAvailableL() |
|
1526 { |
|
1527 TFileName idxfilename; |
|
1528 if (!GenerateIndexFileName(idxfilename)) |
|
1529 { |
|
1530 User::Leave(KErrBadName); |
|
1531 } |
|
1532 |
|
1533 TInt connectErr = iFs.Connect(); |
|
1534 User::LeaveIfError(connectErr); |
|
1535 |
|
1536 RFile idxFile; |
|
1537 TInt errReadIdx = idxFile.Open(iFs, idxfilename, EFileRead); |
|
1538 CleanupClosePushL(idxFile); |
|
1539 if((errReadIdx == KErrNotFound)) |
|
1540 { |
|
1541 CleanupStack::PopAndDestroy(); |
|
1542 return EFalse; |
|
1543 } |
|
1544 CleanupStack::PopAndDestroy(&idxFile); |
|
1545 return ETrue; |
|
1546 } |
1515 |
1547 |
1516 // This method attempts to save all indices to the index file. |
1548 // This method attempts to save all indices to the index file. |
1517 // If any errors are encountered it will Leave. |
1549 // If any errors are encountered it will Leave. |
1518 // Clients of this method should TRAP the Leave and possibly |
1550 // Clients of this method should TRAP the Leave and possibly |
1519 // mark the file as dirty or try to delete it. |
1551 // mark the file as dirty or try to delete it. |