|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __MMSVSTOREMANAGER_H__ |
|
17 #define __MMSVSTOREMANAGER_H__ |
|
18 |
|
19 #include <msvstd.h> |
|
20 |
|
21 /** |
|
22 Provides the File Access mechanism to the files that are stored in the message server's |
|
23 data cage in a secure manner. Presents a common interface to message store file access |
|
24 regardless of the process that its running in. |
|
25 For instance, when the File Access APIs are used on the client-side process, the implementation |
|
26 uses secure IPC calls to the message server that includes capability policing, however, |
|
27 when the same API is used on the server-side, the implementation has direct access to |
|
28 the file in the message store. |
|
29 |
|
30 @internalTechnology |
|
31 */ |
|
32 class MMsvStoreManager |
|
33 { |
|
34 public: |
|
35 /** |
|
36 Allows clients to create a new empty file and allows clients to stream data to it. |
|
37 |
|
38 Creates a new attachment file in the message store for the message entry specified by the aEntryId |
|
39 parameter. The attachment filename is set to the filename indicated by the aFilename parameter. |
|
40 The empty attachment file is passed back to the client using an opened file handle to the file in the message store. |
|
41 |
|
42 @param aEntryId The entry for which an attachment needs to be created in the message store |
|
43 @param aFilename The name of the attachment file to be created |
|
44 @param aFile On return, The created file handle for the attachment file.The ownership is transferred . The caller must close the file handle. |
|
45 @leave KErrAlreadyexists, if the file with the same name already existed the directory. |
|
46 */ |
|
47 virtual TBool CreateAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)=0; |
|
48 |
|
49 /** |
|
50 Allows clients to replace an existing attachment file and allows clients to stream data to it. |
|
51 |
|
52 Replaces an existing attachment file in the message store for the message entry specified by the aEntryId |
|
53 parameter. The attachment filename is set to the filename indicated by the aFilename parameter. |
|
54 If an attachment with the supplied name does not exist, a new file is created. The empty attachment |
|
55 file is passed back to the client using an opened file handle to the file in the message store. |
|
56 |
|
57 @param aEntryId The entry for which an attachment needs to be created in the message store |
|
58 @param aFilename The name of the attachment file to be created |
|
59 @param aFile On return, The created file handle for the attachment file.The ownership is transferred . The caller must close the file handle. |
|
60 */ |
|
61 virtual void ReplaceAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)=0; |
|
62 |
|
63 /** |
|
64 Allows clients to view attachment files. |
|
65 |
|
66 Opens an existing attachment file in the message associated with the message |
|
67 entry specified by the aEntryId parameter. The attachment is identified by |
|
68 the file path specified by the aFilePath parameter. The attachment file is |
|
69 returned as a read-only file handle to the file in the message store. |
|
70 |
|
71 @param aEntryId The entry whose attachment needs to be opened/read from the message store |
|
72 @param aFilePath The name and path of the attachment file to be opened |
|
73 @param aFile On return, The opened file handle for the attachment file.The ownership is transferred . The caller must close the file handle. |
|
74 */ |
|
75 virtual void OpenAttachmentL(TMsvId aEntryId, const TDesC& aFilePath, RFile& aFile)=0; |
|
76 |
|
77 /** |
|
78 Allows clients to open an attachment file for writing. |
|
79 |
|
80 Opens an existing attachment file in the message associated with the message |
|
81 entry specified by the aEntryId parameter. The attachment is identified by |
|
82 the file path specified by the aFilePath parameter. The attachment file is |
|
83 returned as a read/write file handle to the file in the message store. |
|
84 |
|
85 @param aEntryId The entry whose attachment needs to be opened/read from the message store |
|
86 @param aFilePath The name and path of the attachment file to be opened |
|
87 @param aFile On return, The opened file handle for the attachment file.The ownership is transferred . The caller must close the file handle. |
|
88 */ |
|
89 virtual void OpenAttachmentForWriteL(TMsvId aEntryId, const TDesC& aFilePath, RFile& aFile)=0; |
|
90 |
|
91 |
|
92 /** |
|
93 Allow clients to delete existing attachment files. |
|
94 |
|
95 Deletes an existing attachment file in the message store associated with the |
|
96 message entry specified by the aEntryId parameter. The attachment is |
|
97 identified by the file path specified by the aFilePath parameter. |
|
98 |
|
99 @param aEntryId The entry whose attachment needs to be deleted from the message store |
|
100 @param aFilePath The name and path of the attachment file to be deleted |
|
101 @return KErrNone if successful, otherwise any of the system wide error codes. |
|
102 */ |
|
103 virtual TInt DeleteAttachment(TMsvId aEntryId, const TDesC& aFilePath)=0; |
|
104 |
|
105 /** |
|
106 Renames an existing attachment file. |
|
107 |
|
108 Renames an existing attachment file in the message store associated with the |
|
109 message entry specified by the aEntryId parameter. The attachment is |
|
110 identified by the file path specified by the aOldFilePath parameter and renamed to |
|
111 the name supplied in the aNewName paramter. |
|
112 |
|
113 @param aEntryId The entry whose attachment needs to be renamed from the message store |
|
114 @param aOldFilePath The name and path of the attachment file to be renamed. |
|
115 @param aNewName The new name of the attachment file. |
|
116 @return KErrNone if successful, otherwise any of the system wide error codes. |
|
117 */ |
|
118 virtual TInt RenameAttachment(TMsvId aEntryId, const TDesC& aOldFilePath, const TDesC& aNewName) = 0; |
|
119 |
|
120 /** |
|
121 Check if an attachment file with the given path and name already exists. |
|
122 |
|
123 @param aFilePath The full path specification of the file. |
|
124 @return ETrue if file exists, otherwise EFalse. |
|
125 */ |
|
126 virtual TBool FileExistsL(const TDesC& aFilePath)=0; |
|
127 |
|
128 /** |
|
129 Queries the message server for the file path where attachments are stored for the |
|
130 a particular message entry. |
|
131 |
|
132 @param aEntryId The message entry for which the attachment path is required. |
|
133 @param aFilePath On return, this will be set to the file path where the attachment should be stored. |
|
134 */ |
|
135 virtual void AttachmentFilePathL(TMsvId aEntryId, TDes& aFilePath) = 0; |
|
136 |
|
137 // To support CMsvStore to provide message store file management. |
|
138 /** |
|
139 Allows the message store classes to read the store file for a particular message entry. |
|
140 |
|
141 Opens a message store file associated with the message entry specified by the aEntryId parameter. |
|
142 This method returns an open read-only file handle to the message store file. |
|
143 |
|
144 @param aEntryId The entry whose store needs to be opened/read |
|
145 @param aFile On return, The opened file hanlde to the store . The ownership is transferred . The caller must close the file handle. |
|
146 @leave KErrNotFound if file is not found else any of the system wide errors |
|
147 */ |
|
148 virtual TInt OpenFileStoreForRead(TMsvId aEntryId, RFile& aFile)=0; |
|
149 |
|
150 /** |
|
151 Opens a temporary store file associated with the message entry specified by the aEntryId parameter. |
|
152 This method returns an open read-write file handle with an exclusive share to the temporary store file. |
|
153 The temporary store file is defined as \<store_filename\>.new. Data can be streamed to the temporary store file. |
|
154 It is expected that once the temporary store file has been written to and then closed, a call to |
|
155 ReplaceFileStoreL is required to replace the old store file with this temporary one. |
|
156 |
|
157 Along with ReplaceFileStoreL, this method allows the message store classes to write data |
|
158 to the store file for a particular message entry. |
|
159 |
|
160 @param aEntryId The entry whose store needs to be opened/read |
|
161 @param aFile On return, The opened file hanlde to the store . The ownership is transferred . The caller must close the file handle. |
|
162 */ |
|
163 virtual void OpenTempStoreFileL(TMsvId aEntryId, RFile& aFile)=0; |
|
164 |
|
165 /** |
|
166 Replaces the current store file with the temporary store file, created from OpenTempStoreFileL, |
|
167 for the message entry as specified by the aEntryId parameter. The method replaces the store file with |
|
168 the temporary file (<store_filename.new>) and if successful, will then delete the temporary store file. |
|
169 This method assumes that the temporary file exists, otherwise a KErrNotFound error occurs. |
|
170 |
|
171 Along with OpenTempStoreFileL, this method allows the message store classes to write data to the store |
|
172 file for a particular message entry. |
|
173 |
|
174 @param aEntryId The entry whose store needs to be replaced/overwritten |
|
175 */ |
|
176 virtual void ReplaceFileStoreL(TMsvId aEntryId)=0; |
|
177 |
|
178 /** |
|
179 Deletes the store file associated with the message entry as specified by the aEntryId. |
|
180 Also attempts to delete the temporary store file if one exists. |
|
181 |
|
182 @param aEntryId The entry whose store needs to be deleted |
|
183 */ |
|
184 virtual void DeleteFileStoreL(TMsvId aEntryId)=0; |
|
185 |
|
186 /** |
|
187 Queries the message server to check if a store file exists for the message entry specified by |
|
188 the aEntryId parameter. |
|
189 |
|
190 @param aEntryId The entry for whom the check for existance of store is being done |
|
191 @return ETrue if the store exists else EFalse |
|
192 */ |
|
193 virtual TBool FileStoreExistsL(TMsvId aEntryId) const=0; |
|
194 |
|
195 /** |
|
196 Creates an Attachment using a ShareProtected RFs.Used in the case when a message contains a DRM attachment |
|
197 |
|
198 @param aEntryId The entry for which an attachment needs to be created in the message store |
|
199 @param aFilename The name of the attachment file to be created |
|
200 @param aFile On return, The created file handle for the attachment file.The ownership is transferred . The caller must close the file handle. |
|
201 @leave KErrAlreadyexists, if the file with the same name already existed the directory. |
|
202 */ |
|
203 virtual TBool CreateShareProtectedAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile) = 0; |
|
204 |
|
205 /** |
|
206 Gets the path of the bodytext file related to a message in the message store for the message id passed to it. |
|
207 @param aBodyTextId The Id of the bodytext for which the path is required in the message store |
|
208 @param aFilename On return, The path of the file corresponding to the message Id passed. |
|
209 @leave KErrAlreadyexists, if the file with the same name already existed the directory. |
|
210 */ |
|
211 virtual void BodyTextFilePathL(TMsvId aMessageId, TDes& aFilepath) = 0; |
|
212 |
|
213 /** |
|
214 Allows the message store classes to read the store file for a particular message entry. |
|
215 |
|
216 Opens a message store file associated with the message entry specified by the aFilepath parameter. |
|
217 This method returns an open read-only file handle to the message store file. |
|
218 |
|
219 @param aFile On return, The opened file hanlde to the store . The ownership is transferred . The caller must close the file handle. |
|
220 @param aBodyTextId The Id of the bodytext. |
|
221 @param aFilepath The path of the file that needs to be opened/read |
|
222 @leave KErrNotFound if file is not found else any of the system wide errors |
|
223 */ |
|
224 virtual void OpenBodyTextFileForReadL(RFile& aFile, TMsvId aBodyTextId, const TDesC& aFilePath) = 0; |
|
225 |
|
226 /** |
|
227 Allows the message store classes to create the store file for a particular message entry. |
|
228 |
|
229 Creates a message store file associated with the message entry specified by the aFilepath parameter. |
|
230 This method returns an open read-write file handle to the message store file. |
|
231 |
|
232 @param aFile On return, The opened file hanlde to the store . The ownership is transferred . The caller must close the file handle. |
|
233 @param aBodyTextId The Id of the bodytext. |
|
234 @leave one of the other system-wide error codes. |
|
235 */ |
|
236 virtual void CreatePlainTextFileL(RFile& aFile, TMsvId aBodyTextId) = 0; |
|
237 |
|
238 /** |
|
239 Deletes the store file associated with the message entry as specified by aFilepath. |
|
240 |
|
241 @param aBodyTextId The Id of the bodytext. |
|
242 @leave KErrNotFound if file is not found else any of the system wide errors |
|
243 */ |
|
244 virtual void DeletePlainTextFileL(TMsvId aBodyTextId) = 0; |
|
245 |
|
246 /** |
|
247 Replaces the bodytext file associated with the message specified by aEntryId. |
|
248 @param aBodyTextId The Id of the bodytext. |
|
249 @leave KErrNotFound if file is not found else any of the system wide errors |
|
250 */ |
|
251 virtual void ReplacePlainTextFileL(TMsvId aBodyTextId) = 0; |
|
252 }; |
|
253 |
|
254 #endif // __MMSVSTOREMANAGER_H__ |