877 iMessageArray[0].iActionType, iMessageArray[0].iFolderId); |
877 iMessageArray[0].iActionType, iMessageArray[0].iFolderId); |
878 |
878 |
879 // Remove item that is handled |
879 // Remove item that is handled |
880 iMessageArray.Remove(0); |
880 iMessageArray.Remove(0); |
881 } |
881 } |
|
882 |
|
883 if( iMessageArray.Count() <= 0 ) |
|
884 { |
|
885 if( BaflUtils::FileExists( iFs, iFilePath )) |
|
886 BaflUtils::DeleteFile( iFs, iFilePath ); |
|
887 } |
|
888 |
882 OstTraceFunctionExit0( CMESSAGEDATAHANDLER_RESUMEL_EXIT ); |
889 OstTraceFunctionExit0( CMESSAGEDATAHANDLER_RESUMEL_EXIT ); |
883 } |
890 } |
884 |
891 |
|
892 void CMessageDataHandler::SetFilePath(const TDesC& aFilePath) |
|
893 { |
|
894 iFilePath.Copy(aFilePath); |
|
895 } |
|
896 |
|
897 void CMessageDataHandler::SaveRecordsL() |
|
898 { |
|
899 if(iMessageArray.Count() <= 0) |
|
900 return; |
|
901 |
|
902 // Open the stream |
|
903 RFile file; |
|
904 User::LeaveIfError(file.Replace(iFs, iFilePath, EFileWrite)); |
|
905 CleanupClosePushL(file); |
|
906 |
|
907 RFileWriteStream wr(file); |
|
908 wr.PushL(); |
|
909 |
|
910 // Write harvester count |
|
911 wr.WriteInt32L(iMessageArray.Count()); |
|
912 |
|
913 for (TInt i=0; i<iMessageArray.Count(); i++) |
|
914 { |
|
915 wr.WriteInt32L(iMessageArray[i].iMessageId); |
|
916 wr.WriteInt16L(iMessageArray[i].iActionType); |
|
917 wr.WriteInt32L(iMessageArray[i].iFolderId); |
|
918 } |
|
919 // Commit and cleanup |
|
920 wr.CommitL(); |
|
921 CleanupStack::PopAndDestroy(2, &file); |
|
922 } |
|
923 |
|
924 void CMessageDataHandler::LoadRecordsL() |
|
925 { |
|
926 // Open the stream |
|
927 RFile file; |
|
928 User::LeaveIfError(file.Open(iFs, iFilePath, EFileRead)); |
|
929 CleanupClosePushL(file); |
|
930 RFileReadStream rd(file); |
|
931 rd.PushL(); |
|
932 |
|
933 // Read harvester count |
|
934 TInt count = rd.ReadInt32L(); |
|
935 // Read the harvesters |
|
936 for (TInt i=0; i<count; i++) |
|
937 { |
|
938 TMsvId MessageId = rd.ReadInt32L(); |
|
939 TCPixActionType ActionType = static_cast<TCPixActionType> ( rd.ReadInt16L()); |
|
940 TMsvId FolderId = rd.ReadInt32L(); |
|
941 TMessageItem record( MessageId, ActionType, FolderId ); |
|
942 iMessageArray.AppendL( record ); |
|
943 } |
|
944 HandleNextRequest(); |
|
945 // Cleanup |
|
946 CleanupStack::PopAndDestroy(2, &file); |
|
947 } |
|
948 |
885 // End of File |
949 // End of File |
886 |
950 |