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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MMSVSTOREMANAGER_H__
17 #define __MMSVSTOREMANAGER_H__
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.
32 class MMsvStoreManager
36 Allows clients to create a new empty file and allows clients to stream data to it.
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.
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.
47 virtual TBool CreateAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)=0;
50 Allows clients to replace an existing attachment file and allows clients to stream data to it.
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.
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.
61 virtual void ReplaceAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)=0;
64 Allows clients to view attachment files.
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.
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.
75 virtual void OpenAttachmentL(TMsvId aEntryId, const TDesC& aFilePath, RFile& aFile)=0;
78 Allows clients to open an attachment file for writing.
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.
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.
89 virtual void OpenAttachmentForWriteL(TMsvId aEntryId, const TDesC& aFilePath, RFile& aFile)=0;
93 Allow clients to delete existing attachment files.
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.
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.
103 virtual TInt DeleteAttachment(TMsvId aEntryId, const TDesC& aFilePath)=0;
106 Renames an existing attachment file.
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.
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.
118 virtual TInt RenameAttachment(TMsvId aEntryId, const TDesC& aOldFilePath, const TDesC& aNewName) = 0;
121 Check if an attachment file with the given path and name already exists.
123 @param aFilePath The full path specification of the file.
124 @return ETrue if file exists, otherwise EFalse.
126 virtual TBool FileExistsL(const TDesC& aFilePath)=0;
129 Queries the message server for the file path where attachments are stored for the
130 a particular message entry.
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.
135 virtual void AttachmentFilePathL(TMsvId aEntryId, TDes& aFilePath) = 0;
137 // To support CMsvStore to provide message store file management.
139 Allows the message store classes to read the store file for a particular message entry.
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.
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
148 virtual TInt OpenFileStoreForRead(TMsvId aEntryId, RFile& aFile)=0;
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.
157 Along with ReplaceFileStoreL, this method allows the message store classes to write data
158 to the store file for a particular message entry.
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.
163 virtual void OpenTempStoreFileL(TMsvId aEntryId, RFile& aFile)=0;
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.
171 Along with OpenTempStoreFileL, this method allows the message store classes to write data to the store
172 file for a particular message entry.
174 @param aEntryId The entry whose store needs to be replaced/overwritten
176 virtual void ReplaceFileStoreL(TMsvId aEntryId)=0;
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.
182 @param aEntryId The entry whose store needs to be deleted
184 virtual void DeleteFileStoreL(TMsvId aEntryId)=0;
187 Queries the message server to check if a store file exists for the message entry specified by
188 the aEntryId parameter.
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
193 virtual TBool FileStoreExistsL(TMsvId aEntryId) const=0;
196 Creates an Attachment using a ShareProtected RFs.Used in the case when a message contains a DRM attachment
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.
203 virtual TBool CreateShareProtectedAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile) = 0;
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.
211 virtual void BodyTextFilePathL(TMsvId aMessageId, TDes& aFilepath) = 0;
214 Allows the message store classes to read the store file for a particular message entry.
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.
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
224 virtual void OpenBodyTextFileForReadL(RFile& aFile, TMsvId aBodyTextId, const TDesC& aFilePath) = 0;
227 Allows the message store classes to create the store file for a particular message entry.
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.
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.
236 virtual void CreatePlainTextFileL(RFile& aFile, TMsvId aBodyTextId) = 0;
239 Deletes the store file associated with the message entry as specified by aFilepath.
241 @param aBodyTextId The Id of the bodytext.
242 @leave KErrNotFound if file is not found else any of the system wide errors
244 virtual void DeletePlainTextFileL(TMsvId aBodyTextId) = 0;
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
251 virtual void ReplacePlainTextFileL(TMsvId aBodyTextId) = 0;
254 #endif // __MMSVSTOREMANAGER_H__