|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Container store content manager. |
|
15 * |
|
16 */ |
|
17 #ifndef __CONTAINER_STORE_CONTENT_MANAGER_H__ |
|
18 #define __CONTAINER_STORE_CONTENT_MANAGER_H__ |
|
19 |
|
20 |
|
21 |
|
22 // ======== |
|
23 // INCLUDES |
|
24 // ======== |
|
25 |
|
26 #include <e32base.h> |
|
27 //<cmail> |
|
28 #include "DebugLogMacros.h" |
|
29 //</cmail> |
|
30 |
|
31 #include "ContainerStore.h" |
|
32 |
|
33 // ==================== |
|
34 // FORWARD DECLARATIONS |
|
35 // ==================== |
|
36 |
|
37 class CContainerStoreUtils; |
|
38 class CContainerStoreEncryption; |
|
39 class CBufferedReader; |
|
40 class CBufferedWriter; |
|
41 |
|
42 // ======= |
|
43 // CLASSES |
|
44 // ======= |
|
45 |
|
46 class CContainerStoreContentManager : public CBase |
|
47 { |
|
48 public: |
|
49 |
|
50 static CContainerStoreContentManager* NewL( CContainerStoreUtils& aUtils, |
|
51 CContainerStoreEncryption& aEncryption ); |
|
52 |
|
53 virtual ~CContainerStoreContentManager(); |
|
54 |
|
55 static void WipeContentFiles( RFs& aFs ); |
|
56 |
|
57 TUint ContentLengthL( TContainerId aId, TBool aIsEncrypted ); |
|
58 |
|
59 void ReplaceContentL( TContainerId aId, |
|
60 const TDesC8& aContent, |
|
61 TBool aIsContentEncrypted ); |
|
62 |
|
63 |
|
64 void ReplaceContentL( TContainerId aId, |
|
65 RFile& aContentFile, |
|
66 TBool aIsContentEncrypted ); |
|
67 |
|
68 void AppendContentL( TContainerId aId, |
|
69 const TDesC8& aContent, |
|
70 TBool aIsContentEncrypted ); |
|
71 |
|
72 void PrependContentL( TContainerId aId, |
|
73 const TDesC8& aContent, |
|
74 TBool aIsContentEncrypted ); |
|
75 |
|
76 void RemoveContentL( TContainerId aId ); |
|
77 |
|
78 // will truncate the content if the content buffer is too small |
|
79 void FetchContentL( TContainerId aId, |
|
80 TDes8& aContent, |
|
81 TBool aIsContentEncrypted, |
|
82 TUint aStartPosition = 0 ); |
|
83 |
|
84 void FetchContentL( TContainerId aId, |
|
85 RFile& aDestinationFile, |
|
86 TBool aIsContentEncrypted ); |
|
87 |
|
88 void OpenContentFileL( TContainerId aId, |
|
89 RFs& aFs, |
|
90 RFile& aFile, |
|
91 TBool aIsContentEncrypted ); |
|
92 |
|
93 |
|
94 void CopyContentL( TContainerId aOldId, |
|
95 TContainerId aNewId ); |
|
96 |
|
97 TBool SearchContentL( TContainerId aContainerId, |
|
98 const TDesC& aSearchString, |
|
99 TDes8& aSearchBuffer, |
|
100 TBool aIsContentEncrypted ); |
|
101 |
|
102 void EncryptL( TContainerId aId ); |
|
103 void DecryptL( TContainerId aId ); |
|
104 |
|
105 void StartCopyTransaction(); |
|
106 void RollbackCopyTransaction(); |
|
107 |
|
108 /** |
|
109 * Transfer the ownership of an external content file to the content |
|
110 * manager. |
|
111 * @param aContentPath path and file name of an existing content file |
|
112 */ |
|
113 TInt TransferContentFile( |
|
114 TContainerId aId, |
|
115 const TDesC& aContentPath ); |
|
116 |
|
117 |
|
118 private: |
|
119 |
|
120 CContainerStoreContentManager( CContainerStoreUtils& aUtils, |
|
121 CContainerStoreEncryption& aEncryption ); |
|
122 |
|
123 void ConstructL(); |
|
124 |
|
125 void CleanupTemporaryFile(); |
|
126 |
|
127 void CreateContentSubdirectoriesL(); |
|
128 |
|
129 void ContentFilename( TContainerId aId, TDes& aFilename ); |
|
130 |
|
131 void CommitTemporaryFileL( TInt aResult, TContainerId aContainerId ); |
|
132 |
|
133 TBool EncryptAndWriteNextBlockL( CBufferedWriter& aBufferedWriter, |
|
134 const TDesC8& aPlaintextBuffer ); |
|
135 |
|
136 TBool ReadNextBlockL( CBufferedReader& aBufferedReader, |
|
137 TDes8& aPlaintextBlock, |
|
138 TBool aIsContentEncrypted = ETrue ); |
|
139 |
|
140 void UpdateBlockSizeL( TBool isEncrypted ); |
|
141 |
|
142 TInt FindVomitCode( TPtr16& aBody ); |
|
143 |
|
144 private: |
|
145 |
|
146 CContainerStoreUtils& iUtils; |
|
147 CContainerStoreEncryption& iEncryption; |
|
148 RFs& iFs; |
|
149 TFileName iTemporaryFilename; |
|
150 TFileName iEncryptDecryptTempFilename; |
|
151 TInt iBlockSize; |
|
152 //used to store content file ids when copying a message so they can be |
|
153 //rolled back if the transaction fails. |
|
154 RArray<TContainerId> iCopiedContentFiles; |
|
155 |
|
156 __LOG_DECLARATION |
|
157 |
|
158 }; // end CContainerStoreContentManager |
|
159 |
|
160 #endif |